diff options
author | Yuval Peress <peress@chromium.org> | 2019-05-30 12:02:10 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-06-05 18:50:20 +0000 |
commit | 01fd86385bdcf633db0acd91b5f60733097a84a3 (patch) | |
tree | cd142bbb9941fbaf30ff8bb969c74433c1199488 /board | |
parent | e36f5ff57b2456c61f868af7be3f6929b28f1bf3 (diff) | |
download | chrome-ec-01fd86385bdcf633db0acd91b5f60733097a84a3.tar.gz |
common: motion_sense: Require CONFIG_MOTION_SENSOR_MAX_COUNT
This changes requires all boards to define the maximum number
of sensors they support. This will allow us to later create
static arrays with the appropriate length.
BUG=chromium:966506
BRANCH=None
TEST=make buildall
Change-Id: I5a2fa8f0fdcaef69065dfd4c2bfea4e3f371e986
Signed-off-by: Yuval Peress <peress@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1637414
Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'board')
-rw-r--r-- | board/atlas/board.h | 1 | ||||
-rw-r--r-- | board/cheza/board.h | 1 | ||||
-rw-r--r-- | board/coral/board.h | 1 | ||||
-rw-r--r-- | board/elm/board.c | 79 | ||||
-rw-r--r-- | board/elm/board.h | 10 | ||||
-rw-r--r-- | board/eve/board.h | 1 | ||||
-rw-r--r-- | board/glados/board.c | 114 | ||||
-rw-r--r-- | board/glados/board.h | 11 | ||||
-rw-r--r-- | board/kukui/board.h | 1 | ||||
-rw-r--r-- | board/mchpevb1/board.c | 112 | ||||
-rw-r--r-- | board/mchpevb1/board.h | 17 | ||||
-rw-r--r-- | board/nami/board.h | 1 | ||||
-rw-r--r-- | board/nautilus/board.h | 1 | ||||
-rw-r--r-- | board/nocturne/board.h | 1 | ||||
-rw-r--r-- | board/nucleo-f411re/board.h | 1 | ||||
-rw-r--r-- | board/oak/board.c | 113 | ||||
-rw-r--r-- | board/oak/board.h | 15 | ||||
-rw-r--r-- | board/poppy/board.h | 1 | ||||
-rw-r--r-- | board/rainier/board.h | 1 | ||||
-rw-r--r-- | board/rammus/board.h | 1 | ||||
-rw-r--r-- | board/reef/board.h | 1 | ||||
-rw-r--r-- | board/reef_mchp/board.h | 1 | ||||
-rw-r--r-- | board/samus/board.h | 11 | ||||
-rw-r--r-- | board/scarlet/board.h | 1 | ||||
-rw-r--r-- | board/strago/board.c | 86 | ||||
-rw-r--r-- | board/strago/board.h | 10 |
26 files changed, 337 insertions, 256 deletions
diff --git a/board/atlas/board.h b/board/atlas/board.h index 636ff2c982..1f261144f7 100644 --- a/board/atlas/board.h +++ b/board/atlas/board.h @@ -207,6 +207,7 @@ enum pwm_channel { enum sensor_id { LID_ALS, + SENSOR_COUNT, }; /* LID_ALS needs to be polled */ diff --git a/board/cheza/board.h b/board/cheza/board.h index f9adee2690..983316e062 100644 --- a/board/cheza/board.h +++ b/board/cheza/board.h @@ -197,6 +197,7 @@ enum sensor_id { LID_ACCEL = 0, LID_GYRO, LID_ALS, + SENSOR_COUNT, }; enum pwm_channel { diff --git a/board/coral/board.h b/board/coral/board.h index 3a93a88e7c..f9dfb4e174 100644 --- a/board/coral/board.h +++ b/board/coral/board.h @@ -269,6 +269,7 @@ enum sensor_id { LID_ACCEL, BASE_ACCEL, BASE_GYRO, + SENSOR_COUNT, }; #define CONFIG_HOSTCMD_SKUID diff --git a/board/elm/board.c b/board/elm/board.c index f2d567ace7..312caa6509 100644 --- a/board/elm/board.c +++ b/board/elm/board.c @@ -450,50 +450,53 @@ const mat33_fp_t lid_standard_ref = { struct kionix_accel_data g_kx022_data[2]; struct motion_sensor_t motion_sensors[] = { - {.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_kx022_mutex[0], - .drv_data = &g_kx022_data[0], - .addr = 1, /* SPI, device ID 0 */ - .rot_standard_ref = &base_standard_ref, - .default_range = 2, /* g, enough for laptop. */ - .min_frequency = KX022_ACCEL_MIN_FREQ, - .max_frequency = KX022_ACCEL_MAX_FREQ, - .config = { - /* EC use accel for angle detection */ - [SENSOR_CONFIG_EC_S0] = { - .odr = 10000 | ROUND_UP_FLAG, - .ec_rate = 100 * MSEC, + [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_kx022_mutex[0], + .drv_data = &g_kx022_data[0], + .addr = 1, /* SPI, device ID 0 */ + .rot_standard_ref = &base_standard_ref, + .default_range = 2, /* g, enough for laptop. */ + .min_frequency = KX022_ACCEL_MIN_FREQ, + .max_frequency = KX022_ACCEL_MAX_FREQ, + .config = { + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 10000 | ROUND_UP_FLAG, + .ec_rate = 100 * MSEC, + }, }, - }, }, - {.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_kx022_mutex[1], - .drv_data = &g_kx022_data[1], - .addr = 3, /* SPI, device ID 1 */ - .rot_standard_ref = &lid_standard_ref, - .default_range = 2, /* g, enough for laptop. */ - .min_frequency = KX022_ACCEL_MIN_FREQ, - .max_frequency = KX022_ACCEL_MAX_FREQ, - .config = { - /* EC use accel for angle detection */ - [SENSOR_CONFIG_EC_S0] = { - .odr = 10000 | ROUND_UP_FLAG, - .ec_rate = 100 * MSEC, + [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_kx022_mutex[1], + .drv_data = &g_kx022_data[1], + .addr = 3, /* SPI, device ID 1 */ + .rot_standard_ref = &lid_standard_ref, + .default_range = 2, /* g, enough for laptop. */ + .min_frequency = KX022_ACCEL_MIN_FREQ, + .max_frequency = KX022_ACCEL_MAX_FREQ, + .config = { + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 10000 | ROUND_UP_FLAG, + .ec_rate = 100 * MSEC, + }, }, - }, }, }; + const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); void lid_angle_peripheral_enable(int enable) diff --git a/board/elm/board.h b/board/elm/board.h index 8d1283244c..0de9730454 100644 --- a/board/elm/board.h +++ b/board/elm/board.h @@ -19,8 +19,8 @@ #define CONFIG_CMD_ACCELS #define CONFIG_CMD_ACCEL_INFO #define CONFIG_LID_ANGLE -#define CONFIG_LID_ANGLE_SENSOR_BASE 0 -#define CONFIG_LID_ANGLE_SENSOR_LID 1 +#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL +#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL #define CONFIG_LID_ANGLE_UPDATE #define CONFIG_ADC @@ -215,6 +215,12 @@ enum temp_sensor_id { TEMP_SENSOR_COUNT }; +enum sensor_id { + BASE_ACCEL, + LID_ACCEL, + SENSOR_COUNT, +}; + /* TODO: determine the following board specific type-C power constants */ /* * delay to turn on the power supply max is ~16ms. diff --git a/board/eve/board.h b/board/eve/board.h index fce7c0de91..311cc97955 100644 --- a/board/eve/board.h +++ b/board/eve/board.h @@ -269,6 +269,7 @@ enum sensor_id { BASE_GYRO, BASE_MAG, LID_LIGHT, + SENSOR_COUNT, }; enum adc_channel { diff --git a/board/glados/board.c b/board/glados/board.c index e1a5c566fc..48e1acac8b 100644 --- a/board/glados/board.c +++ b/board/glados/board.c @@ -444,65 +444,69 @@ struct motion_sensor_t motion_sensors[] = { * Requirement: accelerometer sensor must init before gyro sensor * DO NOT change the order of the following table. */ - {.name = "Base Accel", - .active_mask = SENSOR_ACTIVE_S0, - .chip = MOTIONSENSE_CHIP_BMI160, - .type = MOTIONSENSE_TYPE_ACCEL, - .location = MOTIONSENSE_LOC_BASE, - .drv = &bmi160_drv, - .mutex = &g_base_mutex, - .drv_data = &g_bmi160_data, - .port = I2C_PORT_ACCEL, - .addr = BMI160_ADDR0, - .rot_standard_ref = NULL, /* Identity matrix. */ - .default_range = 2, /* g, enough for laptop. */ - .min_frequency = BMI160_ACCEL_MIN_FREQ, - .max_frequency = BMI160_ACCEL_MAX_FREQ, - .config = { - /* EC use accel for angle detection */ - [SENSOR_CONFIG_EC_S0] = { - .odr = 10000 | ROUND_UP_FLAG, - .ec_rate = 100 * MSEC, - }, - }, + [BASE_ACCEL] = { + .name = "Base Accel", + .active_mask = SENSOR_ACTIVE_S0, + .chip = MOTIONSENSE_CHIP_BMI160, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_BASE, + .drv = &bmi160_drv, + .mutex = &g_base_mutex, + .drv_data = &g_bmi160_data, + .port = I2C_PORT_ACCEL, + .addr = BMI160_ADDR0, + .rot_standard_ref = NULL, /* Identity matrix. */ + .default_range = 2, /* g, enough for laptop. */ + .min_frequency = BMI160_ACCEL_MIN_FREQ, + .max_frequency = BMI160_ACCEL_MAX_FREQ, + .config = { + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 10000 | ROUND_UP_FLAG, + .ec_rate = 100 * MSEC, + }, + }, }, - {.name = "Base Gyro", - .active_mask = SENSOR_ACTIVE_S0, - .chip = MOTIONSENSE_CHIP_BMI160, - .type = MOTIONSENSE_TYPE_GYRO, - .location = MOTIONSENSE_LOC_BASE, - .drv = &bmi160_drv, - .mutex = &g_base_mutex, - .drv_data = &g_bmi160_data, - .port = I2C_PORT_ACCEL, - .addr = BMI160_ADDR0, - .default_range = 1000, /* dps */ - .rot_standard_ref = NULL, /* Identity Matrix. */ - .min_frequency = BMI160_GYRO_MIN_FREQ, - .max_frequency = BMI160_GYRO_MAX_FREQ, + [BASE_GYRO] = { + .name = "Base Gyro", + .active_mask = SENSOR_ACTIVE_S0, + .chip = MOTIONSENSE_CHIP_BMI160, + .type = MOTIONSENSE_TYPE_GYRO, + .location = MOTIONSENSE_LOC_BASE, + .drv = &bmi160_drv, + .mutex = &g_base_mutex, + .drv_data = &g_bmi160_data, + .port = I2C_PORT_ACCEL, + .addr = BMI160_ADDR0, + .default_range = 1000, /* dps */ + .rot_standard_ref = NULL, /* Identity Matrix. */ + .min_frequency = BMI160_GYRO_MIN_FREQ, + .max_frequency = BMI160_GYRO_MAX_FREQ, }, - {.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. */ - .min_frequency = KX022_ACCEL_MIN_FREQ, - .max_frequency = KX022_ACCEL_MAX_FREQ, - .config = { - /* EC use accel for angle detection */ - [SENSOR_CONFIG_EC_S0] = { - .odr = 10000 | ROUND_UP_FLAG, - .ec_rate = 100 * MSEC, - }, + [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. */ + .min_frequency = KX022_ACCEL_MIN_FREQ, + .max_frequency = KX022_ACCEL_MAX_FREQ, + .config = { + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 10000 | ROUND_UP_FLAG, + .ec_rate = 100 * MSEC, + }, + }, }, }; const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); diff --git a/board/glados/board.h b/board/glados/board.h index 04c5450eb2..c58c2f87a7 100644 --- a/board/glados/board.h +++ b/board/glados/board.h @@ -50,8 +50,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_LTO @@ -188,6 +188,13 @@ enum temp_sensor_id { TEMP_SENSOR_COUNT }; +enum sensor_id { + BASE_ACCEL, + BASE_GYRO, + LID_ACCEL, + SENSOR_COUNT, +}; + /* Light sensors */ enum als_id { ALS_OPT3001 = 0, diff --git a/board/kukui/board.h b/board/kukui/board.h index e49147a2b5..491b0ea29a 100644 --- a/board/kukui/board.h +++ b/board/kukui/board.h @@ -243,6 +243,7 @@ enum sensor_id { LID_GYRO, LID_MAG, VSYNC, + SENSOR_COUNT, }; #include "gpio_signal.h" diff --git a/board/mchpevb1/board.c b/board/mchpevb1/board.c index 79226d7d71..ed5a661224 100644 --- a/board/mchpevb1/board.c +++ b/board/mchpevb1/board.c @@ -929,64 +929,68 @@ struct motion_sensor_t motion_sensors[] = { * Requirement: accelerometer sensor must init before gyro sensor * DO NOT change the order of the following table. */ - {.name = "Base Accel", - .active_mask = SENSOR_ACTIVE_S0, - .chip = MOTIONSENSE_CHIP_BMI160, - .type = MOTIONSENSE_TYPE_ACCEL, - .location = MOTIONSENSE_LOC_BASE, - .drv = &bmi160_drv, - .mutex = &g_base_mutex, - .drv_data = &g_bmi160_data, - .port = CONFIG_SPI_ACCEL_PORT, - .addr = BMI160_SET_SPI_ADDRESS(CONFIG_SPI_ACCEL_PORT), - .rot_standard_ref = NULL, /* Identity matrix. */ - .default_range = 2, /* g, enough for laptop. */ - .min_frequency = BMI160_ACCEL_MIN_FREQ, - .max_frequency = BMI160_ACCEL_MAX_FREQ, - .config = { - /* EC use accel for angle detection */ - [SENSOR_CONFIG_EC_S0] = { - .odr = 10000 | ROUND_UP_FLAG, - .ec_rate = 100 * MSEC, - }, - }, + [BASE_ACCEL] = { + .name = "Base Accel", + .active_mask = SENSOR_ACTIVE_S0, + .chip = MOTIONSENSE_CHIP_BMI160, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_BASE, + .drv = &bmi160_drv, + .mutex = &g_base_mutex, + .drv_data = &g_bmi160_data, + .port = CONFIG_SPI_ACCEL_PORT, + .addr = BMI160_SET_SPI_ADDRESS(CONFIG_SPI_ACCEL_PORT), + .rot_standard_ref = NULL, /* Identity matrix. */ + .default_range = 2, /* g, enough for laptop. */ + .min_frequency = BMI160_ACCEL_MIN_FREQ, + .max_frequency = BMI160_ACCEL_MAX_FREQ, + .config = { + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 10000 | ROUND_UP_FLAG, + .ec_rate = 100 * MSEC, + }, + }, }, - {.name = "Base Gyro", - .active_mask = SENSOR_ACTIVE_S0, - .chip = MOTIONSENSE_CHIP_BMI160, - .type = MOTIONSENSE_TYPE_GYRO, - .location = MOTIONSENSE_LOC_BASE, - .drv = &bmi160_drv, - .mutex = &g_base_mutex, - .drv_data = &g_bmi160_data, - .port = CONFIG_SPI_ACCEL_PORT, - .addr = BMI160_SET_SPI_ADDRESS(CONFIG_SPI_ACCEL_PORT), - .default_range = 1000, /* dps */ - .rot_standard_ref = NULL, /* Identity Matrix. */ - .min_frequency = BMI160_GYRO_MIN_FREQ, - .max_frequency = BMI160_GYRO_MAX_FREQ, + [BASE_GYRO] = { + .name = "Base Gyro", + .active_mask = SENSOR_ACTIVE_S0, + .chip = MOTIONSENSE_CHIP_BMI160, + .type = MOTIONSENSE_TYPE_GYRO, + .location = MOTIONSENSE_LOC_BASE, + .drv = &bmi160_drv, + .mutex = &g_base_mutex, + .drv_data = &g_bmi160_data, + .port = CONFIG_SPI_ACCEL_PORT, + .addr = BMI160_SET_SPI_ADDRESS(CONFIG_SPI_ACCEL_PORT), + .default_range = 1000, /* dps */ + .rot_standard_ref = NULL, /* Identity Matrix. */ + .min_frequency = BMI160_GYRO_MIN_FREQ, + .max_frequency = BMI160_GYRO_MAX_FREQ, }, #ifdef CONFIG_ACCEL_KX022 - {.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. */ - .min_frequency = KX022_ACCEL_MIN_FREQ, - .max_frequency = KX022_ACCEL_MAX_FREQ, - .config = { - /* EC use accel for angle detection */ - [SENSOR_CONFIG_EC_S0] = { - .odr = 10000 | ROUND_UP_FLAG, - .ec_rate = 100 * MSEC, + [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. */ + .min_frequency = KX022_ACCEL_MIN_FREQ, + .max_frequency = KX022_ACCEL_MAX_FREQ, + .config = { + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 10000 | ROUND_UP_FLAG, + .ec_rate = 100 * MSEC, + }, }, }, #endif /* #ifdef CONFIG_ACCEL_KX022 */ diff --git a/board/mchpevb1/board.h b/board/mchpevb1/board.h index 9cc28a38fd..ee6f9d92ba 100644 --- a/board/mchpevb1/board.h +++ b/board/mchpevb1/board.h @@ -182,9 +182,13 @@ #define CONFIG_I2C_MASTER #define CONFIG_KEYBOARD_PROTOCOL_8042 #define CONFIG_LED_COMMON + +#ifdef CONFIG_ACCEL_KX022 #define CONFIG_LID_ANGLE -#define CONFIG_LID_ANGLE_SENSOR_BASE 0 -#define CONFIG_LID_ANGLE_SENSOR_LID 2 +#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL +#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL +#endif /* CONFIG_ACCEL_KX022 */ + #define CONFIG_LID_SWITCH /* * Enable MCHP Low Power Idle support @@ -445,6 +449,15 @@ enum temp_sensor_id { TEMP_SENSOR_COUNT }; +enum sensor_id { + BASE_ACCEL, + BASE_GYRO, +#ifdef CONFIG_ACCEL_KX022 + LID_ACCEL, +#endif + SENSOR_COUNT, +}; + /* Light sensors */ enum als_id { ALS_OPT3001 = 0, diff --git a/board/nami/board.h b/board/nami/board.h index 27f8358a99..61d1274c46 100644 --- a/board/nami/board.h +++ b/board/nami/board.h @@ -254,6 +254,7 @@ enum sensor_id { BASE_ACCEL, BASE_GYRO, LID_ALS, + SENSOR_COUNT, }; enum adc_channel { diff --git a/board/nautilus/board.h b/board/nautilus/board.h index 1d72270566..93a283c4c3 100644 --- a/board/nautilus/board.h +++ b/board/nautilus/board.h @@ -220,6 +220,7 @@ enum sensor_id { LID_ACCEL = 0, BASE_ACCEL, BASE_GYRO, + SENSOR_COUNT, }; enum adc_channel { diff --git a/board/nocturne/board.h b/board/nocturne/board.h index 26dab74e0a..9fe50b7fbd 100644 --- a/board/nocturne/board.h +++ b/board/nocturne/board.h @@ -254,6 +254,7 @@ enum sensor_id { LID_GYRO, LID_ALS, VSYNC, + SENSOR_COUNT, }; #define CONFIG_ACCEL_FORCE_MODE_MASK BIT(LID_ALS) diff --git a/board/nucleo-f411re/board.h b/board/nucleo-f411re/board.h index 7ffa0b0f07..069e1367f2 100644 --- a/board/nucleo-f411re/board.h +++ b/board/nucleo-f411re/board.h @@ -68,6 +68,7 @@ enum adc_channel { enum sensor_id { BASE_ACCEL = 0, BASE_GYRO, + SENSOR_COUNT, }; #include "gpio_signal.h" diff --git a/board/oak/board.c b/board/oak/board.c index 6639202654..845eeebe10 100644 --- a/board/oak/board.c +++ b/board/oak/board.c @@ -623,67 +623,70 @@ struct motion_sensor_t motion_sensors[] = { * Requirement: accelerometer sensor must init before gyro sensor * DO NOT change the order of the following table. */ - {.name = "Base Accel", - .active_mask = SENSOR_ACTIVE_S0, - .chip = MOTIONSENSE_CHIP_BMI160, - .type = MOTIONSENSE_TYPE_ACCEL, - .location = MOTIONSENSE_LOC_BASE, - .drv = &bmi160_drv, - .mutex = &g_base_mutex, - .drv_data = &g_bmi160_data, - .port = I2C_PORT_ACCEL, - .addr = 1, - .rot_standard_ref = &base_standard_ref, - .default_range = 2, /* g, enough for laptop. */ - .min_frequency = BMI160_ACCEL_MIN_FREQ, - .max_frequency = BMI160_ACCEL_MAX_FREQ, - .config = { - /* EC use accel for angle detection */ - [SENSOR_CONFIG_EC_S0] = { - .odr = 10000 | ROUND_UP_FLAG, - .ec_rate = 100 * MSEC, - }, - }, + [BASE_ACCEL] = { + .name = "Base Accel", + .active_mask = SENSOR_ACTIVE_S0, + .chip = MOTIONSENSE_CHIP_BMI160, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_BASE, + .drv = &bmi160_drv, + .mutex = &g_base_mutex, + .drv_data = &g_bmi160_data, + .port = I2C_PORT_ACCEL, + .addr = 1, + .rot_standard_ref = &base_standard_ref, + .default_range = 2, /* g, enough for laptop. */ + .min_frequency = BMI160_ACCEL_MIN_FREQ, + .max_frequency = BMI160_ACCEL_MAX_FREQ, + .config = { + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 10000 | ROUND_UP_FLAG, + .ec_rate = 100 * MSEC, + }, + }, }, - {.name = "Base Gyro", - .active_mask = SENSOR_ACTIVE_S0, - .chip = MOTIONSENSE_CHIP_BMI160, - .type = MOTIONSENSE_TYPE_GYRO, - .location = MOTIONSENSE_LOC_BASE, - .drv = &bmi160_drv, - .mutex = &g_base_mutex, - .drv_data = &g_bmi160_data, - .port = I2C_PORT_ACCEL, - .addr = 1, - .default_range = 1000, /* dps */ - .rot_standard_ref = &base_standard_ref, - .min_frequency = BMI160_GYRO_MIN_FREQ, - .max_frequency = BMI160_GYRO_MAX_FREQ, + [BASE_GYRO] = { + .name = "Base Gyro", + .active_mask = SENSOR_ACTIVE_S0, + .chip = MOTIONSENSE_CHIP_BMI160, + .type = MOTIONSENSE_TYPE_GYRO, + .location = MOTIONSENSE_LOC_BASE, + .drv = &bmi160_drv, + .mutex = &g_base_mutex, + .drv_data = &g_bmi160_data, + .port = I2C_PORT_ACCEL, + .addr = 1, + .default_range = 1000, /* dps */ + .rot_standard_ref = &base_standard_ref, + .min_frequency = BMI160_GYRO_MIN_FREQ, + .max_frequency = BMI160_GYRO_MAX_FREQ, }, #endif #ifdef CONFIG_ACCEL_KX022 - {.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. */ - .min_frequency = KX022_ACCEL_MIN_FREQ, - .max_frequency = KX022_ACCEL_MAX_FREQ, - .config = { - /* EC use accel for angle detection */ - [SENSOR_CONFIG_EC_S0] = { - .odr = 10000 | ROUND_UP_FLAG, - .ec_rate = 100 * MSEC, + [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. */ + .min_frequency = KX022_ACCEL_MIN_FREQ, + .max_frequency = KX022_ACCEL_MAX_FREQ, + .config = { + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 10000 | ROUND_UP_FLAG, + .ec_rate = 100 * MSEC, + }, }, - }, }, #endif }; diff --git a/board/oak/board.h b/board/oak/board.h index b84b852679..e4ae567b29 100644 --- a/board/oak/board.h +++ b/board/oak/board.h @@ -68,8 +68,8 @@ #else #define CONFIG_HIBERNATE_WAKEUP_PINS (STM32_PWR_CSR_EWUP1) #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_ANGLE_UPDATE #endif /* BOARD_REV */ #define CONFIG_HOST_COMMAND_STATUS @@ -208,6 +208,17 @@ enum temp_sensor_id { TEMP_SENSOR_COUNT }; +enum sensor_id { +#ifdef CONFIG_ACCELGYRO_BMI160 + BASE_ACCEL, + BASE_GYRO, +#endif +#ifdef CONFIG_ACCEL_KX022 + LID_ACCEL, +#endif + SENSOR_COUNT, +}; + /* Light sensors */ enum als_id { ALS_OPT3001 = 0, diff --git a/board/poppy/board.h b/board/poppy/board.h index a79216bb63..87262ca4b6 100644 --- a/board/poppy/board.h +++ b/board/poppy/board.h @@ -232,6 +232,7 @@ enum sensor_id { LID_GYRO, LID_MAG, LID_ALS, + SENSOR_COUNT, }; enum adc_channel { diff --git a/board/rainier/board.h b/board/rainier/board.h index 334d481732..4903de557d 100644 --- a/board/rainier/board.h +++ b/board/rainier/board.h @@ -160,6 +160,7 @@ enum sensor_id { LID_ACCEL = 0, LID_GYRO, LID_BARO, + SENSOR_COUNT, }; #include "gpio_signal.h" diff --git a/board/rammus/board.h b/board/rammus/board.h index eb6df68f75..ba4b1c9936 100644 --- a/board/rammus/board.h +++ b/board/rammus/board.h @@ -244,6 +244,7 @@ enum sensor_id { LID_ACCEL = 0, BASE_ACCEL, BASE_GYRO, + SENSOR_COUNT, }; enum adc_channel { diff --git a/board/reef/board.h b/board/reef/board.h index 6847d82c5b..13495970bc 100644 --- a/board/reef/board.h +++ b/board/reef/board.h @@ -278,6 +278,7 @@ enum sensor_id { BASE_MAG, BASE_BARO, LID_ALS, + SENSOR_COUNT, }; enum reef_board_version { diff --git a/board/reef_mchp/board.h b/board/reef_mchp/board.h index 4526946070..162f863009 100644 --- a/board/reef_mchp/board.h +++ b/board/reef_mchp/board.h @@ -286,6 +286,7 @@ enum sensor_id { BASE_MAG, BASE_BARO, LID_ALS, /* firmware-reef-9042.B doesn't have this */ + SENSOR_COUNT, }; enum reef_board_version { diff --git a/board/samus/board.h b/board/samus/board.h index 2bfb1574c8..a3a6b97448 100644 --- a/board/samus/board.h +++ b/board/samus/board.h @@ -173,6 +173,13 @@ enum temp_sensor_id { TEMP_SENSOR_COUNT }; +enum sensor_id { + BASE_ACCEL, + LID_ACCEL, + BASE_GYRO, + SENSOR_COUNT, +}; + /* The number of TMP006 sensor chips on the board. */ #define TMP006_COUNT 6 @@ -213,8 +220,8 @@ void set_pp5000_in_g3(int mask, int enable); #define CONFIG_GESTURE_TAP_MIN_INTERSTICE_T 120 #define CONFIG_GESTURE_TAP_MAX_INTERSTICE_T 500 -#define CONFIG_LID_ANGLE_SENSOR_BASE 0 -#define CONFIG_LID_ANGLE_SENSOR_LID 1 +#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL +#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL #endif /* !__ASSEMBLER__ */ diff --git a/board/scarlet/board.h b/board/scarlet/board.h index 1a682b93ba..c13b45029c 100644 --- a/board/scarlet/board.h +++ b/board/scarlet/board.h @@ -211,6 +211,7 @@ enum sensor_id { LID_ACCEL = 0, LID_GYRO, VSYNC, + SENSOR_COUNT, }; #include "gpio_signal.h" diff --git a/board/strago/board.c b/board/strago/board.c index 7b7304e374..57dff8a71a 100644 --- a/board/strago/board.c +++ b/board/strago/board.c @@ -196,49 +196,51 @@ const mat33_fp_t lid_standard_ref = { }; struct motion_sensor_t motion_sensors[] = { - {.name = "Base Accel", - .active_mask = SENSOR_ACTIVE_S0, - .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. */ - .min_frequency = KXCJ9_ACCEL_MIN_FREQ, - .max_frequency = KXCJ9_ACCEL_MAX_FREQ, - .config = { - /* EC use accel for angle detection */ - [SENSOR_CONFIG_EC_S0] = { - .odr = 100000 | ROUND_UP_FLAG, - .ec_rate = 100 * MSEC, - }, - } + [BASE_ACCEL] = { + .name = "Base Accel", + .active_mask = SENSOR_ACTIVE_S0, + .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. */ + .min_frequency = KXCJ9_ACCEL_MIN_FREQ, + .max_frequency = KXCJ9_ACCEL_MAX_FREQ, + .config = { + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 100000 | ROUND_UP_FLAG, + .ec_rate = 100 * MSEC, + }, + } }, - {.name = "Lid Accel", - .active_mask = SENSOR_ACTIVE_S0, - .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. */ - .min_frequency = KXCJ9_ACCEL_MIN_FREQ, - .max_frequency = KXCJ9_ACCEL_MAX_FREQ, - .config = { - /* EC use accel for angle detection */ - [SENSOR_CONFIG_EC_S0] = { - .odr = 100000 | ROUND_UP_FLAG, - .ec_rate = 100 * MSEC, - }, - }, + [LID_ACCEL] = { + .name = "Lid Accel", + .active_mask = SENSOR_ACTIVE_S0, + .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. */ + .min_frequency = KXCJ9_ACCEL_MIN_FREQ, + .max_frequency = KXCJ9_ACCEL_MAX_FREQ, + .config = { + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 100000 | ROUND_UP_FLAG, + .ec_rate = 100 * MSEC, + }, + }, }, }; const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); diff --git a/board/strago/board.h b/board/strago/board.h index 64721ca95f..185cf1ad92 100644 --- a/board/strago/board.h +++ b/board/strago/board.h @@ -89,8 +89,8 @@ #undef CONFIG_CMD_ACCELS #undef CONFIG_CMD_ACCEL_INFO #define CONFIG_LID_ANGLE -#define CONFIG_LID_ANGLE_SENSOR_BASE 0 -#define CONFIG_LID_ANGLE_SENSOR_LID 1 +#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL +#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL /* Number of buttons */ #define CONFIG_VOLUME_BUTTONS @@ -169,6 +169,12 @@ enum temp_sensor_id { TEMP_SENSOR_COUNT }; +enum sensor_id { + BASE_ACCEL, + LID_ACCEL, + SENSOR_COUNT, +}; + /* Light sensors */ enum als_id { ALS_ISL29035 = 0, |