From: Remi Buisson via B4 Relay <devnull+remi.buisson.tdk.com@kernel.org>
To: "Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org,
devicetree@vger.kernel.org, Remi Buisson <remi.buisson@tdk.com>
Subject: [PATCH v5 8/9] iio: imu: inv_icm45600: add I3C driver for inv_icm45600 driver
Date: Wed, 20 Aug 2025 14:24:26 +0000 [thread overview]
Message-ID: <20250820-add_newport_driver-v5-8-2fc9f13dddee@tdk.com> (raw)
In-Reply-To: <20250820-add_newport_driver-v5-0-2fc9f13dddee@tdk.com>
From: Remi Buisson <remi.buisson@tdk.com>
Add I3C driver for InvenSense ICM-45600 devices.
Signed-off-by: Remi Buisson <remi.buisson@tdk.com>
---
drivers/iio/imu/inv_icm45600/Kconfig | 21 +++++++
drivers/iio/imu/inv_icm45600/Makefile | 3 +
drivers/iio/imu/inv_icm45600/inv_icm45600_i3c.c | 77 +++++++++++++++++++++++++
3 files changed, 101 insertions(+)
diff --git a/drivers/iio/imu/inv_icm45600/Kconfig b/drivers/iio/imu/inv_icm45600/Kconfig
index 01399d136a7ea3aa92a3a18ea455c95c0a6578b3..dc133402f6d75f8c050100e8475404e00993818b 100644
--- a/drivers/iio/imu/inv_icm45600/Kconfig
+++ b/drivers/iio/imu/inv_icm45600/Kconfig
@@ -47,3 +47,24 @@ config INV_ICM45600_SPI
This driver can be built as a module. The module will be called
inv-icm45600-spi.
+
+config INV_ICM45600_I3C
+ tristate "InvenSense ICM-456xx I3C driver"
+ depends on I3C
+ select INV_ICM45600
+ select REGMAP_I3C
+ help
+ This driver supports the InvenSense ICM-456xx motion tracking
+ devices over I3C.
+ Supported devices:
+ - ICM-45605
+ - ICM-45606
+ - ICM-45608
+ - ICM-45634
+ - ICM-45686
+ - ICM-45687
+ - ICM-45688-P
+ - ICM-45689
+
+ This driver can be built as a module. The module will be called
+ inv-icm45600-i3c.
diff --git a/drivers/iio/imu/inv_icm45600/Makefile b/drivers/iio/imu/inv_icm45600/Makefile
index 3692636d393a109a0ad68e955e1cad59005e9128..c98b8365b467de6abe9873e7ba3c0aca77f464e3 100644
--- a/drivers/iio/imu/inv_icm45600/Makefile
+++ b/drivers/iio/imu/inv_icm45600/Makefile
@@ -11,3 +11,6 @@ inv-icm45600-i2c-y += inv_icm45600_i2c.o
obj-$(CONFIG_INV_ICM45600_SPI) += inv-icm45600-spi.o
inv-icm45600-spi-y += inv_icm45600_spi.o
+
+obj-$(CONFIG_INV_ICM45600_I3C) += inv-icm45600-i3c.o
+inv-icm45600-i3c-y += inv_icm45600_i3c.o
diff --git a/drivers/iio/imu/inv_icm45600/inv_icm45600_i3c.c b/drivers/iio/imu/inv_icm45600/inv_icm45600_i3c.c
new file mode 100644
index 0000000000000000000000000000000000000000..e58de9c8a8b59682bec30d6de293a1adda8618e6
--- /dev/null
+++ b/drivers/iio/imu/inv_icm45600/inv_icm45600_i3c.c
@@ -0,0 +1,77 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/* Copyright (C) 2025 InvenSense, Inc. */
+
+#include <linux/err.h>
+#include <linux/i3c/device.h>
+#include <linux/i3c/master.h>
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/regmap.h>
+
+#include "inv_icm45600.h"
+
+static const struct regmap_config inv_icm45600_regmap_config = {
+ .reg_bits = 8,
+ .val_bits = 8,
+};
+
+static const struct i3c_device_id inv_icm45600_i3c_ids[] = {
+ I3C_DEVICE_EXTRA_INFO(0x0235, 0x0000, 0x0011, (void *)NULL),
+ I3C_DEVICE_EXTRA_INFO(0x0235, 0x0000, 0x0084, (void *)NULL),
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(i3c, inv_icm45600_i3c_ids);
+
+static const struct inv_icm45600_chip_info *i3c_chip_info[] = {
+ &inv_icm45605_chip_info,
+ &inv_icm45606_chip_info,
+ &inv_icm45608_chip_info,
+ &inv_icm45634_chip_info,
+ &inv_icm45686_chip_info,
+ &inv_icm45687_chip_info,
+ &inv_icm45688p_chip_info,
+ &inv_icm45689_chip_info,
+};
+
+static int inv_icm45600_i3c_probe(struct i3c_device *i3cdev)
+{
+ int ret;
+ unsigned int whoami;
+ struct regmap *regmap;
+ const int nb_chip = ARRAY_SIZE(i3c_chip_info);
+ int chip;
+
+ regmap = devm_regmap_init_i3c(i3cdev, &inv_icm45600_regmap_config);
+ if (IS_ERR(regmap))
+ return dev_err_probe(&i3cdev->dev, PTR_ERR(regmap),
+ "Failed to register i3c regmap %ld\n", PTR_ERR(regmap));
+
+ ret = regmap_read(regmap, INV_ICM45600_REG_WHOAMI, &whoami);
+ if (ret)
+ return dev_err_probe(&i3cdev->dev, ret, "Failed to read part id %d\n", whoami);
+
+ for (chip = 0; chip < nb_chip; chip++) {
+ if (whoami == i3c_chip_info[chip]->whoami)
+ break;
+ }
+
+ if (chip == nb_chip)
+ dev_err_probe(&i3cdev->dev, -ENODEV, "Failed to match part id %d\n", whoami);
+
+ return inv_icm45600_core_probe(regmap, i3c_chip_info[chip], false, NULL);
+}
+
+static struct i3c_driver inv_icm45600_driver = {
+ .driver = {
+ .name = "inv_icm45600_i3c",
+ .pm = pm_sleep_ptr(&inv_icm45600_pm_ops),
+ },
+ .probe = inv_icm45600_i3c_probe,
+ .id_table = inv_icm45600_i3c_ids,
+};
+module_i3c_driver(inv_icm45600_driver);
+
+MODULE_AUTHOR("Remi Buisson <remi.buisson@tdk.com>");
+MODULE_DESCRIPTION("InvenSense ICM-456xx i3c driver");
+MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS("IIO_ICM45600");
--
2.34.1
next prev parent reply other threads:[~2025-08-20 14:24 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-20 14:24 [PATCH v5 0/9] iio: imu: new inv_icm45600 driver Remi Buisson via B4 Relay
2025-08-20 14:24 ` [PATCH v5 1/9] dt-bindings: iio: imu: Add inv_icm45600 Remi Buisson via B4 Relay
2025-08-20 19:33 ` Conor Dooley
2025-08-20 14:24 ` [PATCH v5 2/9] iio: imu: inv_icm45600: add new inv_icm45600 driver Remi Buisson via B4 Relay
2025-08-21 9:02 ` Andy Shevchenko
2025-09-04 12:58 ` Remi Buisson
2025-09-04 13:17 ` Andy Shevchenko
2025-08-25 10:34 ` Jonathan Cameron
2025-09-04 13:04 ` Remi Buisson
2025-08-20 14:24 ` [PATCH v5 3/9] iio: imu: inv_icm45600: add buffer support in iio devices Remi Buisson via B4 Relay
2025-08-21 9:20 ` Andy Shevchenko
2025-09-04 13:01 ` Remi Buisson
2025-09-04 13:49 ` Andy Shevchenko
2025-08-25 10:42 ` Jonathan Cameron
2025-09-04 13:05 ` Remi Buisson
2025-08-20 14:24 ` [PATCH v5 4/9] iio: imu: inv_icm45600: add IMU IIO gyroscope device Remi Buisson via B4 Relay
2025-08-25 10:55 ` Jonathan Cameron
2025-09-04 13:06 ` Remi Buisson
2025-08-20 14:24 ` [PATCH v5 5/9] iio: imu: inv_icm45600: add IMU IIO accelerometer device Remi Buisson via B4 Relay
2025-08-20 14:24 ` [PATCH v5 6/9] iio: imu: inv_icm45600: add I2C driver for inv_icm45600 driver Remi Buisson via B4 Relay
2025-08-20 14:24 ` [PATCH v5 7/9] iio: imu: inv_icm45600: add SPI " Remi Buisson via B4 Relay
2025-08-20 14:24 ` Remi Buisson via B4 Relay [this message]
2025-08-20 14:24 ` [PATCH v5 9/9] MAINTAINERS: add entry for inv_icm45600 6-axis imu sensor Remi Buisson via B4 Relay
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=20250820-add_newport_driver-v5-8-2fc9f13dddee@tdk.com \
--to=devnull+remi.buisson.tdk.com@kernel.org \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=remi.buisson@tdk.com \
--cc=robh@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).