hwmon: pmbus: max20730: adjust the vout base on
Subsystems (2)
v3 cover hwmon: pmbus: max20730: adjust the vout base on
The patchset includes:
Patch #1 - Implmentation of adjusting vout base on voltage divider Patch #2 - device tree binding documentation
ChangeLog v1 -> v2
- Don't do anything to the ret if an error is returned from pmbus_read_word
- avoid overflow when doing multiplication
ChangeLog v2 -> v3
- Provide the binding documentation in yaml format
Chu Lin (2):
dt-bindings: hwmon: max20730: adding device tree doc for max20730
hwmon: pmbus: max20730: adjust the vout reading given voltage divider
.../bindings/hwmon/maxim,max20730.yaml | 63 +++++++++++++++++++ drivers/hwmon/pmbus/max20730.c | 18 ++++++ 2 files changed, 81 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/maxim,max20730.yaml
Signature · 1 line
2.28.0.681.g6f77f65b4e-goog
PATCH v3 1/2 dt-bindings: hwmon: max20730: adding device tree doc for max20730
max20730 Integrated, Step-Down Switching Regulator with PMBus
--- .../bindings/hwmon/maxim,max20730.yaml | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/maxim,max20730.yaml
Documentation/devicetree/bindings/hwmon/maxim,max20730.yaml new file +63 -0
@@ -0,0 +1,63 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- + +$id: http://devicetree.org/schemas/hwmon/maxim,max20730.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim max20730 + +maintainers: + - Jean Delvare <[email protected]> + - Guenter Roeck <[email protected]> + +description: | + The MAX20730 is a fully integrated, highly efficient switching regulator + with PMBus for applications operating from 4.5V to 16V and requiring + up to 25A (max) load. This single-chip regulator provides extremely + compact, highefficiency power-delivery solutions with high-precision + output voltages and excellent transient response + + Datasheets: + https://datasheets.maximintegrated.com/en/ds/MAX20730.pdf + https://datasheets.maximintegrated.com/en/ds/MAX20734.pdf + https://datasheets.maximintegrated.com/en/ds/MAX20743.pdf + +properties: + compatible: + enum: + - maxim,max20730 + - maxim,max20734 + - maxim,max20743 + + reg: + maxItems: 1 + + vout-voltage-divider: + description: | + If voltage divider presents at vout, the voltage at voltage sensor pin + will be scaled. The properties will convert the raw reading to a more + meaningful number if voltage divider presents. It has two numbers, + the first number is the output resistor, the second number is the total + resistance. Therefore, the adjusted vout is equal to + Vout = Vout * output_resistance / total resistance. + $ref: /schemas/types.yaml#/definitions/uint32-array + minItems: 2 + maxItems: 2 + +required: + - compatible + - reg + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + max20730@10 { + compatible = "maxim,max20730"; + reg = <0x10>; + vout-voltage-divider = <1000 2000>; // vout would be scaled to 0.5 + }; + };
Signature · 1 line
2.28.0.681.g6f77f65b4e-goog
Rob Herring
maintainerRe: [PATCH v3 1/2] dt-bindings: hwmon: max20730: adding device tree doc for max20730
Quoted 22 lines · Chu Lin
max20730 Integrated, Step-Down Switching Regulator with PMBus
Signed-off-by Chu Lin <[email protected]>--- .../bindings/hwmon/maxim,max20730.yaml | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/maxim,max20730.yamlDocumentation/devicetree/bindings/hwmon/maxim,max20730.yaml new file +8
-0@@ -0,0 +1,63 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- + +$id: http://devicetree.org/schemas/hwmon/maxim,max20730.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim max20730
Documentation/devicetree/bindings/hwmon/maxim,max20730.yaml line 18
Quoted 10 lines
Documentation/devicetree/bindings/hwmon/maxim,max20730.yaml new file +10
-0+ +maintainers: + - Jean Delvare <[email protected]> + - Guenter Roeck <[email protected]> + +description: | + The MAX20730 is a fully integrated, highly efficient switching regulator + with PMBus for applications operating from 4.5V to 16V and requiring + up to 25A (max) load. This single-chip regulator provides extremely + compact, highefficiency power-delivery solutions with high-precision
space ^
Documentation/devicetree/bindings/hwmon/maxim,max20730.yaml line 19
Quoted 1 line
Documentation/devicetree/bindings/hwmon/maxim,max20730.yaml new file +1
-0+ output voltages and excellent transient response
period needed
Quoted 11 lines
Documentation/devicetree/bindings/hwmon/maxim,max20730.yaml new file +11
-0+ + Datasheets: + https://datasheets.maximintegrated.com/en/ds/MAX20730.pdf + https://datasheets.maximintegrated.com/en/ds/MAX20734.pdf + https://datasheets.maximintegrated.com/en/ds/MAX20743.pdf + +properties: + compatible: + enum: + - maxim,max20730 + - maxim,max20734
Documentation/devicetree/bindings/hwmon/maxim,max20730.yaml line 40
Quoted 10 lines
Documentation/devicetree/bindings/hwmon/maxim,max20730.yaml new file +10
-0+ - maxim,max20743 + + reg: + maxItems: 1 + + vout-voltage-divider: + description: | + If voltage divider presents at vout, the voltage at voltage sensor pin + will be scaled. The properties will convert the raw reading to a more + meaningful number if voltage divider presents. It has two numbers,
s/presents/present/
Documentation/devicetree/bindings/hwmon/maxim,max20730.yaml line 50
Quoted 10 lines
Documentation/devicetree/bindings/hwmon/maxim,max20730.yaml new file +10
-0+ the first number is the output resistor, the second number is the total + resistance. Therefore, the adjusted vout is equal to + Vout = Vout * output_resistance / total resistance. + $ref: /schemas/types.yaml#/definitions/uint32-array + minItems: 2 + maxItems: 2 + +required: + - compatible + - reg
additionalProperties: false
Quoted 16 lines
Documentation/devicetree/bindings/hwmon/maxim,max20730.yaml new file +13
-0+ +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + max20730@10 { + compatible = "maxim,max20730"; + reg = <0x10>; + vout-voltage-divider = <1000 2000>; // vout would be scaled to 0.5 + }; + };Signature · 1 line
2.28.0.681.g6f77f65b4e-goog
PATCH v3 2/2 hwmon: pmbus: max20730: adjust the vout reading given voltage divider
In reply to Chu LinProblem:
We use voltage dividers so that the voltage presented at the voltage sense pins is confusing. We might need to convert these readings to more meaningful readings given the voltage divider.
Solution:
Read the voltage divider resistance from dts and convert the voltage reading to a more meaningful reading.
Testing:
max20730 with voltage divider
--- drivers/hwmon/pmbus/max20730.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/hwmon/pmbus/max20730.c +18 -0
@@ -31,6 +31,7 @@ struct max20730_data {struct pmbus_driver_info info;struct mutex lock;/* Used to protect against parallel writes */ u16 mfr_devset1; +u32 vout_voltage_divider[2 ]; };#define to_max20730_data (x) container_of(x, struct max20730_data, info)
@@ -114,6 +115,14 @@ static int max20730_read_word_data(struct i2c_client *client, int page, max_c = max_current[data->id][(data->mfr_devset1 >>5 ) &0x3 ]; ret =val_to_direct (max_c,PSC_CURRENT_OUT , info);break ; +case PMBUS_READ_VOUT : + ret =pmbus_read_word_data (client, page, phase, reg); +if (ret >0 && data->vout_voltage_divider[0 ] && data->vout_voltage_divider[1 ]) { +u64 temp =DIV_ROUND_CLOSEST_ULL ((u64 )ret * data->vout_voltage_divider[1 ], + data->vout_voltage_divider[0 ]); + ret =clamp_val (temp,0 ,0xffff ); + } +break ;default : ret = -ENODATA ;break ;
@@ -364,6 +373,15 @@ static int max20730_probe(struct i2c_client *client, data->id = chip_id;mutex_init (&data->lock);memcpy (&data->info, &max20730_info[chip_id],sizeof (data->info)); +if (of_property_read_u32_array (client->dev.of_node,"vout-voltage-divider" , + data->vout_voltage_divider, +ARRAY_SIZE (data->vout_voltage_divider)) !=0 ) +memset (data->vout_voltage_divider,0 ,sizeof (data->vout_voltage_divider)); +if (data->vout_voltage_divider[1 ] < data->vout_voltage_divider[0 ]) { +dev_err (dev, +"The total resistance of voltage divider is less than output resistance\n" ); +return -ENODEV ; + } ret =i2c_smbus_read_word_data (client,MAX20730_MFR_DEVSET1 );if (ret <0 )
Signature · 1 line
2.28.0.681.g6f77f65b4e-goog
Guenter Roeck
maintainerRe: [PATCH v3 2/2] hwmon: pmbus: max20730: adjust the vout reading given voltage divider
Quoted 9 lines · Chu Lin
Problem:
We use voltage dividers so that the voltage presented at the voltage sense pins is confusing. We might need to convert these readings to more meaningful readings given the voltage divider.Solution:
Read the voltage divider resistance from dts and convert the voltage reading to a more meaningful reading.
Quoted 5 lines
Testing:
max20730 with voltage dividerSigned-off-by Chu Lin <[email protected]>---
<Formletter>
Change log goes here. If it is missing, I won't know what changed. That means I will have to dig out older patch versions to compare. That costs time and will hold up both this patch as well as all other patches which I still have to review.
Please keep this in mind when submitting patch revisions without change log. </Formletter>
Worse, this is v3, and I had given v2 a Reviewed-by: tag which was dropped. This means I have to compare the two versions to figure out what changed, probably just to find out that nothing has changed since v2.
Patches like this are the reason why various patches won't make it into the next kernel release. Sorry, I just don't have as much time as people seem to think I have.
Guenter
Quoted 46 lines
drivers/hwmon/pmbus/max20730.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)drivers/hwmon/pmbus/max20730.c +18
-0@@ -31,6 +31,7 @@ struct max20730_data {struct pmbus_driver_info info;struct mutex lock;/* Used to protect against parallel writes */ u16 mfr_devset1; +u32 vout_voltage_divider[2 ]; };#define to_max20730_data (x) container_of(x, struct max20730_data, info)@@ -114,6 +115,14 @@ static int max20730_read_word_data(struct i2c_client *client, int page, max_c = max_current[data->id][(data->mfr_devset1 >>5 ) &0x3 ]; ret =val_to_direct (max_c,PSC_CURRENT_OUT , info);break ; +case PMBUS_READ_VOUT : + ret =pmbus_read_word_data (client, page, phase, reg); +if (ret >0 && data->vout_voltage_divider[0 ] && data->vout_voltage_divider[1 ]) { +u64 temp =DIV_ROUND_CLOSEST_ULL ((u64 )ret * data->vout_voltage_divider[1 ], + data->vout_voltage_divider[0 ]); + ret =clamp_val (temp,0 ,0xffff ); + } +break ;default : ret = -ENODATA ;break ;@@ -364,6 +373,15 @@ static int max20730_probe(struct i2c_client *client, data->id = chip_id;mutex_init (&data->lock);memcpy (&data->info, &max20730_info[chip_id],sizeof (data->info)); +if (of_property_read_u32_array (client->dev.of_node,"vout-voltage-divider" , + data->vout_voltage_divider, +ARRAY_SIZE (data->vout_voltage_divider)) !=0 ) +memset (data->vout_voltage_divider,0 ,sizeof (data->vout_voltage_divider)); +if (data->vout_voltage_divider[1 ] < data->vout_voltage_divider[0 ]) { +dev_err (dev, +"The total resistance of voltage divider is less than output resistance\n" ); +return -ENODEV ; + } ret =i2c_smbus_read_word_data (client,MAX20730_MFR_DEVSET1 );if (ret <0 )