Skip to contentSkip to conversation

hw/sensor: Add SB-TSI Temperature Sensor Interface

PATCH New Hao Wu 1 participant 1 message Aug 12, 2021 Arm/Amlogic Meson SoC support

lore
Share & tools
lore

Hao Wu

author
#0 lore raw

PATCH 1/1 hw/sensor: Add SB-TSI Temperature Sensor Interface

SB Temperature Sensor Interface (SB-TSI) is an SMBus compatible interface that reports AMD SoC's Ttcl (normalized temperature), and resembles a typical 8-pin remote temperature sensor's I2C interface to BMC.

This patch implements a basic AMD SB-TSI sensor that is compatible with the open-source data sheet from AMD and Linux kernel driver.

Reference:
Linux kernel driver:
https://lkml.org/lkml/2020/12/11/968
Register Map:
https://developer.amd.com/wp-content/resources/56255_3_03.PDF
(Chapter 6)

---
 hw/sensor/Kconfig            |   4 +
 hw/sensor/meson.build        |   1 +
 hw/sensor/tmp_sbtsi.c        | 393 +++++++++++++++++++++++++++++++++++
 hw/sensor/trace-events       |   5 +
 hw/sensor/trace.h            |   1 +
 meson.build                  |   1 +
 tests/qtest/meson.build      |   1 +
 tests/qtest/tmp_sbtsi-test.c | 180 ++++++++++++++++
 8 files changed, 586 insertions(+)
 create mode 100644 hw/sensor/tmp_sbtsi.c
 create mode 100644 hw/sensor/trace-events
 create mode 100644 hw/sensor/trace.h
 create mode 100644 tests/qtest/tmp_sbtsi-test.c
hw/sensor/Kconfig +4 -0
index a2b55a4fdb..31e78e6fd5 100644
@@ -17,3 +17,7 @@ config ADM1272
 config MAX34451
     bool
     depends on I2C
+
+config AMDSBTSI
+    bool
+    depends on I2C
hw/sensor/meson.build +1 -0
index 034e3e0207..4e6747b2f2 100644
@@ -3,3 +3,4 @@ softmmu_ss.add(when: 'CONFIG_TMP421', if_true: files('tmp421.c'))
 softmmu_ss.add(when: 'CONFIG_EMC141X', if_true: files('emc141x.c'))
 softmmu_ss.add(when: 'CONFIG_ADM1272', if_true: files('adm1272.c'))
 softmmu_ss.add(when: 'CONFIG_MAX34451', if_true: files('max34451.c'))
+softmmu_ss.add(when: 'CONFIG_AMDSBTSI', if_true: files('tmp_sbtsi.c'))
hw/sensor/tmp_sbtsi.c new file +393 -0

393 lines not on this page · raw message

hw/sensor/trace-events new file +5 -0
new file mode 100644
index 0000000000..21ab3809e2
@@ -0,0 +1,5 @@
+# See docs/devel/tracing.rst for syntax documentation.
+
+# tmp_sbtsi.c
+tmp_sbtsi_write_data(uint8_t addr, uint8_t value) "SBTSI write addr:0x%02x data: 0x%02x"
+tmp_sbtsi_read_data(uint8_t addr, uint8_t value) "SBTSI read addr:0x%02x data: 0x%02x"
hw/sensor/trace.h new file +1 -0
new file mode 100644
index 0000000000..e4721560b0
@@ -0,0 +1 @@
+#include "trace/trace-hw_sensor.h"
meson.build +1 -0
index b3e7ec0e92..e62db1163a 100644
@@ -2138,6 +2138,7 @@ if have_system
     'hw/rtc',
     'hw/s390x',
     'hw/scsi',
+    'hw/sensor',
     'hw/sd',
     'hw/sparc',
     'hw/sparc64',
tests/qtest/meson.build +1 -0
index e22a0792c5..72671e316a 100644
@@ -222,6 +222,7 @@ qos_test_ss.add(
   'spapr-phb-test.c',
   'tmp105-test.c',
   'emc141x-test.c',
+  'tmp_sbtsi-test.c',
   'usb-hcd-ohci-test.c',
   'virtio-test.c',
   'virtio-blk-test.c',
tests/qtest/tmp_sbtsi-test.c new file +180 -0

180 lines not on this page · raw message

Signature · 1 line
2.33.0.rc1.237.g0d66db33f3-goog