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

Commit f90ab0eb authored by Anirudh Ghayal's avatar Anirudh Ghayal
Browse files

power: smb358-charger: Query VADC only if the channel is supported



On different SMB358 + PMIC designs the VBAT/BATT_THERM may/may-not
be routed to the PMIC. Enable access to these ADC channels only if
they are enabled.

Change-Id: I4c21ed0f760cc9e8f685b8e5695c3ba354a00209
Signed-off-by: default avatarAnirudh Ghayal <aghayal@codeaurora.org>
parent 9c186765
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -73,6 +73,8 @@ Optional Properties:
				specified in micro-volts.
- qcom,batt-id-rpullup-kohm	The pull-up resistor connected on the battery-ID
				(vref) line.
- qcom,using-vbat-sns		Bool property to indicate that VBAT sense can be
				done by PMIC.

Example:
	i2c@f9967000 {
+7 −2
Original line number Diff line number Diff line
@@ -208,6 +208,7 @@ struct smb358_charger {
	bool			chg_autonomous_mode;
	bool			disable_apsd;
	bool			using_pmic_therm;
	bool			pmic_vbat_sns;
	bool			battery_missing;
	const char		*bms_psy_name;
	bool			resume_completed;
@@ -1007,7 +1008,9 @@ static int smb358_get_prop_batt_temp(struct smb358_charger *chip)
	int rc = 0;
	struct qpnp_vadc_result results;

	if (!smb358_get_prop_batt_present(chip) || !chip->vadc_dev)
	if (!smb358_get_prop_batt_present(chip)
			|| !chip->vadc_dev
			|| !chip->using_pmic_therm)
		return DEFAULT_TEMP;

	rc = qpnp_vadc_read(chip->vadc_dev, LR_MUX1_BATT_THERM, &results);
@@ -1027,7 +1030,7 @@ smb358_get_prop_battery_voltage_now(struct smb358_charger *chip)
	int rc = 0;
	struct qpnp_vadc_result results;

	if (!chip->vadc_dev)
	if (!chip->vadc_dev || !chip->pmic_vbat_sns)
		return 0;

	rc = qpnp_vadc_read(chip->vadc_dev, VBAT_SNS, &results);
@@ -2191,6 +2194,8 @@ static int smb_parse_dt(struct smb358_charger *chip)

	chip->using_pmic_therm = of_property_read_bool(node,
						"qcom,using-pmic-therm");
	chip->pmic_vbat_sns = of_property_read_bool(node,
					"qcom,using-vbat-sns");
	chip->bms_controlled_charging = of_property_read_bool(node,
						"qcom,bms-controlled-charging");