diff mbox series

[2/5] mfd: sbrmi: Add mfd cell in the probe

Message ID 20240530112307.3089696-3-naveenkrishna.chatradhi@amd.com (mailing list archive)
State Handled Elsewhere
Headers show
Series mfd: add amd side-band functionality | expand

Commit Message

Chatradhi, Naveen Krishna May 30, 2024, 11:23 a.m. UTC
From: Akshay Gupta <akshay.gupta@amd.com>

- AMD provides socket power information from out of band
  which can be read by sensors.
- mfd cell will probe the drivers/hwmon/sbrmi as a platform device
  and share the sbrmi device data.

Signed-off-by: Akshay Gupta <Akshay.Gupta@amd.com>
Reviewed-by: Naveen Krishna Chatradhi <naveenkrishna.chatradhi@amd.com>
---
 drivers/mfd/sbrmi-i2c.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/mfd/sbrmi-i2c.c b/drivers/mfd/sbrmi-i2c.c
index 96215e986740..c19f0b3eb0cd 100644
--- a/drivers/mfd/sbrmi-i2c.c
+++ b/drivers/mfd/sbrmi-i2c.c
@@ -10,6 +10,7 @@ 
 #include <linux/err.h>
 #include <linux/i2c.h>
 #include <linux/init.h>
+#include <linux/mfd/core.h>
 #include <linux/mfd/amd-sb.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
@@ -17,6 +18,10 @@ 
 
 #define SBRMI_CTRL	0x1
 
+static struct mfd_cell apml_sbrmi[] = {
+	{ .name = "sbrmi-hwmon" },
+};
+
 static int sbrmi_enable_alert(struct i2c_client *client)
 {
 	int ctrl;
@@ -72,7 +77,17 @@  static int sbrmi_i2c_probe(struct i2c_client *client)
 		return ret;
 
 	/* Cache maximum power limit */
-	return sbrmi_get_max_pwr_limit(data);
+	ret = sbrmi_get_max_pwr_limit(data);
+	if (ret < 0)
+		return ret;
+
+	dev_set_drvdata(dev, (void *)data);
+
+	ret = devm_mfd_add_devices(dev, PLATFORM_DEVID_AUTO, apml_sbrmi,
+				   ARRAY_SIZE(apml_sbrmi), NULL, 0, NULL);
+	if (ret)
+		dev_err(dev, "Failed to register for sub-devices: %d\n", ret);
+	return ret;
 }
 
 static const struct i2c_device_id sbrmi_id[] = {