diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2015-10-20 11:23:33 -0700 |
---|---|---|
committer | ChromeOS bot <3su6n15k.default@developer.gserviceaccount.com> | 2015-10-29 06:21:43 +0000 |
commit | a3856fb8e56a742522cd8aa023bfb7a20a087fbf (patch) | |
tree | 60e85e710a59dac582a41ac8a52bd277ea1a82b7 | |
parent | 544abdf839481599e7ab728d3eecd7c6d6738b35 (diff) | |
download | chrome-ec-a3856fb8e56a742522cd8aa023bfb7a20a087fbf.tar.gz |
driver: bmi160: Add magic sequence to unlock
If init() is interrupted while we are setting the link to the compass,
the BMI160 may be in paging mode and will only answer to registers 7Eh
and 7Fh. Other registers access will return 00h.
To get out of this state, run the sequence to move back from the paging
mode in the error handler. If successful, a subsequent call to init()
will work.
BRANCH=smaug
BUG=chrome-os-partner:45722
TEST=use a special firmware that exists in the middle of the compass
init sequence. Check that the FIFO and all other registers return 0.
Issue 'accelinit 1' (to reset the Gyro): the command succeeds and the
accelerometer is operational again (double tap works).
Check the sequence can be issued after sysjump to RW/RO.
Change-Id: I3455a8cbdcf1c88699ae90f7c09e4438e1268d47
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/308184
Reviewed-by: Alec Berg <alecaberg@chromium.org>
(cherry picked from commit 8238dfa27d9c6c52dfd72b0328115e49b5c3496d)
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/309595
-rw-r--r-- | driver/accelgyro_bmi160.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/driver/accelgyro_bmi160.c b/driver/accelgyro_bmi160.c index ce7b371840..f923a89aa9 100644 --- a/driver/accelgyro_bmi160.c +++ b/driver/accelgyro_bmi160.c @@ -1065,8 +1065,19 @@ static int init(const struct motion_sensor_t *s) if (ret) return EC_ERROR_UNKNOWN; - if (tmp != BMI160_CHIP_ID_MAJOR) + if (tmp != BMI160_CHIP_ID_MAJOR) { + /* The device may be lock on paging mode. Try to unlock it. */ + raw_write8(s->addr, BMI160_CMD_REG, + BMI160_CMD_EXT_MODE_EN_B0); + raw_write8(s->addr, BMI160_CMD_REG, + BMI160_CMD_EXT_MODE_EN_B1); + raw_write8(s->addr, BMI160_CMD_REG, + BMI160_CMD_EXT_MODE_EN_B2); + raw_write8(s->addr, BMI160_CMD_EXT_MODE_ADDR, + BMI160_CMD_PAGING_EN); + raw_write8(s->addr, BMI160_CMD_EXT_MODE_ADDR, 0); return EC_ERROR_ACCESS_DENIED; + } if (s->type == MOTIONSENSE_TYPE_ACCEL) { |