iio: magnetometer: ak8974: Correct realbits
authorLinus Walleij <linus.walleij@linaro.org>
Mon, 20 Apr 2020 20:40:20 +0000 (22:40 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 3 May 2020 08:47:22 +0000 (09:47 +0100)
commitb67959eba404a6a1a815bf725c0f76e5bc082f06
treef88976b0eb510c840044961bc8c233669ee035f8
parent525530af77594afff21cad063c9ac790d831ceb8
iio: magnetometer: ak8974: Correct realbits

The HSCDTD008A has 15 bits of actual ADC valie, 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.

Cc: Nick Reitemeyer <nick.reitemeyer@web.de>
Cc: Stephan Gerhold <stephan@gerhold.net>
Cc: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/magnetometer/ak8974.c