Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 079af6dc authored by Ashay Jaiswal's avatar Ashay Jaiswal
Browse files

power: qpnp-smbcharger: add support for high current SDP/floating charger



Add support to configure high ICL for SDP chargers, this is useful in case
of SDP or floating chargers which supports high current.
If 'qcom,override-usb-current' property is present override and set ICL
based on current reported by the USB driver otherwise set to USB500 mode.

CRs-Fixed: 963417
Change-Id: I31304cd2a4e710f4e450e6ec5a4da90c50fdfc88
Signed-off-by: default avatarAshay Jaiswal <ashayj@codeaurora.org>
parent 53681f7b
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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 {
+33 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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,
@@ -7365,6 +7395,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;
}