From: Akshay Gupta <akshay.gupta@amd.com>
To: <linux-kernel@vger.kernel.org>, <linux-hwmon@vger.kernel.org>
Cc: <gregkh@linuxfoundation.org>, <arnd@arndb.de>,
<linux@roeck-us.net>, <Anand.Umarji@amd.com>,
Akshay Gupta <akshay.gupta@amd.com>,
"Naveen Krishna Chatradhi" <naveenkrishna.chatradhi@amd.com>
Subject: [PATCH v2 2/6] misc: amd-sbi: Add support for SB-RMI over I3C
Date: Mon, 15 Sep 2025 10:36:45 +0000 [thread overview]
Message-ID: <20250915103649.1705078-2-akshay.gupta@amd.com> (raw)
In-Reply-To: <20250915103649.1705078-1-akshay.gupta@amd.com>
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>
---
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@amd.com>");
MODULE_AUTHOR("Naveen Krishna Chatradhi <naveenkrishna.chatradhi@amd.com>");
--
2.25.1
next prev parent reply other threads:[~2025-09-15 10:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-15 10:36 [PATCH v2 1/6] misc: amd-sbi: Add helper function to prepare I3C support Akshay Gupta
2025-09-15 10:36 ` Akshay Gupta [this message]
2025-09-15 10:36 ` [PATCH v2 3/6] misc: amd-sbi: Add support for Turin platform Akshay Gupta
2025-09-15 10:36 ` [PATCH v2 4/6] misc: amd-sbi: CPUID/MCAMSR protocol for Revision 0x21 Akshay Gupta
2025-09-15 10:36 ` [PATCH v2 5/6] misc: amd-sbi: Extend support for CPUID protocol for rev 0x21 Akshay Gupta
2025-09-15 10:36 ` [PATCH v2 6/6] misc: amd-sbi: Extend support for MCAMSR " Akshay Gupta
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250915103649.1705078-2-akshay.gupta@amd.com \
--to=akshay.gupta@amd.com \
--cc=Anand.Umarji@amd.com \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=naveenkrishna.chatradhi@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®