diff options
author | Aseda Aboagye <aaboagye@google.com> | 2015-09-14 14:14:25 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2015-09-19 02:00:54 -0700 |
commit | d341615383f1ea5d3a540a67bcec777ba902bdfb (patch) | |
tree | 8c39af34493d8b42d8dc27cf85a0709485ec4b66 /board | |
parent | f46c115a28161a81ce17449201c0e8b29a7ef13f (diff) | |
download | chrome-ec-d341615383f1ea5d3a540a67bcec777ba902bdfb.tar.gz |
GLaDOS: Add base accel & gyro.
This commit adds the base accelerometer as well as the gyroscope to the
list of motion sensors on the board. They are currently wrapped behind an
ifdef for HAS_TASK_MOTIONSENSE due to space constraints.
BUG=chrome-os-partner:43494
BRANCH=None
TEST=Build GLaDOS EC with driver enabled and verify that we can calcuate
a valid lid angle.
TEST=Verify that signs of accelerometer conform to those shown in the
Chrome/Android/HTML5 doc/spec. See description in accelerometer_types.h
TEST=Verify that signs of gyroscope conform to those shown in the
"Sysfs interface to EC accelerometers" document.
TEST=make buildall tests
CQ-DEPEND=CL:299504
CQ-DEPEND=CL:300510
Change-Id: I34026813431f0df6211f9c781ab5b8c7b4dd8403
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/299886
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Diffstat (limited to 'board')
-rw-r--r-- | board/glados/board.c | 81 | ||||
-rw-r--r-- | board/glados/board.h | 4 |
2 files changed, 83 insertions, 2 deletions
diff --git a/board/glados/board.c b/board/glados/board.c index af1352d9c1..5fa6217eb7 100644 --- a/board/glados/board.c +++ b/board/glados/board.c @@ -17,6 +17,7 @@ #include "driver/als_opt3001.h" #include "driver/accel_kionix.h" #include "driver/accel_kx022.h" +#include "driver/accelgyro_bmi160.h" #include "extpower.h" #include "gpio.h" #include "hooks.h" @@ -427,10 +428,11 @@ static void board_handle_reboot(void) } DECLARE_HOOK(HOOK_INIT, board_handle_reboot, HOOK_PRIO_FIRST); -/* Motion sensors */ #ifdef HAS_TASK_MOTIONSENSE -/* Lid Sensor mutex */ +/* Motion sensors */ +/* Mutexes */ static struct mutex g_lid_mutex; +static struct mutex g_base_mutex; /* KX022 private data */ struct kionix_accel_data g_kx022_data = { @@ -438,6 +440,81 @@ struct kionix_accel_data g_kx022_data = { }; struct motion_sensor_t motion_sensors[] = { + /* + * Note: bmi160: supports accelerometer and gyro sensor + * Requirement: accelerometer sensor must init before gyro sensor + * DO NOT change the order of the following table. + */ + {.name = "Base Accel", + .active_mask = SENSOR_ACTIVE_S0, + .chip = MOTIONSENSE_CHIP_BMI160, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_BASE, + .drv = &bmi160_drv, + .mutex = &g_base_mutex, + .drv_data = &g_bmi160_data, + .addr = BMI160_ADDR0, + .rot_standard_ref = NULL, /* Identity matrix. */ + .default_range = 2, /* g, enough for laptop. */ + .config = { + /* AP: by default use EC settings */ + [SENSOR_CONFIG_AP] = { + .odr = 0, + .ec_rate = 0, + }, + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 10000 | ROUND_UP_FLAG, + .ec_rate = 100, + }, + /* Sensor off in S3/S5 */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 0, + .ec_rate = 0 + }, + /* Sensor off in S3/S5 */ + [SENSOR_CONFIG_EC_S5] = { + .odr = 0, + .ec_rate = 0 + }, + }, + }, + + {.name = "Base Gyro", + .active_mask = SENSOR_ACTIVE_S0, + .chip = MOTIONSENSE_CHIP_BMI160, + .type = MOTIONSENSE_TYPE_GYRO, + .location = MOTIONSENSE_LOC_BASE, + .drv = &bmi160_drv, + .mutex = &g_base_mutex, + .drv_data = &g_bmi160_data, + .addr = BMI160_ADDR0, + .default_range = 1000, /* dps */ + .rot_standard_ref = NULL, /* Identity Matrix. */ + .config = { + /* AP: by default shutdown all sensors */ + [SENSOR_CONFIG_AP] = { + .odr = 0, + .ec_rate = 0, + }, + /* EC does not need in S0 */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 0, + .ec_rate = 0, + }, + /* Sensor off in S3/S5 */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 0, + .ec_rate = 0, + }, + /* Sensor off in S3/S5 */ + [SENSOR_CONFIG_EC_S5] = { + .odr = 0, + .ec_rate = 0, + }, + }, + }, + {.name = "Lid Accel", .active_mask = SENSOR_ACTIVE_S0, .chip = MOTIONSENSE_CHIP_KX022, diff --git a/board/glados/board.h b/board/glados/board.h index 994b6d8177..28b4874520 100644 --- a/board/glados/board.h +++ b/board/glados/board.h @@ -9,6 +9,7 @@ #define __CROS_EC_BOARD_H /* Optional features */ +#define CONFIG_ACCELGYRO_BMI160 #define CONFIG_ACCEL_KX022 #define CONFIG_ADC #define CONFIG_ALS @@ -40,6 +41,9 @@ #define CONFIG_I2C #define CONFIG_KEYBOARD_PROTOCOL_8042 #define CONFIG_LED_COMMON +#define CONFIG_LID_ANGLE +#define CONFIG_LID_ANGLE_SENSOR_BASE 0 +#define CONFIG_LID_ANGLE_SENSOR_LID 2 #define CONFIG_LID_SWITCH #define CONFIG_LOW_POWER_IDLE #define CONFIG_PORT80_TASK_EN |