Linux-IIO Archive on lore.kernel.org
 help / Atom feed
* [PATCH v2 1/2] dt-bindings: iio: imu: add icm20602 bindings to mpu6050
@ 2019-01-28 18:50 Randolph Maaßen
  2019-01-28 18:50 ` [PATCH v2 2/2] iio: imu: mpu6050: Add support for the ICM 20602 IMU Randolph Maaßen
  2019-01-30 19:49 ` [PATCH v2 1/2] dt-bindings: iio: imu: add icm20602 bindings to mpu6050 Rob Herring
  0 siblings, 2 replies; 5+ messages in thread
From: Randolph Maaßen @ 2019-01-28 18:50 UTC (permalink / raw)
  To: gaireg
  Cc: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Rob Herring, Mark Rutland, Brian Masney,
	Jonathan Marek, Douglas Fischer, Martin Kelly,
	Jean-Baptiste Maneyrol, Hans de Goede, linux-iio, devicetree,
	linux-kernel

Adding the invensense ICM-20602 to the compatible list of the mpu6050
driver

Signed-off-by: Randolph Maaßen <gaireg@gaireg.de>

---
Changes in v2:
- write i2c disable register using reg_set instead of define
- decide to write to i2c disable register based on reg_set instead of
  chip type
---
 Documentation/devicetree/bindings/iio/imu/inv_mpu6050.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/iio/imu/inv_mpu6050.txt b/Documentation/devicetree/bindings/iio/imu/inv_mpu6050.txt
index 6ab9a9d196b0..268bf7568e19 100644
--- a/Documentation/devicetree/bindings/iio/imu/inv_mpu6050.txt
+++ b/Documentation/devicetree/bindings/iio/imu/inv_mpu6050.txt
@@ -11,6 +11,7 @@ Required properties:
 		"invensense,mpu9250"
 		"invensense,mpu9255"
 		"invensense,icm20608"
+		"invensense,icm20602"
  - reg : the I2C address of the sensor
  - interrupts: interrupt mapping for IRQ. It should be configured with flags
    IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_EDGE_RISING, IRQ_TYPE_LEVEL_LOW or
-- 
2.11.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 2/2] iio: imu: mpu6050: Add support for the ICM 20602 IMU
  2019-01-28 18:50 [PATCH v2 1/2] dt-bindings: iio: imu: add icm20602 bindings to mpu6050 Randolph Maaßen
@ 2019-01-28 18:50 ` Randolph Maaßen
  2019-02-02  9:54   ` Jonathan Cameron
  2019-01-30 19:49 ` [PATCH v2 1/2] dt-bindings: iio: imu: add icm20602 bindings to mpu6050 Rob Herring
  1 sibling, 1 reply; 5+ messages in thread
From: Randolph Maaßen @ 2019-01-28 18:50 UTC (permalink / raw)
  To: gaireg
  Cc: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Rob Herring, Mark Rutland, Brian Masney,
	Jonathan Marek, Jean-Baptiste Maneyrol, Martin Kelly,
	Douglas Fischer, Hans de Goede, linux-iio, devicetree,
	linux-kernel

The Invensense ICM-20602 is a 6-axis MotionTracking device that
combines a 3-axis gyroscope and an 3-axis accelerometer. It is very
similar to the ICM-20608 imu which is already supported by the mpu6050
driver. The main difference is that the ICM-20602 has the i2c bus
disable bit in a separate register.

Signed-off-by: Randolph Maaßen <gaireg@gaireg.de>
---
 drivers/iio/imu/inv_mpu6050/Kconfig        |  8 ++++----
 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 31 ++++++++++++++++++++++++++++++
 drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c  |  6 ++++++
 drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h  |  8 ++++++++
 drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c  | 12 +++++++++---
 5 files changed, 58 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/imu/inv_mpu6050/Kconfig b/drivers/iio/imu/inv_mpu6050/Kconfig
index 5483b2ea754d..d2fe9dbddda7 100644
--- a/drivers/iio/imu/inv_mpu6050/Kconfig
+++ b/drivers/iio/imu/inv_mpu6050/Kconfig
@@ -13,8 +13,8 @@ config INV_MPU6050_I2C
 	select INV_MPU6050_IIO
 	select REGMAP_I2C
 	help
-	  This driver supports the Invensense MPU6050/6500/9150 and ICM20608
-	  motion tracking devices over I2C.
+	  This driver supports the Invensense MPU6050/6500/9150 and
+	  ICM20608/20602 motion tracking devices over I2C.
 	  This driver can be built as a module. The module will be called
 	  inv-mpu6050-i2c.
 
@@ -24,7 +24,7 @@ config INV_MPU6050_SPI
 	select INV_MPU6050_IIO
 	select REGMAP_SPI
 	help
-	  This driver supports the Invensense MPU6050/6500/9150 and ICM20608
-	  motion tracking devices over SPI.
+	  This driver supports the Invensense MPU6050/6500/9150 and
+	  ICM20608/20602 motion tracking devices over SPI.
 	  This driver can be built as a module. The module will be called
 	  inv-mpu6050-spi.
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index 1e428c196a82..650de0fefb7b 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -38,6 +38,29 @@ static const int gyro_scale_6050[] = {133090, 266181, 532362, 1064724};
  */
 static const int accel_scale[] = {598, 1196, 2392, 4785};
 
+static const struct inv_mpu6050_reg_map reg_set_icm20602 = {
+	.sample_rate_div	= INV_MPU6050_REG_SAMPLE_RATE_DIV,
+	.lpf                    = INV_MPU6050_REG_CONFIG,
+	.accel_lpf              = INV_MPU6500_REG_ACCEL_CONFIG_2,
+	.user_ctrl              = INV_MPU6050_REG_USER_CTRL,
+	.fifo_en                = INV_MPU6050_REG_FIFO_EN,
+	.gyro_config            = INV_MPU6050_REG_GYRO_CONFIG,
+	.accl_config            = INV_MPU6050_REG_ACCEL_CONFIG,
+	.fifo_count_h           = INV_MPU6050_REG_FIFO_COUNT_H,
+	.fifo_r_w               = INV_MPU6050_REG_FIFO_R_W,
+	.raw_gyro               = INV_MPU6050_REG_RAW_GYRO,
+	.raw_accl               = INV_MPU6050_REG_RAW_ACCEL,
+	.temperature            = INV_MPU6050_REG_TEMPERATURE,
+	.int_enable             = INV_MPU6050_REG_INT_ENABLE,
+	.int_status             = INV_MPU6050_REG_INT_STATUS,
+	.pwr_mgmt_1             = INV_MPU6050_REG_PWR_MGMT_1,
+	.pwr_mgmt_2             = INV_MPU6050_REG_PWR_MGMT_2,
+	.int_pin_cfg            = INV_MPU6050_REG_INT_PIN_CFG,
+	.accl_offset            = INV_MPU6500_REG_ACCEL_OFFSET,
+	.gyro_offset            = INV_MPU6050_REG_GYRO_OFFSET,
+	.i2c_if                 = INV_ICM20602_REG_I2C_IF,
+};
+
 static const struct inv_mpu6050_reg_map reg_set_6500 = {
 	.sample_rate_div	= INV_MPU6050_REG_SAMPLE_RATE_DIV,
 	.lpf                    = INV_MPU6050_REG_CONFIG,
@@ -58,6 +81,7 @@ static const struct inv_mpu6050_reg_map reg_set_6500 = {
 	.int_pin_cfg		= INV_MPU6050_REG_INT_PIN_CFG,
 	.accl_offset		= INV_MPU6500_REG_ACCEL_OFFSET,
 	.gyro_offset		= INV_MPU6050_REG_GYRO_OFFSET,
+	.i2c_if                 = 0,
 };
 
 static const struct inv_mpu6050_reg_map reg_set_6050 = {
@@ -78,6 +102,7 @@ static const struct inv_mpu6050_reg_map reg_set_6050 = {
 	.int_pin_cfg		= INV_MPU6050_REG_INT_PIN_CFG,
 	.accl_offset		= INV_MPU6050_REG_ACCEL_OFFSET,
 	.gyro_offset		= INV_MPU6050_REG_GYRO_OFFSET,
+	.i2c_if                 = 0,
 };
 
 static const struct inv_mpu6050_chip_config chip_config_6050 = {
@@ -140,6 +165,12 @@ static const struct inv_mpu6050_hw hw_info[] = {
 		.reg = &reg_set_6500,
 		.config = &chip_config_6050,
 	},
+	{
+		.whoami = INV_ICM20602_WHOAMI_VALUE,
+		.name = "ICM20602",
+		.reg = &reg_set_icm20602,
+		.config = &chip_config_6050,
+	},
 };
 
 int inv_mpu6050_switch_engine(struct inv_mpu6050_state *st, bool en, u32 mask)
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
index dd758e3d403d..e46eb4ddea21 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
@@ -127,6 +127,7 @@ static int inv_mpu_probe(struct i2c_client *client,
 	st = iio_priv(dev_get_drvdata(&client->dev));
 	switch (st->chip_type) {
 	case INV_ICM20608:
+	case INV_ICM20602:
 		/* no i2c auxiliary bus on the chip */
 		break;
 	default:
@@ -179,6 +180,7 @@ static const struct i2c_device_id inv_mpu_id[] = {
 	{"mpu9250", INV_MPU9250},
 	{"mpu9255", INV_MPU9255},
 	{"icm20608", INV_ICM20608},
+	{"icm20602", INV_ICM20602},
 	{}
 };
 
@@ -213,6 +215,10 @@ static const struct of_device_id inv_of_match[] = {
 		.compatible = "invensense,icm20608",
 		.data = (void *)INV_ICM20608
 	},
+	{
+		.compatible = "invensense,icm20602",
+		.data = (void *)INV_ICM20602
+	},
 	{ }
 };
 MODULE_DEVICE_TABLE(of, inv_of_match);
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
index 6bcc11fc1b88..325afd9f5f61 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
@@ -44,6 +44,7 @@
  *  @int_pin_cfg;	Controls interrupt pin configuration.
  *  @accl_offset:	Controls the accelerometer calibration offset.
  *  @gyro_offset:	Controls the gyroscope calibration offset.
+ *  @i2c_if:		Controls the i2c interface
  */
 struct inv_mpu6050_reg_map {
 	u8 sample_rate_div;
@@ -65,6 +66,7 @@ struct inv_mpu6050_reg_map {
 	u8 int_pin_cfg;
 	u8 accl_offset;
 	u8 gyro_offset;
+	u8 i2c_if;
 };
 
 /*device enum */
@@ -77,6 +79,7 @@ enum inv_devices {
 	INV_MPU9250,
 	INV_MPU9255,
 	INV_ICM20608,
+	INV_ICM20602,
 	INV_NUM_PARTS
 };
 
@@ -195,6 +198,10 @@ struct inv_mpu6050_state {
 #define INV_MPU6050_BIT_PWR_ACCL_STBY       0x38
 #define INV_MPU6050_BIT_PWR_GYRO_STBY       0x07
 
+/* ICM20602 register */
+#define INV_ICM20602_REG_I2C_IF             0x70
+#define INV_ICM20602_BIT_I2C_IF_DIS         0x40
+
 #define INV_MPU6050_REG_FIFO_COUNT_H        0x72
 #define INV_MPU6050_REG_FIFO_R_W            0x74
 
@@ -261,6 +268,7 @@ struct inv_mpu6050_state {
 #define INV_MPU9255_WHOAMI_VALUE		0x73
 #define INV_MPU6515_WHOAMI_VALUE		0x74
 #define INV_ICM20608_WHOAMI_VALUE		0xAF
+#define INV_ICM20602_WHOAMI_VALUE		0x12
 
 /* scan element definition */
 enum inv_mpu6050_scan {
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
index 227f50afff22..a112c3f45f74 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
@@ -31,9 +31,14 @@ static int inv_mpu_i2c_disable(struct iio_dev *indio_dev)
 	if (ret)
 		return ret;
 
-	st->chip_config.user_ctrl |= INV_MPU6050_BIT_I2C_IF_DIS;
-	ret = regmap_write(st->map, st->reg->user_ctrl,
-			   st->chip_config.user_ctrl);
+	if (st->reg->i2c_if) {
+		ret = regmap_write(st->map, st->reg->i2c_if,
+				   INV_ICM20602_BIT_I2C_IF_DIS);
+	} else {
+		st->chip_config.user_ctrl |= INV_MPU6050_BIT_I2C_IF_DIS;
+		ret = regmap_write(st->map, st->reg->user_ctrl,
+				   st->chip_config.user_ctrl);
+	}
 	if (ret) {
 		inv_mpu6050_set_power_itg(st, false);
 		return ret;
@@ -81,6 +86,7 @@ static const struct spi_device_id inv_mpu_id[] = {
 	{"mpu9250", INV_MPU9250},
 	{"mpu9255", INV_MPU9255},
 	{"icm20608", INV_ICM20608},
+	{"icm20602", INV_ICM20602},
 	{}
 };
 
-- 
2.11.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 1/2] dt-bindings: iio: imu: add icm20602 bindings to mpu6050
  2019-01-28 18:50 [PATCH v2 1/2] dt-bindings: iio: imu: add icm20602 bindings to mpu6050 Randolph Maaßen
  2019-01-28 18:50 ` [PATCH v2 2/2] iio: imu: mpu6050: Add support for the ICM 20602 IMU Randolph Maaßen
@ 2019-01-30 19:49 ` Rob Herring
  2019-02-02  9:52   ` Jonathan Cameron
  1 sibling, 1 reply; 5+ messages in thread
From: Rob Herring @ 2019-01-30 19:49 UTC (permalink / raw)
  To: Randolph Maaßen
  Cc: gaireg, Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Mark Rutland, Brian Masney,
	Jonathan Marek, Douglas Fischer, Martin Kelly,
	Jean-Baptiste Maneyrol, Hans de Goede, linux-iio, devicetree,
	linux-kernel

On Mon, 28 Jan 2019 19:50:02 +0100, =?UTF-8?q?Randolph=20Maa=C3=9Fen?= wrote:
> Adding the invensense ICM-20602 to the compatible list of the mpu6050
> driver
> 
> Signed-off-by: Randolph Maaßen <gaireg@gaireg.de>
> 
> ---
> Changes in v2:
> - write i2c disable register using reg_set instead of define
> - decide to write to i2c disable register based on reg_set instead of
>   chip type
> ---
>  Documentation/devicetree/bindings/iio/imu/inv_mpu6050.txt | 1 +
>  1 file changed, 1 insertion(+)
> 

Reviewed-by: Rob Herring <robh@kernel.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 1/2] dt-bindings: iio: imu: add icm20602 bindings to mpu6050
  2019-01-30 19:49 ` [PATCH v2 1/2] dt-bindings: iio: imu: add icm20602 bindings to mpu6050 Rob Herring
@ 2019-02-02  9:52   ` Jonathan Cameron
  0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2019-02-02  9:52 UTC (permalink / raw)
  To: Rob Herring
  Cc: Randolph Maaßen, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Mark Rutland, Brian Masney,
	Jonathan Marek, Douglas Fischer, Martin Kelly,
	Jean-Baptiste Maneyrol, Hans de Goede, linux-iio, devicetree,
	linux-kernel

