Re: [PATCH v2] hwmon: (nct6683) Make pwmN_auto_channels_temp of NCT6687D-R writable

From: Guenter Roeck

Date: Sat Nov 28 2026 - 12:30:46 EST


On Tue, Nov 17, 2026 at 08:16:45AM +0100, Tomasz Bojanowski wrote:
> Allow selecting the temperature used by a fan curve on MSI boards with
> an NCT6687D-R (customer ID 0x20d), in manual and in automatic mode.
>
> On an MSI MAG B850M MORTAR WIFI, the BIOS setup offers four temperature
> sources for the fans: CPU Core, System, MOS and Chipset A. Reading the EC
> before and after selecting them shows that each sets a single bit in the
> lowest byte of the fan's source register, the bit of the monitoring
> channel of temp1, temp2, temp3 and temp4 respectively, and that nothing
> else in the fan curve registers changes. The other bytes were never seen
> in use, and how the EC would combine several bits is not known, so only
> a single temperature reported by the driver on the first eight monitoring
> channels can be selected; other values return -EINVAL. The range can be
> extended if a board needs it.
>
> The attribute is writable if, when the driver is loaded, the curve uses
> one such temperature. Before each write the driver checks that this is
> still the case and returns -EBUSY otherwise, so that it does not overwrite
> a source which could not be selected again.
>
> The source is written in a configuration phase and read back, as the
> curve points are. If that fails while the EC responds, the previous
> source is written again. Sources selected through sysfs are restored on
> resume, after the curves and before manual mode.
>
> Tested on an MSI MAG B850M MORTAR WIFI (MS-7E61) with pwm16 and a test
> curve rising by 10 per degree Celsius around the measured temperatures.
> After selecting temp2, temp3 and temp4 in turn in automatic mode, the
> duty cycle followed the curve for the newly selected temperature. Invalid
> values returned -EINVAL and left the source unchanged. A source selected
> in manual mode took effect after switching back to automatic mode. After
> suspend to RAM, the source and the curve were the same as before, and
> manual mode was still restored. With the driver unloaded during suspend,
> the BIOS restored its own curve but the EC kept the selected source, so
> restoring the source on resume could not be tested on this board.
>
> Signed-off-by: Tomasz Bojanowski <tomasz@xxxxxxxxxxxxx>

Applied.

Thanks,
Guenter