From a8b35099e1b224d628cc3f87eafde425d6e0cf8a Mon Sep 17 00:00:00 2001 From: Gwendal Grignou Date: Tue, 20 Sep 2016 12:34:10 -0700 Subject: elm: Add FIFO support for ARC++ FIFO needed for ARC++ support. BUG=b:27849483,b:31609073 BRANCH=oak TEST=On elm, install R55-8795.0.0, in ARC++, install AIDA64. Check the lid accelerometer is seen. Ran CTS tests: SensorBatchingTests and SingleSensorTests: ./out/host/linux-x86/cts/android-cts/tools/cts-tradefed run \ commandAndExit cts -s :22 -c android.hardware.cts. Change-Id: Iefaaee874bbc32f464c3afe79d03b3087b211ee0 Signed-off-by: Gwendal Grignou Reviewed-on: https://chromium-review.googlesource.com/387164 Reviewed-by: Nicolas Boichat --- board/elm/board.c | 14 ++++++++------ board/elm/board.h | 19 +++++++++++++++++-- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/board/elm/board.c b/board/elm/board.c index 5328c7dbba..678b25df38 100644 --- a/board/elm/board.c +++ b/board/elm/board.c @@ -546,7 +546,8 @@ const matrix_3x3_t lid_standard_ref = { struct kionix_accel_data g_kx022_data[2]; struct motion_sensor_t motion_sensors[] = { - {.name = "Base Accel", + [BASE_ACCEL] = { + .name = "Base Accel", .active_mask = SENSOR_ACTIVE_S0, .chip = MOTIONSENSE_CHIP_KX022, .type = MOTIONSENSE_TYPE_ACCEL, @@ -560,8 +561,8 @@ struct motion_sensor_t motion_sensors[] = { .config = { /* AP: by default use EC settings */ [SENSOR_CONFIG_AP] = { - .odr = 10000 | ROUND_UP_FLAG, - .ec_rate = 100 * MSEC, + .odr = 0, + .ec_rate = 0, }, /* EC use accel for angle detection */ [SENSOR_CONFIG_EC_S0] = { @@ -580,7 +581,8 @@ struct motion_sensor_t motion_sensors[] = { }, }, - {.name = "Lid Accel", + [LID_ACCEL] = { + .name = "Lid Accel", .active_mask = SENSOR_ACTIVE_S0, .chip = MOTIONSENSE_CHIP_KX022, .type = MOTIONSENSE_TYPE_ACCEL, @@ -594,8 +596,8 @@ struct motion_sensor_t motion_sensors[] = { .config = { /* AP: by default use EC settings */ [SENSOR_CONFIG_AP] = { - .odr = 10000 | ROUND_UP_FLAG, - .ec_rate = 100 * MSEC, + .odr = 0, + .ec_rate = 0, }, /* EC use accel for angle detection */ [SENSOR_CONFIG_EC_S0] = { diff --git a/board/elm/board.h b/board/elm/board.h index 7d109a1120..8f294d5dc0 100644 --- a/board/elm/board.h +++ b/board/elm/board.h @@ -15,9 +15,18 @@ #define CONFIG_CMD_ACCEL_INFO #define CONFIG_CMD_ACCEL_RESET #define CONFIG_LID_ANGLE -#define CONFIG_LID_ANGLE_SENSOR_BASE 0 -#define CONFIG_LID_ANGLE_SENSOR_LID 1 +#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL +#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL #define CONFIG_LID_ANGLE_UPDATE +/* FIFO size is in power of 2. */ +#define CONFIG_ACCEL_FIFO 512 +#define CONFIG_ACCEL_FIFO_THRES (CONFIG_ACCEL_FIFO / 3) + +/* + * Sensor internal FIFO is enabled for BMI160, but not for BMA255. + */ +#define CONFIG_ACCEL_FORCE_MODE_MASK \ + ((1 << LID_ACCEL) | (1 << BASE_ACCEL)) #define CONFIG_ADC #undef CONFIG_ADC_WATCHDOG @@ -189,6 +198,12 @@ enum temp_sensor_id { TEMP_SENSOR_COUNT }; +/* Motion sensors */ +enum sensor_id { + BASE_ACCEL = 0, + LID_ACCEL, +}; + /* start as a sink in case we have no other power supply/battery */ #define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED -- cgit v1.2.1