aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlof Johansson <olof@lixom.net>2016-08-25 12:45:33 -0400
committerJonathan Cameron <jic23@kernel.org>2016-09-03 12:26:14 -0400
commit1c500840934a138bd6b13556c210516e9301fbee (patch)
treee1c16632a11450a0c10ea2c7198c68cf1d0ad157
parent36afb176d3c9580651d7f410ed7f000ec48b5137 (diff)
iio: accel: bmc150: reset chip at init time
In at least one known setup, the chip comes up in a state where reading the chip ID returns garbage unless it's been reset, due to noise on the wires during system boot. All supported chips have the same reset method, and based on the datasheets they all need 1.3 or 1.8ms to recover after reset. So, do the conservative thing here and always reset the chip. Signed-off-by: Olof Johansson <olof@lixom.net> Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r--drivers/iio/accel/bmc150-accel-core.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c
index bf17aae66145..59b380dbf27f 100644
--- a/drivers/iio/accel/bmc150-accel-core.c
+++ b/drivers/iio/accel/bmc150-accel-core.c
@@ -67,6 +67,9 @@
67#define BMC150_ACCEL_REG_PMU_BW 0x10 67#define BMC150_ACCEL_REG_PMU_BW 0x10
68#define BMC150_ACCEL_DEF_BW 125 68#define BMC150_ACCEL_DEF_BW 125
69 69
70#define BMC150_ACCEL_REG_RESET 0x14
71#define BMC150_ACCEL_RESET_VAL 0xB6
72
70#define BMC150_ACCEL_REG_INT_MAP_0 0x19 73#define BMC150_ACCEL_REG_INT_MAP_0 0x19
71#define BMC150_ACCEL_INT_MAP_0_BIT_SLOPE BIT(2) 74#define BMC150_ACCEL_INT_MAP_0_BIT_SLOPE BIT(2)
72 75
@@ -1497,6 +1500,14 @@ static int bmc150_accel_chip_init(struct bmc150_accel_data *data)
1497 int ret, i; 1500 int ret, i;
1498 unsigned int val; 1501 unsigned int val;
1499 1502
1503 /*
1504 * Reset chip to get it in a known good state. A delay of 1.8ms after
1505 * reset is required according to the data sheets of supported chips.
1506 */
1507 regmap_write(data->regmap, BMC150_ACCEL_REG_RESET,
1508 BMC150_ACCEL_RESET_VAL);
1509 usleep_range(1800, 2500);
1510
1500 ret = regmap_read(data->regmap, BMC150_ACCEL_REG_CHIP_ID, &val); 1511 ret = regmap_read(data->regmap, BMC150_ACCEL_REG_CHIP_ID, &val);
1501 if (ret < 0) { 1512 if (ret < 0) {
1502 dev_err(dev, "Error: Reading chip id\n"); 1513 dev_err(dev, "Error: Reading chip id\n");