Skip to contentSkip to conversation

misc: amd-sbi: Refactor SBTSI driver with I3C support and ioctl interface

PATCH Superseded Akshay Gupta 3 participants 17 messages Mar 23 – Mar 31

Subsystems (3)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover misc: amd-sbi: Refactor SBTSI driver with I3C support and ioctl interface

This series refactors the AMD SB-TSI (Side-Band Temperature Sensor Interface) driver by moving it from the hwmon subsystem into the drivers/misc/amd-sbi framework, alongside the existing SB-RMI driver.

Background:
The SB-TSI driver currently lives under drivers/hwmon/sbtsi_temp.c and is limited to exposing temperature readings via the hwmon interface. As AMD platforms evolve, SB-TSI access is required from multiple consumers (hwmon, userspace via ioctl, I3C-attached devices), making the hwmon-only placement insufficient.

This series restructures the driver into a layered design:

- tsi-core.c : core register access and ioctl/miscdevice support
- tsi-hwmon.c : hwmon sensor layer built on top of the core
- tsi.c : I2C/I3C probe and glue

Changes in this series:
1. Move core SBTSI driver from drivers/hwmon into drivers/misc/amd-sbi, renaming sbtsi_temp.c -> sbtsi.c and wiring it into the amd-sbi Kconfig/Makefile. The hwmon probe entry point is preserved so existing device-tree bindings and hwmon consumers are unaffected.

2. Update the Kconfig entry to explicitly state that the driver targets BMC-side I2C/I3C controllers (ARM/ARM64), avoiding accidental enablement on non-BMC targets.

3. Split the hwmon sensor handling (sysfs attributes, hwmon_chip_info) into tsi-hwmon.c so the core transport layer is not entangled with hwmon internals, making future interface additions cleaner.

4. Extend the driver to support SB-TSI over I3C in addition to I2C. Both buses share the same core read/write path via sbtsi_xfer(); the is_i3c flag selects the underlying transport at probe time. Backward compatibility with existing I2C deployments is maintained.

5. Add a miscdevice (/dev/sbtsi-<addr>) and an ioctl interface (SBTSI_IOCTL_REG_XFER_CMD) that allows root userspace to perform SB-TSI register read/write operations through the APML protocol, consistent with the existing SBRMI ioctl interface.

6. Document the new SBTSI miscdevice and its ioctl in Documentation/misc-devices/amd-sbi.rst.

Testing:
Tested on AMD Genoa/Turin/Venice BMC platforms with both I2C and I3C-attached SB-TSI targets. hwmon sysfs attributes (tempX_input, tempX_max, etc.) and ioctl register transfers verified against hardware.

Akshay Gupta (1):
misc: amd-sbi: Update SBTSI Kconfig to clarify this is BMC driver

Prathima (5):
hwmon/misc: amd-sbi: Move core SBTSI support from hwmon to misc
misc: amd-sbi: Split SBTSI hwmon sensor handling into a separate
entity
misc: amd-sbi: Add support for SB-TSI over I3C
misc: amd-sbi: Add SBTSI ioctl register transfer interface
docs: misc: amd-sbi: Document SBTSI userspace interface

 Documentation/misc-devices/amd-sbi.rst |  18 ++
 drivers/hwmon/Kconfig                  |  10 -
 drivers/hwmon/Makefile                 |   1 -
 drivers/hwmon/sbtsi_temp.c             | 250 -------------------------
 drivers/misc/amd-sbi/Kconfig           |  24 +++
 drivers/misc/amd-sbi/Makefile          |   4 +
 drivers/misc/amd-sbi/tsi-core.c        | 146 +++++++++++++++
 drivers/misc/amd-sbi/tsi-core.h        |  44 +++++
 drivers/misc/amd-sbi/tsi-hwmon.c       | 198 ++++++++++++++++++++
 drivers/misc/amd-sbi/tsi.c             | 162 ++++++++++++++++
 include/uapi/misc/amd-apml.h           |  23 +++
 11 files changed, 619 insertions(+), 261 deletions(-)
 delete mode 100644 drivers/hwmon/sbtsi_temp.c
 create mode 100644 drivers/misc/amd-sbi/tsi-core.c
 create mode 100644 drivers/misc/amd-sbi/tsi-core.h
 create mode 100644 drivers/misc/amd-sbi/tsi-hwmon.c
 create mode 100644 drivers/misc/amd-sbi/tsi.c
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/6 hwmon/misc: amd-sbi: Move core SBTSI support from hwmon to misc

From: Prathima <[email protected]>

Move SBTSI core functionality out of the hwmon-only path and into drivers/misc/amd-sbi so it can be reused by non-hwmon consumers.

This split prepares the driver for additional interfaces while keeping hwmon support as an optional layer on top of common SBTSI core logic.

---
 drivers/hwmon/Kconfig                                | 10 ----------
 drivers/hwmon/Makefile                               |  1 -
 drivers/misc/amd-sbi/Kconfig                         | 11 +++++++++++
 drivers/misc/amd-sbi/Makefile                        |  2 ++
 drivers/{hwmon/sbtsi_temp.c => misc/amd-sbi/sbtsi.c} |  2 +-
 5 files changed, 14 insertions(+), 12 deletions(-)
 rename drivers/{hwmon/sbtsi_temp.c => misc/amd-sbi/sbtsi.c} (98%)
drivers/hwmon/Kconfig +0 -10
index 328867242cb3..758f9c9f9e4f 100644
@@ -1936,16 +1936,6 @@ config SENSORS_SL28CPLD
 	  This driver can also be built as a module.  If so, the module
 	  will be called sl28cpld-hwmon.
 
