From: Jonathan Cameron <jic23@kernel.org>
To: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>
Subject: Re: [PATCH 9/9] iio: imu: inv_mpu6050: fix LPF bandwidth setting
Date: Sat, 1 Feb 2020 16:23:03 +0000 [thread overview]
Message-ID: <20200201162303.46dc0461@archlinux> (raw)
In-Reply-To: <20200120093620.9681-10-jmaneyrol@invensense.com>
On Mon, 20 Jan 2020 10:36:20 +0100
Jean-Baptiste Maneyrol <jmaneyrol@invensense.com> wrote:
> As every chip has some little variant in LPF bandwidth values,
> use common values that are working for all chips.
> Simplify the LPF setting function.
>
> Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
hmm. On this one I wonder if the 'fix' title is strictly accurate.
It's certainly a good thing to have, but I'm not sure if we will
want to backport it. If you do, then break it out of this series
as a separate fix and add appropriate fixes tag.
All the other patches I haven't commented on in this series look fine
to me subject to Rob's suggestion of combining the dt ID additions for
the binding doc into one patch.
Thanks,
Jonathan
> ---
> drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 30 ++++++++++++----------
> drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 10 ++++----
> 2 files changed, 21 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> index 9ecc667debbe..c4db9086775c 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> @@ -707,30 +707,32 @@ static int inv_mpu6050_write_raw(struct iio_dev *indio_dev,
> /**
> * inv_mpu6050_set_lpf() - set low pass filer based on fifo rate.
> *
> - * Based on the Nyquist principle, the sampling rate must
> - * exceed twice of the bandwidth of the signal, or there
> - * would be alising. This function basically search for the
> - * correct low pass parameters based on the fifo rate, e.g,
> - * sampling frequency.
> + * Based on the Nyquist principle, the bandwidth of the low
> + * pass filter must not exceed the signal sampling rate divided
> + * by 2, or there would be aliasing.
> + * 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)
> {
> - static const int hz[] = {188, 98, 42, 20, 10, 5};
> + static const int hz[] = {400, 200, 90, 40, 20, 10};
> static const int d[] = {
> - INV_MPU6050_FILTER_188HZ, INV_MPU6050_FILTER_98HZ,
> - INV_MPU6050_FILTER_42HZ, INV_MPU6050_FILTER_20HZ,
> + INV_MPU6050_FILTER_200HZ, INV_MPU6050_FILTER_100HZ,
> + INV_MPU6050_FILTER_45HZ, INV_MPU6050_FILTER_20HZ,
> INV_MPU6050_FILTER_10HZ, INV_MPU6050_FILTER_5HZ
> };
> - int i, h, result;
> + int i, result;
> u8 data;
>
> - h = (rate >> 1);
> - i = 0;
> - while ((h < hz[i]) && (i < ARRAY_SIZE(d) - 1))
> - i++;
> - data = d[i];
> + data = INV_MPU6050_FILTER_5HZ;
> + for (i = 0; i < ARRAY_SIZE(hz); ++i) {
> + if (rate >= hz[i]) {
> + data = d[i];
> + break;
> + }
> + }
> result = inv_mpu6050_set_lpf_regs(st, data);
> if (result)
> return result;
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> index 7ae614052210..9a81098a8b4d 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> @@ -370,14 +370,14 @@ enum inv_mpu6050_scan {
> };
>
> enum inv_mpu6050_filter_e {
> - INV_MPU6050_FILTER_256HZ_NOLPF2 = 0,
> - INV_MPU6050_FILTER_188HZ,
> - INV_MPU6050_FILTER_98HZ,
> - INV_MPU6050_FILTER_42HZ,
> + INV_MPU6050_FILTER_NOLPF2 = 0,
> + INV_MPU6050_FILTER_200HZ,
> + INV_MPU6050_FILTER_100HZ,
> + INV_MPU6050_FILTER_45HZ,
> INV_MPU6050_FILTER_20HZ,
> INV_MPU6050_FILTER_10HZ,
> INV_MPU6050_FILTER_5HZ,
> - INV_MPU6050_FILTER_2100HZ_NOLPF,
> + INV_MPU6050_FILTER_NOLPF,
> NUM_MPU6050_FILTER
> };
>
prev parent reply other threads:[~2020-02-01 16:23 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-20 9:36 [PATCH 0/9] Add support of similar chips Jean-Baptiste Maneyrol
2020-01-20 9:36 ` [PATCH 1/9] dt-bindings: iio: imu: inv_mpu6050: add missing entry for mpu6000 Jean-Baptiste Maneyrol
2020-01-31 14:37 ` Rob Herring
2020-01-20 9:36 ` [PATCH 2/9] iio: imu: inv_mpu6050: cleanup spi support Jean-Baptiste Maneyrol
2020-02-01 16:16 ` Jonathan Cameron
2020-01-20 9:36 ` [PATCH 3/9] iio: imu: inv_mpu6050: add support of ICM20609 & ICM20689 Jean-Baptiste Maneyrol
2020-01-20 9:36 ` [PATCH 4/9] dt-bindings: add description for icm20609 and icm20689 Jean-Baptiste Maneyrol
2020-01-20 9:36 ` [PATCH 5/9] iio: imu: inv_mpu6050: add support of IAM20680 Jean-Baptiste Maneyrol
2020-01-20 9:36 ` [PATCH 6/9] dt-bindings: add description for iam20680 Jean-Baptiste Maneyrol
2020-01-20 9:36 ` [PATCH 7/9] iio: imu: inv_mpu6050: add support of ICM20690 Jean-Baptiste Maneyrol
2020-01-20 9:36 ` [PATCH 8/9] dt-bindings: add description for icm20690 Jean-Baptiste Maneyrol
2020-01-20 9:36 ` [PATCH 9/9] iio: imu: inv_mpu6050: fix LPF bandwidth setting Jean-Baptiste Maneyrol
2020-02-01 16:23 ` Jonathan Cameron [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200201162303.46dc0461@archlinux \
--to=jic23@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jmaneyrol@invensense.com \
--cc=linux-iio@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=robh+dt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).