diff options
-rw-r--r-- | board/amenia/board.c | 83 | ||||
-rw-r--r-- | board/amenia/board.h | 11 | ||||
-rw-r--r-- | board/reef/board.c | 77 | ||||
-rw-r--r-- | board/reef/board.h | 11 | ||||
-rw-r--r-- | board/wheatley/board.c | 122 | ||||
-rw-r--r-- | board/wheatley/board.h | 16 |
6 files changed, 165 insertions, 155 deletions
diff --git a/board/amenia/board.c b/board/amenia/board.c index e0d7cc94d0..77c5343daa 100644 --- a/board/amenia/board.c +++ b/board/amenia/board.c @@ -487,11 +487,42 @@ const matrix_3x3_t base_standard_ref = { struct kionix_accel_data g_kx022_data; 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. - */ + [BASE_ACCEL] = { + .name = "Base Accel", + .active_mask = SENSOR_ACTIVE_S0, + .chip = MOTIONSENSE_CHIP_KX022, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_BASE, + .drv = &kionix_accel_drv, + .mutex = &g_base_mutex, + .drv_data = &g_kx022_data, + .port = I2C_PORT_ACCEL, + .addr = KX022_ADDR1, + .rot_standard_ref = &base_standard_ref, + .default_range = 2, /* g, enough for laptop. */ + .config = { + /* AP: diabled until AP asks for data */ + [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 = 100 * MSEC, + }, + /* unused */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 0, + .ec_rate = 0, + }, + [SENSOR_CONFIG_EC_S5] = { + .odr = 0, + .ec_rate = 0, + }, + }, + }, + [LID_ACCEL] = { .name = "Lid Accel", .active_mask = SENSOR_ACTIVE_S0, @@ -508,8 +539,8 @@ struct motion_sensor_t motion_sensors[] = { .config = { /* AP: by default use EC settings */ [SENSOR_CONFIG_AP] = { - .odr = 10000 | ROUND_UP_FLAG, - .ec_rate = 100 * MSEC, + .odr = 0, + .ec_rate = 0, }, /* EC use accel for angle detection */ [SENSOR_CONFIG_EC_S0] = { @@ -603,42 +634,6 @@ struct motion_sensor_t motion_sensors[] = { }, }, - [BASE_ACCEL] = { - .name = "Base Accel", - .active_mask = SENSOR_ACTIVE_S0, - .chip = MOTIONSENSE_CHIP_KX022, - .type = MOTIONSENSE_TYPE_ACCEL, - .location = MOTIONSENSE_LOC_BASE, - .drv = &kionix_accel_drv, - .mutex = &g_base_mutex, - .drv_data = &g_kx022_data, - .port = I2C_PORT_ACCEL, - .addr = KX022_ADDR1, - .rot_standard_ref = &base_standard_ref, /* Identity matrix. */ - .default_range = 2, /* g, enough for laptop. */ - .config = { - /* AP: by default use EC settings */ - [SENSOR_CONFIG_AP] = { - .odr = 10000 | ROUND_UP_FLAG, - .ec_rate = 100 * MSEC, - }, - /* EC use accel for angle detection */ - [SENSOR_CONFIG_EC_S0] = { - .odr = 10000 | ROUND_UP_FLAG, - .ec_rate = 100 * MSEC, - }, - /* unused */ - [SENSOR_CONFIG_EC_S3] = { - .odr = 0, - .ec_rate = 0, - }, - [SENSOR_CONFIG_EC_S5] = { - .odr = 0, - .ec_rate = 0, - }, - }, - }, - [BASE_BARO] = { .name = "Base Baro", .active_mask = SENSOR_ACTIVE_S0, @@ -649,7 +644,7 @@ struct motion_sensor_t motion_sensors[] = { .drv_data = &bmp280_drv_data, .port = I2C_PORT_BARO, .addr = BMP280_I2C_ADDRESS1, - .rot_standard_ref = NULL, /* Identity Matrix. */ + .rot_standard_ref = NULL, .config = { /* AP: by default shutdown all sensors */ [SENSOR_CONFIG_AP] = { diff --git a/board/amenia/board.h b/board/amenia/board.h index 61904a0079..e4ae82bae8 100644 --- a/board/amenia/board.h +++ b/board/amenia/board.h @@ -208,12 +208,17 @@ enum als_id { ALS_COUNT }; -/* Motion sensors */ +/* + * Motion sensors + * When reading through IO memory is set up for sensors (LPC is used), + * the first 2 entries must be accelerometers, then gyroscope. + * For BMI160, accel, gyro and compass sensors must be next to each other. + */ enum sensor_id { - LID_ACCEL = 0, + BASE_ACCEL = 0, + LID_ACCEL, LID_GYRO, LID_MAG, - BASE_ACCEL, BASE_BARO, }; diff --git a/board/reef/board.c b/board/reef/board.c index c17315f68d..4592828d9a 100644 --- a/board/reef/board.c +++ b/board/reef/board.c @@ -717,11 +717,42 @@ struct kionix_accel_data g_kx022_data; /* FIXME(dhendrix): Copied from Amenia, probably need to tweak for Reef */ 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. - */ + [LID_ACCEL] = { + .name = "Lid Accel", + .active_mask = SENSOR_ACTIVE_S0, + .chip = MOTIONSENSE_CHIP_KX022, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_LID, + .drv = &kionix_accel_drv, + .mutex = &g_lid_mutex, + .drv_data = &g_kx022_data, + .port = I2C_PORT_LID_ACCEL, + .addr = KX022_ADDR1, + .rot_standard_ref = NULL, /* Identity matrix. */ + .default_range = 2, /* g, enough for laptop. */ + .config = { + /* AP: by default use EC settings */ + [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 = 100 * MSEC, + }, + /* unused */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 0, + .ec_rate = 0, + }, + [SENSOR_CONFIG_EC_S5] = { + .odr = 0, + .ec_rate = 0, + }, + }, + }, + [BASE_ACCEL] = { .name = "Base Accel", .active_mask = SENSOR_ACTIVE_S0, @@ -833,42 +864,6 @@ struct motion_sensor_t motion_sensors[] = { }, }, - [LID_ACCEL] = { - .name = "Lid Accel", - .active_mask = SENSOR_ACTIVE_S0, - .chip = MOTIONSENSE_CHIP_KX022, - .type = MOTIONSENSE_TYPE_ACCEL, - .location = MOTIONSENSE_LOC_LID, - .drv = &kionix_accel_drv, - .mutex = &g_lid_mutex, - .drv_data = &g_kx022_data, - .port = I2C_PORT_LID_ACCEL, - .addr = KX022_ADDR1, - .rot_standard_ref = NULL, /* Identity matrix. */ - .default_range = 2, /* g, enough for laptop. */ - .config = { - /* AP: by default use EC settings */ - [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 = 100 * MSEC, - }, - /* unused */ - [SENSOR_CONFIG_EC_S3] = { - .odr = 0, - .ec_rate = 0, - }, - [SENSOR_CONFIG_EC_S5] = { - .odr = 0, - .ec_rate = 0, - }, - }, - }, - [BASE_BARO] = { .name = "Base Baro", .active_mask = SENSOR_ACTIVE_S0, diff --git a/board/reef/board.h b/board/reef/board.h index 45674db744..d863611563 100644 --- a/board/reef/board.h +++ b/board/reef/board.h @@ -239,12 +239,17 @@ enum als_id { ALS_COUNT }; -/* Motion sensors */ +/* + * Motion sensors: + * When reading through IO memory is set up for sensors (LPC is used), + * the first 2 entries must be accelerometers, then gyroscope. + * For BMI160, accel, gyro and compass sensors must be next to each other. + */ enum sensor_id { - BASE_ACCEL = 0, + LID_ACCEL = 0, + BASE_ACCEL, BASE_GYRO, BASE_MAG, - LID_ACCEL, BASE_BARO, }; diff --git a/board/wheatley/board.c b/board/wheatley/board.c index 2ab07ccd58..fe0435d952 100644 --- a/board/wheatley/board.c +++ b/board/wheatley/board.c @@ -456,12 +456,44 @@ static struct mutex g_base_mutex; struct kionix_accel_data g_kx022_data; 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 = "Base Accel", + [LID_ACCEL] = { + .name = "Lid Accel", + .active_mask = SENSOR_ACTIVE_S0, + .chip = MOTIONSENSE_CHIP_KX022, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_LID, + .drv = &kionix_accel_drv, + .mutex = &g_lid_mutex, + .drv_data = &g_kx022_data, + .port = I2C_PORT_ACCEL, + .addr = KX022_ADDR1, + .rot_standard_ref = NULL, /* Identity matrix. */ + .default_range = 2, /* g, enough for laptop. */ + .config = { + /* AP: suspended until AP asks for data. */ + [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 = 100 * MSEC, + }, + /* unused */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 0, + .ec_rate = 0, + }, + [SENSOR_CONFIG_EC_S5] = { + .odr = 0, + .ec_rate = 0, + }, + }, + }, + + [BASE_ACCEL] = { + .name = "Base Accel", .active_mask = SENSOR_ACTIVE_S0, .chip = MOTIONSENSE_CHIP_BMI160, .type = MOTIONSENSE_TYPE_ACCEL, @@ -474,30 +506,31 @@ struct motion_sensor_t motion_sensors[] = { .rot_standard_ref = NULL, /* Identity matrix. */ .default_range = 2, /* g, enough for laptop. */ .config = { - /* AP: by default use EC settings */ - [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 = 100, - }, - /* 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 - }, + /* AP: suspended until AP asks for data. */ + [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 = 100, + }, + /* 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 + }, }, }, - {.name = "Base Gyro", + [BASE_GYRO] = { + .name = "Base Gyro", .active_mask = SENSOR_ACTIVE_S0, .chip = MOTIONSENSE_CHIP_BMI160, .type = MOTIONSENSE_TYPE_GYRO, @@ -532,41 +565,6 @@ struct motion_sensor_t motion_sensors[] = { }, }, }, - - {.name = "Lid Accel", - .active_mask = SENSOR_ACTIVE_S0, - .chip = MOTIONSENSE_CHIP_KX022, - .type = MOTIONSENSE_TYPE_ACCEL, - .location = MOTIONSENSE_LOC_LID, - .drv = &kionix_accel_drv, - .mutex = &g_lid_mutex, - .drv_data = &g_kx022_data, - .port = I2C_PORT_ACCEL, - .addr = KX022_ADDR1, - .rot_standard_ref = NULL, /* Identity matrix. */ - .default_range = 2, /* g, enough for laptop. */ - .config = { - /* AP: by default use EC settings */ - [SENSOR_CONFIG_AP] = { - .odr = 10000 | ROUND_UP_FLAG, - .ec_rate = 100 * MSEC, - }, - /* EC use accel for angle detection */ - [SENSOR_CONFIG_EC_S0] = { - .odr = 10000 | ROUND_UP_FLAG, - .ec_rate = 100 * MSEC, - }, - /* unused */ - [SENSOR_CONFIG_EC_S3] = { - .odr = 0, - .ec_rate = 0, - }, - [SENSOR_CONFIG_EC_S5] = { - .odr = 0, - .ec_rate = 0, - }, - }, - }, }; const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); #endif /* defined(HAS_TASK_MOTIONSENSE) */ diff --git a/board/wheatley/board.h b/board/wheatley/board.h index b9f62d73d9..f9ac990dba 100644 --- a/board/wheatley/board.h +++ b/board/wheatley/board.h @@ -47,8 +47,8 @@ #define CONFIG_KEYBOARD_PROTOCOL_8042 #define CONFIG_LED_COMMON #define CONFIG_LID_ANGLE -#define CONFIG_LID_ANGLE_SENSOR_BASE 0 -#define CONFIG_LID_ANGLE_SENSOR_LID 2 +#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL +#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL #define CONFIG_LID_SWITCH #define CONFIG_LOW_POWER_IDLE #define CONFIG_LOW_POWER_S0 @@ -198,6 +198,18 @@ enum als_id { ALS_COUNT }; +/* + * Motion sensors + * When reading through IO memory is set up for sensors (LPC is used), + * the first 2 entries must be accelerometers, then gyroscope. + * For BMI160, accel, gyro and compass sensors must be next to each other. + */ +enum sensor_id { + LID_ACCEL = 0, + BASE_ACCEL, + BASE_GYRO, +}; + /* start as a sink in case we have no other power supply/battery */ #define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED |