Patch "iio: imu: inv_mpu6050: add accel lpf setting for chip >= MPU6500" has been added to the 4.9-stable tree
Subsystems (3)
This is a note to let you know that I've just added the patch titled
iio: imu: inv_mpu6050: add accel lpf setting for chip >= MPU6500
to the 4.9-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
iio-imu-inv_mpu6050-add-accel-lpf-setting-for-chip-mpu6500.patch
and it can be found in the queue-4.9 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
948588e25b8af5e66962ed3f53e1cae1656fa5afMon Sep 17 00:00:00 2001
From: Jean-Baptiste Maneyrol <[email protected]>
Date: Mon, 29 May 2017 09:59:40 +0000
Subject: iio: imu: inv_mpu6050: add accel lpf setting for chip >= MPU6500
From: Jean-Baptiste Maneyrol <[email protected]>
commit 948588e25b8af5e66962ed3f53e1cae1656fa5af upstream.
Starting from MPU6500, accelerometer dlpf is set in a separate register named ACCEL_CONFIG_2.
Add this new register in the map and set it for the corresponding chips.
--- drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 39 ++++++++++++++++++++++++++--- drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 3 ++ 2 files changed, 39 insertions(+), 3 deletions(-)
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +36 -3
@@ -41,6 +41,7 @@ static const int accel_scale[] = {598, 1static const struct inv_mpu6050_reg_map reg_set_6500 = { .sample_rate_div =INV_MPU6050_REG_SAMPLE_RATE_DIV , .lpf =INV_MPU6050_REG_CONFIG , + .accel_lpf =INV_MPU6500_REG_ACCEL_CONFIG_2 , .user_ctrl =INV_MPU6050_REG_USER_CTRL , .fifo_en =INV_MPU6050_REG_FIFO_EN , .gyro_config =INV_MPU6050_REG_GYRO_CONFIG ,
@@ -205,6 +206,37 @@ int inv_mpu6050_set_power_itg(struct invEXPORT_SYMBOL_GPL (inv_mpu6050_set_power_itg);/** +* inv_mpu6050_set_lpf_regs() - set low pass filter registers, chip dependent +* +* MPU60xx/MPU9150 use only 1 register for accelerometer + gyroscope +* MPU6500 and above have a dedicated register for accelerometer +*/ +static int inv_mpu6050_set_lpf_regs (struct inv_mpu6050_state *st, +enum inv_mpu6050_filter_e val) +{ +int result; + + result =regmap_write (st->map, st->reg->lpf, val); +if (result) +return result; + +switch (st->chip_type) { +case INV_MPU6050 : +case INV_MPU6000 : +case INV_MPU9150 : +/* old chips, nothing to do */ + result =0 ; +break ; +default : +/* set accel lpf */ + result =regmap_write (st->map, st->reg->accel_lpf, val); +break ; + } + +return result; +} + +/** * inv_mpu6050_init_config() - Initialize hardware, disable FIFO. * * Initial configuration:
@@ -227,8 +259,7 @@ static int inv_mpu6050_init_config(strucif (result)return result; - d =INV_MPU6050_FILTER_20HZ ; - result =regmap_write (st->map, st->reg->lpf, d); + result =inv_mpu6050_set_lpf_regs (st,INV_MPU6050_FILTER_20HZ );if (result)return result;
@@ -531,6 +562,8 @@ error_write_raw:* would be alising. This function basically search for the * correct low pass parameters based on the fifo rate, e.g, * sampling frequency. +* +* lpf is set automatically when setting sampling rate to avoid any aliases. */ static int inv_mpu6050_set_lpf (struct inv_mpu6050_state *st,int rate) {
@@ -546,7 +579,7 @@ static int inv_mpu6050_set_lpf(struct inwhile ((h < hz[i]) && (i <ARRAY_SIZE (d) -1 )) i++; data = d[i]; - result =regmap_write (st->map, st->reg->lpf, data); + result =inv_mpu6050_set_lpf_regs (st, data);if (result)return result; st->chip_config.lpf = data;
drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h +3 -0
@@ -28,6 +28,7 @@* struct inv_mpu6050_reg_map - Notable registers. * @sample_rate_div: Divider applied to gyro output rate. * @lpf: Configures internal low pass filter. +* @accel_lpf: Configures accelerometer low pass filter. * @user_ctrl: Enables/resets the FIFO. * @fifo_en: Determines which data will appear in FIFO. * @gyro_config: gyro config register.
@@ -47,6 +48,7 @@struct inv_mpu6050_reg_map {u8 sample_rate_div;u8 lpf; +u8 accel_lpf;u8 user_ctrl;u8 fifo_en;u8 gyro_config;
@@ -187,6 +189,7 @@ struct inv_mpu6050_state {#define INV_MPU6050_FIFO_THRESHOLD 500/* mpu6500 registers */ +#define INV_MPU6500_REG_ACCEL_CONFIG_2 0x1D#define INV_MPU6500_REG_ACCEL_OFFSET 0x77/* delay time in milliseconds */
Patches currently in stable-queue which might be from [email protected] are
queue-4.9/iio-imu-inv_mpu6050-add-accel-lpf-setting-for-chip-mpu6500.patch