diff options
| author | Peter Maydell <peter.maydell@linaro.org> | 2020-11-17 12:56:33 +0000 |
|---|---|---|
| committer | Peter Maydell <peter.maydell@linaro.org> | 2020-11-17 12:56:33 +0000 |
| commit | ab135622cf478585bdfcb68b85e4a817d74a0c42 (patch) | |
| tree | d5e124573a0e20f82558f08814f0bdf40c4e2b8d /hw/misc/tmp105.h | |
| parent | e1919889ef78144811d8520fa25776fa73feee66 (diff) | |
| download | focaccia-qemu-ab135622cf478585bdfcb68b85e4a817d74a0c42.tar.gz focaccia-qemu-ab135622cf478585bdfcb68b85e4a817d74a0c42.zip | |
tmp105: Correct handling of temperature limit checks
The TMP105 datasheet says that in Interrupt Mode (when TM==1) the device signals an alert when the temperature equals or exceeds the T_high value and then remains high until a device register is read or the device responds to the SMBUS Alert Response address, or the device is put into Shutdown Mode. Thereafter the Alert pin will only be re-signalled when temperature falls below T_low; alert can then be cleared in the same set of ways, and the device returns to its initial "alert when temperature goes above T_high" mode. (If this textual description is confusing, see figure 3 in the TI datasheet at https://www.ti.com/lit/gpn/tmp105 .) We were misimplementing this as a simple "always alert if temperature is above T_high or below T_low" condition, which gives a spurious alert on startup if using the "T_high = 80 degrees C, T_low = 75 degrees C" reset limit values. Implement the correct (hysteresis) behaviour by tracking whether we are currently looking for the temperature to rise over T_high or for it to fall below T_low. Our implementation of the comparator mode (TM==0) wasn't wrong, but rephrase it to match the way that interrupt mode is now handled for clarity. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Cédric Le Goater <clg@kaod.org> Message-id: 20201110150023.25533-3-peter.maydell@linaro.org
Diffstat (limited to 'hw/misc/tmp105.h')
| -rw-r--r-- | hw/misc/tmp105.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/hw/misc/tmp105.h b/hw/misc/tmp105.h index e5198fce80..7c97071ad7 100644 --- a/hw/misc/tmp105.h +++ b/hw/misc/tmp105.h @@ -43,6 +43,13 @@ struct TMP105State { int16_t limit[2]; int faults; uint8_t alarm; + /* + * The TMP105 initially looks for a temperature rising above T_high; + * once this is detected, the condition it looks for next is the + * temperature falling below T_low. This flag is false when initially + * looking for T_high, true when looking for T_low. + */ + bool detect_falling; }; #endif |