aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLudovic Desroches <ludovic.desroches@atmel.com>2014-10-09 10:02:00 -0400
committerJonathan Cameron <jic23@kernel.org>2014-09-14 13:20:12 -0400
commitd4f51956ac8ad302db9b0c4e4232775b1baa7b44 (patch)
tree453386d572137d274883a716658f25fc114a7610
parent1887e724e2b6df06847522fe9dc2ab53639516cc (diff)
iio: adc: at91: don't use the last converted data register
If touchscreen mode is enabled and a conversion is requested on another channel, the result in the last converted data register can be a touchscreen relative value. Starting a conversion involves to do a conversion for all active channel. It starts with ADC channels and ends with touchscreen channels. Then if ADC_LCD register is not read quickly, its content may be a touchscreen conversion. To remove this temporal constraint, the conversion value is taken from the channel data register. Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com> Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com> Cc: Stable@vger.kernel.org Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r--drivers/iio/adc/at91_adc.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index 772e869c280e..7eadaf16adc1 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -196,6 +196,7 @@ struct at91_adc_state {
196 bool done; 196 bool done;
197 int irq; 197 int irq;
198 u16 last_value; 198 u16 last_value;
199 int chnb;
199 struct mutex lock; 200 struct mutex lock;
200 u8 num_channels; 201 u8 num_channels;
201 void __iomem *reg_base; 202 void __iomem *reg_base;
@@ -274,7 +275,7 @@ void handle_adc_eoc_trigger(int irq, struct iio_dev *idev)
274 disable_irq_nosync(irq); 275 disable_irq_nosync(irq);
275 iio_trigger_poll(idev->trig); 276 iio_trigger_poll(idev->trig);
276 } else { 277 } else {
277 st->last_value = at91_adc_readl(st, AT91_ADC_LCDR); 278 st->last_value = at91_adc_readl(st, AT91_ADC_CHAN(st, st->chnb));
278 st->done = true; 279 st->done = true;
279 wake_up_interruptible(&st->wq_data_avail); 280 wake_up_interruptible(&st->wq_data_avail);
280 } 281 }
@@ -351,7 +352,7 @@ static irqreturn_t at91_adc_rl_interrupt(int irq, void *private)
351 unsigned int reg; 352 unsigned int reg;
352 353
353 status &= at91_adc_readl(st, AT91_ADC_IMR); 354 status &= at91_adc_readl(st, AT91_ADC_IMR);
354 if (status & st->registers->drdy_mask) 355 if (status & GENMASK(st->num_channels - 1, 0))
355 handle_adc_eoc_trigger(irq, idev); 356 handle_adc_eoc_trigger(irq, idev);
356 357
357 if (status & AT91RL_ADC_IER_PEN) { 358 if (status & AT91RL_ADC_IER_PEN) {
@@ -418,7 +419,7 @@ static irqreturn_t at91_adc_9x5_interrupt(int irq, void *private)
418 AT91_ADC_IER_YRDY | 419 AT91_ADC_IER_YRDY |
419 AT91_ADC_IER_PRDY; 420 AT91_ADC_IER_PRDY;
420 421
421 if (status & st->registers->drdy_mask) 422 if (status & GENMASK(st->num_channels - 1, 0))
422 handle_adc_eoc_trigger(irq, idev); 423 handle_adc_eoc_trigger(irq, idev);
423 424
424 if (status & AT91_ADC_IER_PEN) { 425 if (status & AT91_ADC_IER_PEN) {
@@ -689,9 +690,10 @@ static int at91_adc_read_raw(struct iio_dev *idev,
689 case IIO_CHAN_INFO_RAW: 690 case IIO_CHAN_INFO_RAW:
690 mutex_lock(&st->lock); 691 mutex_lock(&st->lock);
691 692
693 st->chnb = chan->channel;
692 at91_adc_writel(st, AT91_ADC_CHER, 694 at91_adc_writel(st, AT91_ADC_CHER,
693 AT91_ADC_CH(chan->channel)); 695 AT91_ADC_CH(chan->channel));
694 at91_adc_writel(st, AT91_ADC_IER, st->registers->drdy_mask); 696 at91_adc_writel(st, AT91_ADC_IER, BIT(chan->channel));
695 at91_adc_writel(st, AT91_ADC_CR, AT91_ADC_START); 697 at91_adc_writel(st, AT91_ADC_CR, AT91_ADC_START);
696 698
697 ret = wait_event_interruptible_timeout(st->wq_data_avail, 699 ret = wait_event_interruptible_timeout(st->wq_data_avail,
@@ -708,7 +710,7 @@ static int at91_adc_read_raw(struct iio_dev *idev,
708 710
709 at91_adc_writel(st, AT91_ADC_CHDR, 711 at91_adc_writel(st, AT91_ADC_CHDR,
710 AT91_ADC_CH(chan->channel)); 712 AT91_ADC_CH(chan->channel));
711 at91_adc_writel(st, AT91_ADC_IDR, st->registers->drdy_mask); 713 at91_adc_writel(st, AT91_ADC_IDR, BIT(chan->channel));
712 714
713 st->last_value = 0; 715 st->last_value = 0;
714 st->done = false; 716 st->done = false;