summaryrefslogtreecommitdiff
path: root/driver/accelgyro_bmi260.c
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2020-05-17 16:43:02 -0700
committerCommit Bot <commit-bot@chromium.org>2020-11-12 03:23:26 +0000
commitd28c10498cdbf007b97b5c0a9a951373574d4eea (patch)
tree3d66ca06837aae98ff747fff85b439976e563045 /driver/accelgyro_bmi260.c
parent9676f9291f60efdfb31373aeb77385ebb6e9f6e5 (diff)
downloadchrome-ec-d28c10498cdbf007b97b5c0a9a951373574d4eea.tar.gz
motion_sense: Make change in range permanent
When AP changes range, unlike offset or ODR, it was not surviving init() call. If the sensor is powered off in S3, at resume the range would be back to the default. To make it consistent with other attributes, remember range change until EC powers down. - remove get_range - add current_range to store the range currently used. This is modifiable by the AP - when the AP shutdown, revert current_range to default_range - Remove const attribute for sensor structure when init and set_range is called. BUG=chromium:1083791 BRANCH=none TEST=One eve branch, check range is preserved even after 'shutdown -h 0' Change-Id: Ia7126ac0cc9c3fef60b4464d95d6dd15e64b0fc4 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2215751 Reviewed-by: Yuval Peress <peress@chromium.org>
Diffstat (limited to 'driver/accelgyro_bmi260.c')
-rw-r--r--driver/accelgyro_bmi260.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/driver/accelgyro_bmi260.c b/driver/accelgyro_bmi260.c
index 56a3ab1a17..1be15b21c7 100644
--- a/driver/accelgyro_bmi260.c
+++ b/driver/accelgyro_bmi260.c
@@ -209,14 +209,14 @@ static int calibrate_offset(const struct motion_sensor_t *s,
return ret;
}
-static int perform_calib(const struct motion_sensor_t *s, int enable)
+static int perform_calib(struct motion_sensor_t *s, int enable)
{
int ret, rate;
int16_t temp;
int16_t offset[3];
intv3_t target = {0, 0, 0};
/* Get sensor range for calibration*/
- int range = bmi_get_range(s);
+ int range = s->current_range;
if (!enable)
return EC_SUCCESS;
@@ -497,7 +497,7 @@ static int init_config(const struct motion_sensor_t *s)
return EC_SUCCESS;
}
-static int init(const struct motion_sensor_t *s)
+static int init(struct motion_sensor_t *s)
{
int ret = 0, tmp, i;
struct accelgyro_saved_data_t *saved_data = BMI_GET_SAVED_DATA(s);
@@ -532,7 +532,6 @@ static int init(const struct motion_sensor_t *s)
* so set data rate to 0.
*/
saved_data->odr = 0;
- bmi_set_range(s, s->default_range, 0);
if (IS_ENABLED(CONFIG_ACCEL_INTERRUPTS) &&
(s->type == MOTIONSENSE_TYPE_ACCEL))
@@ -545,7 +544,6 @@ const struct accelgyro_drv bmi260_drv = {
.init = init,
.read = bmi_read,
.set_range = bmi_set_range,
- .get_range = bmi_get_range,
.get_resolution = bmi_get_resolution,
.set_data_rate = set_data_rate,
.get_data_rate = bmi_get_data_rate,