* Tony Lindgren <tony@xxxxxxxxxxx> [191009 13:34]: > This is against v5.3 so it can be easily picked for earlier kernels as > needed. If no changes needed, this is best applied on v5.3 and then merged > into v5.4-rc based branch as this will cause a minor merge conflict with > v5.4-rc because of 7f7378618b41 ("power: supply: cpcap-charger: Enable vbus > boost voltage"). And below is the merge resolution I used for reference. Regards, Tony 8< --------------------- diff --cc drivers/power/supply/cpcap-charger.c --- a/drivers/power/supply/cpcap-charger.c +++ b/drivers/power/supply/cpcap-charger.c @@@ -447,9 -515,48 +531,49 @@@ static void cpcap_usb_detect(struct wor if (error) return; + /* Just init the state if a charger is connected with no chrg_det set */ + if (!s.chrg_det && s.chrgcurr1 && s.vbusvld) { + cpcap_charger_update_state(ddata, CPCAP_CHARGER_DETECTING); + + return; + } + + /* + * If battery voltage is higher than charge voltage, it may have been + * charged to 3.51V by Android. Try again in 10 minutes. + */ + if (cpcap_charger_get_charge_voltage(ddata) > ddata->voltage) { + cpcap_charger_disconnect(ddata, CPCAP_CHARGER_DETECTING, + HZ * 60 * 10); + + return; + } + + /* Throttle chrgcurr2 interrupt for charger done and retry */ + switch (ddata->state) { + case CPCAP_CHARGER_CHARGING: + if (s.chrgcurr2) + break; + if (s.chrgcurr1 && s.vbusvld) { + cpcap_charger_disconnect(ddata, CPCAP_CHARGER_DONE, + HZ * 5); + return; + } + break; + case CPCAP_CHARGER_DONE: + if (!s.chrgcurr2) + break; + cpcap_charger_disconnect(ddata, CPCAP_CHARGER_DETECTING, + HZ * 5); + return; + default: + break; + } + - if (cpcap_charger_vbus_valid(ddata) && s.chrgcurr1) { + if (!ddata->feeding_vbus && cpcap_charger_vbus_valid(ddata) && + s.chrgcurr1) { int max_current; + int vchrg; if (cpcap_charger_battery_found(ddata)) max_current = CPCAP_REG_CRM_ICHRG_1A596;