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

Commit bdc62b47 authored by Ke Liu's avatar Ke Liu
Browse files

power: smb135x-charger: add support to always disable charging



Currently, SMB will disable charging if qcom,charging-disabled is present.
However, user could still enable charging through sysfs which might result
in crash if battery is not present on that device.

Hence update the driver so that always disable charging if
qcom,charging-disabled is present.

Change-Id: I827601cbdec31bc05408a3e1a3909358149a58a4
CRs-fixed: 661326
Signed-off-by: default avatarKe Liu <keliu@codeaurora.org>
parent 117b6273
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -299,6 +299,7 @@ struct smb135x_chg {
	int				version;

	bool				chg_enabled;
	bool				chg_disabled_permanently;

	bool				usb_present;
	bool				dc_present;
@@ -1135,6 +1136,12 @@ static int __smb135x_charging(struct smb135x_chg *chip, int enable)

	pr_debug("charging enable = %d\n", enable);

	if (chip->chg_disabled_permanently) {
		pr_debug("charging is disabled permanetly\n");
		return -EINVAL;
	}


	rc = smb135x_masked_write(chip, CMD_CHG_REG,
			CMD_CHG_EN, enable ? CMD_CHG_EN : 0);
	if (rc < 0) {
@@ -3046,8 +3053,9 @@ static int smb_parse_dt(struct smb135x_chg *chip)
	chip->iterm_disabled = of_property_read_bool(node,
						"qcom,iterm-disabled");

	chip->chg_enabled = !(of_property_read_bool(node,
	chip->chg_disabled_permanently = (of_property_read_bool(node,
						"qcom,charging-disabled"));
	chip->chg_enabled = !chip->chg_disabled_permanently;

	rc = of_property_read_string(node, "qcom,bms-psy-name",
						&chip->bms_psy_name);