Loading drivers/power/supply/qcom/battery.c +74 −18 Original line number Original line Diff line number Diff line Loading @@ -100,11 +100,15 @@ struct pl_data { struct class qcom_batt_class; struct class qcom_batt_class; struct wakeup_source *pl_ws; struct wakeup_source *pl_ws; struct notifier_block nb; struct notifier_block nb; struct charger_param *chg_param; bool pl_disable; bool pl_disable; bool cp_disabled; bool cp_disabled; int taper_entry_fv; int taper_entry_fv; int main_fcc_max; int main_fcc_max; u32 float_voltage_uv; u32 float_voltage_uv; /* debugfs directory */ struct dentry *dfs_root; }; }; struct pl_data *the_chip; struct pl_data *the_chip; Loading Loading @@ -146,6 +150,15 @@ enum { /********* /********* * HELPER* * HELPER* *********/ *********/ static bool is_usb_available(struct pl_data *chip) { if (!chip->usb_psy) chip->usb_psy = power_supply_get_by_name("usb"); return !!chip->usb_psy; } static bool is_cp_available(struct pl_data *chip) static bool is_cp_available(struct pl_data *chip) { { if (!chip->cp_master_psy) if (!chip->cp_master_psy) Loading Loading @@ -199,9 +212,12 @@ static int cp_get_parallel_mode(struct pl_data *chip, int mode) */ */ static void cp_configure_ilim(struct pl_data *chip, const char *voter, int ilim) static void cp_configure_ilim(struct pl_data *chip, const char *voter, int ilim) { { int rc, fcc; int rc, fcc, main_icl, target_icl = chip->chg_param->hvdcp3_max_icl_ua; union power_supply_propval pval = {0, }; union power_supply_propval pval = {0, }; if (!is_usb_available(chip)) return; if (!is_cp_available(chip)) if (!is_cp_available(chip)) return; return; Loading @@ -209,6 +225,31 @@ static void cp_configure_ilim(struct pl_data *chip, const char *voter, int ilim) == POWER_SUPPLY_PL_OUTPUT_VPH) == POWER_SUPPLY_PL_OUTPUT_VPH) return; return; rc = power_supply_get_property(chip->usb_psy, POWER_SUPPLY_PROP_REAL_TYPE, &pval); if (rc < 0) return; /* * For HVDCP3 adapters limit max. ILIM based on DT configuration * of HVDCP3 ICL value. * Input VBUS: * target_icl = HVDCP3_ICL - main_ICL * Input VMID * target_icl = HVDCP3_ICL */ if (pval.intval == POWER_SUPPLY_TYPE_USB_HVDCP_3) { if (((cp_get_parallel_mode(chip, PARALLEL_INPUT_MODE)) == POWER_SUPPLY_PL_USBIN_USBIN)) { main_icl = get_effective_result_locked( chip->usb_icl_votable); if ((main_icl >= 0) && (main_icl < target_icl)) target_icl -= main_icl; } ilim = min(target_icl, ilim); } rc = power_supply_get_property(chip->cp_master_psy, rc = power_supply_get_property(chip->cp_master_psy, POWER_SUPPLY_PROP_MIN_ICL, &pval); POWER_SUPPLY_PROP_MIN_ICL, &pval); if (rc < 0) if (rc < 0) Loading @@ -230,6 +271,10 @@ static void cp_configure_ilim(struct pl_data *chip, const char *voter, int ilim) vote(chip->cp_ilim_votable, voter, true, pval.intval); vote(chip->cp_ilim_votable, voter, true, pval.intval); else else vote(chip->cp_ilim_votable, voter, true, ilim); vote(chip->cp_ilim_votable, voter, true, ilim); pl_dbg(chip, PR_PARALLEL, "ILIM: vote: %d voter:%s min_ilim=%d fcc = %d\n", ilim, voter, pval.intval, fcc); } } } } Loading Loading @@ -526,8 +571,6 @@ ATTRIBUTE_GROUPS(batt_class); * FCC * * FCC * **********/ **********/ #define EFFICIENCY_PCT 80 #define EFFICIENCY_PCT 80 #define FCC_STEP_SIZE_UA 100000 #define FCC_STEP_UPDATE_DELAY_MS 1000 #define STEP_UP 1 #define STEP_UP 1 #define STEP_DOWN -1 #define STEP_DOWN -1 static void get_fcc_split(struct pl_data *chip, int total_ua, static void get_fcc_split(struct pl_data *chip, int total_ua, Loading Loading @@ -630,6 +673,11 @@ static void get_fcc_stepper_params(struct pl_data *chip, int main_fcc_ua, { { int main_set_fcc_ua, total_fcc_ua; int main_set_fcc_ua, total_fcc_ua; if (!chip->chg_param->fcc_step_size_ua) { pr_err("Invalid fcc stepper step size, value 0\n"); return; } if (is_override_vote_enabled_locked(chip->fcc_main_votable)) { if (is_override_vote_enabled_locked(chip->fcc_main_votable)) { /* /* * FCC stepper params need re-calculation in override mode * FCC stepper params need re-calculation in override mode Loading @@ -650,21 +698,24 @@ static void get_fcc_stepper_params(struct pl_data *chip, int main_fcc_ua, goto skip_fcc_step_update; goto skip_fcc_step_update; } } } } /* Read current FCC of main charger */ /* Read current FCC of main charger */ chip->main_fcc_ua = get_effective_result(chip->fcc_main_votable); chip->main_fcc_ua = get_effective_result(chip->fcc_main_votable); chip->main_step_fcc_dir = (main_fcc_ua > chip->main_fcc_ua) ? chip->main_step_fcc_dir = (main_fcc_ua > chip->main_fcc_ua) ? STEP_UP : STEP_DOWN; STEP_UP : STEP_DOWN; chip->main_step_fcc_count = abs((main_fcc_ua - chip->main_fcc_ua) / chip->main_step_fcc_count = abs((main_fcc_ua - chip->main_fcc_ua) / FCC_STEP_SIZE_UA); chip->chg_param->fcc_step_size_ua); chip->main_step_fcc_residual = abs((main_fcc_ua - chip->main_fcc_ua) % chip->main_step_fcc_residual = abs((main_fcc_ua - chip->main_fcc_ua) % FCC_STEP_SIZE_UA); chip->chg_param->fcc_step_size_ua); chip->parallel_step_fcc_dir = (parallel_fcc_ua > chip->slave_fcc_ua) ? chip->parallel_step_fcc_dir = (parallel_fcc_ua > chip->slave_fcc_ua) ? STEP_UP : STEP_DOWN; STEP_UP : STEP_DOWN; chip->parallel_step_fcc_count = abs((parallel_fcc_ua - chip->parallel_step_fcc_count chip->slave_fcc_ua) / FCC_STEP_SIZE_UA); = abs((parallel_fcc_ua - chip->slave_fcc_ua) / chip->parallel_step_fcc_residual = abs((parallel_fcc_ua - chip->chg_param->fcc_step_size_ua); chip->slave_fcc_ua)) % FCC_STEP_SIZE_UA; chip->parallel_step_fcc_residual = abs((parallel_fcc_ua - chip->slave_fcc_ua) % chip->chg_param->fcc_step_size_ua); skip_fcc_step_update: skip_fcc_step_update: if (chip->parallel_step_fcc_count || chip->parallel_step_fcc_residual if (chip->parallel_step_fcc_count || chip->parallel_step_fcc_residual Loading Loading @@ -955,19 +1006,20 @@ static void fcc_stepper_work(struct work_struct *work) } } if (chip->main_step_fcc_count) { if (chip->main_step_fcc_count) { main_fcc += (FCC_STEP_SIZE_UA * chip->main_step_fcc_dir); main_fcc += (chip->chg_param->fcc_step_size_ua * chip->main_step_fcc_dir); chip->main_step_fcc_count--; chip->main_step_fcc_count--; reschedule_ms = FCC_STEP_UPDATE_DELAY_MS; reschedule_ms = chip->chg_param->fcc_step_delay_ms; } else if (chip->main_step_fcc_residual) { } else if (chip->main_step_fcc_residual) { main_fcc += chip->main_step_fcc_residual; main_fcc += chip->main_step_fcc_residual; chip->main_step_fcc_residual = 0; chip->main_step_fcc_residual = 0; } } if (chip->parallel_step_fcc_count) { if (chip->parallel_step_fcc_count) { parallel_fcc += (FCC_STEP_SIZE_UA * parallel_fcc += (chip->chg_param->fcc_step_size_ua chip->parallel_step_fcc_dir); * chip->parallel_step_fcc_dir); chip->parallel_step_fcc_count--; chip->parallel_step_fcc_count--; reschedule_ms = FCC_STEP_UPDATE_DELAY_MS; reschedule_ms = chip->chg_param->fcc_step_delay_ms; } else if (chip->parallel_step_fcc_residual) { } else if (chip->parallel_step_fcc_residual) { parallel_fcc += chip->parallel_step_fcc_residual; parallel_fcc += chip->parallel_step_fcc_residual; chip->parallel_step_fcc_residual = 0; chip->parallel_step_fcc_residual = 0; Loading Loading @@ -1806,19 +1858,22 @@ static void pl_config_init(struct pl_data *chip, int smb_version) case PM660_SUBTYPE: case PM660_SUBTYPE: chip->wa_flags = AICL_RERUN_WA_BIT | FORCE_INOV_DISABLE_BIT; chip->wa_flags = AICL_RERUN_WA_BIT | FORCE_INOV_DISABLE_BIT; break; break; case PMI632_SUBTYPE: break; default: default: break; break; } } } } #define DEFAULT_RESTRICTED_CURRENT_UA 1000000 #define DEFAULT_RESTRICTED_CURRENT_UA 1000000 int qcom_batt_init(int smb_version) int qcom_batt_init(struct charger_param *chg_param) { { struct pl_data *chip; struct pl_data *chip; int rc = 0; int rc = 0; if (!chg_param) { pr_err("invalid charger parameter\n"); return -EINVAL; } /* initialize just once */ /* initialize just once */ if (the_chip) { if (the_chip) { pr_err("was initialized earlier. Failing now\n"); pr_err("was initialized earlier. Failing now\n"); Loading @@ -1829,7 +1884,8 @@ int qcom_batt_init(int smb_version) if (!chip) if (!chip) return -ENOMEM; return -ENOMEM; chip->slave_pct = 50; chip->slave_pct = 50; pl_config_init(chip, smb_version); chip->chg_param = chg_param; pl_config_init(chip, chg_param->smb_version); chip->restricted_current = DEFAULT_RESTRICTED_CURRENT_UA; chip->restricted_current = DEFAULT_RESTRICTED_CURRENT_UA; chip->pl_ws = wakeup_source_register("qcom-battery"); chip->pl_ws = wakeup_source_register("qcom-battery"); Loading drivers/power/supply/qcom/battery.h +10 −2 Original line number Original line Diff line number Diff line /* Copyright (c) 2017 The Linux Foundation. All rights reserved. /* Copyright (c) 2017, 2019 The Linux Foundation. All rights reserved. * * * This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and * it under the terms of the GNU General Public License version 2 and Loading @@ -12,6 +12,14 @@ #ifndef __BATTERY_H #ifndef __BATTERY_H #define __BATTERY_H #define __BATTERY_H int qcom_batt_init(int smb_version); struct charger_param { u32 fcc_step_delay_ms; u32 fcc_step_size_ua; u32 smb_version; u32 hvdcp3_max_icl_ua; }; int qcom_batt_init(struct charger_param *param); void qcom_batt_deinit(void); void qcom_batt_deinit(void); #endif /* __BATTERY_H */ #endif /* __BATTERY_H */ drivers/power/supply/qcom/qpnp-smb5.c +61 −26 Original line number Original line Diff line number Diff line Loading @@ -288,13 +288,13 @@ static int smb5_chg_config_init(struct smb5 *chip) switch (pmic_rev_id->pmic_subtype) { switch (pmic_rev_id->pmic_subtype) { case PM8150B_SUBTYPE: case PM8150B_SUBTYPE: chip->chg.smb_version = PM8150B_SUBTYPE; chip->chg.chg_param.smb_version = PM8150B_SUBTYPE; chg->param = smb5_pm8150b_params; chg->param = smb5_pm8150b_params; chg->name = "pm8150b_charger"; chg->name = "pm8150b_charger"; chg->wa_flags |= CHG_TERMINATION_WA; chg->wa_flags |= CHG_TERMINATION_WA; break; break; case PM6150_SUBTYPE: case PM6150_SUBTYPE: chip->chg.smb_version = PM6150_SUBTYPE; chip->chg.chg_param.smb_version = PM6150_SUBTYPE; chg->param = smb5_pm8150b_params; chg->param = smb5_pm8150b_params; chg->name = "pm6150_charger"; chg->name = "pm6150_charger"; chg->wa_flags |= SW_THERM_REGULATION_WA | CHG_TERMINATION_WA; chg->wa_flags |= SW_THERM_REGULATION_WA | CHG_TERMINATION_WA; Loading @@ -303,7 +303,7 @@ static int smb5_chg_config_init(struct smb5 *chip) chg->main_fcc_max = PM6150_MAX_FCC_UA; chg->main_fcc_max = PM6150_MAX_FCC_UA; break; break; case PMI632_SUBTYPE: case PMI632_SUBTYPE: chip->chg.smb_version = PMI632_SUBTYPE; chip->chg.chg_param.smb_version = PMI632_SUBTYPE; chg->wa_flags |= WEAK_ADAPTER_WA | USBIN_OV_WA chg->wa_flags |= WEAK_ADAPTER_WA | USBIN_OV_WA | CHG_TERMINATION_WA; | CHG_TERMINATION_WA; chg->param = smb5_pmi632_params; chg->param = smb5_pmi632_params; Loading Loading @@ -390,7 +390,8 @@ static int smb5_configure_internal_pull(struct smb_charger *chg, int type, #define OTG_DEFAULT_DEGLITCH_TIME_MS 50 #define OTG_DEFAULT_DEGLITCH_TIME_MS 50 #define DEFAULT_WD_BARK_TIME 64 #define DEFAULT_WD_BARK_TIME 64 #define DEFAULT_WD_SNARL_TIME_8S 0x07 #define DEFAULT_WD_SNARL_TIME_8S 0x07 #define DEFAULT_FCC_STEP_SIZE_UA 100000 #define DEFAULT_FCC_STEP_UPDATE_DELAY_MS 1000 static int smb5_parse_dt(struct smb5 *chip) static int smb5_parse_dt(struct smb5 *chip) { { struct smb_charger *chg = &chip->chg; struct smb_charger *chg = &chip->chg; Loading Loading @@ -457,8 +458,9 @@ static int smb5_parse_dt(struct smb5 *chip) rc = of_property_read_u32(node, rc = of_property_read_u32(node, "qcom,otg-cl-ua", &chg->otg_cl_ua); "qcom,otg-cl-ua", &chg->otg_cl_ua); if (rc < 0) if (rc < 0) chg->otg_cl_ua = (chip->chg.smb_version == PMI632_SUBTYPE) ? chg->otg_cl_ua = MICRO_1PA : MICRO_3PA; (chip->chg.chg_param.smb_version == PMI632_SUBTYPE) ? MICRO_1PA : MICRO_3PA; rc = of_property_read_u32(node, "qcom,chg-term-src", rc = of_property_read_u32(node, "qcom,chg-term-src", &chip->dt.term_current_src); &chip->dt.term_current_src); Loading Loading @@ -628,6 +630,29 @@ static int smb5_parse_dt(struct smb5 *chip) chip->dt.disable_suspend_on_collapse = of_property_read_bool(node, chip->dt.disable_suspend_on_collapse = of_property_read_bool(node, "qcom,disable-suspend-on-collapse"); "qcom,disable-suspend-on-collapse"); of_property_read_u32(node, "qcom,fcc-step-delay-ms", &chg->chg_param.fcc_step_delay_ms); if (chg->chg_param.fcc_step_delay_ms <= 0) chg->chg_param.fcc_step_delay_ms = DEFAULT_FCC_STEP_UPDATE_DELAY_MS; of_property_read_u32(node, "qcom,fcc-step-size-ua", &chg->chg_param.fcc_step_size_ua); if (chg->chg_param.fcc_step_size_ua <= 0) chg->chg_param.fcc_step_size_ua = DEFAULT_FCC_STEP_SIZE_UA; /* * If property is present parallel charging with CP is disabled * with HVDCP3 adapter. */ chg->hvdcp3_standalone_config = of_property_read_bool(node, "qcom,hvdcp3-standalone-config"); of_property_read_u32(node, "qcom,hvdcp3-max-icl-ua", &chg->chg_param.hvdcp3_max_icl_ua); if (chg->chg_param.hvdcp3_max_icl_ua <= 0) chg->chg_param.hvdcp3_max_icl_ua = MICRO_3PA; return 0; return 0; } } Loading Loading @@ -1219,20 +1244,26 @@ static int smb5_usb_main_set_prop(struct power_supply *psy, struct smb5 *chip = power_supply_get_drvdata(psy); struct smb5 *chip = power_supply_get_drvdata(psy); struct smb_charger *chg = &chip->chg; struct smb_charger *chg = &chip->chg; union power_supply_propval pval = {0, }; union power_supply_propval pval = {0, }; int rc = 0; int rc = 0, offset_ua = 0; switch (psp) { switch (psp) { case POWER_SUPPLY_PROP_VOLTAGE_MAX: case POWER_SUPPLY_PROP_VOLTAGE_MAX: rc = smblib_set_charge_param(chg, &chg->param.fv, val->intval); rc = smblib_set_charge_param(chg, &chg->param.fv, val->intval); break; break; case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX: case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX: rc = smblib_set_charge_param(chg, &chg->param.fcc, val->intval); /* Adjust Main FCC for QC3.0 + SMB1390 */ rc = smblib_get_qc3_main_icl_offset(chg, &offset_ua); if (rc < 0) offset_ua = 0; rc = smblib_set_charge_param(chg, &chg->param.fcc, val->intval + offset_ua); break; break; case POWER_SUPPLY_PROP_CURRENT_MAX: case POWER_SUPPLY_PROP_CURRENT_MAX: rc = smblib_set_icl_current(chg, val->intval); rc = smblib_set_icl_current(chg, val->intval); break; break; case POWER_SUPPLY_PROP_FLASH_ACTIVE: case POWER_SUPPLY_PROP_FLASH_ACTIVE: if ((chg->smb_version == PMI632_SUBTYPE) if ((chg->chg_param.smb_version == PMI632_SUBTYPE) && (chg->flash_active != val->intval)) { && (chg->flash_active != val->intval)) { chg->flash_active = val->intval; chg->flash_active = val->intval; Loading Loading @@ -1278,6 +1309,9 @@ static int smb5_usb_main_set_prop(struct power_supply *psy, case POWER_SUPPLY_PROP_FORCE_MAIN_ICL: case POWER_SUPPLY_PROP_FORCE_MAIN_ICL: vote_override(chg->usb_icl_votable, CC_MODE_VOTER, vote_override(chg->usb_icl_votable, CC_MODE_VOTER, (val->intval < 0) ? false : true, val->intval); (val->intval < 0) ? false : true, val->intval); /* Main ICL updated re-calculate ILIM */ if (chg->real_charger_type == POWER_SUPPLY_TYPE_USB_HVDCP_3) rerun_election(chg->fcc_votable); break; break; case POWER_SUPPLY_PROP_COMP_CLAMP_LEVEL: case POWER_SUPPLY_PROP_COMP_CLAMP_LEVEL: rc = smb5_set_prop_comp_clamp_level(chg, val); rc = smb5_set_prop_comp_clamp_level(chg, val); Loading Loading @@ -2204,7 +2238,7 @@ static int smb5_configure_typec(struct smb_charger *chg) return rc; return rc; } } if (chg->smb_version != PMI632_SUBTYPE) { if (chg->chg_param.smb_version != PMI632_SUBTYPE) { rc = smblib_masked_write(chg, USBIN_LOAD_CFG_REG, rc = smblib_masked_write(chg, USBIN_LOAD_CFG_REG, USBIN_IN_COLLAPSE_GF_SEL_MASK | USBIN_IN_COLLAPSE_GF_SEL_MASK | USBIN_AICL_STEP_TIMING_SEL_MASK, USBIN_AICL_STEP_TIMING_SEL_MASK, Loading Loading @@ -2265,9 +2299,10 @@ static int smb5_configure_micro_usb(struct smb_charger *chg) } } /* Disable periodic monitoring of CC_ID pin */ /* Disable periodic monitoring of CC_ID pin */ rc = smblib_write(chg, ((chg->smb_version == PMI632_SUBTYPE) ? rc = smblib_write(chg, PMI632_TYPEC_U_USB_WATER_PROTECTION_CFG_REG : ((chg->chg_param.smb_version == PMI632_SUBTYPE) TYPEC_U_USB_WATER_PROTECTION_CFG_REG), 0); ? PMI632_TYPEC_U_USB_WATER_PROTECTION_CFG_REG : TYPEC_U_USB_WATER_PROTECTION_CFG_REG), 0); if (rc < 0) { if (rc < 0) { dev_err(chg->dev, "Couldn't disable periodic monitoring of CC_ID rc=%d\n", dev_err(chg->dev, "Couldn't disable periodic monitoring of CC_ID rc=%d\n", rc); rc); Loading @@ -2287,7 +2322,7 @@ static int smb5_configure_iterm_thresholds_adc(struct smb5 *chip) s16 raw_hi_thresh, raw_lo_thresh, max_limit_ma; s16 raw_hi_thresh, raw_lo_thresh, max_limit_ma; struct smb_charger *chg = &chip->chg; struct smb_charger *chg = &chip->chg; if (chip->chg.smb_version == PMI632_SUBTYPE) if (chip->chg.chg_param.smb_version == PMI632_SUBTYPE) max_limit_ma = ITERM_LIMITS_PMI632_MA; max_limit_ma = ITERM_LIMITS_PMI632_MA; else else max_limit_ma = ITERM_LIMITS_PM8150B_MA; max_limit_ma = ITERM_LIMITS_PM8150B_MA; Loading Loading @@ -2348,7 +2383,7 @@ static int smb5_configure_iterm_thresholds(struct smb5 *chip) switch (chip->dt.term_current_src) { switch (chip->dt.term_current_src) { case ITERM_SRC_ADC: case ITERM_SRC_ADC: if (chip->chg.smb_version == PM8150B_SUBTYPE) { if (chip->chg.chg_param.smb_version == PM8150B_SUBTYPE) { rc = smblib_masked_write(chg, CHGR_ADC_TERM_CFG_REG, rc = smblib_masked_write(chg, CHGR_ADC_TERM_CFG_REG, TERM_BASED_ON_SYNC_CONV_OR_SAMPLE_CNT, TERM_BASED_ON_SYNC_CONV_OR_SAMPLE_CNT, TERM_BASED_ON_SAMPLE_CNT); TERM_BASED_ON_SAMPLE_CNT); Loading Loading @@ -2420,7 +2455,7 @@ static int smb5_init_dc_peripheral(struct smb_charger *chg) int rc = 0; int rc = 0; /* PMI632 does not have DC peripheral */ /* PMI632 does not have DC peripheral */ if (chg->smb_version == PMI632_SUBTYPE) if (chg->chg_param.smb_version == PMI632_SUBTYPE) return 0; return 0; /* set DC icl_max 1A */ /* set DC icl_max 1A */ Loading Loading @@ -2527,7 +2562,7 @@ static int smb5_init_hw(struct smb5 *chip) * PMI632 can have the connector type defined by a dedicated register * PMI632 can have the connector type defined by a dedicated register * PMI632_TYPEC_MICRO_USB_MODE_REG or by a common TYPEC_U_USB_CFG_REG. * PMI632_TYPEC_MICRO_USB_MODE_REG or by a common TYPEC_U_USB_CFG_REG. */ */ if (chg->smb_version == PMI632_SUBTYPE) { if (chg->chg_param.smb_version == PMI632_SUBTYPE) { rc = smblib_read(chg, PMI632_TYPEC_MICRO_USB_MODE_REG, &val); rc = smblib_read(chg, PMI632_TYPEC_MICRO_USB_MODE_REG, &val); if (rc < 0) { if (rc < 0) { dev_err(chg->dev, "Couldn't read USB mode rc=%d\n", rc); dev_err(chg->dev, "Couldn't read USB mode rc=%d\n", rc); Loading Loading @@ -2572,7 +2607,7 @@ static int smb5_init_hw(struct smb5 *chip) * boots with charger connected. * boots with charger connected. * - Initialize flash module for PMI632 * - Initialize flash module for PMI632 */ */ if (chg->smb_version == PMI632_SUBTYPE) { if (chg->chg_param.smb_version == PMI632_SUBTYPE) { schgm_flash_init(chg); schgm_flash_init(chg); smblib_rerun_apsd_if_required(chg); smblib_rerun_apsd_if_required(chg); } } Loading Loading @@ -3523,7 +3558,7 @@ static int smb5_probe(struct platform_device *pdev) } } } } switch (chg->smb_version) { switch (chg->chg_param.smb_version) { case PM8150B_SUBTYPE: case PM8150B_SUBTYPE: case PM6150_SUBTYPE: case PM6150_SUBTYPE: rc = smb5_init_dc_psy(chip); rc = smb5_init_dc_psy(chip); Loading drivers/power/supply/qcom/smb1390-charger-psy.c +9 −0 Original line number Original line Diff line number Diff line Loading @@ -1103,6 +1103,12 @@ static void smb1390_status_change_work(struct work_struct *work) goto out; goto out; } } /* * Slave SMB1390 is not required for the power-rating of QC3 */ if (pval.intval != POWER_SUPPLY_CP_HVDCP3) vote(chip->slave_disable_votable, SRC_VOTER, false, 0); /* Check for SOC threshold only once before enabling CP */ /* Check for SOC threshold only once before enabling CP */ vote(chip->disable_votable, SRC_VOTER, false, 0); vote(chip->disable_votable, SRC_VOTER, false, 0); if (!chip->batt_soc_validated) { if (!chip->batt_soc_validated) { Loading Loading @@ -1160,6 +1166,7 @@ static void smb1390_status_change_work(struct work_struct *work) } } } else { } else { chip->batt_soc_validated = false; chip->batt_soc_validated = false; vote(chip->slave_disable_votable, SRC_VOTER, true, 0); vote(chip->disable_votable, SRC_VOTER, true, 0); vote(chip->disable_votable, SRC_VOTER, true, 0); vote(chip->disable_votable, TAPER_END_VOTER, false, 0); vote(chip->disable_votable, TAPER_END_VOTER, false, 0); vote(chip->fcc_votable, CP_VOTER, false, 0); vote(chip->fcc_votable, CP_VOTER, false, 0); Loading Loading @@ -1574,6 +1581,8 @@ static int smb1390_create_votables(struct smb1390 *chip) if (IS_ERR(chip->slave_disable_votable)) if (IS_ERR(chip->slave_disable_votable)) return PTR_ERR(chip->slave_disable_votable); return PTR_ERR(chip->slave_disable_votable); /* Keep slave SMB disabled */ vote(chip->slave_disable_votable, SRC_VOTER, true, 0); /* /* * charge pump is initially disabled; this indirectly votes to allow * charge pump is initially disabled; this indirectly votes to allow * traditional parallel charging if present * traditional parallel charging if present Loading drivers/power/supply/qcom/smb5-lib.c +52 −24 Original line number Original line Diff line number Diff line Loading @@ -22,7 +22,6 @@ #include <linux/of_batterydata.h> #include <linux/of_batterydata.h> #include "smb5-lib.h" #include "smb5-lib.h" #include "smb5-reg.h" #include "smb5-reg.h" #include "battery.h" #include "schgm-flash.h" #include "schgm-flash.h" #include "step-chg-jeita.h" #include "step-chg-jeita.h" #include "storm-watch.h" #include "storm-watch.h" Loading Loading @@ -762,7 +761,7 @@ static int smblib_usb_pd_adapter_allowance_override(struct smb_charger *chg, { { int rc = 0; int rc = 0; if (chg->smb_version == PMI632_SUBTYPE) if (chg->chg_param.smb_version == PMI632_SUBTYPE) return 0; return 0; rc = smblib_write(chg, USBIN_ADAPTER_ALLOW_OVERRIDE_REG, rc = smblib_write(chg, USBIN_ADAPTER_ALLOW_OVERRIDE_REG, Loading Loading @@ -809,7 +808,7 @@ static int smblib_set_usb_pd_allowed_voltage(struct smb_charger *chg, int rc, aicl_threshold; int rc, aicl_threshold; u8 vbus_allowance; u8 vbus_allowance; if (chg->smb_version == PMI632_SUBTYPE) if (chg->chg_param.smb_version == PMI632_SUBTYPE) return 0; return 0; if (chg->pd_active == POWER_SUPPLY_PD_PPS_ACTIVE) { if (chg->pd_active == POWER_SUPPLY_PD_PPS_ACTIVE) { Loading Loading @@ -880,6 +879,37 @@ int smblib_set_aicl_cont_threshold(struct smb_chg_param *param, * HELPER FUNCTIONS * * HELPER FUNCTIONS * ********************/ ********************/ static bool is_cp_available(struct smb_charger *chg) { if (!chg->cp_psy) chg->cp_psy = power_supply_get_by_name("charge_pump_master"); return !!chg->cp_psy; } #define CP_TO_MAIN_ICL_OFFSET_PC 10 int smblib_get_qc3_main_icl_offset(struct smb_charger *chg, int *offset_ua) { union power_supply_propval pval = {0, }; int rc; if ((chg->real_charger_type != POWER_SUPPLY_TYPE_USB_HVDCP_3) || chg->hvdcp3_standalone_config || !is_cp_available(chg)) { *offset_ua = 0; return 0; } rc = power_supply_get_property(chg->cp_psy, POWER_SUPPLY_PROP_CP_ILIM, &pval); if (rc < 0) { smblib_err(chg, "Couldn't get CP ILIM rc=%d\n", rc); return rc; } *offset_ua = (pval.intval * CP_TO_MAIN_ICL_OFFSET_PC * 2) / 100; return 0; } int smblib_get_prop_from_bms(struct smb_charger *chg, int smblib_get_prop_from_bms(struct smb_charger *chg, enum power_supply_property psp, enum power_supply_property psp, union power_supply_propval *val) union power_supply_propval *val) Loading Loading @@ -1477,8 +1507,8 @@ static int smblib_set_moisture_protection(struct smb_charger *chg, /* Set 1% duty cycle on ID detection */ /* Set 1% duty cycle on ID detection */ rc = smblib_masked_write(chg, rc = smblib_masked_write(chg, ((chg->smb_version == PMI632_SUBTYPE) ? ((chg->chg_param.smb_version == PMI632_SUBTYPE) PMI632_TYPEC_U_USB_WATER_PROTECTION_CFG_REG : ? PMI632_TYPEC_U_USB_WATER_PROTECTION_CFG_REG : TYPEC_U_USB_WATER_PROTECTION_CFG_REG), TYPEC_U_USB_WATER_PROTECTION_CFG_REG), EN_MICRO_USB_WATER_PROTECTION_BIT | EN_MICRO_USB_WATER_PROTECTION_BIT | MICRO_USB_DETECTION_ON_TIME_CFG_MASK | MICRO_USB_DETECTION_ON_TIME_CFG_MASK | Loading Loading @@ -1510,8 +1540,9 @@ static int smblib_set_moisture_protection(struct smb_charger *chg, } } /* Disable periodic monitoring of CC_ID pin */ /* Disable periodic monitoring of CC_ID pin */ rc = smblib_write(chg, ((chg->smb_version == PMI632_SUBTYPE) ? rc = smblib_write(chg, PMI632_TYPEC_U_USB_WATER_PROTECTION_CFG_REG : ((chg->chg_param.smb_version == PMI632_SUBTYPE) ? PMI632_TYPEC_U_USB_WATER_PROTECTION_CFG_REG : TYPEC_U_USB_WATER_PROTECTION_CFG_REG), 0); TYPEC_U_USB_WATER_PROTECTION_CFG_REG), 0); if (rc < 0) { if (rc < 0) { smblib_err(chg, "Couldn't disable 1 percent CC_ID duty cycle rc=%d\n", smblib_err(chg, "Couldn't disable 1 percent CC_ID duty cycle rc=%d\n", Loading Loading @@ -1559,7 +1590,7 @@ static int smblib_dc_suspend_vote_callback(struct votable *votable, void *data, { { struct smb_charger *chg = data; struct smb_charger *chg = data; if (chg->smb_version == PMI632_SUBTYPE) if (chg->chg_param.smb_version == PMI632_SUBTYPE) return 0; return 0; /* resume input if suspend is invalid */ /* resume input if suspend is invalid */ Loading Loading @@ -2149,7 +2180,7 @@ int smblib_get_prop_batt_iterm(struct smb_charger *chg, temp = buf[1] | (buf[0] << 8); temp = buf[1] | (buf[0] << 8); temp = sign_extend32(temp, 15); temp = sign_extend32(temp, 15); if (chg->smb_version == PMI632_SUBTYPE) if (chg->chg_param.smb_version == PMI632_SUBTYPE) temp = DIV_ROUND_CLOSEST(temp * ITERM_LIMITS_PMI632_MA, temp = DIV_ROUND_CLOSEST(temp * ITERM_LIMITS_PMI632_MA, ADC_CHG_ITERM_MASK); ADC_CHG_ITERM_MASK); else else Loading Loading @@ -2655,10 +2686,7 @@ static int smblib_update_thermal_readings(struct smb_charger *chg) } } if (chg->sec_chg_selected == POWER_SUPPLY_CHARGER_SEC_CP) { if (chg->sec_chg_selected == POWER_SUPPLY_CHARGER_SEC_CP) { if (!chg->cp_psy) if (is_cp_available(chg)) { chg->cp_psy = power_supply_get_by_name("charge_pump_master"); if (chg->cp_psy) { rc = power_supply_get_property(chg->cp_psy, rc = power_supply_get_property(chg->cp_psy, POWER_SUPPLY_PROP_CP_DIE_TEMP, &pval); POWER_SUPPLY_PROP_CP_DIE_TEMP, &pval); if (rc < 0) { if (rc < 0) { Loading Loading @@ -2875,7 +2903,7 @@ int smblib_get_prop_dc_present(struct smb_charger *chg, int rc; int rc; u8 stat; u8 stat; if (chg->smb_version == PMI632_SUBTYPE) { if (chg->chg_param.smb_version == PMI632_SUBTYPE) { val->intval = 0; val->intval = 0; return 0; return 0; } } Loading @@ -2896,7 +2924,7 @@ int smblib_get_prop_dc_online(struct smb_charger *chg, int rc = 0; int rc = 0; u8 stat; u8 stat; if (chg->smb_version == PMI632_SUBTYPE) { if (chg->chg_param.smb_version == PMI632_SUBTYPE) { val->intval = 0; val->intval = 0; return 0; return 0; } } Loading Loading @@ -3111,7 +3139,7 @@ int smblib_get_prop_usb_voltage_max_design(struct smb_charger *chg, /* else, fallthrough */ /* else, fallthrough */ case POWER_SUPPLY_TYPE_USB_HVDCP_3: case POWER_SUPPLY_TYPE_USB_HVDCP_3: case POWER_SUPPLY_TYPE_USB_PD: case POWER_SUPPLY_TYPE_USB_PD: if (chg->smb_version == PMI632_SUBTYPE) if (chg->chg_param.smb_version == PMI632_SUBTYPE) val->intval = MICRO_9V; val->intval = MICRO_9V; else else val->intval = MICRO_12V; val->intval = MICRO_12V; Loading Loading @@ -3139,7 +3167,7 @@ int smblib_get_prop_usb_voltage_max(struct smb_charger *chg, } } /* else, fallthrough */ /* else, fallthrough */ case POWER_SUPPLY_TYPE_USB_HVDCP_3: case POWER_SUPPLY_TYPE_USB_HVDCP_3: if (chg->smb_version == PMI632_SUBTYPE) if (chg->chg_param.smb_version == PMI632_SUBTYPE) val->intval = MICRO_9V; val->intval = MICRO_9V; else else val->intval = MICRO_12V; val->intval = MICRO_12V; Loading Loading @@ -3237,7 +3265,7 @@ int smblib_get_prop_usb_voltage_now(struct smb_charger *chg, * to occur randomly in the USBIN channel, particularly at high * to occur randomly in the USBIN channel, particularly at high * voltages. * voltages. */ */ if (chg->smb_version == PM8150B_SUBTYPE && pval.intval) if (chg->chg_param.smb_version == PM8150B_SUBTYPE && pval.intval) return smblib_read_mid_voltage_chan(chg, val); return smblib_read_mid_voltage_chan(chg, val); else else return smblib_read_usbin_voltage_chan(chg, val); return smblib_read_usbin_voltage_chan(chg, val); Loading Loading @@ -3571,7 +3599,7 @@ int smblib_get_prop_usb_current_now(struct smb_charger *chg, * For PMI632, scaling factor = reciprocal of * For PMI632, scaling factor = reciprocal of * 0.4V/A in Buck mode, 0.8V/A in Boost mode. * 0.4V/A in Buck mode, 0.8V/A in Boost mode. */ */ switch (chg->smb_version) { switch (chg->chg_param.smb_version) { case PMI632_SUBTYPE: case PMI632_SUBTYPE: buck_scale = 40; buck_scale = 40; boost_scale = 80; boost_scale = 80; Loading Loading @@ -3857,7 +3885,7 @@ int smblib_get_prop_connector_health(struct smb_charger *chg) * In PM8150B, SKIN channel measures Wireless charger receiver * In PM8150B, SKIN channel measures Wireless charger receiver * temp, used to regulate DC ICL. * temp, used to regulate DC ICL. */ */ if (chg->smb_version == PM8150B_SUBTYPE && dc_present) if (chg->chg_param.smb_version == PM8150B_SUBTYPE && dc_present) return smblib_get_skin_temp_status(chg); return smblib_get_skin_temp_status(chg); return POWER_SUPPLY_HEALTH_COOL; return POWER_SUPPLY_HEALTH_COOL; Loading Loading @@ -4818,7 +4846,7 @@ irqreturn_t usbin_uv_irq_handler(int irq, void *data) unsuspend_input: unsuspend_input: /* Force torch in boost mode to ensure it works with low ICL */ /* Force torch in boost mode to ensure it works with low ICL */ if (chg->smb_version == PMI632_SUBTYPE) if (chg->chg_param.smb_version == PMI632_SUBTYPE) schgm_flash_torch_priority(chg, TORCH_BOOST_MODE); schgm_flash_torch_priority(chg, TORCH_BOOST_MODE); if (chg->aicl_max_reached) { if (chg->aicl_max_reached) { Loading Loading @@ -5082,7 +5110,7 @@ void smblib_usb_plugin_locked(struct smb_charger *chg) chg->aicl_cont_threshold_mv); chg->aicl_cont_threshold_mv); chg->aicl_max_reached = false; chg->aicl_max_reached = false; if (chg->smb_version == PMI632_SUBTYPE) if (chg->chg_param.smb_version == PMI632_SUBTYPE) schgm_flash_torch_priority(chg, schgm_flash_torch_priority(chg, TORCH_BUCK_MODE); TORCH_BUCK_MODE); Loading Loading @@ -6428,7 +6456,7 @@ static void smblib_moisture_protection_work(struct work_struct *work) * Disable 1% duty cycle on CC_ID pin and enable uUSB factory mode * Disable 1% duty cycle on CC_ID pin and enable uUSB factory mode * detection to track any change on RID, as interrupts are disable. * detection to track any change on RID, as interrupts are disable. */ */ rc = smblib_write(chg, ((chg->smb_version == PMI632_SUBTYPE) ? rc = smblib_write(chg, ((chg->chg_param.smb_version == PMI632_SUBTYPE) ? PMI632_TYPEC_U_USB_WATER_PROTECTION_CFG_REG : PMI632_TYPEC_U_USB_WATER_PROTECTION_CFG_REG : TYPEC_U_USB_WATER_PROTECTION_CFG_REG), 0); TYPEC_U_USB_WATER_PROTECTION_CFG_REG), 0); if (rc < 0) { if (rc < 0) { Loading Loading @@ -7188,7 +7216,7 @@ int smblib_init(struct smb_charger *chg) switch (chg->mode) { switch (chg->mode) { case PARALLEL_MASTER: case PARALLEL_MASTER: rc = qcom_batt_init(chg->smb_version); rc = qcom_batt_init(&chg->chg_param); if (rc < 0) { if (rc < 0) { smblib_err(chg, "Couldn't init qcom_batt_init rc=%d\n", smblib_err(chg, "Couldn't init qcom_batt_init rc=%d\n", rc); rc); Loading Loading
drivers/power/supply/qcom/battery.c +74 −18 Original line number Original line Diff line number Diff line Loading @@ -100,11 +100,15 @@ struct pl_data { struct class qcom_batt_class; struct class qcom_batt_class; struct wakeup_source *pl_ws; struct wakeup_source *pl_ws; struct notifier_block nb; struct notifier_block nb; struct charger_param *chg_param; bool pl_disable; bool pl_disable; bool cp_disabled; bool cp_disabled; int taper_entry_fv; int taper_entry_fv; int main_fcc_max; int main_fcc_max; u32 float_voltage_uv; u32 float_voltage_uv; /* debugfs directory */ struct dentry *dfs_root; }; }; struct pl_data *the_chip; struct pl_data *the_chip; Loading Loading @@ -146,6 +150,15 @@ enum { /********* /********* * HELPER* * HELPER* *********/ *********/ static bool is_usb_available(struct pl_data *chip) { if (!chip->usb_psy) chip->usb_psy = power_supply_get_by_name("usb"); return !!chip->usb_psy; } static bool is_cp_available(struct pl_data *chip) static bool is_cp_available(struct pl_data *chip) { { if (!chip->cp_master_psy) if (!chip->cp_master_psy) Loading Loading @@ -199,9 +212,12 @@ static int cp_get_parallel_mode(struct pl_data *chip, int mode) */ */ static void cp_configure_ilim(struct pl_data *chip, const char *voter, int ilim) static void cp_configure_ilim(struct pl_data *chip, const char *voter, int ilim) { { int rc, fcc; int rc, fcc, main_icl, target_icl = chip->chg_param->hvdcp3_max_icl_ua; union power_supply_propval pval = {0, }; union power_supply_propval pval = {0, }; if (!is_usb_available(chip)) return; if (!is_cp_available(chip)) if (!is_cp_available(chip)) return; return; Loading @@ -209,6 +225,31 @@ static void cp_configure_ilim(struct pl_data *chip, const char *voter, int ilim) == POWER_SUPPLY_PL_OUTPUT_VPH) == POWER_SUPPLY_PL_OUTPUT_VPH) return; return; rc = power_supply_get_property(chip->usb_psy, POWER_SUPPLY_PROP_REAL_TYPE, &pval); if (rc < 0) return; /* * For HVDCP3 adapters limit max. ILIM based on DT configuration * of HVDCP3 ICL value. * Input VBUS: * target_icl = HVDCP3_ICL - main_ICL * Input VMID * target_icl = HVDCP3_ICL */ if (pval.intval == POWER_SUPPLY_TYPE_USB_HVDCP_3) { if (((cp_get_parallel_mode(chip, PARALLEL_INPUT_MODE)) == POWER_SUPPLY_PL_USBIN_USBIN)) { main_icl = get_effective_result_locked( chip->usb_icl_votable); if ((main_icl >= 0) && (main_icl < target_icl)) target_icl -= main_icl; } ilim = min(target_icl, ilim); } rc = power_supply_get_property(chip->cp_master_psy, rc = power_supply_get_property(chip->cp_master_psy, POWER_SUPPLY_PROP_MIN_ICL, &pval); POWER_SUPPLY_PROP_MIN_ICL, &pval); if (rc < 0) if (rc < 0) Loading @@ -230,6 +271,10 @@ static void cp_configure_ilim(struct pl_data *chip, const char *voter, int ilim) vote(chip->cp_ilim_votable, voter, true, pval.intval); vote(chip->cp_ilim_votable, voter, true, pval.intval); else else vote(chip->cp_ilim_votable, voter, true, ilim); vote(chip->cp_ilim_votable, voter, true, ilim); pl_dbg(chip, PR_PARALLEL, "ILIM: vote: %d voter:%s min_ilim=%d fcc = %d\n", ilim, voter, pval.intval, fcc); } } } } Loading Loading @@ -526,8 +571,6 @@ ATTRIBUTE_GROUPS(batt_class); * FCC * * FCC * **********/ **********/ #define EFFICIENCY_PCT 80 #define EFFICIENCY_PCT 80 #define FCC_STEP_SIZE_UA 100000 #define FCC_STEP_UPDATE_DELAY_MS 1000 #define STEP_UP 1 #define STEP_UP 1 #define STEP_DOWN -1 #define STEP_DOWN -1 static void get_fcc_split(struct pl_data *chip, int total_ua, static void get_fcc_split(struct pl_data *chip, int total_ua, Loading Loading @@ -630,6 +673,11 @@ static void get_fcc_stepper_params(struct pl_data *chip, int main_fcc_ua, { { int main_set_fcc_ua, total_fcc_ua; int main_set_fcc_ua, total_fcc_ua; if (!chip->chg_param->fcc_step_size_ua) { pr_err("Invalid fcc stepper step size, value 0\n"); return; } if (is_override_vote_enabled_locked(chip->fcc_main_votable)) { if (is_override_vote_enabled_locked(chip->fcc_main_votable)) { /* /* * FCC stepper params need re-calculation in override mode * FCC stepper params need re-calculation in override mode Loading @@ -650,21 +698,24 @@ static void get_fcc_stepper_params(struct pl_data *chip, int main_fcc_ua, goto skip_fcc_step_update; goto skip_fcc_step_update; } } } } /* Read current FCC of main charger */ /* Read current FCC of main charger */ chip->main_fcc_ua = get_effective_result(chip->fcc_main_votable); chip->main_fcc_ua = get_effective_result(chip->fcc_main_votable); chip->main_step_fcc_dir = (main_fcc_ua > chip->main_fcc_ua) ? chip->main_step_fcc_dir = (main_fcc_ua > chip->main_fcc_ua) ? STEP_UP : STEP_DOWN; STEP_UP : STEP_DOWN; chip->main_step_fcc_count = abs((main_fcc_ua - chip->main_fcc_ua) / chip->main_step_fcc_count = abs((main_fcc_ua - chip->main_fcc_ua) / FCC_STEP_SIZE_UA); chip->chg_param->fcc_step_size_ua); chip->main_step_fcc_residual = abs((main_fcc_ua - chip->main_fcc_ua) % chip->main_step_fcc_residual = abs((main_fcc_ua - chip->main_fcc_ua) % FCC_STEP_SIZE_UA); chip->chg_param->fcc_step_size_ua); chip->parallel_step_fcc_dir = (parallel_fcc_ua > chip->slave_fcc_ua) ? chip->parallel_step_fcc_dir = (parallel_fcc_ua > chip->slave_fcc_ua) ? STEP_UP : STEP_DOWN; STEP_UP : STEP_DOWN; chip->parallel_step_fcc_count = abs((parallel_fcc_ua - chip->parallel_step_fcc_count chip->slave_fcc_ua) / FCC_STEP_SIZE_UA); = abs((parallel_fcc_ua - chip->slave_fcc_ua) / chip->parallel_step_fcc_residual = abs((parallel_fcc_ua - chip->chg_param->fcc_step_size_ua); chip->slave_fcc_ua)) % FCC_STEP_SIZE_UA; chip->parallel_step_fcc_residual = abs((parallel_fcc_ua - chip->slave_fcc_ua) % chip->chg_param->fcc_step_size_ua); skip_fcc_step_update: skip_fcc_step_update: if (chip->parallel_step_fcc_count || chip->parallel_step_fcc_residual if (chip->parallel_step_fcc_count || chip->parallel_step_fcc_residual Loading Loading @@ -955,19 +1006,20 @@ static void fcc_stepper_work(struct work_struct *work) } } if (chip->main_step_fcc_count) { if (chip->main_step_fcc_count) { main_fcc += (FCC_STEP_SIZE_UA * chip->main_step_fcc_dir); main_fcc += (chip->chg_param->fcc_step_size_ua * chip->main_step_fcc_dir); chip->main_step_fcc_count--; chip->main_step_fcc_count--; reschedule_ms = FCC_STEP_UPDATE_DELAY_MS; reschedule_ms = chip->chg_param->fcc_step_delay_ms; } else if (chip->main_step_fcc_residual) { } else if (chip->main_step_fcc_residual) { main_fcc += chip->main_step_fcc_residual; main_fcc += chip->main_step_fcc_residual; chip->main_step_fcc_residual = 0; chip->main_step_fcc_residual = 0; } } if (chip->parallel_step_fcc_count) { if (chip->parallel_step_fcc_count) { parallel_fcc += (FCC_STEP_SIZE_UA * parallel_fcc += (chip->chg_param->fcc_step_size_ua chip->parallel_step_fcc_dir); * chip->parallel_step_fcc_dir); chip->parallel_step_fcc_count--; chip->parallel_step_fcc_count--; reschedule_ms = FCC_STEP_UPDATE_DELAY_MS; reschedule_ms = chip->chg_param->fcc_step_delay_ms; } else if (chip->parallel_step_fcc_residual) { } else if (chip->parallel_step_fcc_residual) { parallel_fcc += chip->parallel_step_fcc_residual; parallel_fcc += chip->parallel_step_fcc_residual; chip->parallel_step_fcc_residual = 0; chip->parallel_step_fcc_residual = 0; Loading Loading @@ -1806,19 +1858,22 @@ static void pl_config_init(struct pl_data *chip, int smb_version) case PM660_SUBTYPE: case PM660_SUBTYPE: chip->wa_flags = AICL_RERUN_WA_BIT | FORCE_INOV_DISABLE_BIT; chip->wa_flags = AICL_RERUN_WA_BIT | FORCE_INOV_DISABLE_BIT; break; break; case PMI632_SUBTYPE: break; default: default: break; break; } } } } #define DEFAULT_RESTRICTED_CURRENT_UA 1000000 #define DEFAULT_RESTRICTED_CURRENT_UA 1000000 int qcom_batt_init(int smb_version) int qcom_batt_init(struct charger_param *chg_param) { { struct pl_data *chip; struct pl_data *chip; int rc = 0; int rc = 0; if (!chg_param) { pr_err("invalid charger parameter\n"); return -EINVAL; } /* initialize just once */ /* initialize just once */ if (the_chip) { if (the_chip) { pr_err("was initialized earlier. Failing now\n"); pr_err("was initialized earlier. Failing now\n"); Loading @@ -1829,7 +1884,8 @@ int qcom_batt_init(int smb_version) if (!chip) if (!chip) return -ENOMEM; return -ENOMEM; chip->slave_pct = 50; chip->slave_pct = 50; pl_config_init(chip, smb_version); chip->chg_param = chg_param; pl_config_init(chip, chg_param->smb_version); chip->restricted_current = DEFAULT_RESTRICTED_CURRENT_UA; chip->restricted_current = DEFAULT_RESTRICTED_CURRENT_UA; chip->pl_ws = wakeup_source_register("qcom-battery"); chip->pl_ws = wakeup_source_register("qcom-battery"); Loading
drivers/power/supply/qcom/battery.h +10 −2 Original line number Original line Diff line number Diff line /* Copyright (c) 2017 The Linux Foundation. All rights reserved. /* Copyright (c) 2017, 2019 The Linux Foundation. All rights reserved. * * * This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and * it under the terms of the GNU General Public License version 2 and Loading @@ -12,6 +12,14 @@ #ifndef __BATTERY_H #ifndef __BATTERY_H #define __BATTERY_H #define __BATTERY_H int qcom_batt_init(int smb_version); struct charger_param { u32 fcc_step_delay_ms; u32 fcc_step_size_ua; u32 smb_version; u32 hvdcp3_max_icl_ua; }; int qcom_batt_init(struct charger_param *param); void qcom_batt_deinit(void); void qcom_batt_deinit(void); #endif /* __BATTERY_H */ #endif /* __BATTERY_H */
drivers/power/supply/qcom/qpnp-smb5.c +61 −26 Original line number Original line Diff line number Diff line Loading @@ -288,13 +288,13 @@ static int smb5_chg_config_init(struct smb5 *chip) switch (pmic_rev_id->pmic_subtype) { switch (pmic_rev_id->pmic_subtype) { case PM8150B_SUBTYPE: case PM8150B_SUBTYPE: chip->chg.smb_version = PM8150B_SUBTYPE; chip->chg.chg_param.smb_version = PM8150B_SUBTYPE; chg->param = smb5_pm8150b_params; chg->param = smb5_pm8150b_params; chg->name = "pm8150b_charger"; chg->name = "pm8150b_charger"; chg->wa_flags |= CHG_TERMINATION_WA; chg->wa_flags |= CHG_TERMINATION_WA; break; break; case PM6150_SUBTYPE: case PM6150_SUBTYPE: chip->chg.smb_version = PM6150_SUBTYPE; chip->chg.chg_param.smb_version = PM6150_SUBTYPE; chg->param = smb5_pm8150b_params; chg->param = smb5_pm8150b_params; chg->name = "pm6150_charger"; chg->name = "pm6150_charger"; chg->wa_flags |= SW_THERM_REGULATION_WA | CHG_TERMINATION_WA; chg->wa_flags |= SW_THERM_REGULATION_WA | CHG_TERMINATION_WA; Loading @@ -303,7 +303,7 @@ static int smb5_chg_config_init(struct smb5 *chip) chg->main_fcc_max = PM6150_MAX_FCC_UA; chg->main_fcc_max = PM6150_MAX_FCC_UA; break; break; case PMI632_SUBTYPE: case PMI632_SUBTYPE: chip->chg.smb_version = PMI632_SUBTYPE; chip->chg.chg_param.smb_version = PMI632_SUBTYPE; chg->wa_flags |= WEAK_ADAPTER_WA | USBIN_OV_WA chg->wa_flags |= WEAK_ADAPTER_WA | USBIN_OV_WA | CHG_TERMINATION_WA; | CHG_TERMINATION_WA; chg->param = smb5_pmi632_params; chg->param = smb5_pmi632_params; Loading Loading @@ -390,7 +390,8 @@ static int smb5_configure_internal_pull(struct smb_charger *chg, int type, #define OTG_DEFAULT_DEGLITCH_TIME_MS 50 #define OTG_DEFAULT_DEGLITCH_TIME_MS 50 #define DEFAULT_WD_BARK_TIME 64 #define DEFAULT_WD_BARK_TIME 64 #define DEFAULT_WD_SNARL_TIME_8S 0x07 #define DEFAULT_WD_SNARL_TIME_8S 0x07 #define DEFAULT_FCC_STEP_SIZE_UA 100000 #define DEFAULT_FCC_STEP_UPDATE_DELAY_MS 1000 static int smb5_parse_dt(struct smb5 *chip) static int smb5_parse_dt(struct smb5 *chip) { { struct smb_charger *chg = &chip->chg; struct smb_charger *chg = &chip->chg; Loading Loading @@ -457,8 +458,9 @@ static int smb5_parse_dt(struct smb5 *chip) rc = of_property_read_u32(node, rc = of_property_read_u32(node, "qcom,otg-cl-ua", &chg->otg_cl_ua); "qcom,otg-cl-ua", &chg->otg_cl_ua); if (rc < 0) if (rc < 0) chg->otg_cl_ua = (chip->chg.smb_version == PMI632_SUBTYPE) ? chg->otg_cl_ua = MICRO_1PA : MICRO_3PA; (chip->chg.chg_param.smb_version == PMI632_SUBTYPE) ? MICRO_1PA : MICRO_3PA; rc = of_property_read_u32(node, "qcom,chg-term-src", rc = of_property_read_u32(node, "qcom,chg-term-src", &chip->dt.term_current_src); &chip->dt.term_current_src); Loading Loading @@ -628,6 +630,29 @@ static int smb5_parse_dt(struct smb5 *chip) chip->dt.disable_suspend_on_collapse = of_property_read_bool(node, chip->dt.disable_suspend_on_collapse = of_property_read_bool(node, "qcom,disable-suspend-on-collapse"); "qcom,disable-suspend-on-collapse"); of_property_read_u32(node, "qcom,fcc-step-delay-ms", &chg->chg_param.fcc_step_delay_ms); if (chg->chg_param.fcc_step_delay_ms <= 0) chg->chg_param.fcc_step_delay_ms = DEFAULT_FCC_STEP_UPDATE_DELAY_MS; of_property_read_u32(node, "qcom,fcc-step-size-ua", &chg->chg_param.fcc_step_size_ua); if (chg->chg_param.fcc_step_size_ua <= 0) chg->chg_param.fcc_step_size_ua = DEFAULT_FCC_STEP_SIZE_UA; /* * If property is present parallel charging with CP is disabled * with HVDCP3 adapter. */ chg->hvdcp3_standalone_config = of_property_read_bool(node, "qcom,hvdcp3-standalone-config"); of_property_read_u32(node, "qcom,hvdcp3-max-icl-ua", &chg->chg_param.hvdcp3_max_icl_ua); if (chg->chg_param.hvdcp3_max_icl_ua <= 0) chg->chg_param.hvdcp3_max_icl_ua = MICRO_3PA; return 0; return 0; } } Loading Loading @@ -1219,20 +1244,26 @@ static int smb5_usb_main_set_prop(struct power_supply *psy, struct smb5 *chip = power_supply_get_drvdata(psy); struct smb5 *chip = power_supply_get_drvdata(psy); struct smb_charger *chg = &chip->chg; struct smb_charger *chg = &chip->chg; union power_supply_propval pval = {0, }; union power_supply_propval pval = {0, }; int rc = 0; int rc = 0, offset_ua = 0; switch (psp) { switch (psp) { case POWER_SUPPLY_PROP_VOLTAGE_MAX: case POWER_SUPPLY_PROP_VOLTAGE_MAX: rc = smblib_set_charge_param(chg, &chg->param.fv, val->intval); rc = smblib_set_charge_param(chg, &chg->param.fv, val->intval); break; break; case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX: case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX: rc = smblib_set_charge_param(chg, &chg->param.fcc, val->intval); /* Adjust Main FCC for QC3.0 + SMB1390 */ rc = smblib_get_qc3_main_icl_offset(chg, &offset_ua); if (rc < 0) offset_ua = 0; rc = smblib_set_charge_param(chg, &chg->param.fcc, val->intval + offset_ua); break; break; case POWER_SUPPLY_PROP_CURRENT_MAX: case POWER_SUPPLY_PROP_CURRENT_MAX: rc = smblib_set_icl_current(chg, val->intval); rc = smblib_set_icl_current(chg, val->intval); break; break; case POWER_SUPPLY_PROP_FLASH_ACTIVE: case POWER_SUPPLY_PROP_FLASH_ACTIVE: if ((chg->smb_version == PMI632_SUBTYPE) if ((chg->chg_param.smb_version == PMI632_SUBTYPE) && (chg->flash_active != val->intval)) { && (chg->flash_active != val->intval)) { chg->flash_active = val->intval; chg->flash_active = val->intval; Loading Loading @@ -1278,6 +1309,9 @@ static int smb5_usb_main_set_prop(struct power_supply *psy, case POWER_SUPPLY_PROP_FORCE_MAIN_ICL: case POWER_SUPPLY_PROP_FORCE_MAIN_ICL: vote_override(chg->usb_icl_votable, CC_MODE_VOTER, vote_override(chg->usb_icl_votable, CC_MODE_VOTER, (val->intval < 0) ? false : true, val->intval); (val->intval < 0) ? false : true, val->intval); /* Main ICL updated re-calculate ILIM */ if (chg->real_charger_type == POWER_SUPPLY_TYPE_USB_HVDCP_3) rerun_election(chg->fcc_votable); break; break; case POWER_SUPPLY_PROP_COMP_CLAMP_LEVEL: case POWER_SUPPLY_PROP_COMP_CLAMP_LEVEL: rc = smb5_set_prop_comp_clamp_level(chg, val); rc = smb5_set_prop_comp_clamp_level(chg, val); Loading Loading @@ -2204,7 +2238,7 @@ static int smb5_configure_typec(struct smb_charger *chg) return rc; return rc; } } if (chg->smb_version != PMI632_SUBTYPE) { if (chg->chg_param.smb_version != PMI632_SUBTYPE) { rc = smblib_masked_write(chg, USBIN_LOAD_CFG_REG, rc = smblib_masked_write(chg, USBIN_LOAD_CFG_REG, USBIN_IN_COLLAPSE_GF_SEL_MASK | USBIN_IN_COLLAPSE_GF_SEL_MASK | USBIN_AICL_STEP_TIMING_SEL_MASK, USBIN_AICL_STEP_TIMING_SEL_MASK, Loading Loading @@ -2265,9 +2299,10 @@ static int smb5_configure_micro_usb(struct smb_charger *chg) } } /* Disable periodic monitoring of CC_ID pin */ /* Disable periodic monitoring of CC_ID pin */ rc = smblib_write(chg, ((chg->smb_version == PMI632_SUBTYPE) ? rc = smblib_write(chg, PMI632_TYPEC_U_USB_WATER_PROTECTION_CFG_REG : ((chg->chg_param.smb_version == PMI632_SUBTYPE) TYPEC_U_USB_WATER_PROTECTION_CFG_REG), 0); ? PMI632_TYPEC_U_USB_WATER_PROTECTION_CFG_REG : TYPEC_U_USB_WATER_PROTECTION_CFG_REG), 0); if (rc < 0) { if (rc < 0) { dev_err(chg->dev, "Couldn't disable periodic monitoring of CC_ID rc=%d\n", dev_err(chg->dev, "Couldn't disable periodic monitoring of CC_ID rc=%d\n", rc); rc); Loading @@ -2287,7 +2322,7 @@ static int smb5_configure_iterm_thresholds_adc(struct smb5 *chip) s16 raw_hi_thresh, raw_lo_thresh, max_limit_ma; s16 raw_hi_thresh, raw_lo_thresh, max_limit_ma; struct smb_charger *chg = &chip->chg; struct smb_charger *chg = &chip->chg; if (chip->chg.smb_version == PMI632_SUBTYPE) if (chip->chg.chg_param.smb_version == PMI632_SUBTYPE) max_limit_ma = ITERM_LIMITS_PMI632_MA; max_limit_ma = ITERM_LIMITS_PMI632_MA; else else max_limit_ma = ITERM_LIMITS_PM8150B_MA; max_limit_ma = ITERM_LIMITS_PM8150B_MA; Loading Loading @@ -2348,7 +2383,7 @@ static int smb5_configure_iterm_thresholds(struct smb5 *chip) switch (chip->dt.term_current_src) { switch (chip->dt.term_current_src) { case ITERM_SRC_ADC: case ITERM_SRC_ADC: if (chip->chg.smb_version == PM8150B_SUBTYPE) { if (chip->chg.chg_param.smb_version == PM8150B_SUBTYPE) { rc = smblib_masked_write(chg, CHGR_ADC_TERM_CFG_REG, rc = smblib_masked_write(chg, CHGR_ADC_TERM_CFG_REG, TERM_BASED_ON_SYNC_CONV_OR_SAMPLE_CNT, TERM_BASED_ON_SYNC_CONV_OR_SAMPLE_CNT, TERM_BASED_ON_SAMPLE_CNT); TERM_BASED_ON_SAMPLE_CNT); Loading Loading @@ -2420,7 +2455,7 @@ static int smb5_init_dc_peripheral(struct smb_charger *chg) int rc = 0; int rc = 0; /* PMI632 does not have DC peripheral */ /* PMI632 does not have DC peripheral */ if (chg->smb_version == PMI632_SUBTYPE) if (chg->chg_param.smb_version == PMI632_SUBTYPE) return 0; return 0; /* set DC icl_max 1A */ /* set DC icl_max 1A */ Loading Loading @@ -2527,7 +2562,7 @@ static int smb5_init_hw(struct smb5 *chip) * PMI632 can have the connector type defined by a dedicated register * PMI632 can have the connector type defined by a dedicated register * PMI632_TYPEC_MICRO_USB_MODE_REG or by a common TYPEC_U_USB_CFG_REG. * PMI632_TYPEC_MICRO_USB_MODE_REG or by a common TYPEC_U_USB_CFG_REG. */ */ if (chg->smb_version == PMI632_SUBTYPE) { if (chg->chg_param.smb_version == PMI632_SUBTYPE) { rc = smblib_read(chg, PMI632_TYPEC_MICRO_USB_MODE_REG, &val); rc = smblib_read(chg, PMI632_TYPEC_MICRO_USB_MODE_REG, &val); if (rc < 0) { if (rc < 0) { dev_err(chg->dev, "Couldn't read USB mode rc=%d\n", rc); dev_err(chg->dev, "Couldn't read USB mode rc=%d\n", rc); Loading Loading @@ -2572,7 +2607,7 @@ static int smb5_init_hw(struct smb5 *chip) * boots with charger connected. * boots with charger connected. * - Initialize flash module for PMI632 * - Initialize flash module for PMI632 */ */ if (chg->smb_version == PMI632_SUBTYPE) { if (chg->chg_param.smb_version == PMI632_SUBTYPE) { schgm_flash_init(chg); schgm_flash_init(chg); smblib_rerun_apsd_if_required(chg); smblib_rerun_apsd_if_required(chg); } } Loading Loading @@ -3523,7 +3558,7 @@ static int smb5_probe(struct platform_device *pdev) } } } } switch (chg->smb_version) { switch (chg->chg_param.smb_version) { case PM8150B_SUBTYPE: case PM8150B_SUBTYPE: case PM6150_SUBTYPE: case PM6150_SUBTYPE: rc = smb5_init_dc_psy(chip); rc = smb5_init_dc_psy(chip); Loading
drivers/power/supply/qcom/smb1390-charger-psy.c +9 −0 Original line number Original line Diff line number Diff line Loading @@ -1103,6 +1103,12 @@ static void smb1390_status_change_work(struct work_struct *work) goto out; goto out; } } /* * Slave SMB1390 is not required for the power-rating of QC3 */ if (pval.intval != POWER_SUPPLY_CP_HVDCP3) vote(chip->slave_disable_votable, SRC_VOTER, false, 0); /* Check for SOC threshold only once before enabling CP */ /* Check for SOC threshold only once before enabling CP */ vote(chip->disable_votable, SRC_VOTER, false, 0); vote(chip->disable_votable, SRC_VOTER, false, 0); if (!chip->batt_soc_validated) { if (!chip->batt_soc_validated) { Loading Loading @@ -1160,6 +1166,7 @@ static void smb1390_status_change_work(struct work_struct *work) } } } else { } else { chip->batt_soc_validated = false; chip->batt_soc_validated = false; vote(chip->slave_disable_votable, SRC_VOTER, true, 0); vote(chip->disable_votable, SRC_VOTER, true, 0); vote(chip->disable_votable, SRC_VOTER, true, 0); vote(chip->disable_votable, TAPER_END_VOTER, false, 0); vote(chip->disable_votable, TAPER_END_VOTER, false, 0); vote(chip->fcc_votable, CP_VOTER, false, 0); vote(chip->fcc_votable, CP_VOTER, false, 0); Loading Loading @@ -1574,6 +1581,8 @@ static int smb1390_create_votables(struct smb1390 *chip) if (IS_ERR(chip->slave_disable_votable)) if (IS_ERR(chip->slave_disable_votable)) return PTR_ERR(chip->slave_disable_votable); return PTR_ERR(chip->slave_disable_votable); /* Keep slave SMB disabled */ vote(chip->slave_disable_votable, SRC_VOTER, true, 0); /* /* * charge pump is initially disabled; this indirectly votes to allow * charge pump is initially disabled; this indirectly votes to allow * traditional parallel charging if present * traditional parallel charging if present Loading
drivers/power/supply/qcom/smb5-lib.c +52 −24 Original line number Original line Diff line number Diff line Loading @@ -22,7 +22,6 @@ #include <linux/of_batterydata.h> #include <linux/of_batterydata.h> #include "smb5-lib.h" #include "smb5-lib.h" #include "smb5-reg.h" #include "smb5-reg.h" #include "battery.h" #include "schgm-flash.h" #include "schgm-flash.h" #include "step-chg-jeita.h" #include "step-chg-jeita.h" #include "storm-watch.h" #include "storm-watch.h" Loading Loading @@ -762,7 +761,7 @@ static int smblib_usb_pd_adapter_allowance_override(struct smb_charger *chg, { { int rc = 0; int rc = 0; if (chg->smb_version == PMI632_SUBTYPE) if (chg->chg_param.smb_version == PMI632_SUBTYPE) return 0; return 0; rc = smblib_write(chg, USBIN_ADAPTER_ALLOW_OVERRIDE_REG, rc = smblib_write(chg, USBIN_ADAPTER_ALLOW_OVERRIDE_REG, Loading Loading @@ -809,7 +808,7 @@ static int smblib_set_usb_pd_allowed_voltage(struct smb_charger *chg, int rc, aicl_threshold; int rc, aicl_threshold; u8 vbus_allowance; u8 vbus_allowance; if (chg->smb_version == PMI632_SUBTYPE) if (chg->chg_param.smb_version == PMI632_SUBTYPE) return 0; return 0; if (chg->pd_active == POWER_SUPPLY_PD_PPS_ACTIVE) { if (chg->pd_active == POWER_SUPPLY_PD_PPS_ACTIVE) { Loading Loading @@ -880,6 +879,37 @@ int smblib_set_aicl_cont_threshold(struct smb_chg_param *param, * HELPER FUNCTIONS * * HELPER FUNCTIONS * ********************/ ********************/ static bool is_cp_available(struct smb_charger *chg) { if (!chg->cp_psy) chg->cp_psy = power_supply_get_by_name("charge_pump_master"); return !!chg->cp_psy; } #define CP_TO_MAIN_ICL_OFFSET_PC 10 int smblib_get_qc3_main_icl_offset(struct smb_charger *chg, int *offset_ua) { union power_supply_propval pval = {0, }; int rc; if ((chg->real_charger_type != POWER_SUPPLY_TYPE_USB_HVDCP_3) || chg->hvdcp3_standalone_config || !is_cp_available(chg)) { *offset_ua = 0; return 0; } rc = power_supply_get_property(chg->cp_psy, POWER_SUPPLY_PROP_CP_ILIM, &pval); if (rc < 0) { smblib_err(chg, "Couldn't get CP ILIM rc=%d\n", rc); return rc; } *offset_ua = (pval.intval * CP_TO_MAIN_ICL_OFFSET_PC * 2) / 100; return 0; } int smblib_get_prop_from_bms(struct smb_charger *chg, int smblib_get_prop_from_bms(struct smb_charger *chg, enum power_supply_property psp, enum power_supply_property psp, union power_supply_propval *val) union power_supply_propval *val) Loading Loading @@ -1477,8 +1507,8 @@ static int smblib_set_moisture_protection(struct smb_charger *chg, /* Set 1% duty cycle on ID detection */ /* Set 1% duty cycle on ID detection */ rc = smblib_masked_write(chg, rc = smblib_masked_write(chg, ((chg->smb_version == PMI632_SUBTYPE) ? ((chg->chg_param.smb_version == PMI632_SUBTYPE) PMI632_TYPEC_U_USB_WATER_PROTECTION_CFG_REG : ? PMI632_TYPEC_U_USB_WATER_PROTECTION_CFG_REG : TYPEC_U_USB_WATER_PROTECTION_CFG_REG), TYPEC_U_USB_WATER_PROTECTION_CFG_REG), EN_MICRO_USB_WATER_PROTECTION_BIT | EN_MICRO_USB_WATER_PROTECTION_BIT | MICRO_USB_DETECTION_ON_TIME_CFG_MASK | MICRO_USB_DETECTION_ON_TIME_CFG_MASK | Loading Loading @@ -1510,8 +1540,9 @@ static int smblib_set_moisture_protection(struct smb_charger *chg, } } /* Disable periodic monitoring of CC_ID pin */ /* Disable periodic monitoring of CC_ID pin */ rc = smblib_write(chg, ((chg->smb_version == PMI632_SUBTYPE) ? rc = smblib_write(chg, PMI632_TYPEC_U_USB_WATER_PROTECTION_CFG_REG : ((chg->chg_param.smb_version == PMI632_SUBTYPE) ? PMI632_TYPEC_U_USB_WATER_PROTECTION_CFG_REG : TYPEC_U_USB_WATER_PROTECTION_CFG_REG), 0); TYPEC_U_USB_WATER_PROTECTION_CFG_REG), 0); if (rc < 0) { if (rc < 0) { smblib_err(chg, "Couldn't disable 1 percent CC_ID duty cycle rc=%d\n", smblib_err(chg, "Couldn't disable 1 percent CC_ID duty cycle rc=%d\n", Loading Loading @@ -1559,7 +1590,7 @@ static int smblib_dc_suspend_vote_callback(struct votable *votable, void *data, { { struct smb_charger *chg = data; struct smb_charger *chg = data; if (chg->smb_version == PMI632_SUBTYPE) if (chg->chg_param.smb_version == PMI632_SUBTYPE) return 0; return 0; /* resume input if suspend is invalid */ /* resume input if suspend is invalid */ Loading Loading @@ -2149,7 +2180,7 @@ int smblib_get_prop_batt_iterm(struct smb_charger *chg, temp = buf[1] | (buf[0] << 8); temp = buf[1] | (buf[0] << 8); temp = sign_extend32(temp, 15); temp = sign_extend32(temp, 15); if (chg->smb_version == PMI632_SUBTYPE) if (chg->chg_param.smb_version == PMI632_SUBTYPE) temp = DIV_ROUND_CLOSEST(temp * ITERM_LIMITS_PMI632_MA, temp = DIV_ROUND_CLOSEST(temp * ITERM_LIMITS_PMI632_MA, ADC_CHG_ITERM_MASK); ADC_CHG_ITERM_MASK); else else Loading Loading @@ -2655,10 +2686,7 @@ static int smblib_update_thermal_readings(struct smb_charger *chg) } } if (chg->sec_chg_selected == POWER_SUPPLY_CHARGER_SEC_CP) { if (chg->sec_chg_selected == POWER_SUPPLY_CHARGER_SEC_CP) { if (!chg->cp_psy) if (is_cp_available(chg)) { chg->cp_psy = power_supply_get_by_name("charge_pump_master"); if (chg->cp_psy) { rc = power_supply_get_property(chg->cp_psy, rc = power_supply_get_property(chg->cp_psy, POWER_SUPPLY_PROP_CP_DIE_TEMP, &pval); POWER_SUPPLY_PROP_CP_DIE_TEMP, &pval); if (rc < 0) { if (rc < 0) { Loading Loading @@ -2875,7 +2903,7 @@ int smblib_get_prop_dc_present(struct smb_charger *chg, int rc; int rc; u8 stat; u8 stat; if (chg->smb_version == PMI632_SUBTYPE) { if (chg->chg_param.smb_version == PMI632_SUBTYPE) { val->intval = 0; val->intval = 0; return 0; return 0; } } Loading @@ -2896,7 +2924,7 @@ int smblib_get_prop_dc_online(struct smb_charger *chg, int rc = 0; int rc = 0; u8 stat; u8 stat; if (chg->smb_version == PMI632_SUBTYPE) { if (chg->chg_param.smb_version == PMI632_SUBTYPE) { val->intval = 0; val->intval = 0; return 0; return 0; } } Loading Loading @@ -3111,7 +3139,7 @@ int smblib_get_prop_usb_voltage_max_design(struct smb_charger *chg, /* else, fallthrough */ /* else, fallthrough */ case POWER_SUPPLY_TYPE_USB_HVDCP_3: case POWER_SUPPLY_TYPE_USB_HVDCP_3: case POWER_SUPPLY_TYPE_USB_PD: case POWER_SUPPLY_TYPE_USB_PD: if (chg->smb_version == PMI632_SUBTYPE) if (chg->chg_param.smb_version == PMI632_SUBTYPE) val->intval = MICRO_9V; val->intval = MICRO_9V; else else val->intval = MICRO_12V; val->intval = MICRO_12V; Loading Loading @@ -3139,7 +3167,7 @@ int smblib_get_prop_usb_voltage_max(struct smb_charger *chg, } } /* else, fallthrough */ /* else, fallthrough */ case POWER_SUPPLY_TYPE_USB_HVDCP_3: case POWER_SUPPLY_TYPE_USB_HVDCP_3: if (chg->smb_version == PMI632_SUBTYPE) if (chg->chg_param.smb_version == PMI632_SUBTYPE) val->intval = MICRO_9V; val->intval = MICRO_9V; else else val->intval = MICRO_12V; val->intval = MICRO_12V; Loading Loading @@ -3237,7 +3265,7 @@ int smblib_get_prop_usb_voltage_now(struct smb_charger *chg, * to occur randomly in the USBIN channel, particularly at high * to occur randomly in the USBIN channel, particularly at high * voltages. * voltages. */ */ if (chg->smb_version == PM8150B_SUBTYPE && pval.intval) if (chg->chg_param.smb_version == PM8150B_SUBTYPE && pval.intval) return smblib_read_mid_voltage_chan(chg, val); return smblib_read_mid_voltage_chan(chg, val); else else return smblib_read_usbin_voltage_chan(chg, val); return smblib_read_usbin_voltage_chan(chg, val); Loading Loading @@ -3571,7 +3599,7 @@ int smblib_get_prop_usb_current_now(struct smb_charger *chg, * For PMI632, scaling factor = reciprocal of * For PMI632, scaling factor = reciprocal of * 0.4V/A in Buck mode, 0.8V/A in Boost mode. * 0.4V/A in Buck mode, 0.8V/A in Boost mode. */ */ switch (chg->smb_version) { switch (chg->chg_param.smb_version) { case PMI632_SUBTYPE: case PMI632_SUBTYPE: buck_scale = 40; buck_scale = 40; boost_scale = 80; boost_scale = 80; Loading Loading @@ -3857,7 +3885,7 @@ int smblib_get_prop_connector_health(struct smb_charger *chg) * In PM8150B, SKIN channel measures Wireless charger receiver * In PM8150B, SKIN channel measures Wireless charger receiver * temp, used to regulate DC ICL. * temp, used to regulate DC ICL. */ */ if (chg->smb_version == PM8150B_SUBTYPE && dc_present) if (chg->chg_param.smb_version == PM8150B_SUBTYPE && dc_present) return smblib_get_skin_temp_status(chg); return smblib_get_skin_temp_status(chg); return POWER_SUPPLY_HEALTH_COOL; return POWER_SUPPLY_HEALTH_COOL; Loading Loading @@ -4818,7 +4846,7 @@ irqreturn_t usbin_uv_irq_handler(int irq, void *data) unsuspend_input: unsuspend_input: /* Force torch in boost mode to ensure it works with low ICL */ /* Force torch in boost mode to ensure it works with low ICL */ if (chg->smb_version == PMI632_SUBTYPE) if (chg->chg_param.smb_version == PMI632_SUBTYPE) schgm_flash_torch_priority(chg, TORCH_BOOST_MODE); schgm_flash_torch_priority(chg, TORCH_BOOST_MODE); if (chg->aicl_max_reached) { if (chg->aicl_max_reached) { Loading Loading @@ -5082,7 +5110,7 @@ void smblib_usb_plugin_locked(struct smb_charger *chg) chg->aicl_cont_threshold_mv); chg->aicl_cont_threshold_mv); chg->aicl_max_reached = false; chg->aicl_max_reached = false; if (chg->smb_version == PMI632_SUBTYPE) if (chg->chg_param.smb_version == PMI632_SUBTYPE) schgm_flash_torch_priority(chg, schgm_flash_torch_priority(chg, TORCH_BUCK_MODE); TORCH_BUCK_MODE); Loading Loading @@ -6428,7 +6456,7 @@ static void smblib_moisture_protection_work(struct work_struct *work) * Disable 1% duty cycle on CC_ID pin and enable uUSB factory mode * Disable 1% duty cycle on CC_ID pin and enable uUSB factory mode * detection to track any change on RID, as interrupts are disable. * detection to track any change on RID, as interrupts are disable. */ */ rc = smblib_write(chg, ((chg->smb_version == PMI632_SUBTYPE) ? rc = smblib_write(chg, ((chg->chg_param.smb_version == PMI632_SUBTYPE) ? PMI632_TYPEC_U_USB_WATER_PROTECTION_CFG_REG : PMI632_TYPEC_U_USB_WATER_PROTECTION_CFG_REG : TYPEC_U_USB_WATER_PROTECTION_CFG_REG), 0); TYPEC_U_USB_WATER_PROTECTION_CFG_REG), 0); if (rc < 0) { if (rc < 0) { Loading Loading @@ -7188,7 +7216,7 @@ int smblib_init(struct smb_charger *chg) switch (chg->mode) { switch (chg->mode) { case PARALLEL_MASTER: case PARALLEL_MASTER: rc = qcom_batt_init(chg->smb_version); rc = qcom_batt_init(&chg->chg_param); if (rc < 0) { if (rc < 0) { smblib_err(chg, "Couldn't init qcom_batt_init rc=%d\n", smblib_err(chg, "Couldn't init qcom_batt_init rc=%d\n", rc); rc); Loading