diff options
| author | Victor Duicu <victor.duicu@microchip.com> | 2026-04-23 13:56:40 +0300 |
|---|---|---|
| committer | Guenter Roeck <linux@roeck-us.net> | 2026-06-09 08:22:41 -0700 |
| commit | dca421c6efca6f4d04dfbdac6a6907781f9fd311 (patch) | |
| tree | f843e8575feaaf5d66c59a7253d994dc64999ef3 | |
| parent | 42ef8bb116dae7610b0af65d7d819cd9239ad121 (diff) | |
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>
| -rw-r--r-- | drivers/hwmon/mcp9982.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/drivers/hwmon/mcp9982.c b/drivers/hwmon/mcp9982.c index 26c69e3388ab..9e19e2697e25 100644 --- a/drivers/hwmon/mcp9982.c +++ b/drivers/hwmon/mcp9982.c @@ -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: @@ -511,6 +518,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: |
