aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/touchscreen/wm9705.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/touchscreen/wm9705.c')
-rw-r--r--drivers/input/touchscreen/wm9705.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/drivers/input/touchscreen/wm9705.c b/drivers/input/touchscreen/wm9705.c
index 98e61175d3f5..adc13a523ab5 100644
--- a/drivers/input/touchscreen/wm9705.c
+++ b/drivers/input/touchscreen/wm9705.c
@@ -215,8 +215,9 @@ static inline int is_pden(struct wm97xx *wm)
215static int wm9705_poll_sample(struct wm97xx *wm, int adcsel, int *sample) 215static int wm9705_poll_sample(struct wm97xx *wm, int adcsel, int *sample)
216{ 216{
217 int timeout = 5 * delay; 217 int timeout = 5 * delay;
218 bool wants_pen = adcsel & WM97XX_PEN_DOWN;
218 219
219 if (!wm->pen_probably_down) { 220 if (wants_pen && !wm->pen_probably_down) {
220 u16 data = wm97xx_reg_read(wm, AC97_WM97XX_DIGITISER_RD); 221 u16 data = wm97xx_reg_read(wm, AC97_WM97XX_DIGITISER_RD);
221 if (!(data & WM97XX_PEN_DOWN)) 222 if (!(data & WM97XX_PEN_DOWN))
222 return RC_PENUP; 223 return RC_PENUP;
@@ -224,13 +225,10 @@ static int wm9705_poll_sample(struct wm97xx *wm, int adcsel, int *sample)
224 } 225 }
225 226
226 /* set up digitiser */ 227 /* set up digitiser */
227 if (adcsel & 0x8000)
228 adcsel = ((adcsel & 0x7fff) + 3) << 12;
229
230 if (wm->mach_ops && wm->mach_ops->pre_sample) 228 if (wm->mach_ops && wm->mach_ops->pre_sample)
231 wm->mach_ops->pre_sample(adcsel); 229 wm->mach_ops->pre_sample(adcsel);
232 wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER1, 230 wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER1, (adcsel & WM97XX_ADCSEL_MASK)
233 adcsel | WM97XX_POLL | WM97XX_DELAY(delay)); 231 | WM97XX_POLL | WM97XX_DELAY(delay));
234 232
235 /* wait 3 AC97 time slots + delay for conversion */ 233 /* wait 3 AC97 time slots + delay for conversion */
236 poll_delay(delay); 234 poll_delay(delay);
@@ -256,13 +254,14 @@ static int wm9705_poll_sample(struct wm97xx *wm, int adcsel, int *sample)
256 wm->mach_ops->post_sample(adcsel); 254 wm->mach_ops->post_sample(adcsel);
257 255
258 /* check we have correct sample */ 256 /* check we have correct sample */
259 if ((*sample & WM97XX_ADCSEL_MASK) != adcsel) { 257 if ((*sample ^ adcsel) & WM97XX_ADCSEL_MASK) {
260 dev_dbg(wm->dev, "adc wrong sample, read %x got %x", adcsel, 258 dev_dbg(wm->dev, "adc wrong sample, wanted %x got %x",
261 *sample & WM97XX_ADCSEL_MASK); 259 adcsel & WM97XX_ADCSEL_MASK,
260 *sample & WM97XX_ADCSEL_MASK);
262 return RC_PENUP; 261 return RC_PENUP;
263 } 262 }
264 263
265 if (!(*sample & WM97XX_PEN_DOWN)) { 264 if (wants_pen && !(*sample & WM97XX_PEN_DOWN)) {
266 wm->pen_probably_down = 0; 265 wm->pen_probably_down = 0;
267 return RC_PENUP; 266 return RC_PENUP;
268 } 267 }
@@ -277,14 +276,14 @@ static int wm9705_poll_touch(struct wm97xx *wm, struct wm97xx_data *data)
277{ 276{
278 int rc; 277 int rc;
279 278
280 rc = wm9705_poll_sample(wm, WM97XX_ADCSEL_X, &data->x); 279 rc = wm9705_poll_sample(wm, WM97XX_ADCSEL_X | WM97XX_PEN_DOWN, &data->x);
281 if (rc != RC_VALID) 280 if (rc != RC_VALID)
282 return rc; 281 return rc;
283 rc = wm9705_poll_sample(wm, WM97XX_ADCSEL_Y, &data->y); 282 rc = wm9705_poll_sample(wm, WM97XX_ADCSEL_Y | WM97XX_PEN_DOWN, &data->y);
284 if (rc != RC_VALID) 283 if (rc != RC_VALID)
285 return rc; 284 return rc;
286 if (pil) { 285 if (pil) {
287 rc = wm9705_poll_sample(wm, WM97XX_ADCSEL_PRES, &data->p); 286 rc = wm9705_poll_sample(wm, WM97XX_ADCSEL_PRES | WM97XX_PEN_DOWN, &data->p);
288 if (rc != RC_VALID) 287 if (rc != RC_VALID)
289 return rc; 288 return rc;
290 } else 289 } else