-config SENSORS_SBTSI
-	tristate "Emulated SB-TSI temperature sensor"
-	depends on I2C
-	help
-	  If you say yes here you get support for emulated temperature
-	  sensors on AMD SoCs with SB-TSI interface connected to a BMC device.
-
-	  This driver can also be built as a module. If so, the module will
-	  be called sbtsi_temp.
-
 config SENSORS_SHT15
 	tristate "Sensiron humidity and temperature sensors. SHT15 and compat."
 	depends on GPIOLIB || COMPILE_TEST
drivers/hwmon/Makefile +0 -1
index 5833c807c688..c9b6661cfc72 100644
@@ -199,7 +199,6 @@ obj-$(CONFIG_SENSORS_PT5161L)	+= pt5161l.o
 obj-$(CONFIG_SENSORS_PWM_FAN)	+= pwm-fan.o
 obj-$(CONFIG_SENSORS_QNAP_MCU_HWMON)	+= qnap-mcu-hwmon.o
 obj-$(CONFIG_SENSORS_RASPBERRYPI_HWMON)	+= raspberrypi-hwmon.o
-obj-$(CONFIG_SENSORS_SBTSI)	+= sbtsi_temp.o
 obj-$(CONFIG_SENSORS_SBRMI)	+= sbrmi.o
 obj-$(CONFIG_SENSORS_SCH56XX_COMMON)+= sch56xx-common.o
 obj-$(CONFIG_SENSORS_SCH5627)	+= sch5627.o
drivers/misc/amd-sbi/Kconfig +11 -0
index 30e7fad7356c..e6a422b4a371 100644
@@ -20,3 +20,14 @@ config AMD_SBRMI_HWMON
 	  This provides support for RMI device hardware monitoring. If enabled,
 	  a hardware monitoring device will be created for each socket in
 	  the system.
+
+config SENSORS_SBTSI
+	tristate "Emulated SB-TSI temperature sensor"
+	depends on I2C
+	depends on HWMON
+	help
+	  If you say yes here you get support for emulated temperature
+	  sensors on AMD SoCs with SB-TSI interface connected to a BMC device.
+
+	  This driver can also be built as a module. If so, the module will
+	  be called sbtsi.
drivers/misc/amd-sbi/Makefile +2 -0
index 38eaaa651fd9..f04273c0d3ad 100644
@@ -2,3 +2,5 @@
 sbrmi-i2c-objs  		+= rmi-i2c.o rmi-core.o
 sbrmi-i2c-$(CONFIG_AMD_SBRMI_HWMON)	+= rmi-hwmon.o
 obj-$(CONFIG_AMD_SBRMI_I2C)	+= sbrmi-i2c.o
