summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--board/cyan/board.c23
-rw-r--r--board/cyan/ec.tasklist5
-rw-r--r--board/strago/board.c23
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);