* [PATCH v2 0/2] iio: gyro: Add support for iam20380 sensor
@ 2024-11-15 22:37 Frank Li
2024-11-15 22:37 ` [PATCH v2 1/2] dt-bindings: iio: imu: mpu6050: Add invensense,iam20380 compatible string Frank Li
2024-11-15 22:37 ` [PATCH v2 2/2] iio: gyro: Add support for iam20380 sensor Frank Li
0 siblings, 2 replies; 7+ messages in thread
From: Frank Li @ 2024-11-15 22:37 UTC (permalink / raw)
To: Jean-Baptiste Maneyrol, Jonathan Cameron, Lars-Peter Clausen,
Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: linux-iio, devicetree, linux-kernel, Frank Li, Han Xu,
Conor Dooley
Add iam20380 sensor support.
- add binding doc
- Add support for the Invensense IAM20380 sensor to the MPU6050 driver. It is
similar to the IAM20680. But IAM20380 only supports gyro and WHOAMI
register data is difference
Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
Changes in v2:
- Add Conor Dooley's ack tag for binding doc
- use iio_chan_spec
- Add spi part
- Link to v1: https://lore.kernel.org/r/20241113-iam20380-v1-0-cae690c4674d@nxp.com
---
Han Xu (2):
dt-bindings: iio: imu: mpu6050: Add invensense,iam20380 compatible string
iio: gyro: Add support for iam20380 sensor
.../bindings/iio/imu/invensense,mpu6050.yaml | 1 +
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 25 ++++++++++++++++++++++
drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c | 6 ++++++
drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 2 ++
drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c | 5 +++++
5 files changed, 39 insertions(+)
---
base-commit: 28955f4fa2823e39f1ecfb3a37a364563527afbc
change-id: 20241112-iam20380-da900d806bf4
Best regards,
---
Frank Li <Frank.Li@nxp.com>
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH v2 1/2] dt-bindings: iio: imu: mpu6050: Add invensense,iam20380 compatible string 2024-11-15 22:37 [PATCH v2 0/2] iio: gyro: Add support for iam20380 sensor Frank Li @ 2024-11-15 22:37 ` Frank Li 2024-11-15 22:37 ` [PATCH v2 2/2] iio: gyro: Add support for iam20380 sensor Frank Li 1 sibling, 0 replies; 7+ messages in thread From: Frank Li @ 2024-11-15 22:37 UTC (permalink / raw) To: Jean-Baptiste Maneyrol, Jonathan Cameron, Lars-Peter Clausen, Rob Herring, Krzysztof Kozlowski, Conor Dooley Cc: linux-iio, devicetree, linux-kernel, Frank Li, Han Xu, Conor Dooley From: Han Xu <han.xu@nxp.com> Add compatible string "invensense,iam20380" for the Invensense IAM20380 sensor. The IAM20380 is similar to the IAM20680, but only supports gyro. Signed-off-by: Han Xu <han.xu@nxp.com> Acked-by: Conor Dooley <conor.dooley@microchip.com> Signed-off-by: Frank Li <Frank.Li@nxp.com> --- Documentation/devicetree/bindings/iio/imu/invensense,mpu6050.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/iio/imu/invensense,mpu6050.yaml b/Documentation/devicetree/bindings/iio/imu/invensense,mpu6050.yaml index f91954870a44c..0bce71529e34c 100644 --- a/Documentation/devicetree/bindings/iio/imu/invensense,mpu6050.yaml +++ b/Documentation/devicetree/bindings/iio/imu/invensense,mpu6050.yaml @@ -16,6 +16,7 @@ properties: compatible: oneOf: - enum: + - invensense,iam20380 - invensense,iam20680 - invensense,icm20608 - invensense,icm20609 -- 2.34.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 2/2] iio: gyro: Add support for iam20380 sensor 2024-11-15 22:37 [PATCH v2 0/2] iio: gyro: Add support for iam20380 sensor Frank Li 2024-11-15 22:37 ` [PATCH v2 1/2] dt-bindings: iio: imu: mpu6050: Add invensense,iam20380 compatible string Frank Li @ 2024-11-15 22:37 ` Frank Li 2024-11-20 11:05 ` Jean-Baptiste Maneyrol 1 sibling, 1 reply; 7+ messages in thread From: Frank Li @ 2024-11-15 22:37 UTC (permalink / raw) To: Jean-Baptiste Maneyrol, Jonathan Cameron, Lars-Peter Clausen, Rob Herring, Krzysztof Kozlowski, Conor Dooley Cc: linux-iio, devicetree, linux-kernel, Frank Li, Han Xu From: Han Xu <han.xu@nxp.com> Add support for the Invensense IAM20380 sensor to the MPU6050 driver. It is similar to the IAM20680. But IAM20380 only supports gyro and WHOAMI register data is difference. Signed-off-by: Han Xu <han.xu@nxp.com> Signed-off-by: Frank Li <Frank.Li@nxp.com> --- drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 25 +++++++++++++++++++++++++ drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c | 6 ++++++ drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 2 ++ drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c | 5 +++++ 4 files changed, 38 insertions(+) diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c index 40271352b02cf..a7535cbc214e9 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c @@ -277,6 +277,14 @@ static const struct inv_mpu6050_hw hw_info[] = { .temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE}, .startup_time = {INV_ICM20690_GYRO_STARTUP_TIME, INV_ICM20690_ACCEL_STARTUP_TIME}, }, + { .whoami = INV_IAM20380_WHOAMI_VALUE, + .name = "IAM20380", + .reg = ®_set_6500, + .config = &chip_config_6500, + .fifo_size = 512, + .temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE}, + .startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME}, + }, { .whoami = INV_IAM20680_WHOAMI_VALUE, .name = "IAM20680", @@ -1519,6 +1527,14 @@ static const struct iio_chan_spec inv_mpu6050_channels[] = { INV_MPU6050_CHAN(IIO_ACCEL, IIO_MOD_Z, INV_MPU6050_SCAN_ACCL_Z), }; +static const struct iio_chan_spec inv_iam20380_channels[] = { + IIO_CHAN_SOFT_TIMESTAMP(INV_MPU6050_SCAN_TIMESTAMP), + + INV_MPU6050_CHAN(IIO_ANGL_VEL, IIO_MOD_X, INV_MPU6050_SCAN_GYRO_X), + INV_MPU6050_CHAN(IIO_ANGL_VEL, IIO_MOD_Y, INV_MPU6050_SCAN_GYRO_Y), + INV_MPU6050_CHAN(IIO_ANGL_VEL, IIO_MOD_Z, INV_MPU6050_SCAN_GYRO_Z), +}; + static const struct iio_chan_spec inv_mpu6500_channels[] = { IIO_CHAN_SOFT_TIMESTAMP(INV_MPU6050_SCAN_TIMESTAMP), @@ -1623,6 +1639,10 @@ static const struct iio_chan_spec inv_mpu9250_channels[] = { | BIT(INV_MPU9X50_SCAN_MAGN_Y) \ | BIT(INV_MPU9X50_SCAN_MAGN_Z)) +static const unsigned long inv_iam20380_scan_masks[] = { + INV_MPU6050_SCAN_MASK_3AXIS_GYRO, +}; + static const unsigned long inv_mpu9x50_scan_masks[] = { /* 3-axis accel */ INV_MPU6050_SCAN_MASK_3AXIS_ACCEL, @@ -2026,6 +2046,11 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name, indio_dev->num_channels = ARRAY_SIZE(inv_mpu9250_channels); indio_dev->available_scan_masks = inv_mpu9x50_scan_masks; break; + case INV_IAM20380: + indio_dev->channels = inv_iam20380_channels; + indio_dev->num_channels = ARRAY_SIZE(inv_iam20380_channels); + indio_dev->available_scan_masks = inv_iam20380_scan_masks; + break; case INV_ICM20600: case INV_ICM20602: indio_dev->channels = inv_mpu6500_channels; diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c index 7a5926ba6b97d..62f7d16c2ddcb 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c @@ -34,6 +34,7 @@ static bool inv_mpu_i2c_aux_bus(struct device *dev) case INV_ICM20689: case INV_ICM20600: case INV_ICM20602: + case INV_IAM20380: case INV_IAM20680: /* no i2c auxiliary bus on the chip */ return false; @@ -187,6 +188,7 @@ static const struct i2c_device_id inv_mpu_id[] = { {"icm20600", INV_ICM20600}, {"icm20602", INV_ICM20602}, {"icm20690", INV_ICM20690}, + {"iam20380", INV_IAM20380}, {"iam20680", INV_IAM20680}, {"iam20680hp", INV_IAM20680HP}, {"iam20680ht", INV_IAM20680HT}, @@ -252,6 +254,10 @@ static const struct of_device_id inv_of_match[] = { .compatible = "invensense,icm20690", .data = (void *)INV_ICM20690 }, + { + .compatible = "invensense,iam20380", + .data = (void *)INV_IAM20380 + }, { .compatible = "invensense,iam20680", .data = (void *)INV_IAM20680 diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h index a6862cf426396..211901f8b8eb6 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h @@ -84,6 +84,7 @@ enum inv_devices { INV_ICM20600, INV_ICM20602, INV_ICM20690, + INV_IAM20380, INV_IAM20680, INV_IAM20680HP, INV_IAM20680HT, @@ -425,6 +426,7 @@ struct inv_mpu6050_state { #define INV_ICM20600_WHOAMI_VALUE 0x11 #define INV_ICM20602_WHOAMI_VALUE 0x12 #define INV_ICM20690_WHOAMI_VALUE 0x20 +#define INV_IAM20380_WHOAMI_VALUE 0xB5 #define INV_IAM20680_WHOAMI_VALUE 0xA9 #define INV_IAM20680HP_WHOAMI_VALUE 0xF8 #define INV_IAM20680HT_WHOAMI_VALUE 0xFA diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c index e6a291fcda958..cd54e9dbf99ce 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c @@ -79,6 +79,7 @@ static const struct spi_device_id inv_mpu_id[] = { {"icm20600", INV_ICM20600}, {"icm20602", INV_ICM20602}, {"icm20690", INV_ICM20690}, + {"iam20380", INV_IAM20380}, {"iam20680", INV_IAM20680}, {"iam20680hp", INV_IAM20680HP}, {"iam20680ht", INV_IAM20680HT}, @@ -140,6 +141,10 @@ static const struct of_device_id inv_of_match[] = { .compatible = "invensense,icm20690", .data = (void *)INV_ICM20690 }, + { + .compatible = "invensense,iam20380", + .data = (void *)INV_IAM20380 + }, { .compatible = "invensense,iam20680", .data = (void *)INV_IAM20680 -- 2.34.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/2] iio: gyro: Add support for iam20380 sensor 2024-11-15 22:37 ` [PATCH v2 2/2] iio: gyro: Add support for iam20380 sensor Frank Li @ 2024-11-20 11:05 ` Jean-Baptiste Maneyrol 2024-11-23 15:33 ` Jonathan Cameron 0 siblings, 1 reply; 7+ messages in thread From: Jean-Baptiste Maneyrol @ 2024-11-20 11:05 UTC (permalink / raw) To: Frank Li, Jonathan Cameron, Lars-Peter Clausen, Rob Herring, Krzysztof Kozlowski, Conor Dooley Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Han Xu Hello, overall looks good, but I've got one concern. The gyro bits used for scan mask are the same than other chips, meaning bits 4, 5, 6, and timestamp is bit 7, and these are the only bits since the chip is gyro only. Usually scan mask bits start at 0. I don't know if starting from 4 will work or not. Jonathan, do you know if this can be an issue? Thanks, JB ________________________________________ From: Frank Li <Frank.Li@nxp.com> Sent: Friday, November 15, 2024 23:37 To: Jean-Baptiste Maneyrol <Jean-Baptiste.Maneyrol@tdk.com>; Jonathan Cameron <jic23@kernel.org>; Lars-Peter Clausen <lars@metafoo.de>; Rob Herring <robh@kernel.org>; Krzysztof Kozlowski <krzk+dt@kernel.org>; Conor Dooley <conor+dt@kernel.org> Cc: linux-iio@vger.kernel.org <linux-iio@vger.kernel.org>; devicetree@vger.kernel.org <devicetree@vger.kernel.org>; linux-kernel@vger.kernel.org <linux-kernel@vger.kernel.org>; Frank Li <Frank.Li@nxp.com>; Han Xu <han.xu@nxp.com> Subject: [PATCH v2 2/2] iio: gyro: Add support for iam20380 sensor This Message Is From an External Sender This message came from outside your organization. From: Han Xu <han.xu@nxp.com> Add support for the Invensense IAM20380 sensor to the MPU6050 driver. It is similar to the IAM20680. But IAM20380 only supports gyro and WHOAMI register data is difference. Signed-off-by: Han Xu <han.xu@nxp.com> Signed-off-by: Frank Li <Frank.Li@nxp.com> --- drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 25 +++++++++++++++++++++++++ drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c | 6 ++++++ drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 2 ++ drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c | 5 +++++ 4 files changed, 38 insertions(+) diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c index 40271352b02cf..a7535cbc214e9 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c @@ -277,6 +277,14 @@ static const struct inv_mpu6050_hw hw_info[] = { .temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE}, .startup_time = {INV_ICM20690_GYRO_STARTUP_TIME, INV_ICM20690_ACCEL_STARTUP_TIME}, }, + { .whoami = INV_IAM20380_WHOAMI_VALUE, + .name = "IAM20380", + .reg = ®_set_6500, + .config = &chip_config_6500, + .fifo_size = 512, + .temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE}, + .startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME}, + }, { .whoami = INV_IAM20680_WHOAMI_VALUE, .name = "IAM20680", @@ -1519,6 +1527,14 @@ static const struct iio_chan_spec inv_mpu6050_channels[] = { INV_MPU6050_CHAN(IIO_ACCEL, IIO_MOD_Z, INV_MPU6050_SCAN_ACCL_Z), }; +static const struct iio_chan_spec inv_iam20380_channels[] = { + IIO_CHAN_SOFT_TIMESTAMP(INV_MPU6050_SCAN_TIMESTAMP), + + INV_MPU6050_CHAN(IIO_ANGL_VEL, IIO_MOD_X, INV_MPU6050_SCAN_GYRO_X), + INV_MPU6050_CHAN(IIO_ANGL_VEL, IIO_MOD_Y, INV_MPU6050_SCAN_GYRO_Y), + INV_MPU6050_CHAN(IIO_ANGL_VEL, IIO_MOD_Z, INV_MPU6050_SCAN_GYRO_Z), +}; + static const struct iio_chan_spec inv_mpu6500_channels[] = { IIO_CHAN_SOFT_TIMESTAMP(INV_MPU6050_SCAN_TIMESTAMP), @@ -1623,6 +1639,10 @@ static const struct iio_chan_spec inv_mpu9250_channels[] = { | BIT(INV_MPU9X50_SCAN_MAGN_Y) \ | BIT(INV_MPU9X50_SCAN_MAGN_Z)) +static const unsigned long inv_iam20380_scan_masks[] = { + INV_MPU6050_SCAN_MASK_3AXIS_GYRO, +}; + static const unsigned long inv_mpu9x50_scan_masks[] = { /* 3-axis accel */ INV_MPU6050_SCAN_MASK_3AXIS_ACCEL, @@ -2026,6 +2046,11 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name, indio_dev->num_channels = ARRAY_SIZE(inv_mpu9250_channels); indio_dev->available_scan_masks = inv_mpu9x50_scan_masks; break; + case INV_IAM20380: + indio_dev->channels = inv_iam20380_channels; + indio_dev->num_channels = ARRAY_SIZE(inv_iam20380_channels); + indio_dev->available_scan_masks = inv_iam20380_scan_masks; + break; case INV_ICM20600: case INV_ICM20602: indio_dev->channels = inv_mpu6500_channels; diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c index 7a5926ba6b97d..62f7d16c2ddcb 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c @@ -34,6 +34,7 @@ static bool inv_mpu_i2c_aux_bus(struct device *dev) case INV_ICM20689: case INV_ICM20600: case INV_ICM20602: + case INV_IAM20380: case INV_IAM20680: /* no i2c auxiliary bus on the chip */ return false; @@ -187,6 +188,7 @@ static const struct i2c_device_id inv_mpu_id[] = { {"icm20600", INV_ICM20600}, {"icm20602", INV_ICM20602}, {"icm20690", INV_ICM20690}, + {"iam20380", INV_IAM20380}, {"iam20680", INV_IAM20680}, {"iam20680hp", INV_IAM20680HP}, {"iam20680ht", INV_IAM20680HT}, @@ -252,6 +254,10 @@ static const struct of_device_id inv_of_match[] = { .compatible = "invensense,icm20690", .data = (void *)INV_ICM20690 }, + { + .compatible = "invensense,iam20380", + .data = (void *)INV_IAM20380 + }, { .compatible = "invensense,iam20680", .data = (void *)INV_IAM20680 diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h index a6862cf426396..211901f8b8eb6 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h @@ -84,6 +84,7 @@ enum inv_devices { INV_ICM20600, INV_ICM20602, INV_ICM20690, + INV_IAM20380, INV_IAM20680, INV_IAM20680HP, INV_IAM20680HT, @@ -425,6 +426,7 @@ struct inv_mpu6050_state { #define INV_ICM20600_WHOAMI_VALUE 0x11 #define INV_ICM20602_WHOAMI_VALUE 0x12 #define INV_ICM20690_WHOAMI_VALUE 0x20 +#define INV_IAM20380_WHOAMI_VALUE 0xB5 #define INV_IAM20680_WHOAMI_VALUE 0xA9 #define INV_IAM20680HP_WHOAMI_VALUE 0xF8 #define INV_IAM20680HT_WHOAMI_VALUE 0xFA diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c index e6a291fcda958..cd54e9dbf99ce 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c @@ -79,6 +79,7 @@ static const struct spi_device_id inv_mpu_id[] = { {"icm20600", INV_ICM20600}, {"icm20602", INV_ICM20602}, {"icm20690", INV_ICM20690}, + {"iam20380", INV_IAM20380}, {"iam20680", INV_IAM20680}, {"iam20680hp", INV_IAM20680HP}, {"iam20680ht", INV_IAM20680HT}, @@ -140,6 +141,10 @@ static const struct of_device_id inv_of_match[] = { .compatible = "invensense,icm20690", .data = (void *)INV_ICM20690 }, + { + .compatible = "invensense,iam20380", + .data = (void *)INV_IAM20380 + }, { .compatible = "invensense,iam20680", .data = (void *)INV_IAM20680 -- 2.34.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/2] iio: gyro: Add support for iam20380 sensor 2024-11-20 11:05 ` Jean-Baptiste Maneyrol @ 2024-11-23 15:33 ` Jonathan Cameron 2024-11-25 11:43 ` Jean-Baptiste Maneyrol 0 siblings, 1 reply; 7+ messages in thread From: Jonathan Cameron @ 2024-11-23 15:33 UTC (permalink / raw) To: Jean-Baptiste Maneyrol Cc: Frank Li, Lars-Peter Clausen, Rob Herring, Krzysztof Kozlowski, Conor Dooley, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Han Xu On Wed, 20 Nov 2024 11:05:23 +0000 Jean-Baptiste Maneyrol <Jean-Baptiste.Maneyrol@tdk.com> wrote: > Hello, > > overall looks good, but I've got one concern. > > The gyro bits used for scan mask are the same than other chips, meaning bits 4, 5, 6, and timestamp is bit 7, and these are the only bits since the chip is gyro only. Usually scan mask bits start at 0. I don't know if starting from 4 will work or not. > > Jonathan, > do you know if this can be an issue? Shouldn't be an issue. There are various drivers that do this. https://elixir.bootlin.com/linux/v6.12/source/drivers/iio/imu/adis16400.c#L821 was one example that I remembered as IIRC that driver was the motivation for these being sparse. Normally we just pack them together because it feels neat and tidy plus for high channel count devices means we can still use a single unsigned long for the channel bitmaps. It's not a requirement as such... Jonathan > > Thanks, > JB > > ________________________________________ > From: Frank Li <Frank.Li@nxp.com> > Sent: Friday, November 15, 2024 23:37 > To: Jean-Baptiste Maneyrol <Jean-Baptiste.Maneyrol@tdk.com>; Jonathan Cameron <jic23@kernel.org>; Lars-Peter Clausen <lars@metafoo.de>; Rob Herring <robh@kernel.org>; Krzysztof Kozlowski <krzk+dt@kernel.org>; Conor Dooley <conor+dt@kernel.org> > Cc: linux-iio@vger.kernel.org <linux-iio@vger.kernel.org>; devicetree@vger.kernel.org <devicetree@vger.kernel.org>; linux-kernel@vger.kernel.org <linux-kernel@vger.kernel.org>; Frank Li <Frank.Li@nxp.com>; Han Xu <han.xu@nxp.com> > Subject: [PATCH v2 2/2] iio: gyro: Add support for iam20380 sensor > > This Message Is From an External Sender > This message came from outside your organization. > > From: Han Xu <han.xu@nxp.com> > > Add support for the Invensense IAM20380 sensor to the MPU6050 driver. It is > similar to the IAM20680. But IAM20380 only supports gyro and WHOAMI > register data is difference. > > Signed-off-by: Han Xu <han.xu@nxp.com> > Signed-off-by: Frank Li <Frank.Li@nxp.com> > --- > drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 25 +++++++++++++++++++++++++ > drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c | 6 ++++++ > drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 2 ++ > drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c | 5 +++++ > 4 files changed, 38 insertions(+) > > diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c > index 40271352b02cf..a7535cbc214e9 100644 > --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c > +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c > @@ -277,6 +277,14 @@ static const struct inv_mpu6050_hw hw_info[] = { > .temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE}, > .startup_time = {INV_ICM20690_GYRO_STARTUP_TIME, INV_ICM20690_ACCEL_STARTUP_TIME}, > }, > + { .whoami = INV_IAM20380_WHOAMI_VALUE, > + .name = "IAM20380", > + .reg = ®_set_6500, > + .config = &chip_config_6500, > + .fifo_size = 512, > + .temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE}, > + .startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME}, > + }, > { > .whoami = INV_IAM20680_WHOAMI_VALUE, > .name = "IAM20680", > @@ -1519,6 +1527,14 @@ static const struct iio_chan_spec inv_mpu6050_channels[] = { > INV_MPU6050_CHAN(IIO_ACCEL, IIO_MOD_Z, INV_MPU6050_SCAN_ACCL_Z), > }; > > +static const struct iio_chan_spec inv_iam20380_channels[] = { > + IIO_CHAN_SOFT_TIMESTAMP(INV_MPU6050_SCAN_TIMESTAMP), > + > + INV_MPU6050_CHAN(IIO_ANGL_VEL, IIO_MOD_X, INV_MPU6050_SCAN_GYRO_X), > + INV_MPU6050_CHAN(IIO_ANGL_VEL, IIO_MOD_Y, INV_MPU6050_SCAN_GYRO_Y), > + INV_MPU6050_CHAN(IIO_ANGL_VEL, IIO_MOD_Z, INV_MPU6050_SCAN_GYRO_Z), > +}; > + > static const struct iio_chan_spec inv_mpu6500_channels[] = { > IIO_CHAN_SOFT_TIMESTAMP(INV_MPU6050_SCAN_TIMESTAMP), > > @@ -1623,6 +1639,10 @@ static const struct iio_chan_spec inv_mpu9250_channels[] = { > | BIT(INV_MPU9X50_SCAN_MAGN_Y) \ > | BIT(INV_MPU9X50_SCAN_MAGN_Z)) > > +static const unsigned long inv_iam20380_scan_masks[] = { > + INV_MPU6050_SCAN_MASK_3AXIS_GYRO, > +}; > + > static const unsigned long inv_mpu9x50_scan_masks[] = { > /* 3-axis accel */ > INV_MPU6050_SCAN_MASK_3AXIS_ACCEL, > @@ -2026,6 +2046,11 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name, > indio_dev->num_channels = ARRAY_SIZE(inv_mpu9250_channels); > indio_dev->available_scan_masks = inv_mpu9x50_scan_masks; > break; > + case INV_IAM20380: > + indio_dev->channels = inv_iam20380_channels; > + indio_dev->num_channels = ARRAY_SIZE(inv_iam20380_channels); > + indio_dev->available_scan_masks = inv_iam20380_scan_masks; > + break; > case INV_ICM20600: > case INV_ICM20602: > indio_dev->channels = inv_mpu6500_channels; > diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c > index 7a5926ba6b97d..62f7d16c2ddcb 100644 > --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c > +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c > @@ -34,6 +34,7 @@ static bool inv_mpu_i2c_aux_bus(struct device *dev) > case INV_ICM20689: > case INV_ICM20600: > case INV_ICM20602: > + case INV_IAM20380: > case INV_IAM20680: > /* no i2c auxiliary bus on the chip */ > return false; > @@ -187,6 +188,7 @@ static const struct i2c_device_id inv_mpu_id[] = { > {"icm20600", INV_ICM20600}, > {"icm20602", INV_ICM20602}, > {"icm20690", INV_ICM20690}, > + {"iam20380", INV_IAM20380}, > {"iam20680", INV_IAM20680}, > {"iam20680hp", INV_IAM20680HP}, > {"iam20680ht", INV_IAM20680HT}, > @@ -252,6 +254,10 @@ static const struct of_device_id inv_of_match[] = { > .compatible = "invensense,icm20690", > .data = (void *)INV_ICM20690 > }, > + { > + .compatible = "invensense,iam20380", > + .data = (void *)INV_IAM20380 > + }, > { > .compatible = "invensense,iam20680", > .data = (void *)INV_IAM20680 > diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h > index a6862cf426396..211901f8b8eb6 100644 > --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h > +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h > @@ -84,6 +84,7 @@ enum inv_devices { > INV_ICM20600, > INV_ICM20602, > INV_ICM20690, > + INV_IAM20380, > INV_IAM20680, > INV_IAM20680HP, > INV_IAM20680HT, > @@ -425,6 +426,7 @@ struct inv_mpu6050_state { > #define INV_ICM20600_WHOAMI_VALUE 0x11 > #define INV_ICM20602_WHOAMI_VALUE 0x12 > #define INV_ICM20690_WHOAMI_VALUE 0x20 > +#define INV_IAM20380_WHOAMI_VALUE 0xB5 > #define INV_IAM20680_WHOAMI_VALUE 0xA9 > #define INV_IAM20680HP_WHOAMI_VALUE 0xF8 > #define INV_IAM20680HT_WHOAMI_VALUE 0xFA > diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c > index e6a291fcda958..cd54e9dbf99ce 100644 > --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c > +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c > @@ -79,6 +79,7 @@ static const struct spi_device_id inv_mpu_id[] = { > {"icm20600", INV_ICM20600}, > {"icm20602", INV_ICM20602}, > {"icm20690", INV_ICM20690}, > + {"iam20380", INV_IAM20380}, > {"iam20680", INV_IAM20680}, > {"iam20680hp", INV_IAM20680HP}, > {"iam20680ht", INV_IAM20680HT}, > @@ -140,6 +141,10 @@ static const struct of_device_id inv_of_match[] = { > .compatible = "invensense,icm20690", > .data = (void *)INV_ICM20690 > }, > + { > + .compatible = "invensense,iam20380", > + .data = (void *)INV_IAM20380 > + }, > { > .compatible = "invensense,iam20680", > .data = (void *)INV_IAM20680 > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/2] iio: gyro: Add support for iam20380 sensor 2024-11-23 15:33 ` Jonathan Cameron @ 2024-11-25 11:43 ` Jean-Baptiste Maneyrol 2024-11-25 21:32 ` Jonathan Cameron 0 siblings, 1 reply; 7+ messages in thread From: Jean-Baptiste Maneyrol @ 2024-11-25 11:43 UTC (permalink / raw) To: Jonathan Cameron Cc: Frank Li, Lars-Peter Clausen, Rob Herring, Krzysztof Kozlowski, Conor Dooley, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Han Xu Hello, thanks for the confirmation, Jonathan. Then, it's good for me. Acked-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com> Thanks, JB ________________________________________ From: Jonathan Cameron <jic23@kernel.org> Sent: Saturday, November 23, 2024 16:33 To: Jean-Baptiste Maneyrol <Jean-Baptiste.Maneyrol@tdk.com> Cc: Frank Li <Frank.Li@nxp.com>; Lars-Peter Clausen <lars@metafoo.de>; Rob Herring <robh@kernel.org>; Krzysztof Kozlowski <krzk+dt@kernel.org>; Conor Dooley <conor+dt@kernel.org>; linux-iio@vger.kernel.org <linux-iio@vger.kernel.org>; devicetree@vger.kernel.org <devicetree@vger.kernel.org>; linux-kernel@vger.kernel.org <linux-kernel@vger.kernel.org>; Han Xu <han.xu@nxp.com> Subject: Re: [PATCH v2 2/2] iio: gyro: Add support for iam20380 sensor This Message Is From an External Sender This message came from outside your organization. On Wed, 20 Nov 2024 11:05:23 +0000 Jean-Baptiste Maneyrol <Jean-Baptiste.Maneyrol@tdk.com> wrote: > Hello, > > overall looks good, but I've got one concern. > > The gyro bits used for scan mask are the same than other chips, meaning bits 4, 5, 6, and timestamp is bit 7, and these are the only bits since the chip is gyro only. Usually scan mask bits start at 0. I don't know if starting from 4 will work or not. > > Jonathan, > do you know if this can be an issue? Shouldn't be an issue. There are various drivers that do this. https://urldefense.com/v3/__https://elixir.bootlin.com/linux/v6.12/source/drivers/iio/imu/adis16400.c*L821__;Iw!!FtrhtPsWDhZ6tw!BUKGdZqx3SyrRUYhJqLMYen_msXNlBLk9L5OacejstVPtdMCSpltGpI8mpXdrFctK2l-lAmLQE4lpEXq16X-Up4$[elixir[.]bootlin[.]com] was one example that I remembered as IIRC that driver was the motivation for these being sparse. Normally we just pack them together because it feels neat and tidy plus for high channel count devices means we can still use a single unsigned long for the channel bitmaps. It's not a requirement as such... Jonathan > > Thanks, > JB > > ________________________________________ > From: Frank Li <Frank.Li@nxp.com> > Sent: Friday, November 15, 2024 23:37 > To: Jean-Baptiste Maneyrol <Jean-Baptiste.Maneyrol@tdk.com>; Jonathan Cameron <jic23@kernel.org>; Lars-Peter Clausen <lars@metafoo.de>; Rob Herring <robh@kernel.org>; Krzysztof Kozlowski <krzk+dt@kernel.org>; Conor Dooley <conor+dt@kernel.org> > Cc: linux-iio@vger.kernel.org <linux-iio@vger.kernel.org>; devicetree@vger.kernel.org <devicetree@vger.kernel.org>; linux-kernel@vger.kernel.org <linux-kernel@vger.kernel.org>; Frank Li <Frank.Li@nxp.com>; Han Xu <han.xu@nxp.com> > Subject: [PATCH v2 2/2] iio: gyro: Add support for iam20380 sensor > > This Message Is From an External Sender > This message came from outside your organization. > > From: Han Xu <han.xu@nxp.com> > > Add support for the Invensense IAM20380 sensor to the MPU6050 driver. It is > similar to the IAM20680. But IAM20380 only supports gyro and WHOAMI > register data is difference. > > Signed-off-by: Han Xu <han.xu@nxp.com> > Signed-off-by: Frank Li <Frank.Li@nxp.com> > --- > drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 25 +++++++++++++++++++++++++ > drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c | 6 ++++++ > drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 2 ++ > drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c | 5 +++++ > 4 files changed, 38 insertions(+) > > diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c > index 40271352b02cf..a7535cbc214e9 100644 > --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c > +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c > @@ -277,6 +277,14 @@ static const struct inv_mpu6050_hw hw_info[] = { > .temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE}, > .startup_time = {INV_ICM20690_GYRO_STARTUP_TIME, INV_ICM20690_ACCEL_STARTUP_TIME}, > }, > + { .whoami = INV_IAM20380_WHOAMI_VALUE, > + .name = "IAM20380", > + .reg = ®_set_6500, > + .config = &chip_config_6500, > + .fifo_size = 512, > + .temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE}, > + .startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME}, > + }, > { > .whoami = INV_IAM20680_WHOAMI_VALUE, > .name = "IAM20680", > @@ -1519,6 +1527,14 @@ static const struct iio_chan_spec inv_mpu6050_channels[] = { > INV_MPU6050_CHAN(IIO_ACCEL, IIO_MOD_Z, INV_MPU6050_SCAN_ACCL_Z), > }; > > +static const struct iio_chan_spec inv_iam20380_channels[] = { > + IIO_CHAN_SOFT_TIMESTAMP(INV_MPU6050_SCAN_TIMESTAMP), > + > + INV_MPU6050_CHAN(IIO_ANGL_VEL, IIO_MOD_X, INV_MPU6050_SCAN_GYRO_X), > + INV_MPU6050_CHAN(IIO_ANGL_VEL, IIO_MOD_Y, INV_MPU6050_SCAN_GYRO_Y), > + INV_MPU6050_CHAN(IIO_ANGL_VEL, IIO_MOD_Z, INV_MPU6050_SCAN_GYRO_Z), > +}; > + > static const struct iio_chan_spec inv_mpu6500_channels[] = { > IIO_CHAN_SOFT_TIMESTAMP(INV_MPU6050_SCAN_TIMESTAMP), > > @@ -1623,6 +1639,10 @@ static const struct iio_chan_spec inv_mpu9250_channels[] = { > | BIT(INV_MPU9X50_SCAN_MAGN_Y) \ > | BIT(INV_MPU9X50_SCAN_MAGN_Z)) > > +static const unsigned long inv_iam20380_scan_masks[] = { > + INV_MPU6050_SCAN_MASK_3AXIS_GYRO, > +}; > + > static const unsigned long inv_mpu9x50_scan_masks[] = { > /* 3-axis accel */ > INV_MPU6050_SCAN_MASK_3AXIS_ACCEL, > @@ -2026,6 +2046,11 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name, > indio_dev->num_channels = ARRAY_SIZE(inv_mpu9250_channels); > indio_dev->available_scan_masks = inv_mpu9x50_scan_masks; > break; > + case INV_IAM20380: > + indio_dev->channels = inv_iam20380_channels; > + indio_dev->num_channels = ARRAY_SIZE(inv_iam20380_channels); > + indio_dev->available_scan_masks = inv_iam20380_scan_masks; > + break; > case INV_ICM20600: > case INV_ICM20602: > indio_dev->channels = inv_mpu6500_channels; > diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c > index 7a5926ba6b97d..62f7d16c2ddcb 100644 > --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c > +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c > @@ -34,6 +34,7 @@ static bool inv_mpu_i2c_aux_bus(struct device *dev) > case INV_ICM20689: > case INV_ICM20600: > case INV_ICM20602: > + case INV_IAM20380: > case INV_IAM20680: > /* no i2c auxiliary bus on the chip */ > return false; > @@ -187,6 +188,7 @@ static const struct i2c_device_id inv_mpu_id[] = { > {"icm20600", INV_ICM20600}, > {"icm20602", INV_ICM20602}, > {"icm20690", INV_ICM20690}, > + {"iam20380", INV_IAM20380}, > {"iam20680", INV_IAM20680}, > {"iam20680hp", INV_IAM20680HP}, > {"iam20680ht", INV_IAM20680HT}, > @@ -252,6 +254,10 @@ static const struct of_device_id inv_of_match[] = { > .compatible = "invensense,icm20690", > .data = (void *)INV_ICM20690 > }, > + { > + .compatible = "invensense,iam20380", > + .data = (void *)INV_IAM20380 > + }, > { > .compatible = "invensense,iam20680", > .data = (void *)INV_IAM20680 > diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h > index a6862cf426396..211901f8b8eb6 100644 > --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h > +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h > @@ -84,6 +84,7 @@ enum inv_devices { > INV_ICM20600, > INV_ICM20602, > INV_ICM20690, > + INV_IAM20380, > INV_IAM20680, > INV_IAM20680HP, > INV_IAM20680HT, > @@ -425,6 +426,7 @@ struct inv_mpu6050_state { > #define INV_ICM20600_WHOAMI_VALUE 0x11 > #define INV_ICM20602_WHOAMI_VALUE 0x12 > #define INV_ICM20690_WHOAMI_VALUE 0x20 > +#define INV_IAM20380_WHOAMI_VALUE 0xB5 > #define INV_IAM20680_WHOAMI_VALUE 0xA9 > #define INV_IAM20680HP_WHOAMI_VALUE 0xF8 > #define INV_IAM20680HT_WHOAMI_VALUE 0xFA > diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c > index e6a291fcda958..cd54e9dbf99ce 100644 > --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c > +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c > @@ -79,6 +79,7 @@ static const struct spi_device_id inv_mpu_id[] = { > {"icm20600", INV_ICM20600}, > {"icm20602", INV_ICM20602}, > {"icm20690", INV_ICM20690}, > + {"iam20380", INV_IAM20380}, > {"iam20680", INV_IAM20680}, > {"iam20680hp", INV_IAM20680HP}, > {"iam20680ht", INV_IAM20680HT}, > @@ -140,6 +141,10 @@ static const struct of_device_id inv_of_match[] = { > .compatible = "invensense,icm20690", > .data = (void *)INV_ICM20690 > }, > + { > + .compatible = "invensense,iam20380", > + .data = (void *)INV_IAM20380 > + }, > { > .compatible = "invensense,iam20680", > .data = (void *)INV_IAM20680 > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/2] iio: gyro: Add support for iam20380 sensor 2024-11-25 11:43 ` Jean-Baptiste Maneyrol @ 2024-11-25 21:32 ` Jonathan Cameron 0 siblings, 0 replies; 7+ messages in thread From: Jonathan Cameron @ 2024-11-25 21:32 UTC (permalink / raw) To: Jean-Baptiste Maneyrol Cc: Frank Li, Lars-Peter Clausen, Rob Herring, Krzysztof Kozlowski, Conor Dooley, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Han Xu On Mon, 25 Nov 2024 11:43:24 +0000 Jean-Baptiste Maneyrol <Jean-Baptiste.Maneyrol@tdk.com> wrote: > Hello, > > thanks for the confirmation, Jonathan. > > Then, it's good for me. > > Acked-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com> Applied. Thanks, J ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-11-25 21:33 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-11-15 22:37 [PATCH v2 0/2] iio: gyro: Add support for iam20380 sensor Frank Li 2024-11-15 22:37 ` [PATCH v2 1/2] dt-bindings: iio: imu: mpu6050: Add invensense,iam20380 compatible string Frank Li 2024-11-15 22:37 ` [PATCH v2 2/2] iio: gyro: Add support for iam20380 sensor Frank Li 2024-11-20 11:05 ` Jean-Baptiste Maneyrol 2024-11-23 15:33 ` Jonathan Cameron 2024-11-25 11:43 ` Jean-Baptiste Maneyrol 2024-11-25 21:32 ` Jonathan Cameron
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox