diff options
author | Shamile Khan <shamile.khan@intel.com> | 2015-04-13 19:00:21 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-05-05 20:35:48 +0000 |
commit | ddf83269b46379370ff60f4fccc89ce5457fe89b (patch) | |
tree | 7a1c05b0fb105576ddab295b5b64bf20f79b0908 | |
parent | 4293de83e09a0a9ee24e422e09f7012c7a6a751e (diff) | |
download | chrome-ec-ddf83269b46379370ff60f4fccc89ce5457fe89b.tar.gz |
cyan: Set Motion Sensors to Pre-init state in S3
In S3 state, sensors loose their power. Prevent any initiation of
communication with the sensors.
BUG=None
TEST=With Servo connected, verify that no I2C failures are reported
on EC Console when system is brought to S3.
BRANCH=None
Change-Id: I1988c40aa9de48403e9e3a6be5aec3b7267c29e0
Signed-off-by: Shamile Khan <shamile.khan@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/268481
Reviewed-by: Shawn N <shawnn@chromium.org>
-rw-r--r-- | board/cyan/board.c | 23 | ||||
-rw-r--r-- | board/cyan/ec.tasklist | 5 | ||||
-rw-r--r-- | board/strago/board.c | 23 |
3 files changed, 47 insertions, 4 deletions
diff --git a/board/cyan/board.c b/board/cyan/board.c index c1af3f2a59..1118e4d5a8 100644 --- a/board/cyan/board.c +++ b/board/cyan/board.c @@ -11,6 +11,7 @@ #include "driver/temp_sensor/tmp432.h" #include "extpower.h" #include "gpio.h" +#include "hooks.h" #include "host_command.h" #include "i2c.h" #include "lid_switch.h" @@ -134,3 +135,25 @@ const struct accel_orientation acc_orient = { }, .hinge_axis = {0, 1, 0}, }; + +/* + * In S3, power rail for sensors (+V3p3S) goes down asynchronous to EC. We need + * to execute this routine first and set the sensor state to "Not Initialized". + * This prevents the motion_sense_suspend hook routine from communicating with + * the sensor. + */ +static void motion_sensors_pre_init(void) +{ + struct motion_sensor_t *sensor; + int i; + + for (i = 0; i < motion_sensor_count; ++i) { + sensor = &motion_sensors[i]; + sensor->state = SENSOR_NOT_INITIALIZED; + + sensor->odr = sensor->default_odr; + sensor->range = sensor->default_range; + } +} +DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, motion_sensors_pre_init, + MOTION_SENSE_HOOK_PRIO - 1); diff --git a/board/cyan/ec.tasklist b/board/cyan/ec.tasklist index 2fc581d310..ecad9795b8 100644 --- a/board/cyan/ec.tasklist +++ b/board/cyan/ec.tasklist @@ -19,6 +19,7 @@ #define CONFIG_TASK_LIST \ TASK_ALWAYS(HOOKS, hook_task, NULL, TASK_STACK_SIZE) \ TASK_ALWAYS(CHARGER, charger_task, NULL, TASK_STACK_SIZE) \ + TASK_NOTEST(MOTIONSENSE, motion_sense_task, NULL, LARGER_TASK_STACK_SIZE) \ TASK_NOTEST(CHIPSET, chipset_task, NULL, TASK_STACK_SIZE) \ TASK_NOTEST(KEYPROTO, keyboard_protocol_task, NULL, TASK_STACK_SIZE) \ TASK_ALWAYS(HOSTCMD, host_command_task, NULL, TASK_STACK_SIZE) \ @@ -27,7 +28,3 @@ TASK_ALWAYS(POWERBTN, power_button_task, NULL, TASK_STACK_SIZE) \ TASK_NOTEST(KEYSCAN, keyboard_scan_task, NULL, TASK_STACK_SIZE) -/* - * TODO: Re-enable when I2C/S3 issue is resolved. - TASK_NOTEST(MOTIONSENSE, motion_sense_task, NULL, LARGER_TASK_STACK_SIZE) \ - */ diff --git a/board/strago/board.c b/board/strago/board.c index f7017dbf17..2ed9b9c426 100644 --- a/board/strago/board.c +++ b/board/strago/board.c @@ -12,6 +12,7 @@ #include "driver/temp_sensor/tmp432.h" #include "extpower.h" #include "gpio.h" +#include "hooks.h" #include "host_command.h" #include "i2c.h" #include "lid_switch.h" @@ -148,3 +149,25 @@ const struct accel_orientation acc_orient = { }, .hinge_axis = {1, 0, 0}, }; + +/* + * In S3, power rail for sensors (+V3p3S) goes down asynchronous to EC. We need + * to execute this routine first and set the sensor state to "Not Initialized". + * This prevents the motion_sense_suspend hook routine from communicating with + * the sensor. + */ +static void motion_sensors_pre_init(void) +{ + struct motion_sensor_t *sensor; + int i; + + for (i = 0; i < motion_sensor_count; ++i) { + sensor = &motion_sensors[i]; + sensor->state = SENSOR_NOT_INITIALIZED; + + sensor->odr = sensor->default_odr; + sensor->range = sensor->default_range; + } +} +DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, motion_sensors_pre_init, + MOTION_SENSE_HOOK_PRIO - 1); |