Skip to content

Commit f0933a6

Browse files
Jeff LanceLee Jones
authored andcommitted
mfd: ti_am335x_tscadc: Update logic in CTRL register for 5-wire TS
The logic in AFE_Pen_Ctrl bitmask in the CTRL register is different for five wire versus four or eight wire touschscreens. This patch should fix this for five-wire touch screens. There should be no change needed here for four and eight wire tousch screens. Signed-off-by: Jeff Lance <j-lance1@ti.com> [bigeasy: keep the change mfd only] Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Lee Jones <lee.jones@linaro.org>
1 parent 92b8f3a commit f0933a6

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

drivers/mfd/ti_am335x_tscadc.c

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -242,18 +242,20 @@ static int ti_tscadc_probe(struct platform_device *pdev)
242242
tscadc_writel(tscadc, REG_CLKDIV, tscadc->clk_div);
243243

244244
/* Set the control register bits */
245-
ctrl = CNTRLREG_STEPCONFIGWRT |
246-
CNTRLREG_STEPID;
247-
if (tsc_wires > 0)
248-
ctrl |= CNTRLREG_4WIRE | CNTRLREG_TSCENB;
245+
ctrl = CNTRLREG_STEPCONFIGWRT | CNTRLREG_STEPID;
249246
tscadc_writel(tscadc, REG_CTRL, ctrl);
250247

251248
/* Set register bits for Idle Config Mode */
252-
if (tsc_wires > 0)
249+
if (tsc_wires > 0) {
250+
tscadc->tsc_wires = tsc_wires;
251+
if (tsc_wires == 5)
252+
ctrl |= CNTRLREG_5WIRE | CNTRLREG_TSCENB;
253+
else
254+
ctrl |= CNTRLREG_4WIRE | CNTRLREG_TSCENB;
253255
tscadc_idle_config(tscadc);
256+
}
254257

255258
/* Enable the TSC module enable bit */
256-
ctrl = tscadc_readl(tscadc, REG_CTRL);
257259
ctrl |= CNTRLREG_TSCSSENB;
258260
tscadc_writel(tscadc, REG_CTRL, ctrl);
259261

@@ -325,21 +327,23 @@ static int tscadc_suspend(struct device *dev)
325327
static int tscadc_resume(struct device *dev)
326328
{
327329
struct ti_tscadc_dev *tscadc_dev = dev_get_drvdata(dev);
328-
unsigned int restore, ctrl;
330+
u32 ctrl;
329331

330332
pm_runtime_get_sync(dev);
331333

332334
/* context restore */
333335
ctrl = CNTRLREG_STEPCONFIGWRT | CNTRLREG_STEPID;
334-
if (tscadc_dev->tsc_cell != -1)
335-
ctrl |= CNTRLREG_TSCENB | CNTRLREG_4WIRE;
336336
tscadc_writel(tscadc_dev, REG_CTRL, ctrl);
337337

338-
if (tscadc_dev->tsc_cell != -1)
338+
if (tscadc_dev->tsc_cell != -1) {
339+
if (tscadc_dev->tsc_wires == 5)
340+
ctrl |= CNTRLREG_5WIRE | CNTRLREG_TSCENB;
341+
else
342+
ctrl |= CNTRLREG_4WIRE | CNTRLREG_TSCENB;
339343
tscadc_idle_config(tscadc_dev);
340-
restore = tscadc_readl(tscadc_dev, REG_CTRL);
341-
tscadc_writel(tscadc_dev, REG_CTRL,
342-
(restore | CNTRLREG_TSCSSENB));
344+
}
345+
ctrl |= CNTRLREG_TSCSSENB;
346+
tscadc_writel(tscadc_dev, REG_CTRL, ctrl);
343347

344348
tscadc_writel(tscadc_dev, REG_CLKDIV, tscadc_dev->clk_div);
345349

include/linux/mfd/ti_am335x_tscadc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ struct ti_tscadc_dev {
155155
void __iomem *tscadc_base;
156156
int irq;
157157
int used_cells; /* 1-2 */
158+
int tsc_wires;
158159
int tsc_cell; /* -1 if not used */
159160
int adc_cell; /* -1 if not used */
160161
struct mfd_cell cells[TSCADC_CELLS];

0 commit comments

Comments
 (0)