On Wed, 30 Jan 2019 13:49:42 -0600
Rob Herring <robh@kernel.org> wrote:

> On Mon, 28 Jan 2019 19:50:02 +0100, =?UTF-8?q?Randolph=20Maa=C3=9Fen?= wrote:
> > Adding the invensense ICM-20602 to the compatible list of the mpu6050
> > driver
> > 
> > Signed-off-by: Randolph Maaßen <gaireg@gaireg.de>
> > 
> > ---
> > Changes in v2:
> > - write i2c disable register using reg_set instead of define
> > - decide to write to i2c disable register based on reg_set instead of
> >   chip type
> > ---
> >  Documentation/devicetree/bindings/iio/imu/inv_mpu6050.txt | 1 +
> >  1 file changed, 1 insertion(+)
> >   
> 
> Reviewed-by: Rob Herring <robh@kernel.org>
Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to play with it.

Thanks,

Jonathan



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 2/2] iio: imu: mpu6050: Add support for the ICM 20602 IMU
  2019-01-28 18:50 ` [PATCH v2 2/2] iio: imu: mpu6050: Add support for the ICM 20602 IMU Randolph Maaßen
@ 2019-02-02  9:54   ` Jonathan Cameron
  0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2019-02-02  9:54 UTC (permalink / raw)
  To: Randolph Maaßen
  Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Mark Rutland, Brian Masney, Jonathan Marek,
	Jean-Baptiste Maneyrol, Martin Kelly, Douglas Fischer,
	Hans de Goede, linux-iio, devicetree, linux-kernel

