hwmon: (pmbus/lm25066) Support SMBus Current Limit configuration
Subsystems (2)
cover hwmon: (pmbus/lm25066) Support SMBus Current Limit configuration
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.
LORE Link: https://lore.kernel.org/all/[email protected]/
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(+)
Signature · 1 line
2.52.0
PATCH 1/2 dt-bindings: hwmon: pmbus: ti,lm25066: add current limit properties
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
--- .../bindings/hwmon/pmbus/ti,lm25066.yaml | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+)
Documentation/devicetree/bindings/hwmon/pmbus/ti,lm25066.yaml +20 -0
@@ -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
Signature · 1 line
2.52.0
PATCH 2/2 hwmon: (pmbus/lm25066) add current limit configuration support
In reply to Potin LaiAdd 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.
--- drivers/hwmon/pmbus/lm25066.c | 37 +++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)
drivers/hwmon/pmbus/lm25066.c +37 -0
@@ -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 ;
Signature · 1 line
2.52.0