Re: [PATCH] [RFC] hwmon: nct6775: Register fan PWMs as PWM chip

From: Guenter Roeck

Date: Thu Feb 26 2026 - 17:39:45 EST


On 2/25/26 04:51, Richard Weinberger wrote:
The Nuvoton 6775 chip family also offers PWM functionality to control
various fans. Depending on the hardware design, the PWM can also be
used for other purposes, such as controlling a display backlight.

Historically, the driver implemented its own sysfs-based interface to
control the PWMs. This made it impossible to use the PWM as a backend
for other drivers, such as pwm-backlight.

This patch registers the PWM functionality as a PWM chip within the
PWM subsystem. Since the Nuvoton chip has non-trivial control logic,
the following constraints exist:

- Exporting a PWM for external use is only allowed when the fan mode
is set to manual or off.
- As soon as a PWM is exported, changing its configuration is no
longer possible through the hwmon sysfs interface, reading is
still allowed.
- Changing the PWM period is not supported. IMHO, it is too risky
since the PWMs usually control system fans and similar components.
- Reading and decoding the current PWM period is only supported for
one chip variant so far, for all other chips, a fixed period of
100ms is assumed.


This is a good start, but I'll want to see stronger safeguards.
- Creating a pwmchip entry for a pwm channel must be triggered by
device property data, obtained either from devicetree or through
DMI or through device properties embedded in ACPI data. For each
channel, this must be confirmed by checking that the channel is
not associated with a fan control channel.
- If a pwm channel is configured as pwmchip, it must not be used for fan
control, meaning the hwmon properties associated with that channel
must not be created.

This will retain current functionality while enabling support for using
pwm channels for purposes other than fan control.

Thanks,
Guenter