driver: mpu: to support mpu6881/mpu6880
authorZorro Liu <lyx@rock-chips.com>
Mon, 12 Jun 2017 09:48:04 +0000 (17:48 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Wed, 14 Jun 2017 01:29:49 +0000 (09:29 +0800)
Change-Id: I731788cd35d27d2aab946ccb22f744aad85f7be3
Signed-off-by: Zorro Liu <lyx@rock-chips.com>
drivers/staging/iio/imu/inv_mpu/inv_mpu_core.c
drivers/staging/iio/imu/inv_mpu/inv_mpu_iio.h
drivers/staging/iio/imu/inv_mpu/inv_mpu_misc.c

index 471317f7b59c86a9aa9995e1af54ce0e3f53ece6..3e7d07b463c3be8d3913b0ec6ef4caff31fa4fd1 100644 (file)
@@ -1762,6 +1762,7 @@ int inv_check_chip_type(struct inv_mpu_iio_s *st, const char *name)
        struct inv_reg_map_s *reg;
        int result;
        int t_ind;
+       int timeout = 10;
 
        if (!strcmp(name, "itg3500"))
                st->chip_type = INV_ITG3500;
@@ -1787,9 +1788,14 @@ int inv_check_chip_type(struct inv_mpu_iio_s *st, const char *name)
        reg = &st->reg;
        st->setup_reg(reg);
        /* reset to make sure previous state are not there */
-       result = inv_plat_single_write(st, reg->pwr_mgmt_1, BIT_H_RESET);
-       if (result)
-               return result;
+       while (timeout) {
+               result = inv_plat_single_write(st, reg->pwr_mgmt_1, BIT_H_RESET);
+               if (!result)
+                       break;
+               pr_err("inv_mpu: reset chip failed, err = %d\n", result);
+               timeout--;
+               msleep(POWER_UP_TIME);
+       }
        msleep(POWER_UP_TIME);
        /* toggle power state */
        result = st->set_power_state(st, false);
index 99f3ba6893556ac5092d6d6c9d0aa240a6e23575..92f59942512e6216e514d6ddf14b4f5b70f7743b 100644 (file)
@@ -647,6 +647,9 @@ struct inv_mpu_slave {
 /*---- MPU9250 ----*/
 #define MPU9250_ID               0x71      /* unique WHOAMI */
 
+/*---- MPU6880 ----*/
+#define MPU6880_ID               0x78      /* unique WHOAMI */
+
 #define THREE_AXIS               3
 #define GYRO_CONFIG_FSR_SHIFT    3
 #define ACCL_CONFIG_FSR_SHIFT    3
index 3f285e4f33a0afdb24cded3e74c4e06643a0ca3f..480dd95720ed6e0cec65e5a1abc1788585efb33b 100644 (file)
@@ -345,7 +345,7 @@ int inv_get_silicon_rev_mpu6500(struct inv_mpu_iio_s *st)
                if (result)
                        return result;
                if (whoami != MPU6500_ID && whoami != MPU9250_ID &&
-                               whoami != MPU6515_ID)
+                               whoami != MPU6515_ID && whoami != MPU6880_ID)
                        return -EINVAL;
 
                /*memory read need more time after power up */