devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] dt-bindings: hwmon: pwm-fan: Document default-pwm property
@ 2024-04-24 20:24 Peter Korsgaard
  2024-04-24 20:24 ` [PATCH v2 2/2] hwmon: (pwm-fan): support default-pwm property to set default PWM value Peter Korsgaard
  2024-04-25 16:18 ` [PATCH v2 1/2] dt-bindings: hwmon: pwm-fan: Document default-pwm property Rob Herring
  0 siblings, 2 replies; 4+ messages in thread
From: Peter Korsgaard @ 2024-04-24 20:24 UTC (permalink / raw)
  To: linux-hwmon, devicetree, Guenter Roeck
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Peter Korsgaard

Similar to target-rpm from fan-common.yaml but for the default PWM setting
(0..255).

Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
---
Changes since v1:
- Rename to default-pwm

 Documentation/devicetree/bindings/hwmon/pwm-fan.yaml | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.yaml b/Documentation/devicetree/bindings/hwmon/pwm-fan.yaml
index 4e5abf7580cc..70f062b30985 100644
--- a/Documentation/devicetree/bindings/hwmon/pwm-fan.yaml
+++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.yaml
@@ -46,6 +46,14 @@ properties:
 
   "#cooling-cells": true
 
+  default-pwm:
+    description:
+      The default fan PWM to use.
+    $ref: /schemas/types.yaml#/definitions/uint32
+    minimum: 0
+    maximum: 255
+    default: 255
+
 required:
   - compatible
   - pwms
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] hwmon: (pwm-fan): support default-pwm property to set default PWM value
  2024-04-24 20:24 [PATCH v2 1/2] dt-bindings: hwmon: pwm-fan: Document default-pwm property Peter Korsgaard
@ 2024-04-24 20:24 ` Peter Korsgaard
  2024-04-25 16:18 ` [PATCH v2 1/2] dt-bindings: hwmon: pwm-fan: Document default-pwm property Rob Herring
  1 sibling, 0 replies; 4+ messages in thread
From: Peter Korsgaard @ 2024-04-24 20:24 UTC (permalink / raw)
  To: linux-hwmon, devicetree, Guenter Roeck
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Peter Korsgaard

For some use cases defaulting the PWM to full fan speed is not ideal
(noise, power consumption, ..), so support an optional default-pwm
property (0..255) to override the default PWM value.

Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
---
Changes since v1:
- Rename property to default-pwm
- Drop u32 cast

 drivers/hwmon/pwm-fan.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index b67bc9e833c0..a2a309f8e3ee 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -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 default_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, "default-pwm", &default_pwm);
+	if (default_pwm > MAX_PWM) {
+		dev_err(dev, "Invalid default-pwm: %u > %d\n", default_pwm, MAX_PWM);
+		return -EINVAL;
+	}
+
 	/*
-	 * Set duty cycle to maximum allowed and enable PWM output as well as
+	 * Set duty cycle to default 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, default_pwm);
 	if (ret) {
 		dev_err(dev, "Failed to configure PWM: %d\n", ret);
 		return ret;
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/2] dt-bindings: hwmon: pwm-fan: Document default-pwm property
  2024-04-24 20:24 [PATCH v2 1/2] dt-bindings: hwmon: pwm-fan: Document default-pwm property Peter Korsgaard
  2024-04-24 20:24 ` [PATCH v2 2/2] hwmon: (pwm-fan): support default-pwm property to set default PWM value Peter Korsgaard
@ 2024-04-25 16:18 ` Rob Herring
  2024-04-25 20:21   ` Peter Korsgaard
  1 sibling, 1 reply; 4+ messages in thread
From: Rob Herring @ 2024-04-25 16:18 UTC (permalink / raw)
  To: Peter Korsgaard
  Cc: linux-hwmon, devicetree, Guenter Roeck, Krzysztof Kozlowski,
	Conor Dooley

On Wed, Apr 24, 2024 at 10:24:47PM +0200, Peter Korsgaard wrote:
> Similar to target-rpm from fan-common.yaml but for the default PWM setting
> (0..255).
> 
> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
> ---
> Changes since v1:
> - Rename to default-pwm
> 
>  Documentation/devicetree/bindings/hwmon/pwm-fan.yaml | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.yaml b/Documentation/devicetree/bindings/hwmon/pwm-fan.yaml
> index 4e5abf7580cc..70f062b30985 100644
> --- a/Documentation/devicetree/bindings/hwmon/pwm-fan.yaml
> +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.yaml
> @@ -46,6 +46,14 @@ properties:
>  
>    "#cooling-cells": true
>  
> +  default-pwm:
> +    description:
> +      The default fan PWM to use.
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    minimum: 0
> +    maximum: 255
> +    default: 255

See my comments on v1. Please give time for other reviewers a chance to 
comment.

Rob

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/2] dt-bindings: hwmon: pwm-fan: Document default-pwm property
  2024-04-25 16:18 ` [PATCH v2 1/2] dt-bindings: hwmon: pwm-fan: Document default-pwm property Rob Herring
@ 2024-04-25 20:21   ` Peter Korsgaard
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Korsgaard @ 2024-04-25 20:21 UTC (permalink / raw)
  To: Rob Herring
  Cc: linux-hwmon, devicetree, Guenter Roeck, Krzysztof Kozlowski,
	Conor Dooley

On 4/25/24 18:18, Rob Herring wrote:
> On Wed, Apr 24, 2024 at 10:24:47PM +0200, Peter Korsgaard wrote:
>> Similar to target-rpm from fan-common.yaml but for the default PWM setting
>> (0..255).
>>
>> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
>> ---
>> Changes since v1:
>> - Rename to default-pwm
>>
>>   Documentation/devicetree/bindings/hwmon/pwm-fan.yaml | 8 ++++++++
>>   1 file changed, 8 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.yaml b/Documentation/devicetree/bindings/hwmon/pwm-fan.yaml
>> index 4e5abf7580cc..70f062b30985 100644
>> --- a/Documentation/devicetree/bindings/hwmon/pwm-fan.yaml
>> +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.yaml
>> @@ -46,6 +46,14 @@ properties:
>>   
>>     "#cooling-cells": true
>>   
>> +  default-pwm:
>> +    description:
>> +      The default fan PWM to use.
>> +    $ref: /schemas/types.yaml#/definitions/uint32
>> +    minimum: 0
>> +    maximum: 255
>> +    default: 255
> 
> See my comments on v1. Please give time for other reviewers a chance to
> comment.

Sorry. As far as I can see, Guenter explained why we cannot generically 
translate between a default PWM value and RPM.

Do you still want to move this default-pwm property to fan-common.yaml? 
If so, I can send a v3 doing that.

-- 
Bye, Peter Korsgaard


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-04-25 20:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-24 20:24 [PATCH v2 1/2] dt-bindings: hwmon: pwm-fan: Document default-pwm property Peter Korsgaard
2024-04-24 20:24 ` [PATCH v2 2/2] hwmon: (pwm-fan): support default-pwm property to set default PWM value Peter Korsgaard
2024-04-25 16:18 ` [PATCH v2 1/2] dt-bindings: hwmon: pwm-fan: Document default-pwm property Rob Herring
2024-04-25 20:21   ` Peter Korsgaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).