iio: imu: inv_mpu6050: add support of ICM20609 & ICM20689
authorJean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Thu, 6 Feb 2020 10:31:01 +0000 (11:31 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Fri, 14 Feb 2020 15:06:25 +0000 (15:06 +0000)
They are similar to ICM20608 chip.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/imu/inv_mpu6050/Kconfig
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c

index 003134734646bb5d903d65500a32493e35428af5..e933db3a5a8987bbb6b8da4f4514545d7e59d505 100644 (file)
@@ -16,8 +16,8 @@ config INV_MPU6050_I2C
        select REGMAP_I2C
        help
          This driver supports the Invensense MPU6050/9150,
-         MPU6500/6515/9250/9255, ICM20608 and ICM20602 motion tracking devices
-         over I2C.
+         MPU6500/6515/9250/9255, ICM20608/20609/20689 and ICM20602
+         motion tracking devices over I2C.
          This driver can be built as a module. The module will be called
          inv-mpu6050-i2c.
 
@@ -28,7 +28,7 @@ config INV_MPU6050_SPI
        select REGMAP_SPI
        help
          This driver supports the Invensense MPU6000,
-         MPU6500/6515/9250/9255, ICM20608 and ICM20602 motion tracking devices
-         over SPI.
+         MPU6500/6515/9250/9255, ICM20608/20609/20689 and ICM20602
+         motion tracking devices over SPI.
          This driver can be built as a module. The module will be called
          inv-mpu6050-spi.
index 5096fc49012dd813ff56e7ffe2ae37d6bdc68626..5fd57a1bee906f2667b9d2e90e72e0d128d87fb9 100644 (file)
@@ -176,6 +176,22 @@ static const struct inv_mpu6050_hw hw_info[] = {
                .fifo_size = 512,
                .temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
        },
+       {
+               .whoami = INV_ICM20609_WHOAMI_VALUE,
+               .name = "ICM20609",
+               .reg = &reg_set_6500,
+               .config = &chip_config_6050,
+               .fifo_size = 4 * 1024,
+               .temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
+       },
+       {
+               .whoami = INV_ICM20689_WHOAMI_VALUE,
+               .name = "ICM20689",
+               .reg = &reg_set_6500,
+               .config = &chip_config_6050,
+               .fifo_size = 4 * 1024,
+               .temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
+       },
        {
                .whoami = INV_ICM20602_WHOAMI_VALUE,
                .name = "ICM20602",
@@ -286,20 +302,22 @@ static int inv_mpu6050_set_lpf_regs(struct inv_mpu6050_state *st,
        if (result)
                return result;
 
+       /* set accel lpf */
        switch (st->chip_type) {
        case INV_MPU6050:
        case INV_MPU6000:
        case INV_MPU9150:
                /* old chips, nothing to do */
-               result = 0;
+               return 0;
+       case INV_ICM20689:
+               /* set FIFO size to maximum value */
+               val |= INV_ICM20689_BITS_FIFO_SIZE_MAX;
                break;
        default:
-               /* set accel lpf */
-               result = regmap_write(st->map, st->reg->accel_lpf, val);
                break;
        }
 
-       return result;
+       return regmap_write(st->map, st->reg->accel_lpf, val);
 }
 
 /**
index 49e9aa777ba4d93cfbd4f55cb12e0cff7717d5cc..dd054e21216a2671a4f1a9ad84438865ad928f3e 100644 (file)
@@ -61,6 +61,8 @@ static bool inv_mpu_i2c_aux_bus(struct device *dev)
 
        switch (st->chip_type) {
        case INV_ICM20608:
+       case INV_ICM20609:
+       case INV_ICM20689:
        case INV_ICM20602:
                /* no i2c auxiliary bus on the chip */
                return false;
@@ -202,6 +204,8 @@ static const struct i2c_device_id inv_mpu_id[] = {
        {"mpu9250", INV_MPU9250},
        {"mpu9255", INV_MPU9255},
        {"icm20608", INV_ICM20608},
+       {"icm20609", INV_ICM20609},
+       {"icm20689", INV_ICM20689},
        {"icm20602", INV_ICM20602},
        {}
 };
@@ -237,6 +241,14 @@ static const struct of_device_id inv_of_match[] = {
                .compatible = "invensense,icm20608",
                .data = (void *)INV_ICM20608
        },
+       {
+               .compatible = "invensense,icm20609",
+               .data = (void *)INV_ICM20609
+       },
+       {
+               .compatible = "invensense,icm20689",
+               .data = (void *)INV_ICM20689
+       },
        {
                .compatible = "invensense,icm20602",
                .data = (void *)INV_ICM20602
index 6158fca7f70e82eb499c47042478099a3c258467..75b8903450ebe4a84d38aed9c252b48f49be64bc 100644 (file)
@@ -75,6 +75,8 @@ enum inv_devices {
        INV_MPU9250,
        INV_MPU9255,
        INV_ICM20608,
+       INV_ICM20609,
+       INV_ICM20689,
        INV_ICM20602,
        INV_NUM_PARTS
 };
@@ -276,6 +278,7 @@ struct inv_mpu6050_state {
 
 /* mpu6500 registers */
 #define INV_MPU6500_REG_ACCEL_CONFIG_2      0x1D
+#define INV_ICM20689_BITS_FIFO_SIZE_MAX     0xC0
 #define INV_MPU6500_REG_ACCEL_OFFSET        0x77
 
 /* delay time in milliseconds */
@@ -340,6 +343,8 @@ struct inv_mpu6050_state {
 #define INV_MPU9255_WHOAMI_VALUE               0x73
 #define INV_MPU6515_WHOAMI_VALUE               0x74
 #define INV_ICM20608_WHOAMI_VALUE              0xAF
+#define INV_ICM20609_WHOAMI_VALUE              0xA6
+#define INV_ICM20689_WHOAMI_VALUE              0x98
 #define INV_ICM20602_WHOAMI_VALUE              0x12
 
 /* scan element definition for generic MPU6xxx devices */
index 834bfa8e86847216f07b40df3b6e6591a9bcf631..3803c40e7b24200c5485f0e729cfe46158b4dd2d 100644 (file)
@@ -81,6 +81,8 @@ static const struct spi_device_id inv_mpu_id[] = {
        {"mpu9250", INV_MPU9250},
        {"mpu9255", INV_MPU9255},
        {"icm20608", INV_ICM20608},
+       {"icm20609", INV_ICM20609},
+       {"icm20689", INV_ICM20689},
        {"icm20602", INV_ICM20602},
        {}
 };
@@ -112,6 +114,14 @@ static const struct of_device_id inv_of_match[] = {
                .compatible = "invensense,icm20608",
                .data = (void *)INV_ICM20608
        },
+       {
+               .compatible = "invensense,icm20609",
+               .data = (void *)INV_ICM20609
+       },
+       {
+               .compatible = "invensense,icm20689",
+               .data = (void *)INV_ICM20689
+       },
        {
                .compatible = "invensense,icm20602",
                .data = (void *)INV_ICM20602