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

Commit 3bdb0991 authored by Rakesh Kota's avatar Rakesh Kota
Browse files

power: smb1398-charger: Fix wrong IIN value in register



There is possiblity of setting wrong IIN value, if user vote
for greater then IIN_MAX (5000mA <), so fix this by updating
the IIN_MAX as IIN value.

Change-Id: I50df73d71514967d0d383d612f1c9ddba58437ce
Signed-off-by: default avatarRakesh Kota <quic_kotarake@quicinc.com>
parent e9594b2d
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2020-2021 The Linux Foundation. All rights reserved.
 * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
 */

#define pr_fmt(fmt) "SMB1398: %s: " fmt, __func__
@@ -247,6 +248,7 @@
#define COMBO_PRE_REGULATOR		2
#define SMB1394_DIV2_CP_PRY		3
#define SMB1394_DIV2_CP_SECY		4
#define SMB1398_MAX_IIN			5000

#define IS_SMB1394(role) \
	(role == SMB1394_DIV2_CP_PRY || role == SMB1394_DIV2_CP_SECY)
@@ -440,6 +442,9 @@ static int smb1398_set_iin_ma(struct smb1398_chip *chip, int iin_ma)
	int rc = 0;
	u8 val;

	if (iin_ma > SMB1398_MAX_IIN)
		iin_ma = SMB1398_MAX_IIN;

	val = iin_ma / IIN_STEP_MA;
	rc = smb1398_masked_write(chip, IIN_SS_DAC_TARGET_REG,
			IIN_SS_DAC_VALUE_MASK, val);