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

Commit f6c4c69c authored by Abhijeet Dharmapurikar's avatar Abhijeet Dharmapurikar
Browse files

power: smb135x-charger: support external battery thermistor bias voltage



smb135x charger chips can accept an external supply for thermistor
biasing. Add code to enable that external regulator if present.

Change-Id: Ie6691cf3eca6c2dc85f438819f7436b44c9c2aca
Signed-off-by: default avatarAbhijeet Dharmapurikar <adharmap@codeaurora.org>
parent 1f4dd82d
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -46,6 +46,9 @@ Optional Properties:
					the float voltage compensation needs to be disabled to avoid
					that reverse boost.
- regulator-name			A string used as a descriptive name for OTG regulator.
- 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.

Example:
	i2c@f9967000 {
+25 −0
Original line number Diff line number Diff line
@@ -269,6 +269,7 @@ struct smb135x_chg {
	u32				workaround_flags;
	bool				soft_vfloat_comp_disabled;
	struct mutex			irq_complete;
	struct regulator		*therm_bias_vreg;
};

static int smb135x_read(struct smb135x_chg *chip, int reg,
@@ -1825,6 +1826,14 @@ static int smb135x_hw_init(struct smb135x_chg *chip)
	int i;
	u8 reg, mask, dc_cur_val;

	if (chip->therm_bias_vreg) {
		rc = regulator_enable(chip->therm_bias_vreg);
		if (rc) {
			pr_err("Couldn't enable therm-bias rc = %d\n", rc);
			return rc;
		}
	}

	rc = smb135x_enable_volatile_writes(chip);
	if (rc < 0) {
		dev_err(chip->dev, "Couldn't configure for volatile rc = %d\n",
@@ -2189,6 +2198,15 @@ static int smb_parse_dt(struct smb135x_chg *chip)

	chip->soft_vfloat_comp_disabled = of_property_read_bool(node,
					"qcom,soft-vfloat-comp-disabled");

	if (of_find_property(node, "therm-bias-supply", NULL)) {
		/* get the thermistor bias regulator */
		chip->therm_bias_vreg = devm_regulator_get(chip->dev,
							"therm-bias");
		if (IS_ERR(chip->therm_bias_vreg))
			return PTR_ERR(chip->therm_bias_vreg);
	}

	return 0;
}

@@ -2417,8 +2435,15 @@ free_regulator:

static int smb135x_charger_remove(struct i2c_client *client)
{
	int rc;
	struct smb135x_chg *chip = i2c_get_clientdata(client);

	if (chip->therm_bias_vreg) {
		rc = regulator_disable(chip->therm_bias_vreg);
		if (rc)
			pr_err("Couldn't disable therm-bias rc = %d\n", rc);
	}

	debugfs_remove_recursive(chip->debug_root);

	if (chip->dc_psy_type != -EINVAL)