[PATCH v4 02/11] power: supply: max17042_battery: Separate MAX17055 initialization

From: Vincent Cloutier

Date: Sun Jul 26 2026 - 21:15:11 EST


From: Vincent Cloutier <vincent@xxxxxxxxxxx>

MAX17055 uses ModelCfg.Refresh instead of the characterization-data
flow used by the other supported gauges. Move its existing initialization
steps into a dedicated helper without changing behavior. This isolates the
chip-specific path for subsequent EZ Config changes.

Assisted-by: OpenCode:gpt-5.6-sol
Signed-off-by: Vincent Cloutier <vincent@xxxxxxxxxxx>
---
drivers/power/supply/max17042_battery.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
index d409d2f0d383..70c5d5ce945d 100644
--- a/drivers/power/supply/max17042_battery.c
+++ b/drivers/power/supply/max17042_battery.c
@@ -847,18 +847,24 @@ static inline void max17042_override_por_values(struct max17042_chip *chip)
max17042_override_por(map, MAX17055_ModelCfg, config->model_cfg);
}

+static void max17055_init_chip(struct max17042_chip *chip)
+{
+ max17042_override_por_values(chip);
+
+ regmap_write_bits(chip->regmap, MAX17055_ModelCfg,
+ MAX17055_MODELCFG_REFRESH_BIT,
+ MAX17055_MODELCFG_REFRESH_BIT);
+}
+
static int max17042_init_chip(struct max17042_chip *chip)
{
struct regmap *map = chip->regmap;
int ret;

- max17042_override_por_values(chip);
-
- if (chip->chip_type == MAXIM_DEVICE_TYPE_MAX17055) {
- regmap_write_bits(map, MAX17055_ModelCfg,
- MAX17055_MODELCFG_REFRESH_BIT,
- MAX17055_MODELCFG_REFRESH_BIT);
- }
+ if (chip->chip_type == MAXIM_DEVICE_TYPE_MAX17055)
+ max17055_init_chip(chip);
+ else
+ max17042_override_por_values(chip);

/* After Power up, the MAX17042 requires 500mS in order
* to perform signal debouncing and initial SOC reporting
--
2.55.0