mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-10 01:21:49 +00:00
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>
This commit is contained in:
committed by
chrome-bot
parent
f46c115a28
commit
d341615383
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -182,6 +182,7 @@ static int raw_write8(const int addr, const uint8_t reg, int data)
|
||||
return rv;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ACCEL_INTERRUPTS
|
||||
/**
|
||||
* Read 32bit register from accelerometer.
|
||||
*/
|
||||
@@ -201,6 +202,7 @@ static int raw_read32(const int addr, const uint8_t reg, int *data_ptr)
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
#endif /* defined(CONFIG_ACCEL_INTERRUPTS) */
|
||||
|
||||
/**
|
||||
* Read n bytes from accelerometer.
|
||||
@@ -485,9 +487,11 @@ static int get_offset(const struct motion_sensor_t *s,
|
||||
BMI160_OFFSET_GYRO_DIV_MDS;
|
||||
}
|
||||
break;
|
||||
#ifdef CONFIG_MAG_BMI160_BMM150
|
||||
case MOTIONSENSE_TYPE_MAG:
|
||||
bmm150_get_offset(s, v);
|
||||
break;
|
||||
#endif /* defined(CONFIG_MAG_BMI160_BMM150) */
|
||||
default:
|
||||
for (i = X; i <= Z; i++)
|
||||
v[i] = 0;
|
||||
@@ -548,9 +552,11 @@ static int set_offset(const struct motion_sensor_t *s,
|
||||
ret = raw_write8(s->addr, BMI160_OFFSET_EN_GYR98,
|
||||
val98 | BMI160_OFFSET_GYRO_EN);
|
||||
break;
|
||||
#ifdef CONFIG_MAG_BMI160_BMM150
|
||||
case MOTIONSENSE_TYPE_MAG:
|
||||
ret = bmm150_set_offset(s, v);
|
||||
break;
|
||||
#endif /* defined(CONFIG_MAG_BMI160) */
|
||||
default:
|
||||
ret = EC_RES_INVALID_PARAM;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user