Martin Blumenstingl 084ed144c4 hwmon: (jc42) Restore the min/max/critical temperatures on resume
The JC42 compatible thermal sensor on Kingston KSM32ES8/16ME DIMMs
(using Micron E-Die) is an ST Microelectronics STTS2004 (manufacturer
0x104a, device 0x2201). It does not keep the previously programmed
minimum, maximum and critical temperatures after system suspend and
resume (which is a shutdown / startup cycle for the JC42 temperature
sensor). This results in an alarm on system resume because the hardware
default for these values is 0°C (so any environment temperature greater
than 0°C will trigger the alarm).

Example before system suspend:
  jc42-i2c-0-1a
  Adapter: SMBus PIIX4 adapter port 0 at 0b00
  temp1:        +34.8°C  (low  =  +0.0°C)
                         (high = +85.0°C, hyst = +85.0°C)
                         (crit = +95.0°C, hyst = +95.0°C)

Example after system resume (without this change):
  jc42-i2c-0-1a
  Adapter: SMBus PIIX4 adapter port 0 at 0b00
  temp1:        +34.8°C  (low  =  +0.0°C)             ALARM (HIGH, CRIT)
                         (high =  +0.0°C, hyst =  +0.0°C)
                         (crit =  +0.0°C, hyst =  +0.0°C)

Apply the cached values from the JC42_REG_TEMP_UPPER,
JC42_REG_TEMP_LOWER, JC42_REG_TEMP_CRITICAL and JC42_REG_SMBUS (where
the SMBUS register is not related to this issue but a side-effect of
using regcache_sync() during system resume with the previously
cached/programmed values. This fixes the alarm due to the hardware
defaults of 0°C because the previously applied limits (set by userspace)
are re-applied on system resume.

Fixes: 175c490c9e7f ("hwmon: (jc42) Add support for STTS2004 and AT30TSE004")
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Link: https://lore.kernel.org/r/20221023213157.11078-3-martin.blumenstingl@googlemail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-12-04 16:45:02 -08:00
..
2022-10-04 19:02:54 -07:00
2022-10-04 19:02:54 -07:00
2022-12-04 16:45:02 -08:00
2022-10-04 19:02:54 -07:00
2022-10-04 19:02:54 -07:00
2022-10-04 19:02:54 -07:00
2022-12-04 16:45:02 -08:00
2022-10-04 19:02:54 -07:00
2022-10-04 19:02:54 -07:00
2020-09-23 09:42:39 -07:00
2020-09-23 09:42:39 -07:00
2022-08-16 12:46:26 +02:00
2022-02-27 17:03:19 -08:00
2019-11-06 14:37:19 -08:00
2022-12-04 16:45:02 -08:00
2020-09-23 09:42:39 -07:00
2022-12-04 16:45:02 -08:00
2021-04-20 06:50:14 -07:00
2022-09-19 06:17:05 -07:00
2022-05-22 11:32:31 -07:00
2022-12-04 16:45:02 -08:00
2022-12-04 16:45:02 -08:00
2020-09-23 09:42:39 -07:00
2022-12-04 16:45:02 -08:00
2022-08-16 12:46:26 +02:00
2020-09-23 09:42:39 -07:00
2022-10-04 19:02:54 -07:00
2022-10-04 19:02:54 -07:00
2020-09-23 09:42:39 -07:00
2022-10-04 19:02:54 -07:00
2022-10-04 19:02:54 -07:00
2022-10-04 19:02:54 -07:00
2022-10-04 19:02:54 -07:00
2022-10-04 19:02:54 -07:00