summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSheng-Liang Song <ssl@chromium.org>2014-10-30 15:33:43 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-10-31 20:55:24 +0000
commit327bfe2e587b0e2e127ac9659bec6f7bb7a310ed (patch)
tree427ab9314c0df40980d35039b75383df0f2bb187
parente6a2d4c0440aefda9a77f449230e7f710db426a5 (diff)
downloadchrome-ec-327bfe2e587b0e2e127ac9659bec6f7bb7a310ed.tar.gz
Samus: Fixed sensor init when sysjump to between RO and RW code
When sysjump between RO and RW code, the motion sensor global data structure get reset to 0. The motion sensor task does not get notification from the power state change event. Added chipset S0 state check logic to re-init sensor active flag to S0. BUG=chrome-os-partner:33370 BRANCH=ToT TEST=sysjump RW; accelread 0 Test Cases: 1 - press power cycle button; checked with powerinfo,accelread 2 - press power cycle button + F3 (refresh) key; checked with powerinfo,accelread 3 - Go to G3, S0, S3; checked with powerinfo, accelread 4 - boot up to S0; sysjump RW; accelread 0|1|2 Change-Id: Ibfe4ba581c8b771be15adb7440374d09fdf03953 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/226698 Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Sheng-liang Song <ssl@chromium.org> Tested-by: Sheng-liang Song <ssl@chromium.org>
-rw-r--r--common/motion_sense.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/common/motion_sense.c b/common/motion_sense.c
index 9ed0ab92da..21b36a1e7d 100644
--- a/common/motion_sense.c
+++ b/common/motion_sense.c
@@ -245,9 +245,18 @@ void motion_sense_task(void)
set_present(lpc_status);
- /* Initialize sampling interval. */
- accel_interval_ms = chipset_in_state(CHIPSET_STATE_ON) ?
- accel_interval_ap_on_ms : SUSPEND_SAMPLING_INTERVAL;
+ if (chipset_in_state(CHIPSET_STATE_ON)) {
+ /* Update the sensor current active state to S0. */
+ for (i = 0; i < motion_sensor_count; ++i) {
+ sensor = &motion_sensors[i];
+ sensor->active = SENSOR_ACTIVE_S0;
+ }
+
+ accel_interval_ms = accel_interval_ap_on_ms;
+ } else {
+ /* sensor->active already initializes to SENSOR_ACTIVE_S5 */
+ accel_interval_ms = SUSPEND_SAMPLING_INTERVAL;
+ }
while (1) {
ts0 = get_time();
@@ -681,6 +690,7 @@ static int command_accel_read_xyz(int argc, char **argv)
sensor = &motion_sensors[id];
while ((n == -1) || (n-- > 0)) {
+ x = y = z = 0;
sensor->drv->read(sensor, &x, &y, &z);
ccprintf("Current raw data %d: %-5d %-5d %-5d\n", id, x, y, z);
ccprintf("Last calib. data %d: %-5d %-5d %-5d\n", id,