Skip to content

Commit 8ff7eb4

Browse files
QSchulzgregkh
authored andcommitted
iio: bmg160: reset chip when probing
commit 4bdc9029685ac03be50b320b29691766d2326c2b upstream. The gyroscope chip might need to be reset to be used. Without the chip being reset, the driver stopped at the first regmap_read (to get the CHIP_ID) and failed to probe. The datasheet of the gyroscope says that a minimum wait of 30ms after the reset has to be done. This patch has been checked on a BMX055 and the datasheet of the BMG160 and the BMI055 give the same reset register and bits. Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent d4ad442 commit 8ff7eb4

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

drivers/iio/gyro/bmg160_core.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <linux/iio/trigger_consumer.h>
2929
#include <linux/iio/triggered_buffer.h>
3030
#include <linux/regmap.h>
31+
#include <linux/delay.h>
3132
#include "bmg160.h"
3233

3334
#define BMG160_IRQ_NAME "bmg160_event"
@@ -53,6 +54,9 @@
5354
#define BMG160_NO_FILTER 0
5455
#define BMG160_DEF_BW 100
5556

57+
#define BMG160_GYRO_REG_RESET 0x14
58+
#define BMG160_GYRO_RESET_VAL 0xb6
59+
5660
#define BMG160_REG_INT_MAP_0 0x17
5761
#define BMG160_INT_MAP_0_BIT_ANY BIT(1)
5862

@@ -186,6 +190,14 @@ static int bmg160_chip_init(struct bmg160_data *data)
186190
int ret;
187191
unsigned int val;
188192

193+
/*
194+
* Reset chip to get it in a known good state. A delay of 30ms after
195+
* reset is required according to the datasheet.
196+
*/
197+
regmap_write(data->regmap, BMG160_GYRO_REG_RESET,
198+
BMG160_GYRO_RESET_VAL);
199+
usleep_range(30000, 30700);
200+
189201
ret = regmap_read(data->regmap, BMG160_REG_CHIP_ID, &val);
190202
if (ret < 0) {
191203
dev_err(data->dev, "Error reading reg_chip_id\n");

0 commit comments

Comments
 (0)