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

Commit 0edd2a10 authored by Fenglin Wu's avatar Fenglin Wu
Browse files

power: supply: qpnp-smb5: specify different ICL for QC2 9V/12V level



There is an existing device-tree property "qcom,hvdcp2-max-icl-ua" to
specify the ICL when QC2 charger adapter working at high voltage to
avoid VBUS voltage collapse. Normally QC2 adapters have different
current rating at different voltage level, hence keep the existing
property to specify the ICL setting at 9V level and add a new
property "qcom,hvdcp2-12v-max-icl-ua" to specify the ICL setting at
12V level.

Change-Id: I0811932de997b56a1d8d95bd5cbf22a194ffe035
Signed-off-by: default avatarFenglin Wu <fenglinw@codeaurora.org>
parent 9a96de3c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ struct charger_param {
	u32 fcc_step_size_ua;
	u32 smb_version;
	u32 hvdcp2_max_icl_ua;
	u32 hvdcp2_12v_max_icl_ua;
	u32 hvdcp3_max_icl_ua;
	u32 forced_main_fcc;
	u32 qc4_max_icl_ua;
+6 −0
Original line number Diff line number Diff line
@@ -610,6 +610,12 @@ static int smb5_parse_dt_misc(struct smb5 *chip, struct device_node *node)
	if (chg->chg_param.hvdcp2_max_icl_ua <= 0)
		chg->chg_param.hvdcp2_max_icl_ua = MICRO_3PA;

	of_property_read_u32(node, "qcom,hvdcp2-12v-max-icl-ua",
					&chg->chg_param.hvdcp2_12v_max_icl_ua);
	if (chg->chg_param.hvdcp2_12v_max_icl_ua <= 0)
		chg->chg_param.hvdcp2_12v_max_icl_ua =
			chg->chg_param.hvdcp2_max_icl_ua;

	/* Used only in Adapter CV mode of operation */
	of_property_read_u32(node, "qcom,qc4-max-icl-ua",
					&chg->chg_param.qc4_max_icl_ua);
+8 −1
Original line number Diff line number Diff line
@@ -1218,6 +1218,7 @@ static void smblib_uusb_removal(struct smb_charger *chg)
			is_flash_active(chg) ? SDP_CURRENT_UA : SDP_100_MA);
	vote(chg->usb_icl_votable, SW_QC3_VOTER, false, 0);
	vote(chg->usb_icl_votable, HVDCP2_ICL_VOTER, false, 0);
	vote(chg->usb_icl_votable, HVDCP2_12V_ICL_VOTER, false, 0);
	vote(chg->usb_icl_votable, CHG_TERMINATION_VOTER, false, 0);
	vote(chg->usb_icl_votable, THERMAL_THROTTLE_VOTER, false, 0);
	vote(chg->limited_irq_disable_votable, CHARGER_TYPE_VOTER,
@@ -2666,6 +2667,8 @@ int smblib_dp_dm(struct smb_charger *chg, int val)
		rc = smblib_force_vbus_voltage(chg, FORCE_5V_BIT);
		if (rc < 0)
			pr_err("Failed to force 5V\n");

		vote(chg->usb_icl_votable, HVDCP2_12V_ICL_VOTER, false, 0);
		break;
	case POWER_SUPPLY_DP_DM_FORCE_9V:
		if (chg->qc2_unsupported_voltage == QC2_NON_COMPLIANT_9V) {
@@ -2691,6 +2694,8 @@ int smblib_dp_dm(struct smb_charger *chg, int val)
		rc = smblib_force_vbus_voltage(chg, FORCE_9V_BIT);
		if (rc < 0)
			pr_err("Failed to force 9V\n");

		vote(chg->usb_icl_votable, HVDCP2_12V_ICL_VOTER, false, 0);
		break;
	case POWER_SUPPLY_DP_DM_FORCE_12V:
		if (chg->qc2_unsupported_voltage == QC2_NON_COMPLIANT_12V) {
@@ -2707,6 +2712,8 @@ int smblib_dp_dm(struct smb_charger *chg, int val)
		}

		if ((stat & QC_9V_BIT) || (stat & QC_5V_BIT)) {
			vote(chg->usb_icl_votable, HVDCP2_12V_ICL_VOTER, true,
					chg->chg_param.hvdcp2_12v_max_icl_ua);
			/* Force 1A ICL before requesting higher voltage */
			vote(chg->usb_icl_votable, HVDCP2_ICL_VOTER,
					true, 1000000);
@@ -5704,7 +5711,6 @@ static void smblib_handle_hvdcp_check_timeout(struct smb_charger *chg,
	u32 hvdcp_ua = 0;

	if (rising) {

		if (qc_charger) {
			hvdcp_ua = (chg->real_charger_type ==
					POWER_SUPPLY_TYPE_USB_HVDCP) ?
@@ -6249,6 +6255,7 @@ static void typec_src_removal(struct smb_charger *chg)
	vote(chg->usb_icl_votable, SW_QC3_VOTER, false, 0);
	vote(chg->usb_icl_votable, CTM_VOTER, false, 0);
	vote(chg->usb_icl_votable, HVDCP2_ICL_VOTER, false, 0);
	vote(chg->usb_icl_votable, HVDCP2_12V_ICL_VOTER, false, 0);
	vote(chg->usb_icl_votable, CHG_TERMINATION_VOTER, false, 0);
	vote(chg->usb_icl_votable, THERMAL_THROTTLE_VOTER, false, 0);
	vote(chg->usb_icl_votable, LPD_VOTER, false, 0);
+1 −0
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ enum print_reason {
#define JEITA_ARB_VOTER			"JEITA_ARB_VOTER"
#define MOISTURE_VOTER			"MOISTURE_VOTER"
#define HVDCP2_ICL_VOTER		"HVDCP2_ICL_VOTER"
#define HVDCP2_12V_ICL_VOTER		"HVDCP2_12V_ICL_VOTER"
#define AICL_THRESHOLD_VOTER		"AICL_THRESHOLD_VOTER"
#define USBOV_DBC_VOTER			"USBOV_DBC_VOTER"
#define CHG_TERMINATION_VOTER		"CHG_TERMINATION_VOTER"