hwmon: (nct6775) Add support for NCT5525
Subsystems (2)
v2 cover hwmon: (nct6775) Add support for NCT5525
This implements support for the NCT5525 super I/O chip.
First two patches are minor fixes in the driver in preparation, and the last implements the actual support.
These are tested on a ASRock 4X4-V2000 board.
That board has a monitoring of the raw dc comming in to the board, which I thought I would be able to find as a monitor on this chip, but it's either a external voltage divider or it's monitored by something else.
Changes in v2:
- Dropped devicetree bindings
- Alphabetic order of chip lists
- Fixed word size access to dual-use registers
- Fan debounce fixed
- Fan support modeled as NCT6116 with fan3 and 4 unpopulated
- Corrected detection of AUXFAN2 rpm and pwm
- Corrected beep functionallity
- Link to v1: https://lore.kernel.org/all/[email protected]/
Anton Lundin (3):
hwmon: (nct6775) Handle dual use registers
hwmon: (nct6775) Avoid reading nonexistent PWM-mode registers
hwmon: (nct6775) Add support for NCT5525
Documentation/hwmon/nct6775.rst | 10 +- drivers/hwmon/nct6775-core.c | 154 +++++++++++++++++++++++++++++-- drivers/hwmon/nct6775-platform.c | 17 ++++ drivers/hwmon/nct6775.h | 5 +- 4 files changed, 174 insertions(+), 12 deletions(-)
Signature · 1 line
2.47.3
PATCH v2 1/3 hwmon: (nct6775) Handle dual use registers
The REG_TARGET register has different meaning, depending on if pwm is in thermal_cruise or speed_cruise.
This means we can't assume it's always word sized, so we need to handle it differently depending on which mode we're in.
The code already does this, but the register was configured as word sized for the speed_cruise mode, which would do the wrong thing in thermal_cruise mode.
--- drivers/hwmon/nct6775-core.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/hwmon/nct6775-core.c +2 -4
@@ -1188,15 +1188,13 @@ bool nct6775_reg_is_word_sized(struct nct6775_data *data, u16 reg)case nct6106:return reg ==0x20 || reg ==0x22 || reg ==0x24 || (reg >=0x59 && reg <0x69 && (reg &1 )) || - reg ==0xe0 || reg ==0xe2 || reg ==0xe4 || - reg ==0x111 || reg ==0x121 || reg ==0x131 ; + reg ==0xe0 || reg ==0xe2 || reg ==0xe4 ;case nct6116:case nct6126:return reg ==0x20 || reg ==0x22 || reg ==0x24 || reg ==0x26 || reg ==0x28 || reg ==0x59 || reg ==0x5b || reg ==0xe0 || reg ==0xe2 || reg ==0xe4 || reg ==0xe6 || - reg ==0xe8 || reg ==0x111 || reg ==0x121 || reg ==0x131 || - reg ==0x191 || reg ==0x1a1 ; + reg ==0xe8 ;case nct6775: return (((reg & 0xff00) == 0x100 || (reg & 0xff00) == 0x200) &&
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [PATCH v2 1/3] hwmon: (nct6775) Handle dual use registers
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] hwmon: (nct6775) missing Fixes trailers for REG_TARGET word-sized bug --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] hwmon: (nct6775) missing Fixes trailers for REG_TARGET word-sized bug
--
commit 07bbb498967ba79c83375f58dde7d2cb44db82b2
Author: Anton Lundin <[email protected]>
Quoted 5 lines
hwmon: (nct6775) Handle dual use registers
The
REG_TARGETregister has different meaning, depending on if pwm is inthermal_cruiseorspeed_cruise.
Quoted 8 lines
This means we can't assume it's always word sized, so we need to handle it differently depending on which mode we're in.
The code already does this, but the register was configured as word sized for the
speed_cruisemode, which would do the wrong thing inthermal_cruisemode.Signed-off-by Anton Lundin <[email protected]>
[Severity: Low]
Since this fixes how REG_TARGET is accessed in thermal_cruise mode on NCT6106, NCT6116, and NCT6126, should it include Fixes: tags for the commits that added those entries to nct6775_reg_is_word_sized()?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH v2 1/3] hwmon: (nct6775) Handle dual use registers
In reply to Anton LundinQuoted 11 lines · Anton Lundin
The
REG_TARGETregister has different meaning, depending on if pwm is inthermal_cruiseorspeed_cruise.This means we can't assume it's always word sized, so we need to handle it differently depending on which mode we're in.
The code already does this, but the register was configured as word sized for the
speed_cruisemode, which would do the wrong thing inthermal_cruisemode.Signed-off-by Anton Lundin <[email protected]>
Applied, and added the Fixes: tags as suggested by Sashiko.
Thanks,
Guenter
Quoted 26 lines
--- drivers/hwmon/nct6775-core.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/hwmon/nct6775-core.c +2
-4@@ -1188,15 +1188,13 @@ bool nct6775_reg_is_word_sized(struct nct6775_data *data, u16 reg)case nct6106:return reg ==0x20 || reg ==0x22 || reg ==0x24 || (reg >=0x59 && reg <0x69 && (reg &1 )) || - reg ==0xe0 || reg ==0xe2 || reg ==0xe4 || - reg ==0x111 || reg ==0x121 || reg ==0x131 ; + reg ==0xe0 || reg ==0xe2 || reg ==0xe4 ;case nct6116:case nct6126:return reg ==0x20 || reg ==0x22 || reg ==0x24 || reg ==0x26 || reg ==0x28 || reg ==0x59 || reg ==0x5b || reg ==0xe0 || reg ==0xe2 || reg ==0xe4 || reg ==0xe6 || - reg ==0xe8 || reg ==0x111 || reg ==0x121 || reg ==0x131 || - reg ==0x191 || reg ==0x1a1 ; + reg ==0xe8 ;case nct6775: return (((reg & 0xff00) == 0x100 || (reg & 0xff00) == 0x200) &&
PATCH v2 2/3 hwmon: (nct6775) Avoid reading nonexistent PWM-mode registers
In reply to Anton LundinA register value of 0 is used to say that this pwm doesn't have modes.
There were already a guard for this in store_pwm_mode() but nct6775_update_pwm() didn't have one, and read register 0 and then didn't use the value.
This introduces a guard so we won't read a configuration register we're not interested in.
--- drivers/hwmon/nct6775-core.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/hwmon/nct6775-core.c +9 -5
@@ -1432,11 +1432,15 @@ static int nct6775_update_pwm(struct device *dev)if (!(data->has_pwm &BIT (i)))continue ; - err =nct6775_read_value (data, data->REG_PWM_MODE[i], ®); -if (err) -return err; - duty_is_dc = data->REG_PWM_MODE[i] && (reg & data->PWM_MODE_MASK[i]); - data->pwm_mode[i] = !duty_is_dc; +if (data->REG_PWM_MODE[i] ==0 ) { + data->pwm_mode[i] =1 ; + }else { + err =nct6775_read_value (data, data->REG_PWM_MODE[i], ®); +if (err) +return err; + duty_is_dc = data->REG_PWM_MODE[i] && (reg & data->PWM_MODE_MASK[i]); + data->pwm_mode[i] = !duty_is_dc; + } err =nct6775_read_value (data, data->REG_FAN_MODE[i], &fanmodecfg);if (err)
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [PATCH v2 2/3] hwmon: (nct6775) Avoid reading nonexistent PWM-mode registers
Sashiko has reviewed this patch and found no issues.
Quoted 10 lines
A register value of 0 is used to say that this pwm doesn't have modes.
There were already a guard for this in
store_pwm_mode()butnct6775_update_pwm()didn't have one, and read register 0 and then didn't use the value.This introduces a guard so we won't read a configuration register we're not interested in.
Signed-off-by Anton Lundin <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Re: [PATCH v2 2/3] hwmon: (nct6775) Avoid reading nonexistent PWM-mode registers
In reply to Anton LundinQuoted 10 lines · Anton Lundin
A register value of 0 is used to say that this pwm doesn't have modes.
There were already a guard for this in
store_pwm_mode()butnct6775_update_pwm()didn't have one, and read register 0 and then didn't use the value.This introduces a guard so we won't read a configuration register we're not interested in.
Signed-off-by Anton Lundin <[email protected]>
Applied.
Thanks,
Guenter
PATCH v2 3/3 hwmon: (nct6775) Add support for NCT5525
In reply to Anton LundinExtend nct6775 driver to support NCT5525.
--- Documentation/hwmon/nct6775.rst | 10 ++- drivers/hwmon/nct6775-core.c | 134 +++++++++++++++++++++++++++++++ drivers/hwmon/nct6775-platform.c | 17 ++++ drivers/hwmon/nct6775.h | 5 +- 4 files changed, 163 insertions(+), 3 deletions(-)
Documentation/hwmon/nct6775.rst +9 -1
@@ -48,6 +48,14 @@ Supported chips: Datasheet: Available from the Nuvoton web site + * Nuvoton NCT5525D + + Prefix: 'nct5525' + + Addresses scanned: ISA address retrieved from Super I/O registers + + Datasheet: Available from Nuvoton upon request + * Nuvoton NCT5572D/NCT6771F/NCT6772F/NCT6775F/W83677HG-I Prefix: 'nct6775'
@@ -159,7 +167,7 @@ direct temperature sensor inputs, the others are special sources such as PECI, PCH, and SMBUS. Depending on the chip type, 2 to 6 of the temperature sources can be monitored and compared against minimum, maximum, and critical temperatures. The driver reports up to 10 of the temperatures to the user. -There are 4 to 5 fan rotation speed sensors, 8 to 15 analog voltage sensors, +There are 3 to 7 fan rotation speed sensors, 8 to 18 analog voltage sensors, one VID, alarms with beep warnings (control unimplemented), and some automatic fan regulation strategies (plus manual fan control mode).
drivers/hwmon/nct6775-core.c +134 -0
182 lines not on this page · raw message
drivers/hwmon/nct6775-platform.c +17 -0
@@ -23,6 +23,7 @@enum sensor_access { access_direct, access_asuswmi };static const char *const nct6775_sio_names[]__initconst = { + [nct5525] ="NCT5525D" , [nct6106] ="NCT6106D" , [nct6116] ="NCT6116D" , [nct6126] ="NCT6122D/NCT6126D" ,
@@ -75,6 +76,7 @@ MODULE_PARM_DESC(fan_debounce, "Enable debouncing for fan RPM signal");#define SIO_REG_ENABLE 0x30/* Logical device enable */ #define SIO_REG_ADDR 0x60/* Logical device address (2 bytes) */ +#define SIO_NCT5525_ID 0xd2b0#define SIO_NCT6106_ID 0xc450#define SIO_NCT6116_ID 0xd280#define SIO_NCT6122_ID 0xd2a0
@@ -547,6 +549,14 @@ nct6775_check_fan_inputs(struct nct6775_data *data, struct nct6775_sio_data *sio fan4min = fan4pin; pwm3pin = fan3pin; + }else if (data->kind == nct5525) { +/* Pin 48 can be GP64 / SCL / MSCL / AUXFANOUT2 */ +/* Pin 46 can be GP63 / SDA / MSDA / AUXFANIN2 */ +int cr1b = sio_data->sio_inb (sio_data,0x1b ); +int cr2a = sio_data->sio_inb (sio_data,0x2a ); + + fan5pin = (!(cr1b &0x03 ) && (cr2a &0x01 )); + pwm5pin = fan5pin; }else if (data->kind == nct6106) {int cr24 = sio_data->sio_inb (sio_data,0x24 );
@@ -882,6 +892,7 @@ static int nct6775_platform_probe_init(struct nct6775_data *data)case nct6776: data->have_vid = (cr2a &0x60 ) ==0x40 ;break ; +case nct5525:case nct6106:case nct6116:case nct6126:
@@ -914,6 +925,9 @@ static int nct6775_platform_probe_init(struct nct6775_data *data) tmp = sio_data->sio_inb (sio_data,NCT6775_REG_CR_FAN_DEBOUNCE );switch (data->kind) { +case nct5525: + tmp |=0x68 ; +break ;case nct6106:case nct6116:case nct6126:
@@ -1027,6 +1041,9 @@ static int __init nct6775_find(int sioaddr, struct nct6775_sio_data *sio_data) val = force_id;switch (val &SIO_ID_MASK ) { +case SIO_NCT5525_ID : + sio_data->kind = nct5525; +break ;case SIO_NCT6106_ID : sio_data->kind = nct6106;break ;
drivers/hwmon/nct6775.h +3 -2
@@ -4,8 +4,9 @@#include <linux/types.h> -enum kinds { nct6106, nct6116, nct6126, nct6775, nct6776, nct6779, nct6791, - nct6792, nct6793, nct6795, nct6796, nct6797, nct6798, nct6799 }; +enum kinds { nct5525, nct6106, nct6116, nct6126, nct6775, nct6776, nct6779, + nct6791, nct6792, nct6793, nct6795, nct6796, nct6797, nct6798, + nct6799 };enum pwm_enable { off, manual, thermal_cruise, speed_cruise, sf3, sf4 };#define NUM_TEMP 12/* Max number of temp attribute sets w/ limits*/
Signature · 1 line
2.47.3
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 3 lines
Extend nct6775 driver to support NCT5525.
Signed-off-by Anton Lundin <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Quoted 3 lines · Anton Lundin
Extend nct6775 driver to support NCT5525.
Signed-off-by Anton Lundin <[email protected]>
Applied.
Thanks,
Guenter