+# SBTSI Configuration
+obj-$(CONFIG_SENSORS_SBTSI)	+= sbtsi.o
drivers/misc/amd-sbi/sbtsi.c renamed from drivers/hwmon/sbtsi_temp.c +1 -1
similarity index 98%
rename from drivers/hwmon/sbtsi_temp.c
rename to drivers/misc/amd-sbi/sbtsi.c
index c5b2488c4c7f..e09b10c17771 100644
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 /*
- * sbtsi_temp.c - hwmon driver for a SBI Temperature Sensor Interface (SB-TSI)
+ * sbtsi.c - hwmon driver for a SBI Temperature Sensor Interface (SB-TSI)
  *                compliant AMD SoC temperature device.
  *
  * Copyright (c) 2020, Google Inc.
Signature · 1 line
2.34.1
maintainer
#2 lore raw

Re: [PATCH v1 1/6] hwmon/misc: amd-sbi: Move core SBTSI support from hwmon to misc

Quoted 8 lines · Akshay Gupta

From: Prathima <[email protected]>

Move SBTSI core functionality out of the hwmon-only path and into drivers/misc/amd-sbi so it can be reused by non-hwmon consumers.

This split prepares the driver for additional interfaces while keeping hwmon support as an optional layer on top of common SBTSI core logic.

This moves the driver out of hwmon space into misc/amd-sbi which, in my opinion, is completely unnecessary to accomplish the stated goals.

I assume this is to be able to make changes which do not follow the hwmon ABI and/or to bypass hwmon subsystem review, similar to what has been done by others.

Obviously, I think this is a bad idea. I won't give it a NACK, but I won't approve (nor review) it either.

Guenter

#3 lore raw

Re: [PATCH v1 1/6] hwmon/misc: amd-sbi: Move core SBTSI support from hwmon to misc

Quoted 15 lines · Guenter Roeck

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

Quoted 8 lines · Akshay Gupta

From: Prathima <[email protected]>

Move SBTSI core functionality out of the hwmon-only path and into drivers/misc/amd-sbi so it can be reused by non-hwmon consumers.

This split prepares the driver for additional interfaces while keeping hwmon support as an optional layer on top of common SBTSI core logic.

This moves the driver out of hwmon space into misc/amd-sbi which, in my opinion, is completely unnecessary to accomplish the stated goals.

Quoted 8 lines

I assume this is to be able to make changes which do not follow the hwmon ABI and/or to bypass hwmon subsystem review, similar to what has been done by others.

Obviously, I think this is a bad idea. I won't give it a NACK, but I won't approve (nor review) it either.

Guenter

Hi Guenter,

Thank you for your quick response.

At present, TSI supports a range of functionalities that cannot be exposed through hwmon. Additionally, a new protocol leveraging the TSI endpoint in hardware has been introduced, which, to our understanding, cannot be accommodated within the hwmon subsystem.

Since we already support the RMI interface via misc/amd-sbi, we believe this remains the appropriate place to continue AMD's out-of-band support.

I will update the commit message and cover letter to clearly articulate the rationale behind this change.

Thank you

maintainer
#4 lore raw

Re: [PATCH v1 1/6] hwmon/misc: amd-sbi: Move core SBTSI support from hwmon to misc

Quoted 30 lines · Akshay
Quoted 15 lines · Guenter Roeck

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

Quoted 8 lines · Akshay Gupta

From: Prathima <[email protected]>

Move SBTSI core functionality out of the hwmon-only path and into drivers/misc/amd-sbi so it can be reused by non-hwmon consumers.

This split prepares the driver for additional interfaces while keeping hwmon support as an optional layer on top of common SBTSI core logic.

This moves the driver out of hwmon space into misc/amd-sbi which, in my opinion, is completely unnecessary to accomplish the stated goals.

Quoted 8 lines

I assume this is to be able to make changes which do not follow the hwmon ABI and/or to bypass hwmon subsystem review, similar to what has been done by others.

Obviously, I think this is a bad idea. I won't give it a NACK, but I won't approve (nor review) it either.

Guenter

Hi Guenter,

Thank you for your quick response.

Quoted 8 lines

At present, TSI supports a range of functionalities that cannot be exposed through hwmon. Additionally, a new protocol leveraging the TSI endpoint in hardware has been introduced, which, to our understanding, cannot be accommodated within the hwmon subsystem.

Since we already support the RMI interface via misc/amd-sbi, we believe this remains the appropriate place to continue AMD's out-of-band support.

I will update the commit message and cover letter to clearly articulate the rationale behind this change.

Thank you

That is neither a reason or an argument for moving _hwmon_ part of the code out of the hwmon subsystem.

FWIW, your patch series removes a lot of error handling code. Sashiko has a field day with it.

Guenter

#5 lore raw

Re: [PATCH v1 1/6] hwmon/misc: amd-sbi: Move core SBTSI support from hwmon to misc

Quoted 34 lines · Guenter Roeck

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

Quoted 30 lines · Akshay
Quoted 15 lines · Guenter Roeck

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

Quoted 8 lines · Akshay Gupta

From: Prathima <[email protected]>

Move SBTSI core functionality out of the hwmon-only path and into drivers/misc/amd-sbi so it can be reused by non-hwmon consumers.

This split prepares the driver for additional interfaces while keeping hwmon support as an optional layer on top of common SBTSI core logic.

This moves the driver out of hwmon space into misc/amd-sbi which, in my opinion, is completely unnecessary to accomplish the stated goals.

Quoted 8 lines

I assume this is to be able to make changes which do not follow the hwmon ABI and/or to bypass hwmon subsystem review, similar to what has been done by others.

Obviously, I think this is a bad idea. I won't give it a NACK, but I won't approve (nor review) it either.

Guenter

Hi Guenter,

Thank you for your quick response.

At present, TSI supports a range of functionalities that cannot be exposed through hwmon. Additionally, a new protocol leveraging the TSI endpoint in hardware has been introduced, which, to our understanding, cannot be accommodated within the hwmon subsystem.

Quoted 8 lines
Quoted 6 lines

Since we already support the RMI interface via misc/amd-sbi, we believe this remains the appropriate place to continue AMD's out-of-band support.

I will update the commit message and cover letter to clearly articulate the rationale behind this change.

Thank you

That is neither a reason or an argument for moving _hwmon_ part of the code out of the hwmon subsystem.

Following feedback from the Greg and MFD subsystem maintainers, we introduced an sb-rmi driver under misc/ that calls devm_hwmon_device_register_with_info(). We are considering the same approach for the sb-tsi driver. Would you recommend a more suitable alternative?

Quoted 5 lines

FWIW, your patch series removes a lot of error handling code. Sashiko has a field day with it.

Guenter

Thank you for the feedback. I will review and address this in the next version.

Quoted 1 line
maintainer
#6 lore raw

Re: [PATCH v1 1/6] hwmon/misc: amd-sbi: Move core SBTSI support from hwmon to misc

Quoted 38 lines · Akshay
Quoted 36 lines · Guenter Roeck

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

Quoted 32 lines · Akshay
Quoted 15 lines · Guenter Roeck

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

Quoted 8 lines · Akshay Gupta

From: Prathima <[email protected]>

Move SBTSI core functionality out of the hwmon-only path and into drivers/misc/amd-sbi so it can be reused by non-hwmon consumers.

This split prepares the driver for additional interfaces while keeping hwmon support as an optional layer on top of common SBTSI core logic.

This moves the driver out of hwmon space into misc/amd-sbi which, in my opinion, is completely unnecessary to accomplish the stated goals.

Quoted 8 lines

I assume this is to be able to make changes which do not follow the hwmon ABI and/or to bypass hwmon subsystem review, similar to what has been done by others.

Obviously, I think this is a bad idea. I won't give it a NACK, but I won't approve (nor review) it either.

Guenter

Hi Guenter,

Thank you for your quick response.

At present, TSI supports a range of functionalities that cannot be exposed through hwmon. Additionally, a new protocol leveraging the TSI endpoint in hardware has been introduced, which, to our understanding, cannot be accommodated within the hwmon subsystem.

Since we already support the RMI interface via misc/amd-sbi, we believe this remains the appropriate place to continue AMD's out-of-band support.

Quoted 7 lines
Quoted 6 lines
Quoted 4 lines

I will update the commit message and cover letter to clearly articulate the rationale behind this change.

Thank you

That is neither a reason or an argument for moving _hwmon_ part of the code out of the hwmon subsystem.

Following feedback from the Greg and MFD subsystem maintainers, we introduced an sb-rmi driver under misc/ that calls devm_hwmon_device_register_with_info(). We are considering the same approach for the sb-tsi driver. Would you recommend a more suitable alternative?

I would have suggested to use an auxiliary driver, similar to PECI, but who am I to argue if senior maintainers suggest otherwise.

Guenter

#7 lore raw

Re: [PATCH v1 1/6] hwmon/misc: amd-sbi: Move core SBTSI support from hwmon to misc

Quoted 41 lines · Guenter Roeck
Quoted 40 lines · Akshay
Quoted 38 lines · Guenter Roeck

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

Quoted 34 lines · Akshay
Quoted 15 lines · Guenter Roeck

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

Quoted 8 lines · Akshay Gupta

From: Prathima <[email protected]>

Move SBTSI core functionality out of the hwmon-only path and into drivers/misc/amd-sbi so it can be reused by non-hwmon consumers.

This split prepares the driver for additional interfaces while keeping hwmon support as an optional layer on top of common SBTSI core logic.

This moves the driver out of hwmon space into misc/amd-sbi which, in my opinion, is completely unnecessary to accomplish the stated goals.

Quoted 8 lines

I assume this is to be able to make changes which do not follow the hwmon ABI and/or to bypass hwmon subsystem review, similar to what has been done by others.

Obviously, I think this is a bad idea. I won't give it a NACK, but I won't approve (nor review) it either.

Guenter

Hi Guenter,

Thank you for your quick response.

At present, TSI supports a range of functionalities that cannot be exposed through hwmon. Additionally, a new protocol leveraging the TSI endpoint in hardware has been introduced, which, to our understanding, cannot be accommodated within the hwmon subsystem.

Since we already support the RMI interface via misc/amd-sbi, we believe this remains the appropriate place to continue AMD's out-of-band support.

I will update the commit message and cover letter to clearly articulate the rationale behind this change.

Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines

Thank you

That is neither a reason or an argument for moving _hwmon_ part of the code out of the hwmon subsystem.

Following feedback from the Greg and MFD subsystem maintainers, we introduced an sb-rmi driver under misc/ that calls devm_hwmon_device_register_with_info(). We are considering the same approach for the sb-tsi driver. Would you recommend a more suitable alternative?

I would have suggested to use an auxiliary driver, similar to PECI, but who am I to argue if senior maintainers suggest otherwise.

Sounds like an aux driver makes sense to me too, I don't remember saying that you HAD to call devm_hwmon_device_register_with_info(), where was that stated in previous reviews?

thanks,

greg k-h

#8 lore raw

Re: [PATCH v1 1/6] hwmon/misc: amd-sbi: Move core SBTSI support from hwmon to misc

Quoted 51 lines · On 3/27/2026 12:53 PM, [email protected] wrote:

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

Quoted 40 lines · Guenter Roeck
Quoted 39 lines · Akshay
Quoted 38 lines · Guenter Roeck

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

Quoted 34 lines · Akshay
Quoted 15 lines · Guenter Roeck

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

Quoted 8 lines · Akshay Gupta

From: Prathima <[email protected]>

Move SBTSI core functionality out of the hwmon-only path and into drivers/misc/amd-sbi so it can be reused by non-hwmon consumers.

This split prepares the driver for additional interfaces while keeping hwmon support as an optional layer on top of common SBTSI core logic.

This moves the driver out of hwmon space into misc/amd-sbi which, in my opinion, is completely unnecessary to accomplish the stated goals.

Quoted 8 lines

I assume this is to be able to make changes which do not follow the hwmon ABI and/or to bypass hwmon subsystem review, similar to what has been done by others.

Obviously, I think this is a bad idea. I won't give it a NACK, but I won't approve (nor review) it either.

Guenter

Hi Guenter,

Thank you for your quick response.

At present, TSI supports a range of functionalities that cannot be exposed through hwmon. Additionally, a new protocol leveraging the TSI endpoint in hardware has been introduced, which, to our understanding, cannot be accommodated within the hwmon subsystem.

Since we already support the RMI interface via misc/amd-sbi, we believe this remains the appropriate place to continue AMD's out-of-band support.

I will update the commit message and cover letter to clearly articulate the rationale behind this change.

Quoted 7 lines
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines

Thank you

That is neither a reason or an argument for moving _hwmon_ part of the code out of the hwmon subsystem.

Following feedback from the Greg and MFD subsystem maintainers, we introduced an sb-rmi driver under misc/ that calls devm_hwmon_device_register_with_info(). We are considering the same approach for the sb-tsi driver. Would you recommend a more suitable alternative?

I would have suggested to use an auxiliary driver, similar to PECI, but who am I to argue if senior maintainers suggest otherwise.

Quoted 7 lines

Sounds like an aux driver makes sense to me too, I don't remember saying that you HAD to call devm_hwmon_device_register_with_info(), where was that stated in previous reviews?

thanks,

greg k-h

Thank you Greg and Guenter for the feedback. I will explore auxiliary driver and submit the changes as part of next version.

This way hwmon sensor will remain in hwmon subsytem and new implementation can be part of misc.

Following the discussions at https://lore.kernel.org/all/[email protected]/, https://lore.kernel.org/all/[email protected]/, we plan to adopt the same approach for the TSI driver.

#9 lore raw

PATCH 2/6 misc: amd-sbi: Update SBTSI Kconfig to clarify this is BMC driver

In reply to Akshay Gupta

Add an architecture dependency to the SBTSI Kconfig This limits enablement to supported targets

Also clarify in the help text that the SBTSI driver is intended to run on the BMC, not on the managed host node.

---
 drivers/misc/amd-sbi/Kconfig | 2 ++
 1 file changed, 2 insertions(+)
drivers/misc/amd-sbi/Kconfig +2 -0
index e6a422b4a371..19a8d596e8f5 100644
@@ -24,10 +24,12 @@ config AMD_SBRMI_HWMON
 config SENSORS_SBTSI
 	tristate "Emulated SB-TSI temperature sensor"
 	depends on I2C
+	depends on ARM || ARM64 || COMPILE_TEST
 	depends on HWMON
 	help
 	  If you say yes here you get support for emulated temperature
 	  sensors on AMD SoCs with SB-TSI interface connected to a BMC device.
+	  This driver is intended to run on the BMC, not the managed node.
 
 	  This driver can also be built as a module. If so, the module will
 	  be called sbtsi.
Signature · 1 line
2.34.1
#10 lore raw

PATCH 3/6 misc: amd-sbi: Split SBTSI hwmon sensor handling into a separate entity

In reply to Akshay Gupta

From: Prathima <[email protected]>

Separate SBTSI hwmon sensor handling from the core path to improve code organization and maintainability.

This keeps core transport/register access independent while preserving existing hwmon functionality through a dedicated hwmon component.

---
 drivers/misc/amd-sbi/Kconfig                  |  12 +-
 drivers/misc/amd-sbi/Makefile                 |   2 +
 drivers/misc/amd-sbi/tsi-core.h               |  30 +++++
 drivers/misc/amd-sbi/{sbtsi.c => tsi-hwmon.c} | 120 ++++--------------
 drivers/misc/amd-sbi/tsi.c                    |  77 +++++++++++
 5 files changed, 142 insertions(+), 99 deletions(-)
 create mode 100644 drivers/misc/amd-sbi/tsi-core.h
 rename drivers/misc/amd-sbi/{sbtsi.c => tsi-hwmon.c} (57%)
 create mode 100644 drivers/misc/amd-sbi/tsi.c
drivers/misc/amd-sbi/Kconfig +11 -1
index 19a8d596e8f5..2710860a86c7 100644
@@ -25,7 +25,6 @@ config SENSORS_SBTSI
 	tristate "Emulated SB-TSI temperature sensor"
 	depends on I2C
 	depends on ARM || ARM64 || COMPILE_TEST
-	depends on HWMON
 	help
 	  If you say yes here you get support for emulated temperature
 	  sensors on AMD SoCs with SB-TSI interface connected to a BMC device.
@@ -33,3 +32,14 @@ config SENSORS_SBTSI
 
 	  This driver can also be built as a module. If so, the module will
 	  be called sbtsi.
+
+config AMD_SBTSI_HWMON
+	bool "SBTSI hardware monitoring for AMD platforms"
+	depends on SENSORS_SBTSI && HWMON
+	depends on !(SENSORS_SBTSI=y && HWMON=m)
+	default y
+	help
+	  This provides support for TSI device hardware monitoring.
+	  When enabled, a hwmon device is created for each socket to expose
+	  temperature monitoring data through the standard Linux
+	  hwmon interface.
drivers/misc/amd-sbi/Makefile +2 -0
index f04273c0d3ad..a874136e438f 100644
@@ -3,4 +3,6 @@ sbrmi-i2c-objs  		+= rmi-i2c.o rmi-core.o
 sbrmi-i2c-$(CONFIG_AMD_SBRMI_HWMON)	+= rmi-hwmon.o
 obj-$(CONFIG_AMD_SBRMI_I2C)	+= sbrmi-i2c.o
 # SBTSI Configuration
+sbtsi-objs	+= tsi.o
+sbtsi-$(CONFIG_AMD_SBTSI_HWMON)	+= tsi-hwmon.o
 obj-$(CONFIG_SENSORS_SBTSI)	+= sbtsi.o
drivers/misc/amd-sbi/tsi-core.h new file +30 -0
new file mode 100644
index 000000000000..e60cf25fda7a
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2026 Advanced Micro Devices, Inc.
+ */
+
+#ifndef _TSI_CORE_H_
+#define _TSI_CORE_H_
+
+#include <linux/err.h>
+#include <linux/i2c.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/of.h>
+
+/* Each client has this additional data */
+struct sbtsi_data {
+	struct i2c_client *client;
+	bool ext_range_mode;
+	bool read_order;
+};
+
+#ifdef CONFIG_AMD_SBTSI_HWMON
+int create_sbtsi_hwmon_sensor_device(struct device *dev, struct sbtsi_data *data);
+#else
+static inline int create_sbtsi_hwmon_sensor_device(struct device *dev, struct sbtsi_data *data)
+{
+	return 0;
+}
+#endif
+#endif /*_TSI_CORE_H_*/
drivers/misc/amd-sbi/tsi-hwmon.c renamed from drivers/misc/amd-sbi/sbtsi.c +22 -98

