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

Commit 361a2704 authored by Anirudh Ghayal's avatar Anirudh Ghayal
Browse files

power: qpnp-qg: Add the SDAM flash-ocv offset



On PM2250 the PBS sequence expects the battery-OCV
to output the right flash-boost output voltage. Provide
the same in a SDAM offset.

Change-Id: I9d43375d96de5a199c6a87c55e5c1079549b23ee
Signed-off-by: default avatarAnirudh Ghayal <aghayal@codeaurora.org>
parent f88a5347
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -128,6 +128,7 @@
#define QG_SDAM_ESR_DISCHARGE_SF_OFFSET		0x74 /* 2-byte 0x74-0x75 */
#define QG_SDAM_BATT_AGE_LEVEL_OFFSET		0x76 /* 1-byte 0x76 */
#define QG_SDAM_MAGIC_OFFSET			0x80 /* 4-byte 0x80-0x83 */
#define QG_SDAM_FLASH_OCV_OFFSET		0x84 /* 1-byte 0x84 */
#define QG_SDAM_MAX_OFFSET			0xA4

/* Below offset is used by PBS */
+5 −0
Original line number Diff line number Diff line
@@ -91,6 +91,11 @@ static struct qg_sdam_info sdam_info[] = {
		.offset = QG_SDAM_MAGIC_OFFSET,
		.length = 4,
	},
	[SDAM_FLASH_OCV] = {
		.name	= "SDAM_FLASH_OCV_OFFSET",
		.offset = QG_SDAM_FLASH_OCV_OFFSET,
		.length = 1,
	},
};

int qg_sdam_write(u8 param, u32 data)
+1 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ enum qg_sdam_param {
	SDAM_ESR_DISCHARGE_SF,
	SDAM_MAGIC,
	SDAM_BATT_AGE_LEVEL,
	SDAM_FLASH_OCV,
	SDAM_MAX,
};

+7 −0
Original line number Diff line number Diff line
@@ -305,6 +305,7 @@ static int qg_store_soc_params(struct qpnp_qg *chip)
{
	int rc, batt_temp = 0, i;
	unsigned long rtc_sec = 0;
	u32 flash_ocv = 0;

	rc = get_rtc_time(&rtc_sec);
	if (rc < 0)
@@ -324,6 +325,12 @@ static int qg_store_soc_params(struct qpnp_qg *chip)
					i, chip->sdam_data[i]);
	}

	/* store the SDAM OCV */
	flash_ocv = chip->sdam_data[SDAM_OCV_UV] / 20000;
	rc = qg_sdam_write(SDAM_FLASH_OCV, flash_ocv);
	if (rc < 0)
		pr_err("Failed to update flash-ocv rc=%d\n", rc);

	return rc;
}