diff options
author | AlvinCC_Hsu <alvincc_hsu@compal.corp-partner.google.com> | 2020-11-14 21:15:38 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-11-17 21:22:30 +0000 |
commit | f6c02f49136a06dc0e4c8a898c7a37ac645aee97 (patch) | |
tree | b52135aab1b368527da37683707f3381714dea3b | |
parent | d0b880d61ecc8dfe334bae7dbb440156c56a287f (diff) | |
download | chrome-ec-f6c02f49136a06dc0e4c8a898c7a37ac645aee97.tar.gz |
driver: bmi: Fix accelerometer sensor data read failed
This patch reverts CL:2483357. Fix accelerometer
sensor data read failed after EC reboot.
BUG=b:173207451
BRANCH=none
TEST=read sensor data use "ectool motionsense" after
EC reboot
Signed-off-by: AlvinCC_Hsu <alvincc_hsu@compal.corp-partner.google.com>
Change-Id: I1cd6f8364335244a3037e94d859ac1f81a63b395
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2543565
Reviewed-by: Alexandru M Stan <amstan@chromium.org>
Commit-Queue: Alexandru M Stan <amstan@chromium.org>
-rw-r--r-- | driver/accelgyro_bmi_common.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/driver/accelgyro_bmi_common.c b/driver/accelgyro_bmi_common.c index d699c34cf0..9be2fe2bad 100644 --- a/driver/accelgyro_bmi_common.c +++ b/driver/accelgyro_bmi_common.c @@ -200,6 +200,14 @@ int bmi_write8(const int port, const uint16_t i2c_spi_addr_flags, reg, data); #endif } + /* + * From Bosch: BMI needs a delay of 450us after each write if it + * is in suspend mode, otherwise the operation may be ignored by + * the sensor. Given we are only doing write during init, add + * the delay unconditionally. + */ + msleep(1); + return rv; } @@ -226,6 +234,34 @@ int bmi_read16(const int port, const uint16_t i2c_spi_addr_flags, } /** + * Write 16bit register from accelerometer. + */ +int bmi_write16(const int port, const uint16_t i2c_spi_addr_flags, + const int reg, int data) +{ + int rv = -EC_ERROR_PARAM1; + + if (SLAVE_IS_SPI(i2c_spi_addr_flags)) { +#ifdef CONFIG_SPI_ACCEL_PORT + CPRINTS("%s() spi part is not implemented", __func__); +#endif + } else { +#ifdef I2C_PORT_ACCEL + rv = i2c_write16(port, i2c_spi_addr_flags, + reg, data); +#endif + } + /* + * From Bosch: BMI needs a delay of 450us after each write if it + * is in suspend mode, otherwise the operation may be ignored by + * the sensor. Given we are only doing write during init, add + * the delay unconditionally. + */ + msleep(1); + return rv; +} + +/** * Read 32bit register from accelerometer. */ int bmi_read32(const int port, const uint16_t i2c_spi_addr_flags, @@ -287,6 +323,14 @@ int bmi_write_n(const int port, const uint16_t i2c_spi_addr_flags, reg, data_ptr, len); #endif } + /* + * From Bosch: BMI needs a delay of 450us after each write if it + * is in suspend mode, otherwise the operation may be ignored by + * the sensor. Given we are only doing write during init, add + * the delay unconditionally. + */ + msleep(1); + return rv; } /* |