From 22d7aeb27711b87277f65288d58dda12efb77ffe Mon Sep 17 00:00:00 2001 From: Gwendal Grignou Date: Mon, 12 Sep 2016 21:16:42 -0700 Subject: [PATCH] reef: Enable sensors for ARC++ - Enable MKBP events: Allow EC to send sensor event to the kernel sensor stack. - Disable APCI message display, to avoid overwhelming the console. - Set the rotation matrices to match Android requirement. BUG=b:27849483 CQ-DEPEND=CL:384341 BRANCH=reef TEST=Check we can receive sensor events for ARC++. Check the acceleromter axis are correct. Change-Id: I5fa58e22167f027bd1b84e72f002060d15d882c4 Signed-off-by: Gwendal Grignou Reviewed-on: https://chromium-review.googlesource.com/385082 Reviewed-by: Aseda Aboagye --- board/reef/board.c | 20 +++++++++++++------- board/reef/board.h | 20 ++++++++++++++------ 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/board/reef/board.c b/board/reef/board.c index 88e2472bd0..e29936badf 100644 --- a/board/reef/board.c +++ b/board/reef/board.c @@ -704,9 +704,15 @@ static struct mutex g_base_mutex; /* Matrix to rotate accelrator into standard reference frame */ const matrix_3x3_t base_standard_ref = { - { 0, FLOAT_TO_FP(1), 0}, - { FLOAT_TO_FP(-1), 0, 0}, - { 0, 0, FLOAT_TO_FP(1)} + { 0, FLOAT_TO_FP(-1), 0}, + { FLOAT_TO_FP(1), 0, 0}, + { 0, 0, FLOAT_TO_FP(1)} +}; + +const matrix_3x3_t mag_standard_ref = { + { FLOAT_TO_FP(1), 0, 0}, + { 0, FLOAT_TO_FP(-1), 0}, + { 0, 0, FLOAT_TO_FP(-1)} }; /* KX022 private data */ @@ -730,7 +736,7 @@ struct motion_sensor_t motion_sensors[] = { .drv_data = &g_bmi160_data, .port = I2C_PORT_GYRO, .addr = BMI160_ADDR0, - .rot_standard_ref = NULL, /* Identity matrix. */ + .rot_standard_ref = &base_standard_ref, .default_range = 2, /* g, enough for laptop. */ .config = { /* AP: by default use EC settings */ @@ -768,7 +774,7 @@ struct motion_sensor_t motion_sensors[] = { .port = I2C_PORT_GYRO, .addr = BMI160_ADDR0, .default_range = 1000, /* dps */ - .rot_standard_ref = NULL, /* Identity Matrix. */ + .rot_standard_ref = &base_standard_ref, .config = { /* AP: by default shutdown all sensors */ [SENSOR_CONFIG_AP] = { @@ -805,7 +811,7 @@ struct motion_sensor_t motion_sensors[] = { .port = I2C_PORT_GYRO, .addr = BMI160_ADDR0, .default_range = 1 << 11, /* 16LSB / uT, fixed */ - .rot_standard_ref = NULL, /* Identity Matrix. */ + .rot_standard_ref = &mag_standard_ref, .config = { /* AP: by default shutdown all sensors */ [SENSOR_CONFIG_AP] = { @@ -841,7 +847,7 @@ struct motion_sensor_t motion_sensors[] = { .drv_data = &g_kx022_data, .port = I2C_PORT_LID_ACCEL, .addr = KX022_ADDR1, - .rot_standard_ref = &base_standard_ref, /* Identity matrix. */ + .rot_standard_ref = NULL, /* Identity matrix. */ .default_range = 2, /* g, enough for laptop. */ .config = { /* AP: by default use EC settings */ diff --git a/board/reef/board.h b/board/reef/board.h index 28d2cf4fee..f3bf64e101 100644 --- a/board/reef/board.h +++ b/board/reef/board.h @@ -17,6 +17,15 @@ */ #define CONFIG_SYSTEM_UNLOCKED +/* + * By default, enable all console messages excepted HC, ACPI and event: + * The sensor stack is generating a lot of activity. + */ +#define CC_DEFAULT (CC_ALL & ~(CC_MASK(CC_EVENTS) | CC_MASK(CC_LPC))) +#undef CONFIG_HOSTCMD_DEBUG_MODE +#define CONFIG_HOSTCMD_DEBUG_MODE HCDEBUG_OFF + + /* EC console commands */ #define CONFIG_CMD_ACCELS #define CONFIG_CMD_CHARGER_ADC_AMON_BMON @@ -29,9 +38,6 @@ #define BD99955_PSYS_GAIN_SELECT \ BD99955_CMD_PMON_IOUT_CTRL_SET_PMON_GAIN_SET_02UAW -#undef CONFIG_HOSTCMD_DEBUG_MODE -#define CONFIG_HOSTCMD_DEBUG_MODE HCDEBUG_OFF - /* Battery */ #define CONFIG_BATTERY_CUT_OFF #define CONFIG_BATTERY_PRESENT_CUSTOM @@ -154,10 +160,12 @@ #define I2C_PORT_ACCEL I2C_PORT_GYRO /* Sensors */ +#define CONFIG_MKBP_EVENT +#define CONFIG_MKBP_USE_HOST_EVENT #define CONFIG_ACCELGYRO_BMI160 -#define CONFIG_MAG_BMI160_BMM150 -#define BMM150_I2C_ADDRESS BMM150_ADDR0 /* 8-bit address */ -#define CONFIG_MAG_CALIBRATE +#define CONFIG_MAG_BMI160_BMM150 +#define BMM150_I2C_ADDRESS BMM150_ADDR0 /* 8-bit address */ +#define CONFIG_MAG_CALIBRATE #define CONFIG_ACCEL_KX022 #define CONFIG_ALS #define CONFIG_ALS_OPT3001