diff options
author | Gene Chen <gene_chen@mediatek.corp-partner.google.com> | 2019-04-16 10:48:14 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-11-14 09:22:12 +0000 |
commit | d226ec2751923b70ab1b9e6089eab3132df98c60 (patch) | |
tree | 762d5857dc5f98304499e35233696ec854d73eee /driver | |
parent | 86a7e2f4b791ec02da9403781b21ae19e3e6cb1e (diff) | |
download | chrome-ec-d226ec2751923b70ab1b9e6089eab3132df98c60.tar.gz |
rt946x: Fix MT6370 charger type detection
add bc12 workaround when bc12 detect SDP
BRANCH=kukui
BUG=b:128049211
TEST=boot kukui, slow plug in DCP, check bc12 detect chg type
Change-Id: Ie9b8780fdad6e061e967ebb127b27bf63a11db2e
Signed-off-by: Gene Chen <gene_chen@mediatek.corp-partner.google.com>
Signed-off-by: Yilun Lin <yllin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1568887
Reviewed-by: Ting Shen <phoenixshen@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r-- | driver/charger/rt946x.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/driver/charger/rt946x.c b/driver/charger/rt946x.c index cc33a84e02..589dda1960 100644 --- a/driver/charger/rt946x.c +++ b/driver/charger/rt946x.c @@ -1332,12 +1332,30 @@ static int mt6370_irq_handler(void) } #endif /* CONFIG_CHARGER_MT6370 */ +static void rt946x_bc12_workaround(void) +{ + /* + * There is a parasitic capacitance on D+, + * which results in pulling D+ up too slow while detecting BC1.2. + * So we try to fix this in two steps: + * 1. Pull D+ up to a voltage under 0.6V + * 2. re-toggling and pull D+ up to 0.6V (again) + * and then detect the voltage of D-. + */ + rt946x_toggle_bc12_detection(); + msleep(10); + rt946x_toggle_bc12_detection(); +} +DECLARE_DEFERRED(rt946x_bc12_workaround); + void usb_charger_task(void *u) { struct charge_port_info chg; int bc12_type = CHARGE_SUPPLIER_NONE; int chg_type; int reg = 0; + int bc12_cnt = 0; + const int max_bc12_cnt = 3; chg.voltage = USB_CHARGER_VOLTAGE_MV; while (1) { @@ -1370,6 +1388,16 @@ void usb_charger_task(void *u) p9221_notify_vbus_change(1); CPRINTS("WPC ON"); } + if (bc12_type == CHARGE_SUPPLIER_BC12_SDP && + ++bc12_cnt < max_bc12_cnt) { + /* + * defer the workaround and awaiting for + * waken up by the interrupt. + */ + hook_call_deferred( + &rt946x_bc12_workaround_data, 5); + goto wait_event; + } charge_manager_update_charge(bc12_type, 0, &chg); bc12_none: @@ -1380,6 +1408,7 @@ bc12_none: /* VBUS detach event */ if (reg & RT946X_MASK_DPDMIRQ_DETACH) { CPRINTS("VBUS detached"); + bc12_cnt = 0; #ifdef CONFIG_WIRELESS_CHARGER_P9221_R7 p9221_notify_vbus_change(0); #endif @@ -1391,6 +1420,7 @@ bc12_none: hook_notify(HOOK_AC_CHANGE); } +wait_event: task_wait_event(-1); } } |