diff options
Diffstat (limited to 'drivers/iio/gyro/bmg160_core.c')
| -rw-r--r-- | drivers/iio/gyro/bmg160_core.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/iio/gyro/bmg160_core.c b/drivers/iio/gyro/bmg160_core.c index f7fcfa886f72..821919dd245b 100644 --- a/drivers/iio/gyro/bmg160_core.c +++ b/drivers/iio/gyro/bmg160_core.c | |||
| @@ -27,6 +27,7 @@ | |||
| 27 | #include <linux/iio/trigger_consumer.h> | 27 | #include <linux/iio/trigger_consumer.h> |
| 28 | #include <linux/iio/triggered_buffer.h> | 28 | #include <linux/iio/triggered_buffer.h> |
| 29 | #include <linux/regmap.h> | 29 | #include <linux/regmap.h> |
| 30 | #include <linux/delay.h> | ||
| 30 | #include "bmg160.h" | 31 | #include "bmg160.h" |
| 31 | 32 | ||
| 32 | #define BMG160_IRQ_NAME "bmg160_event" | 33 | #define BMG160_IRQ_NAME "bmg160_event" |
| @@ -52,6 +53,9 @@ | |||
| 52 | #define BMG160_DEF_BW 100 | 53 | #define BMG160_DEF_BW 100 |
| 53 | #define BMG160_REG_PMU_BW_RES BIT(7) | 54 | #define BMG160_REG_PMU_BW_RES BIT(7) |
| 54 | 55 | ||
| 56 | #define BMG160_GYRO_REG_RESET 0x14 | ||
| 57 | #define BMG160_GYRO_RESET_VAL 0xb6 | ||
| 58 | |||
| 55 | #define BMG160_REG_INT_MAP_0 0x17 | 59 | #define BMG160_REG_INT_MAP_0 0x17 |
| 56 | #define BMG160_INT_MAP_0_BIT_ANY BIT(1) | 60 | #define BMG160_INT_MAP_0_BIT_ANY BIT(1) |
| 57 | 61 | ||
| @@ -236,6 +240,14 @@ static int bmg160_chip_init(struct bmg160_data *data) | |||
| 236 | int ret; | 240 | int ret; |
| 237 | unsigned int val; | 241 | unsigned int val; |
| 238 | 242 | ||
| 243 | /* | ||
| 244 | * Reset chip to get it in a known good state. A delay of 30ms after | ||
| 245 | * reset is required according to the datasheet. | ||
| 246 | */ | ||
| 247 | regmap_write(data->regmap, BMG160_GYRO_REG_RESET, | ||
| 248 | BMG160_GYRO_RESET_VAL); | ||
| 249 | usleep_range(30000, 30700); | ||
| 250 | |||
| 239 | ret = regmap_read(data->regmap, BMG160_REG_CHIP_ID, &val); | 251 | ret = regmap_read(data->regmap, BMG160_REG_CHIP_ID, &val); |
| 240 | if (ret < 0) { | 252 | if (ret < 0) { |
| 241 | dev_err(dev, "Error reading reg_chip_id\n"); | 253 | dev_err(dev, "Error reading reg_chip_id\n"); |
