From: Jonathan Cameron <jic23@kernel.org>
To: Billy Tsai <billy_tsai@aspeedtech.com>
Cc: <lars@metafoo.de>, <joel@jms.id.au>, <andrew@aj.id.au>,
<colin.king@canonical.com>, <linux-iio@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-aspeed@lists.ozlabs.org>, <linux-kernel@vger.kernel.org>,
Konstantin Klubnichkin <kitsok@yandex-team.ru>
Subject: Re: [PATCH] iio: adc: aspeed: Add divider flag to fix incorrect voltage reading.
Date: Sat, 19 Feb 2022 16:00:02 +0000 [thread overview]
Message-ID: <20220219160002.46e301b8@jic23-huawei> (raw)
In-Reply-To: <20220218085708.8194-1-billy_tsai@aspeedtech.com>
On Fri, 18 Feb 2022 16:57:08 +0800
Billy Tsai <billy_tsai@aspeedtech.com> wrote:
> 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.
>
> Reported-by: Konstantin Klubnichkin <kitsok@yandex-team.ru>
> Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com>
Hi Billy,
Fixes tag?
Also, would be good to call out in the patch description that
CLK_DIVIDER_ONE_BASED rules at 0 as a valid value and hence
avoids the ADC0C[9:0] value of 0 that is causing problems.
That may be obvious to people who make frequent use of clk dividers
but it's not locally obvious when looking at this patch.
Otherwise looks good to me.
Thanks,
Jonathan
> ---
> drivers/iio/adc/aspeed_adc.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/adc/aspeed_adc.c b/drivers/iio/adc/aspeed_adc.c
> index a957cad1bfab..ffae64f39221 100644
> --- a/drivers/iio/adc/aspeed_adc.c
> +++ b/drivers/iio/adc/aspeed_adc.c
> @@ -539,7 +539,9 @@ static int aspeed_adc_probe(struct platform_device *pdev)
> data->clk_scaler = devm_clk_hw_register_divider(
> &pdev->dev, clk_name, clk_parent_name, scaler_flags,
> data->base + ASPEED_REG_CLOCK_CONTROL, 0,
> - data->model_data->scaler_bit_width, 0, &data->clk_lock);
> + data->model_data->scaler_bit_width,
> + data->model_data->need_prescaler ? CLK_DIVIDER_ONE_BASED : 0,
> + &data->clk_lock);
> if (IS_ERR(data->clk_scaler))
> return PTR_ERR(data->clk_scaler);
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-02-19 15:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-18 8:57 [PATCH] iio: adc: aspeed: Add divider flag to fix incorrect voltage reading Billy Tsai
2022-02-19 16:00 ` Jonathan Cameron [this message]
2022-02-21 0:47 ` Billy Tsai
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=20220219160002.46e301b8@jic23-huawei \
--to=jic23@kernel.org \
--cc=andrew@aj.id.au \
--cc=billy_tsai@aspeedtech.com \
--cc=colin.king@canonical.com \
--cc=joel@jms.id.au \
--cc=kitsok@yandex-team.ru \
--cc=lars@metafoo.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-aspeed@lists.ozlabs.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.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