diff options
author | Rong Chang <rongchang@chromium.org> | 2012-08-22 23:25:10 +0800 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-08-22 23:40:20 -0700 |
commit | 5458d7aa678ac6a307342fad808cae184498b4b1 (patch) | |
tree | 093d2e40b6a8c5e64b8f76026054838d7d3d30aa | |
parent | c12777fef3ac872731041fc07230ea0de240c355 (diff) | |
download | chrome-ec-5458d7aa678ac6a307342fad808cae184498b4b1.tar.gz |
Check TPSCHROME VACG when power button is pressed
The AC status GPIO also indicates power button. When power button is
pressed, EC should return VACG in pmu_get_ac() funtion. If this function
is called in interrupt context with power button pressed, return 1.
Charging task will play nicely in charging mode without real AC. But in
discharging mode, it will shutdown application processor if battery
remaining capacity is too low.
Signed-off-by: Rong Chang <rongchang@chromium.org>
BRANCH=snow
BUG=chrome-os-partner:12738
TEST=manual
With AC plugged, press and hold power button.
Run uart console command "pmu" and check output, "ac gpio" should be 1.
Change-Id: I26d1a5a7a4ed2ff26a35e965a3ca2307a9c231e9
Reviewed-on: https://gerrit.chromium.org/gerrit/31112
Reviewed-by: Vic Yang <victoryang@chromium.org>
Commit-Ready: Rong Chang <rongchang@chromium.org>
Tested-by: Rong Chang <rongchang@chromium.org>
-rw-r--r-- | common/pmu_tps65090.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/common/pmu_tps65090.c b/common/pmu_tps65090.c index b0391d42d5..10e106fd75 100644 --- a/common/pmu_tps65090.c +++ b/common/pmu_tps65090.c @@ -223,7 +223,9 @@ int pmu_low_current_charging(int enable) void pmu_irq_handler(enum gpio_signal signal) { + /* TODO(rongchang): remove GPIO_AC_STATUS, we're not using it */ gpio_set_level(GPIO_AC_STATUS, pmu_get_ac()); + task_wake(TASK_ID_PMU_TPS65090_CHARGER); CPRINTF("Charger IRQ received.\n"); } @@ -236,18 +238,31 @@ int pmu_get_ac(void) * On daisy and snow, there's no single gpio signal to detect AC. * GPIO_AC_PWRBTN_L provides AC on and PWRBTN release. * GPIO_KB_PWR_ON_L provides PWRBTN release. - * Hence the ac state can be logical OR of these two signal line. + * + * When AC plugged, both GPIOs will be high. * * One drawback of this detection is, when press-and-hold power - * button. AC state will be unknown. The implementation below treats - * that condition as AC off. + * button. AC state will be unknown. This function will fallback + * to PMU VACG. * * TODO(rongchang): move board related function to board/ and common * interface to system_get_ac() */ - return gpio_get_level(GPIO_AC_PWRBTN_L) && - gpio_get_level(GPIO_KB_PWR_ON_L); + int ac_good = 1, battery_good; + + if (gpio_get_level(GPIO_KB_PWR_ON_L)) + return gpio_get_level(GPIO_AC_PWRBTN_L); + + /* Check PMU VACG */ + if (!in_interrupt_context()) + pmu_get_power_source(&ac_good, &battery_good); + + /* + * Charging task only interacts with AP in discharging state. So + * return 1 when AC status can not be detected by GPIO or VACG. + */ + return ac_good; } void pmu_init(void) |