diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2015-09-09 08:55:09 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2015-09-21 01:13:57 -0700 |
commit | 40e20adefbb46dac71e781473388b33b41f7ff45 (patch) | |
tree | 1736024cebc58cb6031aed1f363662941f5cfd9c /driver | |
parent | 241c2cb42915a37ffc123fea6bc61a24620fc1dd (diff) | |
download | chrome-ec-40e20adefbb46dac71e781473388b33b41f7ff45.tar.gz |
driver: bmi160: Fix for significant motion while in suspend.
- Add interrupt latching: notice that interrupt register
was cleared before entering the task irq handler.
Add a 5ms latching time address the issue.
Check it was not a problem for regular operation.
- Fix FIFO interrupt setting: interrupt when FIFO was full was
missing from one register
- Really disable FIFO when AP does not want data from sensors.
BRANCH=smaug
BUG=b:23570481
TEST=check that significant motion and double tap are reliable in S3.
Change-Id: Iec3681da00462b1aa392056eecea4ee6862d42ee
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/298689
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r-- | driver/accelgyro_bmi160.c | 18 | ||||
-rw-r--r-- | driver/accelgyro_bmi160.h | 1 |
2 files changed, 11 insertions, 8 deletions
diff --git a/driver/accelgyro_bmi160.c b/driver/accelgyro_bmi160.c index aaf6ff8d9b..68259cefaf 100644 --- a/driver/accelgyro_bmi160.c +++ b/driver/accelgyro_bmi160.c @@ -432,8 +432,7 @@ static int set_data_rate(const struct motion_sensor_t *s, #ifdef CONFIG_ACCEL_FIFO /* FIFO start collecting events if AP wants them */ - if (BASE_ODR(s->config[SENSOR_CONFIG_AP].odr) != 0) - enable_fifo(s, 1); + enable_fifo(s, !!BASE_ODR(s->config[SENSOR_CONFIG_AP].odr)); #endif accel_cleanup: @@ -721,7 +720,7 @@ int list_activities(const struct motion_sensor_t *s, #ifdef CONFIG_ACCEL_INTERRUPTS /** - * bmi160_interrupt - called when the sensor activate the interrupt line. + * bmi160_interrupt - called when the sensor activates the interrupt line. * * This is a "top half" interrupt handler, it just asks motion sense ask * to schedule the "bottom half", ->irq_handler(). @@ -749,9 +748,13 @@ static int config_interrupt(const struct motion_sensor_t *s) ret = raw_write8(s->addr, BMI160_INT_TAP_1, BMI160_TAP_TH(s, CONFIG_GESTURE_TAP_THRES_MG)); #endif - /* configure int2 as an external input */ + /* + * configure int2 as an external input. + * Set a 5ms latch to be sure the EC can read the interrupt register + * properly, even when it is running more slowly. + */ ret = raw_write8(s->addr, BMI160_INT_LATCH, - BMI160_INT2_INPUT_EN); + BMI160_INT2_INPUT_EN | BMI160_LATCH_5MS); /* configure int1 as an interupt */ ret = raw_write8(s->addr, BMI160_INT_OUT_CTRL, @@ -770,7 +773,8 @@ static int config_interrupt(const struct motion_sensor_t *s) #ifdef CONFIG_ACCEL_FIFO /* map fifo water mark to int 1 */ ret = raw_write8(s->addr, BMI160_INT_FIFO_MAP, - BMI160_INT_MAP(1, FWM)); + BMI160_INT_MAP(1, FWM) | + BMI160_INT_MAP(1, FFULL)); /* configure fifo watermark at 50% */ ret = raw_write8(s->addr, BMI160_FIFO_CONFIG_0, @@ -779,10 +783,8 @@ static int config_interrupt(const struct motion_sensor_t *s) BMI160_FIFO_TAG_INT1_EN | BMI160_FIFO_TAG_INT2_EN | BMI160_FIFO_HEADER_EN); -#endif /* Set fifo*/ -#ifdef CONFIG_ACCEL_FIFO ret = raw_read8(s->addr, BMI160_INT_EN_1, &tmp); tmp |= BMI160_INT_FWM_EN | BMI160_INT_FFUL_EN; ret = raw_write8(s->addr, BMI160_INT_EN_1, tmp); diff --git a/driver/accelgyro_bmi160.h b/driver/accelgyro_bmi160.h index ee44f9262e..7d875d6675 100644 --- a/driver/accelgyro_bmi160.h +++ b/driver/accelgyro_bmi160.h @@ -262,6 +262,7 @@ enum fifo_header { #define BMI160_INT2_INPUT_EN (1 << 5) #define BMI160_LATCH_MASK 0xf #define BMI160_LATCH_NONE 0 +#define BMI160_LATCH_5MS 5 #define BMI160_LATCH_FOREVER 0xf #define BMI160_INT_MAP_0 0x55 |