aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/touchscreen/wm9712.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/touchscreen/wm9712.c')
-rw-r--r--drivers/input/touchscreen/wm9712.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/drivers/input/touchscreen/wm9712.c b/drivers/input/touchscreen/wm9712.c
index 2bc2fb801009..6e743e3dfda4 100644
--- a/drivers/input/touchscreen/wm9712.c
+++ b/drivers/input/touchscreen/wm9712.c
@@ -255,8 +255,9 @@ static inline int is_pden(struct wm97xx *wm)
255static int wm9712_poll_sample(struct wm97xx *wm, int adcsel, int *sample) 255static int wm9712_poll_sample(struct wm97xx *wm, int adcsel, int *sample)
256{ 256{
257 int timeout = 5 * delay; 257 int timeout = 5 * delay;
258 bool wants_pen = adcsel & WM97XX_PEN_DOWN;
258 259
259 if (!wm->pen_probably_down) { 260 if (wants_pen && !wm->pen_probably_down) {
260 u16 data = wm97xx_reg_read(wm, AC97_WM97XX_DIGITISER_RD); 261 u16 data = wm97xx_reg_read(wm, AC97_WM97XX_DIGITISER_RD);
261 if (!(data & WM97XX_PEN_DOWN)) 262 if (!(data & WM97XX_PEN_DOWN))
262 return RC_PENUP; 263 return RC_PENUP;
@@ -264,13 +265,10 @@ static int wm9712_poll_sample(struct wm97xx *wm, int adcsel, int *sample)
264 } 265 }
265 266
266 /* set up digitiser */ 267 /* set up digitiser */
267 if (adcsel & 0x8000)
268 adcsel = ((adcsel & 0x7fff) + 3) << 12;
269
270 if (wm->mach_ops && wm->mach_ops->pre_sample) 268 if (wm->mach_ops && wm->mach_ops->pre_sample)
271 wm->mach_ops->pre_sample(adcsel); 269 wm->mach_ops->pre_sample(adcsel);
272 wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER1, 270 wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER1, (adcsel & WM97XX_ADCSEL_MASK)
273 adcsel | WM97XX_POLL | WM97XX_DELAY(delay)); 271 | WM97XX_POLL | WM97XX_DELAY(delay));
274 272
275 /* wait 3 AC97 time slots + delay for conversion */ 273 /* wait 3 AC97 time slots + delay for conversion */
276 poll_delay(delay); 274 poll_delay(delay);
@@ -296,13 +294,14 @@ static int wm9712_poll_sample(struct wm97xx *wm, int adcsel, int *sample)
296 wm->mach_ops->post_sample(adcsel); 294 wm->mach_ops->post_sample(adcsel);
297 295
298 /* check we have correct sample */ 296 /* check we have correct sample */
299 if ((*sample & WM97XX_ADCSEL_MASK) != adcsel) { 297 if ((*sample ^ adcsel) & WM97XX_ADCSEL_MASK) {
300 dev_dbg(wm->dev, "adc wrong sample, read %x got %x", adcsel, 298 dev_dbg(wm->dev, "adc wrong sample, wanted %x got %x",
301 *sample & WM97XX_ADCSEL_MASK); 299 adcsel & WM97XX_ADCSEL_MASK,
300 *sample & WM97XX_ADCSEL_MASK);
302 return RC_PENUP; 301 return RC_PENUP;
303 } 302 }
304 303
305 if (!(*sample & WM97XX_PEN_DOWN)) { 304 if (wants_pen && !(*sample & WM97XX_PEN_DOWN)) {
306 wm->pen_probably_down = 0; 305 wm->pen_probably_down = 0;
307 return RC_PENUP; 306 return RC_PENUP;
308 } 307 }
@@ -387,16 +386,18 @@ static int wm9712_poll_touch(struct wm97xx *wm, struct wm97xx_data *data)
387 if (rc != RC_VALID) 386 if (rc != RC_VALID)
388 return rc; 387 return rc;
389 } else { 388 } else {
390 rc = wm9712_poll_sample(wm, WM97XX_ADCSEL_X, &data->x); 389 rc = wm9712_poll_sample(wm, WM97XX_ADCSEL_X | WM97XX_PEN_DOWN,
390 &data->x);
391 if (rc != RC_VALID) 391 if (rc != RC_VALID)
392 return rc; 392 return rc;
393 393
394 rc = wm9712_poll_sample(wm, WM97XX_ADCSEL_Y, &data->y); 394 rc = wm9712_poll_sample(wm, WM97XX_ADCSEL_Y | WM97XX_PEN_DOWN,
395 &data->y);
395 if (rc != RC_VALID) 396 if (rc != RC_VALID)
396 return rc; 397 return rc;
397 398
398 if (pil && !five_wire) { 399 if (pil && !five_wire) {
399 rc = wm9712_poll_sample(wm, WM97XX_ADCSEL_PRES, 400 rc = wm9712_poll_sample(wm, WM97XX_ADCSEL_PRES | WM97XX_PEN_DOWN,
400 &data->p); 401 &data->p);
401 if (rc != RC_VALID) 402 if (rc != RC_VALID)
402 return rc; 403 return rc;