dt-bindings: hwmon: fan-common: reject zero pulses per revolution
Subsystems (4)
PATCH v3 1/4 dt-bindings: hwmon: fan-common: reject zero pulses per revolution
A fan sensor cannot produce zero tachometer pulses per revolution. Add a minimum of one to the shared fan schema so every user rejects this invalid value.
---
Changes in v3:
- New patch: require at least one pulse per revolution in fan-common.
Documentation/devicetree/bindings/hwmon/fan-common.yaml | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/hwmon/fan-common.yaml +1 -0
@@ -27,6 +27,7 @@ properties: description: The number of pulse from fan sensor per revolution. $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 1 maximum: 4 tach-div:
Signature · 1 line
2.56.0
PATCH v3 2/4 dt-bindings: hwmon: add Microchip LAN969x fan controller
The LAN969x fan controller has a PWM output and tachometer input in a register block separate from the Sparx5-compatible temperature sensor. Describe it with its own compatible and binding.
The optional fan child specifies PWM period and polarity, tachometer pulses per revolution, and thermal cooling levels.
---
Changes in v3:
- Drop the unnecessary literal-style description marker.
- Inherit pulse-count bounds from fan-common.yaml.
- Require cooling-levels only when #cooling-cells is present.
- Add Conor Dooley's Acked-by tag.
Changes in v2:
- Describe the fan controller in a separate binding and compatible.
- Keep the existing temperature-sensor binding unchanged.
.../bindings/hwmon/microchip,lan9691-fan.yaml | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/microchip,lan9691-fan.yaml
Documentation/devicetree/bindings/hwmon/microchip,lan9691-fan.yaml new file +79 -0
@@ -0,0 +1,79 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/hwmon/microchip,lan9691-fan.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Microchip LAN969x Fan Controller + +maintainers: + - Robert Marko <[email protected]> + +description: + LAN969x fan controller with a PWM output and tachometer input. The fan + child's pwms property references this node to specify the PWM period and + polarity. + +properties: + compatible: + const: microchip,lan9691-fan + + reg: + maxItems: 1 + + clocks: + items: + - description: System reference clock + + '#pwm-cells': + const: 2 + description: | + Number of cells in a PWM specifier. + - cell 0: PWM period in nanoseconds + - cell 1: PWM polarity: 0 or PWM_POLARITY_INVERTED + + fan: + $ref: fan-common.yaml# + unevaluatedProperties: false + + properties: + cooling-levels: + description: + PWM duty-cycle values corresponding to thermal cooling states. + items: + maximum: 255 + + pulses-per-revolution: + default: 2 + + required: + - pwms + + dependencies: + '#cooling-cells': + - cooling-levels + +required: + - compatible + - reg + - clocks + - '#pwm-cells' + +additionalProperties: false + +examples: + - | + #include <dt-bindings/pwm/pwm.h> + + fanctrl: fan-controller@e2010348 { + compatible = "microchip,lan9691-fan"; + reg = <0xe2010348 0xc>; + clocks = <&sys_clk>; + #pwm-cells = <2>; + + fan { + pwms = <&fanctrl 40000 PWM_POLARITY_INVERTED>; + cooling-levels = <0 128 192 255>; + #cooling-cells = <2>; + }; + };
Signature · 1 line
2.56.0
[email protected]
AI reviewRe: [PATCH v3 2/4] dt-bindings: hwmon: add Microchip LAN969x fan controller
Sashiko has reviewed this patch and found no issues.
Quoted 9 lines
The LAN969x fan controller has a PWM output and tachometer input in a register block separate from the Sparx5-compatible temperature sensor. Describe it with its own compatible and binding.
The optional fan child specifies PWM period and polarity, tachometer pulses per revolution, and thermal cooling levels.
Acked-by Conor Dooley <[email protected]>Signed-off-by Robert Marko <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Re: [PATCH v3 2/4] dt-bindings: hwmon: add Microchip LAN969x fan controller
In reply to Robert MarkoQuoted 16 lines · Robert Marko
The LAN969x fan controller has a PWM output and tachometer input in a register block separate from the Sparx5-compatible temperature sensor. Describe it with its own compatible and binding.
The optional fan child specifies PWM period and polarity, tachometer pulses per revolution, and thermal cooling levels.
Acked-by Conor Dooley <[email protected]>Signed-off-by Robert Marko <[email protected]>---
Changes in v3:
- Drop the unnecessary literal-style description marker.
- Inherit pulse-count bounds fromfan-common.yaml.
- Require cooling-levels only when #cooling-cells is present.
- Add Conor Dooley's Acked-by tag.
Quoted 8 lines
Changes in v2:
- Describe the fan controller in a separate binding and compatible.
- Keep the existing temperature-sensor binding unchanged..../bindings/hwmon/microchip,lan9691-fan.yaml | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/microchip,lan9691-fan.yaml
Re: [PATCH v3 2/4] dt-bindings: hwmon: add Microchip LAN969x fan controller
In reply to Robert MarkoQuoted 10 lines · Robert Marko
The LAN969x fan controller has a PWM output and tachometer input in a register block separate from the Sparx5-compatible temperature sensor. Describe it with its own compatible and binding.
The optional fan child specifies PWM period and polarity, tachometer pulses per revolution, and thermal cooling levels.
Acked-by Conor Dooley <[email protected]>Signed-off-by Robert Marko <[email protected]>Reviewed-by Rob Herring (Arm) <[email protected]>
Applied.
Thanks,
Guenter
PATCH v3 3/4 hwmon: Add Microchip LAN969x fan controller driver
In reply to Robert MarkoThe LAN969x fan controller has its own register block, separate from the Sparx5-compatible temperature sensor.
Add a dedicated hwmon driver for tachometer, PWM, and thermal cooling.
---
Changes in v3:
- Use a standalone fan driver instead of extending sparx5-temp.
- Combine tachometer, PWM and thermal cooling support in one patch.
- Reject a zero-rate fan clock during probe.
- Add a dedicated MAINTAINERS entry.
Changes in v2:
- Register fan and temperature monitoring as separate hwmon devices.
- Reject a present but malformed pulses-per-revolution property.
- Drop the private mutex; hwmon serializes sysfs accesses.
- Preserve firmware PWM polarity when no fan child is present.
- Convert the DT period directly to a divider and reject invalid values before changing fan registers.
- Use hwmon_lock() for cooling callbacks instead of a private mutex.
Documentation/hwmon/index.rst | 1 + Documentation/hwmon/lan969x-fan.rst | 53 ++++ MAINTAINERS | 8 + drivers/hwmon/Kconfig | 10 + drivers/hwmon/Makefile | 1 + drivers/hwmon/lan969x-fan.c | 444 ++++++++++++++++++++++++++++ 6 files changed, 517 insertions(+) create mode 100644 Documentation/hwmon/lan969x-fan.rst create mode 100644 drivers/hwmon/lan969x-fan.c
Documentation/hwmon/index.rst +1 -0
@@ -122,6 +122,7 @@ Hardware Monitoring Kernel Drivers kbatt kfan lan966x + lan969x-fan lattepanda-sigma-ec lineage-pem lm25066
Documentation/hwmon/lan969x-fan.rst new file +53 -0
53 lines not on this page · raw message
MAINTAINERS +8 -0
@@ -18369,6 +18369,14 @@ L: [email protected] S: Maintained F: drivers/net/ethernet/microchip/sparx5/lan969x/* +MICROCHIP LAN969X FAN CONTROLLER DRIVER +M: Robert Marko <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/hwmon/microchip,lan9691-fan.yaml +F: Documentation/hwmon/lan969x-fan.rst +F: drivers/hwmon/lan969x-fan.c + MICROCHIP LCDFB DRIVER M: Nicolas Ferre <[email protected]> L: [email protected]
drivers/hwmon/Kconfig +10 -0
@@ -1060,6 +1060,16 @@ config SENSORS_LAN966X This driver can also be built as a module. If so, the module will be called lan966x-hwmon. +config SENSORS_LAN969X_FAN + tristate "Microchip LAN969x fan controller" + depends on ARCH_LAN969X || COMPILE_TEST + help + If you say yes here you get support for the fan controller on + Microchip LAN969x SoCs. + + This driver can also be built as a module. If so, the module + will be called lan969x-fan. + config SENSORS_LATTEPANDA_SIGMA_EC tristate "LattePanda Sigma EC hardware monitoring" depends on X86
drivers/hwmon/Makefile +1 -0
@@ -122,6 +122,7 @@ obj-$(CONFIG_SENSORS_KB9002) += kb9002.o obj-$(CONFIG_SENSORS_KBATT) += kbatt.o obj-$(CONFIG_SENSORS_KFAN) += kfan.o obj-$(CONFIG_SENSORS_LAN966X) += lan966x-hwmon.o +obj-$(CONFIG_SENSORS_LAN969X_FAN) += lan969x-fan.o obj-$(CONFIG_SENSORS_LATTEPANDA_SIGMA_EC) += lattepanda-sigma-ec.o obj-$(CONFIG_SENSORS_LENOVO_EC) += lenovo-ec-sensors.o obj-$(CONFIG_SENSORS_LINEAGE) += lineage-pem.o
drivers/hwmon/lan969x-fan.c new file +444 -0
444 lines not on this page · raw message
Signature · 1 line
2.56.0
[email protected]
AI reviewRe: [PATCH v3 3/4] hwmon: Add Microchip LAN969x fan controller driver
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] hwmon: lan969x-fan: separate __free() declaration in lan969x_fan_probe() --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] hwmon: lan969x-fan: separate __free() declaration in lan969x_fan_probe()
--
commit b2df768159182a27301144a0ba71d10e45a494fd
Author: Robert Marko <[email protected]>
hwmon: Add Microchip LAN969x fan controller driver
This commit adds a hwmon driver for the Microchip LAN969x fan controller, supporting tachometer input, PWM output, and thermal cooling.
Quoted 5 lines
drivers/hwmon/lan969x-fan.c new file +0
-0
[ ... ]
Quoted 9 lines
drivers/hwmon/lan969x-fan.c new file +9
-0+static int lan969x_fan_probe (struct platform_device *pdev) +{ +struct thermal_cooling_device *cdev; +struct device *dev = &pdev->dev; +struct lan969x_fan *fan; + struct device_node *fan_np __free(device_node) = NULL; +u32 initial_pwm; +int ret; +
drivers/hwmon/lan969x-fan.c line 378
Quoted 10 lines
drivers/hwmon/lan969x-fan.c new file +10
-0+ fan =devm_kzalloc (dev,sizeof (*fan),GFP_KERNEL ); +if (!fan) +return -ENOMEM ; + + fan->base =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (fan->base)) +return PTR_ERR (fan->base); + + fan->pulses_per_revolution =2 ; + fan_np =of_get_available_child_by_name (dev->of_node,"fan" );
[Severity: Low]
This isn't a bug, but per the cleanup.h conventions, fan_np should be defined and initialized in a single statement at the point of assignment rather than declared initialized to NULL at the top of lan969x_fan_probe().
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Re: [PATCH v3 3/4] hwmon: Add Microchip LAN969x fan controller driver
In reply to Robert MarkoQuoted 6 lines · Robert Marko
The LAN969x fan controller has its own register block, separate from the Sparx5-compatible temperature sensor.
Add a dedicated hwmon driver for tachometer, PWM, and thermal cooling.
Signed-off-by Robert Marko <[email protected]>
Applied.
Thanks,
Guenter
PATCH v3 4/4 arm64: dts: microchip: lan969x: add fan controller
In reply to Robert MarkoLAN969x provides a PWM fan output and tachometer input in a register block separate from the temperature sensor. Describe it as its own fan-controller node and keep the temperature sensor compatible.
Connect the EV23X71A fan to the controller and route its pins. Use a 25 kHz normal-polarity PWM for the board low-side FET. Set cooling levels so the fan starts at full speed.
---
Changes in v3:
- No DTS changes; renumber from 6/6 to 4/4.
Changes in v2:
- Split the fan controller from the temperature node.
- Add the EV23X71A fan child with board-specific PWM and cooling levels.
arch/arm64/boot/dts/microchip/lan9691.dtsi | 7 +++++++ arch/arm64/boot/dts/microchip/lan9696-ev23x71a.dts | 8 +++++++- 2 files changed, 14 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/microchip/lan9691.dtsi +7 -0
@@ -522,6 +522,13 @@ sgpio_out: gpio@1 { }; }; + fanctrl: fan-controller@e2010348 { + compatible = "microchip,lan9691-fan"; + reg = <0xe2010348 0xc>; + clocks = <&fx100_clk>; + #pwm-cells = <2>; + }; + tmon: hwmon@e2020100 { compatible = "microchip,lan9691-temp", "microchip,sparx5-temp"; reg = <0xe2020100 0xc>;
arch/arm64/boot/dts/microchip/lan9696-ev23x71a.dts +7 -1
@@ -775,9 +775,15 @@ port29: port@29 { }; }; -&tmon { +&fanctrl { pinctrl-0 = <&fan_pins>; pinctrl-names = "default"; + + fan { + pwms = <&fanctrl 40000 0>; + cooling-levels = <0 128 192 255>; + #cooling-cells = <2>; + }; }; &usart0 {
Signature · 1 line
2.56.0
[email protected]
AI reviewRe: [PATCH v3 4/4] arm64: dts: microchip: lan969x: add fan controller
Sashiko has reviewed this patch and found no issues.
Quoted 9 lines
LAN969x provides a PWM fan output and tachometer input in a register block separate from the temperature sensor. Describe it as its own fan-controller node and keep the temperature sensor compatible.
Connect the EV23X71A fan to the controller and route its pins. Use a 25 kHz normal-polarity PWM for the board low-side FET. Set cooling levels so the fan starts at full speed.
Signed-off-by Robert Marko <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 5 lines
A fan sensor cannot produce zero tachometer pulses per revolution. Add a minimum of one to the shared fan schema so every user rejects this invalid value.
Signed-off-by Robert Marko <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 11 lines · Robert Marko
A fan sensor cannot produce zero tachometer pulses per revolution. Add a minimum of one to the shared fan schema so every user rejects this invalid value.
Signed-off-by Robert Marko <[email protected]>---
Changes in v3:
- New patch: require at least one pulse per revolution in fan-common.Documentation/devicetree/bindings/hwmon/fan-common.yaml | 1 + 1 file changed, 1 insertion(+)
Quoted 6 lines · Robert Marko
A fan sensor cannot produce zero tachometer pulses per revolution. Add a minimum of one to the shared fan schema so every user rejects this invalid value.
Signed-off-by Robert Marko <[email protected]>Reviewed-by Rob Herring (Arm) <[email protected]>
Applied.
Thanks,
Guenter