dt-bindings: hwmon: pwm-fan: Document target-pwm property
Subsystems (2)
PATCH 1/2 dt-bindings: hwmon: pwm-fan: Document target-pwm property
Similar to target-rpm from fan-common.yaml but for the PWM setting (0..255).
--- Documentation/devicetree/bindings/hwmon/pwm-fan.yaml | 8 ++++++++ 1 file changed, 8 insertions(+)
Documentation/devicetree/bindings/hwmon/pwm-fan.yaml +8 -0
@@ -46,6 +46,14 @@ properties: "#cooling-cells": true + target-pwm: + description: + The default desired fan PWM. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 255 + default: 255 + required: - compatible - pwms
Signature · 1 line
2.39.2
PATCH 2/2 hwmon: (pwm-fan): support target-pwm property to set default PWM value
For some use cases defaulting the PWM to full fan speed is not ideal (noise, power consumption, ..), so support an optional target-pwm property (0..255) to override the default PWM value.
--- drivers/hwmon/pwm-fan.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/hwmon/pwm-fan.c +9 -2
@@ -482,6 +482,7 @@ static int pwm_fan_probe(struct platform_device *pdev)const struct hwmon_channel_info **channels;u32 *fan_channel_config;int channel_count =1 ;/* We always have a PWM channel. */ +u32 target_pwm =MAX_PWM ;int i; ctx =devm_kzalloc (dev,sizeof (*ctx),GFP_KERNEL );
@@ -527,11 +528,17 @@ static int pwm_fan_probe(struct platform_device *pdev) ctx->enable_mode = pwm_disable_reg_enable; +of_property_read_u32 (dev->of_node,"target-pwm" , &target_pwm); +if (target_pwm > (u32 )MAX_PWM ) { +dev_err (dev,"Invalid target-pwm: %u > %d\n" , target_pwm,MAX_PWM ); +return -EINVAL ; + } +/* -* Set duty cycle to maximum allowed and enable PWM output as well as +* Set duty cycle to target and enable PWM output as well as * the regulator. In case of error nothing is changed */ - ret =set_pwm (ctx,MAX_PWM ); + ret =set_pwm (ctx, target_pwm);if (ret) {dev_err (dev,"Failed to configure PWM: %d\n" , ret);return ret;
Signature · 1 line
2.39.2
Guenter Roeck
maintainerRe: [PATCH 2/2] hwmon: (pwm-fan): support target-pwm property to set default PWM value
Quoted 31 lines · Peter Korsgaard
For some use cases defaulting the PWM to full fan speed is not ideal (noise, power consumption, ..), so support an optional target-pwm property (0..255) to override the default PWM value.
Signed-off-by Peter Korsgaard <[email protected]>--- drivers/hwmon/pwm-fan.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)drivers/hwmon/pwm-fan.c +7
-0@@ -482,6 +482,7 @@ static int pwm_fan_probe(struct platform_device *pdev)const struct hwmon_channel_info **channels;u32 *fan_channel_config;int channel_count =1 ;/* We always have a PWM channel. */ +u32 target_pwm =MAX_PWM ;int i; ctx =devm_kzalloc (dev,sizeof (*ctx),GFP_KERNEL );@@ -527,11 +528,17 @@ static int pwm_fan_probe(struct platform_device *pdev) ctx->enable_mode = pwm_disable_reg_enable; +of_property_read_u32 (dev->of_node,"target-pwm" , &target_pwm); +if (target_pwm > (u32 )MAX_PWM ) { +dev_err (dev,"Invalid target-pwm: %u > %d\n" , target_pwm,MAX_PWM ); +return -EINVAL ; + } +
drivers/hwmon/pwm-fan.c static int pwm_fan_probe(struct platform_device *pdev) · line 544
Quoted 10 lines
drivers/hwmon/pwm-fan.c +2
-2/* -* Set duty cycle to maximum allowed and enable PWM output as well as +* Set duty cycle to target and enable PWM output as well as * the regulator. In case of error nothing is changed */ - ret =set_pwm (ctx,MAX_PWM ); + ret =set_pwm (ctx, target_pwm);if (ret) {dev_err (dev,"Failed to configure PWM: %d\n" , ret);return ret;
A much better name would be default-pwm for the property name. target-pwm is misleading and doesn't really make sense because there is no "target", just a value that is being set.
Guenter
Guenter Roeck
maintainerRe: [PATCH 2/2] hwmon: (pwm-fan): support target-pwm property to set default PWM value
In reply to Peter KorsgaardQuoted 22 lines · Peter Korsgaard
For some use cases defaulting the PWM to full fan speed is not ideal (noise, power consumption, ..), so support an optional target-pwm property (0..255) to override the default PWM value.
Signed-off-by Peter Korsgaard <[email protected]>--- drivers/hwmon/pwm-fan.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)drivers/hwmon/pwm-fan.c +1
-0@@ -482,6 +482,7 @@ static int pwm_fan_probe(struct platform_device *pdev)const struct hwmon_channel_info **channels;u32 *fan_channel_config;int channel_count =1 ;/* We always have a PWM channel. */ +u32 target_pwm =MAX_PWM ;int i; ctx =devm_kzalloc (dev,sizeof (*ctx),GFP_KERNEL );
drivers/hwmon/pwm-fan.c static int pwm_fan_probe(struct platform_device *pdev) · line 532
Quoted 5 lines
drivers/hwmon/pwm-fan.c +2
-0@@ -527,11 +528,17 @@ static int pwm_fan_probe(struct platform_device *pdev) ctx->enable_mode = pwm_disable_reg_enable; +of_property_read_u32 (dev->of_node,"target-pwm" , &target_pwm); +if (target_pwm > (u32 )MAX_PWM ) {
Unnecessary type cast.
Guenter
Quoted 14 lines
drivers/hwmon/pwm-fan.c +6
-2+dev_err (dev,"Invalid target-pwm: %u > %d\n" , target_pwm,MAX_PWM ); +return -EINVAL ; + } +/* -* Set duty cycle to maximum allowed and enable PWM output as well as +* Set duty cycle to target and enable PWM output as well as * the regulator. In case of error nothing is changed */ - ret =set_pwm (ctx,MAX_PWM ); + ret =set_pwm (ctx, target_pwm);if (ret) {dev_err (dev,"Failed to configure PWM: %d\n" , ret);return ret;
Guenter Roeck
maintainerQuoted 13 lines · Peter Korsgaard
Similar to target-rpm from
fan-common.yamlbut for the PWM setting (0..255).Signed-off-by Peter Korsgaard <[email protected]>--- Documentation/devicetree/bindings/hwmon/pwm-fan.yaml | 8 ++++++++ 1 file changed, 8 insertions(+)Documentation/devicetree/bindings/hwmon/pwm-fan.yaml +0
-0
Documentation/devicetree/bindings/hwmon/pwm-fan.yaml properties: · line 51
Quoted 6 lines
Documentation/devicetree/bindings/hwmon/pwm-fan.yaml +3
-0@@ -46,6 +46,14 @@ properties: "#cooling-cells": true + target-pwm: + description: + The default desired fan PWM.
Unlike target-rpm, there is no "desired" here. If this is the default pwm, to be set, name and describe it accordingly.
Guenter
Quoted 8 lines
Documentation/devicetree/bindings/hwmon/pwm-fan.yaml +5
-0+ $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 255 + default: 255 + required: - compatible - pwms
Quoted 9 lines · Guenter Roeck
Quoted 8 lines · Peter Korsgaard
Similar to target-rpm from
fan-common.yamlbut for the PWM setting (0..255).Signed-off-by Peter Korsgaard <[email protected]>---
Documentation/devicetree/bindings/hwmon/pwm-fan.yaml| 8 ++++++++1 file changed, 8 insertions(+)
Quoted 12 lines
Quoted 9 lines
Documentation/devicetree/bindings/hwmon/pwm-fan.yaml +0
-0@@ -46,6 +46,14 @@ properties:"#cooling-cells": true
+ target-pwm:
+ description:
+ The default desired fan PWM.Unlike target-rpm, there is no "desired" here. If this is the default pwm, to be set, name and describe it accordingly.
OK, I will rename to default-pwm and send a v2 - Thanks.
Signature · 1 line
Bye, Peter Korsgaard
Rob Herring
maintainerQuoted 2 lines · Peter Korsgaard
Similar to target-rpm from
fan-common.yamlbut for the PWM setting (0..255).
IIRC, we have a map of RPMs to PWM duty cycle, so why can't you use that plus target-rpm?
Anything new for existing fan bindings should ideally use what fan-common.yaml defined or be added to it.
Quoted 28 lines
Signed-off-by Peter Korsgaard <[email protected]>--- Documentation/devicetree/bindings/hwmon/pwm-fan.yaml | 8 ++++++++ 1 file changed, 8 insertions(+)Documentation/devicetree/bindings/hwmon/pwm-fan.yaml +8
-0@@ -46,6 +46,14 @@ properties: "#cooling-cells": true + target-pwm: + description: + The default desired fan PWM. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 255 + default: 255 + required: - compatible - pwmsSignature · 1 line
2.39.2
Guenter Roeck
maintainerQuoted 7 lines · Rob Herring
Quoted 2 lines · Peter Korsgaard
Similar to target-rpm from
fan-common.yamlbut for the PWM setting (0..255).IIRC, we have a map of RPMs to PWM duty cycle, so why can't you use that plus target-rpm?
target-rpm is the target fan speed. The property defined here is the default pwm to set when the device is instantiated.
The two values are also orthogonal. The fan rpm is fan dependent. Each fan will require a different pwm value to reach the target speed. Trying to use target-rpm to set a default pwm value would really not make much if any sense.
Guenter
Quoted 31 lines
Anything new for existing fan bindings should ideally use what
fan-common.yamldefined or be added to it.Quoted 28 lines
Signed-off-by Peter Korsgaard <[email protected]>--- Documentation/devicetree/bindings/hwmon/pwm-fan.yaml | 8 ++++++++ 1 file changed, 8 insertions(+)Documentation/devicetree/bindings/hwmon/pwm-fan.yaml +8
-0@@ -46,6 +46,14 @@ properties: "#cooling-cells": true + target-pwm: + description: + The default desired fan PWM. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 255 + default: 255 + required: - compatible - pwmsSignature · 1 line
2.39.2