diff options
-rw-r--r-- | board/umaro/board.c | 95 | ||||
-rw-r--r-- | board/umaro/board.h | 22 | ||||
-rw-r--r-- | board/umaro/ec.tasklist | 1 |
3 files changed, 117 insertions, 1 deletions
diff --git a/board/umaro/board.c b/board/umaro/board.c index bba62e18b2..b0d4f92c64 100644 --- a/board/umaro/board.c +++ b/board/umaro/board.c @@ -90,7 +90,6 @@ struct ec_thermal_config thermal_params[] = { }; BUILD_ASSERT(ARRAY_SIZE(thermal_params) == TEMP_SENSOR_COUNT); - const struct button_config buttons[] = { {"Volume Down", KEYBOARD_BUTTON_VOLUME_DOWN, GPIO_VOLUME_DOWN, 30 * MSEC, 0}, @@ -99,6 +98,100 @@ const struct button_config buttons[] = { }; BUILD_ASSERT(ARRAY_SIZE(buttons) == CONFIG_BUTTON_COUNT); +/* Four Motion sensors */ +/* kxcj9 mutex and local/private data*/ +static struct mutex g_kxcj9_mutex[2]; +struct kionix_accel_data g_kxcj9_data[2]; + +/* Matrix to rotate accelrator into standard reference frame */ +const matrix_3x3_t base_standard_ref = { + { 0, FLOAT_TO_FP(-1), 0}, + {FLOAT_TO_FP(-1), 0, 0}, + { 0, 0, FLOAT_TO_FP(-1)} +}; + +const matrix_3x3_t lid_standard_ref = { + {FLOAT_TO_FP(1), 0, 0}, + { 0, FLOAT_TO_FP(1), 0}, + { 0, 0, FLOAT_TO_FP(1)} +}; + +struct motion_sensor_t motion_sensors[] = { + [BASE_ACCEL] = { + .name = "Base Accel", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_KXCJ9, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_BASE, + .drv = &kionix_accel_drv, + .mutex = &g_kxcj9_mutex[0], + .drv_data = &g_kxcj9_data[0], + .port = I2C_PORT_ACCEL, + .addr = KXCJ9_ADDR1, + .rot_standard_ref = &base_standard_ref, + .default_range = 2, /* g, enough for laptop. */ + .config = { + /* AP: by default shutdown all sensors */ + [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 = 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 + }, + } + }, + [LID_ACCEL] = { + .name = "Lid Accel", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_KXCJ9, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_LID, + .drv = &kionix_accel_drv, + .mutex = &g_kxcj9_mutex[1], + .drv_data = &g_kxcj9_data[1], + .port = I2C_PORT_ACCEL, + .addr = KXCJ9_ADDR0, + .rot_standard_ref = &lid_standard_ref, + .default_range = 2, /* g, enough for laptop. */ + .config = { + /* AP: by default shutdown all sensors */ + [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 = 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 + }, + }, + }, +}; +const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); + /* init ADC ports to avoid floating state due to thermistors */ static void adc_pre_init(void) { diff --git a/board/umaro/board.h b/board/umaro/board.h index cec51c0dbe..2a681f7b6d 100644 --- a/board/umaro/board.h +++ b/board/umaro/board.h @@ -63,6 +63,12 @@ #define CONFIG_I2C +/* Accelerometer */ +#define CONFIG_ACCEL_KXCJ9 +#define CONFIG_CMD_ACCELS +#define CONFIG_CMD_ACCEL_INFO +#define CONFIG_LID_ANGLE + /* Wireless signals */ #define WIRELESS_GPIO_WLAN GPIO_WLAN_OFF_L @@ -95,6 +101,22 @@ enum adc_channel { ADC_CH_COUNT }; +/* Sensor index definition */ +enum sensor_id { + BASE_ACCEL = 0, + LID_ACCEL = 1, +}; + +/* + * We have not enabled the sensor FIFO on the accels, so we force the EC + * to collect at every sample. + */ +#define CONFIG_ACCEL_FORCE_MODE_MASK \ + ((1 << BASE_ACCEL) | (1 << LID_ACCEL)) + +#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL +#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL + /* power signal definitions */ enum power_signal { X86_ALL_SYS_PWRGD = 0, diff --git a/board/umaro/ec.tasklist b/board/umaro/ec.tasklist index 160bf6dad7..faa2d681c9 100644 --- a/board/umaro/ec.tasklist +++ b/board/umaro/ec.tasklist @@ -19,6 +19,7 @@ #define CONFIG_TASK_LIST \ TASK_ALWAYS(HOOKS, hook_task, NULL, LARGER_TASK_STACK_SIZE) \ TASK_ALWAYS(CHARGER, charger_task, NULL, LARGER_TASK_STACK_SIZE) \ + TASK_NOTEST(MOTIONSENSE, motion_sense_task, NULL, LARGER_TASK_STACK_SIZE) \ TASK_NOTEST(CHIPSET, chipset_task, NULL, LARGER_TASK_STACK_SIZE) \ TASK_NOTEST(KEYPROTO, keyboard_protocol_task, NULL, TASK_STACK_SIZE) \ TASK_ALWAYS(HOSTCMD, host_command_task, NULL, LARGER_TASK_STACK_SIZE) \ |