Loading drivers/power/supply/qcom/qpnp-smb5.c +2 −1 Original line number Diff line number Diff line Loading @@ -349,7 +349,7 @@ static int smb5_chg_config_init(struct smb5 *chip) case PMI632_SUBTYPE: chip->chg.smb_version = PMI632_SUBTYPE; chg->wa_flags |= WEAK_ADAPTER_WA | USBIN_OV_WA | CHG_TERMINATION_WA; | CHG_TERMINATION_WA | USBIN_ADC_WA; chg->param = smb5_pmi632_params; chg->use_extcon = true; chg->name = "pmi632_charger"; Loading Loading @@ -3315,6 +3315,7 @@ static int smb5_probe(struct platform_device *pdev) chg->connector_health = -EINVAL; chg->otg_present = false; chg->main_fcc_max = -EINVAL; mutex_init(&chg->adc_lock); chg->regmap = dev_get_regmap(chg->dev->parent, NULL); if (!chg->regmap) { Loading drivers/power/supply/qcom/smb5-lib.c +45 −4 Original line number Diff line number Diff line Loading @@ -3283,12 +3283,36 @@ int smblib_get_prop_usb_voltage_now(struct smb_charger *chg, union power_supply_propval *val) { union power_supply_propval pval = {0, }; int rc; int rc, ret = 0; u8 reg; mutex_lock(&chg->adc_lock); if (chg->wa_flags & USBIN_ADC_WA) { /* Store ADC channel config in order to restore later */ rc = smblib_read(chg, BATIF_ADC_CHANNEL_EN_REG, ®); if (rc < 0) { smblib_err(chg, "Couldn't read ADC config rc=%d\n", rc); ret = rc; goto unlock; } /* Disable all ADC channels except IBAT channel */ rc = smblib_write(chg, BATIF_ADC_CHANNEL_EN_REG, IBATT_CHANNEL_EN_BIT); if (rc < 0) { smblib_err(chg, "Couldn't disable ADC channels rc=%d\n", rc); ret = rc; goto unlock; } } rc = smblib_get_prop_usb_present(chg, &pval); if (rc < 0) { smblib_err(chg, "Couldn't get usb presence status rc=%d\n", rc); return -ENODATA; ret = -ENODATA; goto restore_adc_config; } /* Loading @@ -3297,9 +3321,26 @@ int smblib_get_prop_usb_voltage_now(struct smb_charger *chg, * voltages. */ if (chg->smb_version == PM8150B_SUBTYPE && pval.intval) return smblib_read_mid_voltage_chan(chg, val); rc = smblib_read_mid_voltage_chan(chg, val); else return smblib_read_usbin_voltage_chan(chg, val); rc = smblib_read_usbin_voltage_chan(chg, val); if (rc < 0) { smblib_err(chg, "Failed to read USBIN over vadc, rc=%d\n", rc); ret = rc; } restore_adc_config: /* Restore ADC channel config */ if (chg->wa_flags & USBIN_ADC_WA) rc = smblib_write(chg, BATIF_ADC_CHANNEL_EN_REG, reg); if (rc < 0) smblib_err(chg, "Couldn't write ADC config rc=%d\n", rc); unlock: mutex_unlock(&chg->adc_lock); return ret; } int smblib_get_prop_vph_voltage_now(struct smb_charger *chg, Loading drivers/power/supply/qcom/smb5-lib.h +2 −0 Original line number Diff line number Diff line Loading @@ -123,6 +123,7 @@ enum { WEAK_ADAPTER_WA = BIT(2), USBIN_OV_WA = BIT(3), CHG_TERMINATION_WA = BIT(4), USBIN_ADC_WA = BIT(5), }; enum jeita_cfg_stat { Loading Loading @@ -386,6 +387,7 @@ struct smb_charger { struct mutex irq_status_lock; struct mutex dcin_aicl_lock; spinlock_t typec_pr_lock; struct mutex adc_lock; /* power supplies */ struct power_supply *batt_psy; Loading drivers/power/supply/qcom/smb5-reg.h +1 −0 Original line number Diff line number Diff line Loading @@ -182,6 +182,7 @@ enum { #define SHIP_MODE_EN_BIT BIT(0) #define BATIF_ADC_CHANNEL_EN_REG (BATIF_BASE + 0x82) #define IBATT_CHANNEL_EN_BIT BIT(6) #define CONN_THM_CHANNEL_EN_BIT BIT(4) #define DIE_TEMP_CHANNEL_EN_BIT BIT(2) #define MISC_THM_CHANNEL_EN_BIT BIT(1) Loading Loading
drivers/power/supply/qcom/qpnp-smb5.c +2 −1 Original line number Diff line number Diff line Loading @@ -349,7 +349,7 @@ static int smb5_chg_config_init(struct smb5 *chip) case PMI632_SUBTYPE: chip->chg.smb_version = PMI632_SUBTYPE; chg->wa_flags |= WEAK_ADAPTER_WA | USBIN_OV_WA | CHG_TERMINATION_WA; | CHG_TERMINATION_WA | USBIN_ADC_WA; chg->param = smb5_pmi632_params; chg->use_extcon = true; chg->name = "pmi632_charger"; Loading Loading @@ -3315,6 +3315,7 @@ static int smb5_probe(struct platform_device *pdev) chg->connector_health = -EINVAL; chg->otg_present = false; chg->main_fcc_max = -EINVAL; mutex_init(&chg->adc_lock); chg->regmap = dev_get_regmap(chg->dev->parent, NULL); if (!chg->regmap) { Loading
drivers/power/supply/qcom/smb5-lib.c +45 −4 Original line number Diff line number Diff line Loading @@ -3283,12 +3283,36 @@ int smblib_get_prop_usb_voltage_now(struct smb_charger *chg, union power_supply_propval *val) { union power_supply_propval pval = {0, }; int rc; int rc, ret = 0; u8 reg; mutex_lock(&chg->adc_lock); if (chg->wa_flags & USBIN_ADC_WA) { /* Store ADC channel config in order to restore later */ rc = smblib_read(chg, BATIF_ADC_CHANNEL_EN_REG, ®); if (rc < 0) { smblib_err(chg, "Couldn't read ADC config rc=%d\n", rc); ret = rc; goto unlock; } /* Disable all ADC channels except IBAT channel */ rc = smblib_write(chg, BATIF_ADC_CHANNEL_EN_REG, IBATT_CHANNEL_EN_BIT); if (rc < 0) { smblib_err(chg, "Couldn't disable ADC channels rc=%d\n", rc); ret = rc; goto unlock; } } rc = smblib_get_prop_usb_present(chg, &pval); if (rc < 0) { smblib_err(chg, "Couldn't get usb presence status rc=%d\n", rc); return -ENODATA; ret = -ENODATA; goto restore_adc_config; } /* Loading @@ -3297,9 +3321,26 @@ int smblib_get_prop_usb_voltage_now(struct smb_charger *chg, * voltages. */ if (chg->smb_version == PM8150B_SUBTYPE && pval.intval) return smblib_read_mid_voltage_chan(chg, val); rc = smblib_read_mid_voltage_chan(chg, val); else return smblib_read_usbin_voltage_chan(chg, val); rc = smblib_read_usbin_voltage_chan(chg, val); if (rc < 0) { smblib_err(chg, "Failed to read USBIN over vadc, rc=%d\n", rc); ret = rc; } restore_adc_config: /* Restore ADC channel config */ if (chg->wa_flags & USBIN_ADC_WA) rc = smblib_write(chg, BATIF_ADC_CHANNEL_EN_REG, reg); if (rc < 0) smblib_err(chg, "Couldn't write ADC config rc=%d\n", rc); unlock: mutex_unlock(&chg->adc_lock); return ret; } int smblib_get_prop_vph_voltage_now(struct smb_charger *chg, Loading
drivers/power/supply/qcom/smb5-lib.h +2 −0 Original line number Diff line number Diff line Loading @@ -123,6 +123,7 @@ enum { WEAK_ADAPTER_WA = BIT(2), USBIN_OV_WA = BIT(3), CHG_TERMINATION_WA = BIT(4), USBIN_ADC_WA = BIT(5), }; enum jeita_cfg_stat { Loading Loading @@ -386,6 +387,7 @@ struct smb_charger { struct mutex irq_status_lock; struct mutex dcin_aicl_lock; spinlock_t typec_pr_lock; struct mutex adc_lock; /* power supplies */ struct power_supply *batt_psy; Loading
drivers/power/supply/qcom/smb5-reg.h +1 −0 Original line number Diff line number Diff line Loading @@ -182,6 +182,7 @@ enum { #define SHIP_MODE_EN_BIT BIT(0) #define BATIF_ADC_CHANNEL_EN_REG (BATIF_BASE + 0x82) #define IBATT_CHANNEL_EN_BIT BIT(6) #define CONN_THM_CHANNEL_EN_BIT BIT(4) #define DIE_TEMP_CHANNEL_EN_BIT BIT(2) #define MISC_THM_CHANNEL_EN_BIT BIT(1) Loading