diff options
author | Nick Vaccaro <nvaccaro@chromium.org> | 2017-04-25 19:09:03 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-05-18 21:05:23 -0700 |
commit | 9a0d0aa70d483be79c71a459dfd5f5e89da2638d (patch) | |
tree | 5e61d14a77ec938ce1508dbc61a271e0dfb15ee0 | |
parent | d7eefeffb927cfd311d40c00ce817937eab4cb61 (diff) | |
download | chrome-ec-9a0d0aa70d483be79c71a459dfd5f5e89da2638d.tar.gz |
common: sensors: add extra sensor attributes
Adds min_frequency and max_frequency to struct motion_sensor_t.
New attributes min_frequency and max_frequency are now returned in
ectool's MOTIONSENSE_CMD_INFO response.
Incremented ectool's MOTIONSENSE_CMD_INFO version to version 3.
Add constants for MIN_FREQUENCY and MAX_FREQUENCY to each sensor's
header file.
BRANCH=none
BUG=chromium:615059
TEST=build/boot and verify MOTIONSENSE_CMD_INFO response on kevin,
make buildall -j passes.
Change-Id: I66db9715c122ef6bb4665ad5d086a9ecc9c7c93a
Signed-off-by: Nick Vaccaro <nvaccaro@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/482703
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r-- | board/elm/board.c | 4 | ||||
-rw-r--r-- | board/eve/board.c | 10 | ||||
-rw-r--r-- | board/glados/board.c | 6 | ||||
-rw-r--r-- | board/kahlee/board.c | 2 | ||||
-rw-r--r-- | board/kevin/board.c | 10 | ||||
-rw-r--r-- | board/oak/board.c | 6 | ||||
-rw-r--r-- | board/poppy/board.c | 8 | ||||
-rw-r--r-- | board/reef/board.c | 12 | ||||
-rw-r--r-- | board/rowan/board.c | 4 | ||||
-rw-r--r-- | board/ryu/board.c | 10 | ||||
-rw-r--r-- | board/samus/board.c | 6 | ||||
-rw-r--r-- | board/strago/board.c | 4 | ||||
-rw-r--r-- | board/wheatley/board.c | 6 | ||||
-rw-r--r-- | common/motion_sense.c | 19 | ||||
-rw-r--r-- | driver/accel_bma2x2.h | 4 | ||||
-rw-r--r-- | driver/accel_kx022.h | 4 | ||||
-rw-r--r-- | driver/accel_kxcj9.h | 4 | ||||
-rw-r--r-- | driver/accelgyro_bmi160.h | 6 | ||||
-rw-r--r-- | driver/accelgyro_lsm6ds0.h | 6 | ||||
-rw-r--r-- | driver/als_opt3001.h | 4 | ||||
-rw-r--r-- | driver/als_si114x.h | 6 | ||||
-rw-r--r-- | driver/baro_bmp280.h | 8 | ||||
-rw-r--r-- | driver/gyro_l3gd20h.h | 4 | ||||
-rw-r--r-- | driver/mag_bmm150.h | 3 | ||||
-rw-r--r-- | include/common.h | 3 | ||||
-rw-r--r-- | include/config.h | 3 | ||||
-rw-r--r-- | include/ec_commands.h | 24 | ||||
-rw-r--r-- | include/motion_sense.h | 12 | ||||
-rw-r--r-- | include/util.h | 3 | ||||
-rw-r--r-- | util/ectool.c | 32 |
30 files changed, 222 insertions, 11 deletions
diff --git a/board/elm/board.c b/board/elm/board.c index 4076979b4a..e6734bd4ad 100644 --- a/board/elm/board.c +++ b/board/elm/board.c @@ -512,6 +512,8 @@ struct motion_sensor_t motion_sensors[] = { .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 = { /* AP: by default use EC settings */ [SENSOR_CONFIG_AP] = { @@ -546,6 +548,8 @@ struct motion_sensor_t motion_sensors[] = { .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 = { /* AP: by default use EC settings */ [SENSOR_CONFIG_AP] = { diff --git a/board/eve/board.c b/board/eve/board.c index aed81eccbb..e548baf6dd 100644 --- a/board/eve/board.c +++ b/board/eve/board.c @@ -750,6 +750,8 @@ struct motion_sensor_t motion_sensors[] = { .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 = { /* AP: by default use EC settings */ [SENSOR_CONFIG_AP] = { @@ -786,6 +788,8 @@ struct motion_sensor_t motion_sensors[] = { .addr = BMI160_ADDR0, .rot_standard_ref = NULL, .default_range = 2, /* g, enough for laptop. */ + .min_frequency = BMI160_ACCEL_MIN_FREQ, + .max_frequency = BMI160_ACCEL_MAX_FREQ, .config = { /* AP: by default use EC settings */ [SENSOR_CONFIG_AP] = { @@ -823,6 +827,8 @@ struct motion_sensor_t motion_sensors[] = { .addr = BMI160_ADDR0, .default_range = 1000, /* dps */ .rot_standard_ref = NULL, + .min_frequency = BMI160_GYRO_MIN_FREQ, + .max_frequency = BMI160_GYRO_MAX_FREQ, .config = { /* AP: by default shutdown all sensors */ [SENSOR_CONFIG_AP] = { @@ -860,6 +866,8 @@ struct motion_sensor_t motion_sensors[] = { .addr = BMI160_ADDR0, .default_range = 1 << 11, /* 16LSB / uT, fixed */ .rot_standard_ref = &mag_standard_ref, + .min_frequency = BMM150_MAG_MIN_FREQ, + .max_frequency = BMM150_MAG_MAX_FREQ, .config = { /* AP: by default shutdown all sensors */ [SENSOR_CONFIG_AP] = { @@ -897,6 +905,8 @@ struct motion_sensor_t motion_sensors[] = { .addr = SI114X_ADDR, .rot_standard_ref = NULL, .default_range = 9000, /* 90%: int = 0 - frac = 9000/10000 */ + .min_frequency = SI114X_LIGHT_MIN_FREQ, + .max_frequency = SI114X_LIGHT_MAX_FREQ, .config = { /* AP: by default shutdown all sensors */ [SENSOR_CONFIG_AP] = { diff --git a/board/glados/board.c b/board/glados/board.c index e77be19e93..dd492b17f1 100644 --- a/board/glados/board.c +++ b/board/glados/board.c @@ -497,6 +497,8 @@ struct motion_sensor_t motion_sensors[] = { .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 = { /* AP: by default use EC settings */ [SENSOR_CONFIG_AP] = { @@ -533,6 +535,8 @@ struct motion_sensor_t motion_sensors[] = { .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, .config = { /* AP: by default shutdown all sensors */ [SENSOR_CONFIG_AP] = { @@ -569,6 +573,8 @@ struct motion_sensor_t motion_sensors[] = { .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 = { /* AP: by default use EC settings */ [SENSOR_CONFIG_AP] = { diff --git a/board/kahlee/board.c b/board/kahlee/board.c index 843f035f5f..9eb3e0de9f 100644 --- a/board/kahlee/board.c +++ b/board/kahlee/board.c @@ -541,6 +541,8 @@ struct motion_sensor_t motion_sensors[] = { .addr = KXCJ9_ADDR1, .rot_standard_ref = NULL, /* Identity matrix. */ .default_range = 2, /* g, enough for laptop. */ + .min_frequency = KXCJ9_ACCEL_MIN_FREQ, + .max_frequency = KXCJ9_ACCEL_MAX_FREQ, .config = { /* AP: by default use EC settings */ [SENSOR_CONFIG_AP] = { diff --git a/board/kevin/board.c b/board/kevin/board.c index 8c183ed2bb..c733d565a6 100644 --- a/board/kevin/board.c +++ b/board/kevin/board.c @@ -536,6 +536,8 @@ struct motion_sensor_t motion_sensors[] = { .addr = BMI160_SET_SPI_ADDRESS(CONFIG_SPI_ACCEL_PORT), .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 = { /* AP: by default use EC settings */ [SENSOR_CONFIG_AP] = { @@ -576,6 +578,8 @@ struct motion_sensor_t motion_sensors[] = { #else .rot_standard_ref = NULL, /* Identity matrix. */ #endif + .min_frequency = BMI160_GYRO_MIN_FREQ, + .max_frequency = BMI160_GYRO_MAX_FREQ, .config = { /* AP: by default shutdown all sensors */ [SENSOR_CONFIG_AP] = { @@ -613,6 +617,8 @@ struct motion_sensor_t motion_sensors[] = { .addr = BMA2x2_I2C_ADDR1, .rot_standard_ref = &lid_standard_ref, .default_range = 2, /* g, enough for laptop. */ + .min_frequency = BMA255_ACCEL_MIN_FREQ, + .max_frequency = BMA255_ACCEL_MAX_FREQ, .config = { /* AP: by default use EC settings */ [SENSOR_CONFIG_AP] = { @@ -649,6 +655,8 @@ struct motion_sensor_t motion_sensors[] = { .addr = KX022_ADDR0, .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 = { /* AP: by default use EC settings */ [SENSOR_CONFIG_AP] = { @@ -682,6 +690,8 @@ struct motion_sensor_t motion_sensors[] = { .port = I2C_PORT_BARO, .addr = BMP280_I2C_ADDRESS1, .default_range = 1 << 18, /* 1bit = 4 Pa, 16bit ~= 2600 hPa */ + .min_frequency = BMP280_BARO_MIN_FREQ, + .max_frequency = BMP280_BARO_MAX_FREQ, .config = { /* AP: by default shutdown all sensors */ [SENSOR_CONFIG_AP] = { diff --git a/board/oak/board.c b/board/oak/board.c index f22e016622..1c4ee791f7 100644 --- a/board/oak/board.c +++ b/board/oak/board.c @@ -663,6 +663,8 @@ struct motion_sensor_t motion_sensors[] = { .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 = { /* AP: by default use EC settings */ [SENSOR_CONFIG_AP] = { @@ -699,6 +701,8 @@ struct motion_sensor_t motion_sensors[] = { .addr = 1, .default_range = 1000, /* dps */ .rot_standard_ref = NULL, /* Identity Matrix. */ + .min_frequency = BMI160_GYRO_MIN_FREQ, + .max_frequency = BMI160_GYRO_MAX_FREQ, .config = { /* AP: by default shutdown all sensors */ [SENSOR_CONFIG_AP] = { @@ -736,6 +740,8 @@ struct motion_sensor_t motion_sensors[] = { .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 = { /* AP: by default use EC settings */ [SENSOR_CONFIG_AP] = { diff --git a/board/poppy/board.c b/board/poppy/board.c index 762b2a2d2f..c2cb27390d 100644 --- a/board/poppy/board.c +++ b/board/poppy/board.c @@ -696,6 +696,8 @@ struct motion_sensor_t motion_sensors[] = { .addr = BMI160_ADDR0, .rot_standard_ref = &lid_standard_ref, .default_range = 2, /* g, enough for laptop. */ + .min_frequency = BMI160_ACCEL_MIN_FREQ, + .max_frequency = BMI160_ACCEL_MAX_FREQ, .config = { /* AP: by default use EC settings */ [SENSOR_CONFIG_AP] = { @@ -733,6 +735,8 @@ struct motion_sensor_t motion_sensors[] = { .addr = BMI160_ADDR0, .default_range = 1000, /* dps */ .rot_standard_ref = &lid_standard_ref, + .min_frequency = BMI160_GYRO_MIN_FREQ, + .max_frequency = BMI160_GYRO_MAX_FREQ, .config = { /* AP: by default shutdown all sensors */ [SENSOR_CONFIG_AP] = { @@ -770,6 +774,8 @@ struct motion_sensor_t motion_sensors[] = { .addr = BMI160_ADDR0, .default_range = 1 << 11, /* 16LSB / uT, fixed */ .rot_standard_ref = &mag_standard_ref, + .min_frequency = BMM150_MAG_MIN_FREQ, + .max_frequency = BMM150_MAG_MAX_FREQ, .config = { /* AP: by default shutdown all sensors */ [SENSOR_CONFIG_AP] = { @@ -805,6 +811,8 @@ struct motion_sensor_t motion_sensors[] = { .port = I2C_PORT_BARO, .addr = BMP280_I2C_ADDRESS1, .default_range = 1 << 18, /* 1bit = 4 Pa, 16bit ~= 2600 hPa */ + .min_frequency = BMP280_BARO_MIN_FREQ, + .max_frequency = BMP280_BARO_MAX_FREQ, .config = { /* AP: by default shutdown all sensors */ [SENSOR_CONFIG_AP] = { diff --git a/board/reef/board.c b/board/reef/board.c index 1b8a27ad50..afe50feb63 100644 --- a/board/reef/board.c +++ b/board/reef/board.c @@ -845,6 +845,8 @@ struct motion_sensor_t motion_sensors[] = { .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 = { /* AP: by default use EC settings */ [SENSOR_CONFIG_AP] = { @@ -881,6 +883,8 @@ struct motion_sensor_t motion_sensors[] = { .addr = BMI160_ADDR0, .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 = { /* AP: by default use EC settings */ [SENSOR_CONFIG_AP] = { @@ -918,6 +922,8 @@ struct motion_sensor_t motion_sensors[] = { .addr = BMI160_ADDR0, .default_range = 1000, /* dps */ .rot_standard_ref = &base_standard_ref, + .min_frequency = BMI160_GYRO_MIN_FREQ, + .max_frequency = BMI160_GYRO_MAX_FREQ, .config = { /* AP: by default shutdown all sensors */ [SENSOR_CONFIG_AP] = { @@ -955,6 +961,8 @@ struct motion_sensor_t motion_sensors[] = { .addr = BMI160_ADDR0, .default_range = 1 << 11, /* 16LSB / uT, fixed */ .rot_standard_ref = &mag_standard_ref, + .min_frequency = BMM150_MAG_MIN_FREQ, + .max_frequency = BMM150_MAG_MAX_FREQ, .config = { /* AP: by default shutdown all sensors */ [SENSOR_CONFIG_AP] = { @@ -990,6 +998,8 @@ struct motion_sensor_t motion_sensors[] = { .port = I2C_PORT_BARO, .addr = BMP280_I2C_ADDRESS1, .default_range = 1 << 18, /* 1bit = 4 Pa, 16bit ~= 2600 hPa */ + .min_frequency = BMP280_BARO_MIN_FREQ, + .max_frequency = BMP280_BARO_MAX_FREQ, .config = { /* AP: by default shutdown all sensors */ [SENSOR_CONFIG_AP] = { @@ -1025,6 +1035,8 @@ struct motion_sensor_t motion_sensors[] = { .addr = OPT3001_I2C_ADDR1, .rot_standard_ref = NULL, .default_range = OPT3001_RANGE_AUTOMATIC_FULL_SCALE, + .min_frequency = OPT3001_LIGHT_MIN_FREQ, + .max_frequency = OPT3001_LIGHT_MAX_FREQ, .config = { /* AP: by default shutdown all sensors */ [SENSOR_CONFIG_AP] = { diff --git a/board/rowan/board.c b/board/rowan/board.c index 4a63261b10..4cd8b01345 100644 --- a/board/rowan/board.c +++ b/board/rowan/board.c @@ -527,6 +527,8 @@ struct motion_sensor_t motion_sensors[] = { .addr = BMI160_SET_SPI_ADDRESS(CONFIG_SPI_ACCEL_PORT), .rot_standard_ref = &lid_standard_ref, .default_range = 2, /* g, enough for laptop. */ + .min_frequency = BMI160_ACCEL_MIN_FREQ, + .max_frequency = BMI160_ACCEL_MAX_FREQ, .config = { /* AP: by default use EC settings */ [SENSOR_CONFIG_AP] = { @@ -563,6 +565,8 @@ struct motion_sensor_t motion_sensors[] = { .addr = BMI160_SET_SPI_ADDRESS(CONFIG_SPI_ACCEL_PORT), .default_range = 1000, /* dps */ .rot_standard_ref = &lid_standard_ref, + .min_frequency = BMI160_GYRO_MIN_FREQ, + .max_frequency = BMI160_GYRO_MAX_FREQ, .config = { /* AP: by default shutdown all sensors */ [SENSOR_CONFIG_AP] = { diff --git a/board/ryu/board.c b/board/ryu/board.c index 0950bc8ae0..b4455032a6 100644 --- a/board/ryu/board.c +++ b/board/ryu/board.c @@ -304,6 +304,8 @@ struct motion_sensor_t motion_sensors[] = { .addr = BMI160_ADDR0, .rot_standard_ref = &accelgyro_standard_ref, .default_range = 8, /* g, use hifi requirements */ + .min_frequency = BMI160_ACCEL_MIN_FREQ, + .max_frequency = BMI160_ACCEL_MAX_FREQ, .config = { /* AP: by default shutdown all sensors */ [SENSOR_CONFIG_AP] = { @@ -339,6 +341,8 @@ struct motion_sensor_t motion_sensors[] = { .addr = BMI160_ADDR0, .default_range = 1000, /* dps, use hifi requirement */ .rot_standard_ref = &accelgyro_standard_ref, + .min_frequency = BMI160_GYRO_MIN_FREQ, + .max_frequency = BMI160_GYRO_MAX_FREQ, .config = { /* AP: by default shutdown all sensors */ [SENSOR_CONFIG_AP] = { @@ -374,6 +378,8 @@ struct motion_sensor_t motion_sensors[] = { .addr = BMI160_ADDR0, .rot_standard_ref = &mag_standard_ref, .default_range = 1 << 11, /* 16LSB / uT, fixed */ + .min_frequency = BMM150_MAG_MIN_FREQ, + .max_frequency = BMM150_MAG_MAX_FREQ, .config = { /* AP: by default shutdown all sensors */ [SENSOR_CONFIG_AP] = { @@ -408,6 +414,8 @@ struct motion_sensor_t motion_sensors[] = { .addr = SI114X_ADDR, .rot_standard_ref = NULL, .default_range = 9000, /* 90%: int = 0 - frac = 9000/10000 */ + .min_frequency = SI114X_LIGHT_MIN_FREQ, + .max_frequency = SI114X_LIGHT_MAX_FREQ, .config = { /* AP: by default shutdown all sensors */ [SENSOR_CONFIG_AP] = { @@ -443,6 +451,8 @@ struct motion_sensor_t motion_sensors[] = { .addr = SI114X_ADDR, .rot_standard_ref = NULL, .default_range = 7630, /* Upon testing at desk */ + .min_frequency = SI114X_PROX_MIN_FREQ, + .max_frequency = SI114X_PROX_MAX_FREQ, .config = { /* AP: by default shutdown all sensors */ [SENSOR_CONFIG_AP] = { diff --git a/board/samus/board.c b/board/samus/board.c index d6523c57bb..62aebc32f2 100644 --- a/board/samus/board.c +++ b/board/samus/board.c @@ -316,6 +316,8 @@ struct motion_sensor_t motion_sensors[] = { .addr = LSM6DS0_ADDR1, .rot_standard_ref = &base_standard_ref, .default_range = 2, /* g, enough for laptop. */ + .min_frequency = LSM6DS0_ACCEL_MIN_FREQ, + .max_frequency = LSM6DS0_ACCEL_MAX_FREQ, .config = { /* AP: by default shutdown all sensors */ [SENSOR_CONFIG_AP] = { @@ -351,6 +353,8 @@ struct motion_sensor_t motion_sensors[] = { .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 = { /* AP: by default shutdown all sensors */ [SENSOR_CONFIG_AP] = { @@ -386,6 +390,8 @@ struct motion_sensor_t motion_sensors[] = { .addr = LSM6DS0_ADDR1, .rot_standard_ref = NULL, .default_range = 2000, /* g, enough for laptop. */ + .min_frequency = LSM6DS0_GYRO_MIN_FREQ, + .max_frequency = LSM6DS0_GYRO_MAX_FREQ, .config = { /* AP: by default shutdown all sensors */ [SENSOR_CONFIG_AP] = { diff --git a/board/strago/board.c b/board/strago/board.c index 67e44be830..7f45ba6661 100644 --- a/board/strago/board.c +++ b/board/strago/board.c @@ -216,6 +216,8 @@ struct motion_sensor_t motion_sensors[] = { .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 = { /* AP: by default shutdown all sensors */ [SENSOR_CONFIG_AP] = { @@ -251,6 +253,8 @@ struct motion_sensor_t motion_sensors[] = { .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 = { /* AP: by default shutdown all sensors */ [SENSOR_CONFIG_AP] = { diff --git a/board/wheatley/board.c b/board/wheatley/board.c index bd451c0428..5c985ea260 100644 --- a/board/wheatley/board.c +++ b/board/wheatley/board.c @@ -473,6 +473,8 @@ struct motion_sensor_t motion_sensors[] = { .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 = { /* AP: suspended until AP asks for data. */ [SENSOR_CONFIG_AP] = { @@ -509,6 +511,8 @@ struct motion_sensor_t motion_sensors[] = { .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 = { /* AP: suspended until AP asks for data. */ [SENSOR_CONFIG_AP] = { @@ -546,6 +550,8 @@ struct motion_sensor_t motion_sensors[] = { .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, .config = { /* AP: by default shutdown all sensors */ [SENSOR_CONFIG_AP] = { diff --git a/common/motion_sense.c b/common/motion_sense.c index 2b9d715343..a6792cf210 100644 --- a/common/motion_sense.c +++ b/common/motion_sense.c @@ -1020,10 +1020,23 @@ static int host_cmd_motion_sense(struct host_cmd_handler_args *args) else #endif out->info.type = sensor->type; + out->info.location = sensor->location; out->info.chip = sensor->chip; - - args->response_size = sizeof(out->info); + if (args->version >= 3) { + out->info_3.min_frequency = sensor->min_frequency; + /* + * Make sure reported max frequency for this sensor + * doesn't exceed the max sensor frequency the EC is + * capable of supporting + */ + out->info_3.max_frequency = MIN(sensor->max_frequency, + CONFIG_EC_MAX_SENSOR_FREQ_MILLIHZ); + out->info_3.fifo_max_event_count = MAX_FIFO_EVENT_COUNT; + args->response_size = sizeof(out->info_3); + } else { + args->response_size = sizeof(out->info); + } break; case MOTIONSENSE_CMD_EC_RATE: @@ -1329,7 +1342,7 @@ static int host_cmd_motion_sense(struct host_cmd_handler_args *args) DECLARE_HOST_COMMAND(EC_CMD_MOTION_SENSE_CMD, host_cmd_motion_sense, - EC_VER_MASK(1) | EC_VER_MASK(2)); + EC_VER_MASK(1) | EC_VER_MASK(2) | EC_VER_MASK(3)); /*****************************************************************************/ /* Console commands */ diff --git a/driver/accel_bma2x2.h b/driver/accel_bma2x2.h index 5a37152e99..653b71257a 100644 --- a/driver/accel_bma2x2.h +++ b/driver/accel_bma2x2.h @@ -154,4 +154,8 @@ extern const struct accelgyro_drv bma2x2_accel_drv; #define BMA2x2_BW_250HZ 0x0D /* LowPass 250HZ */ #define BMA2x2_BW_500HZ 0x0E /* LowPass 500HZ */ #define BMA2x2_BW_1000HZ 0x0F /* LowPass 1000HZ */ + +/* Min and Max sampling frequency in mHz */ +#define BMA255_ACCEL_MIN_FREQ 7810 +#define BMA255_ACCEL_MAX_FREQ 1000000 #endif /* __CROS_EC_ACCEL_BMA2x2_H */ diff --git a/driver/accel_kx022.h b/driver/accel_kx022.h index d25d68b380..7b1ea89c43 100644 --- a/driver/accel_kx022.h +++ b/driver/accel_kx022.h @@ -120,4 +120,8 @@ #define KX022_INC2_XPWUE (1 << 4) #define KX022_INC2_XNWUE (1 << 5) +/* Min and Max sampling frequency in mHz */ +#define KX022_ACCEL_MIN_FREQ 781 +#define KX022_ACCEL_MAX_FREQ 1600000 + #endif /* __CROS_EC_ACCEL_KX022_H */ diff --git a/driver/accel_kxcj9.h b/driver/accel_kxcj9.h index b3702ea541..778735a61b 100644 --- a/driver/accel_kxcj9.h +++ b/driver/accel_kxcj9.h @@ -104,4 +104,8 @@ #define KXCJ9_OSA_1600_HZ 7 #define KXCJ9_OSA_FIELD 0xf +/* Min and Max sampling frequency in mHz */ +#define KXCJ9_ACCEL_MIN_FREQ 781 +#define KXCJ9_ACCEL_MAX_FREQ 1600000 + #endif /* __CROS_EC_ACCEL_KXCJ9_H */ diff --git a/driver/accelgyro_bmi160.h b/driver/accelgyro_bmi160.h index b498503b3a..6031d8fb4e 100644 --- a/driver/accelgyro_bmi160.h +++ b/driver/accelgyro_bmi160.h @@ -417,6 +417,12 @@ enum fifo_header { /* Sensor resolution in number of bits. This sensor has fixed resolution. */ #define BMI160_RESOLUTION 16 +/* Min and Max sampling frequency in mHz */ +#define BMI160_ACCEL_MIN_FREQ 12500 +#define BMI160_ACCEL_MAX_FREQ 1600000 +#define BMI160_GYRO_MIN_FREQ 25 +#define BMI160_GYRO_MAX_FREQ 3200000 + extern const struct accelgyro_drv bmi160_drv; enum bmi160_running_mode { diff --git a/driver/accelgyro_lsm6ds0.h b/driver/accelgyro_lsm6ds0.h index 481f39aa10..3236203558 100644 --- a/driver/accelgyro_lsm6ds0.h +++ b/driver/accelgyro_lsm6ds0.h @@ -117,6 +117,12 @@ enum lsm6ds0_bdu { /* Sensor resolution in number of bits. This sensor has fixed resolution. */ #define LSM6DS0_RESOLUTION 16 +/* Min and Max sampling frequency in mHz */ +#define LSM6DS0_ACCEL_MIN_FREQ 14900 +#define LSM6DS0_ACCEL_MAX_FREQ 952000 +#define LSM6DS0_GYRO_MIN_FREQ 14900 +#define LSM6DS0_GYRO_MAX_FREQ 952000 + extern const struct accelgyro_drv lsm6ds0_drv; struct lsm6ds0_data { struct accelgyro_saved_data_t base; diff --git a/driver/als_opt3001.h b/driver/als_opt3001.h index b70909f630..9850dfe723 100644 --- a/driver/als_opt3001.h +++ b/driver/als_opt3001.h @@ -36,6 +36,10 @@ enum opt3001_mode { #define OPT3001_MANUFACTURER_ID 0x5449 #define OPT3001_DEVICE_ID 0x3001 +/* Min and Max sampling frequency in mHz */ +#define OPT3001_LIGHT_MIN_FREQ 1250 +#define OPT3001_LIGHT_MAX_FREQ 10000 + #ifdef HAS_TASK_ALS int opt3001_init(void); int opt3001_read_lux(int *lux, int af); diff --git a/driver/als_si114x.h b/driver/als_si114x.h index 78fed24c78..aeb84dbfb3 100644 --- a/driver/als_si114x.h +++ b/driver/als_si114x.h @@ -214,6 +214,12 @@ /* Delay used for deferred callback when polling is enabled */ #define SI114x_POLLING_DELAY (8 * MSEC) +/* Min and Max sampling frequency in mHz */ +#define SI114X_PROX_MIN_FREQ 504 +#define SI114X_PROX_MAX_FREQ 100000 +#define SI114X_LIGHT_MIN_FREQ 504 +#define SI114X_LIGHT_MAX_FREQ 100000 + extern const struct accelgyro_drv si114x_drv; enum si114x_state { diff --git a/driver/baro_bmp280.h b/driver/baro_bmp280.h index cd4605ed1a..c285d69b73 100644 --- a/driver/baro_bmp280.h +++ b/driver/baro_bmp280.h @@ -159,6 +159,14 @@ /*******************************************************/ #define BMP280_GET_DATA(_s) \ ((struct bmp280_drv_data_t *)(_s)->drv_data) + +/* Min and Max sampling frequency in mHz based on x4 oversampling used */ +/* FIXME - verify how chip is setup to make sure MAX is correct, manual says + * "Typical", not Max. + */ +#define BMP280_BARO_MIN_FREQ 75000 +#define BMP280_BARO_MAX_FREQ 87000 + /**************************************************************/ /* STRUCTURE and ENUM DEFINITIONS */ /**************************************************************/ diff --git a/driver/gyro_l3gd20h.h b/driver/gyro_l3gd20h.h index 73c0253d27..24ad81a693 100644 --- a/driver/gyro_l3gd20h.h +++ b/driver/gyro_l3gd20h.h @@ -71,6 +71,10 @@ #define L3GD20_LOW_ODR_MASK (1 << 0) #define L3GD20_ODR_PD_MASK (1 << 3) +/* Min and Max sampling frequency in mHz */ +#define L3GD20_GYRO_MIN_FREQ 12500 +#define L3GD20_GYRO_MAX_FREQ 800000 + /* * Register : STATUS_REG * Address : 0X27 diff --git a/driver/mag_bmm150.h b/driver/mag_bmm150.h index a76c68cf3d..7eb469cf43 100644 --- a/driver/mag_bmm150.h +++ b/driver/mag_bmm150.h @@ -74,6 +74,9 @@ #define BMM150_HALL_OVERFLOW_ADCVAL (-16384) #define BMM150_OVERFLOW_OUTPUT (0x8000) +/* Min and Max sampling frequency in mHz */ +#define BMM150_MAG_MIN_FREQ 781 +#define BMM150_MAG_MAX_FREQ 800000 struct bmm150_comp_registers { /* Local copy of the compensation registers. */ diff --git a/include/common.h b/include/common.h index f35d543ce8..a98fce3ca2 100644 --- a/include/common.h +++ b/include/common.h @@ -156,4 +156,7 @@ enum ec_error_list { #define test_export_static static #endif +/* find the most significant bit. Not defined in n == 0. */ +#define __fls(n) (31 - __builtin_clz(n)) + #endif /* __CROS_EC_COMMON_H */ diff --git a/include/config.h b/include/config.h index cafc5363fb..ddaac00513 100644 --- a/include/config.h +++ b/include/config.h @@ -925,6 +925,9 @@ /* Support EC to Internal bus bridge. */ #undef CONFIG_EC2I +/* EC capable of sensor speeds up to 200000 mHz */ +#define CONFIG_EC_MAX_SENSOR_FREQ_MILLIHZ 200000 + /* Support EC chip internal data EEPROM */ #undef CONFIG_EEPROM diff --git a/include/ec_commands.h b/include/ec_commands.h index 84aa055d04..abc71517bd 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -2100,7 +2100,8 @@ struct __ec_todo_packed ec_params_motion_sense { * and MOTIONSENSE_CMD_PERFORM_CALIB. */ struct __ec_todo_unpacked { uint8_t sensor_num; - } info, data, fifo_flush, perform_calib, list_activities; + } info, info_3, data, fifo_flush, perform_calib, + list_activities; /* * Used for MOTIONSENSE_CMD_EC_RATE, MOTIONSENSE_CMD_SENSOR_ODR @@ -2220,6 +2221,27 @@ struct __ec_todo_packed ec_response_motion_sense { uint8_t chip; } info; + /* Used for MOTIONSENSE_CMD_INFO version 3 */ + struct __ec_todo_unpacked { + /* Should be element of enum motionsensor_type. */ + uint8_t type; + + /* Should be element of enum motionsensor_location. */ + uint8_t location; + + /* Should be element of enum motionsensor_chip. */ + uint8_t chip; + + /* Minimum sensor sampling frequency */ + uint32_t min_frequency; + + /* Maximum sensor sampling frequency */ + uint32_t max_frequency; + + /* Max number of sensor events that could be in fifo */ + uint32_t fifo_max_event_count; + } info_3; + /* Used for MOTIONSENSE_CMD_DATA */ struct ec_response_motion_sensor_data data; diff --git a/include/motion_sense.h b/include/motion_sense.h index 0ca7443b98..c50faba9c1 100644 --- a/include/motion_sense.h +++ b/include/motion_sense.h @@ -45,6 +45,12 @@ enum sensor_config { #define ROUND_UP_FLAG (1 << 31) #define BASE_ODR(_odr) ((_odr) & ~ROUND_UP_FLAG) +#ifdef CONFIG_ACCEL_FIFO +#define MAX_FIFO_EVENT_COUNT CONFIG_ACCEL_FIFO +#else +#define MAX_FIFO_EVENT_COUNT 0 +#endif + struct motion_data_t { /* * data rate the sensor will measure, in mHz: 0 suspended. @@ -141,6 +147,12 @@ struct motion_sensor_t { * from sensor registers. */ uint32_t last_collection; + + /* Minimum supported sampling frequency in miliHertz for this sensor */ + uint32_t min_frequency; + + /* Maximum supported sampling frequency in miliHertz for this sensor */ + uint32_t max_frequency; }; /* Defined at board level. */ diff --git a/include/util.h b/include/util.h index 5b6b554854..a2395674e9 100644 --- a/include/util.h +++ b/include/util.h @@ -49,9 +49,6 @@ /* True of x is a power of two */ #define POWER_OF_TWO(x) (x && !(x & (x - 1))) -/* find the most significant bit. Not defined in n == 0. */ -#define __fls(n) (31 - __builtin_clz(n)) - /* * macros for integer division with various rounding variants * default integer division rounds down. diff --git a/util/ectool.c b/util/ectool.c index 651fcfcbaa..6a8441f172 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -3473,7 +3473,7 @@ static const struct { uint8_t insize; } ms_command_sizes[] = { MS_DUMP_SIZE(), - MS_SIZES(info), + MS_SIZES(info_3), MS_SIZES(ec_rate), MS_SIZES(sensor_odr), MS_SIZES(sensor_range), @@ -3601,18 +3601,34 @@ static int cmd_motionsense(int argc, char **argv) } if (argc == 3 && !strcasecmp(argv[1], "info")) { - param.cmd = MOTIONSENSE_CMD_INFO; + struct ec_params_get_cmd_versions p; + struct ec_response_get_cmd_versions r; + int version = 0; + param.cmd = MOTIONSENSE_CMD_INFO; param.sensor_odr.sensor_num = strtol(argv[2], &e, 0); if (e && *e) { fprintf(stderr, "Bad %s arg.\n", argv[2]); return -1; } - rv = ec_command(EC_CMD_MOTION_SENSE_CMD, 1, + /* tool defaults to using latest version of info command */ + p.cmd = EC_CMD_MOTION_SENSE_CMD; + rv = ec_command(EC_CMD_GET_CMD_VERSIONS, 0, &p, sizeof(p), + &r, sizeof(r)); + if (rv < 0) { + if (rv == -EC_RES_INVALID_PARAM) + printf("Command 0x%02x not supported by EC.\n", + EC_CMD_GET_CMD_VERSIONS); + return rv; + } + + if (r.version_mask) + version = __fls(r.version_mask); + + rv = ec_command(EC_CMD_MOTION_SENSE_CMD, version, ¶m, ms_command_sizes[param.cmd].outsize, resp, ms_command_sizes[param.cmd].insize); - if (rv < 0) return rv; @@ -3688,6 +3704,14 @@ static int cmd_motionsense(int argc, char **argv) printf("unknown\n"); } + if (version >= 3) { + printf("Min Frequency: %d mHz\n", + resp->info_3.min_frequency); + printf("Max Frequency: %d mHz\n", + resp->info_3.max_frequency); + printf("FIFO Max Event Count: %d\n", + resp->info_3.fifo_max_event_count); + } return 0; } |