From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Matti Vaittinen <mazziesaccount@gmail.com>
Cc: Jonathan Cameron <jic23@kernel.org>,
Jagath Jog J <jagathjog1996@gmail.com>,
Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>,
Lars-Peter Clausen <lars@metafoo.de>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Dmitry Rokosov <DDRokosov@sberdevices.ru>,
Cosmin Tanislav <demonsingur@gmail.com>,
<linux-iio@vger.kernel.org>, <devicetree@vger.kernel.org>,
<linux-kernel@vger.kernel.org>,
Mehdi Djait <mehdi.djait.k@gmail.com>
Subject: Re: [PATCH v5 2/3] iio: accel: Support Kionix/ROHM KX022A accelerometer
Date: Thu, 19 Oct 2023 12:12:26 +0100 [thread overview]
Message-ID: <20231019121226.000078fe@Huawei.com> (raw)
In-Reply-To: <ceaf7033-d86b-4d63-b8e0-bc7445cf0df0@gmail.com>
On Thu, 19 Oct 2023 08:53:31 +0300
Matti Vaittinen <mazziesaccount@gmail.com> wrote:
> On 10/18/23 22:34, Jonathan Cameron wrote:
> > On Wed, 18 Oct 2023 01:37:12 +0530
> > Jagath Jog J <jagathjog1996@gmail.com> wrote:
>
> Hi Jagath - and thanks!
>
> >> Hi Matti,
> >>
> >> On Mon, Oct 24, 2022 at 6:10 PM Matti Vaittinen
> >> <mazziesaccount@gmail.com> wrote:
> >>>
> >>> KX022A is a 3-axis accelerometer from ROHM/Kionix. The sensor features
> >>> include variable ODRs, I2C and SPI control, FIFO/LIFO with watermark IRQ,
> >>> tap/motion detection, wake-up & back-to-sleep events, four acceleration
> >>> ranges (2, 4, 8 and 16g), and probably some other cool features.
> >>
> >> This is a nice driver, and I found it very helpful as a reference.
> >> One question regarding scale please see below.
> >>
> >>> + * range is typically +-2G/4G/8G/16G, distributed over the amount of bits.
> >>> + * The scale table can be calculated using
> >>> + * (range / 2^bits) * g = (range / 2^bits) * 9.80665 m/s^2
> >>> + * => KX022A uses 16 bit (HiRes mode - assume the low 8 bits are zeroed
> >>> + * in low-power mode(?) )
> >>> + * => +/-2G => 4 / 2^16 * 9,80665 * 10^6 (to scale to micro)
> >>> + * => +/-2G - 598.550415
> >>> + * +/-4G - 1197.10083
> >>> + * +/-8G - 2394.20166
> >>> + * +/-16G - 4788.40332
> >>> + */
> >>> +static const int kx022a_scale_table[][2] = {
> >>> + { 598, 550415 },
> >>> + { 1197, 100830 },
> >>> + { 2394, 201660 },
> >>> + { 4788, 403320 },
> >>> +};
> >>
> >> Given that the integer part is non-zero, and
> >> IIO_VAL_INT_PLUS_MICRO is returned for read_scale,
> >> As raw value will never be fractional how does this
> >> correspond to a reading of 9.8 m/s² for the Z-axis?
> >
> > Definitely suspicious as should be in m/s^2 for an acceleration and
> > it should be
> >
> > 9.8*16/2^bits
> >
> > So I think these are out by a factor of 10^6
> I think you are right. Looks like I misinterpreted the meaning of
> IIO_VAL_INT_PLUS_MICRO when I took my first tour in the IIO with this
> driver. The comment above the scale table does support that assumption
> ... 10^6 would match such a brainfart. (This is my first thought. I will
> take better look at this later today and see if I can come up with a fix
> if no-one else has sent a patch already).
>
> I CC'd Mehdi who has also been working on this driver.
>
> Regarding the KX022A - I am not aware of upstream users of this IC
> (yet). May be you're the first lucky one :) Hence, I am tempted to just
> fixing the driver - but it's Jonathan who will take the splatters when
> **** hits the fan - so it's his call to decide whether we can still fix
> this. _If_ there are users who have adapted to this buggy scale (users I
> am not aware of) then fix will break their apps. Mehdi, do you know any
> users of this upstream driver?
It's an ABI usage bug so allowed fix even if it has impacts...
Hopefully those aren't too painful for people to fix :(
So we fix and get it into stable asap.
>
> I will ping the HQ guy who has contacts to those who might be using the
> driver in a downstream repository and ask him to inform potential users.
>
> It'd be very nice to get this fixed.
>
> Sorry and thanks!
>
> Yours,
> -- Matti
>
next prev parent reply other threads:[~2023-10-19 11:12 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-24 12:37 [PATCH v5 0/3] iio: Support ROHM/Kionix kx022a Matti Vaittinen
2022-10-24 12:40 ` [PATCH v5 1/3] dt-bindings: iio: Add KX022A accelerometer Matti Vaittinen
2022-10-24 12:40 ` [PATCH v5 2/3] iio: accel: Support Kionix/ROHM " Matti Vaittinen
2022-10-24 12:54 ` Andy Shevchenko
2022-10-24 14:14 ` Matti Vaittinen
2022-10-29 14:18 ` Jonathan Cameron
2023-10-17 20:07 ` Jagath Jog J
2023-10-18 19:34 ` Jonathan Cameron
2023-10-19 5:53 ` Matti Vaittinen
2023-10-19 11:12 ` Jonathan Cameron [this message]
2022-10-24 12:40 ` [PATCH v5 3/3] MAINTAINERS: Add KX022A maintainer entry Matti Vaittinen
2022-10-29 14:20 ` Jonathan Cameron
2022-10-31 5:40 ` Vaittinen, Matti
2022-10-29 14:23 ` [PATCH v5 0/3] iio: Support ROHM/Kionix kx022a Jonathan Cameron
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=20231019121226.000078fe@Huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=DDRokosov@sberdevices.ru \
--cc=andriy.shevchenko@linux.intel.com \
--cc=demonsingur@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=jagathjog1996@gmail.com \
--cc=jic23@kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matti.vaittinen@fi.rohmeurope.com \
--cc=mazziesaccount@gmail.com \
--cc=mehdi.djait.k@gmail.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).