diff --git a/drivers/power/supply/qcom/battery.c b/drivers/power/supply/qcom/battery.c index d685f8111b85754d38cc4e1891a7135880d6aedc..705462d737ccc2ffe0f3c4cb83bb23b6cda65f1a 100644 --- a/drivers/power/supply/qcom/battery.c +++ b/drivers/power/supply/qcom/battery.c @@ -596,6 +596,25 @@ static void pl_taper_work(struct work_struct *work) goto done; } + /* + * Due to reduction of float voltage in JEITA condition taper + * charging can be initiated at a lower FV. On removal of JEITA + * condition, FV readjusts itself. However, once taper charging + * is initiated, it doesn't exits until parallel chaging is + * disabled due to which FCC doesn't scale back to its original + * value, leading to slow charging thereafter. + * Check if FV increases in comparison to FV at which taper + * charging was initiated, and if yes, exit taper charging. + */ + if (get_effective_result(chip->fv_votable) > + chip->taper_entry_fv) { + pl_dbg(chip, PR_PARALLEL, "Float voltage increased. Exiting taper\n"); + goto done; + } else { + chip->taper_entry_fv = + get_effective_result(chip->fv_votable); + } + rc = power_supply_get_property(chip->batt_psy, POWER_SUPPLY_PROP_CHARGE_TYPE, &pval); if (rc < 0) { @@ -621,26 +640,9 @@ static void pl_taper_work(struct work_struct *work) vote(chip->fcc_votable, TAPER_STEPPER_VOTER, true, eff_fcc_ua); } else { - /* - * Due to reduction of float voltage in JEITA condition - * taper charging can be initiated at a lower FV. On - * removal of JEITA condition, FV readjusts itself. - * However, once taper charging is initiated, it doesn't - * exits until parallel chaging is disabled due to which - * FCC doesn't scale back to its original value, leading - * to slow charging thereafter. - * Check if FV increases in comparison to FV at which - * taper charging was initiated, and if yes, exit taper - * charging. - */ - if (get_effective_result(chip->fv_votable) > - chip->taper_entry_fv) { - pl_dbg(chip, PR_PARALLEL, "Float voltage increased. Exiting taper\n"); - goto done; - } else { - pl_dbg(chip, PR_PARALLEL, "master is fast charging; waiting for next taper\n"); - } + pl_dbg(chip, PR_PARALLEL, "master is fast charging; waiting for next taper\n"); } + /* wait for the charger state to deglitch after FCC change */ msleep(PL_TAPER_WORK_DELAY_MS); } diff --git a/drivers/power/supply/qcom/qpnp-smb5.c b/drivers/power/supply/qcom/qpnp-smb5.c index 4eae836eb8c2687e0eaa3552ac6eef067337f41e..77820a92af81fa86df81db99406643d9001d7dd9 100644 --- a/drivers/power/supply/qcom/qpnp-smb5.c +++ b/drivers/power/supply/qcom/qpnp-smb5.c @@ -354,6 +354,9 @@ static int smb5_parse_dt_misc(struct smb5 *chip, struct device_node *node) chg->sw_jeita_enabled = of_property_read_bool(node, "qcom,sw-jeita-enable"); + chg->pd_not_supported = of_property_read_bool(node, + "qcom,usb-pd-disable"); + rc = of_property_read_u32(node, "qcom,wd-bark-time-secs", &chip->dt.wd_bark_time); if (rc < 0 || chip->dt.wd_bark_time < MIN_WD_BARK_TIME) @@ -1636,7 +1639,42 @@ static int smb5_init_vconn_regulator(struct smb5 *chip) ***************************/ static int smb5_configure_typec(struct smb_charger *chg) { + union power_supply_propval pval = {0, }; int rc; + u8 val = 0; + + rc = smblib_read(chg, LEGACY_CABLE_STATUS_REG, &val); + if (rc < 0) { + dev_err(chg->dev, "Couldn't read Legacy status rc=%d\n", rc); + return rc; + } + + /* + * Across reboot, standard typeC cables get detected as legacy cables + * due to VBUS attachment prior to CC attach/dettach. To handle this, + * "early_usb_attach" flag is used, which assumes that across reboot, + * the cable connected can be standard typeC. However, its jurisdiction + * is limited to PD capable designs only. Hence, for non-PD type designs + * reset legacy cable detection by disabling/enabling typeC mode. + */ + if (chg->pd_not_supported && (val & TYPEC_LEGACY_CABLE_STATUS_BIT)) { + pval.intval = POWER_SUPPLY_TYPEC_PR_NONE; + smblib_set_prop_typec_power_role(chg, &pval); + if (rc < 0) { + dev_err(chg->dev, "Couldn't disable TYPEC rc=%d\n", rc); + return rc; + } + + /* delay before enabling typeC */ + msleep(50); + + pval.intval = POWER_SUPPLY_TYPEC_PR_DUAL; + smblib_set_prop_typec_power_role(chg, &pval); + if (rc < 0) { + dev_err(chg->dev, "Couldn't enable TYPEC rc=%d\n", rc); + return rc; + } + } smblib_apsd_enable(chg, true); smblib_hvdcp_detect_enable(chg, false); diff --git a/drivers/power/supply/qcom/smb1390-charger-psy.c b/drivers/power/supply/qcom/smb1390-charger-psy.c index 6d8758904446bdf4ae64ab5431cd6d7ded7079b6..ff8f484ec84f2fdefeb547a55d0e2f0deab3e0be 100644 --- a/drivers/power/supply/qcom/smb1390-charger-psy.c +++ b/drivers/power/supply/qcom/smb1390-charger-psy.c @@ -635,6 +635,15 @@ static void smb1390_taper_work(struct work_struct *work) goto out; } + if (get_effective_result(chip->fv_votable) > + chip->taper_entry_fv) { + pr_debug("Float voltage increased. Exiting taper\n"); + goto out; + } else { + chip->taper_entry_fv = + get_effective_result(chip->fv_votable); + } + if (pval.intval == POWER_SUPPLY_CHARGE_TYPE_TAPER) { fcc_uA = get_effective_result(chip->fcc_votable) - 100000; @@ -646,10 +655,6 @@ static void smb1390_taper_work(struct work_struct *work) true, 0); goto out; } - } else if (get_effective_result(chip->fv_votable) > - chip->taper_entry_fv) { - pr_debug("Float voltage increased. Exiting taper\n"); - goto out; } else { pr_debug("In fast charging. Wait for next taper\n"); } diff --git a/drivers/power/supply/qcom/smb5-lib.c b/drivers/power/supply/qcom/smb5-lib.c index 9bd05a6cf745710875fa521785162bf5000524a5..0175cc39fabe678e959622ee6a7dde228f8df40e 100644 --- a/drivers/power/supply/qcom/smb5-lib.c +++ b/drivers/power/supply/qcom/smb5-lib.c @@ -739,6 +739,23 @@ static int smblib_set_adapter_allowance(struct smb_charger *chg, { int rc = 0; + /* PMI632 only support max. 9V */ + if (chg->smb_version == PMI632_SUBTYPE) { + switch (allowed_voltage) { + case USBIN_ADAPTER_ALLOW_12V: + case USBIN_ADAPTER_ALLOW_9V_TO_12V: + allowed_voltage = USBIN_ADAPTER_ALLOW_9V; + break; + case USBIN_ADAPTER_ALLOW_5V_OR_12V: + case USBIN_ADAPTER_ALLOW_5V_OR_9V_TO_12V: + allowed_voltage = USBIN_ADAPTER_ALLOW_5V_OR_9V; + break; + case USBIN_ADAPTER_ALLOW_5V_TO_12V: + allowed_voltage = USBIN_ADAPTER_ALLOW_5V_TO_9V; + break; + } + } + rc = smblib_write(chg, USBIN_ADAPTER_ALLOW_CFG_REG, allowed_voltage); if (rc < 0) { smblib_err(chg, "Couldn't write 0x%02x to USBIN_ADAPTER_ALLOW_CFG rc=%d\n",