From 76070804b0ebfa4e297d51ef01ed028d575e8e39 Mon Sep 17 00:00:00 2001 From: Vic Yang Date: Wed, 24 Jul 2013 06:59:29 +0800 Subject: spring: Drop 3.3V to lock TPSChrome into battery mode For Spring, we need to work around a hardware issue that TPSChrome doesn't lock into battery mode when the charger is unplugged. This is done by slightly dropping 3.3V power rail before the EC hibernates. BUG=chrome-os-partner:21107 TEST=Power off and unplug charger. Wait until EC hibernates. Measure power and check 3.3V power rail. BRANCH=Spring Change-Id: I4d13ee039e9c71d8475ad5c480871c9db8a8495c Signed-off-by: Vic Yang Reviewed-on: https://gerrit.chromium.org/gerrit/63127 Reviewed-by: Vincent Palatin --- common/gaia_power.c | 1 + common/pmu_tps65090.c | 22 ++++++++++++++++++++++ include/pmu_tpschrome.h | 5 +++++ 3 files changed, 28 insertions(+) diff --git a/common/gaia_power.c b/common/gaia_power.c index dd336c244e..a11990add4 100644 --- a/common/gaia_power.c +++ b/common/gaia_power.c @@ -149,6 +149,7 @@ static void check_hibernate_timer(void) if (timestamp_expired(hibernate_time, NULL) && !board_get_ac()) { CPRINTF("[%T hibernating]\n"); + pmu_battery_mode(); system_hibernate(0, 0); } } diff --git a/common/pmu_tps65090.c b/common/pmu_tps65090.c index e40a41754c..5cc33d415b 100644 --- a/common/pmu_tps65090.c +++ b/common/pmu_tps65090.c @@ -425,6 +425,28 @@ int pmu_enable_fet(int fet_id, int enable, int *power_good) return EC_SUCCESS; } +void pmu_battery_mode(void) +{ + /* + * The timing is important here. If we drop 3.3V for too long, the + * EC browns out. Disable interrupt to prevent this. + */ + interrupt_disable(); + + gpio_set_level(GPIO_PMIC_RESET, 1); + + /* + * Delay for 20 us. This drops 3.3V power rail to ~2.4V, which is + * low enough to get TPS65090 to go into battery mode, but not as low + * as to brown out the EC. + */ + udelay(20); + + gpio_set_level(GPIO_PMIC_RESET, 0); + + interrupt_enable(); +} + int pmu_adc_read(int adc_idx, int flags) { int ctrl; diff --git a/include/pmu_tpschrome.h b/include/pmu_tpschrome.h index acecb53f8e..03dde334c6 100644 --- a/include/pmu_tpschrome.h +++ b/include/pmu_tpschrome.h @@ -283,5 +283,10 @@ enum charging_state charge_get_state(void); */ int charge_keep_power_off(void); +/** + * Drop 3.3V power rail a little bit to get TPSChrome locked into battery mode. + */ +void pmu_battery_mode(void); + #endif /* __CROS_EC_TPSCHROME_H */ -- cgit v1.2.1