Linux-Hwmon Archive on lore.kernel.org
 help / color / Atom feed
* [v1,1/1] hwmon: (nct7904) Fix incorrect SMI status register setting of LTD temperature and fan.
@ 2019-09-12 11:33 Amy.Shih
  2019-09-12 18:53 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Amy.Shih @ 2019-09-12 11:33 UTC (permalink / raw)
  To: she90122
  Cc: amy.shih, oakley.ding, bichan.lu, Jean Delvare, Guenter Roeck,
	linux-hwmon, linux-kernel

From: "amy.shih" <amy.shih@advantech.com.tw>

According to datasheet, the SMI status register setting of LTD
temperature is SMI_STS3, and the SMI status register setting
of fan is SMI_STS5 and SMI_STS6.

Signed-off-by: amy.shih <amy.shih@advantech.com.tw>
---
 drivers/hwmon/nct7904.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/nct7904.c b/drivers/hwmon/nct7904.c
index ce688ab4fce2..95b447cfa24c 100644
--- a/drivers/hwmon/nct7904.c
+++ b/drivers/hwmon/nct7904.c
@@ -51,6 +51,7 @@
 #define VSEN1_HV_HL_REG		0x00	/* Bank 1; 2 regs (HV/LV) per sensor */
 #define VSEN1_LV_HL_REG		0x01	/* Bank 1; 2 regs (HV/LV) per sensor */
 #define SMI_STS1_REG		0xC1	/* Bank 0; SMI Status Register */
+#define SMI_STS3_REG		0xC3	/* Bank 0; SMI Status Register */
 #define SMI_STS5_REG		0xC5	/* Bank 0; SMI Status Register */
 #define SMI_STS7_REG		0xC7	/* Bank 0; SMI Status Register */
 #define SMI_STS8_REG		0xC8	/* Bank 0; SMI Status Register */
@@ -210,7 +211,7 @@ static int nct7904_read_fan(struct device *dev, u32 attr, int channel,
 		return 0;
 	case hwmon_fan_alarm:
 		ret = nct7904_read_reg(data, BANK_0,
-				       SMI_STS7_REG + (channel >> 3));
+				       SMI_STS5_REG + (channel >> 3));
 		if (ret < 0)
 			return ret;
 		*val = (ret >> (channel & 0x07)) & 1;
@@ -351,7 +352,13 @@ static int nct7904_read_temp(struct device *dev, u32 attr, int channel,
 		*val = sign_extend32(temp, 10) * 125;
 		return 0;
 	case hwmon_temp_alarm:
-		if (channel < 5) {
+		if (channel == 4) {
+			ret = nct7904_read_reg(data, BANK_0,
+					       SMI_STS3_REG);
+			if (ret < 0)
+				return ret;
+			*val = (ret >> 1) & 1;
+		} else if (channel < 4) {
 			ret = nct7904_read_reg(data, BANK_0,
 					       SMI_STS1_REG);
 			if (ret < 0)
-- 
2.17.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [v1,1/1] hwmon: (nct7904) Fix incorrect SMI status register setting of LTD temperature and fan.
  2019-09-12 11:33 [v1,1/1] hwmon: (nct7904) Fix incorrect SMI status register setting of LTD temperature and fan Amy.Shih
@ 2019-09-12 18:53 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2019-09-12 18:53 UTC (permalink / raw)
  To: Amy.Shih
  Cc: she90122, oakley.ding, bichan.lu, Jean Delvare, linux-hwmon,
	linux-kernel

On Thu, Sep 12, 2019 at 11:33:00AM +0000, Amy.Shih@advantech.com.tw wrote:
> From: "amy.shih" <amy.shih@advantech.com.tw>
> 
> According to datasheet, the SMI status register setting of LTD
> temperature is SMI_STS3, and the SMI status register setting
> of fan is SMI_STS5 and SMI_STS6.
> 
> Signed-off-by: amy.shih <amy.shih@advantech.com.tw>

Applied.

Thanks,
Guenter

> ---
>  drivers/hwmon/nct7904.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hwmon/nct7904.c b/drivers/hwmon/nct7904.c
> index ce688ab4fce2..95b447cfa24c 100644
> --- a/drivers/hwmon/nct7904.c
> +++ b/drivers/hwmon/nct7904.c
> @@ -51,6 +51,7 @@
>  #define VSEN1_HV_HL_REG		0x00	/* Bank 1; 2 regs (HV/LV) per sensor */
>  #define VSEN1_LV_HL_REG		0x01	/* Bank 1; 2 regs (HV/LV) per sensor */
>  #define SMI_STS1_REG		0xC1	/* Bank 0; SMI Status Register */
> +#define SMI_STS3_REG		0xC3	/* Bank 0; SMI Status Register */
>  #define SMI_STS5_REG		0xC5	/* Bank 0; SMI Status Register */
>  #define SMI_STS7_REG		0xC7	/* Bank 0; SMI Status Register */
>  #define SMI_STS8_REG		0xC8	/* Bank 0; SMI Status Register */
> @@ -210,7 +211,7 @@ static int nct7904_read_fan(struct device *dev, u32 attr, int channel,
>  		return 0;
>  	case hwmon_fan_alarm:
>  		ret = nct7904_read_reg(data, BANK_0,
> -				       SMI_STS7_REG + (channel >> 3));
> +				       SMI_STS5_REG + (channel >> 3));
>  		if (ret < 0)
>  			return ret;
>  		*val = (ret >> (channel & 0x07)) & 1;
> @@ -351,7 +352,13 @@ static int nct7904_read_temp(struct device *dev, u32 attr, int channel,
>  		*val = sign_extend32(temp, 10) * 125;
>  		return 0;
>  	case hwmon_temp_alarm:
> -		if (channel < 5) {
> +		if (channel == 4) {
> +			ret = nct7904_read_reg(data, BANK_0,
> +					       SMI_STS3_REG);
> +			if (ret < 0)
> +				return ret;
> +			*val = (ret >> 1) & 1;
> +		} else if (channel < 4) {
>  			ret = nct7904_read_reg(data, BANK_0,
>  					       SMI_STS1_REG);
>  			if (ret < 0)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-12 11:33 [v1,1/1] hwmon: (nct7904) Fix incorrect SMI status register setting of LTD temperature and fan Amy.Shih
2019-09-12 18:53 ` Guenter Roeck

Linux-Hwmon Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-hwmon/0 linux-hwmon/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-hwmon linux-hwmon/ https://lore.kernel.org/linux-hwmon \
		linux-hwmon@vger.kernel.org linux-hwmon@archiver.kernel.org
	public-inbox-index linux-hwmon


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-hwmon


AGPL code for this site: git clone https://public-inbox.org/ public-inbox