mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 10:00:51 +07:00
hwmon: (nct7904) Add array fan_alarm and vsen_alarm to store the alarms in nct7904_data struct.
SMI# interrupt for fan and voltage is Two-Times Interrupt Mode.
Fan or voltage exceeds high limit or going below low limit,
it will causes an interrupt if the previous interrupt has been
reset by reading all the interrupt Status Register. Thus, add the
array fan_alarm and vsen_alarm to store the alarms for all of the
fan and voltage sensors.
Signed-off-by: amy.shih <amy.shih@advantech.com.tw>
Link: https://lore.kernel.org/r/20190919030205.11440-1-Amy.Shih@advantech.com.tw
Fixes: 486842db3b
("hwmon: (nct7904) Add extra sysfs support for fan, voltage and temperature.")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
parent
b428db1e88
commit
6bbfdcbc8e
@ -99,6 +99,8 @@ struct nct7904_data {
|
||||
u8 enable_dts;
|
||||
u8 has_dts;
|
||||
u8 temp_mode; /* 0: TR mode, 1: TD mode */
|
||||
u8 fan_alarm[2];
|
||||
u8 vsen_alarm[3];
|
||||
};
|
||||
|
||||
/* Access functions */
|
||||
@ -214,7 +216,15 @@ static int nct7904_read_fan(struct device *dev, u32 attr, int channel,
|
||||
SMI_STS5_REG + (channel >> 3));
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
*val = (ret >> (channel & 0x07)) & 1;
|
||||
if (!data->fan_alarm[channel >> 3])
|
||||
data->fan_alarm[channel >> 3] = ret & 0xff;
|
||||
else
|
||||
/* If there is new alarm showing up */
|
||||
data->fan_alarm[channel >> 3] |= (ret & 0xff);
|
||||
*val = (data->fan_alarm[channel >> 3] >> (channel & 0x07)) & 1;
|
||||
/* Needs to clean the alarm if alarm existing */
|
||||
if (*val)
|
||||
data->fan_alarm[channel >> 3] ^= 1 << (channel & 0x07);
|
||||
return 0;
|
||||
default:
|
||||
return -EOPNOTSUPP;
|
||||
@ -298,7 +308,15 @@ static int nct7904_read_in(struct device *dev, u32 attr, int channel,
|
||||
SMI_STS1_REG + (index >> 3));
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
*val = (ret >> (index & 0x07)) & 1;
|
||||
if (!data->vsen_alarm[index >> 3])
|
||||
data->vsen_alarm[index >> 3] = ret & 0xff;
|
||||
else
|
||||
/* If there is new alarm showing up */
|
||||
data->vsen_alarm[index >> 3] |= (ret & 0xff);
|
||||
*val = (data->vsen_alarm[index >> 3] >> (index & 0x07)) & 1;
|
||||
/* Needs to clean the alarm if alarm existing */
|
||||
if (*val)
|
||||
data->vsen_alarm[index >> 3] ^= 1 << (index & 0x07);
|
||||
return 0;
|
||||
default:
|
||||
return -EOPNOTSUPP;
|
||||
|
Loading…
Reference in New Issue
Block a user