summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2015-10-23 10:50:23 -0700
committerchrome-bot <chrome-bot@chromium.org>2015-10-28 00:23:48 -0700
commit21c46e7b1300022fcee1e5997b3e9293c47c27ea (patch)
tree391f5fb1eeb32a85d054ada31b081840ab5654e7
parent7253e57b3c5f415d53558d8e8266c70ff42975a7 (diff)
downloadchrome-ec-21c46e7b1300022fcee1e5997b3e9293c47c27ea.tar.gz
motion: Remove duplicate shutdown code
Call shutdown() entry point at init() and remove duplicate code. shutdown would init the sensor so they would be ready if needed. Set S5 flag to include G3 (hard off) state, not only S5 (soft off). BUG=chrome-os-partner:45722 BRANCH=smaug TEST=When doing a RO->RW transition while AP is in G3, check the sensors are initialized properly. This issue was found while testng the magic sequence code. Change-Id: I647f83580240bf5ba0c340fca3184220abe4c12e Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/308561 Reviewed-by: Alec Berg <alecaberg@chromium.org>
-rw-r--r--common/motion_sense.c14
-rw-r--r--driver/accelgyro_bmi160.c4
-rw-r--r--include/motion_sense.h2
-rw-r--r--test/motion_lid.c4
4 files changed, 8 insertions, 16 deletions
diff --git a/common/motion_sense.c b/common/motion_sense.c
index 3bd2dfcd5c..0a2f8d11e5 100644
--- a/common/motion_sense.c
+++ b/common/motion_sense.c
@@ -454,19 +454,13 @@ DECLARE_HOOK(HOOK_CHIPSET_RESUME, motion_sense_resume,
static void motion_sense_startup(void)
{
- int i;
- struct motion_sensor_t *sensor;
-
- sensor_active = SENSOR_ACTIVE_S5;
- for (i = 0; i < motion_sensor_count; ++i) {
- sensor = &motion_sensors[i];
- sensor->state = SENSOR_NOT_INITIALIZED;
- }
-
- /* If the AP is already in S0, call the resume hook now.
+ /*
+ * If the AP is already in S0, call the resume hook now.
* We may initialize the sensor 2 times (once in RO, another time in
* RW), but it may be necessary if the init sequence has changed.
*/
+ if (chipset_in_state(SENSOR_ACTIVE_S0_S3_S5))
+ motion_sense_shutdown();
if (chipset_in_state(SENSOR_ACTIVE_S0_S3))
motion_sense_suspend();
if (chipset_in_state(SENSOR_ACTIVE_S0))
diff --git a/driver/accelgyro_bmi160.c b/driver/accelgyro_bmi160.c
index fa759916bc..44900807cc 100644
--- a/driver/accelgyro_bmi160.c
+++ b/driver/accelgyro_bmi160.c
@@ -1197,10 +1197,6 @@ static int init(const struct motion_sensor_t *s)
#ifdef CONFIG_ACCEL_INTERRUPTS
ret = config_interrupt(s);
#endif
-#ifdef CONFIG_GESTURE_SENSOR_BATTERY_TAP
- /* enable double tap, as soon as the chip is ready */
- manage_activity(s, MOTIONSENSE_ACTIVITY_DOUBLE_TAP, 1, NULL);
-#endif
}
CPRINTF("[%T %s: MS Done Init type:0x%X range:%d]\n",
s->name, s->type, get_range(s));
diff --git a/include/motion_sense.h b/include/motion_sense.h
index aa4170b722..0c9632ca7e 100644
--- a/include/motion_sense.h
+++ b/include/motion_sense.h
@@ -30,7 +30,7 @@ enum sensor_config {
SENSOR_CONFIG_MAX,
};
-#define SENSOR_ACTIVE_S5 CHIPSET_STATE_SOFT_OFF
+#define SENSOR_ACTIVE_S5 (CHIPSET_STATE_SOFT_OFF | CHIPSET_STATE_HARD_OFF)
#define SENSOR_ACTIVE_S3 CHIPSET_STATE_SUSPEND
#define SENSOR_ACTIVE_S0 CHIPSET_STATE_ON
#define SENSOR_ACTIVE_S0_S3 (SENSOR_ACTIVE_S3 | SENSOR_ACTIVE_S0)
diff --git a/test/motion_lid.c b/test/motion_lid.c
index ba6a179b1c..158fcb0918 100644
--- a/test/motion_lid.c
+++ b/test/motion_lid.c
@@ -196,12 +196,14 @@ static int test_lid_angle(void)
struct motion_sensor_t *base = &motion_sensors[0];
struct motion_sensor_t *lid = &motion_sensors[1];
- /* Go to S3 state */
+ /* We don't have TASK_CHIP so simulate init ourselves */
+ hook_notify(HOOK_CHIPSET_SHUTDOWN);
TEST_ASSERT(sensor_active == SENSOR_ACTIVE_S5);
TEST_ASSERT(accel_get_data_rate(lid) == 0);
TEST_ASSERT(motion_interval == 0);
/* Go to S0 state */
+ hook_notify(HOOK_CHIPSET_SUSPEND);
hook_notify(HOOK_CHIPSET_RESUME);
msleep(1000);
TEST_ASSERT(sensor_active == SENSOR_ACTIVE_S0);