* [PATCH v1 1/3] dt-bindings: power: supply: samsung,s2mu005-fuel-gauge: add S2MU106
2026-11-16 7:39 [PATCH v1 0/3] power: supply: s2mu005-battery: add S2MU106 (Samsung Galaxy XCover5) Adil Hüsrev Tepe
@ 2026-11-16 7:39 ` Adil Hüsrev Tepe
2026-11-16 7:55 ` sashiko-bot
2026-11-16 7:39 ` [PATCH v1 2/3] power: supply: s2mu005-battery: make the alert interrupt optional Adil Hüsrev Tepe
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Adil Hüsrev Tepe @ 2026-11-16 7:39 UTC (permalink / raw)
To: Sebastian Reichel, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Kaustabh Chakraborty
Cc: Yassine Oudjana, linux-pm, devicetree, linux-kernel,
Adil Hüsrev Tepe
The fuel gauge in the Samsung S2MU106 PMIC shares the S2MU005 fuel
gauge's register layout and scaling for the direct voltage, current and
state-of-charge registers. Add a "samsung,s2mu106-fuel-gauge" compatible
with the existing "samsung,s2mu005-fuel-gauge" as a fallback.
This was verified on a Samsung Galaxy XCover5 (Exynos850): the s2mu005
fuel-gauge driver, bound to the S2MU106 fuel gauge, reports voltage,
state of charge and the sign of the charge current correctly.
Signed-off-by: Adil Hüsrev Tepe <tadilhusrev@gmail.com>
---
.../bindings/power/supply/samsung,s2mu005-fuel-gauge.yaml | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/Documentation/devicetree/bindings/power/supply/samsung,s2mu005-fuel-gauge.yaml b/Documentation/devicetree/bindings/power/supply/samsung,s2mu005-fuel-gauge.yaml
index 05e420316..7b9d56d38 100644
--- a/Documentation/devicetree/bindings/power/supply/samsung,s2mu005-fuel-gauge.yaml
+++ b/Documentation/devicetree/bindings/power/supply/samsung,s2mu005-fuel-gauge.yaml
@@ -14,8 +14,11 @@ allOf:
properties:
compatible:
- enum:
- - samsung,s2mu005-fuel-gauge
+ oneOf:
+ - const: samsung,s2mu005-fuel-gauge
+ - items:
+ - const: samsung,s2mu106-fuel-gauge
+ - const: samsung,s2mu005-fuel-gauge
reg:
maxItems: 1
--
2.53.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH v1 1/3] dt-bindings: power: supply: samsung,s2mu005-fuel-gauge: add S2MU106
2026-11-16 7:39 ` [PATCH v1 1/3] dt-bindings: power: supply: samsung,s2mu005-fuel-gauge: add S2MU106 Adil Hüsrev Tepe
@ 2026-11-16 7:55 ` sashiko-bot
0 siblings, 0 replies; 6+ messages in thread
From: sashiko-bot @ 2026-11-16 7:55 UTC (permalink / raw)
To: Adil Hüsrev Tepe; +Cc: devicetree, robh, conor+dt
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] dt-bindings: power: supply: s2mu005: invalid fallback
compatible for S2MU106
--
commit c83b096797bb5a947ce97c34b89a173145f99454
Author: Adil Hüsrev Tepe <tadilhusrev@gmail.com>
dt-bindings: power: supply: samsung,s2mu005-fuel-gauge: add S2MU106
This commit adds the samsung,s2mu106-fuel-gauge compatible string to the
Samsung S2MU005 fuel-gauge binding with samsung,s2mu005-fuel-gauge as a
required fallback.
> diff --git a/Documentation/devicetree/bindings/power/supply/samsung,s2mu005-fuel-gauge.yaml b/Documentation/devicetree/bindings/power/supply/samsung,s2mu005-fuel-gauge.yaml
> index 05e420316a26b..7b9d56d38c651 100644
> --- a/Documentation/devicetree/bindings/power/supply/samsung,s2mu005-fuel-gauge.yaml
> +++ b/Documentation/devicetree/bindings/power/supply/samsung,s2mu005-fuel-gauge.yaml
> @@ -14,8 +14,11 @@ allOf:
>
> properties:
> compatible:
> - enum:
> - - samsung,s2mu005-fuel-gauge
> + oneOf:
> + - const: samsung,s2mu005-fuel-gauge
> + - items:
> + - const: samsung,s2mu106-fuel-gauge
> + - const: samsung,s2mu005-fuel-gauge
>
> reg:
> maxItems: 1
[Severity: Medium]
Should samsung,s2mu106-fuel-gauge be listed in the compatible enum without a
samsung,s2mu005-fuel-gauge fallback?
When a devicetree node uses this fallback and binds via the
samsung,s2mu005-fuel-gauge driver entry, s2mu005_fg_get_voltage_avg() and
s2mu005_fg_get_current_avg() write S2MU005-specific selector values to
S2MU005_FG_REG_MONOUTSEL and read bogus values from S2MU005_FG_REG_MONOUT.
Because s2mu005_fg_get_status() checks both current_now < 0 and
current_avg < 0 before reporting POWER_SUPPLY_STATUS_DISCHARGING, those
bogus MONOUT reads also cause POWER_SUPPLY_PROP_STATUS to misreport the
charging state.
Later commit "power: supply: s2mu005-battery: add S2MU106 support" adds a
distinct match entry for samsung,s2mu106-fuel-gauge with has_monout = false
to avoid touching MONOUT, while this schema forbids a standalone
samsung,s2mu106-fuel-gauge compatible string.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261116074000.355176-1-tadilhusrev@gmail.com?part=1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v1 2/3] power: supply: s2mu005-battery: make the alert interrupt optional
2026-11-16 7:39 [PATCH v1 0/3] power: supply: s2mu005-battery: add S2MU106 (Samsung Galaxy XCover5) Adil Hüsrev Tepe
2026-11-16 7:39 ` [PATCH v1 1/3] dt-bindings: power: supply: samsung,s2mu005-fuel-gauge: add S2MU106 Adil Hüsrev Tepe
@ 2026-11-16 7:39 ` Adil Hüsrev Tepe
2026-11-16 7:40 ` [PATCH v1 3/3] power: supply: s2mu005-battery: add S2MU106 support Adil Hüsrev Tepe
2026-11-17 10:41 ` [PATCH v1 0/3] power: supply: s2mu005-battery: add S2MU106 (Samsung Galaxy XCover5) Adil Hüsrev Tepe
3 siblings, 0 replies; 6+ messages in thread
From: Adil Hüsrev Tepe @ 2026-11-16 7:39 UTC (permalink / raw)
To: Sebastian Reichel, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Kaustabh Chakraborty
Cc: Yassine Oudjana, linux-pm, devicetree, linux-kernel,
Adil Hüsrev Tepe
The driver unconditionally requests the fuel-gauge alert interrupt and
fails to probe if the board does not wire it. Not all boards route the
alert line (for example the Samsung Galaxy XCover5), so only request the
interrupt when one is present; the gauge is otherwise polled on demand.
Signed-off-by: Adil Hüsrev Tepe <tadilhusrev@gmail.com>
---
drivers/power/supply/s2mu005-battery.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/power/supply/s2mu005-battery.c b/drivers/power/supply/s2mu005-battery.c
index a76154e5a..9798a62ff 100644
--- a/drivers/power/supply/s2mu005-battery.c
+++ b/drivers/power/supply/s2mu005-battery.c
@@ -273,11 +273,13 @@ static int s2mu005_fg_i2c_probe(struct i2c_client *client)
return dev_err_probe(dev, PTR_ERR(priv->psy),
"failed to register power supply subsystem\n");
- ret = devm_request_threaded_irq(priv->dev, client->irq, NULL,
- s2mu005_handle_irq, IRQF_ONESHOT,
- psy_desc->name, priv);
- if (ret)
- return dev_err_probe(dev, ret, "failed to request IRQ\n");
+ if (client->irq > 0) {
+ ret = devm_request_threaded_irq(priv->dev, client->irq, NULL,
+ s2mu005_handle_irq, IRQF_ONESHOT,
+ psy_desc->name, priv);
+ if (ret)
+ return dev_err_probe(dev, ret, "failed to request IRQ\n");
+ }
return 0;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH v1 3/3] power: supply: s2mu005-battery: add S2MU106 support
2026-11-16 7:39 [PATCH v1 0/3] power: supply: s2mu005-battery: add S2MU106 (Samsung Galaxy XCover5) Adil Hüsrev Tepe
2026-11-16 7:39 ` [PATCH v1 1/3] dt-bindings: power: supply: samsung,s2mu005-fuel-gauge: add S2MU106 Adil Hüsrev Tepe
2026-11-16 7:39 ` [PATCH v1 2/3] power: supply: s2mu005-battery: make the alert interrupt optional Adil Hüsrev Tepe
@ 2026-11-16 7:40 ` Adil Hüsrev Tepe
2026-11-17 10:41 ` [PATCH v1 0/3] power: supply: s2mu005-battery: add S2MU106 (Samsung Galaxy XCover5) Adil Hüsrev Tepe
3 siblings, 0 replies; 6+ messages in thread
From: Adil Hüsrev Tepe @ 2026-11-16 7:40 UTC (permalink / raw)
To: Sebastian Reichel, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Kaustabh Chakraborty
Cc: Yassine Oudjana, linux-pm, devicetree, linux-kernel,
Adil Hüsrev Tepe
The Samsung S2MU106 PMIC fuel gauge uses the same STATUS/RVBAT/RCURCC/
RSOC registers and scaling as the S2MU005, so the same read paths apply.
It does not, however, share the MONOUT average-monitoring path: reading
the averaged voltage and current through it returns bogus values on the
S2MU106. Introduce a per-variant descriptor so the S2MU106 exposes only
the instantaneous voltage, current, capacity and status, and derive the
status from the instantaneous current alone when the average is absent.
Tested on a Samsung Galaxy XCover5 (Exynos850): voltage, state of charge
and the sign of the charge current track the stock readings; the gauge
has no alert line wired, which the preceding patch already accommodates.
Signed-off-by: Adil Hüsrev Tepe <tadilhusrev@gmail.com>
---
drivers/power/supply/s2mu005-battery.c | 61 ++++++++++++++++++++++----
1 file changed, 52 insertions(+), 9 deletions(-)
diff --git a/drivers/power/supply/s2mu005-battery.c b/drivers/power/supply/s2mu005-battery.c
index 9798a62ff..a1bd9ffdd 100644
--- a/drivers/power/supply/s2mu005-battery.c
+++ b/drivers/power/supply/s2mu005-battery.c
@@ -38,6 +38,7 @@ struct s2mu005_fg {
struct regmap *regmap;
struct power_supply *psy;
struct mutex monout_mutex;
+ bool has_monout;
};
static const struct regmap_config s2mu005_fg_regmap_config = {
@@ -168,16 +169,18 @@ static int s2mu005_fg_get_capacity(struct s2mu005_fg *priv, int *value)
static int s2mu005_fg_get_status(struct s2mu005_fg *priv, int *value)
{
- int current_now, current_avg, capacity;
+ int current_now, current_avg = -1, capacity;
int ret;
ret = s2mu005_fg_get_current_now(priv, ¤t_now);
if (ret < 0)
return ret;
- ret = s2mu005_fg_get_current_avg(priv, ¤t_avg);
- if (ret < 0)
- return ret;
+ if (priv->has_monout) {
+ ret = s2mu005_fg_get_current_avg(priv, ¤t_avg);
+ if (ret < 0)
+ return ret;
+ }
/*
* Verify both current values reported to reduce inaccuracies due to
@@ -240,12 +243,47 @@ static const struct power_supply_desc s2mu005_fg_desc = {
.get_property = s2mu005_fg_get_property,
};
+/*
+ * The S2MU106 fuel gauge shares the direct STATUS/RVBAT/RCURCC/RSOC
+ * registers and their scaling, but not the MONOUT average-monitoring path,
+ * so the averaged voltage and current are not exposed on it.
+ */
+static const enum power_supply_property s2mu106_fg_properties[] = {
+ POWER_SUPPLY_PROP_VOLTAGE_NOW,
+ POWER_SUPPLY_PROP_CURRENT_NOW,
+ POWER_SUPPLY_PROP_CAPACITY,
+ POWER_SUPPLY_PROP_STATUS,
+};
+
+static const struct power_supply_desc s2mu106_fg_desc = {
+ .name = "s2mu106-fuel-gauge",
+ .type = POWER_SUPPLY_TYPE_BATTERY,
+ .properties = s2mu106_fg_properties,
+ .num_properties = ARRAY_SIZE(s2mu106_fg_properties),
+ .get_property = s2mu005_fg_get_property,
+};
+
+struct s2mu005_fg_variant {
+ const struct power_supply_desc *desc;
+ bool has_monout;
+};
+
+static const struct s2mu005_fg_variant s2mu005_fg_variant = {
+ .desc = &s2mu005_fg_desc,
+ .has_monout = true,
+};
+
+static const struct s2mu005_fg_variant s2mu106_fg_variant = {
+ .desc = &s2mu106_fg_desc,
+ .has_monout = false,
+};
+
static int s2mu005_fg_i2c_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct s2mu005_fg *priv;
struct power_supply_config psy_cfg = {};
- const struct power_supply_desc *psy_desc;
+ const struct s2mu005_fg_variant *variant;
int ret;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
@@ -264,11 +302,12 @@ static int s2mu005_fg_i2c_probe(struct i2c_client *client)
if (ret)
return dev_err_probe(dev, ret, "failed to initialize MONOUT mutex\n");
- psy_desc = device_get_match_data(dev);
+ variant = device_get_match_data(dev);
+ priv->has_monout = variant->has_monout;
psy_cfg.drv_data = priv;
psy_cfg.fwnode = dev_fwnode(dev);
- priv->psy = devm_power_supply_register(priv->dev, psy_desc, &psy_cfg);
+ priv->psy = devm_power_supply_register(priv->dev, variant->desc, &psy_cfg);
if (IS_ERR(priv->psy))
return dev_err_probe(dev, PTR_ERR(priv->psy),
"failed to register power supply subsystem\n");
@@ -276,7 +315,7 @@ static int s2mu005_fg_i2c_probe(struct i2c_client *client)
if (client->irq > 0) {
ret = devm_request_threaded_irq(priv->dev, client->irq, NULL,
s2mu005_handle_irq, IRQF_ONESHOT,
- psy_desc->name, priv);
+ variant->desc->name, priv);
if (ret)
return dev_err_probe(dev, ret, "failed to request IRQ\n");
}
@@ -287,7 +326,11 @@ static int s2mu005_fg_i2c_probe(struct i2c_client *client)
static const struct of_device_id s2mu005_fg_of_match_table[] = {
{
.compatible = "samsung,s2mu005-fuel-gauge",
- .data = &s2mu005_fg_desc,
+ .data = &s2mu005_fg_variant,
+ },
+ {
+ .compatible = "samsung,s2mu106-fuel-gauge",
+ .data = &s2mu106_fg_variant,
},
{ }
};
--
2.53.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH v1 0/3] power: supply: s2mu005-battery: add S2MU106 (Samsung Galaxy XCover5)
2026-11-16 7:39 [PATCH v1 0/3] power: supply: s2mu005-battery: add S2MU106 (Samsung Galaxy XCover5) Adil Hüsrev Tepe
` (2 preceding siblings ...)
2026-11-16 7:40 ` [PATCH v1 3/3] power: supply: s2mu005-battery: add S2MU106 support Adil Hüsrev Tepe
@ 2026-11-17 10:41 ` Adil Hüsrev Tepe
3 siblings, 0 replies; 6+ messages in thread
From: Adil Hüsrev Tepe @ 2026-11-17 10:41 UTC (permalink / raw)
To: Sebastian Reichel, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Kaustabh Chakraborty
Cc: Yassine Oudjana, linux-pm, devicetree, linux-kernel
I'd like to withdraw this series rather than send a v2.
A review bot (Sashiko AI) flagged that patch 1's fallback compatible
(samsung,s2mu106-fuel-gauge falling back to samsung,s2mu005-fuel-gauge)
is unsound: a board using that fallback binds to the S2MU005 driver as-is,
which still reads the MONOUT average-monitoring registers for
VOLTAGE_AVG/CURRENT_AVG and uses current_avg to help decide
POWER_SUPPLY_STATUS. The S2MU106 doesn't have that path, so those reads
return garbage, and garbage current_avg can flip the reported charging
status. Patch 3's has_monout flag avoids calling into that path from the
S2MU106 variant I added, but the binding still allows a device to bind
through the plain samsung,s2mu005-fuel-gauge compatible with no
has_monout gate at all, which is the actual hole.
On reflection, extending s2mu005-battery.c was the wrong shape for this
chip regardless of that specific bug. The S2MU106 fuel gauge is a
separate, standalone I2C device on the Galaxy XCover5 (own address,
0x3b), not a drop-in register-compatible S2MU005 variant sharing a
device tree node -- it only happens to reuse the same STATUS/RVBAT/
RCURCC/RSOC register layout and scaling. A dedicated driver avoids the
fallback-compatible construction entirely, since there's nothing to
fall back to.
I'll send that as a new series instead: a samsung,s2mu106-fuelgauge
binding and a standalone drivers/power/supply/s2mu106-fuelgauge.c,
with no changes to s2mu005-battery.c or its binding. Sorry for the
noise -- I should have settled on this shape before sending v1.
Adil
^ permalink raw reply [flat|nested] 6+ messages in thread