summaryrefslogtreecommitdiff
path: root/include/linux/misc
diff options
context:
space:
mode:
authorPrathima <Prathima.Lk@amd.com>2026-07-10 16:46:40 +0530
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-07-17 15:50:48 +0200
commit48ad55cda029dca47f4cd76b88f18fdfb1d309a8 (patch)
tree8d77ac109fed60215c19dfb4c2c729700700ca92 /include/linux/misc
parentf61a6fd4593bddc0f2109a1d3359fd2a88124d33 (diff)
downloadlinux-next-48ad55cda029dca47f4cd76b88f18fdfb1d309a8.tar.gz
linux-next-48ad55cda029dca47f4cd76b88f18fdfb1d309a8.zip
misc: amd-sbi: Add SBTSI ioctl register transfer interface
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. Add an ioctl command (SBTSI_IOCTL_REG_XFER_CMD) that accepts a register address, data byte, and direction flag. The mutex is taken on the ioctl path here; the hwmon path is placed under the same lock in the next patch, which completes serialization between the hwmon and ioctl paths. Reviewed-by: Akshay Gupta <Akshay.Gupta@amd.com> Signed-off-by: Prathima <Prathima.Lk@amd.com> Link: https://patch.msgid.link/20260710111642.850022-7-Akshay.Gupta@amd.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/misc')
-rw-r--r--include/linux/misc/tsi.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/include/linux/misc/tsi.h b/include/linux/misc/tsi.h
index 0bdd9d923f92..5273c44688f0 100644
--- a/include/linux/misc/tsi.h
+++ b/include/linux/misc/tsi.h
@@ -8,30 +8,46 @@
#ifndef _LINUX_MISC_TSI_H_
#define _LINUX_MISC_TSI_H_
+#include <linux/cleanup.h>
#include <linux/i2c.h>
#include <linux/i3c/device.h>
+#include <linux/kref.h>
+#include <linux/miscdevice.h>
+#include <linux/mutex.h>
#include <linux/types.h>
/**
* struct sbtsi_data - driver private data for an AMD SB-TSI device
* @client: underlying I2C client
* @i3cdev: underlying I3C device (when using I3C bus)
+ * @sbtsi_misc_dev: miscdevice exposing ioctl interface at /dev/sbtsi-<addr>
+ * @lock: mutex protecting concurrent access to the device
+ * @kref: reference count; keeps @sbtsi_data alive while misc fds are open
* @dev_addr: I2C/I3C device address, used as the auxiliary device instance id
+ * and name the misc device node
* @ext_range_mode: sensor uses extended temperature range
* @read_order: if set, decimal part must be read before integer part
* @is_i3c: true when the device is accessed over I3C
+ * @detached: set on driver unbind; open/ioctl return -ENODEV afterward
*/
struct sbtsi_data {
union {
struct i2c_client *client;
struct i3c_device *i3cdev;
};
+ struct miscdevice sbtsi_misc_dev;
+ struct mutex lock; /* protects concurrent access to the device */
+ struct kref kref;
u8 dev_addr;
bool ext_range_mode;
bool read_order;
bool is_i3c;
+ bool detached;
};
+DEFINE_GUARD(sbtsi, struct sbtsi_data *, mutex_lock(&_T->lock),
+ mutex_unlock(&_T->lock))
+
/*
* Name of the auxiliary device published on the auxiliary bus by the core
* driver. The full device name is "amd-sbtsi.temp-sensor.<id>". where