* [PATCH v3 0/2] hwmon: (pmbus/lm25066) Support SMBus Current Limit configuration
@ 2026-06-15 9:49 Potin Lai
2026-06-15 9:49 ` [PATCH v3 1/2] dt-bindings: hwmon: pmbus: ti,lm25066: add current limit properties Potin Lai
2026-06-15 9:49 ` [PATCH v3 2/2] hwmon: (pmbus/lm25066) add current limit configuration support Potin Lai
0 siblings, 2 replies; 5+ messages in thread
From: Potin Lai @ 2026-06-15 9:49 UTC (permalink / raw)
To: Guenter Roeck, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Zev Weiss
Cc: linux-hwmon, devicetree, linux-kernel, Cosmo Chou, Mike Hsieh,
Potin Lai, Potin Lai
This series adds support for configuring the current limit behavior via
software override on LM25066-compatible devices (excluding LM25056) using
the DEVICE_SETUP (0xD9) register.
When the 'ti,current-range' property is specified in the device tree,
the driver configures the DEVICE_SETUP register's Current Limit Configuration
bit (bit 2) to activate SMBus/software override and sets the Current Limit
Setting bit (bit 4) to "low" or "high" threshold accordingly.
Since LM25056 does not support software override (bit 2 of DEVICE_SETUP is
reserved), it is explicitly excluded from this support in both the device
tree binding schema and the driver.
---
Changes in v3:
- Renamed property from 'ti,current-limit' to 'ti,current-range' to
resolve the global schema type conflict.
- Updated commit messages and bindings description to document supported
devices and their physical voltage mappings for the low/high settings.
- Link to v2: https://patch.msgid.link/20260615-lm25066-cl-config-v2-0-59be46e67d5a@gmail.com
Changes in v2:
- Replaced the boolean properties ('ti,cl-smbus-high' and 'ti,cl-smbus-low')
with a single string property 'ti,current-limit' ('low' or 'high')
- Excluded lm25056 in the driver from parsing/setting the current limit property.
- Link to v1: https://patch.msgid.link/20260611-lm25066-cl-config-v1-0-02e567bf3d91@gmail.com
To: Guenter Roeck <linux@roeck-us.net>
To: Rob Herring <robh@kernel.org>
To: Krzysztof Kozlowski <krzk+dt@kernel.org>
To: Conor Dooley <conor+dt@kernel.org>
To: Zev Weiss <zev@bewilderbeest.net>
Cc: linux-hwmon@vger.kernel.org
Cc: devicetree@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: Cosmo Chou <cosmo.chou@quantatw.com>
Cc: Mike Hsieh <Mike_Hsieh@quantatw.com>
Cc: Potin Lai <potin.lai@quantatw.com>
Signed-off-by: Potin Lai <potin.lai.pt@gmail.com>
---
Potin Lai (2):
dt-bindings: hwmon: pmbus: ti,lm25066: add current limit properties
hwmon: (pmbus/lm25066) add current limit configuration support
.../bindings/hwmon/pmbus/ti,lm25066.yaml | 20 ++++++++++++
drivers/hwmon/pmbus/lm25066.c | 37 ++++++++++++++++++++++
2 files changed, 57 insertions(+)
---
base-commit: 05f7e89ab9731565d8a62e3b5d1ec206485eeb0b
change-id: 20260611-lm25066-cl-config-f81925f7337e
Best regards,
--
Potin Lai <potin.lai.pt@gmail.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v3 1/2] dt-bindings: hwmon: pmbus: ti,lm25066: add current limit properties
2026-06-15 9:49 [PATCH v3 0/2] hwmon: (pmbus/lm25066) Support SMBus Current Limit configuration Potin Lai
@ 2026-06-15 9:49 ` Potin Lai
2026-06-15 9:59 ` sashiko-bot
2026-06-15 9:49 ` [PATCH v3 2/2] hwmon: (pmbus/lm25066) add current limit configuration support Potin Lai
1 sibling, 1 reply; 5+ messages in thread
From: Potin Lai @ 2026-06-15 9:49 UTC (permalink / raw)
To: Guenter Roeck, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Zev Weiss
Cc: linux-hwmon, devicetree, linux-kernel, Cosmo Chou, Mike Hsieh,
Potin Lai, Potin Lai
Add a 'ti,current-range' string property to configure the device's Current
Limit (CL) behavior to "high" or "low" via the register, overriding the
physical CL pin setting.
This configuration is supported on LM25066, LM5064, LM5066, and LM5066i.
LM25056 is excluded because it does not support configuring the current
limit via the DEVICE_SETUP register (bit 2 of DEVICE_SETUP is reserved).
The values "low" and "high" map to the respective low/high threshold
voltages of the chips:
- LM25066: low = 25 mV, high = 46 mV
- LM5064, LM5066, LM5066i: low = 26 mV, high = 50 mV
Signed-off-by: Potin Lai <potin.lai.pt@gmail.com>
---
.../devicetree/bindings/hwmon/pmbus/ti,lm25066.yaml | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/Documentation/devicetree/bindings/hwmon/pmbus/ti,lm25066.yaml b/Documentation/devicetree/bindings/hwmon/pmbus/ti,lm25066.yaml
index a20f140dc79a..fe42daabaaa8 100644
--- a/Documentation/devicetree/bindings/hwmon/pmbus/ti,lm25066.yaml
+++ b/Documentation/devicetree/bindings/hwmon/pmbus/ti,lm25066.yaml
@@ -46,12 +46,32 @@ properties:
additionalProperties: false
+ ti,current-range:
+ description: |
+ Configure the current limit setting. When present, this property
+ overrides the hardware setting of the physical CL pin by configuring
+ the DEVICE_SETUP register.
+ - "low": maps to 25 mV (LM25066) or 26 mV (LM5064, LM5066, LM5066i)
+ - "high": maps to 46 mV (LM25066) or 50 mV (LM5064, LM5066, LM5066i)
+ $ref: /schemas/types.yaml#/definitions/string
+ enum:
+ - low
+ - high
+
required:
- compatible
- reg
allOf:
- $ref: /schemas/hwmon/hwmon-common.yaml#
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: ti,lm25056
+ then:
+ properties:
+ ti,current-range: false
unevaluatedProperties: false
--
2.52.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 2/2] hwmon: (pmbus/lm25066) add current limit configuration support
2026-06-15 9:49 [PATCH v3 0/2] hwmon: (pmbus/lm25066) Support SMBus Current Limit configuration Potin Lai
2026-06-15 9:49 ` [PATCH v3 1/2] dt-bindings: hwmon: pmbus: ti,lm25066: add current limit properties Potin Lai
@ 2026-06-15 9:49 ` Potin Lai
2026-06-15 10:03 ` sashiko-bot
1 sibling, 1 reply; 5+ messages in thread
From: Potin Lai @ 2026-06-15 9:49 UTC (permalink / raw)
To: Guenter Roeck, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Zev Weiss
Cc: linux-hwmon, devicetree, linux-kernel, Cosmo Chou, Mike Hsieh,
Potin Lai, Potin Lai
Add support for the 'ti,current-range' devicetree property to configure
the current limit via the DEVICE_SETUP (0xD9) register, overriding the
physical CL pin setting.
This configuration is supported on all chips in this driver (LM25066,
LM5064, LM5066, LM5066i) except LM25056.
The property values "low" and "high" map to:
- LM25066: low = 25 mV, high = 46 mV
- LM5064, LM5066, LM5066i: low = 26 mV, high = 50 mV
The Bit 4 mapping to High/Low current limit is handled dynamically on
probe because it is swapped for LM25066 compared to the other supported
chips.
Signed-off-by: Potin Lai <potin.lai.pt@gmail.com>
---
drivers/hwmon/pmbus/lm25066.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/drivers/hwmon/pmbus/lm25066.c b/drivers/hwmon/pmbus/lm25066.c
index dd7275a67a0a..53d274033d66 100644
--- a/drivers/hwmon/pmbus/lm25066.c
+++ b/drivers/hwmon/pmbus/lm25066.c
@@ -34,6 +34,7 @@ enum chips { lm25056, lm25066, lm5064, lm5066, lm5066i };
#define LM25066_READ_AVG_PIN 0xdf
#define LM25066_DEV_SETUP_CL BIT(4) /* Current limit */
+#define LM25066_DEV_SETUP_CL_CFG BIT(2) /* Current limit configuration */
#define LM25066_SAMPLES_FOR_AVG_MAX 4096
@@ -484,6 +485,42 @@ static int lm25066_probe(struct i2c_client *client)
data->id = (enum chips)(unsigned long)i2c_get_match_data(client);
+ if (data->id != lm25056) {
+ int config_new = config;
+ const char *cl_setting;
+ int ret;
+
+ if (!of_property_read_string(client->dev.of_node,
+ "ti,current-range", &cl_setting)) {
+ config_new |= LM25066_DEV_SETUP_CL_CFG;
+ if (strcmp(cl_setting, "high") == 0) {
+ if (data->id == lm25066)
+ config_new |= LM25066_DEV_SETUP_CL;
+ else
+ config_new &= ~LM25066_DEV_SETUP_CL;
+ } else if (strcmp(cl_setting, "low") == 0) {
+ if (data->id == lm25066)
+ config_new &= ~LM25066_DEV_SETUP_CL;
+ else
+ config_new |= LM25066_DEV_SETUP_CL;
+ } else {
+ dev_err(&client->dev,
+ "invalid current-range setting: %s\n",
+ cl_setting);
+ return -EINVAL;
+ }
+ }
+
+ if (config_new != config) {
+ ret = i2c_smbus_write_byte_data(client,
+ LM25066_DEVICE_SETUP,
+ config_new);
+ if (ret < 0)
+ return ret;
+ config = config_new;
+ }
+ }
+
info = &data->info;
info->pages = 1;
--
2.52.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v3 1/2] dt-bindings: hwmon: pmbus: ti,lm25066: add current limit properties
2026-06-15 9:49 ` [PATCH v3 1/2] dt-bindings: hwmon: pmbus: ti,lm25066: add current limit properties Potin Lai
@ 2026-06-15 9:59 ` sashiko-bot
0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-06-15 9:59 UTC (permalink / raw)
To: Potin Lai; +Cc: linux-hwmon, robh, devicetree, conor+dt
> Add a 'ti,current-range' string property to configure the device's Current
> Limit (CL) behavior to "high" or "low" via the register, overriding the
> physical CL pin setting.
>
> This configuration is supported on LM25066, LM5064, LM5066, and LM5066i.
> LM25056 is excluded because it does not support configuring the current
> limit via the DEVICE_SETUP register (bit 2 of DEVICE_SETUP is reserved).
>
> The values "low" and "high" map to the respective low/high threshold
> voltages of the chips:
> - LM25066: low = 25 mV, high = 46 mV
> - LM5064, LM5066, LM5066i: low = 26 mV, high = 50 mV
>
> Signed-off-by: Potin Lai <potin.lai.pt@gmail.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260615-lm25066-cl-config-v3-0-decb4f5b0b77@gmail.com?part=1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3 2/2] hwmon: (pmbus/lm25066) add current limit configuration support
2026-06-15 9:49 ` [PATCH v3 2/2] hwmon: (pmbus/lm25066) add current limit configuration support Potin Lai
@ 2026-06-15 10:03 ` sashiko-bot
0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-06-15 10:03 UTC (permalink / raw)
To: Potin Lai; +Cc: robh, conor+dt, linux-hwmon, devicetree
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] The PMBus coefficient selection logic uses swapped Bit 4 semantics for non-LM25066 chips, causing incorrect telemetry scaling.
- [High] Missing `R` exponent update when alternative current limit (`_L`) coefficients are selected.
--
commit 5b618ea6bd8652d84454a36d0af72de96fc3501b
Author: Potin Lai <potin.lai.pt@gmail.com>
hwmon: (pmbus/lm25066) add current limit configuration support
Add support for the 'ti,current-range' devicetree property to configure
the current limit via the DEVICE_SETUP (0xD9) register, overriding the
physical CL pin setting.
> diff --git a/drivers/hwmon/pmbus/lm25066.c b/drivers/hwmon/pmbus/lm25066.c
> index dd7275a67a0ab..53d274033d66f 100644
> --- a/drivers/hwmon/pmbus/lm25066.c
> +++ b/drivers/hwmon/pmbus/lm25066.c
[ ... ]
> @@ -484,6 +485,42 @@ static int lm25066_probe(struct i2c_client *client)
>
> data->id = (enum chips)(unsigned long)i2c_get_match_data(client);
>
> + if (data->id != lm25056) {
> + int config_new = config;
> + const char *cl_setting;
> + int ret;
> +
> + if (!of_property_read_string(client->dev.of_node,
> + "ti,current-range", &cl_setting)) {
> + config_new |= LM25066_DEV_SETUP_CL_CFG;
> + if (strcmp(cl_setting, "high") == 0) {
> + if (data->id == lm25066)
> + config_new |= LM25066_DEV_SETUP_CL;
> + else
> + config_new &= ~LM25066_DEV_SETUP_CL;
[Severity: High]
This is a pre-existing issue, but does this bit swapping logic expose a
mismatch in how the PMBus coefficients are selected later in lm25066_probe()?
While this patch correctly clears LM25066_DEV_SETUP_CL for the 'high' range
on non-LM25066 chips, the pre-existing coefficient logic unconditionally
checks Bit 4 without accounting for the chip ID:
if (config & LM25066_DEV_SETUP_CL) {
info->m[PSC_CURRENT_IN] = coeff[PSC_CURRENT_IN_L].m;
...
} else {
info->m[PSC_CURRENT_IN] = coeff[PSC_CURRENT_IN].m;
...
For example, on an LM5066, requesting 'high' sets Bit 4 to 0. This causes
the logic to take the else branch and use the standard CURRENT_IN coefficients
(intended for the 'low' limit). Will this cause the hardware monitoring driver
to report current and power values that are off by roughly a factor of 2?
> + } else if (strcmp(cl_setting, "low") == 0) {
> + if (data->id == lm25066)
> + config_new &= ~LM25066_DEV_SETUP_CL;
> + else
> + config_new |= LM25066_DEV_SETUP_CL;
> + } else {
> + dev_err(&client->dev,
> + "invalid current-range setting: %s\n",
> + cl_setting);
> + return -EINVAL;
> + }
> + }
> +
> + if (config_new != config) {
> + ret = i2c_smbus_write_byte_data(client,
> + LM25066_DEVICE_SETUP,
> + config_new);
> + if (ret < 0)
> + return ret;
> + config = config_new;
> + }
> + }
[Severity: High]
This isn't a bug introduced by this patch, but while reviewing the coefficient
selection logic in lm25066_probe(), is there a missing update for the R
exponent?
When the alternative current limit (_L) coefficients are selected, the m and b
values are updated but R is not:
info->R[PSC_POWER] = coeff[PSC_POWER].R;
if (config & LM25066_DEV_SETUP_CL) {
info->m[PSC_CURRENT_IN] = coeff[PSC_CURRENT_IN_L].m;
info->b[PSC_CURRENT_IN] = coeff[PSC_CURRENT_IN_L].b;
info->m[PSC_POWER] = coeff[PSC_POWER_L].m;
info->b[PSC_POWER] = coeff[PSC_POWER_L].b;
} else {
...
For the lm25056 chip, the POWER_L coefficient array entry has R = -4, while
the standard POWER coefficient has R = -3. Because info->R[PSC_POWER] is
only initialized from the base coefficient, could power readings be
miscalculated by a factor of 10 when the alternative limit is active?
> info = &data->info;
>
> info->pages = 1;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260615-lm25066-cl-config-v3-0-decb4f5b0b77@gmail.com?part=2
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-06-15 10:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-15 9:49 [PATCH v3 0/2] hwmon: (pmbus/lm25066) Support SMBus Current Limit configuration Potin Lai
2026-06-15 9:49 ` [PATCH v3 1/2] dt-bindings: hwmon: pmbus: ti,lm25066: add current limit properties Potin Lai
2026-06-15 9:59 ` sashiko-bot
2026-06-15 9:49 ` [PATCH v3 2/2] hwmon: (pmbus/lm25066) add current limit configuration support Potin Lai
2026-06-15 10:03 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox