hw/sensor: Add SB-TSI Temperature Sensor Interface
v2 cover hw/sensor: Add SB-TSI Temperature Sensor Interface
v2:
* Split the commit into a separate patch for the qtest
* Moved the common registers into the new header
* Introduced a new header
Hao Wu (2):
hw/sensor: Add SB-TSI Temperature Sensor Interface
tests: add qtest for hw/sensor/sbtsi
hw/sensor/Kconfig | 4 + hw/sensor/meson.build | 1 + hw/sensor/tmp_sbtsi.c | 365 +++++++++++++++++++++++++++++++++++ hw/sensor/trace-events | 5 + hw/sensor/trace.h | 1 + include/hw/sensor/sbtsi.h | 50 +++++ meson.build | 1 + tests/qtest/meson.build | 1 + tests/qtest/tmp_sbtsi-test.c | 161 +++++++++++++++ 9 files changed, 589 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 include/hw/sensor/sbtsi.h create mode 100644 tests/qtest/tmp_sbtsi-test.c
Signature · 1 line
2.34.1.575.g55b058a8bb-goog
PATCH v2 1/2 hw/sensor: Add SB-TSI Temperature Sensor Interface
From: Hao Wu <[email protected]>
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 | 365 ++++++++++++++++++++++++++++++++++++++ hw/sensor/trace-events | 5 + hw/sensor/trace.h | 1 + include/hw/sensor/sbtsi.h | 50 ++++++ meson.build | 1 + 7 files changed, 427 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 include/hw/sensor/sbtsi.h
hw/sensor/Kconfig +4 -0
@@ -21,3 +21,7 @@ config ADM1272 config MAX34451 bool depends on I2C + +config AMDSBTSI + bool + depends on I2C
hw/sensor/meson.build +1 -0
@@ -4,3 +4,4 @@ softmmu_ss.add(when: 'CONFIG_DPS310', if_true: files('dps310.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 +365 -0
365 lines not on this page · raw message
hw/sensor/trace-events new file +5 -0
@@ -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
@@ -0,0 +1 @@ +#include "trace/trace-hw_sensor.h"
include/hw/sensor/sbtsi.h new file +50 -0
50 lines not on this page · raw message
meson.build +1 -0
@@ -2494,6 +2494,7 @@ if have_system 'hw/rtc', 'hw/s390x', 'hw/scsi', + 'hw/sensor', 'hw/sd', 'hw/sh4', 'hw/sparc',
Signature · 1 line
2.34.1.575.g55b058a8bb-goog
Hi Patrick,
Quoted 29 lines · Patrick Venture
From: Hao Wu <[email protected]>
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)Signed-off-by Hao Wu <[email protected]>Reviewed-by Doug Evans <[email protected]>--- hw/sensor/Kconfig | 4 + hw/sensor/meson.build | 1 + hw/sensor/tmp_sbtsi.c | 365 ++++++++++++++++++++++++++++++++++++++ hw/sensor/trace-events | 5 + hw/sensor/trace.h | 1 + include/hw/sensor/sbtsi.h | 50 ++++++ meson.build | 1 + 7 files changed, 427 insertions(+)
Quoted 4 lines
create mode 100644
hw/sensor/tmp_sbtsi.c
create mode 100644 hw/sensor/trace-events
create mode 100644hw/sensor/trace.h
create mode 100644include/hw/sensor/sbtsi.h
Since you are posting various patches, consider setting the scripts/git.orderfile script up to ease on-list reviews.
Quoted 18 lines
include/hw/sensor/sbtsi.h new file +12
-0@@ -0,0 +1,50 @@ +/* +* AMD SBI Temperature Sensor Interface (SB-TSI) +* +* Copyright 2021 Google LLC +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
include/hw/sensor/sbtsi.h line 22
Quoted 10 lines
include/hw/sensor/sbtsi.h new file +10
-0+* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +* for more details. +*/ +#ifndef QEMU_TMP_SBTSI_H +#define QEMU_TMP_SBTSI_H + +#include "qom/object.h" + +#define TYPE_SBTSI "sbtsi" +#define SBTSI (obj) OBJECT_CHECK(SBTSIState, (obj), TYPE_SBTSI)
SBTSIState is not declared outside of tmp_sbtsi.c, so I'd keep SBTSI() there. Otherwise:
PATCH v2 2/2 tests: add qtest for hw/sensor/sbtsi
In reply to Patrick VentureFrom: Hao Wu <[email protected]>
--- tests/qtest/meson.build | 1 + tests/qtest/tmp_sbtsi-test.c | 161 +++++++++++++++++++++++++++++++++++ 2 files changed, 162 insertions(+) create mode 100644 tests/qtest/tmp_sbtsi-test.c
tests/qtest/meson.build +1 -0
@@ -254,6 +254,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 +161 -0
161 lines not on this page · raw message
Signature · 1 line
2.34.1.575.g55b058a8bb-goog
Re: [PATCH v2 2/2] tests: add qtest for hw/sensor/sbtsi
Quoted 8 lines · Patrick Venture
From: Hao Wu <[email protected]>
Reviewed-by Doug Evanwqs <[email protected]>Signed-off-by Hao Wu <[email protected]>Signed-off-by Patrick Venture <[email protected]>--- tests/qtest/meson.build | 1 + tests/qtest/tmp_sbtsi-test.c | 161 +++++++++++++++++++++++++++++++++++
I'd prefer to use "-" instead of "_" in the file name, but anyway: