From: Kanak Shilledar <Kanak.Shilledar@axis.com>
To: "jic23@kernel.org" <jic23@kernel.org>
Cc: "dlechner@baylibre.com" <dlechner@baylibre.com>,
"joshua.crofts1@gmail.com" <joshua.crofts1@gmail.com>,
Henrik Grimler <Henrik.Grimler@axis.com>,
"nuno.sa@analog.com" <nuno.sa@analog.com>,
"jean-baptiste.maneyrol@tdk.com" <jean-baptiste.maneyrol@tdk.com>,
"robh@kernel.org" <robh@kernel.org>,
"marcelo.schmitt1@gmail.com" <marcelo.schmitt1@gmail.com>,
"andy@kernel.org" <andy@kernel.org>,
"krzk+dt@kernel.org" <krzk+dt@kernel.org>,
"macromorgan@hotmail.com" <macromorgan@hotmail.com>,
"conor+dt@kernel.org" <conor+dt@kernel.org>,
Kernel <Kernel@axis.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>
Subject: Re: [PATCH v3 5/8] iio: imu: inv_icm42607: Add support for ICM-42370-P
Date: Wed, 16 Sep 2026 09:28:19 +0000 [thread overview]
Message-ID: <d5502abac64a6a6f177e251e8ec514bc346e1a08.camel@axis.com> (raw)
In-Reply-To: <178874609182.3402141.7546313507051426644.b4-review@b4>
[-- Attachment #1: Type: text/plain, Size: 5276 bytes --]
Hi Jonathan,
On Mon, 2026-09-07 at 02:54 +0100, Jonathan Cameron wrote:
> > Add support for the Invensense ICM-42370-P MEMS MotionTracking 3-
> > axis
> > accelerometer with built-in temperature sensor. This device is
> > almost
> > identical to the existing Invensense ICM-42607-P IMU, but lacks
> > gyroscope. The device supports I2C, SPI and I3C, implement only I2C
> > support. Provide basic support for raw sensor reads via sysfs.
> > There is
> > also a built-in temperature sensor but it can not be turned off.
> >
> > Datasheet:
> > https://www.invensense.tdk.com/en-us/products/3-axis/icm-42370-p
> > Datasheet: https://www.lcsc.com/product-detail/C5129967.html
> > Signed-off-by: Kanak Shilledar <kanak.shilledar@axis.com>
> >
> > diff --git a/drivers/iio/imu/inv_icm42607/inv_icm42607.h
> > b/drivers/iio/imu/inv_icm42607/inv_icm42607.h
> > index fa85cf738cc0..a183a8566617 100644
> > --- a/drivers/iio/imu/inv_icm42607/inv_icm42607.h
> > +++ b/drivers/iio/imu/inv_icm42607/inv_icm42607.h
> > @@ -368,6 +368,7 @@ struct inv_icm42607_sensor_state {
> > #define
> > INV_ICM42607_REG_WHOAMI 0x75
> > #define INV_ICM42607P_WHOAMI 0x60
> > #define INV_ICM42607_WHOAMI 0x67
> > +#define INV_ICM42370P_WHOAMI 0x0D
>
> I'd put this in alpha numeric order. Either that or by WHOAMI value.
> Neither is true currently.
Will fix it
>
> >
> > /*
> > * Timings as listed in section 3 of datasheet, all values listed
> > in datasheet
> > @@ -392,6 +393,7 @@ typedef int (*inv_icm42607_bus_setup)(struct
> > inv_icm42607_state *);
> > extern const struct regmap_config inv_icm42607_regmap_config;
> > extern const struct inv_icm42607_hw inv_icm42607_hw_data;
> > extern const struct inv_icm42607_hw inv_icm42607p_hw_data;
> > +extern const struct inv_icm42607_hw inv_icm42370p_hw_data;
> > extern const struct dev_pm_ops inv_icm42607_pm_ops;
> >
> > const struct iio_mount_matrix *
> > diff --git a/drivers/iio/imu/inv_icm42607/inv_icm42607_core.c
> > b/drivers/iio/imu/inv_icm42607/inv_icm42607_core.c
> > index 7eb486ff673b..e77d72e0f7bc 100644
> > --- a/drivers/iio/imu/inv_icm42607/inv_icm42607_core.c
> > +++ b/drivers/iio/imu/inv_icm42607/inv_icm42607_core.c
> > @@ -92,6 +92,17 @@ static const struct inv_icm42607_conf
> > inv_icm42607_default_conf = {
> > },
> > };
> >
> > +/* Chip initial default configuration */
> > +static const struct inv_icm42607_conf inv_icm42370_default_conf =
> > {
> > + .gyro = { },
>
> Don't specificy it. C will fill it in anyway with 0s.
Will fix it
> > + .accel = {
> > + .mode = INV_ICM42607_SENSOR_MODE_OFF,
> > + .fs = INV_ICM42607_ACCEL_FS_4G,
> > + .odr = INV_ICM42607_ODR_100HZ,
> > + .filter = INV_ICM42607_FILTER_BW_25HZ,
> > + },
> > +};
> > +
> > const struct inv_icm42607_hw inv_icm42607_hw_data = {
> > .whoami = INV_ICM42607_WHOAMI,
> > .name = "icm42607",
>
>
> > @@ -617,16 +635,38 @@ int inv_icm42607_core_probe(struct regmap
> > *regmap,
> > pm_runtime_set_autosuspend_delay(dev,
> > INV_ICM42607_SUSPEND_DELAY_MS);
> > pm_runtime_use_autosuspend(dev);
> >
> > - /* Initialize IIO device for Accel */
> > - st->indio_accel = inv_icm42607_accel_init(st);
> > - if (IS_ERR(st->indio_accel))
> > - return PTR_ERR(st->indio_accel);
> > + switch (st->hw->whoami) {
> > + case INV_ICM42607_WHOAMI:
> > + case INV_ICM42607P_WHOAMI:
>
> It is almost never good design to match against whoami values.
> Doing so scales really badly as a driver ends up supporting more and
> more devices.
>
> Instead encode what they mean in additional properties in the chip
> info structure.
Will modify to sue the chip info struct.
>
> > + /*
> > + * Invensense, ICM42607 and ICM42607P both have
> > accelerometer
> > + * and gyroscope functionality.
> > + */
> > + st->indio_accel = inv_icm42607_accel_init(st);
> > + if (IS_ERR(st->indio_accel))
> > + return PTR_ERR(st->indio_accel);
>
> This first bit is in btoh paths, so drop it out of this switch.
>
> > +
> > + st->indio_gyro = inv_icm42607_gyro_init(st);
>
> Add a has_gyro flag or something like that to chip_info.
>
> > + if (IS_ERR(st->indio_gyro))
> > + return PTR_ERR(st->indio_gyro);
> > +
> > + break;
> > + case INV_ICM42370P_WHOAMI:
> > + /*
> > + * Invensense, ICM42370P has only accelerometer
> > functionality.
> > + * Thus, set the gryo property to NULL.
> > + */
> > + st->indio_accel = inv_icm42607_accel_init(st);
> > + if (IS_ERR(st->indio_accel))
> > + return PTR_ERR(st->indio_accel);
> >
> > - /* Initialize IIO device for Gyro */
> > - st->indio_gyro = inv_icm42607_gyro_init(st);
> > - if (IS_ERR(st->indio_gyro))
> > - return PTR_ERR(st->indio_gyro);
> > + st->indio_gyro = NULL;
>
> st should be zeroed anyway so shouldn't be any reason to do this.
Will fix this.
>
> >
> > + break;
> > + default:
> > + /* No WHOAMI value matched */
> > + return dev_err_probe(dev, -ENODEV, "Failed to find
> > a matching WHO_AM_I value\n");
> > + }
> > return 0;
> > }
> > EXPORT_SYMBOL_NS_GPL(inv_icm42607_core_probe, "IIO_ICM42607");
Thanks and Regards,
Kanak Shilledar
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2026-09-16 9:28 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 14:35 [PATCH v3 0/8] Add support for InvenSense ICM-42370-P accelerometer Kanak Shilledar
2026-09-01 14:35 ` [PATCH v3 1/8] dt-bindings: Add InvenSense ICM-42370-p accelerometer Kanak Shilledar
2026-09-07 1:54 ` Jonathan Cameron
2026-09-16 9:25 ` Kanak Shilledar
2026-09-01 14:35 ` [PATCH v3 2/8] iio: imu: inv_icm42607: Update IIO channel macros Kanak Shilledar
2026-09-01 14:35 ` [PATCH v3 3/8] iio: imu: inv_icm42607: Update _odr_to_period_us formatting Kanak Shilledar
2026-09-07 1:54 ` Jonathan Cameron
2026-09-15 17:20 ` Chris Morgan
2026-09-16 9:23 ` Kanak Shilledar
2026-09-01 14:35 ` [PATCH v3 4/8] iio: imu: inv_icm42607: Switch to little endian Kanak Shilledar
2026-09-07 1:54 ` Jonathan Cameron
2026-09-16 9:26 ` Kanak Shilledar
2026-09-01 14:35 ` [PATCH v3 5/8] iio: imu: inv_icm42607: Add support for ICM-42370-P Kanak Shilledar
2026-09-07 1:54 ` Jonathan Cameron
2026-09-16 9:28 ` Kanak Shilledar [this message]
2026-09-01 14:35 ` [PATCH v3 6/8] iio: imu: inv_icm42607: Implement MREGx register access Kanak Shilledar
2026-09-07 1:54 ` Jonathan Cameron
2026-09-07 11:52 ` Jean-Baptiste Maneyrol
2026-09-16 9:30 ` Kanak Shilledar
2026-09-01 14:36 ` [PATCH v3 7/8] iio: imu: inv_icm42607: Add accelerometer calibbias support Kanak Shilledar
2026-09-07 1:54 ` Jonathan Cameron
2026-09-16 9:37 ` Kanak Shilledar
2026-09-16 9:44 ` Joshua Crofts
2026-09-15 17:27 ` Chris Morgan
2026-09-16 9:42 ` Kanak Shilledar
2026-09-01 14:36 ` [PATCH v3 8/8] iio: imu: inv_icm42607: Add gyroscope " Kanak Shilledar
2026-09-07 1:54 ` Jonathan Cameron
2026-09-02 5:30 ` [PATCH v3 0/8] Add support for InvenSense ICM-42370-P accelerometer Andy Shevchenko
2026-09-07 1:54 ` Jonathan Cameron
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=d5502abac64a6a6f177e251e8ec514bc346e1a08.camel@axis.com \
--to=kanak.shilledar@axis.com \
--cc=Henrik.Grimler@axis.com \
--cc=Kernel@axis.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jean-baptiste.maneyrol@tdk.com \
--cc=jic23@kernel.org \
--cc=joshua.crofts1@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=macromorgan@hotmail.com \
--cc=marcelo.schmitt1@gmail.com \
--cc=nuno.sa@analog.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
all inboxes | Powered by JetHome®