Skip to contentSkip to conversation

dt-bindings: hwmon: pwm-fan: Document default-pwm property

PATCH In review Peter Korsgaard 3 participants 10 messages Jan 2, 2025 – Jan 3, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 dt-bindings: hwmon: pwm-fan: Document default-pwm property

The pwm-fan driver uses full PWM (255) duty cycle at startup, which may not always be desirable because of noise or power consumption peaks, so add an optional "default-pwm" property that can be used to specify a custom default PWM duty cycle.

---
 Documentation/devicetree/bindings/hwmon/pwm-fan.yaml | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/devicetree/bindings/hwmon/pwm-fan.yaml +7 -0
index 8b4ed5ee962f..83b8b0b964ee 100644
@@ -20,6 +20,12 @@ properties:
     items:
       maximum: 255
 
+  default-pwm:
+    description: Default PWM duty cycle value to use at startup
+    minimum: 0
+    maximum: 255
+    default: 255
+
   fan-supply:
     description: Phandle to the regulator that provides power to the fan.
 
@@ -100,6 +106,7 @@ examples:
     pwm-fan {
       compatible = "pwm-fan";
       pwms = <&pwm 0 40000 0>;
+      default-pwm = 75;
       fan-supply = <&reg_fan>;
       interrupt-parent = <&gpio5>;
       interrupts = <1 IRQ_TYPE_EDGE_FALLING>;
Signature · 1 line
2.39.5
#1 lore raw

PATCH 2/2 hwmon: (pwm-fan): Make default PWM duty cycle configurable

The pwm-fan driver uses full PWM (255) duty cycle at startup, which may not always be desirable because of noise or power consumption peaks, so support an optional "default-pwm" property that can be used to specify the default PWM duty cycle.

---
 drivers/hwmon/pwm-fan.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/hwmon/pwm-fan.c +7 -2
index 53a1a968d00d..09e9047635f7 100644
@@ -499,6 +499,7 @@ static int pwm_fan_probe(struct platform_device *pdev)
 	const struct hwmon_channel_info **channels;
 	u32 pwm_min_from_stopped = 0;
 	u32 *fan_channel_config;
+	u32 default_pwm;
 	int channel_count = 1;	/* We always have a PWM channel. */
 	int i;
 
@@ -545,11 +546,15 @@ static int pwm_fan_probe(struct platform_device *pdev)
 
 	ctx->enable_mode = pwm_disable_reg_enable;
 
+	ret = device_property_read_u32(dev, "default-pwm", &default_pwm);
+	if (ret)
+		default_pwm = MAX_PWM;
+
 	/*
-	 * 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;
Signature · 1 line
2.39.5
#2 lore raw
In reply to Peter Korsgaard
Quoted 6 lines · Peter Korsgaard

The pwm-fan driver uses full PWM (255) duty cycle at startup, which may not always be desirable because of noise or power consumption peaks, so add an optional "default-pwm" property that can be used to specify a custom default PWM duty cycle.

That's v3, not v1. Also mention here shortly how Rob's comment is addressed.

Please always handle reviewers' feedback, either by implementing it or by responding or by extending commit msg. All this is missing in all your versions you sent.

Best regards,
Krzysztof

#3 lore raw
Quoted 9 lines · Krzysztof Kozlowski
Quoted 6 lines · Peter Korsgaard

The pwm-fan driver uses full PWM (255) duty cycle at startup, which may not always be desirable because of noise or power consumption peaks, so add an optional "default-pwm" property that can be used to specify a custom default PWM duty cycle.

That's v3, not v1. Also mention here shortly how Rob's comment is addressed.

It is? Then that wasn't from me, and I don't right away see anything related on lore. Can you give me a pointer?

Signature · 1 line
Bye, Peter Korsgaard
#4 lore raw
Quoted 7 lines · Peter Korsgaard
Quoted 6 lines · Krzysztof Kozlowski
Quoted 5 lines · Peter Korsgaard

The pwm-fan driver uses full PWM (255) duty cycle at startup, which may not always be desirable because of noise or power consumption peaks, so add an optional "default-pwm" property that can be used to specify a custom default PWM duty cycle.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

That's v3, not v1. Also mention here shortly how Rob's comment is addressed.

It is? Then that wasn't from me, and I don't right away see anything related on lore. Can you give me a pointer?

It is trivial to find your v1 and v2 in lore, so I assume you just reply here to waste my time.

Best regards,
Krzysztof

#5 lore raw
Quoted 10 lines · Krzysztof Kozlowski
Quoted 9 lines · Peter Korsgaard
Quoted 8 lines · Krzysztof Kozlowski
Quoted 6 lines · Peter Korsgaard

The pwm-fan driver uses full PWM (255) duty cycle at startup, which may not always be desirable because of noise or power consumption peaks, so add an optional "default-pwm" property that can be used to specify a custom default PWM duty cycle.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

That's v3, not v1. Also mention here shortly how Rob's comment is addressed.

It is? Then that wasn't from me, and I don't right away see anything related on lore. Can you give me a pointer?

It is trivial to find your v1 and v2 in lore, so I assume you just reply here to waste my time.

Sorry, I indeed apparently did send a v1/v2 ~1 year ago, I must be getting old. I didn't look that far back in lore and for some reason I don't have the changes in my local tree anymore, hence the reason for recreating the commits yesterday and sending a new v1.

Looking at lore, v1 used target-pwm which Gunter suggested I changed to default-rpm while explaining that it cannot be a generic property:

https://lore.kernel.org/linux-devicetree/[email protected]/

Which I then did as a v2, that then didn't get any additional feedback:

https://lore.kernel.org/linux-devicetree/[email protected]/

So if we agree on default-pwm, then I can send an update (a v4!) with the typo in the example fixed, OK?

Signature · 1 line
Bye, Peter Korsgaard
#6 lore raw
Quoted 4 lines · Peter Korsgaard

Looking at lore, v1 used target-pwm which Gunter suggested I changed to default-rpm while explaining that it cannot be a generic property:

Quoted 8 lines

https://lore.kernel.org/linux-devicetree/[email protected]/

Which I then did as a v2, that then didn't get any additional feedback:

https://lore.kernel.org/linux-devicetree/[email protected]/

So if we agree on default-pwm, then I can send an update (a v4!) with the typo in the example fixed, OK?

Yes and we go back to my first comment about commit msg:

"Also mention here shortly how Rob's comment is addressed."

e.g. we cannot use default/target-rpm because of foo bar.

Best regards,
Krzysztof

#7 lore raw
Quoted 8 lines · Krzysztof Kozlowski
Quoted 2 lines

So if we agree on default-pwm, then I can send an update (a v4!) with the typo in the example fixed, OK?

Yes and we go back to my first comment about commit msg:

"Also mention here shortly how Rob's comment is addressed."

e.g. we cannot use default/target-rpm because of foo bar.

OK, I'll extend the commit message and send a v4.

Signature · 1 line
Bye, Peter Korsgaard
#8 lore raw
In reply to Peter Korsgaard
Quoted 10 lines · Peter Korsgaard

The pwm-fan driver uses full PWM (255) duty cycle at startup, which may not always be desirable because of noise or power consumption peaks, so add an optional "default-pwm" property that can be used to specify a custom default PWM duty cycle.

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

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/hwmon/pwm-fan.yaml: default-pwm: missing type definition
Error: Documentation/devicetree/bindings/hwmon/pwm-fan.example.dts:75.25-27 syntax error
FATAL ERROR: Unable to parse input tree
make[2]: *** [scripts/Makefile.dtbs:131: Documentation/devicetree/bindings/hwmon/pwm-fan.example.dtb] Error 1 make[2]: *** Waiting for unfinished jobs....
make[1]: *** [/builds/robherring/dt-review-ci/linux/Makefile:1506: dt_binding_check] Error 2
make: *** [Makefile:251: __sub-make] Error 2

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]

The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.

#9 lore raw
Quoted 17 lines · Rob Herring (Arm)
Quoted 10 lines · Peter Korsgaard

The pwm-fan driver uses full PWM (255) duty cycle at startup, which may not always be desirable because of noise or power consumption peaks, so add an optional "default-pwm" property that can be used to specify a custom default PWM duty cycle.

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

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

Quoted 8 lines

dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/hwmon/pwm-fan.yaml: default-pwm: missing type definition
Error: Documentation/devicetree/bindings/hwmon/pwm-fan.example.dts:75.25-27 syntax error
FATAL ERROR: Unable to parse input tree
make[2]: *** [scripts/Makefile.dtbs:131: Documentation/devicetree/bindings/hwmon/pwm-fan.example.dtb] Error 1 make[2]: *** Waiting for unfinished jobs....
make[1]: *** [/builds/robherring/dt-review-ci/linux/Makefile:1506: dt_binding_check] Error 2
make: *** [Makefile:251: __sub-make] Error 2

Ups, I added the entry to the example AFTER running make dt_binding_check and missed the <>, will fix.

Signature · 1 line
Bye, Peter Korsgaard