summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPotin Lai <potin.lai.pt@gmail.com>2026-06-15 17:49:17 +0800
committerGuenter Roeck <linux@roeck-us.net>2026-08-10 08:59:40 -0700
commita86e9ca4eda2445b582aad4cff42504fa8be6f61 (patch)
treeded4683c9cf7aea824c9e2939e39967d9fdc53fc
parent47afef9f4cf24571caf63c30ecccfcbc0ba5e79d (diff)
downloadlinux-stable-a86e9ca4eda2445b582aad4cff42504fa8be6f61.tar.gz
linux-stable-a86e9ca4eda2445b582aad4cff42504fa8be6f61.zip
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. 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> Link: https://lore.kernel.org/r/20260615-lm25066-cl-config-v3-2-decb4f5b0b77@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
-rw-r--r--drivers/hwmon/pmbus/lm25066.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/drivers/hwmon/pmbus/lm25066.c b/drivers/hwmon/pmbus/lm25066.c
index c797e2e8258f..497802c646e9 100644
--- a/drivers/hwmon/pmbus/lm25066.c
+++ b/drivers/hwmon/pmbus/lm25066.c
@@ -35,6 +35,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
@@ -485,6 +486,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;