* [PATCH v2 0/1] hwmon: Add fan tachometer support for Raspberry Pi RP1
@ 2026-11-24 17:38 Andrea della Porta
2026-11-24 17:39 ` [PATCH v2 1/1] hwmon: Add driver for Raspberry Pi RP1 fan tachometer Andrea della Porta
0 siblings, 1 reply; 3+ messages in thread
From: Andrea della Porta @ 2026-11-24 17:38 UTC (permalink / raw)
To: Guenter Roeck, linux-hwmon, linux-kernel
Cc: Jonathan Corbet, Shuah Khan, Randy Dunlap, linux-doc,
Uwe Kleine-König, linux-pwm, Gary Guo, Andrea della Porta
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/cover.1792748690.git.andrea.porta@suse.com/
[2] - https://lore.kernel.org/all/ae9a4df9-b1f2-4f00-ab86-d9cf8d9bc387@roeck-us.net/
[3] - https://lore.kernel.org/all/20261124173658.31030-1-andrea.porta@suse.com/
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
--
2.51.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2 1/1] hwmon: Add driver for Raspberry Pi RP1 fan tachometer
2026-11-24 17:38 [PATCH v2 0/1] hwmon: Add fan tachometer support for Raspberry Pi RP1 Andrea della Porta
@ 2026-11-24 17:39 ` Andrea della Porta
2026-11-24 17:40 ` sashiko-bot
0 siblings, 1 reply; 3+ messages in thread
From: Andrea della Porta @ 2026-11-24 17:39 UTC (permalink / raw)
To: Guenter Roeck, linux-hwmon, linux-kernel
Cc: Jonathan Corbet, Shuah Khan, Randy Dunlap, linux-doc,
Uwe Kleine-König, linux-pwm, Gary Guo, 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.
Provides the standard hwmon sysfs attribute 'fan1_input'.
Signed-off-by: Andrea della Porta <andrea.porta@suse.com>
---
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
diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst
index 199ca79621e9..2d81cf3b46ff 100644
--- a/Documentation/hwmon/index.rst
+++ b/Documentation/hwmon/index.rst
@@ -240,6 +240,7 @@ Hardware Monitoring Kernel Drivers
q54sj108a2
qnap-mcu-hwmon
raspberrypi-hwmon
+ rp1-fan
sbrmi
sbtsi_temp
sch5627
diff --git a/Documentation/hwmon/rp1-fan.rst b/Documentation/hwmon/rp1-fan.rst
new file mode 100644
index 000000000000..d345551306d8
--- /dev/null
+++ b/Documentation/hwmon/rp1-fan.rst
@@ -0,0 +1,43 @@
+.. SPDX-License-Identifier: GPL-2.0-only
+
+Raspberry Pi RP1 fan tachometer
+=======================================
+
+Supported chips:
+
+ * Raspberry Pi RP1
+
+ Prefix: 'rp1_fan'
+
+ Addresses scanned: -
+
+ Datasheet: not public
+
+Author: Andrea della Porta <andrea.porta@suse.com>
+
+Description
+-----------
+
+The Raspberry Pi RP1 is a multi-function I/O controller (southbridge) used
+on boards such as the Raspberry Pi 5. Among its peripherals, the RP1 includes
+a PWM controller responsible for fan control.
+
+In addition to standard PWM output, the RP1 provides fan speed monitoring
+(tachometer). The tachometer pulse measurement is performed internally by
+firmware running on the RP1 Cortex-M microcontroller core. The computed fan
+speed (RPM) is periodically updated by the firmware directly into dedicated
+MMIO registers located within the RP1 PWM block.
+
+The RP1 PWM controller driver registers an auxiliary device (pwm_rp1.fan.<id>)
+for the tachometer. This driver binds to that auxiliary device, reads the
+firmware-updated register through the PWM driver and exposes the fan speed as
+standard hwmon sysfs attributes. No dedicated Device Tree node is required.
+
+Sysfs entries
+-------------
+
+The following attributes are supported.
+
+======================= ========================================================
+fan1_input fan tachometer speed in RPM (RO)
+======================= ========================================================
diff --git a/MAINTAINERS b/MAINTAINERS
index 26f8520c02ee..f4d011630389 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -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 <andrea.porta@suse.com>
+L: linux-hwmon@vger.kernel.org
+S: Maintained
+F: Documentation/hwmon/rp1-fan.rst
+F: drivers/hwmon/rp1-hwmon.c
+
RASPBERRY PI RP1 PCI DRIVER
M: Andrea della Porta <andrea.porta@suse.com>
S: Maintained
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 18c682e1a475..c668b1f458b5 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -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
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
index d4c345ed7261..5c5ffc900a12 100644
--- a/drivers/hwmon/Makefile
+++ b/drivers/hwmon/Makefile
@@ -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
diff --git a/drivers/hwmon/rp1-hwmon.c b/drivers/hwmon/rp1-hwmon.c
new file mode 100644
index 000000000000..473e6c95f638
--- /dev/null
+++ b/drivers/hwmon/rp1-hwmon.c
@@ -0,0 +1,78 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Hardware monitoring fan driver for Raspberry Pi RP1
+ *
+ * The fan speed is measured by the RP1 firmware and reported through a
+ * register of the RP1 PWM controller. The PWM driver registers a "fan"
+ * auxiliary device which this driver binds to.
+ */
+
+#include <linux/auxiliary_bus.h>
+#include <linux/err.h>
+#include <linux/hwmon.h>
+#include <linux/module.h>
+#include <soc/bcm2835/raspberrypi-pwm-rp1.h>
+
+static int rp1_fan_read(struct device *dev, enum hwmon_sensor_types type,
+ u32 attr, int channel, long *val)
+{
+ struct auxiliary_device *adev = dev_get_drvdata(dev);
+ u32 rpm;
+ int ret;
+
+ if (type != hwmon_fan || attr != hwmon_fan_input)
+ return -EOPNOTSUPP;
+
+ ret = rp1_pwm_read_tachometer(adev, &rpm);
+ if (ret)
+ return ret;
+
+ *val = rpm;
+
+ return 0;
+}
+
+static const struct hwmon_channel_info * const rp1_fan_info[] = {
+ HWMON_CHANNEL_INFO(fan, HWMON_F_INPUT),
+ NULL
+};
+
+static const struct hwmon_ops rp1_fan_hwmon_ops = {
+ .visible = 0444,
+ .read = rp1_fan_read,
+};
+
+static const struct hwmon_chip_info rp1_fan_chip_info = {
+ .ops = &rp1_fan_hwmon_ops,
+ .info = rp1_fan_info,
+};
+
+static int rp1_fan_probe(struct auxiliary_device *adev,
+ const struct auxiliary_device_id *id)
+{
+ struct device *hwmon_dev;
+
+ hwmon_dev = devm_hwmon_device_register_with_info(&adev->dev, "rp1_fan",
+ adev,
+ &rp1_fan_chip_info,
+ NULL);
+
+ return PTR_ERR_OR_ZERO(hwmon_dev);
+}
+
+static const struct auxiliary_device_id rp1_fan_ids[] = {
+ { .name = "pwm_rp1.fan" },
+ { }
+};
+MODULE_DEVICE_TABLE(auxiliary, rp1_fan_ids);
+
+static struct auxiliary_driver rp1_fan_driver = {
+ .probe = rp1_fan_probe,
+ .id_table = rp1_fan_ids,
+};
+module_auxiliary_driver(rp1_fan_driver);
+
+MODULE_AUTHOR("Andrea della Porta <andrea.porta@suse.com>");
+MODULE_DESCRIPTION("Raspberry Pi RP1 HWMon Fan Driver");
+MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS("RP1_PWM");
--
2.51.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2 1/1] hwmon: Add driver for Raspberry Pi RP1 fan tachometer
2026-11-24 17:39 ` [PATCH v2 1/1] hwmon: Add driver for Raspberry Pi RP1 fan tachometer Andrea della Porta
@ 2026-11-24 17:40 ` sashiko-bot
0 siblings, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-11-24 17:40 UTC (permalink / raw)
To: Andrea della Porta, linux-hwmon
> 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'.
>
> Signed-off-by: Andrea della Porta <andrea.porta@suse.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124173900.31266-1-andrea.porta@suse.com?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-24 17:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 17:38 [PATCH v2 0/1] hwmon: Add fan tachometer support for Raspberry Pi RP1 Andrea della Porta
2026-11-24 17:39 ` [PATCH v2 1/1] hwmon: Add driver for Raspberry Pi RP1 fan tachometer Andrea della Porta
2026-11-24 17:40 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox