summaryrefslogtreecommitdiff
path: root/board/glados/board.c
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2015-09-14 14:14:25 -0700
committerchrome-bot <chrome-bot@chromium.org>2015-09-19 02:00:54 -0700
commitd341615383f1ea5d3a540a67bcec777ba902bdfb (patch)
tree8c39af34493d8b42d8dc27cf85a0709485ec4b66 /board/glados/board.c
parentf46c115a28161a81ce17449201c0e8b29a7ef13f (diff)
downloadchrome-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/glados/board.c')
-rw-r--r--board/glados/board.c81
1 files changed, 79 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,