max1720x_battery: nconvgcfg for M5
max77759 doesn't have nvram: change the value in regmap instead.
Bug: 200180657
Test: temperature over 5C, under 5C, hysteresis
Signed-off-by: AleX Pelosi <[email protected]>
Change-Id: I0c1bd452dac320cd6a9c2b274ef3e8a2ef11a29a
diff --git a/max1720x_battery.c b/max1720x_battery.c
index 210e194..6772b38 100644
--- a/max1720x_battery.c
+++ b/max1720x_battery.c
@@ -1303,8 +1303,14 @@
(chip->curr_convgcfg_idx == -1 || idx < chip->curr_convgcfg_idx ||
temp >= chip->temp_convgcfg[chip->curr_convgcfg_idx] +
chip->convgcfg_hysteresis)) {
- REGMAP_WRITE(&chip->regmap_nvram, MAX1720X_NCONVGCFG,
- chip->convgcfg_values[idx]);
+ struct max17x0x_regmap *regmap;
+
+ if (chip->gauge_type == MAX_M5_GAUGE_TYPE)
+ regmap = &chip->regmap;
+ else
+ regmap = &chip->regmap_nvram;
+
+ REGMAP_WRITE(regmap, MAX1720X_NCONVGCFG, chip->convgcfg_values[idx]);
chip->curr_convgcfg_idx = idx;
dev_info(chip->dev, "updating nConvgcfg to 0x%04x as temp is %d (idx:%d)\n",
chip->convgcfg_values[idx], temp, idx);