diff options
author | Randall Spangler <rspangler@chromium.org> | 2014-01-22 15:36:08 -0800 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-01-23 19:32:27 +0000 |
commit | 75857e80d0ef0426fd80fd7cb526ff7b895ba9a0 (patch) | |
tree | 8a4695ef235c925bcb0b30306f293588a5ec9a00 | |
parent | c8c66cdb77eef484d481cc2793f5f73e43542e55 (diff) | |
download | chrome-ec-75857e80d0ef0426fd80fd7cb526ff7b895ba9a0.tar.gz |
rambi: Leave 5V rail on in S3 if USB ports are powered
Previously, the 5V rail was disabled unconditionally in the S0->S3
transition. Now, the rail is left powered if one or both of the USB
ports are powered.
BUG=chrome-os-partner:25178
BRANCH=rambi
TEST=Modify the OS to leave USB ports powered in S3. Then suspend. On
the EC console, 'gpioget pp5000_en' should be 1.
Change-Id: I3c73f3fe228e940317c0da7330f117c7ab0a6d0c
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/183548
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
-rw-r--r-- | board/rambi/board.h | 1 | ||||
-rw-r--r-- | common/usb_port_power_smart.c | 13 | ||||
-rw-r--r-- | include/config.h | 6 | ||||
-rw-r--r-- | include/usb_charge.h | 8 | ||||
-rw-r--r-- | power/baytrail.c | 15 |
5 files changed, 43 insertions, 0 deletions
diff --git a/board/rambi/board.h b/board/rambi/board.h index 62c0784ffe..bebe44e570 100644 --- a/board/rambi/board.h +++ b/board/rambi/board.h @@ -36,6 +36,7 @@ #define CONFIG_SCI_GPIO GPIO_PCH_SCI_L #define CONFIG_TEMP_SENSOR #define CONFIG_TEMP_SENSOR_TMP432 +#define CONFIG_USB_PORT_POWER_IN_S3 #define CONFIG_USB_PORT_POWER_SMART #define CONFIG_USB_PORT_POWER_SMART_SIMPLE #define CONFIG_VBOOT_HASH diff --git a/common/usb_port_power_smart.c b/common/usb_port_power_smart.c index 9a47d78326..89f72c7339 100644 --- a/common/usb_port_power_smart.c +++ b/common/usb_port_power_smart.c @@ -85,6 +85,19 @@ static void usb_charge_all_ports_off(void) usb_charge_set_mode(1, USB_CHARGE_MODE_DISABLED); } +int usb_charge_ports_enabled(void) +{ + int mask = 0; + + if (gpio_get_level(GPIO_USB1_ENABLE)) + mask |= (1 << 0); + + if (gpio_get_level(GPIO_USB2_ENABLE)) + mask |= (1 << 1); + + return mask; +} + int usb_charge_set_mode(int port_id, enum usb_charge_mode mode) { CPRINTF("[%T USB charge p%d m%d]\n", port_id, mode); diff --git a/include/config.h b/include/config.h index abf183151c..58f68e2b33 100644 --- a/include/config.h +++ b/include/config.h @@ -728,6 +728,12 @@ #undef CONFIG_USB_PORT_POWER_DUMB /* + * Support supplying USB power in S3, if the host leaves the port enabled when + * entering S3. + */ +#undef CONFIG_USB_PORT_POWER_IN_S3 + +/* * Support smart power control to the device's USB ports, using * dedicated power control chips. This potentially enables automatic * negotiation of supplying more power to peripherals. diff --git a/include/usb_charge.h b/include/usb_charge.h index 66e6611985..e67aba482e 100644 --- a/include/usb_charge.h +++ b/include/usb_charge.h @@ -34,4 +34,12 @@ enum usb_charge_mode { */ int usb_charge_set_mode(int usb_port_id, enum usb_charge_mode mode); +/** + * Return a bitmask of which USB ports are enabled. + * + * If bit (1 << i) is set, port <i> is enabled. If it is clear, port <i> is + * in USB_CHARGE_MODE_DISABLED. + */ +int usb_charge_ports_enabled(void); + #endif /* __CROS_EC_USB_CHARGE_H */ diff --git a/power/baytrail.c b/power/baytrail.c index e938f9298e..8615964705 100644 --- a/power/baytrail.c +++ b/power/baytrail.c @@ -16,6 +16,7 @@ #include "power.h" #include "system.h" #include "timer.h" +#include "usb_charge.h" #include "util.h" #include "wireless.h" @@ -315,13 +316,27 @@ enum power_state power_handle_state(enum power_state state) /* Turn off power rails */ gpio_set_level(GPIO_PP3300_DX_EN, 0); + +#ifdef CONFIG_USB_PORT_POWER_IN_S3 + /* + * Disable the 5V rail if all USB ports are disabled. Else + * leave 5V enabled so the ports will continue to work in S3. + */ + if (!usb_charge_ports_enabled()) + gpio_set_level(GPIO_PP5000_EN, 0); +#else gpio_set_level(GPIO_PP5000_EN, 0); +#endif + return POWER_S3; case POWER_S3S5: /* Call hooks before we remove power rails */ hook_notify(HOOK_CHIPSET_SHUTDOWN); + /* Turn off 5V rail (if it wasn't turned off in S3) */ + gpio_set_level(GPIO_PP5000_EN, 0); + /* Disable wireless */ wireless_enable(0); |