summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2013-03-19 11:58:13 +0800
committerChromeBot <chrome-bot@google.com>2013-03-20 23:47:43 -0700
commita0661f67427fef1c77f739b4797d3a2e10342678 (patch)
tree4c36d6a9ec8c3dffb8f4ab74e00f7ffafe05aafd
parentdb20e7afde7981945b3076015a57443fc2694899 (diff)
downloadchrome-ec-a0661f67427fef1c77f739b4797d3a2e10342678.tar.gz
spring: disable boost when AP is off and no charger is attached
When AP is off and no charger is attached, we can safely disable boost to save power. BUG=chrome-os-partner:18305 TEST=1. AP off, no charger -> BOOST_EN 0 2. AP off, with charger -> BOOST_EN 1 3. AP on, no charger -> BOOST_EN 1 4. AP on, with charger -> BOOST_EN 1 5. AP on->off, no charger -> BOOST_EN 1->0 6. AP off->on, no charger -> BOOST_EN 0->1 BRANCH=spring Change-Id: I7ff49e51057126490d09a3f0b1be2c60ca6a9bd3 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/45830 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--board/spring/usb_charging.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/board/spring/usb_charging.c b/board/spring/usb_charging.c
index 7d9d5e168f..1bd23160d7 100644
--- a/board/spring/usb_charging.c
+++ b/board/spring/usb_charging.c
@@ -7,6 +7,7 @@
#include "adc.h"
#include "board.h"
+#include "chipset.h"
#include "console.h"
#include "hooks.h"
#include "gpio.h"
@@ -335,6 +336,26 @@ static int usb_has_power_input(int dev_type)
!(dev_type & POWERED_5000_DEVICE_TYPE);
}
+static int usb_need_boost(int dev_type)
+{
+ if (dev_type & POWERED_5000_DEVICE_TYPE)
+ return 0;
+ if (chipset_in_state(CHIPSET_STATE_ON))
+ return 1;
+ return (dev_type != TSU6721_TYPE_NONE);
+}
+
+static void usb_boost_power_hook(int power_on)
+{
+ if (current_dev_type == TSU6721_TYPE_NONE)
+ gpio_set_level(GPIO_BOOST_EN, power_on);
+}
+
+static void usb_boost_pwr_on_hook(void) { usb_boost_power_hook(1); }
+static void usb_boost_pwr_off_hook(void) { usb_boost_power_hook(0); }
+DECLARE_HOOK(HOOK_CHIPSET_PRE_INIT, usb_boost_pwr_on_hook, HOOK_PRIO_DEFAULT);
+DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, usb_boost_pwr_off_hook, HOOK_PRIO_DEFAULT);
+
static void usb_device_change(int dev_type)
{
int need_boost;
@@ -389,13 +410,13 @@ static void usb_device_change(int dev_type)
if (retry_limit-- <= 0)
break;
- need_boost = !(dev_type & POWERED_5000_DEVICE_TYPE);
+ need_boost = usb_need_boost(dev_type);
if (need_boost != gpio_get_level(GPIO_BOOST_EN)) {
gpio_set_level(GPIO_BOOST_EN, need_boost);
msleep(DELAY_POWER_MS);
dev_type = tsu6721_get_device_type();
}
- } while (need_boost == !!(dev_type & POWERED_5000_DEVICE_TYPE));
+ } while (need_boost == !usb_need_boost(dev_type));
/* Supply 3.3V VBUS if needed. */
if (dev_type & POWERED_3300_DEVICE_TYPE) {