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

Commit 5b273681 authored by Jie Cheng's avatar Jie Cheng Committed by Abhijeet Dharmapurikar
Browse files

power: smb1351-charger: add new property for forcing HVDCP 2.0



The SMB1351 will enable the HVDCP 3.0 by default. A new property
"force-hvdcp-2p0" allows to force the HVDCP working on the 2.0 mode.
The HVDCP 3.0 algorithm must be disabled if forcing on the 2.0 mode.

Change-Id: I4b0b24ff0d9969ca3bdf0887e07142d5c1f01b83
Signed-off-by: default avatarJie Cheng <rockiec@codeaurora.org>
parent 6d62498a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ Optional Properties:
				other via power_supply framework. This
				property should be used with 'qcom,iterm-disabled'
				to ensure EOC detection in charger is disabled.
- qcom,force-hvdcp-2p0		Boolean value which allows to force hvdcp working on 2.0 mode.
- qcom,parallel-charger		Boolean value which enables the parallel charger.
- qcom,chg-vadc			Corresponding VADC device's phandle.
- qcom,chg-adc_tm		phandle to the corresponding VADC device to read the ADC channels.
+17 −0
Original line number Diff line number Diff line
@@ -248,6 +248,7 @@

#define CMD_HVDCP_REG				0x34
#define CMD_APSD_RE_RUN_BIT			BIT(7)
#define CMD_FORCE_HVDCP_2P0_BIT			BIT(5)
#define CMD_HVDCP_MODE_MASK			SMB1351_MASK(5, 0)

/* Status registers */
@@ -447,6 +448,7 @@ struct smb1351_charger {
	bool			bms_controlled_charging;
	bool			apsd_rerun;
	bool			chg_remove_work_scheduled;
	bool			force_hvdcp_2p0;

	/* psy */
	struct power_supply	*usb_psy;
@@ -1855,6 +1857,19 @@ static int smb1351_apsd_complete_handler(struct smb1351_charger *chip,
			pr_debug("Setting usb psy allow detection 1 DCP and no rerun\n");
			power_supply_set_allow_detection(chip->usb_psy, 1);
		}
		/*
		 * If defined force hvdcp 2p0 property,
		 * we force to hvdcp 2p0 in the APSD handler.
		 */
		if (chip->force_hvdcp_2p0) {
			pr_debug("Force set to HVDCP 2.0 mode\n");
			smb1351_masked_write(chip, VARIOUS_FUNC_3_REG,
						QC_2P1_AUTH_ALGO_BIT, 0);
			smb1351_masked_write(chip, CMD_HVDCP_REG,
						CMD_FORCE_HVDCP_2P0_BIT,
						CMD_FORCE_HVDCP_2P0_BIT);
		}

		power_supply_set_supply_type(chip->usb_psy, type);
		/*
		 * SMB is now done sampling the D+/D- lines,
@@ -2512,6 +2527,8 @@ static int smb1351_parse_dt(struct smb1351_charger *chip)
						"qcom,using-pmic-therm");
	chip->bms_controlled_charging  = of_property_read_bool(node,
					"qcom,bms-controlled-charging");
	chip->force_hvdcp_2p0 = of_property_read_bool(node,
					"qcom,force-hvdcp-2p0");

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