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

Commit 5fc7e1db authored by Kiran Gunda's avatar Kiran Gunda
Browse files

power: qpnp-fg-gen4: Fix encoding for Rconn



Bit encoding for ESR and Rconn are different. However, currently
the ESR encoding is used for encoding the Rconn value also.
Due to this the incorrect Rconn value is stored in the SRAM and
leads to a premature charge termination.Fix it by adding a
separate encoding rule for Rconn.

Change-Id: I902a8316595f11d8d4b10f25d3ace57a71840d14
Signed-off-by: default avatarKiran Gunda <kgunda@codeaurora.org>
parent 50fddb39
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
 * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved.
 */

#ifndef __FG_CORE_H__
@@ -175,6 +175,7 @@ enum fg_sram_param_id {
	FG_SRAM_VBAT_FINAL,
	FG_SRAM_IBAT_FINAL,
	FG_SRAM_IBAT_FLT,
	FG_SRAM_RCONN,
	FG_SRAM_ESR,
	FG_SRAM_ESR_MDL,
	FG_SRAM_ESR_ACT,
+5 −2
Original line number Diff line number Diff line
@@ -395,6 +395,8 @@ static struct fg_sram_param pm8150b_v1_sram_params[] = {
		0, NULL, fg_decode_voltage_15b),
	PARAM(IBAT_FINAL, IBAT_FINAL_WORD, IBAT_FINAL_OFFSET, 2, 1000, 488282,
		0, NULL, fg_decode_current_16b),
	PARAM(RCONN, RCONN_WORD, RCONN_OFFSET, 2, 1000, 122070, 0,
		fg_encode_default, fg_decode_value_16b),
	PARAM(ESR, ESR_WORD, ESR_OFFSET, 2, 1000, 244141, 0, fg_encode_default,
		fg_decode_value_16b),
	PARAM(ESR_MDL, ESR_MDL_WORD, ESR_MDL_OFFSET, 2, 1000, 244141, 0,
@@ -495,6 +497,8 @@ static struct fg_sram_param pm8150b_v2_sram_params[] = {
		0, NULL, fg_decode_current_16b),
	PARAM(IBAT_FLT, IBAT_FLT_WORD, IBAT_FLT_OFFSET, 4, 10000, 19073, 0,
		NULL, fg_decode_current_24b),
	PARAM(RCONN, RCONN_WORD, RCONN_OFFSET, 2, 1000, 122070, 0,
		fg_encode_default, fg_decode_value_16b),
	PARAM(ESR, ESR_WORD, ESR_OFFSET, 2, 1000, 244141, 0, fg_encode_default,
		fg_decode_value_16b),
	PARAM(ESR_MDL, ESR_MDL_WORD, ESR_MDL_OFFSET, 2, 1000, 244141, 0,
@@ -5454,8 +5458,7 @@ static int fg_gen4_hw_init(struct fg_gen4_chip *chip)
		}

		if (!buf[0] && !buf[1]) {
			/* Rconn has same encoding as ESR */
			fg_encode(fg->sp, FG_SRAM_ESR, chip->dt.rconn_uohms,
			fg_encode(fg->sp, FG_SRAM_RCONN, chip->dt.rconn_uohms,
				buf);
			rc = fg_sram_write(fg, RCONN_WORD, RCONN_OFFSET, buf, 2,
					FG_IMA_DEFAULT);