Loading Documentation/devicetree/bindings/power/smb135x-charger.txt +1 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ Optional Properties: - therm-bias-supply The supply that provides bias voltage to the battery thermistor. This is useful in designs that do not use the SYSON pin to bias the thermistor. - usb-pullup-supply The supply regulator that act as pull-up for USB data lines. - qcom,parallel-charger: A flag to indicate if the charger merely assists for USB charging. In this case the input current from USB is split between a main charger and smb135x for reducing thermal impact Loading drivers/power/smb135x-charger.c +54 −18 Original line number Diff line number Diff line Loading @@ -377,6 +377,7 @@ struct smb135x_chg { bool soft_vfloat_comp_disabled; struct mutex irq_complete; struct regulator *therm_bias_vreg; struct regulator *usb_pullup_vreg; struct delayed_work wireless_insertion_work; unsigned int thermal_levels; Loading Loading @@ -3304,11 +3305,26 @@ static int smb135x_hw_init(struct smb135x_chg *chip) } } /* * Enable USB data line pullup regulator this is needed for the D+ * line to be at proper voltage for HVDCP charger detection. */ if (chip->usb_pullup_vreg) { rc = regulator_enable(chip->usb_pullup_vreg); if (rc) { pr_err("Unable to enable data line pull-up regulator rc=%d\n", rc); if (chip->therm_bias_vreg) regulator_disable(chip->therm_bias_vreg); return rc; } } rc = smb135x_enable_volatile_writes(chip); if (rc < 0) { dev_err(chip->dev, "Couldn't configure for volatile rc = %d\n", rc); return rc; goto free_regulator; } /* Loading @@ -3326,7 +3342,7 @@ static int smb135x_hw_init(struct smb135x_chg *chip) rc = smb135x_masked_write(chip, CMD_INPUT_LIMIT, mask, reg); if (rc < 0) { dev_err(chip->dev, "Couldn't set input limit cmd rc=%d\n", rc); return rc; goto free_regulator; } /* set bit 0 = 100mA bit 1 = 500mA and set register control */ Loading @@ -3335,7 +3351,7 @@ static int smb135x_hw_init(struct smb135x_chg *chip) POLARITY_100_500_BIT); if (rc < 0) { dev_err(chip->dev, "Couldn't set usbin cfg rc=%d\n", rc); return rc; goto free_regulator; } /* Loading @@ -3354,7 +3370,7 @@ static int smb135x_hw_init(struct smb135x_chg *chip) | EN_CHG_INHIBIT_BIT, reg); if (rc < 0) { dev_err(chip->dev, "Couldn't set cfg 14 rc=%d\n", rc); return rc; goto free_regulator; } /* control USB suspend via command bits */ Loading @@ -3367,7 +3383,7 @@ static int smb135x_hw_init(struct smb135x_chg *chip) if (rc < 0) { dev_err(chip->dev, "Couldn't set float voltage rc = %d\n", rc); return rc; goto free_regulator; } } Loading @@ -3375,7 +3391,8 @@ static int smb135x_hw_init(struct smb135x_chg *chip) if (chip->iterm_ma != -EINVAL) { if (chip->iterm_disabled) { dev_err(chip->dev, "Error: Both iterm_disabled and iterm_ma set\n"); return -EINVAL; rc = -EINVAL; goto free_regulator; } else { if (chip->iterm_ma <= 50) reg = CHG_ITERM_50MA; Loading @@ -3399,7 +3416,7 @@ static int smb135x_hw_init(struct smb135x_chg *chip) if (rc) { dev_err(chip->dev, "Couldn't set iterm rc = %d\n", rc); return rc; goto free_regulator; } rc = smb135x_masked_write(chip, CFG_14_REG, Loading @@ -3407,7 +3424,7 @@ static int smb135x_hw_init(struct smb135x_chg *chip) if (rc) { dev_err(chip->dev, "Couldn't enable iterm rc = %d\n", rc); return rc; goto free_regulator; } } } else if (chip->iterm_disabled) { Loading @@ -3417,7 +3434,7 @@ static int smb135x_hw_init(struct smb135x_chg *chip) if (rc) { dev_err(chip->dev, "Couldn't set iterm rc = %d\n", rc); return rc; goto free_regulator; } } Loading @@ -3431,7 +3448,7 @@ static int smb135x_hw_init(struct smb135x_chg *chip) dev_err(chip->dev, "Couldn't disable safety timer rc = %d\n", rc); return rc; goto free_regulator; } } else { for (i = 0; i < ARRAY_SIZE(chg_time); i++) { Loading @@ -3447,7 +3464,7 @@ static int smb135x_hw_init(struct smb135x_chg *chip) dev_err(chip->dev, "Couldn't set safety timer rc = %d\n", rc); return rc; goto free_regulator; } } } Loading @@ -3460,7 +3477,7 @@ static int smb135x_hw_init(struct smb135x_chg *chip) if (rc < 0) { dev_err(chip->dev, "Couldn't set batt_missing config = %d\n", rc); return rc; goto free_regulator; } /* set maximum fastchg current */ Loading @@ -3469,7 +3486,7 @@ static int smb135x_hw_init(struct smb135x_chg *chip) if (rc < 0) { dev_err(chip->dev, "Couldn't set fastchg current = %d\n", rc); return rc; goto free_regulator; } } Loading @@ -3484,7 +3501,7 @@ static int smb135x_hw_init(struct smb135x_chg *chip) if (rc < 0) { dev_err(chip->dev, "Couldn't set irq config rc = %d\n", rc); return rc; goto free_regulator; } /* enabling only interesting interrupts */ Loading @@ -3508,7 +3525,7 @@ static int smb135x_hw_init(struct smb135x_chg *chip) if (rc < 0) { dev_err(chip->dev, "Couldn't set irq enable rc = %d\n", rc); return rc; goto free_regulator; } } Loading @@ -3523,7 +3540,7 @@ static int smb135x_hw_init(struct smb135x_chg *chip) if (rc < 0) { dev_err(chip->dev, "Couldn't set dc charge current rc = %d\n", rc); return rc; goto free_regulator; } } Loading @@ -3542,7 +3559,7 @@ static int smb135x_hw_init(struct smb135x_chg *chip) if (rc < 0) { dev_err(chip->dev, "Couldn't disable soft vfloat rc = %d\n", rc); return rc; goto free_regulator; } } Loading @@ -3555,9 +3572,15 @@ static int smb135x_hw_init(struct smb135x_chg *chip) if (rc < 0) { dev_err(chip->dev, "Couldn't write to otg cfg reg rc = %d\n", rc); return rc; goto free_regulator; } return 0; free_regulator: if (chip->therm_bias_vreg) regulator_disable(chip->therm_bias_vreg); if (chip->usb_pullup_vreg) regulator_disable(chip->usb_pullup_vreg); return rc; } Loading Loading @@ -3702,6 +3725,14 @@ static int smb_parse_dt(struct smb135x_chg *chip) } } if (of_find_property(node, "usb-pullup-supply", NULL)) { /* get the data line pull-up regulator */ chip->usb_pullup_vreg = devm_regulator_get(chip->dev, "usb-pullup"); if (IS_ERR(chip->usb_pullup_vreg)) return PTR_ERR(chip->usb_pullup_vreg); } chip->pinctrl_state_name = of_get_property(node, "pinctrl-names", NULL); return 0; Loading Loading @@ -4066,6 +4097,11 @@ static int smb135x_charger_remove(struct i2c_client *client) pr_err("Couldn't disable therm-bias rc = %d\n", rc); } if (chip->usb_pullup_vreg) { rc = regulator_disable(chip->usb_pullup_vreg); if (rc) pr_err("Couldn't disable data-pullup rc = %d\n", rc); } if (chip->dc_psy_type != -EINVAL) power_supply_unregister(&chip->dc_psy); Loading Loading
Documentation/devicetree/bindings/power/smb135x-charger.txt +1 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ Optional Properties: - therm-bias-supply The supply that provides bias voltage to the battery thermistor. This is useful in designs that do not use the SYSON pin to bias the thermistor. - usb-pullup-supply The supply regulator that act as pull-up for USB data lines. - qcom,parallel-charger: A flag to indicate if the charger merely assists for USB charging. In this case the input current from USB is split between a main charger and smb135x for reducing thermal impact Loading
drivers/power/smb135x-charger.c +54 −18 Original line number Diff line number Diff line Loading @@ -377,6 +377,7 @@ struct smb135x_chg { bool soft_vfloat_comp_disabled; struct mutex irq_complete; struct regulator *therm_bias_vreg; struct regulator *usb_pullup_vreg; struct delayed_work wireless_insertion_work; unsigned int thermal_levels; Loading Loading @@ -3304,11 +3305,26 @@ static int smb135x_hw_init(struct smb135x_chg *chip) } } /* * Enable USB data line pullup regulator this is needed for the D+ * line to be at proper voltage for HVDCP charger detection. */ if (chip->usb_pullup_vreg) { rc = regulator_enable(chip->usb_pullup_vreg); if (rc) { pr_err("Unable to enable data line pull-up regulator rc=%d\n", rc); if (chip->therm_bias_vreg) regulator_disable(chip->therm_bias_vreg); return rc; } } rc = smb135x_enable_volatile_writes(chip); if (rc < 0) { dev_err(chip->dev, "Couldn't configure for volatile rc = %d\n", rc); return rc; goto free_regulator; } /* Loading @@ -3326,7 +3342,7 @@ static int smb135x_hw_init(struct smb135x_chg *chip) rc = smb135x_masked_write(chip, CMD_INPUT_LIMIT, mask, reg); if (rc < 0) { dev_err(chip->dev, "Couldn't set input limit cmd rc=%d\n", rc); return rc; goto free_regulator; } /* set bit 0 = 100mA bit 1 = 500mA and set register control */ Loading @@ -3335,7 +3351,7 @@ static int smb135x_hw_init(struct smb135x_chg *chip) POLARITY_100_500_BIT); if (rc < 0) { dev_err(chip->dev, "Couldn't set usbin cfg rc=%d\n", rc); return rc; goto free_regulator; } /* Loading @@ -3354,7 +3370,7 @@ static int smb135x_hw_init(struct smb135x_chg *chip) | EN_CHG_INHIBIT_BIT, reg); if (rc < 0) { dev_err(chip->dev, "Couldn't set cfg 14 rc=%d\n", rc); return rc; goto free_regulator; } /* control USB suspend via command bits */ Loading @@ -3367,7 +3383,7 @@ static int smb135x_hw_init(struct smb135x_chg *chip) if (rc < 0) { dev_err(chip->dev, "Couldn't set float voltage rc = %d\n", rc); return rc; goto free_regulator; } } Loading @@ -3375,7 +3391,8 @@ static int smb135x_hw_init(struct smb135x_chg *chip) if (chip->iterm_ma != -EINVAL) { if (chip->iterm_disabled) { dev_err(chip->dev, "Error: Both iterm_disabled and iterm_ma set\n"); return -EINVAL; rc = -EINVAL; goto free_regulator; } else { if (chip->iterm_ma <= 50) reg = CHG_ITERM_50MA; Loading @@ -3399,7 +3416,7 @@ static int smb135x_hw_init(struct smb135x_chg *chip) if (rc) { dev_err(chip->dev, "Couldn't set iterm rc = %d\n", rc); return rc; goto free_regulator; } rc = smb135x_masked_write(chip, CFG_14_REG, Loading @@ -3407,7 +3424,7 @@ static int smb135x_hw_init(struct smb135x_chg *chip) if (rc) { dev_err(chip->dev, "Couldn't enable iterm rc = %d\n", rc); return rc; goto free_regulator; } } } else if (chip->iterm_disabled) { Loading @@ -3417,7 +3434,7 @@ static int smb135x_hw_init(struct smb135x_chg *chip) if (rc) { dev_err(chip->dev, "Couldn't set iterm rc = %d\n", rc); return rc; goto free_regulator; } } Loading @@ -3431,7 +3448,7 @@ static int smb135x_hw_init(struct smb135x_chg *chip) dev_err(chip->dev, "Couldn't disable safety timer rc = %d\n", rc); return rc; goto free_regulator; } } else { for (i = 0; i < ARRAY_SIZE(chg_time); i++) { Loading @@ -3447,7 +3464,7 @@ static int smb135x_hw_init(struct smb135x_chg *chip) dev_err(chip->dev, "Couldn't set safety timer rc = %d\n", rc); return rc; goto free_regulator; } } } Loading @@ -3460,7 +3477,7 @@ static int smb135x_hw_init(struct smb135x_chg *chip) if (rc < 0) { dev_err(chip->dev, "Couldn't set batt_missing config = %d\n", rc); return rc; goto free_regulator; } /* set maximum fastchg current */ Loading @@ -3469,7 +3486,7 @@ static int smb135x_hw_init(struct smb135x_chg *chip) if (rc < 0) { dev_err(chip->dev, "Couldn't set fastchg current = %d\n", rc); return rc; goto free_regulator; } } Loading @@ -3484,7 +3501,7 @@ static int smb135x_hw_init(struct smb135x_chg *chip) if (rc < 0) { dev_err(chip->dev, "Couldn't set irq config rc = %d\n", rc); return rc; goto free_regulator; } /* enabling only interesting interrupts */ Loading @@ -3508,7 +3525,7 @@ static int smb135x_hw_init(struct smb135x_chg *chip) if (rc < 0) { dev_err(chip->dev, "Couldn't set irq enable rc = %d\n", rc); return rc; goto free_regulator; } } Loading @@ -3523,7 +3540,7 @@ static int smb135x_hw_init(struct smb135x_chg *chip) if (rc < 0) { dev_err(chip->dev, "Couldn't set dc charge current rc = %d\n", rc); return rc; goto free_regulator; } } Loading @@ -3542,7 +3559,7 @@ static int smb135x_hw_init(struct smb135x_chg *chip) if (rc < 0) { dev_err(chip->dev, "Couldn't disable soft vfloat rc = %d\n", rc); return rc; goto free_regulator; } } Loading @@ -3555,9 +3572,15 @@ static int smb135x_hw_init(struct smb135x_chg *chip) if (rc < 0) { dev_err(chip->dev, "Couldn't write to otg cfg reg rc = %d\n", rc); return rc; goto free_regulator; } return 0; free_regulator: if (chip->therm_bias_vreg) regulator_disable(chip->therm_bias_vreg); if (chip->usb_pullup_vreg) regulator_disable(chip->usb_pullup_vreg); return rc; } Loading Loading @@ -3702,6 +3725,14 @@ static int smb_parse_dt(struct smb135x_chg *chip) } } if (of_find_property(node, "usb-pullup-supply", NULL)) { /* get the data line pull-up regulator */ chip->usb_pullup_vreg = devm_regulator_get(chip->dev, "usb-pullup"); if (IS_ERR(chip->usb_pullup_vreg)) return PTR_ERR(chip->usb_pullup_vreg); } chip->pinctrl_state_name = of_get_property(node, "pinctrl-names", NULL); return 0; Loading Loading @@ -4066,6 +4097,11 @@ static int smb135x_charger_remove(struct i2c_client *client) pr_err("Couldn't disable therm-bias rc = %d\n", rc); } if (chip->usb_pullup_vreg) { rc = regulator_disable(chip->usb_pullup_vreg); if (rc) pr_err("Couldn't disable data-pullup rc = %d\n", rc); } if (chip->dc_psy_type != -EINVAL) power_supply_unregister(&chip->dc_psy); Loading