175 lines not on this page · raw message

drivers/misc/amd-sbi/tsi.c new file +77 -0

77 lines not on this page · raw message

Signature · 1 line
2.34.1
#11 lore raw

PATCH 4/6 misc: amd-sbi: Add support for SB-TSI over I3C

In reply to Akshay Gupta

From: Prathima <[email protected]>

- Extend the SB-TSI driver to support both I2C and I3C bus interfaces.
- The driver maintains backward compatibility with existing I2C deployments while enabling support for systems using the I3C bus.

---
 drivers/misc/amd-sbi/Kconfig     |  5 ++-
 drivers/misc/amd-sbi/Makefile    |  2 +-
 drivers/misc/amd-sbi/tsi-core.c  | 64 ++++++++++++++++++++++++++++++++
 drivers/misc/amd-sbi/tsi-core.h  | 11 +++++-
 drivers/misc/amd-sbi/tsi-hwmon.c | 50 ++++++++++++++++++-------
 drivers/misc/amd-sbi/tsi.c       | 62 +++++++++++++++++++++++++++++--
 6 files changed, 173 insertions(+), 21 deletions(-)
 create mode 100644 drivers/misc/amd-sbi/tsi-core.c
drivers/misc/amd-sbi/Kconfig +3 -2
index 2710860a86c7..d18652537788 100644
@@ -23,11 +23,12 @@ config AMD_SBRMI_HWMON
 
 config SENSORS_SBTSI
 	tristate "Emulated SB-TSI temperature sensor"
