summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2015-06-06 23:09:54 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-06-11 18:27:24 +0000
commite51399aae80923c6aee8f81a38e7c788f9125dca (patch)
tree741789b86fa43aacf31e13997b25b1bd9b3bff21 /include
parente310a2be6272022a90207f5d8227f4536ae0066b (diff)
downloadchrome-ec-e51399aae80923c6aee8f81a38e7c788f9125dca.tar.gz
commands: Add EC FIFO commands
Add command to read the sensors events FIFO from the AP: FIFO_INFO: get information on the FIFO state FIFO_READ: read and update the consumer pointer FIFO_FLUSH: insert a flush meta event and force a interrupt. A new MKBP event is added to tell the host the FIFO needs processing. BRANCH=smaug TEST=Test on ryu BUG=chrome-os-partner:39900 Change-Id: I11c0cf8cdc3087eb9e323f7d6780e6cf3a16257f Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/276264 Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/ec_commands.h93
1 files changed, 82 insertions, 11 deletions
diff --git a/include/ec_commands.h b/include/ec_commands.h
index 09c65f6b34..a0ace7e593 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -1656,6 +1656,22 @@ enum motionsense_command {
*/
MOTIONSENSE_CMD_DATA = 6,
+ /*
+ * Return sensor fifo info.
+ */
+ MOTIONSENSE_CMD_FIFO_INFO = 7,
+
+ /*
+ * Insert a flush element in the fifo and return sensor fifo info.
+ * The host can use that element to synchronize its operation.
+ */
+ MOTIONSENSE_CMD_FIFO_FLUSH = 8,
+
+ /*
+ * Return a portion of the fifo.
+ */
+ MOTIONSENSE_CMD_FIFO_READ = 9,
+
/* Number of motionsense sub-commands. */
MOTIONSENSE_NUM_CMDS
};
@@ -1682,6 +1698,30 @@ enum motionsensor_chip {
MOTIONSENSE_CHIP_BMI160 = 2,
};
+struct ec_response_motion_sensor_data {
+ /* Flags for each sensor. */
+ uint8_t flags;
+ /* sensor number the data comes from */
+ uint8_t sensor_num;
+ /* Each sensor is up to 3-axis. */
+ int16_t data[3];
+} __packed;
+
+struct ec_response_motion_sense_fifo_info {
+ /* Size of the fifo */
+ uint32_t size;
+ /* Amount of space used in the fifo */
+ uint32_t count;
+ /* Lost events since the last fifo_info */
+ uint32_t lost;
+ /* TImestamp recorded in us */
+ uint32_t timestamp;
+} __packed;
+
+struct ec_response_motion_sense_fifo_data {
+ uint32_t number_data;
+ struct ec_response_motion_sensor_data data[0];
+} __packed;
/* Module flag masks used for the dump sub-command. */
#define MOTIONSENSE_MODULE_FLAG_ACTIVE (1<<0)
@@ -1689,6 +1729,13 @@ enum motionsensor_chip {
#define MOTIONSENSE_SENSOR_FLAG_PRESENT (1<<0)
/*
+ * Flush entry for synchronisation.
+ * data contains time stamp
+ */
+#define MOTIONSENSE_SENSOR_FLAG_FLUSH (1<<0)
+#define MOTIONSENSE_SENSOR_FLAG_TIMESTAMP (1<<1)
+
+/*
* Send this value for the data element to only perform a read. If you
* send any other value, the EC will interpret it as data to set and will
* return the actual value set.
@@ -1713,14 +1760,17 @@ struct ec_params_motion_sense {
* MOTIONSENSE_CMD_KB_WAKE_ANGLE.
*/
struct {
- /* Data to set or EC_MOTION_SENSE_NO_VALUE to read. */
+ /* Data to set or EC_MOTION_SENSE_NO_VALUE to read.
+ * ec_rate: polling rate in ms.
+ * kb_wake_angle: angle to wakup AP.
+ */
int16_t data;
} ec_rate, kb_wake_angle;
/* Used for MOTIONSENSE_CMD_INFO, MOTIONSENSE_CMD_DATA. */
struct {
uint8_t sensor_num;
- } info, data;
+ } info, data, fifo_flush;
/*
* Used for MOTIONSENSE_CMD_SENSOR_ODR and
@@ -1737,18 +1787,18 @@ struct ec_params_motion_sense {
/* Data to set or EC_MOTION_SENSE_NO_VALUE to read. */
int32_t data;
} sensor_odr, sensor_range;
+ struct {
+ } fifo_info;
+ struct {
+ /*
+ * Number of expected vector to return.
+ * EC may return less or 0 if none available.
+ */
+ uint32_t max_data_vector;
+ } fifo_read;
};
} __packed;
-struct ec_response_motion_sensor_data {
- /* Flags for each sensor. */
- uint8_t flags;
- uint8_t padding;
-
- /* Each sensor is up to 3-axis. */
- int16_t data[3];
-} __packed;
-
struct ec_response_motion_sense {
union {
/* Used for MOTIONSENSE_CMD_DUMP */
@@ -1790,6 +1840,10 @@ struct ec_response_motion_sense {
/* Current value of the parameter queried. */
int32_t ret;
} ec_rate, sensor_odr, sensor_range, kb_wake_angle;
+
+ struct ec_response_motion_sense_fifo_info fifo_info, fifo_flush;
+
+ struct ec_response_motion_sense_fifo_data fifo_read;
};
} __packed;
@@ -2200,13 +2254,30 @@ enum ec_mkbp_event {
/* New host event. The event data is 4 bytes of host event flags. */
EC_MKBP_EVENT_HOST_EVENT = 1,
+ /* New Sensor FIFO data. The event data is fifo_info structure. */
+ EC_MKBP_EVENT_SENSOR_FIFO = 2,
+
/* Number of MKBP events */
EC_MKBP_EVENT_COUNT,
};
+union ec_response_get_next_data {
+ uint8_t key_matrix[13];
+
+ /* Unaligned */
+ uint32_t host_event;
+
+ struct {
+ /* For aligning the fifo_info */
+ uint8_t rsvd[3];
+ struct ec_response_motion_sense_fifo_info info;
+ } sensor_fifo;
+} __packed;
+
struct ec_response_get_next_event {
uint8_t event_type;
/* Followed by event data if any */
+ union ec_response_get_next_data data;
} __packed;
/*****************************************************************************/