From: Zorro Liu Date: Mon, 12 Jun 2017 09:48:04 +0000 (+0800) Subject: driver: mpu: to support mpu6881/mpu6880 X-Git-Tag: release-20171130_firefly~4^2~406 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=7943fd79eac9ac461aa3cd061f0d7b8bb06e695d;p=firefly-linux-kernel-4.4.55.git driver: mpu: to support mpu6881/mpu6880 Change-Id: I731788cd35d27d2aab946ccb22f744aad85f7be3 Signed-off-by: Zorro Liu --- diff --git a/drivers/staging/iio/imu/inv_mpu/inv_mpu_core.c b/drivers/staging/iio/imu/inv_mpu/inv_mpu_core.c index 471317f7b59c..3e7d07b463c3 100644 --- a/drivers/staging/iio/imu/inv_mpu/inv_mpu_core.c +++ b/drivers/staging/iio/imu/inv_mpu/inv_mpu_core.c @@ -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); diff --git a/drivers/staging/iio/imu/inv_mpu/inv_mpu_iio.h b/drivers/staging/iio/imu/inv_mpu/inv_mpu_iio.h index 99f3ba689355..92f59942512e 100644 --- a/drivers/staging/iio/imu/inv_mpu/inv_mpu_iio.h +++ b/drivers/staging/iio/imu/inv_mpu/inv_mpu_iio.h @@ -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 diff --git a/drivers/staging/iio/imu/inv_mpu/inv_mpu_misc.c b/drivers/staging/iio/imu/inv_mpu/inv_mpu_misc.c index 3f285e4f33a0..480dd95720ed 100644 --- a/drivers/staging/iio/imu/inv_mpu/inv_mpu_misc.c +++ b/drivers/staging/iio/imu/inv_mpu/inv_mpu_misc.c @@ -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 */