-	depends on I2C
+	depends on I3C_OR_I2C
 	depends on ARM || ARM64 || COMPILE_TEST
 	help
 	  If you say yes here you get support for emulated temperature
-	  sensors on AMD SoCs with SB-TSI interface connected to a BMC device.
+	  sensors on AMD SoCs with SB-TSI interface connected to a BMC device
+	  over I2C and I3C.
 	  This driver is intended to run on the BMC, not the managed node.
 
 	  This driver can also be built as a module. If so, the module will
drivers/misc/amd-sbi/Makefile +1 -1
index a874136e438f..e87c8e618dcc 100644
@@ -3,6 +3,6 @@ sbrmi-i2c-objs  		+= rmi-i2c.o rmi-core.o
 sbrmi-i2c-$(CONFIG_AMD_SBRMI_HWMON)	+= rmi-hwmon.o
 obj-$(CONFIG_AMD_SBRMI_I2C)	+= sbrmi-i2c.o
 # SBTSI Configuration
-sbtsi-objs	+= tsi.o
+sbtsi-objs	+= tsi.o tsi-core.o
 sbtsi-$(CONFIG_AMD_SBTSI_HWMON)	+= tsi-hwmon.o
 obj-$(CONFIG_SENSORS_SBTSI)	+= sbtsi.o
