diff options
Diffstat (limited to 'board/umaro/board.c')
-rw-r--r-- | board/umaro/board.c | 95 |
1 files changed, 94 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) { |