hwmon: (adt7475) Add thermal sensor and PWM provider support
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest4 patches 10 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/4 | dt-bindings: hwmon: adt7475: Add #thermal-sensor-cellsDocumentation/ | +16 | 1 reply | |
| 2/4 | hwmon: (adt7475) Convert to hwmon_device_register_with_info()drivers/ | +467 | 5 replies | |
| 3/4 | hwmon: (adt7475) Add thermal zone sensor supportDocumentation/ drivers/ | +15 | 0 replies | |
| 4/4 | hwmon: (adt7475) Expose fan control via PWM frameworkDocumentation/ drivers/ | +322 | 1 reply |
Reviews trailers per patch
1 of 4 patches has a Reviewed-by or Acked-by.
| Patch | Krzysztof Kozlowski |
|---|---|
| 1/4 | R-b |
| 2/4 | |
| 3/4 | |
| 4/4 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH 0/4] hwmon: (adt7475) Add thermal sensor and PWM provider support
This series lets boards use the temperature channels of the ADT7473, ADT7475, ADT7476 and ADT7490 as thermal zone sensors, and drive their PWM outputs with a PWM consumer such as pwm-fan. The kernel thermal framework can then control the fans. It follows the ADT7470 series [1], merged for v7.3.
The board it is for is the Ubiquiti UniFi USW Pro XG 8 PoE, a switch with a Realtek RTL9313 (MIPS) SoC. Its ADT7475 drives both fans and reads the CPU and SFP area temperatures. The fans must also follow eight PHY temperatures that the ADT7475 cannot read, so the chip's automatic mode does not fit.
Patch 1 adds "#thermal-sensor-cells" to the binding. Patch 2 converts the driver to hwmon_device_register_with_info(), through which the hwmon core registers thermal sensors. Patch 3 registers them. Patch 4 registers a PWM chip when the node has "#pwm-cells".
Differences from ADT7470:
- While a PWM consumer holds a channel, writes to that channel's hwmon PWM attributes fail with -EBUSY. ADT7470 hides its PWM attributes when "#pwm-cells" is present. The ADT7475 binding has documented "#pwm-cells" for fan-N children since v6.12, and device trees that follow it must keep their attributes. If preferred, the attributes could instead be hidden when "#pwm-cells" is present and there are no fan-N children.
- The period of each supported frequency is 1 s divided by the frequency, rounded down, so the 44444 ns the binding documents selects 22.5 kHz exactly. ADT7470 rounds up.
- No warning about "#pwm-cells" without CONFIG_PWM, because fan-N children use the property too.
duty_offset_ns is ignored: the chip has no offset, and 0 is the round-down result for any requested offset.
Testing on hwmon-next, the base of this series:
- checkpatch.pl --strict and dt_binding_check are clean. W=1 builds of adt7475.o after each patch, with CONFIG_PWM and CONFIG_THERMAL_OF each on and off, give no warnings. sparse reports nothing for adt7475.c, and the hwmon htmldocs build gives no warning for adt7475.rst.
- x86_64 QEMU guest with i2c-stub, all four chip types, five register images each: the attribute list, every value read and written, and the final register contents are identical before and after patch 2, apart from the two -ERANGE cases its message lists. The same comparison between patches 3 and 4, with and without "#pwm-cells" and with no PWM consumer, is identical too.
- The same guest with PWM_DEBUG and PROVE_LOCKING runs the PWM sysfs interface and pwm-fan as consumers, including unbinding the chip under them. No PWM core or lockdep warning.
Testing on hardware, on the switch above running OpenWrt with this series backported to 6.18. The backported driver differs from this series only where 6.18 and hwmon-next differ:
- Ten thermal zones (the ADT7475's two remote channels and the eight PHYs) drive both fans through pwm-fan at 22.5 kHz. The fan curve was stepped through with emul_temp on three zones, and the first trip on the other seven; fan state and duty registers matched the expected values.
- Unloading and reloading pwm-fan and adt7475: the fans stay at full speed while pwm-fan is unloaded, and thermal control resumes after the reload.
- Writes to the hwmon attributes of the held channels return -EBUSY and leave the registers unchanged; pwm3 stays writable.
The hwmon-next version itself has not run on hardware.
This patch was written with Claude Code, using the models Claude Opus 5.5 and Claude Fable 5.2. They wrote the code and the initial commit message draft, which I cleaned up. I directed the design, reviewed the result, compared against the datasheet as far as I could, and ran tests including on actual hardware.
Davíð Steinn Geirsson (4):
dt-bindings: hwmon: adt7475: Add #thermal-sensor-cells
hwmon: (adt7475) Convert to hwmon_device_register_with_info()
hwmon: (adt7475) Add thermal zone sensor support
hwmon: (adt7475) Expose fan control via PWM framework
.../devicetree/bindings/hwmon/adt7475.yaml | 16 + Documentation/hwmon/adt7475.rst | 18 + drivers/hwmon/adt7475.c | 1266 ++++++++++------- 3 files changed, 809 insertions(+), 491 deletions(-)
base-commit: f9f5501d60c77c71f60bf5b273375e3777d66080
Signature · 1 line
2.56.0