]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
iio: adc: at91_adc: correct default shtim value
authorAlexandre Belloni <alexandre.belloni@free-electrons.com>
Mon, 3 Mar 2014 18:07:00 +0000 (18:07 +0000)
committerJonathan Cameron <jic23@kernel.org>
Sat, 15 Mar 2014 16:32:44 +0000 (16:32 +0000)
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>
Acked-by: Josh Wu <josh.wu@atmel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/adc/at91_adc.c

index bbba014c9939909386777b1dcb327c2c5ccbbc9a..89777ed9abd858773b128c3a4d9fd6b34bdd9584 100644 (file)
@@ -1007,8 +1007,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;