From bffb196a07e985280a45f5e5f7965c99b4332b0a Mon Sep 17 00:00:00 2001 From: Philip Chen Date: Tue, 16 Jan 2018 20:46:33 -0800 Subject: scarlet: Use TCPC to detect if AC is present After VBUS is up, there is a delay of ~500ms for rt946x to determine 'VBUS is ready'. But we need charger_task to detect AC presence and then set a proper sleep time immediately. When using fusb302 to detect VBUS, I almost don't see any delay. BUG=b:71520398 BRANCH=none TEST=Confirm BATTERY LED turns on immediately when AC is plugged in a Scarlet in G3. Change-Id: If1d6d40081b5822eeb9e012115f8deef172def37 Signed-off-by: Philip Chen Reviewed-on: https://chromium-review.googlesource.com/869420 Commit-Ready: Philip Chen Tested-by: Philip Chen Reviewed-by: Philip Chen Reviewed-by: Shawn N --- board/scarlet/board.c | 2 +- driver/charger/rt946x.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/board/scarlet/board.c b/board/scarlet/board.c index 4b9a71c746..277c91ca74 100644 --- a/board/scarlet/board.c +++ b/board/scarlet/board.c @@ -187,7 +187,7 @@ int extpower_is_present(void) if (board_vbus_source_enabled(0)) return 0; else - return rt946x_is_vbus_ready(); + return tcpm_get_vbus_level(0); } int pd_snk_is_vbus_provided(int port) diff --git a/driver/charger/rt946x.c b/driver/charger/rt946x.c index d7dbcc26ef..5cf558b033 100644 --- a/driver/charger/rt946x.c +++ b/driver/charger/rt946x.c @@ -760,6 +760,10 @@ int rt946x_enable_charger_boost(int en) (RT946X_REG_CHGCTRL2, RT946X_MASK_CHG_EN); } +/* + * rt946x reports VBUS ready after VBUS is up for ~500ms. + * Check if this works for the use case before calling this function. + */ int rt946x_is_vbus_ready(void) { int val = 0; -- cgit v1.2.1