Re: [PATCH v4 1/2] hw/sensor: Add SB-TSI Temperature Sensor Interface

2023-02-07 Thread Cédric Le Goater

[ Cc: Titus, since he is maintainer of some sensor models already ]

On 2/7/23 07:51, Philippe Mathieu-Daudé wrote:

On 7/2/23 00:24, Hao Wu wrote:

Hi,

It seems like this patch set is reviewed but never merged. Who should take this 
patch set? What are our next steps for them?


Having some interest in interaction with emulated analog world,
I could have an overall look at hw/sensor/. Co-maintainers welcomed!


On Mon, Jan 31, 2022 at 2:29 PM Patrick Venture mailto:vent...@google.com>> wrote:

    From: Hao Wu mailto:wuhao...@google.com>>

    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 mailto:wuhao...@google.com>>
    Signed-off-by: Patrick Venture mailto:vent...@google.com>>
    Reviewed-by: Doug Evans mailto:d...@google.com>>
    Reviewed-by: Philippe Mathieu-Daudé mailto:f4...@amsat.org>>
    Acked-by: Corey Minyard mailto:cminy...@mvista.com>>
    ---
  meson.build               |   1 +
  hw/sensor/trace.h         |   1 +
  include/hw/sensor/sbtsi.h |  45 +
  hw/sensor/tmp_sbtsi.c     | 369 ++
  hw/sensor/Kconfig         |   4 +
  hw/sensor/meson.build     |   1 +
  hw/sensor/trace-events    |   5 +
  7 files changed, 426 insertions(+)
  create mode 100644 hw/sensor/trace.h
  create mode 100644 include/hw/sensor/sbtsi.h
  create mode 100644 hw/sensor/tmp_sbtsi.c
  create mode 100644 hw/sensor/trace-events







Re: [PATCH v4 1/2] hw/sensor: Add SB-TSI Temperature Sensor Interface

2023-02-06 Thread Philippe Mathieu-Daudé

On 7/2/23 00:24, Hao Wu wrote:

Hi,

It seems like this patch set is reviewed but never merged. Who should 
take this patch set? What are our next steps for them?


Having some interest in interaction with emulated analog world,
I could have an overall look at hw/sensor/. Co-maintainers welcomed!

On Mon, Jan 31, 2022 at 2:29 PM Patrick Venture > wrote:


From: Hao Wu mailto:wuhao...@google.com>>

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 mailto:wuhao...@google.com>>
Signed-off-by: Patrick Venture mailto:vent...@google.com>>
Reviewed-by: Doug Evans mailto:d...@google.com>>
Reviewed-by: Philippe Mathieu-Daudé mailto:f4...@amsat.org>>
Acked-by: Corey Minyard mailto:cminy...@mvista.com>>
---
  meson.build               |   1 +
  hw/sensor/trace.h         |   1 +
  include/hw/sensor/sbtsi.h |  45 +
  hw/sensor/tmp_sbtsi.c     | 369 ++
  hw/sensor/Kconfig         |   4 +
  hw/sensor/meson.build     |   1 +
  hw/sensor/trace-events    |   5 +
  7 files changed, 426 insertions(+)
  create mode 100644 hw/sensor/trace.h
  create mode 100644 include/hw/sensor/sbtsi.h
  create mode 100644 hw/sensor/tmp_sbtsi.c
  create mode 100644 hw/sensor/trace-events





Re: [PATCH v4 1/2] hw/sensor: Add SB-TSI Temperature Sensor Interface

2023-02-06 Thread Hao Wu
Hi,

It seems like this patch set is reviewed but never merged. Who should take
this patch set? What are our next steps for them?

Thanks!

