[PATCH v1 1/5] misc: amd-sbi: Split core driver as separate module

From: Akshay Gupta
Date: Mon Jul 28 2025 - 02:11:14 EST


This change is in preparation for enabling SB-RMI access
over I3C along with present I2C bus.
Split the core APIs into a separate module, export those APIs
to be used by the I2C and I3C modules.
Introduce a config option in Kconfig and update Makefile accordingly.

Reviewed-by: Naveen Krishna Chatradhi <naveenkrishna.chatradhi@xxxxxxx>
Signed-off-by: Akshay Gupta <akshay.gupta@xxxxxxx>
---
drivers/misc/amd-sbi/Kconfig | 11 ++++++++++-
drivers/misc/amd-sbi/Makefile | 6 ++++--
drivers/misc/amd-sbi/rmi-core.c | 5 +++++
drivers/misc/amd-sbi/rmi-hwmon.c | 4 ++++
drivers/misc/amd-sbi/rmi-i2c.c | 1 +
5 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/drivers/misc/amd-sbi/Kconfig b/drivers/misc/amd-sbi/Kconfig
index 4840831c84ca..9b1abeb6ab1a 100644
--- a/drivers/misc/amd-sbi/Kconfig
+++ b/drivers/misc/amd-sbi/Kconfig
@@ -1,7 +1,14 @@
# SPDX-License-Identifier: GPL-2.0-only
+
+menu "AMD side band Interface(APML)"
+
+config AMD_SBRMI
+ bool
+
config AMD_SBRMI_I2C
- tristate "AMD side band RMI support"
+ tristate "AMD side band RMI support over I2C"
depends on I2C
+ select AMD_SBRMI
help
Side band RMI over I2C support for AMD out of band management.

@@ -16,3 +23,5 @@ 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.
+
+endmenu
diff --git a/drivers/misc/amd-sbi/Makefile b/drivers/misc/amd-sbi/Makefile
index 38eaaa651fd9..6f3090fb9ff3 100644
--- a/drivers/misc/amd-sbi/Makefile
+++ b/drivers/misc/amd-sbi/Makefile
@@ -1,4 +1,6 @@
# SPDX-License-Identifier: GPL-2.0-only
-sbrmi-i2c-objs += rmi-i2c.o rmi-core.o
-sbrmi-i2c-$(CONFIG_AMD_SBRMI_HWMON) += rmi-hwmon.o
+obj-$(CONFIG_AMD_SBRMI) += sbrmi_core.o
+sbrmi_core-y := rmi-core.o
+obj-$(CONFIG_AMD_SBRMI_HWMON) += rmi-hwmon.o
+sbrmi-i2c-y := rmi-i2c.o
obj-$(CONFIG_AMD_SBRMI_I2C) += sbrmi-i2c.o
diff --git a/drivers/misc/amd-sbi/rmi-core.c b/drivers/misc/amd-sbi/rmi-core.c
index 3dec2fc00124..6a7d0bb33bf8 100644
--- a/drivers/misc/amd-sbi/rmi-core.c
+++ b/drivers/misc/amd-sbi/rmi-core.c
@@ -352,6 +352,7 @@ int rmi_mailbox_xfer(struct sbrmi_data *data,
mutex_unlock(&data->lock);
return ret;
}
+EXPORT_SYMBOL_NS_GPL(rmi_mailbox_xfer, "AMD_SBRMI");

static int apml_rmi_reg_xfer(struct sbrmi_data *data,
struct apml_reg_xfer_msg __user *arg)
@@ -482,3 +483,7 @@ int create_misc_rmi_device(struct sbrmi_data *data,

return misc_register(&data->sbrmi_misc_dev);
}
+EXPORT_SYMBOL_NS_GPL(create_misc_rmi_device, "AMD_SBRMI");
+
+MODULE_DESCRIPTION("AMD SB-RMI common driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/misc/amd-sbi/rmi-hwmon.c b/drivers/misc/amd-sbi/rmi-hwmon.c
index f4f015605daa..e5d234549b5c 100644
--- a/drivers/misc/amd-sbi/rmi-hwmon.c
+++ b/drivers/misc/amd-sbi/rmi-hwmon.c
@@ -6,6 +6,7 @@
*/
#include <linux/err.h>
#include <linux/hwmon.h>
+#include <linux/module.h>
#include <uapi/misc/amd-apml.h>
#include "rmi-core.h"

@@ -118,3 +119,6 @@ int create_hwmon_sensor_device(struct device *dev, struct sbrmi_data *data)
&sbrmi_chip_info, NULL);
return PTR_ERR_OR_ZERO(hwmon_dev);
}
+EXPORT_SYMBOL(create_hwmon_sensor_device);
+
+MODULE_IMPORT_NS("AMD_SBRMI");
diff --git a/drivers/misc/amd-sbi/rmi-i2c.c b/drivers/misc/amd-sbi/rmi-i2c.c
index f891f5af4bc6..e90ab0a5f8eb 100644
--- a/drivers/misc/amd-sbi/rmi-i2c.c
+++ b/drivers/misc/amd-sbi/rmi-i2c.c
@@ -127,6 +127,7 @@ static struct i2c_driver sbrmi_driver = {

module_i2c_driver(sbrmi_driver);

+MODULE_IMPORT_NS("AMD_SBRMI");
MODULE_AUTHOR("Akshay Gupta <akshay.gupta@xxxxxxx>");
MODULE_AUTHOR("Naveen Krishna Chatradhi <naveenkrishna.chatradhi@xxxxxxx>");
MODULE_DESCRIPTION("Hwmon driver for AMD SB-RMI emulated sensor");
--
2.25.1