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

Commit dcabac7f authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "power: smb135x-charger: Vote for USB data-line pull-up regulator"

parents dce2ab4e cd7f178f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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
+54 −18
Original line number Diff line number Diff line
@@ -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;
@@ -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;
	}

	/*
@@ -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 */
@@ -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;
	}

	/*
@@ -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 */
@@ -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;
		}
	}

@@ -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;
@@ -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,
@@ -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) {
@@ -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;
		}
	}

@@ -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++) {
@@ -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;
			}
		}
	}
@@ -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 */
@@ -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;
		}
	}

@@ -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 */
@@ -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;
		}
	}

@@ -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;
		}
	}

@@ -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;
		}
	}

@@ -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;
}

@@ -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;
@@ -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);