Loading Documentation/devicetree/bindings/power/qpnp-smbcharger.txt +3 −0 Original line number Diff line number Diff line Loading @@ -294,6 +294,9 @@ Optional Properties: a required property. - qcom,otg-pinctrl: A boolean property to be used when OTG enable control is configured in pin control mode. - qcom,override-usb-current A boolean property to override the ICL limit for USB charger(SDP) based on the current reported by USB driver. Example: qcom,qpnp-smbcharger { Loading drivers/power/qpnp-smbcharger.c +47 −8 Original line number Diff line number Diff line Loading @@ -143,6 +143,7 @@ struct smbchg_chip { bool skip_usb_suspend_for_fake_battery; bool hvdcp_not_supported; bool otg_pinctrl; bool cfg_override_usb_current; u8 original_usbin_allowance; struct parallel_usb_cfg parallel; struct delayed_work parallel_en_work; Loading Loading @@ -1670,6 +1671,35 @@ static int smbchg_set_usb_current_max(struct smbchg_chip *chip, (chip->wa_flags & SMBCHG_USB100_WA)) current_ma = CURRENT_150_MA; /* handle special SDP case when USB reports high current */ if (current_ma > CURRENT_900_MA) { if (chip->cfg_override_usb_current) { /* * allow setting the current value as reported * by USB driver. */ rc = smbchg_set_high_usb_chg_current(chip, current_ma); if (rc < 0) { pr_err("Couldn't set %dmA rc = %d\n", current_ma, rc); goto out; } rc = smbchg_masked_write(chip, chip->usb_chgpth_base + CMD_IL, ICL_OVERRIDE_BIT, ICL_OVERRIDE_BIT); if (rc < 0) pr_err("Couldn't set ICL override rc = %d\n", rc); } else { /* default to 500mA */ current_ma = CURRENT_500_MA; } pr_smb(PR_STATUS, "override_usb_current=%d current_ma set to %d\n", chip->cfg_override_usb_current, current_ma); } if (current_ma < CURRENT_150_MA) { /* force 100mA */ rc = smbchg_sec_masked_write(chip, Loading Loading @@ -1899,6 +1929,16 @@ static bool smbchg_is_usbin_active_pwr_src(struct smbchg_chip *chip) && (reg & USBIN_ACTIVE_PWR_SRC_BIT); } static void smbchg_detect_parallel_charger(struct smbchg_chip *chip) { struct power_supply *parallel_psy = get_parallel_psy(chip); if (parallel_psy) chip->parallel_charger_detected = power_supply_set_present(parallel_psy, true) ? false : true; } static int smbchg_parallel_usb_charging_en(struct smbchg_chip *chip, bool en) { struct power_supply *parallel_psy = get_parallel_psy(chip); Loading Loading @@ -2020,7 +2060,8 @@ static void smbchg_parallel_usb_taper(struct smbchg_chip *chip) int parallel_fcc_ma, tries = 0; u8 reg = 0; if (!parallel_psy || !chip->parallel_charger_detected) smbchg_detect_parallel_charger(chip); if (!chip->parallel_charger_detected) return; smbchg_stay_awake(chip, PM_PARALLEL_TAPER); Loading Loading @@ -4644,7 +4685,6 @@ static bool is_usbin_uv_high(struct smbchg_chip *chip) #define HVDCP_NOTIFY_MS 2500 static void handle_usb_insertion(struct smbchg_chip *chip) { struct power_supply *parallel_psy = get_parallel_psy(chip); enum power_supply_type usb_supply_type; int rc; char *usb_type_name = "null"; Loading Loading @@ -4694,12 +4734,7 @@ static void handle_usb_insertion(struct smbchg_chip *chip) msecs_to_jiffies(HVDCP_NOTIFY_MS)); } if (parallel_psy) { rc = power_supply_set_present(parallel_psy, true); chip->parallel_charger_detected = rc ? false : true; if (rc) pr_debug("parallel-charger absent rc=%d\n", rc); } smbchg_detect_parallel_charger(chip); if (chip->parallel.avail && chip->aicl_done_irq && !chip->enable_aicl_wake) { Loading Loading @@ -6044,6 +6079,7 @@ static irqreturn_t fastchg_handler(int irq, void *_chip) struct smbchg_chip *chip = _chip; pr_smb(PR_INTERRUPT, "p2f triggered\n"); smbchg_detect_parallel_charger(chip); smbchg_parallel_usb_check_ok(chip); if (chip->psy_registered) power_supply_changed(&chip->batt_psy); Loading Loading @@ -7365,6 +7401,9 @@ static int smb_parse_dt(struct smbchg_chip *chip) chip->otg_pinctrl = of_property_read_bool(node, "qcom,otg-pinctrl"); chip->cfg_override_usb_current = of_property_read_bool(node, "qcom,override-usb-current"); return 0; } Loading Loading
Documentation/devicetree/bindings/power/qpnp-smbcharger.txt +3 −0 Original line number Diff line number Diff line Loading @@ -294,6 +294,9 @@ Optional Properties: a required property. - qcom,otg-pinctrl: A boolean property to be used when OTG enable control is configured in pin control mode. - qcom,override-usb-current A boolean property to override the ICL limit for USB charger(SDP) based on the current reported by USB driver. Example: qcom,qpnp-smbcharger { Loading
drivers/power/qpnp-smbcharger.c +47 −8 Original line number Diff line number Diff line Loading @@ -143,6 +143,7 @@ struct smbchg_chip { bool skip_usb_suspend_for_fake_battery; bool hvdcp_not_supported; bool otg_pinctrl; bool cfg_override_usb_current; u8 original_usbin_allowance; struct parallel_usb_cfg parallel; struct delayed_work parallel_en_work; Loading Loading @@ -1670,6 +1671,35 @@ static int smbchg_set_usb_current_max(struct smbchg_chip *chip, (chip->wa_flags & SMBCHG_USB100_WA)) current_ma = CURRENT_150_MA; /* handle special SDP case when USB reports high current */ if (current_ma > CURRENT_900_MA) { if (chip->cfg_override_usb_current) { /* * allow setting the current value as reported * by USB driver. */ rc = smbchg_set_high_usb_chg_current(chip, current_ma); if (rc < 0) { pr_err("Couldn't set %dmA rc = %d\n", current_ma, rc); goto out; } rc = smbchg_masked_write(chip, chip->usb_chgpth_base + CMD_IL, ICL_OVERRIDE_BIT, ICL_OVERRIDE_BIT); if (rc < 0) pr_err("Couldn't set ICL override rc = %d\n", rc); } else { /* default to 500mA */ current_ma = CURRENT_500_MA; } pr_smb(PR_STATUS, "override_usb_current=%d current_ma set to %d\n", chip->cfg_override_usb_current, current_ma); } if (current_ma < CURRENT_150_MA) { /* force 100mA */ rc = smbchg_sec_masked_write(chip, Loading Loading @@ -1899,6 +1929,16 @@ static bool smbchg_is_usbin_active_pwr_src(struct smbchg_chip *chip) && (reg & USBIN_ACTIVE_PWR_SRC_BIT); } static void smbchg_detect_parallel_charger(struct smbchg_chip *chip) { struct power_supply *parallel_psy = get_parallel_psy(chip); if (parallel_psy) chip->parallel_charger_detected = power_supply_set_present(parallel_psy, true) ? false : true; } static int smbchg_parallel_usb_charging_en(struct smbchg_chip *chip, bool en) { struct power_supply *parallel_psy = get_parallel_psy(chip); Loading Loading @@ -2020,7 +2060,8 @@ static void smbchg_parallel_usb_taper(struct smbchg_chip *chip) int parallel_fcc_ma, tries = 0; u8 reg = 0; if (!parallel_psy || !chip->parallel_charger_detected) smbchg_detect_parallel_charger(chip); if (!chip->parallel_charger_detected) return; smbchg_stay_awake(chip, PM_PARALLEL_TAPER); Loading Loading @@ -4644,7 +4685,6 @@ static bool is_usbin_uv_high(struct smbchg_chip *chip) #define HVDCP_NOTIFY_MS 2500 static void handle_usb_insertion(struct smbchg_chip *chip) { struct power_supply *parallel_psy = get_parallel_psy(chip); enum power_supply_type usb_supply_type; int rc; char *usb_type_name = "null"; Loading Loading @@ -4694,12 +4734,7 @@ static void handle_usb_insertion(struct smbchg_chip *chip) msecs_to_jiffies(HVDCP_NOTIFY_MS)); } if (parallel_psy) { rc = power_supply_set_present(parallel_psy, true); chip->parallel_charger_detected = rc ? false : true; if (rc) pr_debug("parallel-charger absent rc=%d\n", rc); } smbchg_detect_parallel_charger(chip); if (chip->parallel.avail && chip->aicl_done_irq && !chip->enable_aicl_wake) { Loading Loading @@ -6044,6 +6079,7 @@ static irqreturn_t fastchg_handler(int irq, void *_chip) struct smbchg_chip *chip = _chip; pr_smb(PR_INTERRUPT, "p2f triggered\n"); smbchg_detect_parallel_charger(chip); smbchg_parallel_usb_check_ok(chip); if (chip->psy_registered) power_supply_changed(&chip->batt_psy); Loading Loading @@ -7365,6 +7401,9 @@ static int smb_parse_dt(struct smbchg_chip *chip) chip->otg_pinctrl = of_property_read_bool(node, "qcom,otg-pinctrl"); chip->cfg_override_usb_current = of_property_read_bool(node, "qcom,override-usb-current"); return 0; } Loading