summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Vaccaro <nvaccaro@chromium.org>2017-04-25 19:09:03 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2019-03-29 21:05:09 +0000
commite9ef15fe21c5d96e547ac9c5c0187fe3c79e4ade (patch)
tree28b4c7dfd329ca7977f76b6b6e158da3dd95bf64
parente979ebb6c35b5737b4636ae9f2d45cf95ab52461 (diff)
downloadchrome-ec-e9ef15fe21c5d96e547ac9c5c0187fe3c79e4ade.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. BUG=chromium:615059,b:123039234 BRANCH=reef TEST=build/boot and verify MOTIONSENSE_CMD_INFO response on kevin, make buildall -j passes. TEST=Pass CTS P test. Conflicts: board/eve/board.c board/kahlee/board.c board/poppy/board.c board/reef/board.c board/rowan/board.c driver/als_opt3001.h driver/als_si114x.h include/config.h Only change boards present in the branch. Do not upgrade opt3001, not using motion sense task yet. 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> (cherry picked from commit 9a0d0aa70d483be79c71a459dfd5f5e89da2638d) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1529134 Tested-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Enrico Granata <egranata@chromium.org> Commit-Queue: Gwendal Grignou <gwendal@chromium.org>
-rw-r--r--board/elm/board.c4
-rw-r--r--board/eve/board.c8
-rw-r--r--board/glados/board.c6
-rw-r--r--board/kevin/board.c10
-rw-r--r--board/oak/board.c6
-rw-r--r--board/reef/board.c10
-rw-r--r--board/ryu/board.c10
-rw-r--r--board/samus/board.c6
-rw-r--r--board/strago/board.c4
-rw-r--r--board/wheatley/board.c6
-rw-r--r--common/motion_sense.c19
-rw-r--r--driver/accel_bma2x2.h4
-rw-r--r--driver/accel_kx022.h4
-rw-r--r--driver/accel_kxcj9.h4
-rw-r--r--driver/accelgyro_bmi160.h6
-rw-r--r--driver/accelgyro_lsm6ds0.h6
-rw-r--r--driver/als_si114x.h6
-rw-r--r--driver/baro_bmp280.h8
-rw-r--r--driver/gyro_l3gd20h.h4
-rw-r--r--driver/mag_bmm150.h3
-rw-r--r--include/common.h3
-rw-r--r--include/config.h3
-rw-r--r--include/ec_commands.h24
-rw-r--r--include/motion_sense.h12
-rw-r--r--include/util.h3
-rw-r--r--util/ectool.c32
26 files changed, 200 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 4cc75b2717..626c0f6585 100644
--- a/board/eve/board.c
+++ b/board/eve/board.c
@@ -699,6 +699,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] = {
@@ -735,6 +737,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] = {
@@ -772,6 +776,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] = {
@@ -809,6 +815,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] = {
diff --git a/board/glados/board.c b/board/glados/board.c
index 7ef71dd915..7e3ac12579 100644
--- a/board/glados/board.c
+++ b/board/glados/board.c
@@ -495,6 +495,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] = {
@@ -531,6 +533,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] = {
@@ -567,6 +571,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/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/reef/board.c b/board/reef/board.c
index 4d074b3af3..706a0f451d 100644
--- a/board/reef/board.c
+++ b/board/reef/board.c
@@ -860,6 +860,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] = {
@@ -896,6 +898,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] = {
@@ -933,6 +937,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] = {
@@ -970,6 +976,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] = {
@@ -1005,6 +1013,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/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 53c56c9070..91e2ee9d7f 100644
--- a/board/samus/board.c
+++ b/board/samus/board.c
@@ -311,6 +311,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] = {
@@ -346,6 +348,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] = {
@@ -381,6 +385,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 6459488567..9e28ca49aa 100644
--- a/board/strago/board.c
+++ b/board/strago/board.c
@@ -211,6 +211,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] = {
@@ -246,6 +248,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 c404475734..4d4f8a0914 100644
--- a/board/wheatley/board.c
+++ b/board/wheatley/board.c
@@ -471,6 +471,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] = {
@@ -507,6 +509,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] = {
@@ -544,6 +548,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 062a32d10e..1787fd0196 100644
--- a/common/motion_sense.c
+++ b/common/motion_sense.c
@@ -987,10 +987,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:
@@ -1242,7 +1255,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_si114x.h b/driver/als_si114x.h
index 5fbc3c665f..2486d05dc2 100644
--- a/driver/als_si114x.h
+++ b/driver/als_si114x.h
@@ -211,6 +211,12 @@
/* Time to wait before re-initializing the device if access is denied */
#define SI114X_DENIED_THRESHOLD (10 * SECOND)
+/* 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 b5b7656fde..818c00d0b2 100644
--- a/include/config.h
+++ b/include/config.h
@@ -879,6 +879,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
+
/*
* Allow board to override the feature bitmap provided through host command
* and ACPI.
diff --git a/include/ec_commands.h b/include/ec_commands.h
index fb305e46d8..1bb70e482a 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -2083,7 +2083,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
@@ -2189,6 +2190,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 98c27ae04d..9ecd63dce0 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.
@@ -134,6 +140,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 e031148e45..39c0707fb4 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 799939249c..fc94d26414 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -3423,7 +3423,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),
@@ -3548,18 +3548,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,
&param, ms_command_sizes[param.cmd].outsize,
resp, ms_command_sizes[param.cmd].insize);
-
if (rv < 0)
return rv;
@@ -3632,6 +3648,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;
}