diff options
author | Vic Yang <victoryang@chromium.org> | 2014-11-20 13:20:37 -0800 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-12-12 07:26:49 +0000 |
commit | 33142ba9ac61833ad10ffe5b7b6a2ca0e7be9912 (patch) | |
tree | 054f23a09fbbf10cf300ff2b88ae426e123055fa /common/inductive_charging.c | |
parent | 99ec74d7d414b4acd6e210798469f7699fedea01 (diff) | |
download | chrome-ec-33142ba9ac61833ad10ffe5b7b6a2ca0e7be9912.tar.gz |
ryu: Try to clear CHARGE_DONE when the lid is just closed
For the transmitter to clear CHARGE_DONE, charging must be enabled.
Therefore, we should always enable charging when the lid is just closed.
BRANCH=ryu
BUG=None
TEST=Test on Ryu p1.
Signed-off-by: Vic Yang <victoryang@chromium.org>
Change-Id: I44f3d7c9e413a63be66ccf9695fea5411b2067b6
Reviewed-on: https://chromium-review.googlesource.com/231121
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'common/inductive_charging.c')
-rw-r--r-- | common/inductive_charging.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/common/inductive_charging.c b/common/inductive_charging.c index 3a2448933f..0021cc3ac6 100644 --- a/common/inductive_charging.c +++ b/common/inductive_charging.c @@ -9,24 +9,40 @@ #include "gpio.h" #include "hooks.h" #include "lid_switch.h" +#include "timer.h" void inductive_charging_interrupt(enum gpio_signal signal) { int charger_enabled = gpio_get_level(GPIO_BASE_CHG_VDD_EN); int charge_done = gpio_get_level(GPIO_CHARGE_DONE); + /* Always try to charge if the lid is just closed */ + if (signal == GPIO_LID_OPEN) + charge_done = 0; + if (!charger_enabled || charge_done) gpio_set_level(GPIO_CHARGE_EN, 0); else gpio_set_level(GPIO_CHARGE_EN, 1); } -static void inductive_charging_lid_update(void) +static void inductive_charging_deferred_update(void) { int lid_open = lid_is_open(); gpio_set_level(GPIO_BASE_CHG_VDD_EN, !lid_open); inductive_charging_interrupt(GPIO_LID_OPEN); } +DECLARE_DEFERRED(inductive_charging_deferred_update); + +static void inductive_charging_lid_update(void) +{ + /* + * When the lid close signal changes, the coils might still be + * unaligned. Delay here to give the coils time to align before + * we try to clear CHARGE_DONE. + */ + hook_call_deferred(inductive_charging_deferred_update, 5 * SECOND); +} DECLARE_HOOK(HOOK_LID_CHANGE, inductive_charging_lid_update, HOOK_PRIO_DEFAULT); static void inductive_charging_init(void) |