On Mon, Jan 31, 2022 at 2:29 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 
> Signed-off-by: Patrick Venture 
> Reviewed-by: Doug Evans 
> Reviewed-by: Philippe Mathieu-Daudé 
> Acked-by: Corey Minyard 
> ---
>  meson.build   |   1 +
>  hw/sensor/trace.h |   1 +
>  include/hw/sensor/sbtsi.h |  45 +
>  hw/sensor/tmp_sbtsi.c | 369 ++
>  hw/sensor/Kconfig |   4 +
>  hw/sensor/meson.build |   1 +
>  hw/sensor/trace-events|   5 +
>  7 files changed, 426 insertions(+)
>  create mode 100644 hw/sensor/trace.h
>  create mode 100644 include/hw/sensor/sbtsi.h
>  create mode 100644 hw/sensor/tmp_sbtsi.c
>  create mode 100644 hw/sensor/trace-events
>
> diff --git a/meson.build b/meson.build
> index c1b1db1e28..3634214546 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/hw/sensor/trace.h b/hw/sensor/trace.h
> new file mode 100644
> index 00..e4721560b0
> --- /dev/null
> +++ b/hw/sensor/trace.h
> @@ -0,0 +1 @@
> +#include "trace/trace-hw_sensor.h"
> diff --git a/include/hw/sensor/sbtsi.h b/include/hw/sensor/sbtsi.h
> new file mode 100644
> index 00..9073f76ebb
> --- /dev/null
> +++ b/include/hw/sensor/sbtsi.h
> @@ -0,0 +1,45 @@
> +/*
> + * 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.
> + */
> +#ifndef QEMU_TMP_SBTSI_H
> +#define QEMU_TMP_SBTSI_H
> +
> +/*
> + * 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_STATUS0x02 /* RO */
> +#define SBTSI_REG_CONFIG0x03 /* 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)
> +
> +/* The temperature we stored are in units of 0.125 degrees. */
> +#define SBTSI_TEMP_UNIT_IN_MILLIDEGREE 125
> +
> +#endif
> diff --git a/hw/sensor/tmp_sbtsi.c b/hw/sensor/tmp_sbtsi.c
> new file mode 100644
> index 00..d5406844ef
> --- /dev/null
> +++ b/hw/sensor/tmp_sbtsi.c
> @@ -0,0 +1,369 @@
> +/*
> + * 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/sensor/sbtsi.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 

[PATCH v4 1/2] hw/sensor: Add SB-TSI Temperature Sensor Interface

2022-01-31 Thread Patrick Venture
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 
Signed-off-by: Patrick Venture 
Reviewed-by: Doug Evans 
Reviewed-by: Philippe Mathieu-Daudé 
Acked-by: Corey Minyard 
---
 meson.build   |   1 +
 hw/sensor/trace.h |   1 +
 include/hw/sensor/sbtsi.h |  45 +
 hw/sensor/tmp_sbtsi.c | 369 ++
 hw/sensor/Kconfig |   4 +
 hw/sensor/meson.build |   1 +
 hw/sensor/trace-events|   5 +
 7 files changed, 426 insertions(+)
 create mode 100644 hw/sensor/trace.h
 create mode 100644 include/hw/sensor/sbtsi.h
 create mode 100644 hw/sensor/tmp_sbtsi.c
 create mode 100644 hw/sensor/trace-events

diff --git a/meson.build b/meson.build
index c1b1db1e28..3634214546 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/hw/sensor/trace.h b/hw/sensor/trace.h
new file mode 100644
index 00..e4721560b0
--- /dev/null
+++ b/hw/sensor/trace.h
@@ -0,0 +1 @@
+#include "trace/trace-hw_sensor.h"
diff --git a/include/hw/sensor/sbtsi.h b/include/hw/sensor/sbtsi.h
new file mode 100644
index 00..9073f76ebb
--- /dev/null
+++ b/include/hw/sensor/sbtsi.h
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+#ifndef QEMU_TMP_SBTSI_H
+#define QEMU_TMP_SBTSI_H
+
+/*
+ * 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_STATUS0x02 /* RO */
+#define SBTSI_REG_CONFIG0x03 /* 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)
+
+/* The temperature we stored are in units of 0.125 degrees. */
+#define SBTSI_TEMP_UNIT_IN_MILLIDEGREE 125
+
+#endif
diff --git a/hw/sensor/tmp_sbtsi.c b/hw/sensor/tmp_sbtsi.c
new file mode 100644
index 00..d5406844ef
--- /dev/null
+++ b/hw/sensor/tmp_sbtsi.c
@@ -0,0 +1,369 @@
+/*
+ * 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/sensor/sbtsi.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 "qom/object.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.
+ *