]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
misc: amd-sbi: Add support for SB-RMI over I3C
authorAkshay Gupta <akshay.gupta@amd.com>
Mon, 15 Sep 2025 10:36:45 +0000 (10:36 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Oct 2025 05:59:57 +0000 (07:59 +0200)
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@amd.com>
Signed-off-by: Akshay Gupta <akshay.gupta@amd.com>
Link: https://patch.msgid.link/20250915103649.1705078-2-akshay.gupta@amd.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/amd-sbi/Kconfig
drivers/misc/amd-sbi/rmi-i2c.c

index 4aae0733d0fc166836d20134434afdfaff12295c..acf0450ba220179abb77e23b73f15cc376aa01e3 100644 (file)
@@ -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.
index d41457a5237610c3ec7d10473ba31becf3c34edf..087c57bb0f372b298c62c15bf08d2b494b9d3046 100644 (file)
@@ -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@amd.com>");
 MODULE_AUTHOR("Naveen Krishna Chatradhi <naveenkrishna.chatradhi@amd.com>");