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

Commit 67904eed authored by Anirudh Ghayal's avatar Anirudh Ghayal
Browse files

power: smb1360: Add a DT property to configure minimum ICL



On removal of USB charger the input current limit (ICL)
needs to be configured to a minimum value. Add a DT
property to allow this value to be configured to USB100
or USB500.

Configuring this value to USB500 does not adhere to the
USB charging spec. but guarantees that the minimum
charging current in all scenarios is 500mA. Setting
this value to USB100 follows the USB spec but can
drastically increase the charging time during pre-charge.

Use a default value of USB500.

CRs-Fixed: 713576
Change-Id: I094ac520437b24ecb4f5fc81c8b8898bb7ed9a65
Signed-off-by: default avatarAnirudh Ghayal <aghayal@codeaurora.org>
parent c5bc590f
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -103,6 +103,9 @@ Optional Properties:
				from battery when device working at OTG mode.
				The possible values are: 350, 550, 950, 1500mA.
- qcom,fg-auto-recharge-soc	This property defines the auto recharging SOC threshold.
- qcom,min-icl-100ma		A bool property to set the minimum ICL current
				to 100mA. If this property is not set the minimum
				ICL is set to 500mA in all the scenarios.

Example:
	i2c@f9967000 {
+28 −12
Original line number Diff line number Diff line
@@ -278,6 +278,7 @@ struct smb1360_chip {
	unsigned int			therm_lvl_sel;
	unsigned int			*thermal_mitigation;
	int				otg_batt_curr_limit;
	bool				min_icl_usb100;

	/* configuration data - fg */
	int				soc_max;
@@ -985,7 +986,8 @@ static int smb1360_set_minimum_usb_current(struct smb1360_chip *chip)
{
	int rc = 0;

	pr_debug("set USB current to minimum\n");
	if (chip->min_icl_usb100) {
		pr_debug("USB min current set to 100mA\n");
		/* set input current limit to minimum (300mA) */
		rc = smb1360_masked_write(chip, CFG_BATT_CHG_ICL_REG,
						INPUT_CURR_LIM_MASK,
@@ -993,11 +995,19 @@ static int smb1360_set_minimum_usb_current(struct smb1360_chip *chip)
		if (rc)
			pr_err("Couldn't set ICL mA rc=%d\n", rc);

	if (!(chip->workaround_flags & WRKRND_USB100_FAIL)) {
		if (!(chip->workaround_flags & WRKRND_USB100_FAIL))
			rc = smb1360_masked_write(chip, CMD_IL_REG,
					USB_CTRL_MASK, USB_100_BIT);
			if (rc)
			pr_err("Couldn't configure for USB100 rc=%d\n", rc);
				pr_err("Couldn't configure for USB100 rc=%d\n",
								rc);
	} else {
		pr_debug("USB min current set to 500mA\n");
		rc = smb1360_masked_write(chip, CMD_IL_REG,
				USB_CTRL_MASK, USB_500_BIT);
		if (rc)
			pr_err("Couldn't configure for USB100 rc=%d\n",
							rc);
	}

	return rc;
@@ -1063,8 +1073,11 @@ static int smb1360_set_appropriate_usb_current(struct smb1360_chip *chip)
	pr_debug("ICL set to = %d\n", input_current_limit[i]);

	if ((current_ma <= CURRENT_100_MA) &&
		(chip->workaround_flags & WRKRND_USB100_FAIL)) {
		pr_debug("usb100 not supported\n");
		((chip->workaround_flags & WRKRND_USB100_FAIL) ||
				!chip->min_icl_usb100)) {
		pr_debug("usb100 not supported: usb100_wrkrnd=%d min_icl_100=%d\n",
			!!(chip->workaround_flags & WRKRND_USB100_FAIL),
						chip->min_icl_usb100);
		current_ma = CURRENT_500_MA;
	}

@@ -3213,6 +3226,9 @@ static int smb_parse_dt(struct smb1360_chip *chip)
	chip->shdn_after_pwroff = of_property_read_bool(node,
						"qcom,shdn-after-pwroff");

	chip->min_icl_usb100 = of_property_read_bool(node,
						"qcom,min-icl-100ma");

	if (of_find_property(node, "qcom,thermal-mitigation",
					&chip->thermal_levels)) {
		chip->thermal_mitigation = devm_kzalloc(chip->dev,