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

Commit 928b17b2 authored by Abhijeet Dharmapurikar's avatar Abhijeet Dharmapurikar
Browse files

power: qpnp-fg: Increase precision of voltage and current



The driver currently uses 153 as LSB value. Instead use 152.587 for
accurate voltage and current readings.

Change-Id: I52feb423cccff32603e4fc441e2bf15e7d98e445
Signed-off-by: default avatarAbhijeet Dharmapurikar <adharmap@codeaurora.org>
parent 53ae2296
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -998,7 +998,8 @@ static int fg_is_batt_id_valid(struct fg_chip *chip)
	return (fg_batt_sts & BATT_IDED) ? 1 : 0;
}

#define LSB_16B		153
#define LSB_16B_NUMRTR		152587
#define LSB_16B_DENMTR		1000
#define LSB_8B		9800
#define TEMP_LSB_16B	625
#define DECIKELVIN	2730
@@ -1026,10 +1027,14 @@ static void update_sram_data(struct fg_chip *chip, int *resched_ms)
		switch (i) {
		case FG_DATA_OCV:
		case FG_DATA_VOLTAGE:
			fg_data[i].value = ((u16) temp) * LSB_16B;
			fg_data[i].value = div_u64(
					(u64)(u16)temp * LSB_16B_NUMRTR,
					LSB_16B_DENMTR);
			break;
		case FG_DATA_CURRENT:
			fg_data[i].value = temp * LSB_16B;
			fg_data[i].value = div_s64(
					(s64)temp * LSB_16B_NUMRTR,
					LSB_16B_DENMTR);
			break;
		case FG_DATA_BATT_ESR:
			fg_data[i].value = float_decode((u16) temp);