]> www.infradead.org Git - users/dwmw2/linux.git/commit
iio: adc: aspeed: Add divider flag to fix incorrect voltage reading.
authorBilly Tsai <billy_tsai@aspeedtech.com>
Mon, 21 Feb 2022 01:27:05 +0000 (09:27 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 8 Apr 2022 11:57:15 +0000 (13:57 +0200)
commit65254652c312917854be9a1a5ec76b2d3ccb174c
tree924c43f42757427dad2800d179fd8af6ad16526b
parentd2d9ebdbff79d87d27652578e6d1638ad3b5f3bf
iio: adc: aspeed: Add divider flag to fix incorrect voltage reading.

commit 571426631acf46e2999c7ecd1e9d048172969a43 upstream.

The formula for the ADC sampling period in ast2400/ast2500 is:
ADC clock period = PCLK * 2 * (ADC0C[31:17] + 1) * (ADC0C[9:0])
When ADC0C[9:0] is set to 0 the sampling voltage will be lower than
expected, because the hardware may not have enough time to
charge/discharge to a stable voltage. This patch use the flag
CLK_DIVIDER_ONE_BASED which will use the raw value read from the
register, with the value of zero considered invalid to conform to the
corrected formula.

Fixes: 573803234e72 ("iio: Aspeed ADC")
Reported-by: Konstantin Klubnichkin <kitsok@yandex-team.ru>
Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Link: https://lore.kernel.org/r/20220221012705.22008-1-billy_tsai@aspeedtech.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/iio/adc/aspeed_adc.c