Skip to content

Commit 3a3acf8

Browse files
refractionwaresre
authored andcommitted
power: supply: max17042_battery: Fix SOC threshold calc w/ no current sense
Commit 223a3b8 ("power: supply: max17042_battery: use VFSOC for capacity when no rsns") made it so that capacity on systems without current sensing would be read from VFSOC instead of RepSOC. However, the SOC threshold calculation still read RepSOC to get the SOC regardless of the current sensing option state. Fix this by applying the same conditional to determine which register should be read. This also seems to be the intended behavior as per the datasheet - SOC alert config value in MiscCFG on setups without current sensing is set to a value of 0b11, indicating SOC alerts being generated based on VFSOC, instead of 0b00 which indicates SOC alerts being generated based on RepSOC. This fixes an issue on the Galaxy S3/Midas boards, where the alert interrupt would be constantly retriggered, causing high CPU usage on idle (around ~12%-15%). Fixes: e5f3872 ("max17042: Add support for signalling change in SOC") Signed-off-by: Artur Weber <[email protected]> Reviewed-by: Henrik Grimler <[email protected]> Reviewed-by: Krzysztof Kozlowski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sebastian Reichel <[email protected]>
1 parent dc123a1 commit 3a3acf8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/power/supply/max17042_battery.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,10 @@ static void max17042_set_soc_threshold(struct max17042_chip *chip, u16 off)
853853
/* program interrupt thresholds such that we should
854854
* get interrupt for every 'off' perc change in the soc
855855
*/
856-
regmap_read(map, MAX17042_RepSOC, &soc);
856+
if (chip->pdata->enable_current_sense)
857+
regmap_read(map, MAX17042_RepSOC, &soc);
858+
else
859+
regmap_read(map, MAX17042_VFSOC, &soc);
857860
soc >>= 8;
858861
soc_tr = (soc + off) << 8;
859862
if (off < soc)

0 commit comments

Comments
 (0)