diff options
-rw-r--r-- | board/zinger/board.h | 1 | ||||
-rw-r--r-- | chip/stm32/usb_pd_phy.c | 8 | ||||
-rw-r--r-- | common/usb_pd_tcpc.c | 15 | ||||
-rw-r--r-- | include/config.h | 3 |
4 files changed, 25 insertions, 2 deletions
diff --git a/board/zinger/board.h b/board/zinger/board.h index a00731f16c..64893bc1b0 100644 --- a/board/zinger/board.h +++ b/board/zinger/board.h @@ -57,6 +57,7 @@ #undef CONFIG_USB_PD_INTERNAL_COMP #define CONFIG_USB_PD_LOGGING #define CONFIG_USB_PD_LOG_SIZE 256 +#define CONFIG_USB_PD_LOW_POWER_IDLE_WHEN_CONNECTED #define CONFIG_USB_PD_PORT_COUNT 1 #define CONFIG_USB_PD_TCPC #define CONFIG_USB_PD_TCPM_STUB diff --git a/chip/stm32/usb_pd_phy.c b/chip/stm32/usb_pd_phy.c index 5c0ed3d0fd..0a8566efcc 100644 --- a/chip/stm32/usb_pd_phy.c +++ b/chip/stm32/usb_pd_phy.c @@ -459,13 +459,17 @@ void pd_rx_handler(void) PD_RX_TRANSITION_COUNT - 1) ? 0 : rx_edge_ts_idx[i] + 1; +#if defined(CONFIG_LOW_POWER_IDLE) && \ +defined(CONFIG_USB_PD_LOW_POWER_IDLE_WHEN_CONNECTED) /* * Do not deep sleep while waiting for more edges. For * most boards, sleep is already disabled due to being - * in PD connected state, but other boards can sleep - * while connected. + * in PD connected state, but boards which define + * CONFIG_USB_PD_LOW_POWER_IDLE_WHEN_CONNECTED can + * sleep while connected. */ disable_sleep(SLEEP_MASK_USB_PD); +#endif /* * If we have seen enough edges in a certain amount of diff --git a/common/usb_pd_tcpc.c b/common/usb_pd_tcpc.c index 494eea4913..cad272f9a3 100644 --- a/common/usb_pd_tcpc.c +++ b/common/usb_pd_tcpc.c @@ -13,6 +13,7 @@ #include "hooks.h" #include "host_command.h" #include "registers.h" +#include "system.h" #include "task.h" #include "tcpci.h" #include "timer.h" @@ -972,11 +973,25 @@ int tcpc_set_vconn(int port, int enable) int tcpc_set_rx_enable(int port, int enable) { +#if defined(CONFIG_LOW_POWER_IDLE) && !defined(CONFIG_USB_POWER_DELIVERY) + int i; +#endif pd[port].rx_enabled = enable; if (!enable) pd_rx_disable_monitoring(port); +#if defined(CONFIG_LOW_POWER_IDLE) && !defined(CONFIG_USB_POWER_DELIVERY) + /* If any PD port is connected, then disable deep sleep */ + for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; ++i) + if (pd[port].rx_enabled) + break; + + if (i == CONFIG_USB_PD_PORT_COUNT) + enable_sleep(SLEEP_MASK_USB_PD); + else + disable_sleep(SLEEP_MASK_USB_PD); +#endif return EC_SUCCESS; } diff --git a/include/config.h b/include/config.h index 63548f7bf7..db74a4c507 100644 --- a/include/config.h +++ b/include/config.h @@ -1718,6 +1718,9 @@ /* Save power by waking up on VBUS rather than polling CC */ #undef CONFIG_USB_PD_LOW_POWER +/* Allow chip to go into low power idle even when a PD device is attached */ +#undef CONFIG_USB_PD_LOW_POWER_IDLE_WHEN_CONNECTED + /* Define if USB-PD device has no way of detecting USB VBUS */ #undef CONFIG_USB_PD_NO_VBUS_DETECT |