• Linus Walleij's avatar
    iio: magnetometer: ak8974: Correct realbits · b67959eb
    Linus Walleij authored
    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: default avatarLinus Walleij <linus.walleij@linaro.org>
    Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
    b67959eb
ak8974.c 25.3 KB