hwmon: Add fan tachometer support for Raspberry Pi RP1
Subsystems (3)
v2 cover hwmon: Add fan tachometer support for Raspberry Pi RP1
Hi,
This patch adds fan tachometer / RPM monitoring support for the Raspberry Pi RP1 southbridge found on the Raspberry Pi 5.
The fan speed is measured by the RP1 Cortex-M firmware, which writes the computed RPM value into a register of the RP1 PWM controller block.
Following the discussion on the RFC [1], the driver is now implemented as an auxiliary driver: the RP1 PWM driver registers a "fan" auxiliary device (pwm_rp1.fan.<id>) and this driver binds to it, reading the RPM through rp1_pwm_read_tachometer(), exported by the PWM driver in the 'RP1_PWM' symbol namespace (as suggested in the auxiliary bus documentation and agreed in [2]).
This series depends on the RP1 PWM series [3], which provides both the auxiliary device and the exported accessor.
Changes since RFC:
- converted from platform driver to auxiliary driver
- dropped the 'raspberrypi,rp1-fan' DT binding and the DTS node: the device is now instantiated by the PWM driver
- dropped the DT phandle lookup, device link and reference handling:
the auxiliary device is a child of the PWM controller, so the driver model already guarantees the correct lifetime and unbind ordering
- rp1_pwm_read_tachometer() now takes the auxiliary device and returns the RPM through a pointer, separating it from the error code
- Kconfig: depend on PWM_RASPBERRYPI_RP1 without the COMPILE_TEST alternative, fixing the link error reported by the kernel test robot when the hwmon driver is built-in and the PWM driver is a module
- removed <linux/mod_devicetable.h> and the other unneeded includes (Uwe)
- updated Documentation/hwmon/rp1-fan.rst to reflect the changes
- added a dedicated MAINTAINERS entry for the driver, instead of adding it to the RP1 PCI driver entry
[1] - https://lore.kernel.org/all/[email protected]/
[2] - https://lore.kernel.org/all/[email protected]/
[3] - https://lore.kernel.org/all/[email protected]/
Thanks,
Andrea
This version has been prepared with the help of an AI coding assistant (Claude Opus 5.5).
Andrea della Porta (1):
hwmon: Add driver for Raspberry Pi RP1 fan tachometer
Documentation/hwmon/index.rst | 1 + Documentation/hwmon/rp1-fan.rst | 43 ++++++++++++++++++ MAINTAINERS | 7 +++ drivers/hwmon/Kconfig | 11 +++++ drivers/hwmon/Makefile | 1 + drivers/hwmon/rp1-hwmon.c | 78 +++++++++++++++++++++++++++++++++ 6 files changed, 141 insertions(+) create mode 100644 Documentation/hwmon/rp1-fan.rst create mode 100644 drivers/hwmon/rp1-hwmon.c
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
prerequisite-patch-id: 8a9c7c53e94bfc4dd1dc40e8277f22c1f410f404
prerequisite-patch-id: 3053bded44bcd6a78ecae5a255ae876c5a9cb49b
prerequisite-patch-id: ade915a82dd15722ecb44802d307ff9d60a79228
Signature · 1 line
2.51.0
PATCH v2 1/1 hwmon: Add driver for Raspberry Pi RP1 fan tachometer
Add a hardware monitoring driver to support the fan tachometer on the Raspberry Pi RP1 southbridge, found on the Raspberry Pi 5.
The RP1 PWM controller block contains an MMIO register that holds the current fan speed in RPM. This register is periodically updated by the RP1 internal firmware based on the tachometer pulses.
The RP1 PWM driver registers a "fan" auxiliary device for the tachometer. This driver binds to it as an auxiliary driver and reads the RPM value through rp1_pwm_read_tachometer(), exported by the PWM driver in the 'RP1_PWM' symbol namespace. Since the auxiliary device is a child of the PWM controller, no Device Tree node is needed and the lifetime of this driver is bound to the one of the PWM controller.
Provides the standard hwmon sysfs attribute 'fan1_input'.
--- Documentation/hwmon/index.rst | 1 + Documentation/hwmon/rp1-fan.rst | 43 ++++++++++++++++++ MAINTAINERS | 7 +++ drivers/hwmon/Kconfig | 11 +++++ drivers/hwmon/Makefile | 1 + drivers/hwmon/rp1-hwmon.c | 78 +++++++++++++++++++++++++++++++++ 6 files changed, 141 insertions(+) create mode 100644 Documentation/hwmon/rp1-fan.rst create mode 100644 drivers/hwmon/rp1-hwmon.c
Documentation/hwmon/index.rst +1 -0
@@ -240,6 +240,7 @@ Hardware Monitoring Kernel Drivers q54sj108a2 qnap-mcu-hwmon raspberrypi-hwmon + rp1-fan sbrmi sbtsi_temp sch5627
Documentation/hwmon/rp1-fan.rst new file +43 -0
43 lines not on this page · raw message
MAINTAINERS +7 -0
@@ -23368,6 +23368,13 @@ S: Maintained F: Documentation/devicetree/bindings/media/raspberrypi,rp1-cfe.yaml F: drivers/media/platform/raspberrypi/rp1-cfe/ +RASPBERRY PI RP1 FAN TACHOMETER DRIVER +M: Andrea della Porta <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/hwmon/rp1-fan.rst +F: drivers/hwmon/rp1-hwmon.c + RASPBERRY PI RP1 PCI DRIVER M: Andrea della Porta <[email protected]> S: Maintained
drivers/hwmon/Kconfig +11 -0
@@ -2020,6 +2020,17 @@ config SENSORS_RASPBERRYPI_HWMON This driver can also be built as a module. If so, the module will be called raspberrypi-hwmon. +config SENSORS_RP1_FAN + tristate "Raspberry Pi RP1 PWM Fan Support" + depends on PWM_RASPBERRYPI_RP1 + help + If you say yes here you get support for reading the fan tachometer + from Raspberry Pi RP1. The driver binds to the auxiliary device + registered by the RP1 PWM controller driver. + + This driver can also be built as a module. If so, the module + will be called rp1-hwmon. + config SENSORS_SL28CPLD tristate "Kontron sl28cpld hardware monitoring driver" depends on MFD_SL28CPLD || COMPILE_TEST
drivers/hwmon/Makefile +1 -0
@@ -211,6 +211,7 @@ obj-$(CONFIG_SENSORS_PT5161L) += pt5161l.o obj-$(CONFIG_SENSORS_PWM_FAN) += pwm-fan.o obj-$(CONFIG_SENSORS_QNAP_MCU_HWMON) += qnap-mcu-hwmon.o obj-$(CONFIG_SENSORS_RASPBERRYPI_HWMON) += raspberrypi-hwmon.o +obj-$(CONFIG_SENSORS_RP1_FAN) += rp1-hwmon.o obj-$(CONFIG_SENSORS_SBTSI) += sbtsi_temp.o obj-$(CONFIG_SENSORS_SCH56XX_COMMON)+= sch56xx-common.o obj-$(CONFIG_SENSORS_SCH5627) += sch5627.o
drivers/hwmon/rp1-hwmon.c new file +78 -0
78 lines not on this page · raw message
Signature · 1 line
2.51.0
[email protected]
AI reviewRe: [PATCH v2 1/1] hwmon: Add driver for Raspberry Pi RP1 fan tachometer
Sashiko has reviewed this patch and found no issues.
Quoted 14 lines
Add a hardware monitoring driver to support the fan tachometer on the Raspberry Pi RP1 southbridge, found on the Raspberry Pi 5.
The RP1 PWM controller block contains an MMIO register that holds the current fan speed in RPM. This register is periodically updated by the RP1 internal firmware based on the tachometer pulses.
The RP1 PWM driver registers a "fan" auxiliary device for the tachometer. This driver binds to it as an auxiliary driver and reads the RPM value through
rp1_pwm_read_tachometer(), exported by the PWM driver in the 'RP1_PWM' symbol namespace. Since the auxiliary device is a child of the PWM controller, no Device Tree node is needed and the lifetime of this driver is bound to the one of the PWM controller.
Quoted 3 lines
Provides the standard hwmon sysfs attribute '
fan1_input'.Signed-off-by Andrea della Porta <[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
Re: [PATCH v2 1/1] hwmon: Add driver for Raspberry Pi RP1 fan tachometer
In reply to Andrea della PortaQuoted 14 lines · Andrea della Porta
Add a hardware monitoring driver to support the fan tachometer on the Raspberry Pi RP1 southbridge, found on the Raspberry Pi 5.
The RP1 PWM controller block contains an MMIO register that holds the current fan speed in RPM. This register is periodically updated by the RP1 internal firmware based on the tachometer pulses.
The RP1 PWM driver registers a "fan" auxiliary device for the tachometer. This driver binds to it as an auxiliary driver and reads the RPM value through
rp1_pwm_read_tachometer(), exported by the PWM driver in the 'RP1_PWM' symbol namespace. Since the auxiliary device is a child of the PWM controller, no Device Tree node is needed and the lifetime of this driver is bound to the one of the PWM controller.
Quoted 3 lines
Provides the standard hwmon sysfs attribute '
fan1_input'.Signed-off-by Andrea della Porta <[email protected]>
I assume that the driver will be applied together with the changes introducing rp1_pwm_read_tachometer().
Guenter