From: Jonathan Cameron <jic23@kernel.org>
To: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
Cc: Linus Walleij <linus.walleij@linaro.org>,
linux-iio@vger.kernel.org, Hartmut Knaack <knaack.h@gmx.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
linux-input@vger.kernel.org,
Nick Reitemeyer <nick.reitemeyer@web.de>,
Stephan Gerhold <stephan@gerhold.net>
Subject: Re: [PATCH 1/3 v3] iio: magnetometer: ak8974: Correct realbits
Date: Sat, 18 Apr 2020 15:30:02 +0100 [thread overview]
Message-ID: <20200418153002.62626a88@archlinux> (raw)
In-Reply-To: <20200417140521.GB18337@qmqm.qmqm.pl>
On Fri, 17 Apr 2020 16:05:21 +0200
Michał Mirosław <mirq-linux@rere.qmqm.pl> wrote:
> On Fri, Apr 17, 2020 at 01:40:18PM +0200, Linus Walleij wrote:
> > The original AK8974 has 16 bits of actual value, while the
> > HSCDTD008A has 15 bits and the AMI305 and AMI306 has 12 bits.
> > Correct this by providing an extra parameter to the channel
> > macro and define a separate set of channels for each variant
> > of the chip. The resolution is the actual resolution of the
> > internal ADC of the chip.
> >
> > The values are stored in a S16 in 2's complement so all 16
> > bits are used for storing (no shifting needed).
> >
> > The AMI305, AMI306 and HSCDTD008A valid bits are picked from
> > respective datasheet.
> >
> > My best educated guess is that AK8974 is also 12 bits. The
> > AK8973 is an 8 bit and earlier version, and the sibling
> > drivers AMI305 and AMI306 are 12 bits, so it makes sense
> > to assume that the AK8974 is also 12 bits.
> [...]
> > -#define AK8974_AXIS_CHANNEL(axis, index) \
> > +#define AK8974_AXIS_CHANNEL(axis, index, bits) \
> > { \
> > .type = IIO_MAGN, \
> > .modified = 1, \
> > @@ -662,16 +662,42 @@ static const struct iio_chan_spec_ext_info ak8974_ext_info[] = {
> > .scan_index = index, \
> > .scan_type = { \
> > .sign = 's', \
> > - .realbits = 16, \
> > + .realbits = bits, \
> > .storagebits = 16, \
> > .endianness = IIO_LE \
> > }, \
> > }
> >
> > +/*
> > + * We have no datasheet for the AK8974 but we guess that its
> > + * ADC is 12 bits.
> > + */
> > static const struct iio_chan_spec ak8974_channels[] = {
> > - AK8974_AXIS_CHANNEL(X, 0),
> > - AK8974_AXIS_CHANNEL(Y, 1),
> > - AK8974_AXIS_CHANNEL(Z, 2),
> > + AK8974_AXIS_CHANNEL(X, 0, 12),
> > + AK8974_AXIS_CHANNEL(Y, 1, 12),
> > + AK8974_AXIS_CHANNEL(Z, 2, 12),
> > + IIO_CHAN_SOFT_TIMESTAMP(3),
> > +};
> > +
> > +/*
> > + * The AMI305 and AMI306 have 12 bit ADC resolution according to
> > + * datasheets.
> > + */
> > +static const struct iio_chan_spec ami30x_channels[] = {
> > + AK8974_AXIS_CHANNEL(X, 0, 12),
> > + AK8974_AXIS_CHANNEL(Y, 1, 12),
> > + AK8974_AXIS_CHANNEL(Z, 2, 12),
> > + IIO_CHAN_SOFT_TIMESTAMP(3),
> > +};
>
> Maybe call it channels_12bit[] and then you wouldn't need to make
> am exact duplicate for ak8974?
Agreed they should be combined. I've not problem with just picking
one device name though on a first come first named basis...
Up to you.
Jonathan
>
> Best Regards,
> Michał Mirosław
prev parent reply other threads:[~2020-04-18 14:30 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-17 11:40 [PATCH 1/3 v3] iio: magnetometer: ak8974: Correct realbits Linus Walleij
2020-04-17 11:40 ` [PATCH 2/3 v3] iio: magnetometer: ak8974: Break out measurement Linus Walleij
2020-04-17 13:17 ` Andy Shevchenko
2020-04-17 14:02 ` Michał Mirosław
2020-04-17 11:40 ` [PATCH 3/3 v3] iio: magnetometer: ak8974: Provide scaling Linus Walleij
2020-04-17 14:11 ` Michał Mirosław
2020-04-17 14:05 ` [PATCH 1/3 v3] iio: magnetometer: ak8974: Correct realbits Michał Mirosław
2020-04-18 14:30 ` 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=20200418153002.62626a88@archlinux \
--to=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linus.walleij@linaro.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=mirq-linux@rere.qmqm.pl \
--cc=nick.reitemeyer@web.de \
--cc=pmeerw@pmeerw.net \
--cc=stephan@gerhold.net \
/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).