2023-11-20 08:17:51

by Xing Tong Wu

[permalink] [raw]
Subject: [PATCH v2 0/2] hwmon: (nct6775) Fix pwm bugs for NCT chips

From: Xing Tong Wu <[email protected]>

These patches address bugs in the pwm features that do not meet the
specification definition.

changes since v1:
- Add PWM mode and mask register arrays for NCT6116
- Delete 2nd patch for pwm_enable change
- Delete log print and add comment for pwm failure set

Xing Tong Wu (2):
hwmon: (nct6775) Fix incomplete register array
hwmon: (nct6775) Fix fan speed set failure in automatic mode

drivers/hwmon/nct6775-core.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)

--
2.25.1


2023-11-20 08:18:03

by Xing Tong Wu

[permalink] [raw]
Subject: [PATCH v2 2/2] hwmon: (nct6775) Fix fan speed set failure in automatic mode

From: Xing Tong Wu <[email protected]>

Setting the fan speed is only valid in manual mode; it is not possible
to set the fan's speed in automatic mode.
Return error when attempting to set the fan speed in automatic mode.

Signed-off-by: Xing Tong Wu <[email protected]>
---
drivers/hwmon/nct6775-core.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/drivers/hwmon/nct6775-core.c b/drivers/hwmon/nct6775-core.c
index c24b2c312911..38c2e5b7cfe9 100644
--- a/drivers/hwmon/nct6775-core.c
+++ b/drivers/hwmon/nct6775-core.c
@@ -2556,6 +2556,13 @@ store_pwm(struct device *dev, struct device_attribute *attr, const char *buf,
int err;
u16 reg;

+ /*
+ * The fan control mode should be set to manual if the user wants to adjust
+ * the fan speed. Otherwise, it will fail to set.
+ */
+ if (index == 0 && data->pwm_enable[nr] > manual)
+ return -EBUSY;
+
err = kstrtoul(buf, 10, &val);
if (err < 0)
return err;
--
2.25.1

2023-11-20 08:31:41

by Xing Tong Wu

[permalink] [raw]
Subject: [PATCH v2 1/2] hwmon: (nct6775) Fix incomplete register array

From: Xing Tong Wu <[email protected]>

The nct6116 specification actually includes 5 PWMs, but only 3
PWMs are present in the array. To address this, the missing 2
PWMs have been added to the array.

Signed-off-by: Xing Tong Wu <[email protected]>
---
drivers/hwmon/nct6775-core.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/hwmon/nct6775-core.c b/drivers/hwmon/nct6775-core.c
index d928eb8ae5a3..c24b2c312911 100644
--- a/drivers/hwmon/nct6775-core.c
+++ b/drivers/hwmon/nct6775-core.c
@@ -844,6 +844,9 @@ static const u16 NCT6116_REG_FAN_PULSES[] = { 0xf6, 0xf6, 0xf6, 0xf6, 0xf5 };
static const u16 NCT6116_FAN_PULSE_SHIFT[] = { 0, 2, 4, 6, 6 };

static const u16 NCT6116_REG_PWM[] = { 0x119, 0x129, 0x139, 0x199, 0x1a9 };
+static const u8 NCT6116_REG_PWM_MODE[] = { 0xf3, 0xf3, 0xf3, 0xf3, 0xf3 };
+static const u8 NCT6116_PWM_MODE_MASK[] = { 0x01, 0x02, 0x04, 0x04, 0x04 };
+static const u16 NCT6116_REG_PWM_READ[] = { 0x4a, 0x4b, 0x4c, 0xd8, 0xd9 };
static const u16 NCT6116_REG_FAN_MODE[] = { 0x113, 0x123, 0x133, 0x193, 0x1a3 };
static const u16 NCT6116_REG_TEMP_SEL[] = { 0x110, 0x120, 0x130, 0x190, 0x1a0 };
static const u16 NCT6116_REG_TEMP_SOURCE[] = {
@@ -3595,7 +3598,7 @@ int nct6775_probe(struct device *dev, struct nct6775_data *data,
break;
case nct6116:
data->in_num = 9;
- data->pwm_num = 3;
+ data->pwm_num = 5;
data->auto_pwm_num = 4;
data->temp_fixed_num = 3;
data->num_temp_alarms = 3;
@@ -3629,9 +3632,9 @@ int nct6775_probe(struct device *dev, struct nct6775_data *data,
data->REG_PWM[2] = NCT6116_REG_FAN_STOP_OUTPUT;
data->REG_PWM[5] = NCT6106_REG_WEIGHT_DUTY_STEP;
data->REG_PWM[6] = NCT6106_REG_WEIGHT_DUTY_BASE;
- data->REG_PWM_READ = NCT6106_REG_PWM_READ;
- data->REG_PWM_MODE = NCT6106_REG_PWM_MODE;
- data->PWM_MODE_MASK = NCT6106_PWM_MODE_MASK;
+ data->REG_PWM_READ = NCT6116_REG_PWM_READ;
+ data->REG_PWM_MODE = NCT6116_REG_PWM_MODE;
+ data->PWM_MODE_MASK = NCT6116_PWM_MODE_MASK;
data->REG_AUTO_TEMP = NCT6116_REG_AUTO_TEMP;
data->REG_AUTO_PWM = NCT6116_REG_AUTO_PWM;
data->REG_CRITICAL_TEMP = NCT6116_REG_CRITICAL_TEMP;
--
2.25.1

2023-11-20 14:46:37

by Guenter Roeck

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] hwmon: (nct6775) Fix incomplete register array

On 11/20/23 00:15, Xing Tong Wu wrote:
> From: Xing Tong Wu <[email protected]>
>
> The nct6116 specification actually includes 5 PWMs, but only 3
> PWMs are present in the array. To address this, the missing 2
> PWMs have been added to the array.
>
> Signed-off-by: Xing Tong Wu <[email protected]>
> ---
> drivers/hwmon/nct6775-core.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/hwmon/nct6775-core.c b/drivers/hwmon/nct6775-core.c
> index d928eb8ae5a3..c24b2c312911 100644
> --- a/drivers/hwmon/nct6775-core.c
> +++ b/drivers/hwmon/nct6775-core.c
> @@ -844,6 +844,9 @@ static const u16 NCT6116_REG_FAN_PULSES[] = { 0xf6, 0xf6, 0xf6, 0xf6, 0xf5 };
> static const u16 NCT6116_FAN_PULSE_SHIFT[] = { 0, 2, 4, 6, 6 };
>
> static const u16 NCT6116_REG_PWM[] = { 0x119, 0x129, 0x139, 0x199, 0x1a9 };
> +static const u8 NCT6116_REG_PWM_MODE[] = { 0xf3, 0xf3, 0xf3, 0xf3, 0xf3 };
> +static const u8 NCT6116_PWM_MODE_MASK[] = { 0x01, 0x02, 0x04, 0x04, 0x04 };

No, this isn't correct. Chapter 8.4.4 in the datasheet says that auxfanout1 and
auxfanout2 are always in pwm mode, so those register addresses and bit positions
need to be 0 in the array. Also, please just extend the NCT6106 arrays.

> +static const u16 NCT6116_REG_PWM_READ[] = { 0x4a, 0x4b, 0x4c, 0xd8, 0xd9 };

Please just extend the nct6106 array.

Thanks,
Guenter

2023-11-20 14:51:55

by Guenter Roeck

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] hwmon: (nct6775) Fix incomplete register array

On 11/20/23 00:15, Xing Tong Wu wrote:
> From: Xing Tong Wu <[email protected]>
>
> The nct6116 specification actually includes 5 PWMs, but only 3
> PWMs are present in the array. To address this, the missing 2
> PWMs have been added to the array.
>

Please rephrase.

The subject and the description is a bit misleading. The need to extend
the arrays is necessary, but the key change is adding support for the two
additional fan controls.

Thanks,
Guenter