mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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 1/6] misc: amd-sbi: Add helper function to prepare I3C support
Date: Mon, 15 Sep 2025 10:36:44 +0000	[thread overview]
Message-ID: <20250915103649.1705078-1-akshay.gupta@amd.com> (raw)

New AMD processors support APML connection over I3C.
Move the code, common for both I2C and I3C to new helper
function, "sbrmi_common_probe()"
While at it, renaming the static structure regmap_config "sbrmi_i2c_regmap_config"
to "sbrmi_regmap_config" to avoid confusion.

Reviewed-by: Naveen Krishna Chatradhi <naveenkrishna.chatradhi@amd.com>
Signed-off-by: Akshay Gupta <akshay.gupta@amd.com>
---

Changes from v1:
- New patch, as per suggestion to use same module for i2c and i3c
- Patch series is applied over "char-misc-next", commit ID: e2258cfd9b9809002ad52f1f763ff192e612a1fe

 drivers/misc/amd-sbi/rmi-i2c.c | 32 +++++++++++++++++++++-----------
 1 file changed, 21 insertions(+), 11 deletions(-)

diff --git a/drivers/misc/amd-sbi/rmi-i2c.c b/drivers/misc/amd-sbi/rmi-i2c.c
index f891f5af4bc6..d41457a52376 100644
--- a/drivers/misc/amd-sbi/rmi-i2c.c
+++ b/drivers/misc/amd-sbi/rmi-i2c.c
@@ -50,26 +50,18 @@ static int sbrmi_get_max_pwr_limit(struct sbrmi_data *data)
 	return ret;
 }
 
-static int sbrmi_i2c_probe(struct i2c_client *client)
+static int sbrmi_common_probe(struct device *dev, struct regmap *regmap, uint8_t address)
 {
-	struct device *dev = &client->dev;
 	struct sbrmi_data *data;
-	struct regmap_config sbrmi_i2c_regmap_config = {
-		.reg_bits = 8,
-		.val_bits = 8,
-	};
 	int ret;
 
 	data = devm_kzalloc(dev, sizeof(struct sbrmi_data), GFP_KERNEL);
 	if (!data)
 		return -ENOMEM;
 
+	data->regmap = regmap;
 	mutex_init(&data->lock);
 
-	data->regmap = devm_regmap_init_i2c(client, &sbrmi_i2c_regmap_config);
-	if (IS_ERR(data->regmap))
-		return PTR_ERR(data->regmap);
-
 	/* Enable alert for SB-RMI sequence */
 	ret = sbrmi_enable_alert(data);
 	if (ret < 0)
@@ -80,7 +72,8 @@ static int sbrmi_i2c_probe(struct i2c_client *client)
 	if (ret < 0)
 		return ret;
 
-	data->dev_static_addr = client->addr;
+	data->dev_static_addr = address;
+
 	dev_set_drvdata(dev, data);
 
 	ret = create_hwmon_sensor_device(dev, data);
@@ -89,6 +82,23 @@ static int sbrmi_i2c_probe(struct i2c_client *client)
 	return create_misc_rmi_device(data, dev);
 }
 
+static struct regmap_config sbrmi_regmap_config = {
+	.reg_bits = 8,
+	.val_bits = 8,
+};
+
+static int sbrmi_i2c_probe(struct i2c_client *client)
+{
+	struct device *dev = &client->dev;
+	struct regmap *regmap;
+
+	regmap = devm_regmap_init_i2c(client, &sbrmi_regmap_config);
+	if (IS_ERR(regmap))
+		return PTR_ERR(regmap);
+
+	return sbrmi_common_probe(dev, regmap, client->addr);
+}
+
 static void sbrmi_i2c_remove(struct i2c_client *client)
 {
 	struct sbrmi_data *data = dev_get_drvdata(&client->dev);
-- 
2.25.1


             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 Akshay Gupta [this message]
2025-09-15 10:36 ` [PATCH v2 2/6] misc: amd-sbi: Add support for SB-RMI over I3C Akshay Gupta
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-1-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®