summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/motion_sense.c14
-rw-r--r--include/motion_sense.h2
-rw-r--r--test/motion_lid.c4
3 files changed, 8 insertions, 12 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/include/motion_sense.h b/include/motion_sense.h
index 6b28a0bacf..156b898f05 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 1ae57f239f..9db6815b1e 100644
--- a/test/motion_lid.c
+++ b/test/motion_lid.c
@@ -199,12 +199,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);