Skip to content

Commit 1322dc3

Browse files
kristina-martsenkosashalevin
authored andcommitted
iio: mxs-lradc: make ADC reads not disable touchscreen interrupts
commit 86bf7f3 upstream. Reading a channel through sysfs, or starting a buffered capture, will currently turn off the touchscreen. This is because the read_raw() and buffer preenable()/postdisable() callbacks disable interrupts for all LRADC channels, including those the touchscreen uses. So make the callbacks only disable interrupts for the channels they use. This means channel 0 for read_raw() and channels 0-5 for the buffer (if the touchscreen is enabled). Since the touchscreen uses different channels (6 and 7), it no longer gets turned off. Note that only i.MX28 is affected by this issue, i.MX23 should be fine. Signed-off-by: Kristina Martšenko <kristina.martsenko@gmail.com> Reviewed-by: Marek Vasut <marex@denx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
1 parent 567a6d5 commit 1322dc3

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

‎drivers/staging/iio/adc/mxs-lradc.c‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,9 @@ struct mxs_lradc {
220220
*/
221221
#define TOUCHSCREEN_VCHANNEL1 7
222222
#define TOUCHSCREEN_VCHANNEL2 6
223+
#define BUFFER_VCHANS_LIMITED 0x3f
224+
#define BUFFER_VCHANS_ALL 0xff
225+
u8 buffer_vchans;
223226

224227
/*
225228
* Furthermore, certain LRADC channels are shared between touchscreen
@@ -817,7 +820,7 @@ static int mxs_lradc_read_single(struct iio_dev *iio_dev, int chan, int *val)
817820
* used if doing raw sampling.
818821
*/
819822
if (lradc->soc == IMX28_LRADC)
820-
mxs_lradc_reg_clear(lradc, LRADC_CTRL1_MX28_LRADC_IRQ_EN_MASK,
823+
mxs_lradc_reg_clear(lradc, LRADC_CTRL1_LRADC_IRQ_EN(0),
821824
LRADC_CTRL1);
822825
mxs_lradc_reg_clear(lradc, 0xff, LRADC_CTRL0);
823826

@@ -1264,8 +1267,9 @@ static int mxs_lradc_buffer_preenable(struct iio_dev *iio)
12641267
}
12651268

12661269
if (lradc->soc == IMX28_LRADC)
1267-
mxs_lradc_reg_clear(lradc, LRADC_CTRL1_MX28_LRADC_IRQ_EN_MASK,
1268-
LRADC_CTRL1);
1270+
mxs_lradc_reg_clear(lradc,
1271+
lradc->buffer_vchans << LRADC_CTRL1_LRADC_IRQ_EN_OFFSET,
1272+
LRADC_CTRL1);
12691273
mxs_lradc_reg_clear(lradc, 0xff, LRADC_CTRL0);
12701274

12711275
for_each_set_bit(chan, iio->active_scan_mask, LRADC_MAX_TOTAL_CHANS) {
@@ -1301,8 +1305,9 @@ static int mxs_lradc_buffer_postdisable(struct iio_dev *iio)
13011305

13021306
mxs_lradc_reg_clear(lradc, 0xff, LRADC_CTRL0);
13031307
if (lradc->soc == IMX28_LRADC)
1304-
mxs_lradc_reg_clear(lradc, LRADC_CTRL1_MX28_LRADC_IRQ_EN_MASK,
1305-
LRADC_CTRL1);
1308+
mxs_lradc_reg_clear(lradc,
1309+
lradc->buffer_vchans << LRADC_CTRL1_LRADC_IRQ_EN_OFFSET,
1310+
LRADC_CTRL1);
13061311

13071312
kfree(lradc->buffer);
13081313
mutex_unlock(&lradc->lock);
@@ -1547,6 +1552,11 @@ static int mxs_lradc_probe(struct platform_device *pdev)
15471552

15481553
touch_ret = mxs_lradc_probe_touchscreen(lradc, node);
15491554

1555+
if (touch_ret == 0)
1556+
lradc->buffer_vchans = BUFFER_VCHANS_LIMITED;
1557+
else
1558+
lradc->buffer_vchans = BUFFER_VCHANS_ALL;
1559+
15501560
/* Grab all IRQ sources */
15511561
for (i = 0; i < of_cfg->irq_count; i++) {
15521562
lradc->irq[i] = platform_get_irq(pdev, i);

0 commit comments

Comments
 (0)