summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2015-10-23 10:50:23 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2016-11-12 19:22:05 +0000
commit2b23a6d508f88f587e2a36837a43a38fe6b11537 (patch)
treea380eb4948c80c728b98db99ea3c8075103ea526
parent7e005b791bab924883486cac8f737d4befded030 (diff)
downloadchrome-ec-2b23a6d508f88f587e2a36837a43a38fe6b11537.tar.gz
BACKPORT: 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, b:27849483 BRANCH=smaug, cyan 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> (cherry picked from commit 21c46e7b1300022fcee1e5997b3e9293c47c27ea) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/359393 Reviewed-on: https://chromium-review.googlesource.com/409480 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
-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);