From 8df604fec43740653366a79f53ec6378b97255f9 Mon Sep 17 00:00:00 2001 From: Jett Rink Date: Thu, 7 Feb 2019 15:19:49 -0700 Subject: arcada_ish: add sensor and heci tasks Add sensor configuration for LSM6DS3 and heci host command task to transfer sensor data to AP BRANCH=none BUG=b:122281217 TEST=arcada_ish can pass sensor data through iio sysfs interface using CL stack and under-development kernel driver Change-Id: Ic9250f6781b8501afe99e2999940020a2437e664 Signed-off-by: Jett Rink Reviewed-on: https://chromium-review.googlesource.com/c/1460085 --- board/arcada_ish/board.c | 71 ++++++++++++++++++++++++++++++++++++++++++-- board/arcada_ish/board.h | 28 ++++++++++++++--- board/arcada_ish/ec.tasklist | 7 ++++- 3 files changed, 98 insertions(+), 8 deletions(-) diff --git a/board/arcada_ish/board.c b/board/arcada_ish/board.c index cd66add92c..0c0fabc86e 100644 --- a/board/arcada_ish/board.c +++ b/board/arcada_ish/board.c @@ -5,14 +5,17 @@ /* Arcada ISH board-specific configuration */ +#include "accelgyro_lsm6dsm.h" #include "console.h" #include "gpio.h" +#include "hooks.h" #include "host_command.h" #include "i2c.h" +#include "motion_sense.h" +#include "power.h" +#include "task.h" #include "gpio_list.h" /* has to be included last */ -#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args) -#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ## args) /* I2C port map */ const struct i2c_port_t i2c_ports[] = { @@ -24,8 +27,70 @@ const struct i2c_port_t i2c_ports[] = { }; const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); -/* dummy functions to remove 'undefined' symbol link error for acpi.o +/* Sensor config */ +static struct mutex g_base_mutex; +/* sensor private data */ +static struct lsm6dsm_data lsm6dsm_a_data; + +/* Drivers */ +struct motion_sensor_t motion_sensors[] = { + [BASE_ACCEL] = { + .name = "Base Accel", + .active_mask = SENSOR_ACTIVE_S0, + .chip = MOTIONSENSE_CHIP_LSM6DS3, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_BASE, + .drv = &lsm6dsm_drv, + .mutex = &g_base_mutex, + .drv_data = &lsm6dsm_a_data, + .port = I2C_PORT_SENSOR, + .addr = LSM6DSM_ADDR1, + .rot_standard_ref = NULL, /* TODO rotate correctly */ + .default_range = 4, /* g */ + .min_frequency = LSM6DSM_ODR_MIN_VAL, + .max_frequency = LSM6DSM_ODR_MAX_VAL, + .config = { + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 13000 | ROUND_UP_FLAG, + .ec_rate = 100 * MSEC, + }, + }, + }, + /* TODO(b/122281217): Add remain sensors */ +}; +const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); + +/* TODO(b/122364080): replace when implement real chipset/power task */ +int chipset_in_state(int state_mask) +{ + /* Until we know better, ISH assumes AP is always ON */ + return state_mask & CHIPSET_STATE_ON; +} + +/* TODO(b/122364080): replace when implement real chipset/power task */ +int chipset_in_or_transitioning_to_state(int state_mask) +{ + /* Until we know better, ISH assumes AP is always ON */ + return state_mask & CHIPSET_STATE_ON; +} + +/* TODO(b/122364080): replace when implement real chipset/power task */ +void chipset_force_shutdown(enum chipset_shutdown_reason reason) +{ +} + +/* TODO(b/122364080): remove when implement real chipset/power task */ +int board_idle_task(void *unused) +{ + while (1) + task_wait_event(-1); +} + +/* + * Dummy functions to remove 'undefined' symbol link error for acpi.o * due to CONFIG_LPC flag + * TODO(b/123634700): clean this up when implement EC->AP communication */ #ifdef CONFIG_HOSTCMD_LPC int lpc_query_host_event_state(void) diff --git a/board/arcada_ish/board.h b/board/arcada_ish/board.h index ec187cab51..119b63ce9a 100644 --- a/board/arcada_ish/board.h +++ b/board/arcada_ish/board.h @@ -31,18 +31,33 @@ #define CONFIG_I2C #define CONFIG_I2C_MASTER +#define CONFIG_ACCELGYRO_LSM6DSM /* For LSM6DS3 */ +/* TODO(b/123634700): This is temporary until FIFO is supported */ +#define CONFIG_ACCEL_FORCE_MODE_MASK (1 << BASE_ACCEL) + +/* HECI Support*/ +#define CONFIG_HECI +/* ISH IPC (over HECI) */ +#define CONFIG_ISH_IPC +/* Host command over HECI */ +#define CONFIG_HOSTCMD_HECI + /* I2C ports */ #define I2C_PORT_SENSOR ISH_I2C0 #define CONFIG_CMD_I2C_XFER -/* Undefine features */ +/* EC Console Commands */ +#define CONFIG_CMD_ACCELS +#define CONFIG_CMD_ACCEL_INFO +#define CONFIG_CMD_TIMERINFO + +/* Undefined features */ #undef CONFIG_CMD_HASH #undef CONFIG_CMD_I2C_SCAN #undef CONFIG_CMD_KEYBOARD #undef CONFIG_CMD_POWER_AP #undef CONFIG_CMD_POWERINDEBUG #undef CONFIG_CMD_SHMEM -#undef CONFIG_CMD_TIMERINFO #undef CONFIG_EXTPOWER #undef CONFIG_KEYBOARD_KSO_BASE #undef CONFIG_FLASH @@ -55,10 +70,8 @@ #undef CONFIG_WATCHDOG /* Modules we want to exclude */ -#undef CONFIG_CMD_ACCELS #undef CONFIG_CMD_HASH #undef CONFIG_CMD_TEMP_SENSOR -#undef CONFIG_CMD_TIMERINFO #undef CONFIG_ADC #undef CONFIG_SHA256 @@ -67,6 +80,13 @@ #include "gpio_signal.h" #include "registers.h" +/* Motion sensors */ +enum sensor_id { + BASE_ACCEL, + /* TODO(b/122281217): Add remain sensors */ + SENSOR_COUNT +}; + #endif /* !__ASSEMBLER__ */ #endif /* __CROS_EC_BOARD_H */ diff --git a/board/arcada_ish/ec.tasklist b/board/arcada_ish/ec.tasklist index b6e2cf28d5..1da6803690 100644 --- a/board/arcada_ish/ec.tasklist +++ b/board/arcada_ish/ec.tasklist @@ -21,4 +21,9 @@ #define CONFIG_TASK_LIST \ TASK_ALWAYS(HOOKS, hook_task, NULL, HUGE_TASK_STACK_SIZE, 0) \ - TASK_ALWAYS(CONSOLE, console_task, NULL, LARGER_TASK_STACK_SIZE, 0) + TASK_ALWAYS(MOTIONSENSE, motion_sense_task, NULL, LARGER_TASK_STACK_SIZE, 0) \ + TASK_NOTEST(CHIPSET, board_idle_task, NULL, IDLE_TASK_STACK_SIZE, 0) \ + TASK_ALWAYS(HOSTCMD, host_command_task, NULL, LARGER_TASK_STACK_SIZE, 0) \ + TASK_ALWAYS(CONSOLE, console_task, NULL, LARGER_TASK_STACK_SIZE, 0) \ + TASK_ALWAYS(HECI_RX, heci_rx_task, NULL, HUGE_TASK_STACK_SIZE, 0) \ + TASK_ALWAYS(IPC_MNG, ipc_mng_task, NULL, LARGER_TASK_STACK_SIZE, 0) -- cgit v1.2.1