diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2015-08-25 18:52:19 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2015-08-29 01:34:14 -0700 |
commit | 4e7e1bb796190e658ea2de8d4e391efa59b0d643 (patch) | |
tree | c6927e9226f1853ce2602cc71d6399f7ad210860 /board/ryu | |
parent | 398bd9a0178c0120a2dbf3f58419d6a5360dfb3d (diff) | |
download | chrome-ec-4e7e1bb796190e658ea2de8d4e391efa59b0d643.tar.gz |
motion_sense: Add more complex EC/AP sensor rate support.
Add config settings for ODR and EC rate per requestor and
per power state (1 for the AP, 3 for the EC).
This way we can finely set ec rate and ODR depending on usage.
On chromeos, AP is not setting frequency, so EC sets for different power
state. On some platform, sensors can now be suspended in S3/S5.
Allow EC oversampling when AP is only looking for a few samples.
It is useful for double tap detection where high accelerator ODR is
required.
BRANCH=ryu
TEST=Tested on Ryu
BUG=chromium:513458
Change-Id: Ic3888a749699f07b10c5da3bc07204afd4de70da
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/295637
Diffstat (limited to 'board/ryu')
-rw-r--r-- | board/ryu/board.c | 137 |
1 files changed, 111 insertions, 26 deletions
diff --git a/board/ryu/board.c b/board/ryu/board.c index c38a9823da..53d3d2efd3 100644 --- a/board/ryu/board.c +++ b/board/ryu/board.c @@ -287,12 +287,29 @@ struct motion_sensor_t motion_sensors[] = { .drv_data = &g_bmi160_data, .addr = BMI160_ADDR0, .rot_standard_ref = &accelgyro_standard_ref, - .default_config = { - /* 100Hz is fast enough for double tap detection */ - .odr = 100000, - .range = 8, /* g */ - .ec_rate = SUSPEND_SAMPLING_INTERVAL, - } + .default_range = 8, /* g, use hifi requirements */ + .config = { + /* AP: by default shutdown all sensors */ + [SENSOR_CONFIG_AP] = { + .odr = 0, + .ec_rate = 0, + }, + /* EC does not need accel in S0 */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 0, + .ec_rate = 0, + }, + /* Used for double tap */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 100000, + /* Interrupt driven, no polling */ + .ec_rate = 0, + }, + [SENSOR_CONFIG_EC_S5] = { + .odr = 100000, + .ec_rate = 0, + }, + }, }, {.name = "Gyro", @@ -304,12 +321,29 @@ struct motion_sensor_t motion_sensors[] = { .mutex = &g_mutex, .drv_data = &g_bmi160_data, .addr = BMI160_ADDR0, + .default_range = 1000, /* dps, use hifi requirement */ .rot_standard_ref = &accelgyro_standard_ref, - .default_config = { - .odr = 0, - .range = 1000, /* dps */ - .ec_rate = MAX_MOTION_SENSE_WAIT_TIME, - } + .config = { + /* AP: by default shutdown all sensors */ + [SENSOR_CONFIG_AP] = { + .odr = 0, + .ec_rate = 0, + }, + /* EC does not need accel in S0 */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 0, + .ec_rate = 0, + }, + /* Unused */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 0, + .ec_rate = 0, + }, + [SENSOR_CONFIG_EC_S5] = { + .odr = 0, + .ec_rate = 0, + }, + }, }, {.name = "Mag", @@ -322,11 +356,28 @@ struct motion_sensor_t motion_sensors[] = { .drv_data = &g_bmi160_data, .addr = BMI160_ADDR0, .rot_standard_ref = &mag_standard_ref, - .default_config = { - .odr = 0, - .range = 1 << 11, /* 16LSB / uT */ - .ec_rate = MAX_MOTION_SENSE_WAIT_TIME, - } + .default_range = 1 << 11, /* 16LSB / uT, fixed */ + .config = { + /* AP: by default shutdown all sensors */ + [SENSOR_CONFIG_AP] = { + .odr = 0, + .ec_rate = 0, + }, + /* EC does not need accel in S0 */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 0, + .ec_rate = 0, + }, + /* Unused */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 0, + .ec_rate = 0, + }, + [SENSOR_CONFIG_EC_S5] = { + .odr = 0, + .ec_rate = 0, + }, + }, }, {.name = "Light", .active_mask = SENSOR_ACTIVE_S0_S3_S5, @@ -338,11 +389,28 @@ struct motion_sensor_t motion_sensors[] = { .drv_data = &g_si114x_data, .addr = SI114X_ADDR, .rot_standard_ref = NULL, - .default_config = { - .odr = 0, - .range = 9000, /* 90%: int = 0 - frac = 9000/10000 */ - .ec_rate = 1000 * MSEC, - } + .default_range = 9000, /* 90%: int = 0 - frac = 9000/10000 */ + .config = { + /* AP: by default shutdown all sensors */ + [SENSOR_CONFIG_AP] = { + .odr = 0, + .ec_rate = 0, + }, + /* EC to use to set led brightness */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 1000, + .ec_rate = 1000, + }, + [SENSOR_CONFIG_EC_S3] = { + .odr = 1000, + /* Interrupt driven, for double tap */ + .ec_rate = 0, + }, + [SENSOR_CONFIG_EC_S5] = { + .odr = 1000, + .ec_rate = 0, + }, + }, }, {.name = "Proxi", .active_mask = SENSOR_ACTIVE_S0_S3_S5, @@ -354,11 +422,28 @@ struct motion_sensor_t motion_sensors[] = { .drv_data = &g_si114x_data, .addr = SI114X_ADDR, .rot_standard_ref = NULL, - .default_config = { - .odr = 0, - .range = 1 << 16, /* 100% fuzzy unit */ - .ec_rate = 1000 * MSEC, - } + .default_range = 1 << 16, /* 100% fuzzy unit */ + .config = { + /* AP: by default shutdown all sensors */ + [SENSOR_CONFIG_AP] = { + .odr = 0, + .ec_rate = 0, + }, + /* EC does not need accel in S0 */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 0, + .ec_rate = 0, + }, + /* 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); |