hwmon: adt7475: Implement support for #pwm-cells = <3>
cover hwmon: adt7475: Implement support for #pwm-cells = <3>
Hello,
this patch series implements support for #pwm-cells = <3> and updates the
binding accordingly. 3 cells is the usual PWM binding as was discussed in
https://lore.kernel.org/linux-hwmon/jmxmxzzfyobuheqe75lj7qcq5rlt625wddb3rlhiernunjdodu@tgxghvfef4tl .
Best regards
Uwe
Uwe Kleine-König (2):
hwmon: adt7475: Implement support for #pwm-cells = <3>
dt-bindings: hwmon: adt7475: Allow and recommend #pwm-cells = <3>
.../devicetree/bindings/hwmon/adt7475.yaml | 15 ++++++++------ drivers/hwmon/adt7475.c | 20 ++++++++++++++++--- 2 files changed, 26 insertions(+), 9 deletions(-)
base-commit: 4325743c7e209ae7845293679a4de94b969f2bef
Signature · 1 line
2.49.0
PATCH 1/2 hwmon: adt7475: Implement support for #pwm-cells = <3>
The adt7475 driver and binding are outliers requiring 4 pwm-cells. The typical value is 3, there are a few devices that use a lesser value for historical reasons, no other uses a value bigger than 3.
Implement support for 3 cells to make the adt7475 binding match the usual PWM binding.
--- drivers/hwmon/adt7475.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
drivers/hwmon/adt7475.c +17 -3
@@ -1704,12 +1704,15 @@ static int adt7475_pwm_properties_parse_reference_args(struct fwnode_handle *fwnif (ret)return ret; -if (rargs.nargs !=4 ) { +if (rargs.nargs !=3 && rargs.nargs !=4 ) {fwnode_handle_put (rargs.fwnode);return -EINVAL ; } -for (i =0 ; i <4 ; i++) +/* Let duty_cycle default to period */ + args[3 ] = rargs.args[1 ]; + +for (i =0 ; i < rargs.nargs; i++) args[i] = rargs.args[i]; ret =_adt7475_pwm_properties_parse_args (args, cfg);
@@ -1724,11 +1727,22 @@ static int adt7475_pwm_properties_parse_args(struct fwnode_handle *fwnode, {int ret;u32 args[4 ] = {}; +size_t n_vals =fwnode_property_count_u32 (fwnode,"pwms" ); - ret =fwnode_property_read_u32_array (fwnode,"pwms" , args,ARRAY_SIZE (args)); +if (n_vals !=3 && n_vals !=4 ) +return -EOVERFLOW ; + + ret =fwnode_property_read_u32_array (fwnode,"pwms" , args, n_vals);if (ret)return ret; +/* +* If there are no item to define the duty_cycle, default it to the +* period. +*/ +if (n_vals ==3 ) + args[3 ] = args[1 ]; +return _adt7475_pwm_properties_parse_args (args, cfg); }
Signature · 1 line
2.49.0
Quoted 8 lines · Uwe Kleine-König
The adt7475 driver and binding are outliers requiring 4 pwm-cells. The typical value is 3, there are a few devices that use a lesser value for historical reasons, no other uses a value bigger than 3.
Implement support for 3 cells to make the adt7475 binding match the usual PWM binding.
Signed-off-by Uwe Kleine-König <[email protected]>
Applied.
Guenter
PATCH 2/2 dt-bindings: hwmon: adt7475: Allow and recommend #pwm-cells = <3>
In reply to Uwe Kleine-KönigTo make this binding match what is usally used for PWMs, deprecate 4 cells and allow 3 instead.
--- .../devicetree/bindings/hwmon/adt7475.yaml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
Documentation/devicetree/bindings/hwmon/adt7475.yaml +9 -6
@@ -53,7 +53,10 @@ properties: default: 1 "#pwm-cells": - const: 4 + oneOf: + - const: 3 + - const: 4 + deprecated: true description: | Number of cells in a PWM specifier. - 0: The PWM channel
@@ -68,7 +71,7 @@ properties: - 11363636 (88 Hz) - 44444 (22 kHz) - 2: PWM flags 0 or PWM_POLARITY_INVERTED - - 3: The default PWM duty cycle in nanoseconds + - 3: The default PWM duty cycle in nanoseconds, defaults to period. patternProperties: "^adi,bypass-attenuator-in[0-4]$":
@@ -124,15 +127,15 @@ examples: adi,bypass-attenuator-in1 = <0>; adi,pin10-function = "smbalert#"; adi,pin14-function = "tach4"; - #pwm-cells = <4>; + #pwm-cells = <3>; - /* PWMs at 22.5 kHz frequency, 50% duty*/ + /* PWMs at 22.5 kHz frequency */ fan-0 { - pwms = <&pwm 0 44444 0 22222>; + pwms = <&pwm 0 44444 0>; }; fan-1 { - pwms = <&pwm 2 44444 0 22222>; + pwms = <&pwm 2 44444 0>; }; }; };
Signature · 1 line
2.49.0
Re: [PATCH 2/2] dt-bindings: hwmon: adt7475: Allow and recommend #pwm-cells = <3>
Quoted 8 lines · Uwe Kleine-König
To make this binding match what is usally used for PWMs, deprecate 4 cells and allow 3 instead.
Signed-off-by Uwe Kleine-König <[email protected]>--- .../devicetree/bindings/hwmon/adt7475.yaml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
Re: [PATCH 2/2] dt-bindings: hwmon: adt7475: Allow and recommend #pwm-cells = <3>
In reply to Uwe Kleine-KönigQuoted 5 lines · Uwe Kleine-König
To make this binding match what is usally used for PWMs, deprecate 4 cells and allow 3 instead.
Signed-off-by Uwe Kleine-König <[email protected]>Reviewed-by Rob Herring (Arm) <[email protected]>
Applied.
Guenter