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

Commit 875c6be9 authored by Umang Chheda's avatar Umang Chheda
Browse files

power: smb5: Add property to limit QC2.0 input current



Some QC2.0 adapters collapse with 3A ICL, add a logic to
limit the ICL to 2A.
Use DT property "qcom,hvdcp2-max-icl-ua" to limit the value.

Change-Id: Ia03c971f388470e5b5770d6e7271e3298c84db57
Signed-off-by: default avatarUmang Chheda <uchheda@codeaurora.org>
parent fd8f045d
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (c) 2017, 2019 The Linux Foundation. All rights reserved.
 * Copyright (c) 2017, 2019-2020 The Linux Foundation. All rights reserved.
 */

#ifndef __BATTERY_H
@@ -10,6 +10,7 @@ struct charger_param {
	u32 fcc_step_delay_ms;
	u32 fcc_step_size_ua;
	u32 smb_version;
	u32 hvdcp2_max_icl_ua;
	u32 hvdcp3_max_icl_ua;
	u32 forced_main_fcc;
};
+6 −1
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
 * Copyright (c) 2018-2020 The Linux Foundation. All rights reserved.
 */

#include <linux/debugfs.h>
@@ -599,6 +599,11 @@ static int smb5_parse_dt_misc(struct smb5 *chip, struct device_node *node)
	if (chg->chg_param.hvdcp3_max_icl_ua <= 0)
		chg->chg_param.hvdcp3_max_icl_ua = MICRO_3PA;

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

	return 0;
}

+8 −1
Original line number Diff line number Diff line
@@ -5511,16 +5511,23 @@ static void smblib_handle_hvdcp_3p0_auth_done(struct smb_charger *chg,
static void smblib_handle_hvdcp_check_timeout(struct smb_charger *chg,
					      bool rising, bool qc_charger)
{
	u32 hvdcp_ua = 0;

	if (rising) {

		if (qc_charger) {
			hvdcp_ua = (chg->real_charger_type ==
					POWER_SUPPLY_TYPE_USB_HVDCP) ?
					chg->chg_param.hvdcp2_max_icl_ua :
					HVDCP_CURRENT_UA;

			/* enable HDC and ICL irq for QC2/3 charger */
			vote(chg->limited_irq_disable_votable,
					CHARGER_TYPE_VOTER, false, 0);
			vote(chg->hdc_irq_disable_votable,
					CHARGER_TYPE_VOTER, false, 0);
			vote(chg->usb_icl_votable, SW_ICL_MAX_VOTER, true,
				HVDCP_CURRENT_UA);
					hvdcp_ua);
		} else {
			/* A plain DCP, enforce DCP ICL if specified */
			vote(chg->usb_icl_votable, DCP_VOTER,