Re: [PATCH 2/2] iio: imu: mpu6050: Add support for the ICM 20602 IMU
Hi, first, thanks for the review. Am Samstag, den 26.01.2019, 20:05 + schrieb Jonathan Cameron: > On Tue, 22 Jan 2019 13:02:14 +0100 > Randolph Maaßen 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 > > There is a slight oddity in here, in that you introduce a > field in the chip info to describe the register to control the i2c disable > but then don't actually use it in the code. > > You should check if that is 0 and if not, write the separate > register it provides. I see, i mixed the register handling up. I intended to use the variable in the inv_mpu_i2c_disable function but used the define there. I'll send a v2 Randolph > > Jonathan > > --- > > drivers/iio/imu/inv_mpu6050/Kconfig| 8 > > drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 29 > > + > > 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, 56 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..01c856417d8f 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, > > @@ -140,6 +163,12 @@ static const struct inv_mpu6050_hw hw_info[] = { > > .reg = _set_6500, > > .config = _config_6050, > > }, > > + { > > + .whoami = INV_ICM20602_WHOAMI_VALUE, > > + .name = "ICM20602", > > + .reg = _set_icm20602, > > + .config = _config_6050, > > + }, > > }; > > > > int inv_mpu6050_switch_engine(struct inv_mpu6050_state *st, bool en, u32 > > mask) > > diff --git
Re: [PATCH 2/2] iio: imu: mpu6050: Add support for the ICM 20602 IMU
On Tue, 22 Jan 2019 13:02:14 +0100 Randolph Maaßen 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 There is a slight oddity in here, in that you introduce a field in the chip info to describe the register to control the i2c disable but then don't actually use it in the code. You should check if that is 0 and if not, write the separate register it provides. Jonathan > --- > drivers/iio/imu/inv_mpu6050/Kconfig| 8 > drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 29 + > 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, 56 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..01c856417d8f 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, > @@ -140,6 +163,12 @@ static const struct inv_mpu6050_hw hw_info[] = { > .reg = _set_6500, > .config = _config_6050, > }, > + { > + .whoami = INV_ICM20602_WHOAMI_VALUE, > + .name = "ICM20602", > + .reg = _set_icm20602, > + .config = _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(>dev)); > switch (st->chip_type) { > case
[PATCH 2/2] iio: imu: mpu6050: Add support for the ICM 20602 IMU
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 --- drivers/iio/imu/inv_mpu6050/Kconfig| 8 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 29 + 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, 56 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..01c856417d8f 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, @@ -140,6 +163,12 @@ static const struct inv_mpu6050_hw hw_info[] = { .reg = _set_6500, .config = _config_6050, }, + { + .whoami = INV_ICM20602_WHOAMI_VALUE, + .name = "ICM20602", + .reg = _set_icm20602, + .config = _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(>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[] = {