lkml.org 
[lkml]   [2020]   [Mar]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.4 062/102] iio: adc: at91-sama5d2_adc: fix differential channels in triggered mode
    Date
    From: Eugen Hristev <eugen.hristev@microchip.com>

    commit a500f3bd787f8224341e44b238f318c407b10897 upstream.

    The differential channels require writing the channel offset register (COR).
    Otherwise they do not work in differential mode.
    The configuration of COR is missing in triggered mode.

    Fixes: 5e1a1da0f8c9 ("iio: adc: at91-sama5d2_adc: add hw trigger and buffer support")
    Signed-off-by: Eugen Hristev <eugen.hristev@microchip.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/at91-sama5d2_adc.c | 15 +++++++++++++++
    1 file changed, 15 insertions(+)

    --- a/drivers/iio/adc/at91-sama5d2_adc.c
    +++ b/drivers/iio/adc/at91-sama5d2_adc.c
    @@ -723,6 +723,7 @@ static int at91_adc_configure_trigger(st

    for_each_set_bit(bit, indio->active_scan_mask, indio->num_channels) {
    struct iio_chan_spec const *chan = at91_adc_chan_get(indio, bit);
    + u32 cor;

    if (!chan)
    continue;
    @@ -732,6 +733,20 @@ static int at91_adc_configure_trigger(st
    continue;

    if (state) {
    + cor = at91_adc_readl(st, AT91_SAMA5D2_COR);
    +
    + if (chan->differential)
    + cor |= (BIT(chan->channel) |
    + BIT(chan->channel2)) <<
    + AT91_SAMA5D2_COR_DIFF_OFFSET;
    + else
    + cor &= ~(BIT(chan->channel) <<
    + AT91_SAMA5D2_COR_DIFF_OFFSET);
    +
    + at91_adc_writel(st, AT91_SAMA5D2_COR, cor);
    + }
    +
    + if (state) {
    at91_adc_writel(st, AT91_SAMA5D2_CHER,
    BIT(chan->channel));
    /* enable irq only if not using DMA */

    \
     
     \ /
      Last update: 2020-03-24 14:18    [W:4.085 / U:0.756 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site