drivers/misc/amd-sbi/tsi-core.c new file +64 -0

64 lines not on this page · raw message

drivers/misc/amd-sbi/tsi-core.h +10 -1
index e60cf25fda7a..a4ded17942c9 100644
@@ -11,14 +11,23 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/types.h>
+#include <linux/i3c/device.h>
+#include <linux/i3c/master.h>
 
 /* Each client has this additional data */
 struct sbtsi_data {
-	struct i2c_client *client;
+	union {
+		struct i2c_client *client;
+		struct i3c_device *i3cdev;
+	};
 	bool ext_range_mode;
 	bool read_order;
+	bool is_i3c;
 };
 
+int sbtsi_xfer(struct sbtsi_data *data, u8 reg, u8 *val, bool is_read);
+
 #ifdef CONFIG_AMD_SBTSI_HWMON
 int create_sbtsi_hwmon_sensor_device(struct device *dev, struct sbtsi_data *data);
 #else
drivers/misc/amd-sbi/tsi-hwmon.c +37 -13

81 lines not on this page · raw message

drivers/misc/amd-sbi/tsi.c +58 -4

88 lines not on this page · raw message

Signature · 1 line
2.34.1
#12 lore raw

PATCH 5/6 misc: amd-sbi: Add SBTSI ioctl register transfer interface

In reply to Akshay Gupta

From: Prathima <[email protected]>

Implement IOCTL interface for SB-TSI driver to enable userspace access to TSI register read/write operations through the AMD Advanced Platform Management Link (APML) protocol.

---
 drivers/misc/amd-sbi/tsi-core.c | 86 ++++++++++++++++++++++++++++++++-
 drivers/misc/amd-sbi/tsi-core.h |  5 ++
 drivers/misc/amd-sbi/tsi.c      | 37 ++++++++++++--
 include/uapi/misc/amd-apml.h    | 23 +++++++++
 4 files changed, 146 insertions(+), 5 deletions(-)
drivers/misc/amd-sbi/tsi-core.c +84 -2
index fcb7fcf87a55..080cf1f368df 100644
@@ -6,6 +6,10 @@
  * Copyright (c) 2020, Kun Yi <[email protected]>
  */
 
+#include <linux/fs.h>
+#include <linux/ioctl.h>
+#include <linux/uaccess.h>
+#include <uapi/misc/amd-apml.h>
 #include "tsi-core.h"
 
 /* I3C read transfer function */
@@ -56,9 +60,87 @@ static int sbtsi_i2c_xfer(struct sbtsi_data *data, u8 reg, u8 *val, bool is_read
 /* Unified transfer function for I2C and I3C access */
 int sbtsi_xfer(struct sbtsi_data *data, u8 reg, u8 *val, bool is_read)
 {
+	int ret;
+
+	mutex_lock(&data->lock);
 	if (data->is_i3c)
-		return is_read ? sbtsi_i3c_read(data, reg, val)
+		ret = is_read ? sbtsi_i3c_read(data, reg, val)
 			: sbtsi_i3c_write(data, reg, val);
+	else
+		ret = sbtsi_i2c_xfer(data, reg, val, is_read);
+	mutex_unlock(&data->lock);
+	return ret;
+}
+
+static int apml_tsi_reg_xfer(struct sbtsi_data *data,
+			     struct apml_tsi_xfer_msg __user *arg)
+{
+	struct apml_tsi_xfer_msg msg = { 0 };
+	u8 val;
+	int ret;
+
+	/* Copy the structure from user */
+	if (copy_from_user(&msg, arg, sizeof(struct apml_tsi_xfer_msg)))
+		return -EFAULT;
+
+	if (msg.rflag) {
+		/* Read operation */
+		ret = sbtsi_xfer(data, msg.reg_addr, &val, true);
+		if (!ret)
+			msg.data_in_out = val;
+	} else {
+		/* Write operation */
+		ret = sbtsi_xfer(data, msg.reg_addr, &msg.data_in_out, false);
+	}
+
+	if (msg.rflag && !ret) {
+		if (copy_to_user(arg, &msg, sizeof(struct apml_tsi_xfer_msg)))
+			return -EFAULT;
+	}
+	return ret;
+}
+
+static long sbtsi_ioctl(struct file *fp, unsigned int cmd, unsigned long arg)
+{
+	void __user *argp = (void __user *)arg;
+	struct sbtsi_data *data;
+
+	data = container_of(fp->private_data, struct sbtsi_data, sbtsi_misc_dev);
+	switch (cmd) {
+	case SBTSI_IOCTL_REG_XFER_CMD:
+		return apml_tsi_reg_xfer(data, argp);
+	default:
+		return -ENOTTY;
+	}
+}
+
+static const struct file_operations sbtsi_fops = {
+	.owner          = THIS_MODULE,
+	.unlocked_ioctl = sbtsi_ioctl,
+	.compat_ioctl   = compat_ptr_ioctl,
+};
+
+int create_misc_tsi_device(struct sbtsi_data *data,
+			   struct device *dev)
+{
+	int ret;
+
+	data->sbtsi_misc_dev.name            = devm_kasprintf(dev, GFP_KERNEL,
+							      "sbtsi-%x", data->dev_addr);
+	if (!data->sbtsi_misc_dev.name)
+		return -ENOMEM;
+	data->sbtsi_misc_dev.minor           = MISC_DYNAMIC_MINOR;
+	data->sbtsi_misc_dev.fops            = &sbtsi_fops;
+	data->sbtsi_misc_dev.parent          = dev;
+	data->sbtsi_misc_dev.nodename        = devm_kasprintf(dev, GFP_KERNEL,
+							      "sbtsi-%x", data->dev_addr);
+	if (!data->sbtsi_misc_dev.nodename)
+		return -ENOMEM;
+	data->sbtsi_misc_dev.mode            = 0600;
+
+	ret = misc_register(&data->sbtsi_misc_dev);
+	if (ret)
+		return ret;
 
-	return sbtsi_i2c_xfer(data, reg, val, is_read);
+	return ret;
 }
drivers/misc/amd-sbi/tsi-core.h +5 -0
index a4ded17942c9..d130ceadde04 100644
@@ -9,6 +9,7 @@
 #include <linux/err.h>
 #include <linux/i2c.h>
 #include <linux/init.h>
+#include <linux/miscdevice.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/types.h>
@@ -21,12 +22,16 @@ struct sbtsi_data {
 		struct i2c_client *client;
 		struct i3c_device *i3cdev;
 	};
+	struct miscdevice sbtsi_misc_dev;
+	struct mutex lock; /* serializes SBTSI register access */
 	bool ext_range_mode;
 	bool read_order;
 	bool is_i3c;
+	u8 dev_addr;
 };
 
 int sbtsi_xfer(struct sbtsi_data *data, u8 reg, u8 *val, bool is_read);
+int create_misc_tsi_device(struct sbtsi_data *data, struct device *dev);
 
 #ifdef CONFIG_AMD_SBTSI_HWMON
 int create_sbtsi_hwmon_sensor_device(struct device *dev, struct sbtsi_data *data);
drivers/misc/amd-sbi/tsi.c +34 -3
index d7a8237fc4fd..6e321064a3f3 100644
@@ -38,6 +38,7 @@ static int sbtsi_i2c_probe(struct i2c_client *client)
 
 	data->is_i3c = false;
 	data->client = client;
+	mutex_init(&data->lock);
 	err = i2c_smbus_read_byte_data(data->client, SBTSI_REG_CONFIG);
 	if (err < 0)
 		return err;
@@ -45,7 +46,21 @@ static int sbtsi_i2c_probe(struct i2c_client *client)
 	data->read_order = FIELD_GET(BIT(SBTSI_CONFIG_READ_ORDER_SHIFT), err);
 
 	dev_set_drvdata(dev, data);
-	return create_sbtsi_hwmon_sensor_device(dev, data);
+	err = create_sbtsi_hwmon_sensor_device(dev, data);
+	if (err < 0)
+		return err;
+	data->dev_addr = client->addr;
+	return create_misc_tsi_device(data, dev);
+}
+
+static void sbtsi_i2c_remove(struct i2c_client *client)
+{
+	struct sbtsi_data *data = dev_get_drvdata(&client->dev);
+
+	if (data)
+		misc_deregister(&data->sbtsi_misc_dev);
+
+	dev_info(&client->dev, "Removed sbtsi driver\n");
 }
 
 static const struct i2c_device_id sbtsi_id[] = {
@@ -68,6 +83,7 @@ static struct i2c_driver sbtsi_driver = {
 		.of_match_table = of_match_ptr(sbtsi_of_match),
 	},
 	.probe = sbtsi_i2c_probe,
+	.remove = sbtsi_i2c_remove,
 	.id_table = sbtsi_id,
 };
 
@@ -90,7 +106,7 @@ static int sbtsi_i3c_probe(struct i3c_device *i3cdev)
 	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
 	if (!data)
 		return -ENOMEM;
-
+	mutex_init(&data->lock);
 	data->i3cdev = i3cdev;
 	data->is_i3c = true;
 
@@ -102,7 +118,21 @@ static int sbtsi_i3c_probe(struct i3c_device *i3cdev)
 	data->read_order = FIELD_GET(BIT(SBTSI_CONFIG_READ_ORDER_SHIFT), val);
 
 	dev_set_drvdata(dev, data);
-	return create_sbtsi_hwmon_sensor_device(dev, data);
+	err = create_sbtsi_hwmon_sensor_device(dev, data);
+	if (err < 0)
+		return err;
+	data->dev_addr = i3cdev->desc->info.dyn_addr;
+	return create_misc_tsi_device(data, dev);
+}
+
+static void sbtsi_i3c_remove(struct i3c_device *i3cdev)
+{
+	struct sbtsi_data *data = dev_get_drvdata(&i3cdev->dev);
+
+	if (data)
+		misc_deregister(&data->sbtsi_misc_dev);
+
+	dev_info(&i3cdev->dev, "Removed sbtsi-i3c driver\n");
 }
 
 static const struct i3c_device_id sbtsi_i3c_id[] = {
@@ -121,6 +151,7 @@ static struct i3c_driver sbtsi_i3c_driver = {
 		.name = "sbtsi-i3c",
 	},
 	.probe = sbtsi_i3c_probe,
+	.remove = sbtsi_i3c_remove,
 	.id_table = sbtsi_i3c_id,
 };
 
include/uapi/misc/amd-apml.h +23 -0
index 745b3338fc06..199532b8e64a 100644
@@ -73,6 +73,13 @@ struct apml_reg_xfer_msg {
 	__u8 rflag;
 };
 
