* [PATCH] iio: adc: at91_adc: correct default shtim value
@ 2014-03-03 18:07 Alexandre Belloni
2014-03-05 11:04 ` Josh Wu
0 siblings, 1 reply; 4+ messages in thread
From: Alexandre Belloni @ 2014-03-03 18:07 UTC (permalink / raw)
To: Jonathan Cameron
Cc: linux-kernel, linux-iio, Maxime Ripard, Josh Wu,
Ludovic Desroches, Alexandre Belloni
When sample_hold_time is zero (this is the case when DT is not used or if
atmel,adc-sample-hold-time is omitted), then the calculated shtim is large.
Make that 0, which is the default for that register and the ADC will then use a
sane value of 2/ADCCLK or 1/ADCCLK depending on the version.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
drivers/iio/adc/at91_adc.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index 5b1aa027c034..0b103f905607 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -1004,8 +1004,11 @@ static int at91_adc_probe(struct platform_device *pdev)
* the best converted final value between two channels selection
* The formula thus is : Sample and Hold Time = (shtim + 1) / ADCClock
*/
- shtim = round_up((st->sample_hold_time * adc_clk_khz /
- 1000) - 1, 1);
+ if (st->sample_hold_time > 0)
+ shtim = round_up((st->sample_hold_time * adc_clk_khz / 1000)
+ - 1, 1);
+ else
+ shtim = 0;
reg = AT91_ADC_PRESCAL_(prsc) & st->registers->mr_prescal_mask;
reg |= AT91_ADC_STARTUP_(ticks) & st->registers->mr_startup_mask;
--
1.8.3.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] iio: adc: at91_adc: correct default shtim value
2014-03-03 18:07 [PATCH] iio: adc: at91_adc: correct default shtim value Alexandre Belloni
@ 2014-03-05 11:04 ` Josh Wu
2014-03-15 16:34 ` Jonathan Cameron
0 siblings, 1 reply; 4+ messages in thread
From: Josh Wu @ 2014-03-05 11:04 UTC (permalink / raw)
To: Alexandre Belloni, Jonathan Cameron
Cc: linux-kernel, linux-iio, Maxime Ripard, Ludovic Desroches
Hi, Alexandre
On 3/4/2014 2:07 AM, Alexandre Belloni wrote:
> When sample_hold_time is zero (this is the case when DT is not used or if
> atmel,adc-sample-hold-time is omitted), then the calculated shtim is large.
>
> Make that 0, which is the default for that register and the ADC will then use a
> sane value of 2/ADCCLK or 1/ADCCLK depending on the version.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Thanks for the fix and
Acked-by: Josh Wu<josh.wu@atmel.com>
Best Regards,
Josh Wu
> ---
> drivers/iio/adc/at91_adc.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
> index 5b1aa027c034..0b103f905607 100644
> --- a/drivers/iio/adc/at91_adc.c
> +++ b/drivers/iio/adc/at91_adc.c
> @@ -1004,8 +1004,11 @@ static int at91_adc_probe(struct platform_device *pdev)
> * the best converted final value between two channels selection
> * The formula thus is : Sample and Hold Time = (shtim + 1) / ADCClock
> */
> - shtim = round_up((st->sample_hold_time * adc_clk_khz /
> - 1000) - 1, 1);
> + if (st->sample_hold_time > 0)
> + shtim = round_up((st->sample_hold_time * adc_clk_khz / 1000)
> + - 1, 1);
> + else
> + shtim = 0;
>
> reg = AT91_ADC_PRESCAL_(prsc) & st->registers->mr_prescal_mask;
> reg |= AT91_ADC_STARTUP_(ticks) & st->registers->mr_startup_mask;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iio: adc: at91_adc: correct default shtim value
2014-03-05 11:04 ` Josh Wu
@ 2014-03-15 16:34 ` Jonathan Cameron
2014-03-15 21:21 ` Alexandre Belloni
0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Cameron @ 2014-03-15 16:34 UTC (permalink / raw)
To: Josh Wu, Alexandre Belloni
Cc: linux-kernel, linux-iio, Maxime Ripard, Ludovic Desroches
On 05/03/14 11:04, Josh Wu wrote:
> Hi, Alexandre
>
> On 3/4/2014 2:07 AM, Alexandre Belloni wrote:
>> When sample_hold_time is zero (this is the case when DT is not used or if
>> atmel,adc-sample-hold-time is omitted), then the calculated shtim is large.
>>
>> Make that 0, which is the default for that register and the ADC will then use a
>> sane value of 2/ADCCLK or 1/ADCCLK depending on the version.
>>
>> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
>
> Thanks for the fix and
>
> Acked-by: Josh Wu<josh.wu@atmel.com>
>
Applied to the fixes-togreg branch of iio.git.
Note that is likely that this will go upstream after the merge window now.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iio: adc: at91_adc: correct default shtim value
2014-03-15 16:34 ` Jonathan Cameron
@ 2014-03-15 21:21 ` Alexandre Belloni
0 siblings, 0 replies; 4+ messages in thread
From: Alexandre Belloni @ 2014-03-15 21:21 UTC (permalink / raw)
To: Jonathan Cameron
Cc: Josh Wu, linux-kernel, linux-iio, Maxime Ripard,
Ludovic Desroches
Hi,
On 15/03/2014 at 16:34:02 +0000, Jonathan Cameron wrote :
> Applied to the fixes-togreg branch of iio.git.
> Note that is likely that this will go upstream after the merge window now.
>
I was aiming at 3.15 anyway.
Thanks for you help !
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-03-15 21:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-03 18:07 [PATCH] iio: adc: at91_adc: correct default shtim value Alexandre Belloni
2014-03-05 11:04 ` Josh Wu
2014-03-15 16:34 ` Jonathan Cameron
2014-03-15 21:21 ` Alexandre Belloni
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).