mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 10:09:10 +02:00
hwmon: (mcp9982) Add external diode fault read
Add external diode fault read capability to the MCP998X/33 and MCP998XD/33D driver. Signed-off-by: Victor Duicu <victor.duicu@microchip.com> Link: https://lore.kernel.org/r/20260423-add-external-diode-fault-read-v2-1-4004bb5f7d55@microchip.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
parent
42ef8bb116
commit
dca421c6ef
|
|
@ -92,19 +92,19 @@ static const struct hwmon_channel_info * const mcp9985_info[] = {
|
|||
HWMON_T_INPUT | HWMON_T_LABEL | HWMON_T_MIN |
|
||||
HWMON_T_MIN_ALARM | HWMON_T_MAX | HWMON_T_MAX_ALARM |
|
||||
HWMON_T_MAX_HYST | HWMON_T_CRIT | HWMON_T_CRIT_ALARM |
|
||||
HWMON_T_CRIT_HYST,
|
||||
HWMON_T_CRIT_HYST | HWMON_T_FAULT,
|
||||
HWMON_T_INPUT | HWMON_T_LABEL | HWMON_T_MIN |
|
||||
HWMON_T_MIN_ALARM | HWMON_T_MAX | HWMON_T_MAX_ALARM |
|
||||
HWMON_T_MAX_HYST | HWMON_T_CRIT | HWMON_T_CRIT_ALARM |
|
||||
HWMON_T_CRIT_HYST,
|
||||
HWMON_T_CRIT_HYST | HWMON_T_FAULT,
|
||||
HWMON_T_INPUT | HWMON_T_LABEL | HWMON_T_MIN |
|
||||
HWMON_T_MIN_ALARM | HWMON_T_MAX | HWMON_T_MAX_ALARM |
|
||||
HWMON_T_MAX_HYST | HWMON_T_CRIT | HWMON_T_CRIT_ALARM |
|
||||
HWMON_T_CRIT_HYST,
|
||||
HWMON_T_CRIT_HYST | HWMON_T_FAULT,
|
||||
HWMON_T_INPUT | HWMON_T_LABEL | HWMON_T_MIN |
|
||||
HWMON_T_MIN_ALARM | HWMON_T_MAX | HWMON_T_MAX_ALARM |
|
||||
HWMON_T_MAX_HYST | HWMON_T_CRIT | HWMON_T_CRIT_ALARM |
|
||||
HWMON_T_CRIT_HYST),
|
||||
HWMON_T_CRIT_HYST | HWMON_T_FAULT),
|
||||
HWMON_CHANNEL_INFO(chip,
|
||||
HWMON_C_UPDATE_INTERVAL),
|
||||
NULL
|
||||
|
|
@ -369,7 +369,8 @@ static int mcp9982_read(struct device *dev, enum hwmon_sensor_types type, u32 at
|
|||
|
||||
/*
|
||||
* In Standby State the conversion cycle must be initated manually in
|
||||
* order to read fresh temperature values and the status of the alarms.
|
||||
* order to read fresh temperature values, the status of the alarms and
|
||||
* fault information.
|
||||
*/
|
||||
if (!priv->run_state) {
|
||||
switch (type) {
|
||||
|
|
@ -379,6 +380,7 @@ static int mcp9982_read(struct device *dev, enum hwmon_sensor_types type, u32 at
|
|||
case hwmon_temp_max_alarm:
|
||||
case hwmon_temp_min_alarm:
|
||||
case hwmon_temp_crit_alarm:
|
||||
case hwmon_temp_fault:
|
||||
ret = regmap_write(priv->regmap, MCP9982_ONE_SHOT_ADDR, 1);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
|
@ -402,6 +404,11 @@ static int mcp9982_read(struct device *dev, enum hwmon_sensor_types type, u32 at
|
|||
}
|
||||
|
||||
switch (type) {
|
||||
/*
|
||||
* Because the ALERT/THERM pin is set in Therm(Comparator) mode,
|
||||
* the external diode fault status, high limit status and low
|
||||
* limit status registers do not clear the bits after reading.
|
||||
*/
|
||||
case hwmon_temp:
|
||||
switch (attr) {
|
||||
case hwmon_temp_input:
|
||||
|
|
@ -510,6 +517,13 @@ static int mcp9982_read(struct device *dev, enum hwmon_sensor_types type, u32 at
|
|||
|
||||
*val -= hyst * 1000;
|
||||
|
||||
return 0;
|
||||
case hwmon_temp_fault:
|
||||
*val = regmap_test_bits(priv->regmap, MCP9982_EXT_FAULT_STATUS_ADDR,
|
||||
BIT(channel));
|
||||
if (*val < 0)
|
||||
return *val;
|
||||
|
||||
return 0;
|
||||
default:
|
||||
return -EINVAL;
|
||||
|
|
@ -681,6 +695,7 @@ static umode_t mcp9982_is_visible(const void *_data, enum hwmon_sensor_types typ
|
|||
case hwmon_temp_max_alarm:
|
||||
case hwmon_temp_max_hyst:
|
||||
case hwmon_temp_crit_alarm:
|
||||
case hwmon_temp_fault:
|
||||
return 0444;
|
||||
case hwmon_temp_min:
|
||||
case hwmon_temp_max:
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user