ryu: Add bosh sensor to smaug EC.

Add Primitive support for Bosh Sensor.
Neither gesture nor FIFO are supported.

BUG=chrome-os-partner:39900
BRANCH=none
TEST=Running accelinfo.
From user space, check values via /sys/class/iio/devices/...

Change-Id: I62dbe230c9064ec7c0fa8e343bbe6eae843e3ac0
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/270455
Reviewed-by: Sheng-liang Song <ssl@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
This commit is contained in:
Gwendal Grignou
2015-05-11 16:18:37 -07:00
committed by ChromeOS Commit Bot
parent 8d04e95a49
commit 5dd0f62c31
3 changed files with 56 additions and 0 deletions

View File

@@ -14,6 +14,7 @@
#include "charger.h"
#include "common.h"
#include "console.h"
#include "driver/accelgyro_bmi160.h"
#include "ec_version.h"
#include "gpio.h"
#include "hooks.h"
@@ -21,6 +22,7 @@
#include "i2c.h"
#include "inductive_charging.h"
#include "lid_switch.h"
#include "motion_sense.h"
#include "power.h"
#include "power_button.h"
#include "registers.h"
@@ -362,6 +364,53 @@ const struct i2c_port_t i2c_ports[] = {
};
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
/* Sensor mutex */
static struct mutex g_mutex;
/* local sensor data (per-sensor) */
struct motion_data_t g_saved_data[2];
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 = "Accel",
.active_mask = SENSOR_ACTIVE_S0_S3_S5,
.chip = MOTIONSENSE_CHIP_BMI160,
.type = MOTIONSENSE_TYPE_ACCEL,
.location = MOTIONSENSE_LOC_LID,
.drv = &bmi160_drv,
.mutex = &g_mutex,
.drv_data = &g_saved_data[0],
.i2c_addr = BMI160_ADDR0,
.rot_standard_ref = NULL,
.default_config = {
.odr = 100000,
.range = 2
}
},
{.name = "Gyro",
.active_mask = SENSOR_ACTIVE_S0_S3,
.chip = MOTIONSENSE_CHIP_BMI160,
.type = MOTIONSENSE_TYPE_GYRO,
.location = MOTIONSENSE_LOC_LID,
.drv = &bmi160_drv,
.mutex = &g_mutex,
.drv_data = &g_saved_data[1],
.i2c_addr = BMI160_ADDR0,
.rot_standard_ref = NULL,
.default_config = {
.odr = 100000,
.range = 2000
}
},
};
const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
static void board_set_usb_switches(int port, int open)
{
/* If switch is not changing, then return */

View File

@@ -77,6 +77,7 @@
#define I2C_PORT_CHARGER I2C_PORT_MASTER
#define I2C_PORT_BATTERY I2C_PORT_MASTER
#define I2C_PORT_LIGHTBAR I2C_PORT_MASTER
#define I2C_PORT_ACCEL I2C_PORT_MASTER
/* slave address for host commands */
#ifdef HAS_TASK_HOSTCMD
@@ -123,6 +124,11 @@
/* Enable Case Closed Debugging */
#define CONFIG_CASE_CLOSED_DEBUG
/* Sensor support */
#define CONFIG_ACCELGYRO_BMI160
#define CONFIG_CMD_ACCELS
#define CONFIG_CMD_ACCEL_INFO
/* Maximum number of deferrable functions */
#undef DEFERRABLE_MAX_COUNT
#define DEFERRABLE_MAX_COUNT 16

View File

@@ -21,6 +21,7 @@
TASK_ALWAYS(USB_CHG, usb_charger_task, NULL, SMALLER_TASK_STACK_SIZE) \
TASK_NOTEST(LIGHTBAR, lightbar_task, NULL, LARGER_TASK_STACK_SIZE) \
TASK_ALWAYS(CHARGER, charger_task, NULL, TASK_STACK_SIZE) \
TASK_NOTEST(MOTIONSENSE, motion_sense_task, NULL, TASK_STACK_SIZE) \
TASK_NOTEST(CHIPSET, chipset_task, NULL, TASK_STACK_SIZE) \
TASK_NOTEST(HOSTCMD, host_command_task, NULL, TASK_STACK_SIZE) \
TASK_ALWAYS(CONSOLE, console_task, NULL, LARGER_TASK_STACK_SIZE) \