Add JHB100 Fan-Tach support
Subsystems (3)
v6 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 v5:
PATCH 1:
- Add Conor's "Reviewed-by" tag.
PATCH 2:
- Do not stop at the first failing channel in starfive_pwm_fan_pwm_disable_all(). A PWM channel that fails to be disabled no longer leaves the remaining, independent channels running on driver removal or system suspend. The error is logged and the first error code is returned once all channels have been handled.
- Save the tachometer registers (channel enable, measure time and the per-channel thresholds) in ->suspend() and restore them in ->resume()
- Add a struct device pointer to struct starfive_pwm_fan_data for the error messages.
v5: https://lore.kernel.org/all/[email protected]/
v4: https://lore.kernel.org/all/[email protected]/
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-pwm-fan
hwmon: (starfive-pwm-fan) Add PWM fan driver for StarFive JHB100
.../hwmon/starfive,jhb100-pwm-fan.yaml | 87 ++ Documentation/hwmon/index.rst | 1 + Documentation/hwmon/starfive-pwm-fan.rst | 45 + MAINTAINERS | 8 + drivers/hwmon/Kconfig | 15 + drivers/hwmon/Makefile | 1 + drivers/hwmon/starfive-pwm-fan.c | 834 ++++++++++++++++++ 7 files changed, 991 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/starfive,jhb100-pwm-fan.yaml create mode 100644 Documentation/hwmon/starfive-pwm-fan.rst create mode 100644 drivers/hwmon/starfive-pwm-fan.c
--
2.25.1
PATCH v6 1/2 dt-bindings: hwmon: Add starfive,jhb100-pwm-fan
Add a binding for the StarFive JHB100 PWM fan controller. The controller has a hardware tachometer block with 16 tachometer inputs, while fan speed is controlled through 8 PWM channels supplied by an external PWM controller.
One PWM channel can drive up to two fans, so each fan-N child node references one PWM channel and lists the tachometer inputs wired to the fans it drives.
--- .../hwmon/starfive,jhb100-pwm-fan.yaml | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/starfive,jhb100-pwm-fan.yaml
Documentation/devicetree/bindings/hwmon/starfive,jhb100-pwm-fan.yaml new file +87 -0
@@ -0,0 +1,87 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/hwmon/starfive,jhb100-pwm-fan.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: StarFive JHB100 PWM Fan Controller + +maintainers: + - Changhuang Liang <[email protected]> + +description: + The StarFive JHB100 fan controller uses a hardware tachometer block with + 16 tachometer inputs to measure fan speed. Fan speed is controlled through + 8 PWM channels supplied by an external PWM controller, and one PWM channel + can drive up to two fans. Each fan child node references the PWM channel + driving the fan(s) and lists the tachometer inputs wired to them. + +properties: + compatible: + const: starfive,jhb100-pwm-fan + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + resets: + maxItems: 1 + + interrupts: + maxItems: 1 + +patternProperties: + "^fan-[0-7]$": + $ref: fan-common.yaml# + unevaluatedProperties: false + + properties: + pulses-per-revolution: + minimum: 1 + default: 2 + + tach-ch: + description: + The tachometer input(s) wired to the fan(s) driven by the PWM + channel. One PWM channel can drive up to two fans. + minItems: 1 + maxItems: 2 + items: + maximum: 15 + + required: + - pwms + - tach-ch + +required: + - compatible + - reg + - clocks + - resets + - interrupts + +additionalProperties: false + +examples: + - | + fan-controller@11be0000 { + compatible = "starfive,jhb100-pwm-fan"; + reg = <0x11be0000 0x400>; + interrupts = <128>; + clocks = <&per2crg 33>; + resets = <&per2crg 5>; + + fan-0 { + pwms = <&pwm0 0 40000 0>; + tach-ch = /bits/ 8 <0x0 0x8>; + pulses-per-revolution = <2>; + }; + + fan-1 { + pwms = <&pwm1 0 40000 0>; + tach-ch = /bits/ 8 <0x1 0x9>; + }; + }; +...
Signature · 1 line
2.25.1
[email protected]
AI reviewRe: [PATCH v6 1/2] dt-bindings: hwmon: Add starfive,jhb100-pwm-fan
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 10 lines
Add a binding for the StarFive JHB100 PWM fan controller. The controller has a hardware tachometer block with 16 tachometer inputs, while fan speed is controlled through 8 PWM channels supplied by an external PWM controller.
One PWM channel can drive up to two fans, so each fan-N child node references one PWM channel and lists the tachometer inputs wired to the fans it drives.
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 v6 1/2] dt-bindings: hwmon: Add starfive,jhb100-pwm-fan
In reply to Changhuang LiangQuoted 11 lines · Changhuang Liang
Add a binding for the StarFive JHB100 PWM fan controller. The controller has a hardware tachometer block with 16 tachometer inputs, while fan speed is controlled through 8 PWM channels supplied by an external PWM controller.
One PWM channel can drive up to two fans, so each fan-N child node references one PWM channel and lists the tachometer inputs wired to the fans it drives.
Signed-off-by Changhuang Liang <[email protected]>Reviewed-by Conor Dooley <[email protected]>
Applied.
Thanks,
Guenter
PATCH v6 2/2 hwmon: (starfive-pwm-fan) Add PWM fan driver for StarFive JHB100
In reply to Changhuang LiangAdd PWM fan controller driver for StarFive JHB100 SoC.
Fan speed is controlled through up to 8 PWM channels supplied by an external PWM controller and exposed as pwm[1-8], and one PWM channel can drive up to two fans. The tachometer block supports 16 independent 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-pwm-fan.rst | 45 ++ MAINTAINERS | 8 + drivers/hwmon/Kconfig | 15 + drivers/hwmon/Makefile | 1 + drivers/hwmon/starfive-pwm-fan.c | 834 +++++++++++++++++++++++ 6 files changed, 904 insertions(+) create mode 100644 Documentation/hwmon/starfive-pwm-fan.rst create mode 100644 drivers/hwmon/starfive-pwm-fan.c
Documentation/hwmon/index.rst +1 -0
@@ -263,6 +263,7 @@ Hardware Monitoring Kernel Drivers sparx5-temp spd5118 sq24860 + starfive-pwm-fan stpddc60 surface_fan sy7636a-hwmon
Documentation/hwmon/starfive-pwm-fan.rst new file +45 -0
45 lines not on this page · raw message
MAINTAINERS +8 -0
@@ -26647,6 +26647,14 @@ S: Maintained F: Documentation/devicetree/bindings/pinctrl/starfive,jhb1*.yaml F: drivers/pinctrl/starfive/pinctrl-starfive-jhb1* +STARFIVE JHB100 PWM FAN DRIVER +M: Changhuang Liang <[email protected]> +L: [email protected] +S: Supported +F: Documentation/devicetree/bindings/hwmon/starfive,jhb100-pwm-fan.yaml +F: Documentation/hwmon/starfive-pwm-fan.rst +F: drivers/hwmon/starfive-pwm-fan.c + STATIC BRANCH/CALL M: Peter Zijlstra <[email protected]> M: Josh Poimboeuf <[email protected]>
drivers/hwmon/Kconfig +15 -0
@@ -2467,6 +2467,21 @@ config SENSORS_SPD5118_DETECT If unsure, say Y. +config SENSORS_STARFIVE_PWM_FAN + tristate "StarFive JHB100 PWM fan controller" + depends on ARCH_STARFIVE || COMPILE_TEST + depends on HAS_IOMEM + depends on PWM + help + This driver supports the PWM fan controller found on StarFive SoCs + such as the JHB100. It uses up to 8 PWM outputs supplied by an + external PWM controller to control fan speed, and a tachometer block + with 16 inputs to report 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-pwm-fan. + config SENSORS_TC74 tristate "Microchip TC74" depends on I2C
drivers/hwmon/Makefile +1 -0
@@ -231,6 +231,7 @@ obj-$(CONFIG_SENSORS_SMSC47M192)+= smsc47m192.o obj-$(CONFIG_SENSORS_ALTERA_SOCFPGA_HWMON) += socfpga-hwmon.o obj-$(CONFIG_SENSORS_SPARX5) += sparx5-temp.o obj-$(CONFIG_SENSORS_SPD5118) += spd5118.o +obj-$(CONFIG_SENSORS_STARFIVE_PWM_FAN) += starfive-pwm-fan.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-pwm-fan.c new file +834 -0
834 lines not on this page · raw message
Signature · 1 line
2.25.1
[email protected]
AI reviewRe: [PATCH v6 2/2] hwmon: (starfive-pwm-fan) Add PWM fan driver for StarFive JHB100
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 8 lines
Add PWM fan controller driver for StarFive JHB100 SoC.
Fan speed is controlled through up to 8 PWM channels supplied by an external PWM controller and exposed as pwm[1-8], and one PWM channel can drive up to two fans. The tachometer block supports 16 independent 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
Re: [PATCH v6 2/2] hwmon: (starfive-pwm-fan) Add PWM fan driver for StarFive JHB100
In reply to Changhuang LiangQuoted 8 lines · Changhuang Liang
Add PWM fan controller driver for StarFive JHB100 SoC.
Fan speed is controlled through up to 8 PWM channels supplied by an external PWM controller and exposed as pwm[1-8], and one PWM channel can drive up to two fans. The tachometer block supports 16 independent 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]>
Applied.
Thanks,
Guenter