+struct apml_tsi_xfer_msg {
+	__u8 reg_addr;	/* TSI register address offset */
+	__u8 data_in_out;	/* Register data for read/write */
+	__u8 rflag;	/* Register read or write */
+	__u8 pad;	/* Explicit padding */
+};
+
 /*
  * AMD sideband interface base IOCTL
  */
@@ -149,4 +156,20 @@ struct apml_reg_xfer_msg {
  */
 #define SBRMI_IOCTL_REG_XFER_CMD	_IOWR(SB_BASE_IOCTL_NR, 3, struct apml_reg_xfer_msg)
 
+/**
+ * DOC: SBTSI_IOCTL_REG_XFER_CMD
+ *
+ * @Parameters
+ *
+ * @struct apml_tsi_xfer_msg
+ *      Pointer to the &struct apml_tsi_xfer_msg that will contain the protocol
+ *      information
+ *
+ * @Description
+ * IOCTL command for APML TSI messages using generic _IOWR
+ * The IOCTL provides userspace access to AMD sideband TSI register xfer protocol
+ * - TSI protocol to read/write temperature sensor registers
+ */
+#define SBTSI_IOCTL_REG_XFER_CMD	_IOWR(SB_BASE_IOCTL_NR, 4, struct apml_tsi_xfer_msg)
+
 #endif /*_AMD_APML_H_*/
Signature · 1 line
2.34.1
maintainer
#13 lore raw

Re: [PATCH v1 5/6] misc: amd-sbi: Add SBTSI ioctl register transfer interface

drivers/misc/amd-sbi/tsi.c static int sbtsi_i2c_probe(struct i2c_client *client) · line 63

Quoted 1 line · Akshay Gupta
drivers/misc/amd-sbi/tsi.c +1 -0
+	dev_info(&client->dev, "Removed sbtsi driver\n");

When drivers work properly, they are quiet. No need for this kernel log spam.

And were are all of these new ioctls documented and where is the userspace tools that use them?

thanks,

greg k-h

#14 lore raw

PATCH 6/6 docs: misc: amd-sbi: Document SBTSI userspace interface

In reply to Akshay Gupta

From: Prathima <[email protected]>

- Document AMD sideband IOCTL description defined
for SBTSI and its usage.
User space C-APIs are made available by esmi_oob_library [1], which is provided by the E-SMS project [2].

---
 Documentation/misc-devices/amd-sbi.rst | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
Documentation/misc-devices/amd-sbi.rst +18 -0
index f91ddadefe48..ddff3cea8ed1 100644
@@ -48,6 +48,20 @@ Access restrictions:
  * APML Mailbox messages and Register xfer access are read-write,
  * CPUID and MCA_MSR access is read-only.
 
+SBTSI device
+============
+
+apml_sbtsi driver under the drivers/misc/amd-sbi creates miscdevice
+/dev/sbtsi-* to let user space programs run APML TSI register xfer
+commands.
+
+The driver supports both I2C and I3C transports for SB-TSI targets.
+The transport is selected by the bus where the device is enumerated.
+
+Access restrictions:
+ * Only root user is allowed to open the file.
+ * APML TSI Register xfer access is read-write.
+
 Driver IOCTLs
 =============
 
@@ -63,6 +77,9 @@ Driver IOCTLs
 .. c:macro:: SBRMI_IOCTL_REG_XFER_CMD
 .. kernel-doc:: include/uapi/misc/amd-apml.h
    :doc: SBRMI_IOCTL_REG_XFER_CMD
+.. c:macro:: SBTSI_IOCTL_REG_XFER_CMD
+.. kernel-doc:: include/uapi/misc/amd-apml.h
+   :doc: SBTSI_IOCTL_REG_XFER_CMD
 
 User-space usage
 ================
@@ -92,6 +109,7 @@ The following IOCTLs are defined:
 ``#define SBRMI_IOCTL_CPUID_CMD		_IOWR(SB_BASE_IOCTL_NR, 1, struct apml_cpuid_msg)``
 ``#define SBRMI_IOCTL_MCAMSR_CMD	_IOWR(SB_BASE_IOCTL_NR, 2, struct apml_mcamsr_msg)``
 ``#define SBRMI_IOCTL_REG_XFER_CMD	_IOWR(SB_BASE_IOCTL_NR, 3, struct apml_reg_xfer_msg)``
+``#define SBTSI_IOCTL_REG_XFER_CMD      _IOWR(SB_BASE_IOCTL_NR, 4, struct apml_tsi_xfer_msg)``
 
 
 User space C-APIs are made available by esmi_oob_library, hosted at
Signature · 1 line
2.34.1
maintainer
#15 lore raw

Re: [PATCH v1 6/6] docs: misc: amd-sbi: Document SBTSI userspace interface

Quoted 9 lines · Akshay Gupta

From: Prathima <[email protected]>

- Document AMD sideband IOCTL description defined
for SBTSI and its usage.
User space C-APIs are made available by esmi_oob_library [1], which is provided by the E-SMS project [2].

Ok, nevermind, here's the documentation :)

But it's very tiny, it's not saying what the api actually is.

thanks,

greg k-h

#16 lore raw

Re: [PATCH v1 6/6] docs: misc: amd-sbi: Document SBTSI userspace interface

Quoted 13 lines · Greg KH

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

Quoted 9 lines · Akshay Gupta

From: Prathima <[email protected]>

- Document AMD sideband IOCTL description defined
for SBTSI and its usage.
User space C-APIs are made available by esmi_oob_library [1], which is provided by the E-SMS project [2].

Quoted 7 lines

Ok, nevermind, here's the documentation :)

But it's very tiny, it's not saying what the api actually is.

thanks,

greg k-h

Hi Greg,

Thank you for the feedback, will update the doc in next version with details.