summaryrefslogtreecommitdiff
path: root/driver
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2016-11-15 16:35:12 -0800
committerchrome-bot <chrome-bot@chromium.org>2016-11-21 18:22:56 -0800
commitbcbeb89da1b1a906ba913a5a08ada343342781d7 (patch)
treeca2458f602eef3e113e82fd95a07aee92e9b2b38 /driver
parent88685f6a667f1a3b283fd29d4f4269766be06e72 (diff)
downloadchrome-ec-bcbeb89da1b1a906ba913a5a08ada343342781d7.tar.gz
driver: bmi160: Remove unnecessary delay
Rereading the specification, remove delays when not needed: - When we move the sensor out of suspend, we need to wait before using it (BMI160 spec: 2.11.38 Register (0x7E) CMD) When we do a softreset, we need just need to wait 300us for the sensor to go in suspend, we will wait only when we change the rate and enable the sensor. - The timeout at fifo flush is not needed, it was added for debugging. - Remove unnecessary printf when initializing the magnetometer. BUG=chrome-os-partner:59188 BRANCH=glados, reef, strago TEST=On reef, check the EC boot faster: time spend initializing the sensors decreased from 240ms to 133ms Change-Id: Ia80232da42aa705df819a4988da483a344ffcbb4 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/411964 Commit-Ready: David Hendricks <dhendrix@chromium.org> Tested-by: David Hendricks <dhendrix@chromium.org> Reviewed-by: David Hendricks <dhendrix@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r--driver/accelgyro_bmi160.c16
-rw-r--r--driver/mag_bmm150.c2
2 files changed, 10 insertions, 8 deletions
diff --git a/driver/accelgyro_bmi160.c b/driver/accelgyro_bmi160.c
index 589206414e..4be19e9266 100644
--- a/driver/accelgyro_bmi160.c
+++ b/driver/accelgyro_bmi160.c
@@ -788,7 +788,6 @@ static int config_interrupt(const struct motion_sensor_t *s)
mutex_lock(s->mutex);
raw_write8(s->port, s->addr, BMI160_CMD_REG, BMI160_CMD_FIFO_FLUSH);
- msleep(30);
raw_write8(s->port, s->addr, BMI160_CMD_REG, BMI160_CMD_INT_RESET);
#ifdef CONFIG_GESTURE_SENSOR_BATTERY_TAP
@@ -1110,7 +1109,7 @@ static int init(const struct motion_sensor_t *s)
/* Reset the chip to be in a good state */
raw_write8(s->port, s->addr, BMI160_CMD_REG,
BMI160_CMD_SOFT_RESET);
- msleep(30);
+ msleep(1);
data->flags &= ~(BMI160_FLAG_SEC_I2C_ENABLED |
(BMI160_FIFO_ALL_MASK <<
BMI160_FIFO_FLAG_OFFSET));
@@ -1130,13 +1129,18 @@ static int init(const struct motion_sensor_t *s)
raw_write8(s->port, s->addr, BMI160_PMU_TRIGGER, 0);
}
- raw_write8(s->port, s->addr, BMI160_CMD_REG,
- BMI160_CMD_MODE_NORMAL(s->type));
- msleep(wakeup_time[s->type]);
-
#ifdef CONFIG_MAG_BMI160_BMM150
if (s->type == MOTIONSENSE_TYPE_MAG) {
struct bmi160_drv_data_t *data = BMI160_GET_DATA(s);
+
+ /*
+ * To be able to configure the real magnetometer, we must set
+ * the BMI160 magnetometer part (a pass through) in normal mode.
+ */
+ raw_write8(s->port, s->addr, BMI160_CMD_REG,
+ BMI160_CMD_MODE_NORMAL(s->type));
+ msleep(wakeup_time[s->type]);
+
if ((data->flags & BMI160_FLAG_SEC_I2C_ENABLED) == 0) {
int ext_page_reg, pullup_reg;
/* Enable secondary interface */
diff --git a/driver/mag_bmm150.c b/driver/mag_bmm150.c
index 2eb736a722..c546dec1ce 100644
--- a/driver/mag_bmm150.c
+++ b/driver/mag_bmm150.c
@@ -121,9 +121,7 @@ int bmm150_init(const struct motion_sensor_t *s)
raw_mag_write8(s->port, s->addr, BMM150_REPXY, BMM150_REP(SPECIAL, XY));
raw_mag_write8(s->port, s->addr, BMM150_REPZ, BMM150_REP(SPECIAL, Z));
ret = raw_mag_read8(s->port, s->addr, BMM150_REPXY, &val);
- CPRINTS("repxy: 0x%02x", val);
ret = raw_mag_read8(s->port, s->addr, BMM150_REPZ, &val);
- CPRINTS("repz: 0x%02x", val);
/*
* Set the compass forced mode, to sleep after each measure.
*/