diff options
-rw-r--r-- | zephyr/CMakeLists.txt | 3 | ||||
-rw-r--r-- | zephyr/Kconfig.tasks | 41 | ||||
-rw-r--r-- | zephyr/Kconfig.usbc | 10 | ||||
-rw-r--r-- | zephyr/shim/include/shimmed_task_id.h | 9 | ||||
-rw-r--r-- | zephyr/shim/include/shimmed_tasks.h | 18 |
5 files changed, 78 insertions, 3 deletions
diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index 28620657d4..147375f0dc 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -91,6 +91,9 @@ zephyr_sources_ifdef(CONFIG_PLATFORM_EC_POWERSEQ_INTEL "${PLATFORM_EC}/power/intel_x86.c") zephyr_sources_ifdef(CONFIG_PLATFORM_EC_TIMER "${PLATFORM_EC}/common/timer.c") +zephyr_sources_ifdef(CONFIG_PLATFORM_EC_USB_CHARGER + "${PLATFORM_EC}/common/usb_charger.c") + zephyr_sources_ifdef(CONFIG_PLATFORM_EC_USB_POWER_DELIVERY "${PLATFORM_EC}/common/usb_common.c" "${PLATFORM_EC}/common/usbc/usb_sm.c") diff --git a/zephyr/Kconfig.tasks b/zephyr/Kconfig.tasks index 766ffa4b21..8bc93b7a3a 100644 --- a/zephyr/Kconfig.tasks +++ b/zephyr/Kconfig.tasks @@ -125,4 +125,45 @@ config TASK_POWERBTN_STACK_SIZE endif # HAS_TASK_POWERBTN +config HAS_TASK_USB_CHG_P0 + bool "USB Charger (port 0)" + depends on PLATFORM_EC_USB_CHARGER + help + This turns on the USB charger task for port 0. This handles + negotiating power from an attached charger, trying to get the maximum + available power consistent with the needs of the device. + + There is one of these tasks for each USB-C port on the device. + +if HAS_TASK_USB_CHG_P0 + +config TASK_USB_CHG_STACK_SIZE + hex "(all ports) task stack size" + default 0x400 # EC uses VENTI_TASK_STACK_SIZE which is 896 + help + The stack size of the USB charger task. If there are multiple tasks, + each one gets the same stack size. + + See b/176180736 for checking these stack sizes. + +endif # HAS_TASK_USB_CHG_P0 + +config HAS_TASK_USB_CHG_P1 + bool "USB Charger (port 1)" + help + This turns on the USB charger task for port 1. This handles + negotiating power from an attached charger, trying to get the maximum + available power consistent with the needs of the device. + + There is one of these tasks for each USB-C port on the device. + +config HAS_TASK_USB_CHG_P2 + bool "USB Charger (port 2)" + help + This turns on the USB charger task for port 2. This handles + negotiating power from an attached charger, trying to get the maximum + available power consistent with the needs of the device. + + There is one of these tasks for each USB-C port on the device. + endmenu # Tasks diff --git a/zephyr/Kconfig.usbc b/zephyr/Kconfig.usbc index c3d92807d0..410156e2e3 100644 --- a/zephyr/Kconfig.usbc +++ b/zephyr/Kconfig.usbc @@ -424,4 +424,14 @@ endif # PLATFORM_EC_USB_PD_TCPM_TCPCI endif # PLATFORM_EC_USBC_PPC +config PLATFORM_EC_USB_CHARGER + bool "Support charging from a USB-C port" + # default y (next CL, once we can compile the code) + # select HAS_TASK_USB_CHG_P0 (next CL, once we can compile the code) + help + This enables common BC1.2 (Battery-Charging Specification Rev1.2) + charger-detection routines. With this is possible to negotiate a + power contract with an attached battery charger and use this to + charge the device's battery. + endif # PLATFORM_EC_USBC diff --git a/zephyr/shim/include/shimmed_task_id.h b/zephyr/shim/include/shimmed_task_id.h index 29b6d675b6..3da93e67c9 100644 --- a/zephyr/shim/include/shimmed_task_id.h +++ b/zephyr/shim/include/shimmed_task_id.h @@ -19,6 +19,15 @@ typedef uint8_t task_id_t; */ #ifndef CONFIG_ZTEST #define CROS_EC_TASK_LIST \ + COND_CODE_1(HAS_TASK_USB_CHG_P0, \ + (CROS_EC_TASK(USB_CHG_P0, usb_charger_task, 0, \ + CONFIG_TASK_USB_CHG_STACK_SIZE)), ()) \ + COND_CODE_1(HAS_TASK_USB_CHG_P1, \ + (CROS_EC_TASK(USB_CHG_P1, usb_charger_task, 0, \ + CONFIG_TASK_USB_CHG_STACK_SIZE)), ()) \ + COND_CODE_1(HAS_TASK_USB_CHG_P2, \ + (CROS_EC_TASK(USB_CHG_P2, usb_charger_task, 0, \ + CONFIG_TASK_USB_CHG_STACK_SIZE)), ()) \ COND_CODE_1(HAS_TASK_CHARGER, \ (CROS_EC_TASK(CHARGER, charger_task, 0, \ CONFIG_TASK_CHARGER_STACK_SIZE)), ()) \ diff --git a/zephyr/shim/include/shimmed_tasks.h b/zephyr/shim/include/shimmed_tasks.h index bc45b37227..5f1dff78f0 100644 --- a/zephyr/shim/include/shimmed_tasks.h +++ b/zephyr/shim/include/shimmed_tasks.h @@ -6,6 +6,10 @@ #ifndef __CROS_EC_SHIMMED_TASKS_H #define __CROS_EC_SHIMMED_TASKS_H +#ifdef CONFIG_HAS_TASK_CHARGER +#define HAS_TASK_CHARGER 1 +#endif /* CONFIG_HAS_TASK_CHARGER */ + #ifdef CONFIG_HAS_TASK_CHIPSET #define HAS_TASK_CHIPSET 1 #endif /* CONFIG_HAS_TASK_CHIPSET */ @@ -27,8 +31,16 @@ #define HAS_TASK_POWERBTN 1 #endif /* CONFIG_HAS_TASK_POWERBTN */ -#ifdef CONFIG_HAS_TASK_CHARGER -#define HAS_TASK_CHARGER 1 -#endif /* CONFIG_HAS_TASK_CHARGER */ +#ifdef CONFIG_HAS_TASK_USB_CHG_P0 +#define HAS_TASK_USB_CHG_P0 1 +#endif /* CONFIG_HAS_TASK_USB_CHG_P0 */ + +#ifdef CONFIG_HAS_TASK_USB_CHG_P1 +#define HAS_TASK_USB_CHG_P1 1 +#endif /* CONFIG_HAS_TASK_USB_CHG_P1 */ + +#ifdef CONFIG_HAS_TASK_USB_CHG_P2 +#define HAS_TASK_USB_CHG_P2 1 +#endif /* CONFIG_HAS_TASK_USB_CHG_P2 */ #endif /* __CROS_EC_SHIMMED_TASKS_H */ |