From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ADA70C433EF for ; Thu, 27 Jan 2022 18:24:00 +0000 (UTC) Received: from localhost ([::1]:52150 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nD9R9-0006jX-SL for qemu-devel@archiver.kernel.org; Thu, 27 Jan 2022 13:23:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58278) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nD9Nm-00046z-3q for qemu-devel@nongnu.org; Thu, 27 Jan 2022 13:20:32 -0500 Received: from [2a00:1450:4864:20::134] (port=40559 helo=mail-lf1-x134.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nD9NX-00071m-IH for qemu-devel@nongnu.org; Thu, 27 Jan 2022 13:20:22 -0500 Received: by mail-lf1-x134.google.com with SMTP id a28so6996233lfl.7 for ; Thu, 27 Jan 2022 10:20:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qVhL3pN73bU28DaA28tJBHbVdmawHf0iSyop4rmegdk=; b=jYK7VehsZvKN9tjYPNWkCKS1lAdzqy9CXSGgpkn58xom/Bt6frNS0lJaW01zw33Qvu ehy2LdXWmmy9CtBpL3ivlViVOauIqfTzjKI5am0xm5Mj6cZRZ6UXNUHcJOCdsnlxQOmv VDPN2oKNoQUKTNWWdXMDlRNziBIyPmUd8CRyyc6n29gN7CI4cx+QqEgCyf87B5CR82Pi ngR83fXe7CEhOsMUG9Ym4izVm/KWJ/qZrvS3zRH0F55dmsI8Fnbnr6L7QUBQGPZDy2f7 WH6v6czAwlfxCyZmn6zQE3UMRJuwP9uNUvLdS7VQ6/k1a7BoonfCmMtl7EgkEa2GABua hzkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qVhL3pN73bU28DaA28tJBHbVdmawHf0iSyop4rmegdk=; b=s/C8bbRKvmEqJnuNJ6xhVqzEDrl/YzjXVX5Guup53E91Cwxnw3uigPoVTc/ynlM1uu egs6PQHn6EJnJ9UoFwEPdaots08kHFELUPohjultGVx/yUE1kCZfaZmNvZ2UzwMZXmkc VUDXAolhjwfqOnyveavFJgKPtrqgNKIYOZbiq/4fhE6Wh5a+T8ov1CJahMma6px7M75O J/uAnmJP3c+mPy5Okiygy8oOeBtbxstT9aJu94OwXYyk0ukXFpJOunaLqyCqbRSaqDUK RSkk2oN6WL3kjGeG78M6NV5wZ/bUMk2PURJmE8yN86O/D/c7vSScFU9CMbGdXPy1cSuq BbKw== X-Gm-Message-State: AOAM531HdyxnstLXUVWFSbrM8HqV+Y0hitB4LtnONlZ4/c/uhPzpWYN1 Ye79eBDSFXdf5ATixHQSjewNNx4X5sNoI9Q7ywEybg== X-Google-Smtp-Source: ABdhPJymoWOYWtAOIwSdE5GEkGNkGQ32IEYEorOGV5CJAxrRRAcJZFvfmWHxG5/1+lagA42WOuVAT8Oc1zWUat06aeM= X-Received: by 2002:ac2:4157:: with SMTP id c23mr3732886lfi.380.1643307605731; Thu, 27 Jan 2022 10:20:05 -0800 (PST) MIME-Version: 1.0 References: <20220108030451.3867815-1-venture@google.com> <20220117140524.GC34953@minyard.net> <20220127145532.GI34953@minyard.net> In-Reply-To: <20220127145532.GI34953@minyard.net> From: Hao Wu Date: Thu, 27 Jan 2022 10:19:54 -0800 Message-ID: Subject: Re: [PATCH] hw/sensor: Add SB-TSI Temperature Sensor Interface To: Corey Minyard Cc: Patrick Venture , Thomas Huth , Laurent Vivier , Paolo Bonzini , QEMU Developers , Doug Evans Content-Type: multipart/alternative; boundary="00000000000019555805d6945e84" X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::134 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::134; envelope-from=wuhaotsh@google.com; helo=mail-lf1-x134.google.com X-Spam_score_int: -167 X-Spam_score: -16.8 X-Spam_bar: ---------------- X-Spam_report: (-16.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, ENV_AND_HDR_SPF_MATCH=-0.5, HTML_MESSAGE=0.001, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, USER_IN_DEF_DKIM_WL=-7.5, USER_IN_DEF_SPF_WL=-7.5 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" --00000000000019555805d6945e84 Content-Type: text/plain; charset="UTF-8" On Thu, Jan 27, 2022 at 6:55 AM Corey Minyard wrote: > On Wed, Jan 26, 2022 at 04:09:03PM -0800, Hao Wu wrote: > > Hi, > > > > Sorry for the late reply. I'm not sure what "auto-increment" means here. > > The question is: When a value is read, does the address automatically > increment. I2C devices very often do this. If you do a multi-byte > read, they often will read the value from address 0, then from address > 1, etc. Same for writes. > The datasheet does not suggest such behavior could happen. > > > The kernel driver at > > https://lkml.org/lkml/2020/12/11/968 > > only has byte-size read/write operations, so I don't see a problem here. > > The values are extracted > > from the datasheet. > > The *Linux* kernel driver my only do byte-size operations, but other > kernels may work different, and the Linux kernel may change. You have > to implement from the datasheet, not the device driver. > The implementation is already according to the datasheet. > Thanks, > > -corey > > > > > On Tue, Jan 18, 2022 at 9:10 AM Patrick Venture > wrote: > > > > > > > > > > > On Mon, Jan 17, 2022 at 6:05 AM Corey Minyard > wrote: > > > > > >> On Sun, Jan 09, 2022 at 06:17:34PM -0800, Patrick Venture wrote: > > >> > On Fri, Jan 7, 2022 at 7:04 PM Patrick Venture > > >> wrote: > > >> > > > >> > > From: Hao Wu > > >> > > > > >> > > 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 > > >> > > Reviewed-by: Doug Evans > > >> > > --- > > >> > > 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 > > >> > > > > >> > > diff --git a/hw/sensor/Kconfig b/hw/sensor/Kconfig > > >> > > index 9c8a049b06..27f6f79c84 100644 > > >> > > --- a/hw/sensor/Kconfig > > >> > > +++ b/hw/sensor/Kconfig > > >> > > @@ -21,3 +21,7 @@ config ADM1272 > > >> > > config MAX34451 > > >> > > bool > > >> > > depends on I2C > > >> > > + > > >> > > +config AMDSBTSI > > >> > > + bool > > >> > > + depends on I2C > > >> > > diff --git a/hw/sensor/meson.build b/hw/sensor/meson.build > > >> > > index 059c4ca935..f7b0e645eb 100644 > > >> > > --- a/hw/sensor/meson.build > > >> > > +++ b/hw/sensor/meson.build > > >> > > @@ -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')) > > >> > > diff --git a/hw/sensor/tmp_sbtsi.c b/hw/sensor/tmp_sbtsi.c > > >> > > new file mode 100644 > > >> > > index 0000000000..b68c7ebf61 > > >> > > --- /dev/null > > >> > > +++ b/hw/sensor/tmp_sbtsi.c > > >> > > @@ -0,0 +1,393 @@ > > >> > > +/* > > >> > > + * 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 > > >> > > + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public > > >> License > > >> > > + * for more details. > > >> > > + */ > > >> > > + > > >> > > +#include "qemu/osdep.h" > > >> > > +#include "hw/i2c/smbus_slave.h" > > >> > > +#include "hw/irq.h" > > >> > > +#include "migration/vmstate.h" > > >> > > +#include "qapi/error.h" > > >> > > +#include "qapi/visitor.h" > > >> > > +#include "qemu/log.h" > > >> > > +#include "qemu/module.h" > > >> > > +#include "trace.h" > > >> > > + > > >> > > +#define TYPE_SBTSI "sbtsi" > > >> > > +#define SBTSI(obj) OBJECT_CHECK(SBTSIState, (obj), TYPE_SBTSI) > > >> > > + > > >> > > +/** > > >> > > + * SBTSIState: > > >> > > + * temperatures are in units of 0.125 degrees > > >> > > + * @temperature: Temperature > > >> > > + * @limit_low: Lowest temperature > > >> > > + * @limit_high: Highest temperature > > >> > > + * @status: The status register > > >> > > + * @config: The config register > > >> > > + * @alert_config: The config for alarm_l output. > > >> > > + * @addr: The address to read/write for the next cmd. > > >> > > + * @alarm: The alarm_l output pin (GPIO) > > >> > > + */ > > >> > > +typedef struct SBTSIState { > > >> > > + SMBusDevice parent; > > >> > > + > > >> > > + uint32_t temperature; > > >> > > + uint32_t limit_low; > > >> > > + uint32_t limit_high; > > >> > > + uint8_t status; > > >> > > + uint8_t config; > > >> > > + uint8_t alert_config; > > >> > > + uint8_t addr; > > >> > > + qemu_irq alarm; > > >> > > +} SBTSIState; > > >> > > + > > >> > > +/* > > >> > > + * SB-TSI registers only support SMBus byte data access. "_INT" > > >> registers > > >> > > are > > >> > > + * the integer part of a temperature value or limit, and "_DEC" > > >> registers > > >> > > are > > >> > > + * corresponding decimal parts. > > >> > > + */ > > >> > > +#define SBTSI_REG_TEMP_INT 0x01 /* RO */ > > >> > > +#define SBTSI_REG_STATUS 0x02 /* RO */ > > >> > > +#define SBTSI_REG_CONFIG 0x03 /* RO */ > > >> > > +#define SBTSI_REG_TEMP_HIGH_INT 0x07 /* RW */ > > >> > > +#define SBTSI_REG_TEMP_LOW_INT 0x08 /* RW */ > > >> > > +#define SBTSI_REG_CONFIG_WR 0x09 /* RW */ > > >> > > +#define SBTSI_REG_TEMP_DEC 0x10 /* RO */ > > >> > > +#define SBTSI_REG_TEMP_HIGH_DEC 0x13 /* RW */ > > >> > > +#define SBTSI_REG_TEMP_LOW_DEC 0x14 /* RW */ > > >> > > +#define SBTSI_REG_ALERT_CONFIG 0xBF /* RW */ > > >> > > +#define SBTSI_REG_MAN 0xFE /* RO */ > > >> > > +#define SBTSI_REG_REV 0xFF /* RO */ > > >> > > + > > >> > > +#define SBTSI_STATUS_HIGH_ALERT BIT(4) > > >> > > +#define SBTSI_STATUS_LOW_ALERT BIT(3) > > >> > > +#define SBTSI_CONFIG_ALERT_MASK BIT(7) > > >> > > +#define SBTSI_ALARM_EN BIT(0) > > >> > > + > > >> > > +#define SBTSI_LIMIT_LOW_DEFAULT (0) > > >> > > +#define SBTSI_LIMIT_HIGH_DEFAULT (560) > > >> > > +#define SBTSI_MAN_DEFAULT (0) > > >> > > +#define SBTSI_REV_DEFAULT (4) > > >> > > +#define SBTSI_ALARM_L "alarm_l" > > >> > > + > > >> > > +/* The temperature we stored are in units of 0.125 degrees. */ > > >> > > +#define SBTSI_TEMP_UNIT_IN_MILLIDEGREE 125 > > >> > > + > > >> > > +/* > > >> > > + * The integer part and decimal of the temperature both 8 bits. > > >> > > + * Only the top 3 bits of the decimal parts are used. > > >> > > + * So the max temperature is (2^8-1) + (2^3-1)/8 = 255.875 > degrees. > > >> > > + */ > > >> > > +#define SBTSI_TEMP_MAX 255875 > > >> > > + > > >> > > +/* The integer part of the temperature in terms of 0.125 > degrees. */ > > >> > > +static uint8_t get_temp_int(uint32_t temp) > > >> > > +{ > > >> > > + return temp >> 3; > > >> > > +} > > >> > > + > > >> > > +/* > > >> > > + * The decimal part of the temperature, in terms of 0.125 > degrees. > > >> > > + * H/W store it in the top 3 bits so we shift it by 5. > > >> > > + */ > > >> > > +static uint8_t get_temp_dec(uint32_t temp) > > >> > > +{ > > >> > > + return (temp & 0x7) << 5; > > >> > > +} > > >> > > + > > >> > > +/* > > >> > > + * Compute the temperature using the integer and decimal part, > > >> > > + * in terms of 0.125 degrees. The decimal part are only the top 3 > > >> bits > > >> > > + * so we shift it by 5 here. > > >> > > + */ > > >> > > +static uint32_t compute_temp(uint8_t integer, uint8_t decimal) > > >> > > +{ > > >> > > + return (integer << 3) + (decimal >> 5); > > >> > > +} > > >> > > + > > >> > > +/* Compute new temp with new int part of the temperature. */ > > >> > > +static uint32_t compute_temp_int(uint32_t temp, uint8_t integer) > > >> > > +{ > > >> > > + return compute_temp(integer, get_temp_dec(temp)); > > >> > > +} > > >> > > + > > >> > > +/* Compute new temp with new dec part of the temperature. */ > > >> > > +static uint32_t compute_temp_dec(uint32_t temp, uint8_t decimal) > > >> > > +{ > > >> > > + return compute_temp(get_temp_int(temp), decimal); > > >> > > +} > > >> > > + > > >> > > +/* The integer part of the temperature. */ > > >> > > +static void sbtsi_update_status(SBTSIState *s) > > >> > > +{ > > >> > > + s->status = 0; > > >> > > + if (s->alert_config & SBTSI_ALARM_EN) { > > >> > > + if (s->temperature >= s->limit_high) { > > >> > > + s->status |= SBTSI_STATUS_HIGH_ALERT; > > >> > > + } > > >> > > + if (s->temperature <= s->limit_low) { > > >> > > + s->status |= SBTSI_STATUS_LOW_ALERT; > > >> > > + } > > >> > > + } > > >> > > +} > > >> > > + > > >> > > +static void sbtsi_update_alarm(SBTSIState *s) > > >> > > +{ > > >> > > + sbtsi_update_status(s); > > >> > > + if (s->status != 0 && !(s->config & > SBTSI_CONFIG_ALERT_MASK)) { > > >> > > + qemu_irq_raise(s->alarm); > > >> > > + } else { > > >> > > + qemu_irq_lower(s->alarm); > > >> > > + } > > >> > > +} > > >> > > + > > >> > > +static uint8_t sbtsi_read_byte(SMBusDevice *d) > > >> > > +{ > > >> > > + SBTSIState *s = SBTSI(d); > > >> > > + uint8_t data = 0; > > >> > > + > > >> > > + switch (s->addr) { > > >> > > + case SBTSI_REG_TEMP_INT: > > >> > > + data = get_temp_int(s->temperature); > > >> > > + break; > > >> > > + > > >> > > + case SBTSI_REG_TEMP_DEC: > > >> > > + data = get_temp_dec(s->temperature); > > >> > > + break; > > >> > > + > > >> > > + case SBTSI_REG_TEMP_HIGH_INT: > > >> > > + data = get_temp_int(s->limit_high); > > >> > > + break; > > >> > > + > > >> > > + case SBTSI_REG_TEMP_LOW_INT: > > >> > > + data = get_temp_int(s->limit_low); > > >> > > + break; > > >> > > + > > >> > > + case SBTSI_REG_TEMP_HIGH_DEC: > > >> > > + data = get_temp_dec(s->limit_high); > > >> > > + break; > > >> > > + > > >> > > + case SBTSI_REG_TEMP_LOW_DEC: > > >> > > + data = get_temp_dec(s->limit_low); > > >> > > + break; > > >> > > + > > >> > > + case SBTSI_REG_CONFIG: > > >> > > + case SBTSI_REG_CONFIG_WR: > > >> > > + data = s->config; > > >> > > + break; > > >> > > + > > >> > > + case SBTSI_REG_STATUS: > > >> > > + sbtsi_update_alarm(s); > > >> > > + data = s->status; > > >> > > + break; > > >> > > + > > >> > > + case SBTSI_REG_ALERT_CONFIG: > > >> > > + data = s->alert_config; > > >> > > + break; > > >> > > + > > >> > > + case SBTSI_REG_MAN: > > >> > > + data = SBTSI_MAN_DEFAULT; > > >> > > + break; > > >> > > + > > >> > > + case SBTSI_REG_REV: > > >> > > + data = SBTSI_REV_DEFAULT; > > >> > > + break; > > >> > > >> Does this device do some sort of auto-increment on the address when > > >> reading/writing? > > >> > > > > > > +Hao Wu - Please take a look at the above > > > question. I imagine it's a while since you've thought about it, but > please > > > double check :) > > > Thanks! > > > > > > > > >> Other than that possible issue, I don't see anything else, it's pretty > > >> straightforward. > > >> > > >> > > + > > >> > > + default: > > >> > > + qemu_log_mask(LOG_GUEST_ERROR, > > >> > > + "%s: reading from invalid reg: 0x%02x\n", > > >> > > + __func__, s->addr); > > >> > > + break; > > >> > > + } > > >> > > + > > >> > > + trace_tmp_sbtsi_read_data(s->addr, data); > > >> > > + return data; > > >> > > +} > > >> > > + > > >> > > +static void sbtsi_write(SBTSIState *s, uint8_t data) > > >> > > +{ > > >> > > + trace_tmp_sbtsi_write_data(s->addr, data); > > >> > > + switch (s->addr) { > > >> > > + case SBTSI_REG_CONFIG_WR: > > >> > > + s->config = data; > > >> > > + break; > > >> > > + > > >> > > + case SBTSI_REG_TEMP_HIGH_INT: > > >> > > + s->limit_high = compute_temp_int(s->limit_high, data); > > >> > > + break; > > >> > > + > > >> > > + case SBTSI_REG_TEMP_LOW_INT: > > >> > > + s->limit_low = compute_temp_int(s->limit_low, data); > > >> > > + break; > > >> > > + > > >> > > + case SBTSI_REG_TEMP_HIGH_DEC: > > >> > > + s->limit_high = compute_temp_dec(s->limit_high, data); > > >> > > + break; > > >> > > + > > >> > > + case SBTSI_REG_TEMP_LOW_DEC: > > >> > > + s->limit_low = compute_temp_dec(s->limit_low, data); > > >> > > + break; > > >> > > + > > >> > > + case SBTSI_REG_ALERT_CONFIG: > > >> > > + s->alert_config = data; > > >> > > + break; > > >> > > + > > >> > > + case SBTSI_REG_TEMP_INT: > > >> > > + case SBTSI_REG_TEMP_DEC: > > >> > > + case SBTSI_REG_CONFIG: > > >> > > + case SBTSI_REG_STATUS: > > >> > > + case SBTSI_REG_MAN: > > >> > > + case SBTSI_REG_REV: > > >> > > + qemu_log_mask(LOG_GUEST_ERROR, > > >> > > + "%s: writing to read only reg: 0x%02x data: > > >> 0x%02x\n", > > >> > > + __func__, s->addr, data); > > >> > > + break; > > >> > > + > > >> > > + default: > > >> > > + qemu_log_mask(LOG_GUEST_ERROR, > > >> > > + "%s: writing to invalid reg: 0x%02x data: > 0x%02x\n", > > >> > > + __func__, s->addr, data); > > >> > > + break; > > >> > > + } > > >> > > + sbtsi_update_alarm(s); > > >> > > +} > > >> > > + > > >> > > +static int sbtsi_write_data(SMBusDevice *d, uint8_t *buf, uint8_t > > >> len) > > >> > > +{ > > >> > > + SBTSIState *s = SBTSI(d); > > >> > > + > > >> > > + if (len == 0) { > > >> > > + qemu_log_mask(LOG_GUEST_ERROR, "%s: writing empty > data\n", > > >> > > __func__); > > >> > > + return -1; > > >> > > + } > > >> > > + > > >> > > + s->addr = buf[0]; > > >> > > + if (len > 1) { > > >> > > + sbtsi_write(s, buf[1]); > > >> > > + if (len > 2) { > > >> > > + qemu_log_mask(LOG_GUEST_ERROR, "%s: extra data at > end\n", > > >> > > __func__); > > >> > > + } > > >> > > + } > > >> > > + return 0; > > >> > > +} > > >> > > + > > >> > > +/* Units are millidegrees. */ > > >> > > +static void sbtsi_get_temperature(Object *obj, Visitor *v, const > char > > >> > > *name, > > >> > > + void *opaque, Error **errp) > > >> > > +{ > > >> > > + SBTSIState *s = SBTSI(obj); > > >> > > + uint32_t temp = s->temperature * > SBTSI_TEMP_UNIT_IN_MILLIDEGREE; > > >> > > + > > >> > > + visit_type_uint32(v, name, &temp, errp); > > >> > > +} > > >> > > + > > >> > > +/* Units are millidegrees. */ > > >> > > +static void sbtsi_set_temperature(Object *obj, Visitor *v, const > char > > >> > > *name, > > >> > > + void *opaque, Error **errp) > > >> > > +{ > > >> > > + SBTSIState *s = SBTSI(obj); > > >> > > + uint32_t temp; > > >> > > + > > >> > > + if (!visit_type_uint32(v, name, &temp, errp)) { > > >> > > + return; > > >> > > + } > > >> > > + if (temp > SBTSI_TEMP_MAX) { > > >> > > + error_setg(errp, "value %" PRIu32 ".%03" PRIu32 " C is > out of > > >> > > range", > > >> > > + temp / 1000, temp % 1000); > > >> > > + return; > > >> > > + } > > >> > > + > > >> > > + s->temperature = temp / SBTSI_TEMP_UNIT_IN_MILLIDEGREE; > > >> > > + sbtsi_update_alarm(s); > > >> > > +} > > >> > > + > > >> > > +static int sbtsi_post_load(void *opaque, int version_id) > > >> > > +{ > > >> > > + SBTSIState *s = opaque; > > >> > > + > > >> > > + sbtsi_update_alarm(s); > > >> > > + return 0; > > >> > > +} > > >> > > + > > >> > > +static const VMStateDescription vmstate_sbtsi = { > > >> > > + .name = "SBTSI", > > >> > > + .version_id = 0, > > >> > > + .minimum_version_id = 0, > > >> > > + .post_load = sbtsi_post_load, > > >> > > + .fields = (VMStateField[]) { > > >> > > + VMSTATE_UINT32(temperature, SBTSIState), > > >> > > + VMSTATE_UINT32(limit_low, SBTSIState), > > >> > > + VMSTATE_UINT32(limit_high, SBTSIState), > > >> > > + VMSTATE_UINT8(config, SBTSIState), > > >> > > + VMSTATE_UINT8(status, SBTSIState), > > >> > > + VMSTATE_UINT8(addr, SBTSIState), > > >> > > + VMSTATE_END_OF_LIST() > > >> > > + } > > >> > > +}; > > >> > > + > > >> > > +static void sbtsi_enter_reset(Object *obj, ResetType type) > > >> > > +{ > > >> > > + SBTSIState *s = SBTSI(obj); > > >> > > + > > >> > > + s->config = 0; > > >> > > + s->limit_low = SBTSI_LIMIT_LOW_DEFAULT; > > >> > > + s->limit_high = SBTSI_LIMIT_HIGH_DEFAULT; > > >> > > +} > > >> > > + > > >> > > +static void sbtsi_hold_reset(Object *obj) > > >> > > +{ > > >> > > + SBTSIState *s = SBTSI(obj); > > >> > > + > > >> > > + qemu_irq_lower(s->alarm); > > >> > > +} > > >> > > + > > >> > > +static void sbtsi_init(Object *obj) > > >> > > +{ > > >> > > + SBTSIState *s = SBTSI(obj); > > >> > > + > > >> > > + /* Current temperature in millidegrees. */ > > >> > > + object_property_add(obj, "temperature", "uint32", > > >> > > + sbtsi_get_temperature, > sbtsi_set_temperature, > > >> > > + NULL, NULL); > > >> > > + qdev_init_gpio_out_named(DEVICE(obj), &s->alarm, > SBTSI_ALARM_L, > > >> 0); > > >> > > +} > > >> > > + > > >> > > +static void sbtsi_class_init(ObjectClass *klass, void *data) > > >> > > +{ > > >> > > + ResettableClass *rc = RESETTABLE_CLASS(klass); > > >> > > + DeviceClass *dc = DEVICE_CLASS(klass); > > >> > > + SMBusDeviceClass *k = SMBUS_DEVICE_CLASS(klass); > > >> > > + > > >> > > + dc->desc = "SB-TSI Temperature Sensor"; > > >> > > + dc->vmsd = &vmstate_sbtsi; > > >> > > + k->write_data = sbtsi_write_data; > > >> > > + k->receive_byte = sbtsi_read_byte; > > >> > > + rc->phases.enter = sbtsi_enter_reset; > > >> > > + rc->phases.hold = sbtsi_hold_reset; > > >> > > +} > > >> > > + > > >> > > +static const TypeInfo sbtsi_info = { > > >> > > + .name = TYPE_SBTSI, > > >> > > + .parent = TYPE_SMBUS_DEVICE, > > >> > > + .instance_size = sizeof(SBTSIState), > > >> > > + .instance_init = sbtsi_init, > > >> > > + .class_init = sbtsi_class_init, > > >> > > +}; > > >> > > + > > >> > > +static void sbtsi_register_types(void) > > >> > > +{ > > >> > > + type_register_static(&sbtsi_info); > > >> > > +} > > >> > > + > > >> > > +type_init(sbtsi_register_types) > > >> > > diff --git a/hw/sensor/trace-events b/hw/sensor/trace-events > > >> > > new file mode 100644 > > >> > > index 0000000000..21ab3809e2 > > >> > > --- /dev/null > > >> > > +++ b/hw/sensor/trace-events > > >> > > @@ -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" > > >> > > diff --git a/hw/sensor/trace.h b/hw/sensor/trace.h > > >> > > new file mode 100644 > > >> > > index 0000000000..e4721560b0 > > >> > > --- /dev/null > > >> > > +++ b/hw/sensor/trace.h > > >> > > @@ -0,0 +1 @@ > > >> > > +#include "trace/trace-hw_sensor.h" > > >> > > diff --git a/meson.build b/meson.build > > >> > > index 53065e96ec..f8ab0bf74e 100644 > > >> > > --- a/meson.build > > >> > > +++ b/meson.build > > >> > > @@ -2494,6 +2494,7 @@ if have_system > > >> > > 'hw/rtc', > > >> > > 'hw/s390x', > > >> > > 'hw/scsi', > > >> > > + 'hw/sensor', > > >> > > 'hw/sd', > > >> > > 'hw/sh4', > > >> > > 'hw/sparc', > > >> > > diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build > > >> > > index 37e1eaa449..d1a8c38f74 100644 > > >> > > --- a/tests/qtest/meson.build > > >> > > +++ b/tests/qtest/meson.build > > >> > > @@ -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', > > >> > > diff --git a/tests/qtest/tmp_sbtsi-test.c > > >> b/tests/qtest/tmp_sbtsi-test.c > > >> > > new file mode 100644 > > >> > > index 0000000000..7f5fafacc7 > > >> > > --- /dev/null > > >> > > +++ b/tests/qtest/tmp_sbtsi-test.c > > >> > > @@ -0,0 +1,180 @@ > > >> > > +/* > > >> > > + * QTests for the SBTSI temperature sensor > > >> > > + * > > >> > > + * Copyright 2020 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 > > >> > > + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public > > >> License > > >> > > + * for more details. > > >> > > + */ > > >> > > + > > >> > > +#include "qemu/osdep.h" > > >> > > + > > >> > > +#include "libqtest-single.h" > > >> > > +#include "libqos/qgraph.h" > > >> > > +#include "libqos/i2c.h" > > >> > > +#include "qapi/qmp/qdict.h" > > >> > > +#include "qemu/bitops.h" > > >> > > + > > >> > > +#define TEST_ID "sbtsi-test" > > >> > > +#define TEST_ADDR (0x4c) > > >> > > + > > >> > > +/* > > >> > > + * SB-TSI registers only support SMBus byte data access. "_INT" > > >> registers > > >> > > are > > >> > > + * the integer part of a temperature value or limit, and "_DEC" > > >> registers > > >> > > are > > >> > > + * corresponding decimal parts. > > >> > > + */ > > >> > > +#define REG_TEMP_INT 0x01 /* RO */ > > >> > > +#define REG_STATUS 0x02 /* RO */ > > >> > > +#define REG_CONFIG 0x03 /* RO */ > > >> > > +#define REG_TEMP_HIGH_INT 0x07 /* RW */ > > >> > > +#define REG_TEMP_LOW_INT 0x08 /* RW */ > > >> > > +#define REG_CONFIG_WR 0x09 /* RW */ > > >> > > +#define REG_TEMP_DEC 0x10 /* RO */ > > >> > > +#define REG_TEMP_HIGH_DEC 0x13 /* RW */ > > >> > > +#define REG_TEMP_LOW_DEC 0x14 /* RW */ > > >> > > +#define REG_ALERT_CONFIG 0xBF /* RW */ > > >> > > + > > >> > > +#define STATUS_HIGH_ALERT BIT(4) > > >> > > +#define STATUS_LOW_ALERT BIT(3) > > >> > > +#define CONFIG_ALERT_MASK BIT(7) > > >> > > +#define ALARM_EN BIT(0) > > >> > > + > > >> > > +/* The temperature stored are in units of 0.125 degrees. */ > > >> > > +#define TEMP_UNIT_IN_MILLIDEGREE 125 > > >> > > +#define LIMIT_LOW (10500) > > >> > > +#define LIMIT_HIGH (55125) > > >> > > + > > >> > > +static uint32_t qmp_sbtsi_get_temperature(const char *id) > > >> > > +{ > > >> > > + QDict *response; > > >> > > + int ret; > > >> > > + > > >> > > + response = qmp("{ 'execute': 'qom-get', 'arguments': { > 'path': > > >> %s, " > > >> > > + "'property': 'temperature' } }", id); > > >> > > + g_assert(qdict_haskey(response, "return")); > > >> > > + ret = (uint32_t)qdict_get_int(response, "return"); > > >> > > + qobject_unref(response); > > >> > > + return ret; > > >> > > +} > > >> > > + > > >> > > +static void qmp_sbtsi_set_temperature(const char *id, uint32_t > value) > > >> > > +{ > > >> > > + QDict *response; > > >> > > + > > >> > > + response = qmp("{ 'execute': 'qom-set', 'arguments': { > 'path': > > >> %s, " > > >> > > + "'property': 'temperature', 'value': %d } }", > id, > > >> > > value); > > >> > > + g_assert(qdict_haskey(response, "return")); > > >> > > + qobject_unref(response); > > >> > > +} > > >> > > + > > >> > > +/* > > >> > > + * Compute the temperature using the integer and decimal part and > > >> return > > >> > > + * millidegrees. The decimal part are only the top 3 bits so we > > >> shift it > > >> > > by > > >> > > + * 5 here. > > >> > > + */ > > >> > > +static uint32_t regs_to_temp(uint8_t integer, uint8_t decimal) > > >> > > +{ > > >> > > + return ((integer << 3) + (decimal >> 5)) * > > >> TEMP_UNIT_IN_MILLIDEGREE; > > >> > > +} > > >> > > + > > >> > > +/* > > >> > > + * Compute the integer and decimal parts of the temperature in > > >> > > millidegrees. > > >> > > + * H/W store the decimal in the top 3 bits so we shift it by 5. > > >> > > + */ > > >> > > +static void temp_to_regs(uint32_t temp, uint8_t *integer, uint8_t > > >> > > *decimal) > > >> > > +{ > > >> > > + temp /= TEMP_UNIT_IN_MILLIDEGREE; > > >> > > + *integer = temp >> 3; > > >> > > + *decimal = (temp & 0x7) << 5; > > >> > > +} > > >> > > + > > >> > > +static void tx_rx(void *obj, void *data, QGuestAllocator *alloc) > > >> > > +{ > > >> > > + uint16_t value; > > >> > > + uint8_t integer, decimal; > > >> > > + QI2CDevice *i2cdev = (QI2CDevice *)obj; > > >> > > + > > >> > > + /* Test default values */ > > >> > > + value = qmp_sbtsi_get_temperature(TEST_ID); > > >> > > + g_assert_cmpuint(value, ==, 0); > > >> > > + > > >> > > + integer = i2c_get8(i2cdev, REG_TEMP_INT); > > >> > > + decimal = i2c_get8(i2cdev, REG_TEMP_DEC); > > >> > > + g_assert_cmpuint(regs_to_temp(integer, decimal), ==, 0); > > >> > > + > > >> > > + /* Test setting temperature */ > > >> > > + qmp_sbtsi_set_temperature(TEST_ID, 20000); > > >> > > + value = qmp_sbtsi_get_temperature(TEST_ID); > > >> > > + g_assert_cmpuint(value, ==, 20000); > > >> > > + > > >> > > + integer = i2c_get8(i2cdev, REG_TEMP_INT); > > >> > > + decimal = i2c_get8(i2cdev, REG_TEMP_DEC); > > >> > > + g_assert_cmpuint(regs_to_temp(integer, decimal), ==, 20000); > > >> > > + > > >> > > + /* Set alert mask in config */ > > >> > > + i2c_set8(i2cdev, REG_CONFIG_WR, CONFIG_ALERT_MASK); > > >> > > + value = i2c_get8(i2cdev, REG_CONFIG); > > >> > > + g_assert_cmphex(value, ==, CONFIG_ALERT_MASK); > > >> > > + /* Enable alarm_en */ > > >> > > + i2c_set8(i2cdev, REG_ALERT_CONFIG, ALARM_EN); > > >> > > + value = i2c_get8(i2cdev, REG_ALERT_CONFIG); > > >> > > + g_assert_cmphex(value, ==, ALARM_EN); > > >> > > + > > >> > > + /* Test setting limits */ > > >> > > + /* Limit low = 10.500 */ > > >> > > + temp_to_regs(LIMIT_LOW, &integer, &decimal); > > >> > > + i2c_set8(i2cdev, REG_TEMP_LOW_INT, integer); > > >> > > + i2c_set8(i2cdev, REG_TEMP_LOW_DEC, decimal); > > >> > > + integer = i2c_get8(i2cdev, REG_TEMP_LOW_INT); > > >> > > + decimal = i2c_get8(i2cdev, REG_TEMP_LOW_DEC); > > >> > > + g_assert_cmpuint(regs_to_temp(integer, decimal), ==, > LIMIT_LOW); > > >> > > + /* Limit high = 55.125 */ > > >> > > + temp_to_regs(LIMIT_HIGH, &integer, &decimal); > > >> > > + i2c_set8(i2cdev, REG_TEMP_HIGH_INT, integer); > > >> > > + i2c_set8(i2cdev, REG_TEMP_HIGH_DEC, decimal); > > >> > > + integer = i2c_get8(i2cdev, REG_TEMP_HIGH_INT); > > >> > > + decimal = i2c_get8(i2cdev, REG_TEMP_HIGH_DEC); > > >> > > + g_assert_cmpuint(regs_to_temp(integer, decimal), ==, > LIMIT_HIGH); > > >> > > + /* No alert is generated. */ > > >> > > + value = i2c_get8(i2cdev, REG_STATUS); > > >> > > + g_assert_cmphex(value, ==, 0); > > >> > > + > > >> > > + /* Test alert for low temperature */ > > >> > > + qmp_sbtsi_set_temperature(TEST_ID, LIMIT_LOW); > > >> > > + value = i2c_get8(i2cdev, REG_STATUS); > > >> > > + g_assert_cmphex(value, ==, STATUS_LOW_ALERT); > > >> > > + > > >> > > + /* Test alert for high temperature */ > > >> > > + qmp_sbtsi_set_temperature(TEST_ID, LIMIT_HIGH); > > >> > > + value = i2c_get8(i2cdev, REG_STATUS); > > >> > > + g_assert_cmphex(value, ==, STATUS_HIGH_ALERT); > > >> > > + > > >> > > + /* Disable alarm_en */ > > >> > > + i2c_set8(i2cdev, REG_ALERT_CONFIG, 0); > > >> > > + value = i2c_get8(i2cdev, REG_ALERT_CONFIG); > > >> > > + g_assert_cmphex(value, ==, 0); > > >> > > + /* No alert when alarm_en is false. */ > > >> > > + value = i2c_get8(i2cdev, REG_STATUS); > > >> > > + g_assert_cmphex(value, ==, 0); > > >> > > +} > > >> > > + > > >> > > +static void sbtsi_register_nodes(void) > > >> > > +{ > > >> > > + QOSGraphEdgeOptions opts = { > > >> > > + .extra_device_opts = "id=" TEST_ID ",address=0x4c" > > >> > > + }; > > >> > > + add_qi2c_address(&opts, &(QI2CAddress) { TEST_ADDR }); > > >> > > + > > >> > > + qos_node_create_driver("sbtsi", i2c_device_create); > > >> > > + qos_node_consumes("sbtsi", "i2c-bus", &opts); > > >> > > + > > >> > > + qos_add_test("tx-rx", "sbtsi", tx_rx, NULL); > > >> > > +} > > >> > > +libqos_init(sbtsi_register_nodes); > > >> > > -- > > >> > > > >> > > > >> > + Corey for i2c maintainer. The new sensor directory is mostly if > not > > >> > entirely i2c devices. I didn't create a maintainer entry for this > i2c > > >> > device, but I can if desired and send out a v2. > > >> > > >> Yeah, I guess I should be maintainer there. I'll queue up a change > for > > >> that. Thanks. > > >> > > >> -corey > > >> > > >> > > > >> > > > >> > > 2.34.1.575.g55b058a8bb-goog > > >> > > > > >> > > > > >> > > > > --00000000000019555805d6945e84 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

On Thu, Jan 27, 2022 at 6:55 AM Corey Min= yard <cminyard@mvista.com>= wrote:
On Wed, = Jan 26, 2022 at 04:09:03PM -0800, Hao Wu wrote:
> Hi,
>
> Sorry for the late reply. I'm not sure what "auto-increment&q= uot; means here.

The question is: When a value is read, does the address automatically
increment.=C2=A0 I2C devices very often do this.=C2=A0 If you do a multi-by= te
read, they often will read the value from address 0, then from address
1, etc.=C2=A0 Same for writes.
The datasheet does not = suggest such behavior could happen.=C2=A0

> The kernel driver at
> https://lkml.org/lkml/2020/12/11/968
> only has byte-size read/write operations, so I don't see a problem= here.
> The values are extracted
> from the datasheet.

The *Linux* kernel driver my only do byte-size operations, but other
kernels may work different, and the Linux kernel may change.=C2=A0 You have=
to implement from the datasheet, not the device driver.
The implementation is already according to the datasheet.
Thanks,

-corey

>
> On Tue, Jan 18, 2022 at 9:10 AM Patrick Venture <venture@google.com> wrote:
>
> >
> >
> > On Mon, Jan 17, 2022 at 6:05 AM Corey Minyard <cminyard@mvista.com> wrote= :
> >
> >> On Sun, Jan 09, 2022 at 06:17:34PM -0800, Patrick Venture wro= te:
> >> > On Fri, Jan 7, 2022 at 7:04 PM Patrick Venture <venture@google.com&g= t;
> >> wrote:
> >> >
> >> > > From: Hao Wu <wuhaotsh@google.com>
> >> > >
> >> > > SB Temperature Sensor Interface (SB-TSI) is an SMBu= s compatible
> >> > > interface that reports AMD SoC's Ttcl (normaliz= ed temperature),
> >> > > and resembles a typical 8-pin remote temperature se= nsor's I2C
> >> interface
> >> > > to BMC.
> >> > >
> >> > > This patch implements a basic AMD SB-TSI sensor tha= t 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://develop= er.amd.com/wp-content/resources/56255_3_03.PDF
> >> > > (Chapter 6)
> >> > >
> >> > > Signed-off-by: Hao Wu <wuhaotsh@google.com>
> >> > > Reviewed-by: Doug Evans <dje@google.com>
> >> > > ---
> >> > >=C2=A0 hw/sensor/Kconfig=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 |=C2=A0 =C2=A04 +
> >> > >=C2=A0 hw/sensor/meson.build=C2=A0 =C2=A0 =C2=A0 =C2= =A0 |=C2=A0 =C2=A01 +
> >> > >=C2=A0 hw/sensor/tmp_sbtsi.c=C2=A0 =C2=A0 =C2=A0 =C2= =A0 | 393
> >> +++++++++++++++++++++++++++++++++++
> >> > >=C2=A0 hw/sensor/trace-events=C2=A0 =C2=A0 =C2=A0 = =C2=A0|=C2=A0 =C2=A05 +
> >> > >=C2=A0 hw/sensor/trace.h=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 |=C2=A0 =C2=A01 +
> >> > >=C2=A0 meson.build=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 =C2=A01 +
> >> > >=C2=A0 tests/qtest/meson.build=C2=A0 =C2=A0 =C2=A0 |= =C2=A0 =C2=A01 +
> >> > >=C2=A0 tests/qtest/tmp_sbtsi-test.c | 180 ++++++++++= ++++++
> >> > >=C2=A0 8 files changed, 586 insertions(+)
> >> > >=C2=A0 create mode 100644 hw/sensor/tmp_sbtsi.c
> >> > >=C2=A0 create mode 100644 hw/sensor/trace-events
> >> > >=C2=A0 create mode 100644 hw/sensor/trace.h
> >> > >=C2=A0 create mode 100644 tests/qtest/tmp_sbtsi-test= .c
> >> > >
> >> > > diff --git a/hw/sensor/Kconfig b/hw/sensor/Kconfig<= br> > >> > > index 9c8a049b06..27f6f79c84 100644
> >> > > --- a/hw/sensor/Kconfig
> >> > > +++ b/hw/sensor/Kconfig
> >> > > @@ -21,3 +21,7 @@ config ADM1272
> >> > >=C2=A0 config MAX34451
> >> > >=C2=A0 =C2=A0 =C2=A0 bool
> >> > >=C2=A0 =C2=A0 =C2=A0 depends on I2C
> >> > > +
> >> > > +config AMDSBTSI
> >> > > +=C2=A0 =C2=A0 bool
> >> > > +=C2=A0 =C2=A0 depends on I2C
> >> > > diff --git a/hw/sensor/meson.build b/hw/sensor/meso= n.build
> >> > > index 059c4ca935..f7b0e645eb 100644
> >> > > --- a/hw/sensor/meson.build
> >> > > +++ b/hw/sensor/meson.build
> >> > > @@ -4,3 +4,4 @@ softmmu_ss.add(when: 'CONFIG_DP= S310', if_true:
> >> > > files('dps310.c'))
> >> > >=C2=A0 softmmu_ss.add(when: 'CONFIG_EMC141X'= , if_true: files('emc141x.c'))
> >> > >=C2=A0 softmmu_ss.add(when: 'CONFIG_ADM1272'= , if_true: files('adm1272.c'))
> >> > >=C2=A0 softmmu_ss.add(when: 'CONFIG_MAX34451'= ;, if_true: files('max34451.c'))
> >> > > +softmmu_ss.add(when: 'CONFIG_AMDSBTSI', if= _true:
> >> files('tmp_sbtsi.c'))
> >> > > diff --git a/hw/sensor/tmp_sbtsi.c b/hw/sensor/tmp_= sbtsi.c
> >> > > new file mode 100644
> >> > > index 0000000000..b68c7ebf61
> >> > > --- /dev/null
> >> > > +++ b/hw/sensor/tmp_sbtsi.c
> >> > > @@ -0,0 +1,393 @@
> >> > > +/*
> >> > > + * AMD SBI Temperature Sensor Interface (SB-TSI) > >> > > + *
> >> > > + * Copyright 2021 Google LLC
> >> > > + *
> >> > > + * This program is free software; you can redistri= bute it and/or
> >> modify it
> >> > > + * under the terms of the GNU General Public Licen= se as published by
> >> the
> >> > > + * Free Software Foundation; either version 2 of t= he 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
> >> > > + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU G= eneral Public
> >> License
> >> > > + * for more details.
> >> > > + */
> >> > > +
> >> > > +#include "qemu/osdep.h"
> >> > > +#include "hw/i2c/smbus_slave.h"
> >> > > +#include "hw/irq.h"
> >> > > +#include "migration/vmstate.h"
> >> > > +#include "qapi/error.h"
> >> > > +#include "qapi/visitor.h"
> >> > > +#include "qemu/log.h"
> >> > > +#include "qemu/module.h"
> >> > > +#include "trace.h"
> >> > > +
> >> > > +#define TYPE_SBTSI "sbtsi"
> >> > > +#define SBTSI(obj) OBJECT_CHECK(SBTSIState, (obj),= TYPE_SBTSI)
> >> > > +
> >> > > +/**
> >> > > + * SBTSIState:
> >> > > + * temperatures are in units of 0.125 degrees
> >> > > + * @temperature: Temperature
> >> > > + * @limit_low: Lowest temperature
> >> > > + * @limit_high: Highest temperature
> >> > > + * @status: The status register
> >> > > + * @config: The config register
> >> > > + * @alert_config: The config for alarm_l output. > >> > > + * @addr: The address to read/write for the next c= md.
> >> > > + * @alarm: The alarm_l output pin (GPIO)
> >> > > + */
> >> > > +typedef struct SBTSIState {
> >> > > +=C2=A0 =C2=A0 SMBusDevice parent;
> >> > > +
> >> > > +=C2=A0 =C2=A0 uint32_t temperature;
> >> > > +=C2=A0 =C2=A0 uint32_t limit_low;
> >> > > +=C2=A0 =C2=A0 uint32_t limit_high;
> >> > > +=C2=A0 =C2=A0 uint8_t status;
> >> > > +=C2=A0 =C2=A0 uint8_t config;
> >> > > +=C2=A0 =C2=A0 uint8_t alert_config;
> >> > > +=C2=A0 =C2=A0 uint8_t addr;
> >> > > +=C2=A0 =C2=A0 qemu_irq alarm;
> >> > > +} SBTSIState;
> >> > > +
> >> > > +/*
> >> > > + * SB-TSI registers only support SMBus byte data a= ccess. "_INT"
> >> registers
> >> > > are
> >> > > + * the integer part of a temperature value or limi= t, and "_DEC"
> >> registers
> >> > > are
> >> > > + * corresponding decimal parts.
> >> > > + */
> >> > > +#define SBTSI_REG_TEMP_INT=C2=A0 =C2=A0 =C2=A0 0x0= 1 /* RO */
> >> > > +#define SBTSI_REG_STATUS=C2=A0 =C2=A0 =C2=A0 =C2= =A0 0x02 /* RO */
> >> > > +#define SBTSI_REG_CONFIG=C2=A0 =C2=A0 =C2=A0 =C2= =A0 0x03 /* RO */
> >> > > +#define SBTSI_REG_TEMP_HIGH_INT 0x07 /* RW */
> >> > > +#define SBTSI_REG_TEMP_LOW_INT=C2=A0 0x08 /* RW */=
> >> > > +#define SBTSI_REG_CONFIG_WR=C2=A0 =C2=A0 =C2=A00x0= 9 /* RW */
> >> > > +#define SBTSI_REG_TEMP_DEC=C2=A0 =C2=A0 =C2=A0 0x1= 0 /* RO */
> >> > > +#define SBTSI_REG_TEMP_HIGH_DEC 0x13 /* RW */
> >> > > +#define SBTSI_REG_TEMP_LOW_DEC=C2=A0 0x14 /* RW */=
> >> > > +#define SBTSI_REG_ALERT_CONFIG=C2=A0 0xBF /* RW */=
> >> > > +#define SBTSI_REG_MAN=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A00xFE /* RO */
> >> > > +#define SBTSI_REG_REV=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A00xFF /* RO */
> >> > > +
> >> > > +#define SBTSI_STATUS_HIGH_ALERT BIT(4)
> >> > > +#define SBTSI_STATUS_LOW_ALERT=C2=A0 BIT(3)
> >> > > +#define SBTSI_CONFIG_ALERT_MASK BIT(7)
> >> > > +#define SBTSI_ALARM_EN=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 BIT(0)
> >> > > +
> >> > > +#define SBTSI_LIMIT_LOW_DEFAULT (0)
> >> > > +#define SBTSI_LIMIT_HIGH_DEFAULT (560)
> >> > > +#define SBTSI_MAN_DEFAULT (0)
> >> > > +#define SBTSI_REV_DEFAULT (4)
> >> > > +#define SBTSI_ALARM_L "alarm_l"
> >> > > +
> >> > > +/* The temperature we stored are in units of 0.125= degrees. */
> >> > > +#define SBTSI_TEMP_UNIT_IN_MILLIDEGREE 125
> >> > > +
> >> > > +/*
> >> > > + * The integer part and decimal of the temperature= both 8 bits.
> >> > > + * Only the top 3 bits of the decimal parts are us= ed.
> >> > > + * So the max temperature is (2^8-1) + (2^3-1)/8 = =3D 255.875 degrees.
> >> > > + */
> >> > > +#define SBTSI_TEMP_MAX 255875
> >> > > +
> >> > > +/* The integer part of the temperature in terms of= 0.125 degrees. */
> >> > > +static uint8_t get_temp_int(uint32_t temp)
> >> > > +{
> >> > > +=C2=A0 =C2=A0 return temp >> 3;
> >> > > +}
> >> > > +
> >> > > +/*
> >> > > + * The decimal part of the temperature, in terms o= f 0.125 degrees.
> >> > > + * H/W store it in the top 3 bits so we shift it b= y 5.
> >> > > + */
> >> > > +static uint8_t get_temp_dec(uint32_t temp)
> >> > > +{
> >> > > +=C2=A0 =C2=A0 return (temp & 0x7) << 5;<= br> > >> > > +}
> >> > > +
> >> > > +/*
> >> > > + * Compute the temperature using the integer and d= ecimal part,
> >> > > + * in terms of 0.125 degrees. The decimal part are= only the top 3
> >> bits
> >> > > + * so we shift it by 5 here.
> >> > > + */
> >> > > +static uint32_t compute_temp(uint8_t integer, uint= 8_t decimal)
> >> > > +{
> >> > > +=C2=A0 =C2=A0 return (integer << 3) + (decim= al >> 5);
> >> > > +}
> >> > > +
> >> > > +/* Compute new temp with new int part of the tempe= rature. */
> >> > > +static uint32_t compute_temp_int(uint32_t temp, ui= nt8_t integer)
> >> > > +{
> >> > > +=C2=A0 =C2=A0 return compute_temp(integer, get_tem= p_dec(temp));
> >> > > +}
> >> > > +
> >> > > +/* Compute new temp with new dec part of the tempe= rature. */
> >> > > +static uint32_t compute_temp_dec(uint32_t temp, ui= nt8_t decimal)
> >> > > +{
> >> > > +=C2=A0 =C2=A0 return compute_temp(get_temp_int(tem= p), decimal);
> >> > > +}
> >> > > +
> >> > > +/* The integer part of the temperature. */
> >> > > +static void sbtsi_update_status(SBTSIState *s)
> >> > > +{
> >> > > +=C2=A0 =C2=A0 s->status =3D 0;
> >> > > +=C2=A0 =C2=A0 if (s->alert_config & SBTSI_A= LARM_EN) {
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (s->temperature = >=3D s->limit_high) {
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 s->st= atus |=3D SBTSI_STATUS_HIGH_ALERT;
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (s->temperature = <=3D s->limit_low) {
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 s->st= atus |=3D SBTSI_STATUS_LOW_ALERT;
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
> >> > > +=C2=A0 =C2=A0 }
> >> > > +}
> >> > > +
> >> > > +static void sbtsi_update_alarm(SBTSIState *s)
> >> > > +{
> >> > > +=C2=A0 =C2=A0 sbtsi_update_status(s);
> >> > > +=C2=A0 =C2=A0 if (s->status !=3D 0 && != (s->config & SBTSI_CONFIG_ALERT_MASK)) {
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 qemu_irq_raise(s->a= larm);
> >> > > +=C2=A0 =C2=A0 } else {
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 qemu_irq_lower(s->a= larm);
> >> > > +=C2=A0 =C2=A0 }
> >> > > +}
> >> > > +
> >> > > +static uint8_t sbtsi_read_byte(SMBusDevice *d)
> >> > > +{
> >> > > +=C2=A0 =C2=A0 SBTSIState *s =3D SBTSI(d);
> >> > > +=C2=A0 =C2=A0 uint8_t data =3D 0;
> >> > > +
> >> > > +=C2=A0 =C2=A0 switch (s->addr) {
> >> > > +=C2=A0 =C2=A0 case SBTSI_REG_TEMP_INT:
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 data =3D get_temp_int(= s->temperature);
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 break;
> >> > > +
> >> > > +=C2=A0 =C2=A0 case SBTSI_REG_TEMP_DEC:
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 data =3D get_temp_dec(= s->temperature);
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 break;
> >> > > +
> >> > > +=C2=A0 =C2=A0 case SBTSI_REG_TEMP_HIGH_INT:
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 data =3D get_temp_int(= s->limit_high);
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 break;
> >> > > +
> >> > > +=C2=A0 =C2=A0 case SBTSI_REG_TEMP_LOW_INT:
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 data =3D get_temp_int(= s->limit_low);
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 break;
> >> > > +
> >> > > +=C2=A0 =C2=A0 case SBTSI_REG_TEMP_HIGH_DEC:
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 data =3D get_temp_dec(= s->limit_high);
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 break;
> >> > > +
> >> > > +=C2=A0 =C2=A0 case SBTSI_REG_TEMP_LOW_DEC:
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 data =3D get_temp_dec(= s->limit_low);
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 break;
> >> > > +
> >> > > +=C2=A0 =C2=A0 case SBTSI_REG_CONFIG:
> >> > > +=C2=A0 =C2=A0 case SBTSI_REG_CONFIG_WR:
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 data =3D s->config;=
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 break;
> >> > > +
> >> > > +=C2=A0 =C2=A0 case SBTSI_REG_STATUS:
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 sbtsi_update_alarm(s);=
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 data =3D s->status;=
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 break;
> >> > > +
> >> > > +=C2=A0 =C2=A0 case SBTSI_REG_ALERT_CONFIG:
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 data =3D s->alert_c= onfig;
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 break;
> >> > > +
> >> > > +=C2=A0 =C2=A0 case SBTSI_REG_MAN:
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 data =3D SBTSI_MAN_DEF= AULT;
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 break;
> >> > > +
> >> > > +=C2=A0 =C2=A0 case SBTSI_REG_REV:
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 data =3D SBTSI_REV_DEF= AULT;
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 break;
> >>
> >> Does this device do some sort of auto-increment on the addres= s when
> >> reading/writing?
> >>
> >
> > +Hao Wu <wuhaotsh@google.com>=C2=A0 =C2=A0- Please take a look at the abo= ve
> > question.=C2=A0 I imagine it's a while since you've thoug= ht about it, but please
> > double check :)
> > Thanks!
> >
> >
> >> Other than that possible issue, I don't see anything else= , it's pretty
> >> straightforward.
> >>
> >> > > +
> >> > > +=C2=A0 =C2=A0 default:
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 qemu_log_mask(LOG_GUES= T_ERROR,
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 "%s: reading from invalid reg: 0x%02x\n",
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 __func__, s->addr);
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 break;
> >> > > +=C2=A0 =C2=A0 }
> >> > > +
> >> > > +=C2=A0 =C2=A0 trace_tmp_sbtsi_read_data(s->addr= , data);
> >> > > +=C2=A0 =C2=A0 return data;
> >> > > +}
> >> > > +
> >> > > +static void sbtsi_write(SBTSIState *s, uint8_t dat= a)
> >> > > +{
> >> > > +=C2=A0 =C2=A0 trace_tmp_sbtsi_write_data(s->add= r, data);
> >> > > +=C2=A0 =C2=A0 switch (s->addr) {
> >> > > +=C2=A0 =C2=A0 case SBTSI_REG_CONFIG_WR:
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 s->config =3D data;=
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 break;
> >> > > +
> >> > > +=C2=A0 =C2=A0 case SBTSI_REG_TEMP_HIGH_INT:
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 s->limit_high =3D c= ompute_temp_int(s->limit_high, data);
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 break;
> >> > > +
> >> > > +=C2=A0 =C2=A0 case SBTSI_REG_TEMP_LOW_INT:
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 s->limit_low =3D co= mpute_temp_int(s->limit_low, data);
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 break;
> >> > > +
> >> > > +=C2=A0 =C2=A0 case SBTSI_REG_TEMP_HIGH_DEC:
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 s->limit_high =3D c= ompute_temp_dec(s->limit_high, data);
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 break;
> >> > > +
> >> > > +=C2=A0 =C2=A0 case SBTSI_REG_TEMP_LOW_DEC:
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 s->limit_low =3D co= mpute_temp_dec(s->limit_low, data);
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 break;
> >> > > +
> >> > > +=C2=A0 =C2=A0 case SBTSI_REG_ALERT_CONFIG:
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 s->alert_config =3D= data;
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 break;
> >> > > +
> >> > > +=C2=A0 =C2=A0 case SBTSI_REG_TEMP_INT:
> >> > > +=C2=A0 =C2=A0 case SBTSI_REG_TEMP_DEC:
> >> > > +=C2=A0 =C2=A0 case SBTSI_REG_CONFIG:
> >> > > +=C2=A0 =C2=A0 case SBTSI_REG_STATUS:
> >> > > +=C2=A0 =C2=A0 case SBTSI_REG_MAN:
> >> > > +=C2=A0 =C2=A0 case SBTSI_REG_REV:
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 qemu_log_mask(LOG_GUES= T_ERROR,
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 "%s: writing to read only reg: 0x%02x data:
> >> 0x%02x\n",
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 __func__, s->addr, data);
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 break;
> >> > > +
> >> > > +=C2=A0 =C2=A0 default:
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 qemu_log_mask(LOG_GUES= T_ERROR,
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 "%s: writing to invalid reg: 0x%02x data: 0x%02x\n",
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 __func__, s->addr, data);
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 break;
> >> > > +=C2=A0 =C2=A0 }
> >> > > +=C2=A0 =C2=A0 sbtsi_update_alarm(s);
> >> > > +}
> >> > > +
> >> > > +static int sbtsi_write_data(SMBusDevice *d, uint8_= t *buf, uint8_t
> >> len)
> >> > > +{
> >> > > +=C2=A0 =C2=A0 SBTSIState *s =3D SBTSI(d);
> >> > > +
> >> > > +=C2=A0 =C2=A0 if (len =3D=3D 0) {
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 qemu_log_mask(LOG_GUES= T_ERROR, "%s: writing empty data\n",
> >> > > __func__);
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 return -1;
> >> > > +=C2=A0 =C2=A0 }
> >> > > +
> >> > > +=C2=A0 =C2=A0 s->addr =3D buf[0];
> >> > > +=C2=A0 =C2=A0 if (len > 1) {
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 sbtsi_write(s, buf[1])= ;
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (len > 2) {
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 qemu_log= _mask(LOG_GUEST_ERROR, "%s: extra data at end\n",
> >> > > __func__);
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
> >> > > +=C2=A0 =C2=A0 }
> >> > > +=C2=A0 =C2=A0 return 0;
> >> > > +}
> >> > > +
> >> > > +/* Units are millidegrees. */
> >> > > +static void sbtsi_get_temperature(Object *obj, Vis= itor *v, const char
> >> > > *name,
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 void = *opaque, Error **errp)
> >> > > +{
> >> > > +=C2=A0 =C2=A0 SBTSIState *s =3D SBTSI(obj);
> >> > > +=C2=A0 =C2=A0 uint32_t temp =3D s->temperature = * SBTSI_TEMP_UNIT_IN_MILLIDEGREE;
> >> > > +
> >> > > +=C2=A0 =C2=A0 visit_type_uint32(v, name, &temp= , errp);
> >> > > +}
> >> > > +
> >> > > +/* Units are millidegrees. */
> >> > > +static void sbtsi_set_temperature(Object *obj, Vis= itor *v, const char
> >> > > *name,
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 void = *opaque, Error **errp)
> >> > > +{
> >> > > +=C2=A0 =C2=A0 SBTSIState *s =3D SBTSI(obj);
> >> > > +=C2=A0 =C2=A0 uint32_t temp;
> >> > > +
> >> > > +=C2=A0 =C2=A0 if (!visit_type_uint32(v, name, &= ;temp, errp)) {
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 return;
> >> > > +=C2=A0 =C2=A0 }
> >> > > +=C2=A0 =C2=A0 if (temp > SBTSI_TEMP_MAX) {
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 error_setg(errp, "= ;value %" PRIu32 ".%03" PRIu32 " C is out of
> >> > > range",
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0temp / 1000, temp % 1000);
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 return;
> >> > > +=C2=A0 =C2=A0 }
> >> > > +
> >> > > +=C2=A0 =C2=A0 s->temperature =3D temp / SBTSI_T= EMP_UNIT_IN_MILLIDEGREE;
> >> > > +=C2=A0 =C2=A0 sbtsi_update_alarm(s);
> >> > > +}
> >> > > +
> >> > > +static int sbtsi_post_load(void *opaque, int versi= on_id)
> >> > > +{
> >> > > +=C2=A0 =C2=A0 SBTSIState *s =3D opaque;
> >> > > +
> >> > > +=C2=A0 =C2=A0 sbtsi_update_alarm(s);
> >> > > +=C2=A0 =C2=A0 return 0;
> >> > > +}
> >> > > +
> >> > > +static const VMStateDescription vmstate_sbtsi =3D = {
> >> > > +=C2=A0 =C2=A0 .name =3D "SBTSI",
> >> > > +=C2=A0 =C2=A0 .version_id =3D 0,
> >> > > +=C2=A0 =C2=A0 .minimum_version_id =3D 0,
> >> > > +=C2=A0 =C2=A0 .post_load =3D sbtsi_post_load,
> >> > > +=C2=A0 =C2=A0 .fields =3D (VMStateField[]) {
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 VMSTATE_UINT32(tempera= ture, SBTSIState),
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 VMSTATE_UINT32(limit_l= ow, SBTSIState),
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 VMSTATE_UINT32(limit_h= igh, SBTSIState),
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 VMSTATE_UINT8(config, = SBTSIState),
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 VMSTATE_UINT8(status, = SBTSIState),
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 VMSTATE_UINT8(addr, SB= TSIState),
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 VMSTATE_END_OF_LIST()<= br> > >> > > +=C2=A0 =C2=A0 }
> >> > > +};
> >> > > +
> >> > > +static void sbtsi_enter_reset(Object *obj, ResetTy= pe type)
> >> > > +{
> >> > > +=C2=A0 =C2=A0 SBTSIState *s =3D SBTSI(obj);
> >> > > +
> >> > > +=C2=A0 =C2=A0 s->config =3D 0;
> >> > > +=C2=A0 =C2=A0 s->limit_low =3D SBTSI_LIMIT_LOW_= DEFAULT;
> >> > > +=C2=A0 =C2=A0 s->limit_high =3D SBTSI_LIMIT_HIG= H_DEFAULT;
> >> > > +}
> >> > > +
> >> > > +static void sbtsi_hold_reset(Object *obj)
> >> > > +{
> >> > > +=C2=A0 =C2=A0 SBTSIState *s =3D SBTSI(obj);
> >> > > +
> >> > > +=C2=A0 =C2=A0 qemu_irq_lower(s->alarm);
> >> > > +}
> >> > > +
> >> > > +static void sbtsi_init(Object *obj)
> >> > > +{
> >> > > +=C2=A0 =C2=A0 SBTSIState *s =3D SBTSI(obj);
> >> > > +
> >> > > +=C2=A0 =C2=A0 /* Current temperature in millidegre= es. */
> >> > > +=C2=A0 =C2=A0 object_property_add(obj, "tempe= rature", "uint32",
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 sbtsi_get_temperature, sbtsi_set_tempera= ture,
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 NULL, NULL);
> >> > > +=C2=A0 =C2=A0 qdev_init_gpio_out_named(DEVICE(obj)= , &s->alarm, SBTSI_ALARM_L,
> >> 0);
> >> > > +}
> >> > > +
> >> > > +static void sbtsi_class_init(ObjectClass *klass, v= oid *data)
> >> > > +{
> >> > > +=C2=A0 =C2=A0 ResettableClass *rc =3D RESETTABLE_C= LASS(klass);
> >> > > +=C2=A0 =C2=A0 DeviceClass *dc =3D DEVICE_CLASS(kla= ss);
> >> > > +=C2=A0 =C2=A0 SMBusDeviceClass *k =3D SMBUS_DEVICE= _CLASS(klass);
> >> > > +
> >> > > +=C2=A0 =C2=A0 dc->desc =3D "SB-TSI Tempera= ture Sensor";
> >> > > +=C2=A0 =C2=A0 dc->vmsd =3D &vmstate_sbtsi;<= br> > >> > > +=C2=A0 =C2=A0 k->write_data =3D sbtsi_write_dat= a;
> >> > > +=C2=A0 =C2=A0 k->receive_byte =3D sbtsi_read_by= te;
> >> > > +=C2=A0 =C2=A0 rc->phases.enter =3D sbtsi_enter_= reset;
> >> > > +=C2=A0 =C2=A0 rc->phases.hold =3D sbtsi_hold_re= set;
> >> > > +}
> >> > > +
> >> > > +static const TypeInfo sbtsi_info =3D {
> >> > > +=C2=A0 =C2=A0 .name=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =3D TYPE_SBTSI,
> >> > > +=C2=A0 =C2=A0 .parent=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =3D TYPE_SMBUS_DEVICE,
> >> > > +=C2=A0 =C2=A0 .instance_size =3D sizeof(SBTSIState= ),
> >> > > +=C2=A0 =C2=A0 .instance_init =3D sbtsi_init,
> >> > > +=C2=A0 =C2=A0 .class_init=C2=A0 =C2=A0 =3D sbtsi_c= lass_init,
> >> > > +};
> >> > > +
> >> > > +static void sbtsi_register_types(void)
> >> > > +{
> >> > > +=C2=A0 =C2=A0 type_register_static(&sbtsi_info= );
> >> > > +}
> >> > > +
> >> > > +type_init(sbtsi_register_types)
> >> > > diff --git a/hw/sensor/trace-events b/hw/sensor/tra= ce-events
> >> > > new file mode 100644
> >> > > index 0000000000..21ab3809e2
> >> > > --- /dev/null
> >> > > +++ b/hw/sensor/trace-events
> >> > > @@ -0,0 +1,5 @@
> >> > > +# See docs/devel/tracing.rst for syntax documentat= ion.
> >> > > +
> >> > > +# 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) &= quot;SBTSI read
> >> addr:0x%02x
> >> > > data: 0x%02x"
> >> > > diff --git a/hw/sensor/trace.h b/hw/sensor/trace.h<= br> > >> > > new file mode 100644
> >> > > index 0000000000..e4721560b0
> >> > > --- /dev/null
> >> > > +++ b/hw/sensor/trace.h
> >> > > @@ -0,0 +1 @@
> >> > > +#include "trace/trace-hw_sensor.h"
> >> > > diff --git a/meson.build b/meson.build
> >> > > index 53065e96ec..f8ab0bf74e 100644
> >> > > --- a/meson.build
> >> > > +++ b/meson.build
> >> > > @@ -2494,6 +2494,7 @@ if have_system
> >> > >=C2=A0 =C2=A0 =C2=A0 'hw/rtc',
> >> > >=C2=A0 =C2=A0 =C2=A0 'hw/s390x',
> >> > >=C2=A0 =C2=A0 =C2=A0 'hw/scsi',
> >> > > +=C2=A0 =C2=A0 'hw/sensor',
> >> > >=C2=A0 =C2=A0 =C2=A0 'hw/sd',
> >> > >=C2=A0 =C2=A0 =C2=A0 'hw/sh4',
> >> > >=C2=A0 =C2=A0 =C2=A0 'hw/sparc',
> >> > > diff --git a/tests/qtest/meson.build b/tests/qtest/= meson.build
> >> > > index 37e1eaa449..d1a8c38f74 100644
> >> > > --- a/tests/qtest/meson.build
> >> > > +++ b/tests/qtest/meson.build
> >> > > @@ -254,6 +254,7 @@ qos_test_ss.add(
> >> > >=C2=A0 =C2=A0 'spapr-phb-test.c',
> >> > >=C2=A0 =C2=A0 'tmp105-test.c',
> >> > >=C2=A0 =C2=A0 'emc141x-test.c',
> >> > > +=C2=A0 'tmp_sbtsi-test.c',
> >> > >=C2=A0 =C2=A0 'usb-hcd-ohci-test.c',
> >> > >=C2=A0 =C2=A0 'virtio-test.c',
> >> > >=C2=A0 =C2=A0 'virtio-blk-test.c',
> >> > > diff --git a/tests/qtest/tmp_sbtsi-test.c
> >> b/tests/qtest/tmp_sbtsi-test.c
> >> > > new file mode 100644
> >> > > index 0000000000..7f5fafacc7
> >> > > --- /dev/null
> >> > > +++ b/tests/qtest/tmp_sbtsi-test.c
> >> > > @@ -0,0 +1,180 @@
> >> > > +/*
> >> > > + * QTests for the SBTSI temperature sensor
> >> > > + *
> >> > > + * Copyright 2020 Google LLC
> >> > > + *
> >> > > + * This program is free software; you can redistri= bute it and/or
> >> modify it
> >> > > + * under the terms of the GNU General Public Licen= se as published by
> >> the
> >> > > + * Free Software Foundation; either version 2 of t= he 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
> >> > > + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU G= eneral Public
> >> License
> >> > > + * for more details.
> >> > > + */
> >> > > +
> >> > > +#include "qemu/osdep.h"
> >> > > +
> >> > > +#include "libqtest-single.h"
> >> > > +#include "libqos/qgraph.h"
> >> > > +#include "libqos/i2c.h"
> >> > > +#include "qapi/qmp/qdict.h"
> >> > > +#include "qemu/bitops.h"
> >> > > +
> >> > > +#define TEST_ID=C2=A0 =C2=A0"sbtsi-test"=
> >> > > +#define TEST_ADDR (0x4c)
> >> > > +
> >> > > +/*
> >> > > + * SB-TSI registers only support SMBus byte data a= ccess. "_INT"
> >> registers
> >> > > are
> >> > > + * the integer part of a temperature value or limi= t, and "_DEC"
> >> registers
> >> > > are
> >> > > + * corresponding decimal parts.
> >> > > + */
> >> > > +#define REG_TEMP_INT=C2=A0 =C2=A0 =C2=A0 0x01 /* R= O */
> >> > > +#define REG_STATUS=C2=A0 =C2=A0 =C2=A0 =C2=A0 0x02= /* RO */
> >> > > +#define REG_CONFIG=C2=A0 =C2=A0 =C2=A0 =C2=A0 0x03= /* RO */
> >> > > +#define REG_TEMP_HIGH_INT 0x07 /* RW */
> >> > > +#define REG_TEMP_LOW_INT=C2=A0 0x08 /* RW */
> >> > > +#define REG_CONFIG_WR=C2=A0 =C2=A0 =C2=A00x09 /* R= W */
> >> > > +#define REG_TEMP_DEC=C2=A0 =C2=A0 =C2=A0 0x10 /* R= O */
> >> > > +#define REG_TEMP_HIGH_DEC 0x13 /* RW */
> >> > > +#define REG_TEMP_LOW_DEC=C2=A0 0x14 /* RW */
> >> > > +#define REG_ALERT_CONFIG=C2=A0 0xBF /* RW */
> >> > > +
> >> > > +#define STATUS_HIGH_ALERT BIT(4)
> >> > > +#define STATUS_LOW_ALERT=C2=A0 BIT(3)
> >> > > +#define CONFIG_ALERT_MASK BIT(7)
> >> > > +#define ALARM_EN=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= BIT(0)
> >> > > +
> >> > > +/* The temperature stored are in units of 0.125 de= grees. */
> >> > > +#define TEMP_UNIT_IN_MILLIDEGREE 125
> >> > > +#define LIMIT_LOW (10500)
> >> > > +#define LIMIT_HIGH (55125)
> >> > > +
> >> > > +static uint32_t qmp_sbtsi_get_temperature(const ch= ar *id)
> >> > > +{
> >> > > +=C2=A0 =C2=A0 QDict *response;
> >> > > +=C2=A0 =C2=A0 int ret;
> >> > > +
> >> > > +=C2=A0 =C2=A0 response =3D qmp("{ 'execut= e': 'qom-get', 'arguments': { 'path':
> >> %s, "
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0"'property': 'temperature' } }&quo= t;, id);
> >> > > +=C2=A0 =C2=A0 g_assert(qdict_haskey(response, &quo= t;return"));
> >> > > +=C2=A0 =C2=A0 ret =3D (uint32_t)qdict_get_int(resp= onse, "return");
> >> > > +=C2=A0 =C2=A0 qobject_unref(response);
> >> > > +=C2=A0 =C2=A0 return ret;
> >> > > +}
> >> > > +
> >> > > +static void qmp_sbtsi_set_temperature(const char *= id, uint32_t value)
> >> > > +{
> >> > > +=C2=A0 =C2=A0 QDict *response;
> >> > > +
> >> > > +=C2=A0 =C2=A0 response =3D qmp("{ 'execut= e': 'qom-set', 'arguments': { 'path':
> >> %s, "
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0"'property': 'temperature', 'v= alue': %d } }", id,
> >> > > value);
> >> > > +=C2=A0 =C2=A0 g_assert(qdict_haskey(response, &quo= t;return"));
> >> > > +=C2=A0 =C2=A0 qobject_unref(response);
> >> > > +}
> >> > > +
> >> > > +/*
> >> > > + * Compute the temperature using the integer and d= ecimal part and
> >> return
> >> > > + * millidegrees. The decimal part are only the top= 3 bits so we
> >> shift it
> >> > > by
> >> > > + * 5 here.
> >> > > + */
> >> > > +static uint32_t regs_to_temp(uint8_t integer, uint= 8_t decimal)
> >> > > +{
> >> > > +=C2=A0 =C2=A0 return ((integer << 3) + (deci= mal >> 5)) *
> >> TEMP_UNIT_IN_MILLIDEGREE;
> >> > > +}
> >> > > +
> >> > > +/*
> >> > > + * Compute the integer and decimal parts of the te= mperature in
> >> > > millidegrees.
> >> > > + * H/W store the decimal in the top 3 bits so we s= hift it by 5.
> >> > > + */
> >> > > +static void temp_to_regs(uint32_t temp, uint8_t *i= nteger, uint8_t
> >> > > *decimal)
> >> > > +{
> >> > > +=C2=A0 =C2=A0 temp /=3D TEMP_UNIT_IN_MILLIDEGREE;<= br> > >> > > +=C2=A0 =C2=A0 *integer =3D temp >> 3;
> >> > > +=C2=A0 =C2=A0 *decimal =3D (temp & 0x7) <&l= t; 5;
> >> > > +}
> >> > > +
> >> > > +static void tx_rx(void *obj, void *data, QGuestAll= ocator *alloc)
> >> > > +{
> >> > > +=C2=A0 =C2=A0 uint16_t value;
> >> > > +=C2=A0 =C2=A0 uint8_t integer, decimal;
> >> > > +=C2=A0 =C2=A0 QI2CDevice *i2cdev =3D (QI2CDevice *= )obj;
> >> > > +
> >> > > +=C2=A0 =C2=A0 /* Test default values */
> >> > > +=C2=A0 =C2=A0 value =3D qmp_sbtsi_get_temperature(= TEST_ID);
> >> > > +=C2=A0 =C2=A0 g_assert_cmpuint(value, =3D=3D, 0);<= br> > >> > > +
> >> > > +=C2=A0 =C2=A0 integer =3D i2c_get8(i2cdev, REG_TEM= P_INT);
> >> > > +=C2=A0 =C2=A0 decimal =3D i2c_get8(i2cdev, REG_TEM= P_DEC);
> >> > > +=C2=A0 =C2=A0 g_assert_cmpuint(regs_to_temp(intege= r, decimal), =3D=3D, 0);
> >> > > +
> >> > > +=C2=A0 =C2=A0 /* Test setting temperature */
> >> > > +=C2=A0 =C2=A0 qmp_sbtsi_set_temperature(TEST_ID, 2= 0000);
> >> > > +=C2=A0 =C2=A0 value =3D qmp_sbtsi_get_temperature(= TEST_ID);
> >> > > +=C2=A0 =C2=A0 g_assert_cmpuint(value, =3D=3D, 2000= 0);
> >> > > +
> >> > > +=C2=A0 =C2=A0 integer =3D i2c_get8(i2cdev, REG_TEM= P_INT);
> >> > > +=C2=A0 =C2=A0 decimal =3D i2c_get8(i2cdev, REG_TEM= P_DEC);
> >> > > +=C2=A0 =C2=A0 g_assert_cmpuint(regs_to_temp(intege= r, decimal), =3D=3D, 20000);
> >> > > +
> >> > > +=C2=A0 =C2=A0 /* Set alert mask in config */
> >> > > +=C2=A0 =C2=A0 i2c_set8(i2cdev, REG_CONFIG_WR, CONF= IG_ALERT_MASK);
> >> > > +=C2=A0 =C2=A0 value =3D i2c_get8(i2cdev, REG_CONFI= G);
> >> > > +=C2=A0 =C2=A0 g_assert_cmphex(value, =3D=3D, CONFI= G_ALERT_MASK);
> >> > > +=C2=A0 =C2=A0 /* Enable alarm_en */
> >> > > +=C2=A0 =C2=A0 i2c_set8(i2cdev, REG_ALERT_CONFIG, A= LARM_EN);
> >> > > +=C2=A0 =C2=A0 value =3D i2c_get8(i2cdev, REG_ALERT= _CONFIG);
> >> > > +=C2=A0 =C2=A0 g_assert_cmphex(value, =3D=3D, ALARM= _EN);
> >> > > +
> >> > > +=C2=A0 =C2=A0 /* Test setting limits */
> >> > > +=C2=A0 =C2=A0 /* Limit low =3D 10.500 */
> >> > > +=C2=A0 =C2=A0 temp_to_regs(LIMIT_LOW, &integer= , &decimal);
> >> > > +=C2=A0 =C2=A0 i2c_set8(i2cdev, REG_TEMP_LOW_INT, i= nteger);
> >> > > +=C2=A0 =C2=A0 i2c_set8(i2cdev, REG_TEMP_LOW_DEC, d= ecimal);
> >> > > +=C2=A0 =C2=A0 integer =3D i2c_get8(i2cdev, REG_TEM= P_LOW_INT);
> >> > > +=C2=A0 =C2=A0 decimal =3D i2c_get8(i2cdev, REG_TEM= P_LOW_DEC);
> >> > > +=C2=A0 =C2=A0 g_assert_cmpuint(regs_to_temp(intege= r, decimal), =3D=3D, LIMIT_LOW);
> >> > > +=C2=A0 =C2=A0 /* Limit high =3D 55.125 */
> >> > > +=C2=A0 =C2=A0 temp_to_regs(LIMIT_HIGH, &intege= r, &decimal);
> >> > > +=C2=A0 =C2=A0 i2c_set8(i2cdev, REG_TEMP_HIGH_INT, = integer);
> >> > > +=C2=A0 =C2=A0 i2c_set8(i2cdev, REG_TEMP_HIGH_DEC, = decimal);
> >> > > +=C2=A0 =C2=A0 integer =3D i2c_get8(i2cdev, REG_TEM= P_HIGH_INT);
> >> > > +=C2=A0 =C2=A0 decimal =3D i2c_get8(i2cdev, REG_TEM= P_HIGH_DEC);
> >> > > +=C2=A0 =C2=A0 g_assert_cmpuint(regs_to_temp(intege= r, decimal), =3D=3D, LIMIT_HIGH);
> >> > > +=C2=A0 =C2=A0 /* No alert is generated. */
> >> > > +=C2=A0 =C2=A0 value =3D i2c_get8(i2cdev, REG_STATU= S);
> >> > > +=C2=A0 =C2=A0 g_assert_cmphex(value, =3D=3D, 0); > >> > > +
> >> > > +=C2=A0 =C2=A0 /* Test alert for low temperature */=
> >> > > +=C2=A0 =C2=A0 qmp_sbtsi_set_temperature(TEST_ID, L= IMIT_LOW);
> >> > > +=C2=A0 =C2=A0 value =3D i2c_get8(i2cdev, REG_STATU= S);
> >> > > +=C2=A0 =C2=A0 g_assert_cmphex(value, =3D=3D, STATU= S_LOW_ALERT);
> >> > > +
> >> > > +=C2=A0 =C2=A0 /* Test alert for high temperature *= /
> >> > > +=C2=A0 =C2=A0 qmp_sbtsi_set_temperature(TEST_ID, L= IMIT_HIGH);
> >> > > +=C2=A0 =C2=A0 value =3D i2c_get8(i2cdev, REG_STATU= S);
> >> > > +=C2=A0 =C2=A0 g_assert_cmphex(value, =3D=3D, STATU= S_HIGH_ALERT);
> >> > > +
> >> > > +=C2=A0 =C2=A0 /* Disable alarm_en */
> >> > > +=C2=A0 =C2=A0 i2c_set8(i2cdev, REG_ALERT_CONFIG, 0= );
> >> > > +=C2=A0 =C2=A0 value =3D i2c_get8(i2cdev, REG_ALERT= _CONFIG);
> >> > > +=C2=A0 =C2=A0 g_assert_cmphex(value, =3D=3D, 0); > >> > > +=C2=A0 =C2=A0 /* No alert when alarm_en is false. = */
> >> > > +=C2=A0 =C2=A0 value =3D i2c_get8(i2cdev, REG_STATU= S);
> >> > > +=C2=A0 =C2=A0 g_assert_cmphex(value, =3D=3D, 0); > >> > > +}
> >> > > +
> >> > > +static void sbtsi_register_nodes(void)
> >> > > +{
> >> > > +=C2=A0 =C2=A0 QOSGraphEdgeOptions opts =3D {
> >> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 .extra_device_opts =3D= "id=3D" TEST_ID ",address=3D0x4c"
> >> > > +=C2=A0 =C2=A0 };
> >> > > +=C2=A0 =C2=A0 add_qi2c_address(&opts, &(QI= 2CAddress) { TEST_ADDR });
> >> > > +
> >> > > +=C2=A0 =C2=A0 qos_node_create_driver("sbtsi&q= uot;, i2c_device_create);
> >> > > +=C2=A0 =C2=A0 qos_node_consumes("sbtsi",= "i2c-bus", &opts);
> >> > > +
> >> > > +=C2=A0 =C2=A0 qos_add_test("tx-rx", &quo= t;sbtsi", tx_rx, NULL);
> >> > > +}
> >> > > +libqos_init(sbtsi_register_nodes);
> >> > > --
> >> >
> >> >
> >> > + Corey for i2c maintainer.=C2=A0 The new sensor directo= ry is mostly if not
> >> > entirely i2c devices.=C2=A0 I didn't create a mainta= iner entry for this i2c
> >> > device, but I can if desired and send out a v2.
> >>
> >> Yeah, I guess I should be maintainer there.=C2=A0 I'll qu= eue up a change for
> >> that.=C2=A0 Thanks.
> >>
> >> -corey
> >>
> >> >
> >> >
> >> > > 2.34.1.575.g55b058a8bb-goog
> >> > >
> >> > >
> >>
> >
--00000000000019555805d6945e84--