diff options
author | Eric Yilun Lin <yllin@chromium.org> | 2022-03-07 11:10:32 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2022-03-16 10:22:53 +0000 |
commit | f67ade587349ba3a3ba4f618ce9258649739e340 (patch) | |
tree | 9cdc794ae20dc6a1077ed7af104d58ad0fc801ec | |
parent | dadd1edfe514a6af7d2ca4e6b9bd94d83dfd5bef (diff) | |
download | chrome-ec-f67ade587349ba3a3ba4f618ce9258649739e340.tar.gz |
zephyr: port DPS to zephyr
Port config dynamic PDO selection to zephyr.
BUG=b:206709593
TEST=enable DPS on herobrine and build
BRANCH=none
Change-Id: I2ee111c086625fe3b4972b490b64b68f122aefb4
Signed-off-by: Eric Yilun Lin <yllin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3522248
Reviewed-by: Ting Shen <phoenixshen@chromium.org>
Commit-Queue: Ting Shen <phoenixshen@chromium.org>
Tested-by: Eric Yilun Lin <yllin@google.com>
Auto-Submit: Eric Yilun Lin <yllin@google.com>
-rw-r--r-- | zephyr/CMakeLists.txt | 2 | ||||
-rw-r--r-- | zephyr/Kconfig.pd | 4 | ||||
-rw-r--r-- | zephyr/Kconfig.tasks | 19 | ||||
-rw-r--r-- | zephyr/shim/include/shimmed_task_id.h | 3 | ||||
-rw-r--r-- | zephyr/shim/include/shimmed_tasks.h | 4 |
5 files changed, 31 insertions, 1 deletions
diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index a998e8ab92..964047201f 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -414,6 +414,8 @@ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USB_MUX_TUSB1044 zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL "${PLATFORM_EC}/driver/usb_mux/virtual.c") +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USB_PD_DPS + "${PLATFORM_EC}/common/dps.c") zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USB_PD_LOGGING "${PLATFORM_EC}/common/event_log.c" "${PLATFORM_EC}/common/pd_log.c") diff --git a/zephyr/Kconfig.pd b/zephyr/Kconfig.pd index edfbcf1718..b4e7394967 100644 --- a/zephyr/Kconfig.pd +++ b/zephyr/Kconfig.pd @@ -127,10 +127,12 @@ config PLATFORM_EC_USB_PD_DUAL_ROLE up its battery), or send out power to an attached device on the same port. -config PLATFORM_EC_USB_PD_DPS +menuconfig PLATFORM_EC_USB_PD_DPS bool "Board can support Dynamic PDO Selection" depends on PLATFORM_EC_BATTERY + depends on PLATFORM_EC_USB_POWER_DELIVERY default n + select HAS_TASK_DPS help Enable this if the board needs dynamic PDO selection. DPS picks a power efficient PDO regarding to the underlying battery diff --git a/zephyr/Kconfig.tasks b/zephyr/Kconfig.tasks index d8c456808d..470172dc4f 100644 --- a/zephyr/Kconfig.tasks +++ b/zephyr/Kconfig.tasks @@ -188,6 +188,25 @@ config TASK_PD_INT_STACK_SIZE endif # PLATFORM_EC_USB_PD_PORT_MAX_COUNT > 0 +if HAS_TASK_DPS + +config TASK_DPS_STACK_SIZE + int "DPS task stack size" + default 1024 + help + The stack size of the DPS task. + +endif # HAS_TASK_DPS + +config HAS_TASK_DPS + bool + depends on PLATFORM_EC_USB_PD_DPS + help + This turns on the DPS task which evalutes the SRCCAP from all the SNK + ports and issues a new power request to the port which has the most + efficient power data object (PDO). + + config HAS_TASK_PD_C0 bool depends on PLATFORM_EC_USB_POWER_DELIVERY diff --git a/zephyr/shim/include/shimmed_task_id.h b/zephyr/shim/include/shimmed_task_id.h index e5481ca051..42fbf7bc28 100644 --- a/zephyr/shim/include/shimmed_task_id.h +++ b/zephyr/shim/include/shimmed_task_id.h @@ -47,6 +47,9 @@ typedef uint8_t task_id_t; 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_DPS, \ + (CROS_EC_TASK(DPS, dps_task, 0, \ + CONFIG_TASK_DPS_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 bd29e0b1a9..07552f1b27 100644 --- a/zephyr/shim/include/shimmed_tasks.h +++ b/zephyr/shim/include/shimmed_tasks.h @@ -18,6 +18,10 @@ #define HAS_TASK_CHIPSET 1 #endif /* CONFIG_HAS_TASK_CHIPSET */ +#ifdef CONFIG_HAS_TASK_DPS +#define HAS_TASK_DPS 1 +#endif /* CONFIG_HAS_TASK_DPS */ + #ifdef CONFIG_HAS_TASK_HOSTCMD #define HAS_TASK_HOSTCMD 1 #define CONFIG_HOSTCMD_EVENTS |