summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2015-05-11 16:18:37 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-05-12 23:36:00 +0000
commit5dd0f62c312946a3ddbb1baebfaf585d04a72a0a (patch)
treeb20dad8af19bd868aab8b20f598cfc03ff89bcd5
parent8d04e95a49b0f9e63bba99e1911ff80616738064 (diff)
downloadchrome-ec-5dd0f62c312946a3ddbb1baebfaf585d04a72a0a.tar.gz
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>
-rw-r--r--board/ryu/board.c49
-rw-r--r--board/ryu/board.h6
-rw-r--r--board/ryu/ec.tasklist1
3 files changed, 56 insertions, 0 deletions
diff --git a/board/ryu/board.c b/board/ryu/board.c
index a9792ed8ed..a361198748 100644
--- a/board/ryu/board.c
+++ b/board/ryu/board.c
@@ -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 */
diff --git a/board/ryu/board.h b/board/ryu/board.h
index ad017a48b6..3b92e8d2d3 100644
--- a/board/ryu/board.h
+++ b/board/ryu/board.h
@@ -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
diff --git a/board/ryu/ec.tasklist b/board/ryu/ec.tasklist
index 4c040bd207..78b7a758c8 100644
--- a/board/ryu/ec.tasklist
+++ b/board/ryu/ec.tasklist
@@ -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) \