From: Guenter Roeck <linux@roeck-us.net>
To: linux-hwmon@vger.kernel.org
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>,
Yo-Jung Lin <leo.lin@canonical.com>,
Guenter Roeck <linux@roeck-us.net>
Subject: [RFT PATCH 5/5] hwmon: (spd5118) Add I3C support
Date: Sat, 19 Apr 2025 09:13:55 -0700 [thread overview]
Message-ID: <20250419161356.2528986-6-linux@roeck-us.net> (raw)
In-Reply-To: <20250419161356.2528986-1-linux@roeck-us.net>
Add code to support instantiating SPD5118 compatible hub and SPD devices
connected to I3C controllers.
Note that protecting the I3C probe function against CONFIG_I3C is not
necessary even though it calls a function which is not available in this
case. The I3C registration and unregistration functions are protected with
IS_ENABLED(CONFIG_I3C), which causes the I3C probe function to be optimized
away if CONFIG_I3C is disabled.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
RFT: Compile tested only.
drivers/hwmon/Kconfig | 2 ++
drivers/hwmon/spd5118.c | 51 ++++++++++++++++++++++++++++++++++++++++-
2 files changed, 52 insertions(+), 1 deletion(-)
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index f91f713b0105..6ee302cccf48 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -2259,7 +2259,9 @@ config SENSORS_INA3221
config SENSORS_SPD5118
tristate "SPD5118 Compliant Temperature Sensors"
depends on I2C
+ depends on I3C || I3C=n
select REGMAP_I2C
+ select REGMAP_I3C if I3C
help
If you say yes here you get support for SPD5118 (JEDEC JESD300)
compliant temperature sensors. Such sensors are found on DDR5 memory
diff --git a/drivers/hwmon/spd5118.c b/drivers/hwmon/spd5118.c
index 5da44571b6a0..f68848b003fb 100644
--- a/drivers/hwmon/spd5118.c
+++ b/drivers/hwmon/spd5118.c
@@ -18,6 +18,7 @@
#include <linux/bits.h>
#include <linux/err.h>
#include <linux/i2c.h>
+#include <linux/i3c/device.h>
#include <linux/hwmon.h>
#include <linux/module.h>
#include <linux/mutex.h>
@@ -705,6 +706,8 @@ static int spd5118_i2c_init(struct i2c_client *client)
* which does reset the addressing mode. To prevent this from happening,
* detect if 16-bit addressing is enabled and always use the currently
* configured addressing mode.
+ *
+ * I3C always uses 16-bit addressing.
*/
static int spd5118_i2c_probe(struct i2c_client *client)
@@ -770,7 +773,53 @@ static struct i2c_driver spd5118_i2c_driver = {
.address_list = IS_ENABLED(CONFIG_SENSORS_SPD5118_DETECT) ? normal_i2c : NULL,
};
-module_i2c_driver(spd5118_i2c_driver);
+/* I3C */
+
+static int spd5118_i3c_probe(struct i3c_device *i3cdev)
+{
+ struct device *dev = i3cdev_to_dev(i3cdev);
+ struct regmap *regmap;
+
+ regmap = devm_regmap_init_i3c(i3cdev, &spd5118_regmap16_config);
+ if (IS_ERR(regmap))
+ return dev_err_probe(dev, PTR_ERR(regmap), "regmap init failed\n");
+
+ return spd5118_common_probe(dev, regmap, true);
+}
+
+/*
+ * SPD5118 compliant devices do not have to support the GETPID command.
+ * It is unknown if those chips can be auto-detected on I3C busses. It may be
+ * necessary to instantiate SPD5118 devices on I3C through devicetree or by
+ * other explicit means. See Documentation/devicetree/bindings/i3c/i3c.yaml
+ * for details on how to instantiate I3C devices from devicetree.
+ * Device IDs are provided to enable association of devicetree entries with the
+ * driver. The Renesas entry was found in a driver from Nuvoton. A reference to
+ * the IDT ID was found in a devicetree file. The entries for Rambus and Montage
+ * Technology were guessed based on assigned MIPI IDs (https://mid.mipi.org).
+ * There is also a SPD5118 compliant EEPROM/Hub/Temperature sensor (S-34HTS08AB)
+ * from Ablic. The MIPI ID for this chip might be 0x0173 (Mitsumi) for Ablic's
+ * parent company, but that is unconfirmed.
+ */
+static const struct i3c_device_id spd5118_i3c_ids[] = {
+ I3C_DEVICE(0x01e0, 0x5118, NULL), /* IDT */
+ I3C_DEVICE(0x0266, 0x5118, NULL), /* Renesas */
+ I3C_DEVICE(0x03fa, 0x5118, NULL), /* Rambus (unconfirmed) */
+ I3C_DEVICE(0x0433, 0x5118, NULL), /* Montage Technology (unconfirmed) */
+ { }
+};
+MODULE_DEVICE_TABLE(i3c, spd5118_i3c_ids);
+
+static struct i3c_driver spd5118_i3c_driver = {
+ .driver = {
+ .name = "spd5118_i3c",
+ .pm = pm_sleep_ptr(&spd5118_pm_ops),
+ },
+ .probe = spd5118_i3c_probe,
+ .id_table = spd5118_i3c_ids,
+};
+
+module_i3c_i2c_driver(spd5118_i3c_driver, &spd5118_i2c_driver);
MODULE_AUTHOR("René Rebe <rene@exactcode.de>");
MODULE_AUTHOR("Guenter Roeck <linux@roeck-us.net>");
--
2.45.2
prev parent reply other threads:[~2025-04-19 16:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-19 16:13 [PATCH 0/5] hwmon: (spd5118) Add I3C support Guenter Roeck
2025-04-19 16:13 ` [PATCH 1/5] hwmon: (spd5118) Split into common and I2C specific code Guenter Roeck
2025-04-19 16:13 ` [PATCH 2/5] hwmon: (spd5118) Name chips taking the specification literally Guenter Roeck
2025-04-19 16:13 ` [PATCH 3/5] hwmon: (spd5118) Support 16-bit addressing for NVMEM accesses Guenter Roeck
2025-04-19 16:13 ` [PATCH 4/5] hwmon: (spd5118) Detect and support 16-bit register addressing Guenter Roeck
2025-04-19 16:13 ` Guenter Roeck [this message]
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=20250419161356.2528986-6-linux@roeck-us.net \
--to=linux@roeck-us.net \
--cc=leo.lin@canonical.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=wsa+renesas@sang-engineering.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