[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250915103649.1705078-2-akshay.gupta@amd.com>
Date: Mon, 15 Sep 2025 10:36:45 +0000
From: Akshay Gupta <akshay.gupta@....com>
To: <linux-kernel@...r.kernel.org>, <linux-hwmon@...r.kernel.org>
CC: <gregkh@...uxfoundation.org>, <arnd@...db.de>, <linux@...ck-us.net>,
<Anand.Umarji@....com>, Akshay Gupta <akshay.gupta@....com>, "Naveen Krishna
Chatradhi" <naveenkrishna.chatradhi@....com>
Subject: [PATCH v2 2/6] misc: amd-sbi: Add support for SB-RMI over I3C
AMD EPYC platforms with zen5 and later support APML(SB-RMI)
connection to the BMC over I3C bus for faster data transfer
up to 12.5 Mhz.
I2C and I3C is supported in same file using module_i3c_i2c_driver()
with probe based on dts entry.
AMD APML I3C devices support static address for backward compatibility to I2C.
I3C static address can be used to assign I3C device dynamic address.
Reviewed-by: Naveen Krishna Chatradhi <naveenkrishna.chatradhi@....com>
Signed-off-by: Akshay Gupta <akshay.gupta@....com>
---
Changes from v1:
- Address reviewer's comment
- Single module file for both i2c and i3c,
hence no change in common function
drivers/misc/amd-sbi/Kconfig | 4 ++-
drivers/misc/amd-sbi/rmi-i2c.c | 45 +++++++++++++++++++++++++++++++++-
2 files changed, 47 insertions(+), 2 deletions(-)
diff --git a/drivers/misc/amd-sbi/Kconfig b/drivers/misc/amd-sbi/Kconfig
index 4aae0733d0fc..acf0450ba220 100644
--- a/drivers/misc/amd-sbi/Kconfig
+++ b/drivers/misc/amd-sbi/Kconfig
@@ -3,8 +3,10 @@ config AMD_SBRMI_I2C
tristate "AMD side band RMI support"
depends on I2C
select REGMAP_I2C
+ depends on I3C || !I3C
+ select REGMAP_I3C if I3C
help
- Side band RMI over I2C support for AMD out of band management.
+ Side band RMI over I2C/I3C support for AMD out of band management.
This driver can also be built as a module. If so, the module will
be called sbrmi-i2c.
diff --git a/drivers/misc/amd-sbi/rmi-i2c.c b/drivers/misc/amd-sbi/rmi-i2c.c
index d41457a52376..087c57bb0f37 100644
--- a/drivers/misc/amd-sbi/rmi-i2c.c
+++ b/drivers/misc/amd-sbi/rmi-i2c.c
@@ -9,6 +9,8 @@
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/i2c.h>
+#include <linux/i3c/device.h>
+#include <linux/i3c/master.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/mutex.h>
@@ -135,7 +137,48 @@ static struct i2c_driver sbrmi_driver = {
.id_table = sbrmi_id,
};
-module_i2c_driver(sbrmi_driver);
+static int sbrmi_i3c_probe(struct i3c_device *i3cdev)
+{
+ struct device *dev = i3cdev_to_dev(i3cdev);
+ struct regmap *regmap;
+
+ regmap = devm_regmap_init_i3c(i3cdev, &sbrmi_regmap_config);
+ if (IS_ERR(regmap))
+ return PTR_ERR(regmap);
+
+ /*
+ * AMD APML I3C devices support static address.
+ * If static address is defined, dynamic address is same as static address.
+ * In case static address is not defined, I3C master controller defined
+ * dynamic address is used.
+ */
+ return sbrmi_common_probe(dev, regmap, i3cdev->desc->info.dyn_addr);
+}
+
+static void sbrmi_i3c_remove(struct i3c_device *i3cdev)
+{
+ struct sbrmi_data *data = dev_get_drvdata(&i3cdev->dev);
+
+ misc_deregister(&data->sbrmi_misc_dev);
+}
+
+static const struct i3c_device_id sbrmi_i3c_id[] = {
+ /* PID for AMD SBRMI device */
+ I3C_DEVICE_EXTRA_INFO(0x112, 0x0, 0x2, NULL),
+ {}
+};
+MODULE_DEVICE_TABLE(i3c, sbrmi_i3c_id);
+
+static struct i3c_driver sbrmi_i3c_driver = {
+ .driver = {
+ .name = "sbrmi-i3c",
+ },
+ .probe = sbrmi_i3c_probe,
+ .remove = sbrmi_i3c_remove,
+ .id_table = sbrmi_i3c_id,
+};
+
+module_i3c_i2c_driver(sbrmi_i3c_driver, &sbrmi_driver);
MODULE_AUTHOR("Akshay Gupta <akshay.gupta@....com>");
MODULE_AUTHOR("Naveen Krishna Chatradhi <naveenkrishna.chatradhi@....com>");
--
2.25.1
Powered by blists - more mailing lists