Loading drivers/power/supply/qcom/battery.c +2 −1 Original line number Diff line number Diff line Loading @@ -314,6 +314,7 @@ static ssize_t slave_pct_store(struct class *c, struct class_attribute *attr, vote(chip->pl_disable_votable, ICL_LIMIT_VOTER, disable, 0); rerun_election(chip->fcc_votable); rerun_election(chip->fv_votable); if (IS_USBIN(chip->pl_mode)) split_settled(chip); return count; Loading drivers/power/supply/qcom/fg-core.h +1 −0 Original line number Diff line number Diff line Loading @@ -206,6 +206,7 @@ enum fg_sram_param_id { FG_SRAM_KI_COEFF_MED_CHG, FG_SRAM_KI_COEFF_HI_CHG, FG_SRAM_KI_COEFF_FULL_SOC, FG_SRAM_KI_COEFF_CUTOFF, FG_SRAM_ESR_TIGHT_FILTER, FG_SRAM_ESR_BROAD_FILTER, FG_SRAM_SLOPE_LIMIT, Loading drivers/power/supply/qcom/qpnp-fg-gen4.c +26 −0 Original line number Diff line number Diff line Loading @@ -77,6 +77,8 @@ #define CUTOFF_CURR_OFFSET 0 #define CUTOFF_VOLT_WORD 20 #define CUTOFF_VOLT_OFFSET 0 #define KI_COEFF_CUTOFF_WORD 21 #define KI_COEFF_CUTOFF_OFFSET 0 #define SYS_TERM_CURR_WORD 22 #define SYS_TERM_CURR_OFFSET 0 #define VBATT_FULL_WORD 23 Loading Loading @@ -233,6 +235,7 @@ struct fg_dt_props { int ki_coeff_low_chg; int ki_coeff_med_chg; int ki_coeff_hi_chg; int ki_coeff_cutoff_gain; int ki_coeff_full_soc_dischg[2]; int ki_coeff_soc[KI_COEFF_SOC_LEVELS]; int ki_coeff_low_dischg[KI_COEFF_SOC_LEVELS]; Loading Loading @@ -412,6 +415,8 @@ static struct fg_sram_param pm8150b_v1_sram_params[] = { 1, 1000, 15625, 0, fg_encode_default, NULL), PARAM(DELTA_ESR_THR, DELTA_ESR_THR_WORD, DELTA_ESR_THR_OFFSET, 2, 1000, 61036, 0, fg_encode_default, NULL), PARAM(KI_COEFF_CUTOFF, KI_COEFF_CUTOFF_WORD, KI_COEFF_CUTOFF_OFFSET, 1, 1000, 61035, 0, fg_encode_default, NULL), PARAM(KI_COEFF_FULL_SOC, KI_COEFF_FULL_SOC_NORM_WORD, KI_COEFF_FULL_SOC_NORM_OFFSET, 1, 1000, 61035, 0, fg_encode_default, NULL), Loading Loading @@ -508,6 +513,8 @@ static struct fg_sram_param pm8150b_v2_sram_params[] = { 1, 1000, 15625, 0, fg_encode_default, NULL), PARAM(DELTA_ESR_THR, DELTA_ESR_THR_WORD, DELTA_ESR_THR_OFFSET, 2, 1000, 61036, 0, fg_encode_default, NULL), PARAM(KI_COEFF_CUTOFF, KI_COEFF_CUTOFF_WORD, KI_COEFF_CUTOFF_OFFSET, 1, 1000, 61035, 0, fg_encode_default, NULL), PARAM(KI_COEFF_FULL_SOC, KI_COEFF_FULL_SOC_NORM_WORD, KI_COEFF_FULL_SOC_NORM_OFFSET, 1, 1000, 61035, 0, fg_encode_default, NULL), Loading Loading @@ -5070,6 +5077,21 @@ static int fg_gen4_hw_init(struct fg_gen4_chip *chip) } } if (chip->dt.ki_coeff_cutoff_gain != -EINVAL) { fg_encode(fg->sp, FG_SRAM_KI_COEFF_CUTOFF, chip->dt.ki_coeff_cutoff_gain, &val); rc = fg_sram_write(fg, fg->sp[FG_SRAM_KI_COEFF_CUTOFF].addr_word, fg->sp[FG_SRAM_KI_COEFF_CUTOFF].addr_byte, &val, fg->sp[FG_SRAM_KI_COEFF_CUTOFF].len, FG_IMA_DEFAULT); if (rc < 0) { pr_err("Error in writing ki_coeff_cutoff_gain, rc=%d\n", rc); return rc; } } rc = fg_gen4_esr_calib_config(chip); if (rc < 0) return rc; Loading Loading @@ -5158,6 +5180,10 @@ static int fg_parse_ki_coefficients(struct fg_dev *fg) of_property_read_u32(node, "qcom,ki-coeff-hi-chg", &chip->dt.ki_coeff_hi_chg); chip->dt.ki_coeff_cutoff_gain = -EINVAL; of_property_read_u32(node, "qcom,ki-coeff-cutoff", &chip->dt.ki_coeff_cutoff_gain); if (!of_find_property(node, "qcom,ki-coeff-soc-dischg", NULL) || (!of_find_property(node, "qcom,ki-coeff-low-dischg", NULL) && !of_find_property(node, "qcom,ki-coeff-med-dischg", NULL) && Loading drivers/power/supply/qcom/qpnp-smb5.c +34 −6 Original line number Diff line number Diff line Loading @@ -728,6 +728,8 @@ static enum power_supply_property smb5_usb_props[] = { POWER_SUPPLY_PROP_CONNECTOR_TYPE, POWER_SUPPLY_PROP_CONNECTOR_HEALTH, POWER_SUPPLY_PROP_VOLTAGE_MAX, POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN, POWER_SUPPLY_PROP_VOLTAGE_MAX_LIMIT, POWER_SUPPLY_PROP_SMB_EN_MODE, POWER_SUPPLY_PROP_SMB_EN_REASON, POWER_SUPPLY_PROP_SCOPE, Loading @@ -754,9 +756,18 @@ static int smb5_usb_get_prop(struct power_supply *psy, case POWER_SUPPLY_PROP_ONLINE: rc = smblib_get_usb_online(chg, val); break; case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN: rc = smblib_get_prop_usb_voltage_max_design(chg, val); break; case POWER_SUPPLY_PROP_VOLTAGE_MAX: rc = smblib_get_prop_usb_voltage_max(chg, val); break; case POWER_SUPPLY_PROP_VOLTAGE_MAX_LIMIT: if (chg->usbin_forced_max_uv) val->intval = chg->usbin_forced_max_uv; else smblib_get_prop_usb_voltage_max_design(chg, val); break; case POWER_SUPPLY_PROP_VOLTAGE_NOW: rc = smblib_get_prop_usb_voltage_now(chg, val); break; Loading Loading @@ -936,6 +947,9 @@ static int smb5_usb_set_prop(struct power_supply *psy, else rc = -EINVAL; break; case POWER_SUPPLY_PROP_VOLTAGE_MAX_LIMIT: smblib_set_prop_usb_voltage_max_limit(chg, val); break; default: pr_err("set prop %d is not supported\n", psp); rc = -EINVAL; Loading @@ -952,6 +966,7 @@ static int smb5_usb_prop_is_writeable(struct power_supply *psy, case POWER_SUPPLY_PROP_CTM_CURRENT_MAX: case POWER_SUPPLY_PROP_CONNECTOR_HEALTH: case POWER_SUPPLY_PROP_THERM_ICL_LIMIT: case POWER_SUPPLY_PROP_VOLTAGE_MAX_LIMIT: return 1; default: break; Loading Loading @@ -2060,9 +2075,18 @@ static int smb5_configure_iterm_thresholds_adc(struct smb5 *chip) static int smb5_configure_iterm_thresholds(struct smb5 *chip) { int rc = 0; struct smb_charger *chg = &chip->chg; switch (chip->dt.term_current_src) { case ITERM_SRC_ADC: rc = smblib_masked_write(chg, CHGR_ADC_TERM_CFG_REG, TERM_BASED_ON_SYNC_CONV_OR_SAMPLE_CNT, TERM_BASED_ON_SAMPLE_CNT); if (rc < 0) { dev_err(chg->dev, "Couldn't configure ADC_ITERM_CFG rc=%d\n", rc); return rc; } rc = smb5_configure_iterm_thresholds_adc(chip); break; default: Loading Loading @@ -2493,13 +2517,15 @@ static int smb5_init_hw(struct smb5 *chip) return rc; } val = WDOG_TIMER_EN_ON_PLUGIN_BIT; if (chip->dt.wd_snarl_time_cfg == -EINVAL) val |= BARK_WDOG_INT_EN_BIT; /* enable WD BARK and enable it on plugin */ rc = smblib_masked_write(chg, WD_CFG_REG, WATCHDOG_TRIGGER_AFP_EN_BIT | WDOG_TIMER_EN_ON_PLUGIN_BIT | BARK_WDOG_INT_EN_BIT, WDOG_TIMER_EN_ON_PLUGIN_BIT | BARK_WDOG_INT_EN_BIT); BARK_WDOG_INT_EN_BIT, val); if (rc < 0) { pr_err("Couldn't configue WD config rc=%d\n", rc); return rc; Loading Loading @@ -2613,7 +2639,7 @@ static int smb5_post_init(struct smb5 *chip) return rc; } rerun_election(chg->usb_irq_enable_votable); rerun_election(chg->temp_change_irq_disable_votable); return 0; } Loading Loading @@ -2953,6 +2979,7 @@ static int smb5_request_interrupt(struct smb5 *chip, irq_data->storm_data = smb5_irqs[irq_index].storm_data; mutex_init(&irq_data->storm_data.storm_lock); smb5_irqs[irq_index].enabled = true; rc = devm_request_threaded_irq(chg->dev, irq, NULL, smb5_irqs[irq_index].handler, IRQF_ONESHOT, irq_name, irq_data); Loading Loading @@ -2986,8 +3013,6 @@ static int smb5_request_interrupts(struct smb5 *chip) return rc; } } if (chg->irq_info[USBIN_ICL_CHANGE_IRQ].irq) chg->usb_icl_change_irq_enabled = true; /* * WDOG_SNARL_IRQ is required for SW Thermal Regulation WA. In case Loading @@ -3002,6 +3027,9 @@ static int smb5_request_interrupts(struct smb5 *chip) disable_irq_nosync(chg->irq_info[WDOG_SNARL_IRQ].irq); } vote(chg->limited_irq_disable_votable, CHARGER_TYPE_VOTER, true, 0); vote(chg->hdc_irq_disable_votable, CHARGER_TYPE_VOTER, true, 0); return rc; } Loading drivers/power/supply/qcom/smb1390-charger-psy.c +41 −1 Original line number Diff line number Diff line Loading @@ -89,6 +89,7 @@ #define WIRELESS_VOTER "WIRELESS_VOTER" #define SRC_VOTER "SRC_VOTER" #define SWITCHER_TOGGLE_VOTER "SWITCHER_TOGGLE_VOTER" #define SOC_LEVEL_VOTER "SOC_LEVEL_VOTER" #define THERMAL_SUSPEND_DECIDEGC 1400 Loading Loading @@ -168,9 +169,11 @@ struct smb1390 { bool switcher_enabled; int die_temp; bool suspended; bool disabled; u32 debug_mask; u32 min_ilim_ua; u32 max_temp_alarm_degc; u32 max_cutoff_soc; }; struct smb_irq { Loading Loading @@ -452,6 +455,28 @@ static int smb1390_get_isns(struct smb1390 *chip, return rc; } static int smb1390_is_batt_soc_valid(struct smb1390 *chip) { int rc; union power_supply_propval pval = {0, }; if (!chip->batt_psy) goto out; rc = power_supply_get_property(chip->batt_psy, POWER_SUPPLY_PROP_CAPACITY, &pval); if (rc < 0) { pr_err("Couldn't get CAPACITY rc=%d\n", rc); goto out; } if (pval.intval >= chip->max_cutoff_soc) return false; out: return true; } /* voter callbacks */ static int smb1390_disable_vote_cb(struct votable *votable, void *data, int disable, const char *client) Loading @@ -475,8 +500,10 @@ static int smb1390_disable_vote_cb(struct votable *votable, void *data, } /* charging may have been disabled by ILIM; send uevent */ if (chip->cp_master_psy) if (chip->cp_master_psy && (disable != chip->disabled)) power_supply_changed(chip->cp_master_psy); chip->disabled = disable; return rc; } Loading Loading @@ -551,6 +578,9 @@ static void smb1390_status_change_work(struct work_struct *work) if (!is_psy_voter_available(chip)) goto out; vote(chip->disable_votable, SOC_LEVEL_VOTER, smb1390_is_batt_soc_valid(chip) ? false : true, 0); rc = power_supply_get_property(chip->usb_psy, POWER_SUPPLY_PROP_SMB_EN_MODE, &pval); if (rc < 0) { Loading Loading @@ -629,6 +659,7 @@ static void smb1390_status_change_work(struct work_struct *work) vote(chip->disable_votable, SRC_VOTER, true, 0); vote(chip->disable_votable, TAPER_END_VOTER, false, 0); vote(chip->fcc_votable, CP_VOTER, false, 0); vote(chip->disable_votable, SOC_LEVEL_VOTER, true, 0); } out: Loading Loading @@ -896,6 +927,10 @@ static int smb1390_parse_dt(struct smb1390 *chip) of_property_read_u32(chip->dev->of_node, "qcom,max-temp-alarm-degc", &chip->max_temp_alarm_degc); chip->max_cutoff_soc = 85; /* 85% */ of_property_read_u32(chip->dev->of_node, "qcom,max-cutoff-soc", &chip->max_cutoff_soc); return 0; } Loading @@ -922,6 +957,9 @@ static int smb1390_create_votables(struct smb1390 *chip) * traditional parallel charging if present */ vote(chip->disable_votable, USER_VOTER, true, 0); /* keep charge pump disabled if SOC is above threshold */ vote(chip->disable_votable, SOC_LEVEL_VOTER, smb1390_is_batt_soc_valid(chip) ? false : true, 0); /* * In case SMB1390 probe happens after FCC value has been configured, Loading Loading @@ -1110,6 +1148,7 @@ static int smb1390_probe(struct platform_device *pdev) mutex_init(&chip->die_chan_lock); chip->die_temp = -ENODATA; chip->pmic_rev_id = pmic_rev_id; chip->disabled = true; platform_set_drvdata(pdev, chip); chip->regmap = dev_get_regmap(chip->dev->parent, NULL); Loading Loading @@ -1187,6 +1226,7 @@ static int smb1390_remove(struct platform_device *pdev) /* explicitly disable charging */ vote(chip->disable_votable, USER_VOTER, true, 0); vote(chip->disable_votable, SOC_LEVEL_VOTER, true, 0); cancel_work_sync(&chip->taper_work); cancel_work_sync(&chip->status_change_work); wakeup_source_unregister(chip->cp_ws); Loading Loading
drivers/power/supply/qcom/battery.c +2 −1 Original line number Diff line number Diff line Loading @@ -314,6 +314,7 @@ static ssize_t slave_pct_store(struct class *c, struct class_attribute *attr, vote(chip->pl_disable_votable, ICL_LIMIT_VOTER, disable, 0); rerun_election(chip->fcc_votable); rerun_election(chip->fv_votable); if (IS_USBIN(chip->pl_mode)) split_settled(chip); return count; Loading
drivers/power/supply/qcom/fg-core.h +1 −0 Original line number Diff line number Diff line Loading @@ -206,6 +206,7 @@ enum fg_sram_param_id { FG_SRAM_KI_COEFF_MED_CHG, FG_SRAM_KI_COEFF_HI_CHG, FG_SRAM_KI_COEFF_FULL_SOC, FG_SRAM_KI_COEFF_CUTOFF, FG_SRAM_ESR_TIGHT_FILTER, FG_SRAM_ESR_BROAD_FILTER, FG_SRAM_SLOPE_LIMIT, Loading
drivers/power/supply/qcom/qpnp-fg-gen4.c +26 −0 Original line number Diff line number Diff line Loading @@ -77,6 +77,8 @@ #define CUTOFF_CURR_OFFSET 0 #define CUTOFF_VOLT_WORD 20 #define CUTOFF_VOLT_OFFSET 0 #define KI_COEFF_CUTOFF_WORD 21 #define KI_COEFF_CUTOFF_OFFSET 0 #define SYS_TERM_CURR_WORD 22 #define SYS_TERM_CURR_OFFSET 0 #define VBATT_FULL_WORD 23 Loading Loading @@ -233,6 +235,7 @@ struct fg_dt_props { int ki_coeff_low_chg; int ki_coeff_med_chg; int ki_coeff_hi_chg; int ki_coeff_cutoff_gain; int ki_coeff_full_soc_dischg[2]; int ki_coeff_soc[KI_COEFF_SOC_LEVELS]; int ki_coeff_low_dischg[KI_COEFF_SOC_LEVELS]; Loading Loading @@ -412,6 +415,8 @@ static struct fg_sram_param pm8150b_v1_sram_params[] = { 1, 1000, 15625, 0, fg_encode_default, NULL), PARAM(DELTA_ESR_THR, DELTA_ESR_THR_WORD, DELTA_ESR_THR_OFFSET, 2, 1000, 61036, 0, fg_encode_default, NULL), PARAM(KI_COEFF_CUTOFF, KI_COEFF_CUTOFF_WORD, KI_COEFF_CUTOFF_OFFSET, 1, 1000, 61035, 0, fg_encode_default, NULL), PARAM(KI_COEFF_FULL_SOC, KI_COEFF_FULL_SOC_NORM_WORD, KI_COEFF_FULL_SOC_NORM_OFFSET, 1, 1000, 61035, 0, fg_encode_default, NULL), Loading Loading @@ -508,6 +513,8 @@ static struct fg_sram_param pm8150b_v2_sram_params[] = { 1, 1000, 15625, 0, fg_encode_default, NULL), PARAM(DELTA_ESR_THR, DELTA_ESR_THR_WORD, DELTA_ESR_THR_OFFSET, 2, 1000, 61036, 0, fg_encode_default, NULL), PARAM(KI_COEFF_CUTOFF, KI_COEFF_CUTOFF_WORD, KI_COEFF_CUTOFF_OFFSET, 1, 1000, 61035, 0, fg_encode_default, NULL), PARAM(KI_COEFF_FULL_SOC, KI_COEFF_FULL_SOC_NORM_WORD, KI_COEFF_FULL_SOC_NORM_OFFSET, 1, 1000, 61035, 0, fg_encode_default, NULL), Loading Loading @@ -5070,6 +5077,21 @@ static int fg_gen4_hw_init(struct fg_gen4_chip *chip) } } if (chip->dt.ki_coeff_cutoff_gain != -EINVAL) { fg_encode(fg->sp, FG_SRAM_KI_COEFF_CUTOFF, chip->dt.ki_coeff_cutoff_gain, &val); rc = fg_sram_write(fg, fg->sp[FG_SRAM_KI_COEFF_CUTOFF].addr_word, fg->sp[FG_SRAM_KI_COEFF_CUTOFF].addr_byte, &val, fg->sp[FG_SRAM_KI_COEFF_CUTOFF].len, FG_IMA_DEFAULT); if (rc < 0) { pr_err("Error in writing ki_coeff_cutoff_gain, rc=%d\n", rc); return rc; } } rc = fg_gen4_esr_calib_config(chip); if (rc < 0) return rc; Loading Loading @@ -5158,6 +5180,10 @@ static int fg_parse_ki_coefficients(struct fg_dev *fg) of_property_read_u32(node, "qcom,ki-coeff-hi-chg", &chip->dt.ki_coeff_hi_chg); chip->dt.ki_coeff_cutoff_gain = -EINVAL; of_property_read_u32(node, "qcom,ki-coeff-cutoff", &chip->dt.ki_coeff_cutoff_gain); if (!of_find_property(node, "qcom,ki-coeff-soc-dischg", NULL) || (!of_find_property(node, "qcom,ki-coeff-low-dischg", NULL) && !of_find_property(node, "qcom,ki-coeff-med-dischg", NULL) && Loading
drivers/power/supply/qcom/qpnp-smb5.c +34 −6 Original line number Diff line number Diff line Loading @@ -728,6 +728,8 @@ static enum power_supply_property smb5_usb_props[] = { POWER_SUPPLY_PROP_CONNECTOR_TYPE, POWER_SUPPLY_PROP_CONNECTOR_HEALTH, POWER_SUPPLY_PROP_VOLTAGE_MAX, POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN, POWER_SUPPLY_PROP_VOLTAGE_MAX_LIMIT, POWER_SUPPLY_PROP_SMB_EN_MODE, POWER_SUPPLY_PROP_SMB_EN_REASON, POWER_SUPPLY_PROP_SCOPE, Loading @@ -754,9 +756,18 @@ static int smb5_usb_get_prop(struct power_supply *psy, case POWER_SUPPLY_PROP_ONLINE: rc = smblib_get_usb_online(chg, val); break; case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN: rc = smblib_get_prop_usb_voltage_max_design(chg, val); break; case POWER_SUPPLY_PROP_VOLTAGE_MAX: rc = smblib_get_prop_usb_voltage_max(chg, val); break; case POWER_SUPPLY_PROP_VOLTAGE_MAX_LIMIT: if (chg->usbin_forced_max_uv) val->intval = chg->usbin_forced_max_uv; else smblib_get_prop_usb_voltage_max_design(chg, val); break; case POWER_SUPPLY_PROP_VOLTAGE_NOW: rc = smblib_get_prop_usb_voltage_now(chg, val); break; Loading Loading @@ -936,6 +947,9 @@ static int smb5_usb_set_prop(struct power_supply *psy, else rc = -EINVAL; break; case POWER_SUPPLY_PROP_VOLTAGE_MAX_LIMIT: smblib_set_prop_usb_voltage_max_limit(chg, val); break; default: pr_err("set prop %d is not supported\n", psp); rc = -EINVAL; Loading @@ -952,6 +966,7 @@ static int smb5_usb_prop_is_writeable(struct power_supply *psy, case POWER_SUPPLY_PROP_CTM_CURRENT_MAX: case POWER_SUPPLY_PROP_CONNECTOR_HEALTH: case POWER_SUPPLY_PROP_THERM_ICL_LIMIT: case POWER_SUPPLY_PROP_VOLTAGE_MAX_LIMIT: return 1; default: break; Loading Loading @@ -2060,9 +2075,18 @@ static int smb5_configure_iterm_thresholds_adc(struct smb5 *chip) static int smb5_configure_iterm_thresholds(struct smb5 *chip) { int rc = 0; struct smb_charger *chg = &chip->chg; switch (chip->dt.term_current_src) { case ITERM_SRC_ADC: rc = smblib_masked_write(chg, CHGR_ADC_TERM_CFG_REG, TERM_BASED_ON_SYNC_CONV_OR_SAMPLE_CNT, TERM_BASED_ON_SAMPLE_CNT); if (rc < 0) { dev_err(chg->dev, "Couldn't configure ADC_ITERM_CFG rc=%d\n", rc); return rc; } rc = smb5_configure_iterm_thresholds_adc(chip); break; default: Loading Loading @@ -2493,13 +2517,15 @@ static int smb5_init_hw(struct smb5 *chip) return rc; } val = WDOG_TIMER_EN_ON_PLUGIN_BIT; if (chip->dt.wd_snarl_time_cfg == -EINVAL) val |= BARK_WDOG_INT_EN_BIT; /* enable WD BARK and enable it on plugin */ rc = smblib_masked_write(chg, WD_CFG_REG, WATCHDOG_TRIGGER_AFP_EN_BIT | WDOG_TIMER_EN_ON_PLUGIN_BIT | BARK_WDOG_INT_EN_BIT, WDOG_TIMER_EN_ON_PLUGIN_BIT | BARK_WDOG_INT_EN_BIT); BARK_WDOG_INT_EN_BIT, val); if (rc < 0) { pr_err("Couldn't configue WD config rc=%d\n", rc); return rc; Loading Loading @@ -2613,7 +2639,7 @@ static int smb5_post_init(struct smb5 *chip) return rc; } rerun_election(chg->usb_irq_enable_votable); rerun_election(chg->temp_change_irq_disable_votable); return 0; } Loading Loading @@ -2953,6 +2979,7 @@ static int smb5_request_interrupt(struct smb5 *chip, irq_data->storm_data = smb5_irqs[irq_index].storm_data; mutex_init(&irq_data->storm_data.storm_lock); smb5_irqs[irq_index].enabled = true; rc = devm_request_threaded_irq(chg->dev, irq, NULL, smb5_irqs[irq_index].handler, IRQF_ONESHOT, irq_name, irq_data); Loading Loading @@ -2986,8 +3013,6 @@ static int smb5_request_interrupts(struct smb5 *chip) return rc; } } if (chg->irq_info[USBIN_ICL_CHANGE_IRQ].irq) chg->usb_icl_change_irq_enabled = true; /* * WDOG_SNARL_IRQ is required for SW Thermal Regulation WA. In case Loading @@ -3002,6 +3027,9 @@ static int smb5_request_interrupts(struct smb5 *chip) disable_irq_nosync(chg->irq_info[WDOG_SNARL_IRQ].irq); } vote(chg->limited_irq_disable_votable, CHARGER_TYPE_VOTER, true, 0); vote(chg->hdc_irq_disable_votable, CHARGER_TYPE_VOTER, true, 0); return rc; } Loading
drivers/power/supply/qcom/smb1390-charger-psy.c +41 −1 Original line number Diff line number Diff line Loading @@ -89,6 +89,7 @@ #define WIRELESS_VOTER "WIRELESS_VOTER" #define SRC_VOTER "SRC_VOTER" #define SWITCHER_TOGGLE_VOTER "SWITCHER_TOGGLE_VOTER" #define SOC_LEVEL_VOTER "SOC_LEVEL_VOTER" #define THERMAL_SUSPEND_DECIDEGC 1400 Loading Loading @@ -168,9 +169,11 @@ struct smb1390 { bool switcher_enabled; int die_temp; bool suspended; bool disabled; u32 debug_mask; u32 min_ilim_ua; u32 max_temp_alarm_degc; u32 max_cutoff_soc; }; struct smb_irq { Loading Loading @@ -452,6 +455,28 @@ static int smb1390_get_isns(struct smb1390 *chip, return rc; } static int smb1390_is_batt_soc_valid(struct smb1390 *chip) { int rc; union power_supply_propval pval = {0, }; if (!chip->batt_psy) goto out; rc = power_supply_get_property(chip->batt_psy, POWER_SUPPLY_PROP_CAPACITY, &pval); if (rc < 0) { pr_err("Couldn't get CAPACITY rc=%d\n", rc); goto out; } if (pval.intval >= chip->max_cutoff_soc) return false; out: return true; } /* voter callbacks */ static int smb1390_disable_vote_cb(struct votable *votable, void *data, int disable, const char *client) Loading @@ -475,8 +500,10 @@ static int smb1390_disable_vote_cb(struct votable *votable, void *data, } /* charging may have been disabled by ILIM; send uevent */ if (chip->cp_master_psy) if (chip->cp_master_psy && (disable != chip->disabled)) power_supply_changed(chip->cp_master_psy); chip->disabled = disable; return rc; } Loading Loading @@ -551,6 +578,9 @@ static void smb1390_status_change_work(struct work_struct *work) if (!is_psy_voter_available(chip)) goto out; vote(chip->disable_votable, SOC_LEVEL_VOTER, smb1390_is_batt_soc_valid(chip) ? false : true, 0); rc = power_supply_get_property(chip->usb_psy, POWER_SUPPLY_PROP_SMB_EN_MODE, &pval); if (rc < 0) { Loading Loading @@ -629,6 +659,7 @@ static void smb1390_status_change_work(struct work_struct *work) vote(chip->disable_votable, SRC_VOTER, true, 0); vote(chip->disable_votable, TAPER_END_VOTER, false, 0); vote(chip->fcc_votable, CP_VOTER, false, 0); vote(chip->disable_votable, SOC_LEVEL_VOTER, true, 0); } out: Loading Loading @@ -896,6 +927,10 @@ static int smb1390_parse_dt(struct smb1390 *chip) of_property_read_u32(chip->dev->of_node, "qcom,max-temp-alarm-degc", &chip->max_temp_alarm_degc); chip->max_cutoff_soc = 85; /* 85% */ of_property_read_u32(chip->dev->of_node, "qcom,max-cutoff-soc", &chip->max_cutoff_soc); return 0; } Loading @@ -922,6 +957,9 @@ static int smb1390_create_votables(struct smb1390 *chip) * traditional parallel charging if present */ vote(chip->disable_votable, USER_VOTER, true, 0); /* keep charge pump disabled if SOC is above threshold */ vote(chip->disable_votable, SOC_LEVEL_VOTER, smb1390_is_batt_soc_valid(chip) ? false : true, 0); /* * In case SMB1390 probe happens after FCC value has been configured, Loading Loading @@ -1110,6 +1148,7 @@ static int smb1390_probe(struct platform_device *pdev) mutex_init(&chip->die_chan_lock); chip->die_temp = -ENODATA; chip->pmic_rev_id = pmic_rev_id; chip->disabled = true; platform_set_drvdata(pdev, chip); chip->regmap = dev_get_regmap(chip->dev->parent, NULL); Loading Loading @@ -1187,6 +1226,7 @@ static int smb1390_remove(struct platform_device *pdev) /* explicitly disable charging */ vote(chip->disable_votable, USER_VOTER, true, 0); vote(chip->disable_votable, SOC_LEVEL_VOTER, true, 0); cancel_work_sync(&chip->taper_work); cancel_work_sync(&chip->status_change_work); wakeup_source_unregister(chip->cp_ws); Loading