Re: [PATCH 2/2] power: supply: s2mu106-fuelgauge: add standalone driver
From: Krzysztof Kozlowski
Date: Mon Nov 23 2026 - 07:30:54 EST
On Tue, Nov 17, 2026 at 01:43:28PM +0300, Adil Hüsrev Tepe wrote:
> Add a standalone driver for the fuel gauge in the Samsung S2MU106
> PMIC, as fitted on the Samsung Galaxy XCover5 (own I2C address, 0x3b).
> It shares the S2MU005 fuel gauge's STATUS/RVBAT/RCURCC/RSOC register
> layout and scaling, which this driver reads directly with the stock
> fixed-point formulas; it has no MONOUT average-monitoring registers,
> so unlike s2mu005-battery.c it never reads VOLTAGE_AVG/CURRENT_AVG or
> uses current_avg to decide POWER_SUPPLY_STATUS.
>
> This replaces a previous version of this series
> (https://lore.kernel.org/all/20261116074000.355176-1-tadilhusrev@xxxxxxxxx/)
> that instead extended s2mu005-battery.c with a samsung,s2mu106-fuel-gauge
> fallback compatible; see "dt-bindings: power: supply: add
> samsung,s2mu106-fuelgauge" in this series for why that shape was
> dropped.
No relevant
>
> The driver was drafted with an AI coding assistant (Claude Code,
> Anthropic) from this register map; I reviewed every line, built it
Not relevant!
> (arm64, 0 warnings), ran checkpatch --strict (clean), and tested it on
> a Samsung Galaxy XCover5 (re-confirmed 2026-11-17, kernel
> 7.4.0-rc1-00023-gdcb8b91fb779+ #30): it probes, and
> /sys/class/power_supply/s2mu106-battery/ reports plausible voltage,
> capacity and charging-status values that track the device's actual
> state (confirmed live, including across a flash/reboot cycle).
Even less relevant, drop. AI usage goes to changelog.
> +static int s2mu106_fg_probe(struct i2c_client *client)
> +{
> + struct s2mu106_fg *fg;
> + struct power_supply_config cfg = {};
> +
> + fg = devm_kzalloc(&client->dev, sizeof(*fg), GFP_KERNEL);
> + if (!fg)
> + return -ENOMEM;
> +
> + fg->dev = &client->dev;
> + mutex_init(&fg->lock);
> +
> + fg->regmap = devm_regmap_init_i2c(client, &s2mu106_fg_regmap_config);
> + if (IS_ERR(fg->regmap))
> + return PTR_ERR(fg->regmap);
> +
> + i2c_set_clientdata(client, fg);
> +
> + cfg.drv_data = fg;
> + fg->psy = devm_power_supply_register(&client->dev, &s2mu106_fg_desc, &cfg);
> + if (IS_ERR(fg->psy))
> + return PTR_ERR(fg->psy);
> +
> + dev_info(&client->dev, "S2MU106 fuel gauge registered (addr 0x%02x)\n",
> + client->addr);
Drop, drivers should be silent on success.
> + return 0;
Why do you need a new driver instead of integrating it into existing
s2mu005?
Best regards,
Krzysztof