diff options
author | Eric Yilun Lin <yllin@chromium.org> | 2019-12-17 17:14:36 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-12-20 08:01:08 +0000 |
commit | 7ac25f043ae797e6fabab215e9acf612c8a2ca76 (patch) | |
tree | 8e7ee7c5399ed85bdab5fef28f3fb312560268b1 /driver | |
parent | 8eff05481f59a9696d2efd6c1603c0ae36ee026b (diff) | |
download | chrome-ec-7ac25f043ae797e6fabab215e9acf612c8a2ca76.tar.gz |
charger/rt946x: support AC state detection
Some boards don't have extpower pin to update AC state.
Support AC state detection to wakeup charger_task immediately in S5/G3
when port plug. Otherwise, charger_task will wakeup
per 30 seconds and it can't respond to port plug in time.
TEST=aps; plug PD/BC12 adapter and ensure it can drain current
up to 2A immediately
BUG=b:146183246
BRANCH=kukui
Change-Id: I6f0389a7fd4388a8c31f66f78293303b681ee932
Signed-off-by: Eric Yilun Lin <yllin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1970676
Reviewed-by: Ting Shen <phoenixshen@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r-- | driver/charger/rt946x.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/driver/charger/rt946x.c b/driver/charger/rt946x.c index db395a8f99..e75c2018c1 100644 --- a/driver/charger/rt946x.c +++ b/driver/charger/rt946x.c @@ -13,6 +13,7 @@ #include "compile_time_macros.h" #include "config.h" #include "console.h" +#include "extpower.h" #include "hooks.h" #include "i2c.h" #include "printf.h" @@ -1192,9 +1193,27 @@ static int rt946x_get_bc12_ilim(int charge_supplier) } } +static void check_ac_state(void) +{ + static uint8_t ac; + + if (ac != extpower_is_present()) { + ac = !ac; + hook_notify(HOOK_AC_CHANGE); + } +} +DECLARE_DEFERRED(check_ac_state); + void rt946x_interrupt(enum gpio_signal signal) { task_wake(TASK_ID_USB_CHG); + /* + * Generally, VBUS detection can be done immediately when the port + * plug/unplug happens. But if it's a PD plug(and will generate an + * interrupt), then it will take a few milliseconds to raise VBUS + * by PD negotiation. + */ + hook_call_deferred(&check_ac_state_data, 100 * MSEC); } int rt946x_toggle_bc12_detection(void) @@ -1240,6 +1259,7 @@ static void rt946x_usb_connect(void) /* delay extra 50 ms to ensure SrcCap received */ hook_call_deferred(&check_pd_capable_data, PD_T_SINK_WAIT_CAP + 50 * MSEC); + hook_call_deferred(&check_ac_state_data, 0); } DECLARE_HOOK(HOOK_USB_PD_CONNECT, rt946x_usb_connect, HOOK_PRIO_DEFAULT); @@ -1247,6 +1267,7 @@ static void rt946x_pd_disconnect(void) { /* Type-C disconnected, disable deferred check. */ hook_call_deferred(&check_pd_capable_data, -1); + hook_call_deferred(&check_ac_state_data, 0); } DECLARE_HOOK(HOOK_USB_PD_DISCONNECT, rt946x_pd_disconnect, HOOK_PRIO_DEFAULT); |