summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-01-07 13:04:17 -0700
committerCommit Bot <commit-bot@chromium.org>2021-01-09 05:11:02 +0000
commitf366e0c5db6621684dd042a104d83162731cba04 (patch)
treef27fe44d843aaa6821993ef9d52627edce7a7dfc
parentb1b5659062f4ba8ff7de2df4dcebd339084a90e6 (diff)
downloadchrome-ec-f366e0c5db6621684dd042a104d83162731cba04.tar.gz
zephyr: Add the USB charger tasks
Add these tasks so that we can enable USB charging. For now it is left off since the driver is missing. Move the charger task to the top so that things are in alphabetical order. BUG=b:175434113 BRANCH=none TEST=make BOARD=volteer -j30 build volteer on zephyr Change-Id: Ib1f48438a2b33069624beb2cd9330db475f76333 Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2615620 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
-rw-r--r--zephyr/CMakeLists.txt3
-rw-r--r--zephyr/Kconfig.tasks41
-rw-r--r--zephyr/Kconfig.usbc10
-rw-r--r--zephyr/shim/include/shimmed_task_id.h9
-rw-r--r--zephyr/shim/include/shimmed_tasks.h18
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 */