On Mon, 28 Jan 2019 19:50:03 +0100
Randolph Maaßen <gaireg@gaireg.de> wrote:

> The Invensense ICM-20602 is a 6-axis MotionTracking device that
> combines a 3-axis gyroscope and an 3-axis accelerometer. It is very
> similar to the ICM-20608 imu which is already supported by the mpu6050
> driver. The main difference is that the ICM-20602 has the i2c bus
> disable bit in a separate register.
> 
> Signed-off-by: Randolph Maaßen <gaireg@gaireg.de>
I'm not sure this particular approach will prove extensible for
future devices (seems likely that the bit may move around within
the 'different' register) but who knows and we can deal with that
when it happens.

Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to play with it.

Thanks

Jonathan

> ---
>  drivers/iio/imu/inv_mpu6050/Kconfig        |  8 ++++----
>  drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 31 ++++++++++++++++++++++++++++++
>  drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c  |  6 ++++++
>  drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h  |  8 ++++++++
>  drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c  | 12 +++++++++---
>  5 files changed, 58 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/iio/imu/inv_mpu6050/Kconfig b/drivers/iio/imu/inv_mpu6050/Kconfig
> index 5483b2ea754d..d2fe9dbddda7 100644
> --- a/drivers/iio/imu/inv_mpu6050/Kconfig
> +++ b/drivers/iio/imu/inv_mpu6050/Kconfig
> @@ -13,8 +13,8 @@ config INV_MPU6050_I2C
>  	select INV_MPU6050_IIO
>  	select REGMAP_I2C
>  	help
> -	  This driver supports the Invensense MPU6050/6500/9150 and ICM20608
> -	  motion tracking devices over I2C.
> +	  This driver supports the Invensense MPU6050/6500/9150 and
> +	  ICM20608/20602 motion tracking devices over I2C.
>  	  This driver can be built as a module. The module will be called
>  	  inv-mpu6050-i2c.
>  
> @@ -24,7 +24,7 @@ config INV_MPU6050_SPI
>  	select INV_MPU6050_IIO
>  	select REGMAP_SPI
>  	help
> -	  This driver supports the Invensense MPU6050/6500/9150 and ICM20608
> -	  motion tracking devices over SPI.
> +	  This driver supports the Invensense MPU6050/6500/9150 and
> +	  ICM20608/20602 motion tracking devices over SPI.
>  	  This driver can be built as a module. The module will be called
>  	  inv-mpu6050-spi.
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> index 1e428c196a82..650de0fefb7b 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> @@ -38,6 +38,29 @@ static const int gyro_scale_6050[] = {133090, 266181, 532362, 1064724};
>   */
>  static const int accel_scale[] = {598, 1196, 2392, 4785};
>  
> +static const struct inv_mpu6050_reg_map reg_set_icm20602 = {
> +	.sample_rate_div	= INV_MPU6050_REG_SAMPLE_RATE_DIV,
> +	.lpf                    = INV_MPU6050_REG_CONFIG,
> +	.accel_lpf              = INV_MPU6500_REG_ACCEL_CONFIG_2,
> +	.user_ctrl              = INV_MPU6050_REG_USER_CTRL,
> +	.fifo_en                = INV_MPU6050_REG_FIFO_EN,
> +	.gyro_config            = INV_MPU6050_REG_GYRO_CONFIG,
> +	.accl_config            = INV_MPU6050_REG_ACCEL_CONFIG,
> +	.fifo_count_h           = INV_MPU6050_REG_FIFO_COUNT_H,
> +	.fifo_r_w               = INV_MPU6050_REG_FIFO_R_W,
> +	.raw_gyro               = INV_MPU6050_REG_RAW_GYRO,
> +	.raw_accl               = INV_MPU6050_REG_RAW_ACCEL,
> +	.temperature            = INV_MPU6050_REG_TEMPERATURE,
> +	.int_enable             = INV_MPU6050_REG_INT_ENABLE,
> +	.int_status             = INV_MPU6050_REG_INT_STATUS,
> +	.pwr_mgmt_1             = INV_MPU6050_REG_PWR_MGMT_1,
> +	.pwr_mgmt_2             = INV_MPU6050_REG_PWR_MGMT_2,
> +	.int_pin_cfg            = INV_MPU6050_REG_INT_PIN_CFG,
> +	.accl_offset            = INV_MPU6500_REG_ACCEL_OFFSET,
> +	.gyro_offset            = INV_MPU6050_REG_GYRO_OFFSET,
> +	.i2c_if                 = INV_ICM20602_REG_I2C_IF,
> +};
> +
>  static const struct inv_mpu6050_reg_map reg_set_6500 = {
>  	.sample_rate_div	= INV_MPU6050_REG_SAMPLE_RATE_DIV,
>  	.lpf                    = INV_MPU6050_REG_CONFIG,
> @@ -58,6 +81,7 @@ static const struct inv_mpu6050_reg_map reg_set_6500 = {
>  	.int_pin_cfg		= INV_MPU6050_REG_INT_PIN_CFG,
>  	.accl_offset		= INV_MPU6500_REG_ACCEL_OFFSET,
>  	.gyro_offset		= INV_MPU6050_REG_GYRO_OFFSET,
> +	.i2c_if                 = 0,
>  };
>  
>  static const struct inv_mpu6050_reg_map reg_set_6050 = {
> @@ -78,6 +102,7 @@ static const struct inv_mpu6050_reg_map reg_set_6050 = {
>  	.int_pin_cfg		= INV_MPU6050_REG_INT_PIN_CFG,
>  	.accl_offset		= INV_MPU6050_REG_ACCEL_OFFSET,
>  	.gyro_offset		= INV_MPU6050_REG_GYRO_OFFSET,
> +	.i2c_if                 = 0,
>  };
>  
>  static const struct inv_mpu6050_chip_config chip_config_6050 = {
> @@ -140,6 +165,12 @@ static const struct inv_mpu6050_hw hw_info[] = {
>  		.reg = &reg_set_6500,
>  		.config = &chip_config_6050,
>  	},
> +	{
> +		.whoami = INV_ICM20602_WHOAMI_VALUE,
> +		.name = "ICM20602",
> +		.reg = &reg_set_icm20602,
> +		.config = &chip_config_6050,
> +	},
>  };
>  
>  int inv_mpu6050_switch_engine(struct inv_mpu6050_state *st, bool en, u32 mask)
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
> index dd758e3d403d..e46eb4ddea21 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
> @@ -127,6 +127,7 @@ static int inv_mpu_probe(struct i2c_client *client,
>  	st = iio_priv(dev_get_drvdata(&client->dev));
>  	switch (st->chip_type) {
>  	case INV_ICM20608:
> +	case INV_ICM20602:
>  		/* no i2c auxiliary bus on the chip */
>  		break;
>  	default:
> @@ -179,6 +180,7 @@ static const struct i2c_device_id inv_mpu_id[] = {
>  	{"mpu9250", INV_MPU9250},
>  	{"mpu9255", INV_MPU9255},
>  	{"icm20608", INV_ICM20608},
> +	{"icm20602", INV_ICM20602},
>  	{}
>  };
>  
> @@ -213,6 +215,10 @@ static const struct of_device_id inv_of_match[] = {
>  		.compatible = "invensense,icm20608",
>  		.data = (void *)INV_ICM20608
>  	},
> +	{
> +		.compatible = "invensense,icm20602",
> +		.data = (void *)INV_ICM20602
> +	},
>  	{ }
>  };
>  MODULE_DEVICE_TABLE(of, inv_of_match);
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> index 6bcc11fc1b88..325afd9f5f61 100644
> --- a/drivers/iio/imu/inv_mpu6050i2c_i/inv_mpu_iio.h
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> @@ -44,6 +44,7 @@
>   *  @int_pin_cfg;	Controls interrupt pin configuration.
>   *  @accl_offset:	Controls the accelerometer calibration offset.
>   *  @gyro_offset:	Controls the gyroscope calibration offset.
> + *  @i2c_if:		Controls the i2c interface
>   */
>  struct inv_mpu6050_reg_map {
>  	u8 sample_rate_div;
> @@ -65,6 +66,7 @@ struct inv_mpu6050_reg_map {
>  	u8 int_pin_cfg;
>  	u8 accl_offset;
>  	u8 gyro_offset;
> +	u8 i2c_if;
>  };
>  
>  /*device enum */
> @@ -77,6 +79,7 @@ enum inv_devices {
>  	INV_MPU9250,
>  	INV_MPU9255,
>  	INV_ICM20608,
> +	INV_ICM20602,
>  	INV_NUM_PARTS
>  };
>  
> @@ -195,6 +198,10 @@ struct inv_mpu6050_state {
>  #define INV_MPU6050_BIT_PWR_ACCL_STBY       0x38
>  #define INV_MPU6050_BIT_PWR_GYRO_STBY       0x07
>  
> +/* ICM20602 register */
> +#define INV_ICM20602_REG_I2C_IF             0x70
> +#define INV_ICM20602_BIT_I2C_IF_DIS         0x40
> +
>  #define INV_MPU6050_REG_FIFO_COUNT_H        0x72
>  #define INV_MPU6050_REG_FIFO_R_W            0x74
>  
> @@ -261,6 +268,7 @@ struct inv_mpu6050_state {
>  #define INV_MPU9255_WHOAMI_VALUE		0x73
>  #define INV_MPU6515_WHOAMI_VALUE		0x74
>  #define INV_ICM20608_WHOAMI_VALUE		0xAF
> +#define INV_ICM20602_WHOAMI_VALUE		0x12
>  
>  /* scan element definition */
>  enum inv_mpu6050_scan {
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
> index 227f50afff22..a112c3f45f74 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
> @@ -31,9 +31,14 @@ static int inv_mpu_i2c_disable(struct iio_dev *indio_dev)
>  	if (ret)
>  		return ret;
>  
> -	st->chip_config.user_ctrl |= INV_MPU6050_BIT_I2C_IF_DIS;
> -	ret = regmap_write(st->map, st->reg->user_ctrl,
> -			   st->chip_config.user_ctrl);
> +	if (st->reg->i2c_if) {
> +		ret = regmap_write(st->map, st->reg->i2c_if,
> +				   INV_ICM20602_BIT_I2C_IF_DIS);
> +	} else {
> +		st->chip_config.user_ctrl |= INV_MPU6050_BIT_I2C_IF_DIS;
> +		ret = regmap_write(st->map, st->reg->user_ctrl,
> +				   st->chip_config.user_ctrl);
> +	}
>  	if (ret) {
>  		inv_mpu6050_set_power_itg(st, false);
>  		return ret;
> @@ -81,6 +86,7 @@ static const struct spi_device_id inv_mpu_id[] = {
>  	{"mpu9250", INV_MPU9250},
>  	{"mpu9255", INV_MPU9255},
>  	{"icm20608", INV_ICM20608},
> +	{"icm20602", INV_ICM20602},
>  	{}
>  };
>  


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-28 18:50 [PATCH v2 1/2] dt-bindings: iio: imu: add icm20602 bindings to mpu6050 Randolph Maaßen
2019-01-28 18:50 ` [PATCH v2 2/2] iio: imu: mpu6050: Add support for the ICM 20602 IMU Randolph Maaßen
2019-02-02  9:54   ` Jonathan Cameron
2019-01-30 19:49 ` [PATCH v2 1/2] dt-bindings: iio: imu: add icm20602 bindings to mpu6050 Rob Herring
2019-02-02  9:52   ` Jonathan Cameron

Linux-IIO Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-iio/0 linux-iio/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-iio linux-iio/ https://lore.kernel.org/linux-iio \
		linux-iio@vger.kernel.org linux-iio@archiver.kernel.org
	public-inbox-index linux-iio


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-iio


AGPL code for this site: git clone https://public-inbox.org/ public-inbox