Add JHB100 Fan-Tach support
Subsystems (3)
v4 cover Add JHB100 Fan-Tach support
StarFive Fan-Tach controller can support up to 16 fan tach input. The series has been tested on the EVB1 board.
Change since v3:
PATCH 2:
- writing 0 to INT_EN before touching the STATUS and requesting the IRQ.
v3: https://lore.kernel.org/all/[email protected]/
v2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/
Changhuang Liang (2):
dt-bindings: hwmon: Add starfive,jhb100-fan-tach
hwmon: (starfive-fan-tach) Add fan tach driver for StarFive JHB100
.../hwmon/starfive,jhb100-fan-tach.yaml | 93 +++ Documentation/hwmon/index.rst | 1 + Documentation/hwmon/starfive-fan-tach.rst | 38 ++ MAINTAINERS | 8 + drivers/hwmon/Kconfig | 14 + drivers/hwmon/Makefile | 1 + drivers/hwmon/starfive-fan-tach.c | 542 ++++++++++++++++++ 7 files changed, 697 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yaml create mode 100644 Documentation/hwmon/starfive-fan-tach.rst create mode 100644 drivers/hwmon/starfive-fan-tach.c
--
2.25.1
PATCH v4 1/2 dt-bindings: hwmon: Add starfive,jhb100-fan-tach
Add compatible "starfive,jhb100-fan-tach" for StarFive JHB100 Fan-Tach controller.
--- .../hwmon/starfive,jhb100-fan-tach.yaml | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yaml
Documentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yaml new file +93 -0
@@ -0,0 +1,93 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/hwmon/starfive,jhb100-fan-tach.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: StarFive JHB100 Fan-Tach controller + +maintainers: + - Changhuang Liang <[email protected]> + +description: + The StarFive Fan-Tach controller can support up to 16 fan tach input. + +properties: + compatible: + enum: + - starfive,jhb100-fan-tach + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + resets: + maxItems: 1 + + interrupts: + maxItems: 1 + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + +patternProperties: + "^fan@[0-9a-f]+$": + $ref: fan-common.yaml# + unevaluatedProperties: false + + properties: + reg: + description: + PWM channel index. The driver allows two fans to share the same + PWM channel, or each fan to use a dedicated channel. + maximum: 15 + + tach-ch: + description: + The tachometer channel(s) wired to the fan(s) driven by this PWM + channel. Integer values in the range 0-15. + minItems: 1 + maxItems: 2 + items: + maximum: 15 + + required: + - reg + - tach-ch + +required: + - compatible + - reg + - clocks + - resets + - interrupts + +additionalProperties: false + +examples: + - | + fan-controller@11be0000 { + compatible = "starfive,jhb100-fan-tach"; + reg = <0x11be0000 0x400>; + interrupts = <128>; + clocks = <&per2crg 33>; + resets = <&per2crg 5>; + #address-cells = <1>; + #size-cells = <0>; + + fan@0 { + reg = <0x0>; + tach-ch = /bits/ 8 <0x0 0x8>; + pulses-per-revolution = <2>; + }; + fan@1 { + reg = <0x1>; + tach-ch = /bits/ 8 <0x1>; + pulses-per-revolution = <2>; + }; + };
Signature · 1 line
2.25.1
[email protected]
AI reviewRe: [PATCH v4 1/2] dt-bindings: hwmon: Add starfive,jhb100-fan-tach
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 4 lines
Add compatible "starfive,jhb100-fan-tach" for StarFive JHB100 Fan-Tach controller.
Signed-off-by Changhuang Liang <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH v4 1/2] dt-bindings: hwmon: Add starfive,jhb100-fan-tach
In reply to Changhuang LiangQuoted 52 lines · Changhuang Liang
Add compatible "starfive,jhb100-fan-tach" for StarFive JHB100 Fan-Tach controller.
Signed-off-by Changhuang Liang <[email protected]>--- .../hwmon/starfive,jhb100-fan-tach.yaml | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yamlDocumentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yaml new file +37
-0@@ -0,0 +1,93 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/hwmon/starfive,jhb100-fan-tach.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: StarFive JHB100 Fan-Tach controller + +maintainers: + - Changhuang Liang <[email protected]> + +description: + The StarFive Fan-Tach controller can support up to 16 fan tach input. + +properties: + compatible: + enum: + - starfive,jhb100-fan-tach + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + resets: + maxItems: 1 + + interrupts: + maxItems: 1 + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 +
Documentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yaml line 47
Quoted 10 lines
Documentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yaml new file +10
-0+patternProperties: + "^fan@[0-9a-f]+$": + $ref: fan-common.yaml# + unevaluatedProperties: false + + properties: + reg: + description: + PWM channel index. The driver allows two fans to share the same + PWM channel, or each fan to use a dedicated channel.
Doesn't matter what the driver can do, the description should describe what the hardware supports.
pw-bot: changes-requested
Does this fan-tach controller provide the PWMs?
If so (although Guenter may correct me), I think the fan-tach controller needs to be.
If you don't do that, I think you're going to run into problems with having multiple nodes with the same unit address when two fans share a pwm?
I think what you're supposed to do is drop "reg" and replace it with "pwms", but once again Guenter may correct me there.
e.g. aspeed,g6-pwm-tach.yaml
Cheers,
Conor.
Quoted 49 lines
Documentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yaml new file +46
-0+ maximum: 15 + + tach-ch: + description: + The tachometer channel(s) wired to the fan(s) driven by this PWM + channel. Integer values in the range 0-15. + minItems: 1 + maxItems: 2 + items: + maximum: 15 + + required: + - reg + - tach-ch + +required: + - compatible + - reg + - clocks + - resets + - interrupts + +additionalProperties: false + +examples: + - | + fan-controller@11be0000 { + compatible = "starfive,jhb100-fan-tach"; + reg = <0x11be0000 0x400>; + interrupts = <128>; + clocks = <&per2crg 33>; + resets = <&per2crg 5>; + #address-cells = <1>; + #size-cells = <0>; + + fan@0 { + reg = <0x0>; + tach-ch = /bits/ 8 <0x0 0x8>; + pulses-per-revolution = <2>; + }; + fan@1 { + reg = <0x1>; + tach-ch = /bits/ 8 <0x1>; + pulses-per-revolution = <2>; + }; + };Signature · 1 line
2.25.1
Guenter Roeck
maintainerRe: [PATCH v4 1/2] dt-bindings: hwmon: Add starfive,jhb100-fan-tach
Quoted 68 lines · Conor Dooley
Quoted 52 lines · Changhuang Liang
Add compatible "starfive,jhb100-fan-tach" for StarFive JHB100 Fan-Tach controller.
Signed-off-by Changhuang Liang <[email protected]>--- .../hwmon/starfive,jhb100-fan-tach.yaml | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+)create mode 100644
Documentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yamlDocumentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yaml new file +37
-0@@ -0,0 +1,93 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/hwmon/starfive,jhb100-fan-tach.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: StarFive JHB100 Fan-Tach controller + +maintainers: + - Changhuang Liang <[email protected]> + +description: + The StarFive Fan-Tach controller can support up to 16 fan tach input. + +properties: + compatible: + enum: + - starfive,jhb100-fan-tach + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + resets: + maxItems: 1 + + interrupts: + maxItems: 1 + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 +Documentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yaml line 47
Quoted 10 lines
Documentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yaml new file +10
-0+patternProperties: + "^fan@[0-9a-f]+$": + $ref: fan-common.yaml# + unevaluatedProperties: false + + properties: + reg: + description: + PWM channel index. The driver allows two fans to share the same + PWM channel, or each fan to use a dedicated channel.Doesn't matter what the driver can do, the description should describe what the hardware supports.
pw-bot: changes-requested
Quoted 8 lines
Does this fan-tach controller provide the PWMs?
If so (although Guenter may correct me), I think the fan-tach controller needs to be.If you don't do that, I think you're going to run into problems with having multiple nodes with the same unit address when two fans share a pwm?
Depends on how the controller works. Normally fan controllers have a feedback mechanism which can be either temperature -> pwm output or fan speed -> pwm output. I don't know how this controller works, specifically if the fan speed inputs are internally associated with pwm outputs or if they are completely independent of each other. If it is the latter, aspeed,g6-pwm-tach.yaml would probably be a good baseline.
Quoted 4 lines
I think what you're supposed to do is drop "reg" and replace it with "pwms", but once again Guenter may correct me there.
e.g. aspeed,g6-pwm-tach.yaml
Sorry, when it comes to devicetree properties, I am completely clueless. Usually the devicetree and pwm maintainers insist that all fan controllers are modeled as pwm controllers because they have pwm outputs. My approach is "use whatever bindings are acceptable by DT maintainers".
Guenter
Quoted 52 lines
Cheers,
Conor.Quoted 49 lines
Documentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yaml new file +46
-0+ maximum: 15 + + tach-ch: + description: + The tachometer channel(s) wired to the fan(s) driven by this PWM + channel. Integer values in the range 0-15. + minItems: 1 + maxItems: 2 + items: + maximum: 15 + + required: + - reg + - tach-ch + +required: + - compatible + - reg + - clocks + - resets + - interrupts + +additionalProperties: false + +examples: + - | + fan-controller@11be0000 { + compatible = "starfive,jhb100-fan-tach"; + reg = <0x11be0000 0x400>; + interrupts = <128>; + clocks = <&per2crg 33>; + resets = <&per2crg 5>; + #address-cells = <1>; + #size-cells = <0>; + + fan@0 { + reg = <0x0>; + tach-ch = /bits/ 8 <0x0 0x8>; + pulses-per-revolution = <2>; + }; + fan@1 { + reg = <0x1>; + tach-ch = /bits/ 8 <0x1>; + pulses-per-revolution = <2>; + }; + };Signature · 1 line
2.25.1
Re: [PATCH v4 1/2] dt-bindings: hwmon: Add starfive,jhb100-fan-tach
Quoted 78 lines · Guenter Roeck
Quoted 68 lines · Conor Dooley
Quoted 52 lines · Changhuang Liang
Add compatible "starfive,jhb100-fan-tach" for StarFive JHB100 Fan-Tach controller.
Signed-off-by Changhuang Liang <[email protected]>--- .../hwmon/starfive,jhb100-fan-tach.yaml | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+)create mode 100644
Documentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yamlDocumentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yaml new file +37
-0@@ -0,0 +1,93 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/hwmon/starfive,jhb100-fan-tach.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: StarFive JHB100 Fan-Tach controller + +maintainers: + - Changhuang Liang <[email protected]> + +description: + The StarFive Fan-Tach controller can support up to 16 fan tach input. + +properties: + compatible: + enum: + - starfive,jhb100-fan-tach + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + resets: + maxItems: 1 + + interrupts: + maxItems: 1 + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 +Documentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yaml line 47
Quoted 10 lines
Documentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yaml new file +10
-0+patternProperties: + "^fan@[0-9a-f]+$": + $ref: fan-common.yaml# + unevaluatedProperties: false + + properties: + reg: + description: + PWM channel index. The driver allows two fans to share the same + PWM channel, or each fan to use a dedicated channel.Doesn't matter what the driver can do, the description should describe what the hardware supports.
pw-bot: changes-requestedQuoted 8 lines
Does this fan-tach controller provide the PWMs?
If so (although Guenter may correct me), I think the fan-tach controller needs to be.If you don't do that, I think you're going to run into problems with having multiple nodes with the same unit address when two fans share a pwm?
Quoted 6 lines
Depends on how the controller works. Normally fan controllers have a feedback mechanism which can be either temperature -> pwm output or fan speed -> pwm output. I don't know how this controller works, specifically if the fan speed inputs are internally associated with pwm outputs or if they are completely independent of each other. If it is the latter, aspeed,g6-pwm-tach.yaml would probably be a good baseline.
Judging from the other reply, it probably isn't a good baseline because this is not a pwm provider.
Quoted 9 lines
Quoted 4 lines
I think what you're supposed to do is drop "reg" and replace it with "pwms", but once again Guenter may correct me there.
e.g. aspeed,g6-pwm-tach.yamlSorry, when it comes to devicetree properties, I am completely clueless. Usually the devicetree and pwm maintainers insist that all fan controllers are modeled as pwm controllers because they have pwm outputs. My approach is "use whatever bindings are acceptable by DT maintainers".
Would you mind taking a look at my question in the other reply about how the feedback path works (or doesn't) in that case? My lack of familiarity with the subsystem has me scratching my head about how the tach would be used to adjust the pwm duty cycle with the dt setup described there!
Thanks,
Conor.
Quoted 56 lines
Guenter
Quoted 52 lines
Cheers,
Conor.Quoted 49 lines
Documentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yaml new file +46
-0+ maximum: 15 + + tach-ch: + description: + The tachometer channel(s) wired to the fan(s) driven by this PWM + channel. Integer values in the range 0-15. + minItems: 1 + maxItems: 2 + items: + maximum: 15 + + required: + - reg + - tach-ch + +required: + - compatible + - reg + - clocks + - resets + - interrupts + +additionalProperties: false + +examples: + - | + fan-controller@11be0000 { + compatible = "starfive,jhb100-fan-tach"; + reg = <0x11be0000 0x400>; + interrupts = <128>; + clocks = <&per2crg 33>; + resets = <&per2crg 5>; + #address-cells = <1>; + #size-cells = <0>; + + fan@0 { + reg = <0x0>; + tach-ch = /bits/ 8 <0x0 0x8>; + pulses-per-revolution = <2>; + }; + fan@1 { + reg = <0x1>; + tach-ch = /bits/ 8 <0x1>; + pulses-per-revolution = <2>; + }; + };Signature · 1 line
2.25.1
Re: [PATCH v4 1/2] dt-bindings: hwmon: Add starfive,jhb100-fan-tach
In reply to Conor DooleyHi, Conor
Thanks for the review.
Quoted 82 lines · Changhuang Liang
Quoted 6 lines
Add compatible "starfive,jhb100-fan-tach" for StarFive JHB100 Fan-Tach controller.
Signed-off-by Changhuang Liang <[email protected]>--- .../hwmon/starfive,jhb100-fan-tach.yaml | 93+++++++++++++++++++
Quoted 6 lines
1 file changed, 93 insertions(+) create mode 100644
Documentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yamldiff --git
a/Documentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yam
Quoted 2 lines
l
b/Documentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yam
Quoted 5 lines
l
new file mode 100644
index 000000000000..1dcd4932768f
---/dev/null
+++b/Documentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach
Quoted 38 lines
+++ .yaml
Documentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yaml new file +36
-0@@ -0,0 +1,93 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause %YAML 1.2 +--- +$id: +http://devicetree.org/schemas/hwmon/starfive,jhb100-fan-tach.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: StarFive JHB100 Fan-Tach controller + +maintainers: + - Changhuang Liang <[email protected]> + +description: + The StarFive Fan-Tach controller can support up to 16 fan tach input. + +properties: + compatible: + enum: + - starfive,jhb100-fan-tach + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + resets: + maxItems: 1 + + interrupts: + maxItems: 1 + + "#address-cells": + const: 1 + + "#size-cells": + const: 0Documentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yaml line 46
Quoted 10 lines
Documentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yaml new file +10
-0+ +patternProperties: + "^fan@[0-9a-f]+$": + $ref: fan-common.yaml# + unevaluatedProperties: false + + properties: + reg: + description: + PWM channel index. The driver allows two fans to share thesame
Documentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yaml line 47
Quoted 1 line
Documentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yaml new file +1
-0+ PWM channel, or each fan to use a dedicated channel.Doesn't matter what the driver can do, the description should describe what the hardware supports.
pw-bot: changes-requested
Does this fan-tach controller provide the PWMs?
If so (although Guenter may correct me), I think the fan-tach controller needs to be.
Quoted 7 lines
If you don't do that, I think you're going to run into problems with having multiple nodes with the same unit address when two fans share a pwm?
I think what you're supposed to do is drop "reg" and replace it with "pwms", but once again Guenter may correct me there.
e.g. aspeed,g6-pwm-tach.yaml
Perhaps I can refer to aspeed,g6-pwm-tach.yaml and change "^fan@[0-9a-f]+$" to "^fan-[0-9]+$", which would remove the reg property. In fact, the driver does not use reg either.
Our fan-tach controller does not include PWM. The JHB100 SoC will have a separate PWM controller. (This controller uses the same IP as the JH7110 SoC, but there are some differences in driver implementation.)
The JHB100 has 8 PWM channels and 16 fan tach channels.
So currently we expect the Device Tree to be configured like this:
pwm0: pwm {
compatible = "starfive,jhb100-pwm";
};
pwm1: pwm {
compatible = "starfive,jhb100-pwm";
};
pwm2: pwm {
compatible = "starfive,jhb100-pwm";
};
pwm3: pwm {
compatible = "starfive,jhb100-pwm";
};
pwm4: pwm {
compatible = "starfive,jhb100-pwm";
};
pwm5: pwm {
compatible = "starfive,jhb100-pwm";
};
pwm6: pwm {
compatible = "starfive,jhb100-pwm";
};
pwm7: pwm {
compatible = "starfive,jhb100-pwm";
};
fan0: pwm-fan0 {
compatible = "pwm-fan";
pwms = <&pwm0 0 40000 0>;
};
fan1: pwm-fan1 {
compatible = "pwm-fan";
pwms = <&pwm1 0 40000 0>;
};
fan2: pwm-fan2 {
compatible = "pwm-fan";
pwms = <&pwm2 0 40000 0>;
};
fan3: pwm-fan3 {
compatible = "pwm-fan";
pwms = <&pwm3 0 40000 0>;
};
fan4: pwm-fan4 {
compatible = "pwm-fan";
pwms = <&pwm4 0 40000 0>;
};
fan5: pwm-fan5 {
compatible = "pwm-fan";
pwms = <&pwm5 0 40000 0>;
};
fan6: pwm-fan6 {
compatible = "pwm-fan";
pwms = <&pwm6 0 40000 0>;
};
fan7: pwm-fan7 {
compatible = "pwm-fan";
pwms = <&pwm7 0 40000 0>;
};fan-controller {
compatible = "starfive,jhb100-fan-tach";
fan@0 {
tach-ch = <0x0>, <0x8>;
};
fan@1 {
tach-ch = <0x1>, <0x9>;
};
fan@2 {
tach-ch = <0x2>, <0xa>;
};
fan@3 {
tach-ch = <0x3>, <0xb>;
};
fan@4 {
tach-ch = <0x4>, <0xc>;
};
fan@5 {
tach-ch = <0x5>, <0xd>;
};
fan@6 {
tach-ch = <0x6>, <0xe>;
};
fan@7 {
tach-ch = <0x7>, <0xf>;
};
};Quoted 45 lines
Cheers,
Conor.Documentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yaml
Quoted 5 lines
Documentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yaml new file +5
-0+ maximum: 15 + + tach-ch: + description: + The tachometer channel(s) wired to the fan(s) driven by thisPWM
Quoted 36 lines
Documentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yaml new file +36
-0+ channel. Integer values in the range 0-15. + minItems: 1 + maxItems: 2 + items: + maximum: 15 + + required: + - reg + - tach-ch + +required: + - compatible + - reg + - clocks + - resets + - interrupts + +additionalProperties: false + +examples: + - | + fan-controller@11be0000 { + compatible = "starfive,jhb100-fan-tach"; + reg = <0x11be0000 0x400>; + interrupts = <128>; + clocks = <&per2crg 33>; + resets = <&per2crg 5>; + #address-cells = <1>; + #size-cells = <0>; + + fan@0 { + reg = <0x0>; + tach-ch = /bits/ 8 <0x0 0x8>; + pulses-per-revolution = <2>; + }; + fan@1 {
Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yaml new file +5
-1+ reg = <0x1>; + tach-ch = /bits/ 8 <0x1>; + pulses-per-revolution = <2>; + }; + }; --2.25.1
Best Regards,
Changhuang
Re: [PATCH v4 1/2] dt-bindings: hwmon: Add starfive,jhb100-fan-tach
Quoted 52 lines · Changhuang Liang
Quoted 20 lines · Changhuang Liang
Documentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yaml
Quoted 9 lines
Documentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yaml new file +9
-0+patternProperties: + "^fan@[0-9a-f]+$": + $ref: fan-common.yaml# + unevaluatedProperties: false + + properties: + reg: + description: + PWM channel index. The driver allows two fans to share thesame
Quoted 1 line
+ PWM channel, or each fan to use a dedicated channel.
Doesn't matter what the driver can do, the description should describe what the hardware supports.
pw-bot: changes-requested
Does this fan-tach controller provide the PWMs?
If so (although Guenter may correct me), I think the fan-tach controller needs to be.Quoted 7 lines
If you don't do that, I think you're going to run into problems with having multiple nodes with the same unit address when two fans share a pwm?
I think what you're supposed to do is drop "reg" and replace it with "pwms", but once again Guenter may correct me there.
e.g. aspeed,g6-pwm-tach.yamlPerhaps I can refer to aspeed,g6-pwm-tach.yaml and change "^fan@[0-9a-f]+$" to "^fan-[0-9]+$", which would remove the reg property. In fact, the driver does not use reg either.
Our fan-tach controller does not include PWM. The JHB100 SoC will have a separate PWM controller. (This controller uses the same IP as the JH7110 SoC, but there are some differences in driver implementation.)
The JHB100 has 8 PWM channels and 16 fan tach channels.
So currently we expect the Device Tree to be configured like this:
pwm0: pwm { compatible = "starfive,jhb100-pwm"; }; fan0: pwm-fan0 { compatible = "pwm-fan"; pwms = <&pwm0 0 40000 0>; };
Quoted 6 lines
fan-controller {
compatible = "starfive,jhb100-fan-tach";
fan@0 {
tach-ch = <0x0>, <0x8>;
};Truncating this for readability, but it looks wrong to me. How does the feedback loop work here when there's no way to determine which fan is connected to a tach channel? The unit address of the child nodes has no dt enforced guarantee to line up with node names of the fans or pwm indices.
Guenter Roeck
maintainerRe: [PATCH v4 1/2] dt-bindings: hwmon: Add starfive,jhb100-fan-tach
Quoted 60 lines · Conor Dooley
Quoted 52 lines · Changhuang Liang
Quoted 20 lines · Changhuang Liang
Documentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yaml
Quoted 9 lines
Documentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yaml new file +9
-0+patternProperties: + "^fan@[0-9a-f]+$": + $ref: fan-common.yaml# + unevaluatedProperties: false + + properties: + reg: + description: + PWM channel index. The driver allows two fans to share thesame
Quoted 1 line
+ PWM channel, or each fan to use a dedicated channel.
Doesn't matter what the driver can do, the description should describe what the hardware supports.
pw-bot: changes-requested
Does this fan-tach controller provide the PWMs?
If so (although Guenter may correct me), I think the fan-tach controller needs to be.Quoted 7 lines
If you don't do that, I think you're going to run into problems with having multiple nodes with the same unit address when two fans share a pwm?
I think what you're supposed to do is drop "reg" and replace it with "pwms", but once again Guenter may correct me there.
e.g. aspeed,g6-pwm-tach.yamlPerhaps I can refer to aspeed,g6-pwm-tach.yaml and change "^fan@[0-9a-f]+$" to "^fan-[0-9]+$", which would remove the reg property. In fact, the driver does not use reg either.
Our fan-tach controller does not include PWM. The JHB100 SoC will have a separate PWM controller. (This controller uses the same IP as the JH7110 SoC, but there are some differences in driver implementation.)
The JHB100 has 8 PWM channels and 16 fan tach channels.
So currently we expect the Device Tree to be configured like this:
pwm0: pwm { compatible = "starfive,jhb100-pwm"; }; fan0: pwm-fan0 { compatible = "pwm-fan"; pwms = <&pwm0 0 40000 0>; };Quoted 6 lines
fan-controller { compatible = "starfive,jhb100-fan-tach"; fan@0 { tach-ch = <0x0>, <0x8>; };
Quoted 5 lines
Truncating this for readability, but it looks wrong to me. How does the feedback loop work here when there's no way to determine which fan is connected to a tach channel? The unit address of the child nodes has no dt enforced guarantee to line up with node names of the fans or pwm indices.
Normally (for other fan controllers) the fan would have a target speed. The controller measures the speed and adjusts pwm output values until the fan speed matches the expected value. The controller needs to know the association between tachometer input and pwm output for this to work. Typically (for classic fan controllers) that association is static. In the Aspeed G6 fan controller it is dynamic/configurable.
I thought this is the case here as well, but I have no idea if that is correct (or if there is a chip-internal feedback loop to start with).
Guenter
Re: [PATCH v4 1/2] dt-bindings: hwmon: Add starfive,jhb100-fan-tach
Hi, Guenter, Conor
Thanks for the review.
Quoted 77 lines · Conor Dooley
Quoted 22 lines · Changhuang Liang
Quoted 21 lines
Quoted 21 lines · Changhuang Liang
Documentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yaml
Quoted 10 lines
Documentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yaml new file +10
-0+patternProperties: + "^fan@[0-9a-f]+$": + $ref: fan-common.yaml# + unevaluatedProperties: false + + properties: + reg: + description: + PWM channel index. The driver allows two fans to share + thesame
Quoted 1 line
+ PWM channel, or each fan to use a dedicated channel.
Doesn't matter what the driver can do, the description should describe what the hardware supports.
pw-bot: changes-requested
Does this fan-tach controller provide the PWMs?
If so (although Guenter may correct me), I think the fan-tach controller needs to be.Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
If you don't do that, I think you're going to run into problems with having multiple nodes with the same unit address when two fans share a
pwm?
Quoted 38 lines
Quoted 31 lines
Quoted 5 lines
I think what you're supposed to do is drop "reg" and replace it with "pwms", but once again Guenter may correct me there.
e.g. aspeed,g6-pwm-tach.yamlPerhaps I can refer to aspeed,g6-pwm-tach.yaml and change "^fan@[0-9a-f]+$" to "^fan-[0-9]+$", which would remove the reg property. In fact, the driver does not use reg either.
Our fan-tach controller does not include PWM. The JHB100 SoC will have a separate PWM controller. (This controller uses the same IP as the JH7110 SoC, but there are some differences in driver implementation.)
The JHB100 has 8 PWM channels and 16 fan tach channels.
So currently we expect the Device Tree to be configured like this:
pwm0: pwm { compatible = "starfive,jhb100-pwm"; }; fan0: pwm-fan0 { compatible = "pwm-fan"; pwms = <&pwm0 0 40000 0>; };Quoted 6 lines
fan-controller { compatible = "starfive,jhb100-fan-tach"; fan@0 { tach-ch = <0x0>, <0x8>; };Quoted 5 lines
Truncating this for readability, but it looks wrong to me. How does the feedback loop work here when there's no way to determine which fan is connected to a tach channel? The unit address of the child nodes has no dt enforced guarantee to line up with node names of the fans or pwm indices.
Normally (for other fan controllers) the fan would have a target speed. The controller measures the speed and adjusts pwm output values until the fan speed matches the expected value. The controller needs to know the association between tachometer input and pwm output for this to work. Typically (for classic fan controllers) that association is static. In the Aspeed G6 fan controller it is dynamic/configurable.
Quoted 2 lines
I thought this is the case here as well, but I have no idea if that is correct (or if there is a chip-internal feedback loop to start with).
Here is some information I found about fan tach and PWM control. It looks like these two devices are managed through an application.
Do you have any new suggestions for modifications?
https://github.com/openbmc/phosphor-pid-control/blob/master/README.md
Best Regards,
Changhuang
Re: [PATCH v4 1/2] dt-bindings: hwmon: Add starfive,jhb100-fan-tach
Quoted 81 lines · Changhuang Liang
Hi, Guenter, Conor
Thanks for the review.
Quoted 77 lines · Conor Dooley
Quoted 22 lines · Changhuang Liang
Quoted 21 lines
Quoted 21 lines · Changhuang Liang
Documentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yaml
Quoted 10 lines
Documentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yaml new file +10
-0+patternProperties: + "^fan@[0-9a-f]+$": + $ref: fan-common.yaml# + unevaluatedProperties: false + + properties: + reg: + description: + PWM channel index. The driver allows two fans to share + thesame
Quoted 1 line
+ PWM channel, or each fan to use a dedicated channel.
Doesn't matter what the driver can do, the description should describe what the hardware supports.
pw-bot: changes-requested
Does this fan-tach controller provide the PWMs?
If so (although Guenter may correct me), I think the fan-tach controller needs to be.Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
If you don't do that, I think you're going to run into problems with having multiple nodes with the same unit address when two fans share a
pwm?
Quoted 38 lines
Quoted 31 lines
Quoted 5 lines
I think what you're supposed to do is drop "reg" and replace it with "pwms", but once again Guenter may correct me there.
e.g. aspeed,g6-pwm-tach.yamlPerhaps I can refer to aspeed,g6-pwm-tach.yaml and change "^fan@[0-9a-f]+$" to "^fan-[0-9]+$", which would remove the reg property. In fact, the driver does not use reg either.
Our fan-tach controller does not include PWM. The JHB100 SoC will have a separate PWM controller. (This controller uses the same IP as the JH7110 SoC, but there are some differences in driver implementation.)
The JHB100 has 8 PWM channels and 16 fan tach channels.
So currently we expect the Device Tree to be configured like this:
pwm0: pwm { compatible = "starfive,jhb100-pwm"; }; fan0: pwm-fan0 { compatible = "pwm-fan"; pwms = <&pwm0 0 40000 0>; };Quoted 6 lines
fan-controller { compatible = "starfive,jhb100-fan-tach"; fan@0 { tach-ch = <0x0>, <0x8>; };Quoted 5 lines
Truncating this for readability, but it looks wrong to me. How does the feedback loop work here when there's no way to determine which fan is connected to a tach channel? The unit address of the child nodes has no dt enforced guarantee to line up with node names of the fans or pwm indices.
Normally (for other fan controllers) the fan would have a target speed. The controller measures the speed and adjusts pwm output values until the fan speed matches the expected value. The controller needs to know the association between tachometer input and pwm output for this to work. Typically (for classic fan controllers) that association is static. In the Aspeed G6 fan controller it is dynamic/configurable.
Quoted 7 lines
Quoted 2 lines
I thought this is the case here as well, but I have no idea if that is correct (or if there is a chip-internal feedback loop to start with).
Here is some information I found about fan tach and PWM control. It looks like these two devices are managed through an application.
Do you have any new suggestions for modifications?
I, at least, have no new suggestions. I thought the most recent reply from Guenter was pretty clear? If you've got a dedicated fan controller with static association then you don't need to provide the association, but if there's dynamic/configurable pwm-tach then you need to provide the association so that the fan controller can work correctly? To me, that read as if the pwms property would be required here, because what's proposed above represents the same fan twice, as pwm-fan0 and fan0 without an association between the two because you have an different IP entirely providing the pwm.
For this to work, don't you actually need to do:
pwm0: pwm {
compatible = "starfive,jhb100-pwm";
};fan-controller {
compatible = "starfive,jhb100-fan-tach";
fan@0 {
pwms = <&pwm0 0 40000 0>;
tach-ch = <0x0>, <0x8>;
};
};Cheers,
Conor.
Quoted 6 lines
https://github.com/openbmc/phosphor-pid-control/blob/master/README.md
Best Regards,
Changhuang
Re: [PATCH v4 1/2] dt-bindings: hwmon: Add starfive,jhb100-fan-tach
Hi, Conor
Quoted 107 lines · Changhuang Liang
Quoted 79 lines
Hi, Guenter, Conor
Thanks for the review.
Quoted 75 lines · Conor Dooley
Quoted 22 lines · Changhuang Liang
Quoted 21 lines
Quoted 21 lines · Changhuang Liang
Review
Quoted 10 lines
(quoted diff) +10
-0+patternProperties: + "^fan@[0-9a-f]+$": + $ref: fan-common.yaml# + unevaluatedProperties: false + + properties: + reg: + description: + PWM channel index. The driver allows two fans to + share thesame
Quoted 1 line
+ PWM channel, or each fan to use a dedicated channel.
Doesn't matter what the driver can do, the description should describe what the hardware supports.
pw-bot: changes-requested
Does this fan-tach controller provide the PWMs?
If so (although Guenter may correct me), I think the fan-tach controller needs to be.Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
If you don't do that, I think you're going to run into problems with having multiple nodes with the same unit address when two fans share a
pwm?
Quoted 38 lines
Quoted 31 lines
Quoted 5 lines
I think what you're supposed to do is drop "reg" and replace it with "pwms", but once again Guenter may correct me there. e.g. aspeed,g6-pwm-tach.yaml
Perhaps I can refer to aspeed,g6-pwm-tach.yaml and change "^fan@[0-9a-f]+$" to "^fan-[0-9]+$", which would remove the reg property. In fact, the driver does not use reg either.
Our fan-tach controller does not include PWM. The JHB100 SoC will have a separate PWM controller. (This controller uses the same IP as the JH7110 SoC, but there are some differences in driver implementation.)
The JHB100 has 8 PWM channels and 16 fan tach channels.
So currently we expect the Device Tree to be configured like this:
pwm0: pwm { compatible = "starfive,jhb100-pwm"; }; fan0: pwm-fan0 { compatible = "pwm-fan"; pwms = <&pwm0 0 40000 0>; };Quoted 6 lines
fan-controller { compatible = "starfive,jhb100-fan-tach"; fan@0 { tach-ch = <0x0>, <0x8>; };Quoted 5 lines
Truncating this for readability, but it looks wrong to me. How does the feedback loop work here when there's no way to determine which fan is connected to a tach channel? The unit address of the child nodes has no dt enforced guarantee to line up with node names of the fans or pwm indices.
Normally (for other fan controllers) the fan would have a target speed. The controller measures the speed and adjusts pwm output values until the fan speed matches the expected value. The controller needs to know the association between tachometer input and pwm output for
this to work.
Quoted 10 lines
Quoted 5 lines
Typically (for classic fan controllers) that association is static. In the Aspeed G6 fan controller it is dynamic/configurable.
I thought this is the case here as well, but I have no idea if that is correct (or if there is a chip-internal feedback loop to start with).
Here is some information I found about fan tach and PWM control. It looks like these two devices are managed through an application.
Do you have any new suggestions for modifications?
I, at least, have no new suggestions. I thought the most recent reply from Guenter was pretty clear? If you've got a dedicated fan controller with static association then you don't need to provide the association, but if there's dynamic/configurable pwm-tach then you need to provide the association so that the fan controller can work correctly?
To me, that read as if the pwms property would be required here, because what's proposed above represents the same fan twice, as pwm-fan0 and fan0 without an association between the two because you have an different IP entirely providing the pwm.For this to work, don't you actually need to do:
pwm0: pwm { compatible = "starfive,jhb100-pwm"; };
Quoted 9 lines
fan-controller {
compatible = "starfive,jhb100-fan-tach";
fan@0 {
pwms = <&pwm0 0 40000 0>;
tach-ch = <0x0>, <0x8>;
};
};Okay, I recently came across a similar example:
https://lore.kernel.org/all/[email protected]/
I'll refer to this for the next version.
Best Regards,
Changhuang
PATCH v4 2/2 hwmon: (starfive-fan-tach) Add fan tach driver for StarFive JHB100
In reply to Changhuang LiangAdd fan tach driver for StarFive JHB100 SoC.
The controller supports up to 16 independent fan tachometer inputs and reports fan speed in RPM through the hwmon sysfs interface, along with stall and low-speed alarms.
For this controller, the special clock and reset operation sequence is:
probe: clk_prepare_enable() then reset_control_deassert()
remove: clk_disable_unprepare() then reset_control_assert()
--- Documentation/hwmon/index.rst | 1 + Documentation/hwmon/starfive-fan-tach.rst | 38 ++ MAINTAINERS | 8 + drivers/hwmon/Kconfig | 14 + drivers/hwmon/Makefile | 1 + drivers/hwmon/starfive-fan-tach.c | 542 ++++++++++++++++++++++ 6 files changed, 604 insertions(+) create mode 100644 Documentation/hwmon/starfive-fan-tach.rst create mode 100644 drivers/hwmon/starfive-fan-tach.c
Documentation/hwmon/index.rst +1 -0
@@ -253,6 +253,7 @@ Hardware Monitoring Kernel Drivers smsc47m1 sparx5-temp spd5118 + starfive-fan-tach stpddc60 surface_fan sy7636a-hwmon
Documentation/hwmon/starfive-fan-tach.rst new file +38 -0
@@ -0,0 +1,38 @@ +.. SPDX-License-Identifier: GPL-2.0 + +Kernel driver starfive-fan-tach +=============================== + +Supported chips: + + * StarFive JHB100 + + Prefix: 'starfive_fan_tach' + + Addresses scanned: - + +Authors: + - Changhuang Liang <[email protected]> + +Description +----------- + +This driver implements support for the fan tachometer controller found on +the StarFive JHB100 SoC. The controller supports up to 16 independent fan +tachometer inputs. Each tachometer channel measures the number of pulses +within a fixed 100 ms window. + +Sysfs entries +------------- + +===================== ======================================================= +fan[1-16]_input Fan speed in RPM (read-only), without a fan connected, + reading this value can be significantly slow. +fan[1-16]_min Lower fan speed limit in RPM (read/write) +fan[1-16]_enable Enable/disable the tachometer channel (read/write) +fan[1-16]_fault Fan stall indication (read-only), with the fan running + normally, reading this value can be significantly slow. +fan[1-16]_min_alarm Fan speed below fan[1-16]_min (read-only), when + fan[1-16]_input is greater than or equal fan[1-16]_min, + reading this value can be significantly slow. +===================== =======================================================
MAINTAINERS +8 -0
@@ -25897,6 +25897,14 @@ S: Supported F: Documentation/devicetree/bindings/interrupt-controller/starfive,jhb100-intc.yaml F: drivers/irqchip/irq-starfive-jhb100-intc.c +STARFIVE JHB100 FAN-TACH DRIVER +M: Changhuang Liang <[email protected]> +L: [email protected] +S: Supported +F: Documentation/devicetree/bindings/hwmon/starfive,jhb100-fan-tach.yaml +F: Documentation/hwmon/starfive-fan-tach.rst +F: drivers/hwmon/starfive-fan-tach.c + STATIC BRANCH/CALL M: Peter Zijlstra <[email protected]> M: Josh Poimboeuf <[email protected]>
drivers/hwmon/Kconfig +14 -0
@@ -2383,6 +2383,20 @@ config SENSORS_SPD5118_DETECT If unsure, say Y. +config SENSORS_STARFIVE_FAN_TACH + tristate "StarFive Fan-Tach driver" + depends on ARCH_STARFIVE || COMPILE_TEST + depends on HAS_IOMEM + help + This driver provides support for the fan tachometer controller + found on StarFive SoCs such as the JHB100. The controller supports + up to 16 independent fan tachometer inputs and reports fan speed + in RPM through the hwmon sysfs interface, along with stall and + low-speed alarms. + + This driver can also be built as a module. If so, the module + will be called starfive-fan-tach. + config SENSORS_TC74 tristate "Microchip TC74" depends on I2C
drivers/hwmon/Makefile +1 -0
@@ -223,6 +223,7 @@ obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o obj-$(CONFIG_SENSORS_SMSC47M192)+= smsc47m192.o obj-$(CONFIG_SENSORS_SPARX5) += sparx5-temp.o obj-$(CONFIG_SENSORS_SPD5118) += spd5118.o +obj-$(CONFIG_SENSORS_STARFIVE_FAN_TACH) += starfive-fan-tach.o obj-$(CONFIG_SENSORS_STTS751) += stts751.o obj-$(CONFIG_SENSORS_SURFACE_FAN)+= surface_fan.o obj-$(CONFIG_SENSORS_SURFACE_TEMP)+= surface_temp.o
drivers/hwmon/starfive-fan-tach.c new file +542 -0
542 lines not on this page · raw message
Signature · 1 line
2.25.1
[email protected]
AI reviewRe: [PATCH v4 2/2] hwmon: (starfive-fan-tach) Add fan tach driver for StarFive JHB100
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 6 lines
Add fan tach driver for StarFive JHB100 SoC.
The controller supports up to 16 independent fan tachometer inputs and reports fan speed in RPM through the hwmon sysfs interface, along with stall and low-speed alarms.
Quoted 7 lines
For this controller, the special clock and reset operation sequence is:
probe:clk_prepare_enable()thenreset_control_deassert()
remove:clk_disable_unprepare()thenreset_control_assert()Co-developed-by William Qiu <[email protected]>Signed-off-by William Qiu <[email protected]>Signed-off-by Changhuang Liang <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2