diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2014-10-28 17:52:25 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-11-18 05:20:15 +0000 |
commit | d64324ad4d2211f9326dbaaed873c66c390f6f5b (patch) | |
tree | 614941e6da7e80f718c13db8b907befd39f043f7 | |
parent | 3bdd18d24654f4131f24439efe2c05f031fd67cb (diff) | |
download | chrome-ec-d64324ad4d2211f9326dbaaed873c66c390f6f5b.tar.gz |
ryu: Add LSM6DS0 support.
Add Code to setup LSM6DS0 gyro/accell in sensor hub.
BUG=chrome-os-partner:31071
BRANCH=ToT
TEST=See the compass and gyro.
Message at boot:
[0.007142 hash start 0x00010000 0x000096dd]
[0.007293 Inits done]
[0.007506 power state 2 = S3, in 0x0000]
[0.007765 power state 3 = S0, in 0x0000]
[0.007908 event set 0x00002000]
[0.008021 hostcmd init 0x2000]
[0.111195 Accel: MS Done Init type:0x1 range:2 odr:119000]
[0.116751 Gyro: MS Done Init type:0x2 range:2000 odr:119000]
[0.146870 hash done
f87d7824b439db923d270df016af5aabec51b73505b7c4faa6e40c16b12dd392]
Check '/usr/sbin/ectool --name=cros_sh motionsense' works.
Change-Id: I7ca87faf92803486d8d2d51c7ffe4c6d8c9efef2
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/226882
Reviewed-by: Sheng-liang Song <ssl@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
-rw-r--r-- | board/ryu_sh/board.c | 25 | ||||
-rw-r--r-- | board/ryu_sh/board.h | 3 | ||||
-rw-r--r-- | board/ryu_sh/ec.tasklist | 1 |
3 files changed, 29 insertions, 0 deletions
diff --git a/board/ryu_sh/board.c b/board/ryu_sh/board.c index c6af0f8388..c2c4c32f20 100644 --- a/board/ryu_sh/board.c +++ b/board/ryu_sh/board.c @@ -6,9 +6,11 @@ #include "common.h" #include "console.h" +#include "driver/accelgyro_lsm6ds0.h" #include "gpio.h" #include "hooks.h" #include "i2c.h" +#include "motion_sense.h" #include "power.h" #include "registers.h" #include "task.h" @@ -37,6 +39,29 @@ const struct i2c_port_t i2c_ports[] = { }; const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); +/* Sensor mutex */ +static struct mutex g_mutex; + +struct motion_sensor_t motion_sensors[] = { + + /* + * Note: lsm6ds0: supports accelerometer and gyro sensor + * Requriement: accelerometer sensor must init before gyro sensor + * DO NOT change the order of the following table. + */ + {SENSOR_ACTIVE_S0_S3, "Accel", MOTIONSENSE_CHIP_LSM6DS0, + MOTIONSENSE_TYPE_ACCEL, MOTIONSENSE_LOC_LID, + &lsm6ds0_drv, &g_mutex, NULL, + LSM6DS0_ADDR1, NULL, 119000, 2}, + + {SENSOR_ACTIVE_S0_S3, "Gyro", MOTIONSENSE_CHIP_LSM6DS0, + MOTIONSENSE_TYPE_GYRO, MOTIONSENSE_LOC_LID, + &lsm6ds0_drv, &g_mutex, NULL, + LSM6DS0_ADDR1, NULL, 119000, 2000}, + +}; +const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); + void board_config_pre_init(void) { /* diff --git a/board/ryu_sh/board.h b/board/ryu_sh/board.h index 7db8da45b3..5b341c06c4 100644 --- a/board/ryu_sh/board.h +++ b/board/ryu_sh/board.h @@ -21,6 +21,7 @@ /* Optional features */ #undef CONFIG_EXTPOWER #undef CONFIG_HIBERNATE +#define CONFIG_ACCELGYRO_LSM6DS0 #define CONFIG_STM_HWTIMER32 #define CONFIG_I2C #define CONFIG_BOARD_PRE_INIT @@ -28,6 +29,8 @@ #undef CONFIG_CMD_POWER_AP #define CONFIG_POWER_COMMON #define CONFIG_CHIPSET_ECDRIVEN +#define CONFIG_CMD_ACCELS +#define CONFIG_CMD_ACCEL_INFO #define CONFIG_VBOOT_HASH #undef CONFIG_WATCHDOG_HELP diff --git a/board/ryu_sh/ec.tasklist b/board/ryu_sh/ec.tasklist index a3fe8448af..421cf57ed8 100644 --- a/board/ryu_sh/ec.tasklist +++ b/board/ryu_sh/ec.tasklist @@ -20,4 +20,5 @@ TASK_ALWAYS(HOOKS, hook_task, NULL, LARGER_TASK_STACK_SIZE) \ TASK_NOTEST(HOSTCMD, host_command_task, NULL, TASK_STACK_SIZE) \ TASK_NOTEST(CHIPSET, chipset_task, NULL, TASK_STACK_SIZE) \ + TASK_NOTEST(MOTIONSENSE, motion_sense_task, NULL, TASK_STACK_SIZE) \ TASK_ALWAYS(CONSOLE, console_task, NULL, TASK_STACK_SIZE) |