hwmon: (lm90) Drop critical attribute support for MAX6654

[ Upstream commit 16ba51b5dcd3f6dde2e51d5ccc86313119dcf889 ]

Tests with a real chip and a closer look into the datasheet show that
MAX6654 does not support CRIT/THERM/OVERTEMP limits, so drop support
of the respective attributes for this chip.

Introduce LM90_HAVE_CRIT flag and use it to instantiate critical limit
attributes to solve the problem.

Cc: Josh Lehan <krellan@google.com>
Fixes: 229d495d81 ("hwmon: (lm90) Add max6654 support to lm90 driver")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Guenter Roeck
2021-11-13 08:55:06 -08:00
committed by Greg Kroah-Hartman
parent 2464738d0e
commit 51c7b2a7b8

View File

@@ -35,13 +35,14 @@
* explicitly as max6659, or if its address is not 0x4c. * explicitly as max6659, or if its address is not 0x4c.
* These chips lack the remote temperature offset feature. * These chips lack the remote temperature offset feature.
* *
* This driver also supports the MAX6654 chip made by Maxim. This chip can * This driver also supports the MAX6654 chip made by Maxim. This chip can be
* be at 9 different addresses, similar to MAX6680/MAX6681. The MAX6654 is * at 9 different addresses, similar to MAX6680/MAX6681. The MAX6654 is similar
* otherwise similar to MAX6657/MAX6658/MAX6659. Extended range is available * to MAX6657/MAX6658/MAX6659, but does not support critical temperature
* by setting the configuration register accordingly, and is done during * limits. Extended range is available by setting the configuration register
* initialization. Extended precision is only available at conversion rates * accordingly, and is done during initialization. Extended precision is only
* of 1 Hz and slower. Note that extended precision is not enabled by * available at conversion rates of 1 Hz and slower. Note that extended
* default, as this driver initializes all chips to 2 Hz by design. * precision is not enabled by default, as this driver initializes all chips
* to 2 Hz by design.
* *
* This driver also supports the MAX6646, MAX6647, MAX6648, MAX6649 and * This driver also supports the MAX6646, MAX6647, MAX6648, MAX6649 and
* MAX6692 chips made by Maxim. These are again similar to the LM86, * MAX6692 chips made by Maxim. These are again similar to the LM86,
@@ -188,6 +189,7 @@ enum chips { lm90, adm1032, lm99, lm86, max6657, max6659, adt7461, max6680,
#define LM90_HAVE_BROKEN_ALERT (1 << 7) /* Broken alert */ #define LM90_HAVE_BROKEN_ALERT (1 << 7) /* Broken alert */
#define LM90_HAVE_EXTENDED_TEMP (1 << 8) /* extended temperature support*/ #define LM90_HAVE_EXTENDED_TEMP (1 << 8) /* extended temperature support*/
#define LM90_PAUSE_FOR_CONFIG (1 << 9) /* Pause conversion for config */ #define LM90_PAUSE_FOR_CONFIG (1 << 9) /* Pause conversion for config */
#define LM90_HAVE_CRIT (1 << 10)/* Chip supports CRIT/OVERT register */
/* LM90 status */ /* LM90 status */
#define LM90_STATUS_LTHRM (1 << 0) /* local THERM limit tripped */ #define LM90_STATUS_LTHRM (1 << 0) /* local THERM limit tripped */
@@ -354,38 +356,43 @@ struct lm90_params {
static const struct lm90_params lm90_params[] = { static const struct lm90_params lm90_params[] = {
[adm1032] = { [adm1032] = {
.flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT
| LM90_HAVE_BROKEN_ALERT, | LM90_HAVE_BROKEN_ALERT | LM90_HAVE_CRIT,
.alert_alarms = 0x7c, .alert_alarms = 0x7c,
.max_convrate = 10, .max_convrate = 10,
}, },
[adt7461] = { [adt7461] = {
.flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT
| LM90_HAVE_BROKEN_ALERT | LM90_HAVE_EXTENDED_TEMP, | LM90_HAVE_BROKEN_ALERT | LM90_HAVE_EXTENDED_TEMP
| LM90_HAVE_CRIT,
.alert_alarms = 0x7c, .alert_alarms = 0x7c,
.max_convrate = 10, .max_convrate = 10,
}, },
[g781] = { [g781] = {
.flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT
| LM90_HAVE_BROKEN_ALERT, | LM90_HAVE_BROKEN_ALERT | LM90_HAVE_CRIT,
.alert_alarms = 0x7c, .alert_alarms = 0x7c,
.max_convrate = 8, .max_convrate = 8,
}, },
[lm86] = { [lm86] = {
.flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT, .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT
| LM90_HAVE_CRIT,
.alert_alarms = 0x7b, .alert_alarms = 0x7b,
.max_convrate = 9, .max_convrate = 9,
}, },
[lm90] = { [lm90] = {
.flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT, .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT
| LM90_HAVE_CRIT,
.alert_alarms = 0x7b, .alert_alarms = 0x7b,
.max_convrate = 9, .max_convrate = 9,
}, },
[lm99] = { [lm99] = {
.flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT, .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT
| LM90_HAVE_CRIT,
.alert_alarms = 0x7b, .alert_alarms = 0x7b,
.max_convrate = 9, .max_convrate = 9,
}, },
[max6646] = { [max6646] = {
.flags = LM90_HAVE_CRIT,
.alert_alarms = 0x7c, .alert_alarms = 0x7c,
.max_convrate = 6, .max_convrate = 6,
.reg_local_ext = MAX6657_REG_R_LOCAL_TEMPL, .reg_local_ext = MAX6657_REG_R_LOCAL_TEMPL,
@@ -396,50 +403,50 @@ static const struct lm90_params lm90_params[] = {
.reg_local_ext = MAX6657_REG_R_LOCAL_TEMPL, .reg_local_ext = MAX6657_REG_R_LOCAL_TEMPL,
}, },
[max6657] = { [max6657] = {
.flags = LM90_PAUSE_FOR_CONFIG, .flags = LM90_PAUSE_FOR_CONFIG | LM90_HAVE_CRIT,
.alert_alarms = 0x7c, .alert_alarms = 0x7c,
.max_convrate = 8, .max_convrate = 8,
.reg_local_ext = MAX6657_REG_R_LOCAL_TEMPL, .reg_local_ext = MAX6657_REG_R_LOCAL_TEMPL,
}, },
[max6659] = { [max6659] = {
.flags = LM90_HAVE_EMERGENCY, .flags = LM90_HAVE_EMERGENCY | LM90_HAVE_CRIT,
.alert_alarms = 0x7c, .alert_alarms = 0x7c,
.max_convrate = 8, .max_convrate = 8,
.reg_local_ext = MAX6657_REG_R_LOCAL_TEMPL, .reg_local_ext = MAX6657_REG_R_LOCAL_TEMPL,
}, },
[max6680] = { [max6680] = {
.flags = LM90_HAVE_OFFSET, .flags = LM90_HAVE_OFFSET | LM90_HAVE_CRIT,
.alert_alarms = 0x7c, .alert_alarms = 0x7c,
.max_convrate = 7, .max_convrate = 7,
}, },
[max6696] = { [max6696] = {
.flags = LM90_HAVE_EMERGENCY .flags = LM90_HAVE_EMERGENCY
| LM90_HAVE_EMERGENCY_ALARM | LM90_HAVE_TEMP3, | LM90_HAVE_EMERGENCY_ALARM | LM90_HAVE_TEMP3 | LM90_HAVE_CRIT,
.alert_alarms = 0x1c7c, .alert_alarms = 0x1c7c,
.max_convrate = 6, .max_convrate = 6,
.reg_local_ext = MAX6657_REG_R_LOCAL_TEMPL, .reg_local_ext = MAX6657_REG_R_LOCAL_TEMPL,
}, },
[w83l771] = { [w83l771] = {
.flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT, .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT | LM90_HAVE_CRIT,
.alert_alarms = 0x7c, .alert_alarms = 0x7c,
.max_convrate = 8, .max_convrate = 8,
}, },
[sa56004] = { [sa56004] = {
.flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT, .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT | LM90_HAVE_CRIT,
.alert_alarms = 0x7b, .alert_alarms = 0x7b,
.max_convrate = 9, .max_convrate = 9,
.reg_local_ext = SA56004_REG_R_LOCAL_TEMPL, .reg_local_ext = SA56004_REG_R_LOCAL_TEMPL,
}, },
[tmp451] = { [tmp451] = {
.flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT
| LM90_HAVE_BROKEN_ALERT | LM90_HAVE_EXTENDED_TEMP, | LM90_HAVE_BROKEN_ALERT | LM90_HAVE_EXTENDED_TEMP | LM90_HAVE_CRIT,
.alert_alarms = 0x7c, .alert_alarms = 0x7c,
.max_convrate = 9, .max_convrate = 9,
.reg_local_ext = TMP451_REG_R_LOCAL_TEMPL, .reg_local_ext = TMP451_REG_R_LOCAL_TEMPL,
}, },
[tmp461] = { [tmp461] = {
.flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT
| LM90_HAVE_BROKEN_ALERT | LM90_HAVE_EXTENDED_TEMP, | LM90_HAVE_BROKEN_ALERT | LM90_HAVE_EXTENDED_TEMP | LM90_HAVE_CRIT,
.alert_alarms = 0x7c, .alert_alarms = 0x7c,
.max_convrate = 9, .max_convrate = 9,
.reg_local_ext = TMP451_REG_R_LOCAL_TEMPL, .reg_local_ext = TMP451_REG_R_LOCAL_TEMPL,
@@ -667,6 +674,7 @@ static int lm90_update_limits(struct device *dev)
struct i2c_client *client = data->client; struct i2c_client *client = data->client;
int val; int val;
if (data->flags & LM90_HAVE_CRIT) {
val = lm90_read_reg(client, LM90_REG_R_LOCAL_CRIT); val = lm90_read_reg(client, LM90_REG_R_LOCAL_CRIT);
if (val < 0) if (val < 0)
return val; return val;
@@ -681,6 +689,7 @@ static int lm90_update_limits(struct device *dev)
if (val < 0) if (val < 0)
return val; return val;
data->temp_hyst = val; data->temp_hyst = val;
}
val = lm90_read_reg(client, LM90_REG_R_REMOTE_LOWH); val = lm90_read_reg(client, LM90_REG_R_REMOTE_LOWH);
if (val < 0) if (val < 0)
@@ -1866,11 +1875,14 @@ static int lm90_probe(struct i2c_client *client)
info->config = data->channel_config; info->config = data->channel_config;
data->channel_config[0] = HWMON_T_INPUT | HWMON_T_MIN | HWMON_T_MAX | data->channel_config[0] = HWMON_T_INPUT | HWMON_T_MIN | HWMON_T_MAX |
HWMON_T_CRIT | HWMON_T_CRIT_HYST | HWMON_T_MIN_ALARM | HWMON_T_MIN_ALARM | HWMON_T_MAX_ALARM;
HWMON_T_MAX_ALARM | HWMON_T_CRIT_ALARM;
data->channel_config[1] = HWMON_T_INPUT | HWMON_T_MIN | HWMON_T_MAX | data->channel_config[1] = HWMON_T_INPUT | HWMON_T_MIN | HWMON_T_MAX |
HWMON_T_CRIT | HWMON_T_CRIT_HYST | HWMON_T_MIN_ALARM | HWMON_T_MIN_ALARM | HWMON_T_MAX_ALARM | HWMON_T_FAULT;
HWMON_T_MAX_ALARM | HWMON_T_CRIT_ALARM | HWMON_T_FAULT;
if (data->flags & LM90_HAVE_CRIT) {
data->channel_config[0] |= HWMON_T_CRIT | HWMON_T_CRIT_ALARM | HWMON_T_CRIT_HYST;
data->channel_config[1] |= HWMON_T_CRIT | HWMON_T_CRIT_ALARM | HWMON_T_CRIT_HYST;
}
if (data->flags & LM90_HAVE_OFFSET) if (data->flags & LM90_HAVE_OFFSET)
data->channel_config[1] |= HWMON_T_OFFSET; data->channel_config[1] |= HWMON_T_OFFSET;