diff options
| author | Robert Hodaszi <robert.hodaszi@digi.com> | 2014-10-06 09:41:00 -0400 |
|---|---|---|
| committer | Jonathan Cameron <jic23@kernel.org> | 2014-06-14 10:01:20 -0400 |
| commit | 19bc4981a213d0c5b0e1e8b08815c0b26f01ec54 (patch) | |
| tree | 18bc6729e9190cf0536f20b8eed04133c9515ea5 | |
| parent | 8ba42fb7b17649c9ab5b5e79d4e90370a0b4645e (diff) | |
iio: mxs-lradc: fix divider
All channels' single measurement are happening on CH 0. So enabling / disabling
the divider once is not enough, because it has impact on all channels.
Set only a flag, then check this on each measurement, and enable / disable the
divider as required.
Signed-off-by: Robert Hodaszi <robert.hodaszi@digi.com>
Cc: Stable@vger.kernel.org
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Marek Vasut <marex@denx.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
| -rw-r--r-- | drivers/staging/iio/adc/mxs-lradc.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c index dae8d1a9038e..52d7517b342e 100644 --- a/drivers/staging/iio/adc/mxs-lradc.c +++ b/drivers/staging/iio/adc/mxs-lradc.c | |||
| @@ -846,6 +846,14 @@ static int mxs_lradc_read_single(struct iio_dev *iio_dev, int chan, int *val) | |||
| 846 | LRADC_CTRL1); | 846 | LRADC_CTRL1); |
| 847 | mxs_lradc_reg_clear(lradc, 0xff, LRADC_CTRL0); | 847 | mxs_lradc_reg_clear(lradc, 0xff, LRADC_CTRL0); |
| 848 | 848 | ||
| 849 | /* Enable / disable the divider per requirement */ | ||
| 850 | if (test_bit(chan, &lradc->is_divided)) | ||
| 851 | mxs_lradc_reg_set(lradc, 1 << LRADC_CTRL2_DIVIDE_BY_TWO_OFFSET, | ||
| 852 | LRADC_CTRL2); | ||
| 853 | else | ||
| 854 | mxs_lradc_reg_clear(lradc, | ||
| 855 | 1 << LRADC_CTRL2_DIVIDE_BY_TWO_OFFSET, LRADC_CTRL2); | ||
| 856 | |||
| 849 | /* Clean the slot's previous content, then set new one. */ | 857 | /* Clean the slot's previous content, then set new one. */ |
| 850 | mxs_lradc_reg_clear(lradc, LRADC_CTRL4_LRADCSELECT_MASK(0), | 858 | mxs_lradc_reg_clear(lradc, LRADC_CTRL4_LRADCSELECT_MASK(0), |
| 851 | LRADC_CTRL4); | 859 | LRADC_CTRL4); |
| @@ -961,15 +969,11 @@ static int mxs_lradc_write_raw(struct iio_dev *iio_dev, | |||
| 961 | if (val == scale_avail[MXS_LRADC_DIV_DISABLED].integer && | 969 | if (val == scale_avail[MXS_LRADC_DIV_DISABLED].integer && |
| 962 | val2 == scale_avail[MXS_LRADC_DIV_DISABLED].nano) { | 970 | val2 == scale_avail[MXS_LRADC_DIV_DISABLED].nano) { |
| 963 | /* divider by two disabled */ | 971 | /* divider by two disabled */ |
| 964 | writel(1 << LRADC_CTRL2_DIVIDE_BY_TWO_OFFSET, | ||
| 965 | lradc->base + LRADC_CTRL2 + STMP_OFFSET_REG_CLR); | ||
| 966 | clear_bit(chan->channel, &lradc->is_divided); | 972 | clear_bit(chan->channel, &lradc->is_divided); |
| 967 | ret = 0; | 973 | ret = 0; |
| 968 | } else if (val == scale_avail[MXS_LRADC_DIV_ENABLED].integer && | 974 | } else if (val == scale_avail[MXS_LRADC_DIV_ENABLED].integer && |
| 969 | val2 == scale_avail[MXS_LRADC_DIV_ENABLED].nano) { | 975 | val2 == scale_avail[MXS_LRADC_DIV_ENABLED].nano) { |
| 970 | /* divider by two enabled */ | 976 | /* divider by two enabled */ |
| 971 | writel(1 << LRADC_CTRL2_DIVIDE_BY_TWO_OFFSET, | ||
| 972 | lradc->base + LRADC_CTRL2 + STMP_OFFSET_REG_SET); | ||
| 973 | set_bit(chan->channel, &lradc->is_divided); | 977 | set_bit(chan->channel, &lradc->is_divided); |
| 974 | ret = 0; | 978 | ret = 0; |
| 975 | } | 979 | } |
