Loading drivers/power/supply/qcom/qpnp-smb2.c +123 −5 Original line number Diff line number Diff line Loading @@ -427,6 +427,7 @@ static enum power_supply_property smb2_usb_props[] = { POWER_SUPPLY_PROP_PE_START, POWER_SUPPLY_PROP_CTM_CURRENT_MAX, POWER_SUPPLY_PROP_HW_CURRENT_MAX, POWER_SUPPLY_PROP_REAL_TYPE, }; static int smb2_usb_get_prop(struct power_supply *psy, Loading @@ -446,6 +447,16 @@ static int smb2_usb_get_prop(struct power_supply *psy, break; case POWER_SUPPLY_PROP_ONLINE: rc = smblib_get_prop_usb_online(chg, val); if (!val->intval) break; rc = smblib_get_prop_typec_mode(chg, val); if ((val->intval == POWER_SUPPLY_TYPEC_SOURCE_DEFAULT || chg->micro_usb_mode) && chg->real_charger_type == POWER_SUPPLY_TYPE_USB) val->intval = 0; else val->intval = 1; break; case POWER_SUPPLY_PROP_VOLTAGE_MIN: val->intval = chg->voltage_min_uv; Loading @@ -463,10 +474,13 @@ static int smb2_usb_get_prop(struct power_supply *psy, rc = smblib_get_prop_usb_current_max(chg, val); break; case POWER_SUPPLY_PROP_TYPE: val->intval = POWER_SUPPLY_TYPE_USB_PD; break; case POWER_SUPPLY_PROP_REAL_TYPE: if (chip->bad_part) val->intval = POWER_SUPPLY_TYPE_USB; val->intval = POWER_SUPPLY_TYPE_USB_PD; else val->intval = chg->usb_psy_desc.type; val->intval = chg->real_charger_type; break; case POWER_SUPPLY_PROP_TYPEC_MODE: if (chg->micro_usb_mode) Loading Loading @@ -608,7 +622,7 @@ static int smb2_init_usb_psy(struct smb2 *chip) struct smb_charger *chg = &chip->chg; chg->usb_psy_desc.name = "usb"; chg->usb_psy_desc.type = POWER_SUPPLY_TYPE_UNKNOWN; chg->usb_psy_desc.type = POWER_SUPPLY_TYPE_USB_PD; chg->usb_psy_desc.properties = smb2_usb_props; chg->usb_psy_desc.num_properties = ARRAY_SIZE(smb2_usb_props); chg->usb_psy_desc.get_property = smb2_usb_get_prop; Loading @@ -628,6 +642,97 @@ static int smb2_init_usb_psy(struct smb2 *chip) return 0; } /******************************** * USB PC_PORT PSY REGISTRATION * ********************************/ static enum power_supply_property smb2_usb_port_props[] = { POWER_SUPPLY_PROP_TYPE, POWER_SUPPLY_PROP_ONLINE, }; static int smb2_usb_port_get_prop(struct power_supply *psy, enum power_supply_property psp, union power_supply_propval *val) { struct smb2 *chip = power_supply_get_drvdata(psy); struct smb_charger *chg = &chip->chg; int rc = 0; switch (psp) { case POWER_SUPPLY_PROP_TYPE: val->intval = POWER_SUPPLY_TYPE_USB; break; case POWER_SUPPLY_PROP_ONLINE: rc = smblib_get_prop_usb_online(chg, val); if (!val->intval) break; rc = smblib_get_prop_typec_mode(chg, val); if ((val->intval == POWER_SUPPLY_TYPEC_SOURCE_DEFAULT || chg->micro_usb_mode) && chg->real_charger_type == POWER_SUPPLY_TYPE_USB) val->intval = 1; else val->intval = 0; break; default: pr_err_ratelimited("Get prop %d is not supported in pc_port\n", psp); return -EINVAL; } if (rc < 0) { pr_debug("Couldn't get prop %d rc = %d\n", psp, rc); return -ENODATA; } return 0; } static int smb2_usb_port_set_prop(struct power_supply *psy, enum power_supply_property psp, const union power_supply_propval *val) { int rc = 0; switch (psp) { default: pr_err_ratelimited("Set prop %d is not supported in pc_port\n", psp); rc = -EINVAL; break; } return rc; } static const struct power_supply_desc usb_port_psy_desc = { .name = "pc_port", .type = POWER_SUPPLY_TYPE_USB, .properties = smb2_usb_port_props, .num_properties = ARRAY_SIZE(smb2_usb_port_props), .get_property = smb2_usb_port_get_prop, .set_property = smb2_usb_port_set_prop, }; static int smb2_init_usb_port_psy(struct smb2 *chip) { struct power_supply_config usb_port_cfg = {}; struct smb_charger *chg = &chip->chg; usb_port_cfg.drv_data = chip; usb_port_cfg.of_node = chg->dev->of_node; chg->usb_port_psy = power_supply_register(chg->dev, &usb_port_psy_desc, &usb_port_cfg); if (IS_ERR(chg->usb_port_psy)) { pr_err("Couldn't register USB pc_port power supply\n"); return PTR_ERR(chg->usb_port_psy); } return 0; } /***************************** * USB MAIN PSY REGISTRATION * *****************************/ Loading Loading @@ -1061,6 +1166,9 @@ static int smb2_batt_set_prop(struct power_supply *psy, case POWER_SUPPLY_PROP_DP_DM: rc = smblib_dp_dm(chg, val->intval); break; case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMITED: rc = smblib_set_prop_input_current_limited(chg, val); break; default: rc = -EINVAL; } Loading @@ -1078,6 +1186,7 @@ static int smb2_batt_prop_is_writeable(struct power_supply *psy, case POWER_SUPPLY_PROP_PARALLEL_DISABLE: case POWER_SUPPLY_PROP_DP_DM: case POWER_SUPPLY_PROP_RERUN_AICL: case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMITED: return 1; default: break; Loading Loading @@ -2266,7 +2375,13 @@ static int smb2_probe(struct platform_device *pdev) rc = smb2_init_usb_main_psy(chip); if (rc < 0) { pr_err("Couldn't initialize usb psy rc=%d\n", rc); pr_err("Couldn't initialize usb main psy rc=%d\n", rc); goto cleanup; } rc = smb2_init_usb_port_psy(chip); if (rc < 0) { pr_err("Couldn't initialize usb pc_port psy rc=%d\n", rc); goto cleanup; } Loading Loading @@ -2324,7 +2439,7 @@ static int smb2_probe(struct platform_device *pdev) device_init_wakeup(chg->dev, true); pr_info("QPNP SMB2 probed successfully usb:present=%d type=%d batt:present = %d health = %d charge = %d\n", usb_present, chg->usb_psy_desc.type, usb_present, chg->real_charger_type, batt_present, batt_health, batt_charge_type); return rc; Loading @@ -2336,6 +2451,8 @@ cleanup: power_supply_unregister(chg->usb_main_psy); if (chg->usb_psy) power_supply_unregister(chg->usb_psy); if (chg->usb_port_psy) power_supply_unregister(chg->usb_port_psy); if (chg->dc_psy) power_supply_unregister(chg->dc_psy); if (chg->vconn_vreg && chg->vconn_vreg->rdev) Loading @@ -2356,6 +2473,7 @@ static int smb2_remove(struct platform_device *pdev) power_supply_unregister(chg->batt_psy); power_supply_unregister(chg->usb_psy); power_supply_unregister(chg->usb_port_psy); regulator_unregister(chg->vconn_vreg->rdev); regulator_unregister(chg->vbus_vreg->rdev); Loading drivers/power/supply/qcom/smb-lib.c +20 −7 Original line number Diff line number Diff line Loading @@ -550,9 +550,9 @@ static const struct apsd_result *smblib_update_usb_type(struct smb_charger *chg) /* if PD is active, APSD is disabled so won't have a valid result */ if (chg->pd_active) chg->usb_psy_desc.type = POWER_SUPPLY_TYPE_USB_PD; chg->real_charger_type = POWER_SUPPLY_TYPE_USB_PD; else chg->usb_psy_desc.type = apsd_result->pst; chg->real_charger_type = apsd_result->pst; smblib_dbg(chg, PR_MISC, "APSD=%s PD=%d\n", apsd_result->name, chg->pd_active); Loading Loading @@ -858,7 +858,7 @@ int smblib_set_icl_current(struct smb_charger *chg, int icl_ua) /* configure current */ if (pval.intval == POWER_SUPPLY_TYPEC_SOURCE_DEFAULT && (chg->usb_psy_desc.type == POWER_SUPPLY_TYPE_USB)) { && (chg->real_charger_type == POWER_SUPPLY_TYPE_USB)) { rc = set_sdp_current(chg, icl_ua); if (rc < 0) { smblib_err(chg, "Couldn't set SDP ICL rc=%d\n", rc); Loading @@ -879,10 +879,10 @@ override_suspend_config: /* remove override if no voters - hw defaults is desired */ override = false; } else if (pval.intval == POWER_SUPPLY_TYPEC_SOURCE_DEFAULT) { if (chg->usb_psy_desc.type == POWER_SUPPLY_TYPE_USB) if (chg->real_charger_type == POWER_SUPPLY_TYPE_USB) /* For std cable with type = SDP never override */ override = false; else if (chg->usb_psy_desc.type == POWER_SUPPLY_TYPE_USB_CDP else if (chg->real_charger_type == POWER_SUPPLY_TYPE_USB_CDP && icl_ua == 1500000) /* * For std cable with type = CDP override only if Loading Loading @@ -1707,6 +1707,11 @@ int smblib_get_prop_input_current_limited(struct smb_charger *chg, u8 stat; int rc; if (chg->fake_input_current_limited >= 0) { val->intval = chg->fake_input_current_limited; return 0; } rc = smblib_read(chg, AICL_STATUS_REG, &stat); if (rc < 0) { smblib_err(chg, "Couldn't read AICL_STATUS rc=%d\n", rc); Loading Loading @@ -1898,6 +1903,13 @@ int smblib_set_prop_charge_qnovo_enable(struct smb_charger *chg, return rc; } int smblib_set_prop_input_current_limited(struct smb_charger *chg, const union power_supply_propval *val) { chg->fake_input_current_limited = val->intval; return 0; } int smblib_rerun_aicl(struct smb_charger *chg) { int rc, settled_icl_ua; Loading Loading @@ -3314,7 +3326,7 @@ static void smblib_hvdcp_adaptive_voltage_change(struct smb_charger *chg) int pulses; power_supply_changed(chg->usb_main_psy); if (chg->usb_psy_desc.type == POWER_SUPPLY_TYPE_USB_HVDCP) { if (chg->real_charger_type == POWER_SUPPLY_TYPE_USB_HVDCP) { rc = smblib_read(chg, QC_CHANGE_STATUS_REG, &stat); if (rc < 0) { smblib_err(chg, Loading Loading @@ -3342,7 +3354,7 @@ static void smblib_hvdcp_adaptive_voltage_change(struct smb_charger *chg) } } if (chg->usb_psy_desc.type == POWER_SUPPLY_TYPE_USB_HVDCP_3) { if (chg->real_charger_type == POWER_SUPPLY_TYPE_USB_HVDCP_3) { rc = smblib_read(chg, QC_PULSE_COUNT_STATUS_REG, &stat); if (rc < 0) { smblib_err(chg, Loading Loading @@ -4471,6 +4483,7 @@ int smblib_init(struct smb_charger *chg) INIT_DELAYED_WORK(&chg->pl_enable_work, smblib_pl_enable_work); INIT_WORK(&chg->legacy_detection_work, smblib_legacy_detection_work); chg->fake_capacity = -EINVAL; chg->fake_input_current_limited = -EINVAL; switch (chg->mode) { case PARALLEL_MASTER: Loading drivers/power/supply/qcom/smb-lib.h +5 −0 Original line number Diff line number Diff line Loading @@ -244,6 +244,8 @@ struct smb_charger { struct power_supply *bms_psy; struct power_supply_desc usb_psy_desc; struct power_supply *usb_main_psy; struct power_supply *usb_port_psy; enum power_supply_type real_charger_type; /* notifiers */ struct notifier_block nb; Loading Loading @@ -316,6 +318,7 @@ struct smb_charger { bool typec_present; u8 typec_status[5]; bool typec_legacy_valid; int fake_input_current_limited; /* workaround flag */ u32 wa_flags; Loading Loading @@ -419,6 +422,8 @@ int smblib_set_prop_batt_capacity(struct smb_charger *chg, const union power_supply_propval *val); int smblib_set_prop_system_temp_level(struct smb_charger *chg, const union power_supply_propval *val); int smblib_set_prop_input_current_limited(struct smb_charger *chg, const union power_supply_propval *val); int smblib_get_prop_dc_present(struct smb_charger *chg, union power_supply_propval *val); Loading drivers/power/supply/qcom/smb138x-charger.c +27 −49 Original line number Diff line number Diff line Loading @@ -598,26 +598,6 @@ static enum power_supply_property smb1355_parallel_props[] = { POWER_SUPPLY_PROP_CHARGER_TEMP_MAX, }; static int smb138x_get_parallel_charging(struct smb138x *chip, int *disabled) { struct smb_charger *chg = &chip->chg; int rc = 0; u8 cfg2; rc = smblib_read(chg, CHGR_CFG2_REG, &cfg2); if (rc < 0) { pr_err("Couldn't read en_cmg_reg rc=%d\n", rc); return rc; } if (cfg2 & CHG_EN_SRC_BIT) *disabled = 0; else *disabled = 1; return 0; } static int smb138x_parallel_get_prop(struct power_supply *psy, enum power_supply_property prop, union power_supply_propval *val) Loading @@ -644,7 +624,7 @@ static int smb138x_parallel_get_prop(struct power_supply *psy, val->intval = !(temp & DISABLE_CHARGING_BIT); break; case POWER_SUPPLY_PROP_INPUT_SUSPEND: rc = smb138x_get_parallel_charging(chip, &val->intval); rc = smblib_get_usb_suspend(chg, &val->intval); break; case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMITED: if ((chip->dt.pl_mode == POWER_SUPPLY_PL_USBIN_USBIN) Loading Loading @@ -714,33 +694,28 @@ static int smb138x_parallel_get_prop(struct power_supply *psy, return rc; } static int smb138x_set_parallel_charging(struct smb138x *chip, bool disable) static int smb138x_set_parallel_suspend(struct smb138x *chip, bool suspend) { struct smb_charger *chg = &chip->chg; int rc = 0; rc = smblib_masked_write(chg, WD_CFG_REG, WDOG_TIMER_EN_BIT, disable ? 0 : WDOG_TIMER_EN_BIT); suspend ? 0 : WDOG_TIMER_EN_BIT); if (rc < 0) { pr_err("Couldn't %s watchdog rc=%d\n", disable ? "disable" : "enable", rc); disable = true; suspend ? "disable" : "enable", rc); suspend = true; } /* * Configure charge enable for high polarity and * When disabling charging set it to cmd register control(cmd bit=0) * When enabling charging set it to pin control */ rc = smblib_masked_write(chg, CHGR_CFG2_REG, CHG_EN_POLARITY_BIT | CHG_EN_SRC_BIT, disable ? 0 : CHG_EN_SRC_BIT); rc = smblib_masked_write(chg, USBIN_CMD_IL_REG, USBIN_SUSPEND_BIT, suspend ? USBIN_SUSPEND_BIT : 0); if (rc < 0) { pr_err("Couldn't configure charge enable source rc=%d\n", rc); pr_err("Couldn't %s parallel charger rc=%d\n", suspend ? "suspend" : "resume", rc); return rc; } return 0; return rc; } static int smb138x_parallel_set_prop(struct power_supply *psy, Loading @@ -753,7 +728,7 @@ static int smb138x_parallel_set_prop(struct power_supply *psy, switch (prop) { case POWER_SUPPLY_PROP_INPUT_SUSPEND: rc = smb138x_set_parallel_charging(chip, (bool)val->intval); rc = smb138x_set_parallel_suspend(chip, (bool)val->intval); break; case POWER_SUPPLY_PROP_CURRENT_MAX: if ((chip->dt.pl_mode == POWER_SUPPLY_PL_USBIN_USBIN) Loading Loading @@ -971,32 +946,35 @@ static int smb138x_init_slave_hw(struct smb138x *chip) return rc; } /* disable the charging path when under s/w control */ rc = smblib_masked_write(chg, CHARGING_ENABLE_CMD_REG, CHARGING_ENABLE_CMD_BIT, 0); /* suspend parallel charging */ rc = smb138x_set_parallel_suspend(chip, true); if (rc < 0) { pr_err("Couldn't disable charging rc=%d\n", rc); pr_err("Couldn't suspend parallel charging rc=%d\n", rc); return rc; } /* disable parallel charging path */ rc = smb138x_set_parallel_charging(chip, true); /* initialize FCC to 0 */ rc = smblib_set_charge_param(chg, &chg->param.fcc, 0); if (rc < 0) { pr_err("Couldn't disable parallel path rc=%d\n", rc); pr_err("Couldn't set 0 FCC rc=%d\n", rc); return rc; } /* unsuspend parallel charging */ rc = smblib_masked_write(chg, USBIN_CMD_IL_REG, USBIN_SUSPEND_BIT, 0); /* enable the charging path */ rc = smblib_masked_write(chg, CHARGING_ENABLE_CMD_REG, CHARGING_ENABLE_CMD_BIT, CHARGING_ENABLE_CMD_BIT); if (rc < 0) { pr_err("Couldn't unsuspend parallel charging rc=%d\n", rc); pr_err("Couldn't enable charging rc=%d\n", rc); return rc; } /* initialize FCC to 0 */ rc = smblib_set_charge_param(chg, &chg->param.fcc, 0); /* configure charge enable for software control; active high */ rc = smblib_masked_write(chg, CHGR_CFG2_REG, CHG_EN_POLARITY_BIT | CHG_EN_SRC_BIT, 0); if (rc < 0) { pr_err("Couldn't set 0 FCC rc=%d\n", rc); pr_err("Couldn't configure charge enable source rc=%d\n", rc); return rc; } Loading drivers/usb/dwc3/dwc3-msm.c +2 −1 Original line number Diff line number Diff line Loading @@ -3597,7 +3597,8 @@ static int dwc3_msm_gadget_vbus_draw(struct dwc3_msm *mdwc, unsigned mA) } } power_supply_get_property(mdwc->usb_psy, POWER_SUPPLY_PROP_TYPE, &pval); power_supply_get_property(mdwc->usb_psy, POWER_SUPPLY_PROP_REAL_TYPE, &pval); if (pval.intval != POWER_SUPPLY_TYPE_USB) return 0; Loading Loading
drivers/power/supply/qcom/qpnp-smb2.c +123 −5 Original line number Diff line number Diff line Loading @@ -427,6 +427,7 @@ static enum power_supply_property smb2_usb_props[] = { POWER_SUPPLY_PROP_PE_START, POWER_SUPPLY_PROP_CTM_CURRENT_MAX, POWER_SUPPLY_PROP_HW_CURRENT_MAX, POWER_SUPPLY_PROP_REAL_TYPE, }; static int smb2_usb_get_prop(struct power_supply *psy, Loading @@ -446,6 +447,16 @@ static int smb2_usb_get_prop(struct power_supply *psy, break; case POWER_SUPPLY_PROP_ONLINE: rc = smblib_get_prop_usb_online(chg, val); if (!val->intval) break; rc = smblib_get_prop_typec_mode(chg, val); if ((val->intval == POWER_SUPPLY_TYPEC_SOURCE_DEFAULT || chg->micro_usb_mode) && chg->real_charger_type == POWER_SUPPLY_TYPE_USB) val->intval = 0; else val->intval = 1; break; case POWER_SUPPLY_PROP_VOLTAGE_MIN: val->intval = chg->voltage_min_uv; Loading @@ -463,10 +474,13 @@ static int smb2_usb_get_prop(struct power_supply *psy, rc = smblib_get_prop_usb_current_max(chg, val); break; case POWER_SUPPLY_PROP_TYPE: val->intval = POWER_SUPPLY_TYPE_USB_PD; break; case POWER_SUPPLY_PROP_REAL_TYPE: if (chip->bad_part) val->intval = POWER_SUPPLY_TYPE_USB; val->intval = POWER_SUPPLY_TYPE_USB_PD; else val->intval = chg->usb_psy_desc.type; val->intval = chg->real_charger_type; break; case POWER_SUPPLY_PROP_TYPEC_MODE: if (chg->micro_usb_mode) Loading Loading @@ -608,7 +622,7 @@ static int smb2_init_usb_psy(struct smb2 *chip) struct smb_charger *chg = &chip->chg; chg->usb_psy_desc.name = "usb"; chg->usb_psy_desc.type = POWER_SUPPLY_TYPE_UNKNOWN; chg->usb_psy_desc.type = POWER_SUPPLY_TYPE_USB_PD; chg->usb_psy_desc.properties = smb2_usb_props; chg->usb_psy_desc.num_properties = ARRAY_SIZE(smb2_usb_props); chg->usb_psy_desc.get_property = smb2_usb_get_prop; Loading @@ -628,6 +642,97 @@ static int smb2_init_usb_psy(struct smb2 *chip) return 0; } /******************************** * USB PC_PORT PSY REGISTRATION * ********************************/ static enum power_supply_property smb2_usb_port_props[] = { POWER_SUPPLY_PROP_TYPE, POWER_SUPPLY_PROP_ONLINE, }; static int smb2_usb_port_get_prop(struct power_supply *psy, enum power_supply_property psp, union power_supply_propval *val) { struct smb2 *chip = power_supply_get_drvdata(psy); struct smb_charger *chg = &chip->chg; int rc = 0; switch (psp) { case POWER_SUPPLY_PROP_TYPE: val->intval = POWER_SUPPLY_TYPE_USB; break; case POWER_SUPPLY_PROP_ONLINE: rc = smblib_get_prop_usb_online(chg, val); if (!val->intval) break; rc = smblib_get_prop_typec_mode(chg, val); if ((val->intval == POWER_SUPPLY_TYPEC_SOURCE_DEFAULT || chg->micro_usb_mode) && chg->real_charger_type == POWER_SUPPLY_TYPE_USB) val->intval = 1; else val->intval = 0; break; default: pr_err_ratelimited("Get prop %d is not supported in pc_port\n", psp); return -EINVAL; } if (rc < 0) { pr_debug("Couldn't get prop %d rc = %d\n", psp, rc); return -ENODATA; } return 0; } static int smb2_usb_port_set_prop(struct power_supply *psy, enum power_supply_property psp, const union power_supply_propval *val) { int rc = 0; switch (psp) { default: pr_err_ratelimited("Set prop %d is not supported in pc_port\n", psp); rc = -EINVAL; break; } return rc; } static const struct power_supply_desc usb_port_psy_desc = { .name = "pc_port", .type = POWER_SUPPLY_TYPE_USB, .properties = smb2_usb_port_props, .num_properties = ARRAY_SIZE(smb2_usb_port_props), .get_property = smb2_usb_port_get_prop, .set_property = smb2_usb_port_set_prop, }; static int smb2_init_usb_port_psy(struct smb2 *chip) { struct power_supply_config usb_port_cfg = {}; struct smb_charger *chg = &chip->chg; usb_port_cfg.drv_data = chip; usb_port_cfg.of_node = chg->dev->of_node; chg->usb_port_psy = power_supply_register(chg->dev, &usb_port_psy_desc, &usb_port_cfg); if (IS_ERR(chg->usb_port_psy)) { pr_err("Couldn't register USB pc_port power supply\n"); return PTR_ERR(chg->usb_port_psy); } return 0; } /***************************** * USB MAIN PSY REGISTRATION * *****************************/ Loading Loading @@ -1061,6 +1166,9 @@ static int smb2_batt_set_prop(struct power_supply *psy, case POWER_SUPPLY_PROP_DP_DM: rc = smblib_dp_dm(chg, val->intval); break; case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMITED: rc = smblib_set_prop_input_current_limited(chg, val); break; default: rc = -EINVAL; } Loading @@ -1078,6 +1186,7 @@ static int smb2_batt_prop_is_writeable(struct power_supply *psy, case POWER_SUPPLY_PROP_PARALLEL_DISABLE: case POWER_SUPPLY_PROP_DP_DM: case POWER_SUPPLY_PROP_RERUN_AICL: case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMITED: return 1; default: break; Loading Loading @@ -2266,7 +2375,13 @@ static int smb2_probe(struct platform_device *pdev) rc = smb2_init_usb_main_psy(chip); if (rc < 0) { pr_err("Couldn't initialize usb psy rc=%d\n", rc); pr_err("Couldn't initialize usb main psy rc=%d\n", rc); goto cleanup; } rc = smb2_init_usb_port_psy(chip); if (rc < 0) { pr_err("Couldn't initialize usb pc_port psy rc=%d\n", rc); goto cleanup; } Loading Loading @@ -2324,7 +2439,7 @@ static int smb2_probe(struct platform_device *pdev) device_init_wakeup(chg->dev, true); pr_info("QPNP SMB2 probed successfully usb:present=%d type=%d batt:present = %d health = %d charge = %d\n", usb_present, chg->usb_psy_desc.type, usb_present, chg->real_charger_type, batt_present, batt_health, batt_charge_type); return rc; Loading @@ -2336,6 +2451,8 @@ cleanup: power_supply_unregister(chg->usb_main_psy); if (chg->usb_psy) power_supply_unregister(chg->usb_psy); if (chg->usb_port_psy) power_supply_unregister(chg->usb_port_psy); if (chg->dc_psy) power_supply_unregister(chg->dc_psy); if (chg->vconn_vreg && chg->vconn_vreg->rdev) Loading @@ -2356,6 +2473,7 @@ static int smb2_remove(struct platform_device *pdev) power_supply_unregister(chg->batt_psy); power_supply_unregister(chg->usb_psy); power_supply_unregister(chg->usb_port_psy); regulator_unregister(chg->vconn_vreg->rdev); regulator_unregister(chg->vbus_vreg->rdev); Loading
drivers/power/supply/qcom/smb-lib.c +20 −7 Original line number Diff line number Diff line Loading @@ -550,9 +550,9 @@ static const struct apsd_result *smblib_update_usb_type(struct smb_charger *chg) /* if PD is active, APSD is disabled so won't have a valid result */ if (chg->pd_active) chg->usb_psy_desc.type = POWER_SUPPLY_TYPE_USB_PD; chg->real_charger_type = POWER_SUPPLY_TYPE_USB_PD; else chg->usb_psy_desc.type = apsd_result->pst; chg->real_charger_type = apsd_result->pst; smblib_dbg(chg, PR_MISC, "APSD=%s PD=%d\n", apsd_result->name, chg->pd_active); Loading Loading @@ -858,7 +858,7 @@ int smblib_set_icl_current(struct smb_charger *chg, int icl_ua) /* configure current */ if (pval.intval == POWER_SUPPLY_TYPEC_SOURCE_DEFAULT && (chg->usb_psy_desc.type == POWER_SUPPLY_TYPE_USB)) { && (chg->real_charger_type == POWER_SUPPLY_TYPE_USB)) { rc = set_sdp_current(chg, icl_ua); if (rc < 0) { smblib_err(chg, "Couldn't set SDP ICL rc=%d\n", rc); Loading @@ -879,10 +879,10 @@ override_suspend_config: /* remove override if no voters - hw defaults is desired */ override = false; } else if (pval.intval == POWER_SUPPLY_TYPEC_SOURCE_DEFAULT) { if (chg->usb_psy_desc.type == POWER_SUPPLY_TYPE_USB) if (chg->real_charger_type == POWER_SUPPLY_TYPE_USB) /* For std cable with type = SDP never override */ override = false; else if (chg->usb_psy_desc.type == POWER_SUPPLY_TYPE_USB_CDP else if (chg->real_charger_type == POWER_SUPPLY_TYPE_USB_CDP && icl_ua == 1500000) /* * For std cable with type = CDP override only if Loading Loading @@ -1707,6 +1707,11 @@ int smblib_get_prop_input_current_limited(struct smb_charger *chg, u8 stat; int rc; if (chg->fake_input_current_limited >= 0) { val->intval = chg->fake_input_current_limited; return 0; } rc = smblib_read(chg, AICL_STATUS_REG, &stat); if (rc < 0) { smblib_err(chg, "Couldn't read AICL_STATUS rc=%d\n", rc); Loading Loading @@ -1898,6 +1903,13 @@ int smblib_set_prop_charge_qnovo_enable(struct smb_charger *chg, return rc; } int smblib_set_prop_input_current_limited(struct smb_charger *chg, const union power_supply_propval *val) { chg->fake_input_current_limited = val->intval; return 0; } int smblib_rerun_aicl(struct smb_charger *chg) { int rc, settled_icl_ua; Loading Loading @@ -3314,7 +3326,7 @@ static void smblib_hvdcp_adaptive_voltage_change(struct smb_charger *chg) int pulses; power_supply_changed(chg->usb_main_psy); if (chg->usb_psy_desc.type == POWER_SUPPLY_TYPE_USB_HVDCP) { if (chg->real_charger_type == POWER_SUPPLY_TYPE_USB_HVDCP) { rc = smblib_read(chg, QC_CHANGE_STATUS_REG, &stat); if (rc < 0) { smblib_err(chg, Loading Loading @@ -3342,7 +3354,7 @@ static void smblib_hvdcp_adaptive_voltage_change(struct smb_charger *chg) } } if (chg->usb_psy_desc.type == POWER_SUPPLY_TYPE_USB_HVDCP_3) { if (chg->real_charger_type == POWER_SUPPLY_TYPE_USB_HVDCP_3) { rc = smblib_read(chg, QC_PULSE_COUNT_STATUS_REG, &stat); if (rc < 0) { smblib_err(chg, Loading Loading @@ -4471,6 +4483,7 @@ int smblib_init(struct smb_charger *chg) INIT_DELAYED_WORK(&chg->pl_enable_work, smblib_pl_enable_work); INIT_WORK(&chg->legacy_detection_work, smblib_legacy_detection_work); chg->fake_capacity = -EINVAL; chg->fake_input_current_limited = -EINVAL; switch (chg->mode) { case PARALLEL_MASTER: Loading
drivers/power/supply/qcom/smb-lib.h +5 −0 Original line number Diff line number Diff line Loading @@ -244,6 +244,8 @@ struct smb_charger { struct power_supply *bms_psy; struct power_supply_desc usb_psy_desc; struct power_supply *usb_main_psy; struct power_supply *usb_port_psy; enum power_supply_type real_charger_type; /* notifiers */ struct notifier_block nb; Loading Loading @@ -316,6 +318,7 @@ struct smb_charger { bool typec_present; u8 typec_status[5]; bool typec_legacy_valid; int fake_input_current_limited; /* workaround flag */ u32 wa_flags; Loading Loading @@ -419,6 +422,8 @@ int smblib_set_prop_batt_capacity(struct smb_charger *chg, const union power_supply_propval *val); int smblib_set_prop_system_temp_level(struct smb_charger *chg, const union power_supply_propval *val); int smblib_set_prop_input_current_limited(struct smb_charger *chg, const union power_supply_propval *val); int smblib_get_prop_dc_present(struct smb_charger *chg, union power_supply_propval *val); Loading
drivers/power/supply/qcom/smb138x-charger.c +27 −49 Original line number Diff line number Diff line Loading @@ -598,26 +598,6 @@ static enum power_supply_property smb1355_parallel_props[] = { POWER_SUPPLY_PROP_CHARGER_TEMP_MAX, }; static int smb138x_get_parallel_charging(struct smb138x *chip, int *disabled) { struct smb_charger *chg = &chip->chg; int rc = 0; u8 cfg2; rc = smblib_read(chg, CHGR_CFG2_REG, &cfg2); if (rc < 0) { pr_err("Couldn't read en_cmg_reg rc=%d\n", rc); return rc; } if (cfg2 & CHG_EN_SRC_BIT) *disabled = 0; else *disabled = 1; return 0; } static int smb138x_parallel_get_prop(struct power_supply *psy, enum power_supply_property prop, union power_supply_propval *val) Loading @@ -644,7 +624,7 @@ static int smb138x_parallel_get_prop(struct power_supply *psy, val->intval = !(temp & DISABLE_CHARGING_BIT); break; case POWER_SUPPLY_PROP_INPUT_SUSPEND: rc = smb138x_get_parallel_charging(chip, &val->intval); rc = smblib_get_usb_suspend(chg, &val->intval); break; case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMITED: if ((chip->dt.pl_mode == POWER_SUPPLY_PL_USBIN_USBIN) Loading Loading @@ -714,33 +694,28 @@ static int smb138x_parallel_get_prop(struct power_supply *psy, return rc; } static int smb138x_set_parallel_charging(struct smb138x *chip, bool disable) static int smb138x_set_parallel_suspend(struct smb138x *chip, bool suspend) { struct smb_charger *chg = &chip->chg; int rc = 0; rc = smblib_masked_write(chg, WD_CFG_REG, WDOG_TIMER_EN_BIT, disable ? 0 : WDOG_TIMER_EN_BIT); suspend ? 0 : WDOG_TIMER_EN_BIT); if (rc < 0) { pr_err("Couldn't %s watchdog rc=%d\n", disable ? "disable" : "enable", rc); disable = true; suspend ? "disable" : "enable", rc); suspend = true; } /* * Configure charge enable for high polarity and * When disabling charging set it to cmd register control(cmd bit=0) * When enabling charging set it to pin control */ rc = smblib_masked_write(chg, CHGR_CFG2_REG, CHG_EN_POLARITY_BIT | CHG_EN_SRC_BIT, disable ? 0 : CHG_EN_SRC_BIT); rc = smblib_masked_write(chg, USBIN_CMD_IL_REG, USBIN_SUSPEND_BIT, suspend ? USBIN_SUSPEND_BIT : 0); if (rc < 0) { pr_err("Couldn't configure charge enable source rc=%d\n", rc); pr_err("Couldn't %s parallel charger rc=%d\n", suspend ? "suspend" : "resume", rc); return rc; } return 0; return rc; } static int smb138x_parallel_set_prop(struct power_supply *psy, Loading @@ -753,7 +728,7 @@ static int smb138x_parallel_set_prop(struct power_supply *psy, switch (prop) { case POWER_SUPPLY_PROP_INPUT_SUSPEND: rc = smb138x_set_parallel_charging(chip, (bool)val->intval); rc = smb138x_set_parallel_suspend(chip, (bool)val->intval); break; case POWER_SUPPLY_PROP_CURRENT_MAX: if ((chip->dt.pl_mode == POWER_SUPPLY_PL_USBIN_USBIN) Loading Loading @@ -971,32 +946,35 @@ static int smb138x_init_slave_hw(struct smb138x *chip) return rc; } /* disable the charging path when under s/w control */ rc = smblib_masked_write(chg, CHARGING_ENABLE_CMD_REG, CHARGING_ENABLE_CMD_BIT, 0); /* suspend parallel charging */ rc = smb138x_set_parallel_suspend(chip, true); if (rc < 0) { pr_err("Couldn't disable charging rc=%d\n", rc); pr_err("Couldn't suspend parallel charging rc=%d\n", rc); return rc; } /* disable parallel charging path */ rc = smb138x_set_parallel_charging(chip, true); /* initialize FCC to 0 */ rc = smblib_set_charge_param(chg, &chg->param.fcc, 0); if (rc < 0) { pr_err("Couldn't disable parallel path rc=%d\n", rc); pr_err("Couldn't set 0 FCC rc=%d\n", rc); return rc; } /* unsuspend parallel charging */ rc = smblib_masked_write(chg, USBIN_CMD_IL_REG, USBIN_SUSPEND_BIT, 0); /* enable the charging path */ rc = smblib_masked_write(chg, CHARGING_ENABLE_CMD_REG, CHARGING_ENABLE_CMD_BIT, CHARGING_ENABLE_CMD_BIT); if (rc < 0) { pr_err("Couldn't unsuspend parallel charging rc=%d\n", rc); pr_err("Couldn't enable charging rc=%d\n", rc); return rc; } /* initialize FCC to 0 */ rc = smblib_set_charge_param(chg, &chg->param.fcc, 0); /* configure charge enable for software control; active high */ rc = smblib_masked_write(chg, CHGR_CFG2_REG, CHG_EN_POLARITY_BIT | CHG_EN_SRC_BIT, 0); if (rc < 0) { pr_err("Couldn't set 0 FCC rc=%d\n", rc); pr_err("Couldn't configure charge enable source rc=%d\n", rc); return rc; } Loading
drivers/usb/dwc3/dwc3-msm.c +2 −1 Original line number Diff line number Diff line Loading @@ -3597,7 +3597,8 @@ static int dwc3_msm_gadget_vbus_draw(struct dwc3_msm *mdwc, unsigned mA) } } power_supply_get_property(mdwc->usb_psy, POWER_SUPPLY_PROP_TYPE, &pval); power_supply_get_property(mdwc->usb_psy, POWER_SUPPLY_PROP_REAL_TYPE, &pval); if (pval.intval != POWER_SUPPLY_TYPE_USB) return 0; Loading