* [PATCH v2 0/3] Add INA232 power monitor support for Arduino VENTUNO Q
@ 2026-06-11 14:05 Loic Poulain
2026-06-11 14:05 ` [PATCH v2 1/3] dt-bindings: hwmon: ina2xx: add ina232 compatible Loic Poulain
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Loic Poulain @ 2026-06-11 14:05 UTC (permalink / raw)
To: Guenter Roeck, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Bjorn Andersson, Konrad Dybcio
Cc: Krzysztof Kozlowski, linux-hwmon, devicetree, linux-kernel,
linux-arm-msm, Loic Poulain, Martino Facchin
Add support for the TI INA232 current/power monitor to the ina2xx
hwmon driver, and enable it on the Arduino Monza board.
The INA232 is a bidirectional current/power monitor that shares the
same I2C register layout as the INA226, but has different electrical
characteristics.
On the Arduino Monza/Ventuno-Q board, the INA232 is connected on
I2C12 at address 0x40 with a 2 mΩ shunt resistor, and is used to
monitor the board supply current.
Signed-off-by: Loic Poulain <loic.poulain@oss.qualcomm.com>
---
Changes in v2:
- has_update_interval was missing and should be set to true/supported
(sashiko/Guenter)
- ti,ina232 added to two allOf conditional exclusion blocks. (sashiko)
- Fix commit message, it incorrectly mentioned 2Mohm instead of
milli-ohm. (sahiko, Konrad).
- Link to v1: https://lore.kernel.org/r/20260610-monza-ina232-v1-0-925b0d12771b@oss.qualcomm.com
---
Loic Poulain (1):
arm64: dts: qcom: monaco-arduino-monza: add ina232 power sensor
Martino Facchin (2):
dt-bindings: hwmon: ina2xx: add ina232 compatible
hwmon: ina2xx: support ina232
.../devicetree/bindings/hwmon/ti,ina2xx.yaml | 3 +++
arch/arm64/boot/dts/qcom/monaco-arduino-monza.dts | 6 ++++++
drivers/hwmon/ina2xx.c | 20 ++++++++++++++++++++
3 files changed, 29 insertions(+)
---
base-commit: 8a4062d204752e0d66a1e7e1a2f8834571a8d40f
change-id: 20260610-monza-ina232-de180e669dc1
Best regards,
--
Loic Poulain <loic.poulain@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 1/3] dt-bindings: hwmon: ina2xx: add ina232 compatible
2026-06-11 14:05 [PATCH v2 0/3] Add INA232 power monitor support for Arduino VENTUNO Q Loic Poulain
@ 2026-06-11 14:05 ` Loic Poulain
2026-06-11 14:13 ` sashiko-bot
2026-06-11 14:05 ` [PATCH v2 2/3] hwmon: ina2xx: support ina232 Loic Poulain
2026-06-11 14:05 ` [PATCH v2 3/3] arm64: dts: qcom: monaco-arduino-monza: add ina232 power sensor Loic Poulain
2 siblings, 1 reply; 7+ messages in thread
From: Loic Poulain @ 2026-06-11 14:05 UTC (permalink / raw)
To: Guenter Roeck, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Bjorn Andersson, Konrad Dybcio
Cc: Krzysztof Kozlowski, linux-hwmon, devicetree, linux-kernel,
linux-arm-msm, Loic Poulain, Martino Facchin
From: Martino Facchin <m.facchin@arduino.cc>
The INA232 is a current/power monitor from Texas Instruments sharing
the same register map as the other INA2xx.
Signed-off-by: Martino Facchin <m.facchin@arduino.cc>
Signed-off-by: Loic Poulain <loic.poulain@oss.qualcomm.com>
---
Documentation/devicetree/bindings/hwmon/ti,ina2xx.yaml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Documentation/devicetree/bindings/hwmon/ti,ina2xx.yaml b/Documentation/devicetree/bindings/hwmon/ti,ina2xx.yaml
index 009d78b308596ca795bebdd160431bd718b127e0..a79ade3142fa4f36f2ae4655bbf0db8ad84ec13a 100644
--- a/Documentation/devicetree/bindings/hwmon/ti,ina2xx.yaml
+++ b/Documentation/devicetree/bindings/hwmon/ti,ina2xx.yaml
@@ -28,6 +28,7 @@ properties:
- ti,ina228
- ti,ina230
- ti,ina231
+ - ti,ina232
- ti,ina233
- ti,ina234
- ti,ina237
@@ -114,6 +115,7 @@ allOf:
- ti,ina228
- ti,ina230
- ti,ina231
+ - ti,ina232
- ti,ina234
- ti,ina237
- ti,ina238
@@ -136,6 +138,7 @@ allOf:
- ti,ina226
- ti,ina230
- ti,ina231
+ - ti,ina232
- ti,ina234
- ti,ina260
- ti,ina700
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 2/3] hwmon: ina2xx: support ina232
2026-06-11 14:05 [PATCH v2 0/3] Add INA232 power monitor support for Arduino VENTUNO Q Loic Poulain
2026-06-11 14:05 ` [PATCH v2 1/3] dt-bindings: hwmon: ina2xx: add ina232 compatible Loic Poulain
@ 2026-06-11 14:05 ` Loic Poulain
2026-06-11 14:19 ` sashiko-bot
2026-06-11 14:05 ` [PATCH v2 3/3] arm64: dts: qcom: monaco-arduino-monza: add ina232 power sensor Loic Poulain
2 siblings, 1 reply; 7+ messages in thread
From: Loic Poulain @ 2026-06-11 14:05 UTC (permalink / raw)
To: Guenter Roeck, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Bjorn Andersson, Konrad Dybcio
Cc: Krzysztof Kozlowski, linux-hwmon, devicetree, linux-kernel,
linux-arm-msm, Loic Poulain, Martino Facchin
From: Martino Facchin <m.facchin@arduino.cc>
The INA232 is a current/power monitor. It shares the same register
layout as the INA2xx and uses the INA226 default configuration, but
differs in its electrical characteristics:
Signed-off-by: Martino Facchin <m.facchin@arduino.cc>
Signed-off-by: Loic Poulain <loic.poulain@oss.qualcomm.com>
---
drivers/hwmon/ina2xx.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/hwmon/ina2xx.c b/drivers/hwmon/ina2xx.c
index 613ffb622b7c42b8b6090d3b4ec7b2fa412e24a4..fc2319ad99fc398a50e97ee617f67255bd0b3038 100644
--- a/drivers/hwmon/ina2xx.c
+++ b/drivers/hwmon/ina2xx.c
@@ -122,6 +122,7 @@ static const struct regmap_config ina2xx_regmap_config = {
enum ina2xx_ids {
ina219,
ina226,
+ ina232,
ina234,
ina260,
sy24655
@@ -196,6 +197,20 @@ static const struct ina2xx_config ina2xx_config[] = {
.current_shift = 4,
.has_update_interval = true,
},
+ [ina232] = {
+ .config_default = INA226_CONFIG_DEFAULT,
+ .calibration_value = 2048,
+ .shunt_div = 400,
+ .shunt_voltage_shift = 0,
+ .bus_voltage_shift = 0,
+ .bus_voltage_lsb = 1600,
+ .power_lsb_factor = 32,
+ .has_alerts = true,
+ .has_ishunt = false,
+ .has_power_average = false,
+ .current_shift = 0,
+ .has_update_interval = true,
+ },
[ina260] = {
.config_default = INA260_CONFIG_DEFAULT,
.shunt_div = 400,
@@ -1005,6 +1020,7 @@ static const struct i2c_device_id ina2xx_id[] = {
{ "ina226", ina226 },
{ "ina230", ina226 },
{ "ina231", ina226 },
+ { "ina232", ina232 },
{ "ina234", ina234 },
{ "ina260", ina260 },
{ "sy24655", sy24655 },
@@ -1037,6 +1053,10 @@ static const struct of_device_id __maybe_unused ina2xx_of_match[] = {
.compatible = "ti,ina231",
.data = (void *)ina226
},
+ {
+ .compatible = "ti,ina232",
+ .data = (void *)ina232
+ },
{
.compatible = "ti,ina234",
.data = (void *)ina234
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 3/3] arm64: dts: qcom: monaco-arduino-monza: add ina232 power sensor
2026-06-11 14:05 [PATCH v2 0/3] Add INA232 power monitor support for Arduino VENTUNO Q Loic Poulain
2026-06-11 14:05 ` [PATCH v2 1/3] dt-bindings: hwmon: ina2xx: add ina232 compatible Loic Poulain
2026-06-11 14:05 ` [PATCH v2 2/3] hwmon: ina2xx: support ina232 Loic Poulain
@ 2026-06-11 14:05 ` Loic Poulain
2026-06-11 14:09 ` sashiko-bot
2 siblings, 1 reply; 7+ messages in thread
From: Loic Poulain @ 2026-06-11 14:05 UTC (permalink / raw)
To: Guenter Roeck, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Bjorn Andersson, Konrad Dybcio
Cc: Krzysztof Kozlowski, linux-hwmon, devicetree, linux-kernel,
linux-arm-msm, Loic Poulain
The Arduino Monza board has a TI INA232 current/power monitor connected
on I2C12 at address 0x40. It is used to measure the board supply current
through a 2 milliohms shunt resistor.
Signed-off-by: Loic Poulain <loic.poulain@oss.qualcomm.com>
---
arch/arm64/boot/dts/qcom/monaco-arduino-monza.dts | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/arch/arm64/boot/dts/qcom/monaco-arduino-monza.dts b/arch/arm64/boot/dts/qcom/monaco-arduino-monza.dts
index 379b796f261f4c8f6b7712c5d340b20be1b9217c..a526c8a07b30c22820f54b54644916b268496209 100644
--- a/arch/arm64/boot/dts/qcom/monaco-arduino-monza.dts
+++ b/arch/arm64/boot/dts/qcom/monaco-arduino-monza.dts
@@ -291,6 +291,12 @@ adv7535_out: endpoint {
};
};
};
+
+ power-sensor@40 {
+ compatible = "ti,ina232";
+ reg = <0x40>;
+ shunt-resistor = <2000>;
+ };
};
&mdss {
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 3/3] arm64: dts: qcom: monaco-arduino-monza: add ina232 power sensor
2026-06-11 14:05 ` [PATCH v2 3/3] arm64: dts: qcom: monaco-arduino-monza: add ina232 power sensor Loic Poulain
@ 2026-06-11 14:09 ` sashiko-bot
0 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-06-11 14:09 UTC (permalink / raw)
To: Loic Poulain; +Cc: devicetree, conor+dt, linux-hwmon, robh
> The Arduino Monza board has a TI INA232 current/power monitor connected
> on I2C12 at address 0x40. It is used to measure the board supply current
> through a 2 milliohms shunt resistor.
>
> Signed-off-by: Loic Poulain <loic.poulain@oss.qualcomm.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260611-monza-ina232-v2-0-e4375ce652d0@oss.qualcomm.com?part=3
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/3] dt-bindings: hwmon: ina2xx: add ina232 compatible
2026-06-11 14:05 ` [PATCH v2 1/3] dt-bindings: hwmon: ina2xx: add ina232 compatible Loic Poulain
@ 2026-06-11 14:13 ` sashiko-bot
0 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-06-11 14:13 UTC (permalink / raw)
To: Loic Poulain; +Cc: robh, conor+dt, linux-hwmon, devicetree
> From: Martino Facchin <m.facchin@arduino.cc>
>
> The INA232 is a current/power monitor from Texas Instruments sharing
> the same register map as the other INA2xx.
>
> Signed-off-by: Martino Facchin <m.facchin@arduino.cc>
> Signed-off-by: Loic Poulain <loic.poulain@oss.qualcomm.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260611-monza-ina232-v2-0-e4375ce652d0@oss.qualcomm.com?part=1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/3] hwmon: ina2xx: support ina232
2026-06-11 14:05 ` [PATCH v2 2/3] hwmon: ina2xx: support ina232 Loic Poulain
@ 2026-06-11 14:19 ` sashiko-bot
0 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-06-11 14:19 UTC (permalink / raw)
To: Loic Poulain; +Cc: robh, devicetree, linux-hwmon, conor+dt
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
Pre-existing issues:
- [High] Power alert limit calculation always evaluates to 0 on 32-bit systems due to `UINT_MAX` underflow when cast to a signed long.
- [High] Setting a high bus voltage alert limit on 32-bit systems causes signed integer overflow for chips with a high `bus_voltage_shift`.
- [High] Arithmetic overflow and truncation in power and current reading calculations due to 32-bit signed integer limits.
--
commit 1860bedc8e47e2aefaa388ad7ade74649ff17da9
Author: Martino Facchin <m.facchin@arduino.cc>
hwmon: ina2xx: support ina232
The INA232 is a current/power monitor. It shares the same register
layout as the INA2xx and uses the INA226 default configuration, but
differs in its electrical characteristics.
> diff --git a/drivers/hwmon/ina2xx.c b/drivers/hwmon/ina2xx.c
> index 613ffb622b7c4..fc2319ad99fc3 100644
> --- a/drivers/hwmon/ina2xx.c
> +++ b/drivers/hwmon/ina2xx.c
> @@ -196,6 +197,20 @@ static const struct ina2xx_config ina2xx_config[] = {
> .current_shift = 4,
> .has_update_interval = true,
> },
> + [ina232] = {
> + .config_default = INA226_CONFIG_DEFAULT,
> + .calibration_value = 2048,
> + .shunt_div = 400,
> + .shunt_voltage_shift = 0,
> + .bus_voltage_shift = 0,
> + .bus_voltage_lsb = 1600,
> + .power_lsb_factor = 32,
> + .has_alerts = true,
> + .has_ishunt = false,
> + .has_power_average = false,
> + .current_shift = 0,
> + .has_update_interval = true,
> + },
[Severity: High]
This is a pre-existing issue, but does power alert configuration work correctly
on 32-bit systems?
In ina226_alert_to_reg() for INA2XX_POWER, the limit is clamped using:
val = clamp_val(val, 0, UINT_MAX - data->power_lsb_uW);
val = DIV_ROUND_CLOSEST(val, data->power_lsb_uW);
return clamp_val(val, 0, USHRT_MAX);
The clamp_val() macro casts its limit arguments to the type of val, which is
a signed long. On 32-bit systems, UINT_MAX - data->power_lsb_uW evaluates to
a negative value.
Because the maximum limit is negative, clamp_val() forces any positive input
to this negative limit, and the final clamp_val(..., 0, USHRT_MAX) will
unconditionally return 0, silently disabling or instantly triggering alerts.
[Severity: High]
This isn't a bug introduced by this patch, but could setting high bus voltage
alerts on 32-bit systems cause an integer overflow?
In ina226_alert_to_reg() for INA2XX_BUS_VOLTAGE, the value is calculated as:
val = clamp_val(val, 0, 200000);
val = (val * 1000) << data->config->bus_voltage_shift;
For chips with a high bus_voltage_shift like the INA234 (shift = 4), a valid
high input limit such as 150,000 mV evaluates to (150,000 * 1000) << 4,
which equals 2,400,000,000.
On 32-bit architectures, this exceeds the maximum positive value for a
signed long, overflowing into a negative number. The subsequent clamp to
USHRT_MAX then limits this to 0, converting legitimate high voltage limits
to 0.
[Severity: High]
This is a pre-existing issue, but does this calculation overflow for systems
measuring high loads with low-value shunt resistors?
In ina2xx_get_value(), the calculation is stored in a 32-bit signed integer:
static int ina2xx_get_value(struct ina2xx_data *data, u8 reg,
unsigned int regval)
{
int val;
...
case INA2XX_POWER:
val = regval * data->power_lsb_uW;
break;
For a system using a 1 mOhm shunt, power_lsb_uW might be 80,000. If regval
is large (e.g., 65535), the product exceeds INT_MAX.
This overflows on 32-bit systems or truncates when assigned to the 32-bit
integer val on 64-bit systems, causing the driver to report completely
incorrect and often large negative values.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260611-monza-ina232-v2-0-e4375ce652d0@oss.qualcomm.com?part=2
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-06-11 14:19 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-11 14:05 [PATCH v2 0/3] Add INA232 power monitor support for Arduino VENTUNO Q Loic Poulain
2026-06-11 14:05 ` [PATCH v2 1/3] dt-bindings: hwmon: ina2xx: add ina232 compatible Loic Poulain
2026-06-11 14:13 ` sashiko-bot
2026-06-11 14:05 ` [PATCH v2 2/3] hwmon: ina2xx: support ina232 Loic Poulain
2026-06-11 14:19 ` sashiko-bot
2026-06-11 14:05 ` [PATCH v2 3/3] arm64: dts: qcom: monaco-arduino-monza: add ina232 power sensor Loic Poulain
2026-06-11 14:09 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox