Lines Matching +full:y +full:- +full:plate

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Touchscreen driver for UCB1x00-based touchscreens
8 * 21-Jan-2002 <jco@ict.es> :
34 #include <asm/mach-types.h>
54 static inline void ucb1x00_ts_evt_add(struct ucb1x00_ts *ts, u16 pressure, u16 x, u16 y) in ucb1x00_ts_evt_add() argument
56 struct input_dev *idev = ts->idev; in ucb1x00_ts_evt_add()
59 input_report_abs(idev, ABS_Y, y); in ucb1x00_ts_evt_add()
67 struct input_dev *idev = ts->idev; in ucb1x00_ts_event_release()
79 ucb1x00_reg_write(ts->ucb, UCB_TS_CR, in ucb1x00_ts_mode_int()
92 ucb1x00_io_write(ts->ucb, COLLIE_TC35143_GPIO_TBL_CHK, 0); in ucb1x00_ts_read_pressure()
93 ucb1x00_reg_write(ts->ucb, UCB_TS_CR, in ucb1x00_ts_read_pressure()
99 return ucb1x00_adc_read(ts->ucb, UCB_ADC_INP_AD2, ts->adcsync); in ucb1x00_ts_read_pressure()
101 ucb1x00_reg_write(ts->ucb, UCB_TS_CR, in ucb1x00_ts_read_pressure()
106 return ucb1x00_adc_read(ts->ucb, UCB_ADC_INP_TSPY, ts->adcsync); in ucb1x00_ts_read_pressure()
111 * Switch to X position mode and measure Y plate. We switch the plate
119 ucb1x00_io_write(ts->ucb, 0, COLLIE_TC35143_GPIO_TBL_CHK); in ucb1x00_ts_read_xpos()
121 ucb1x00_reg_write(ts->ucb, UCB_TS_CR, in ucb1x00_ts_read_xpos()
124 ucb1x00_reg_write(ts->ucb, UCB_TS_CR, in ucb1x00_ts_read_xpos()
128 ucb1x00_reg_write(ts->ucb, UCB_TS_CR, in ucb1x00_ts_read_xpos()
134 return ucb1x00_adc_read(ts->ucb, UCB_ADC_INP_TSPY, ts->adcsync); in ucb1x00_ts_read_xpos()
138 * Switch to Y position mode and measure X plate. We switch the plate
146 ucb1x00_io_write(ts->ucb, 0, COLLIE_TC35143_GPIO_TBL_CHK); in ucb1x00_ts_read_ypos()
148 ucb1x00_reg_write(ts->ucb, UCB_TS_CR, in ucb1x00_ts_read_ypos()
151 ucb1x00_reg_write(ts->ucb, UCB_TS_CR, in ucb1x00_ts_read_ypos()
156 ucb1x00_reg_write(ts->ucb, UCB_TS_CR, in ucb1x00_ts_read_ypos()
162 return ucb1x00_adc_read(ts->ucb, UCB_ADC_INP_TSPX, ts->adcsync); in ucb1x00_ts_read_ypos()
166 * Switch to X plate resistance mode. Set MX to ground, PX to
171 ucb1x00_reg_write(ts->ucb, UCB_TS_CR, in ucb1x00_ts_read_xres()
174 return ucb1x00_adc_read(ts->ucb, 0, ts->adcsync); in ucb1x00_ts_read_xres()
178 * Switch to Y plate resistance mode. Set MY to ground, PY to
183 ucb1x00_reg_write(ts->ucb, UCB_TS_CR, in ucb1x00_ts_read_yres()
186 return ucb1x00_adc_read(ts->ucb, 0, ts->adcsync); in ucb1x00_ts_read_yres()
191 unsigned int val = ucb1x00_reg_read(ts->ucb, UCB_TS_CR); in ucb1x00_ts_pen_down()
212 add_wait_queue(&ts->irq_wait, &wait); in ucb1x00_thread()
214 unsigned int x, y, p; in ucb1x00_thread() local
220 ucb1x00_adc_enable(ts->ucb); in ucb1x00_thread()
223 y = ucb1x00_ts_read_ypos(ts); in ucb1x00_thread()
230 ucb1x00_adc_disable(ts->ucb); in ucb1x00_thread()
234 ucb1x00_enable(ts->ucb); in ucb1x00_thread()
240 spin_lock_irq(&ts->irq_lock); in ucb1x00_thread()
241 if (ts->irq_disabled) { in ucb1x00_thread()
242 ts->irq_disabled = 0; in ucb1x00_thread()
243 enable_irq(ts->ucb->irq_base + UCB_IRQ_TSPX); in ucb1x00_thread()
245 spin_unlock_irq(&ts->irq_lock); in ucb1x00_thread()
246 ucb1x00_disable(ts->ucb); in ucb1x00_thread()
259 ucb1x00_disable(ts->ucb); in ucb1x00_thread()
267 ucb1x00_ts_evt_add(ts, p, x, y); in ucb1x00_thread()
278 remove_wait_queue(&ts->irq_wait, &wait); in ucb1x00_thread()
280 ts->rtask = NULL; in ucb1x00_thread()
292 spin_lock(&ts->irq_lock); in ucb1x00_ts_irq()
293 ts->irq_disabled = 1; in ucb1x00_ts_irq()
294 disable_irq_nosync(ts->ucb->irq_base + UCB_IRQ_TSPX); in ucb1x00_ts_irq()
295 spin_unlock(&ts->irq_lock); in ucb1x00_ts_irq()
296 wake_up(&ts->irq_wait); in ucb1x00_ts_irq()
307 BUG_ON(ts->rtask); in ucb1x00_ts_open()
314 ts->irq_disabled = 0; in ucb1x00_ts_open()
316 init_waitqueue_head(&ts->irq_wait); in ucb1x00_ts_open()
317 ret = request_irq(ts->ucb->irq_base + UCB_IRQ_TSPX, ucb1x00_ts_irq, in ucb1x00_ts_open()
318 flags, "ucb1x00-ts", ts); in ucb1x00_ts_open()
324 * measure and read the X and Y resistance at any time. in ucb1x00_ts_open()
326 ucb1x00_adc_enable(ts->ucb); in ucb1x00_ts_open()
327 ts->x_res = ucb1x00_ts_read_xres(ts); in ucb1x00_ts_open()
328 ts->y_res = ucb1x00_ts_read_yres(ts); in ucb1x00_ts_open()
329 ucb1x00_adc_disable(ts->ucb); in ucb1x00_ts_open()
331 ts->rtask = kthread_run(ucb1x00_thread, ts, "ktsd"); in ucb1x00_ts_open()
332 if (!IS_ERR(ts->rtask)) { in ucb1x00_ts_open()
335 free_irq(ts->ucb->irq_base + UCB_IRQ_TSPX, ts); in ucb1x00_ts_open()
336 ts->rtask = NULL; in ucb1x00_ts_open()
337 ret = -EFAULT; in ucb1x00_ts_open()
351 if (ts->rtask) in ucb1x00_ts_close()
352 kthread_stop(ts->rtask); in ucb1x00_ts_close()
354 ucb1x00_enable(ts->ucb); in ucb1x00_ts_close()
355 free_irq(ts->ucb->irq_base + UCB_IRQ_TSPX, ts); in ucb1x00_ts_close()
356 ucb1x00_reg_write(ts->ucb, UCB_TS_CR, 0); in ucb1x00_ts_close()
357 ucb1x00_disable(ts->ucb); in ucb1x00_ts_close()
373 err = -ENOMEM; in ucb1x00_ts_add()
377 ts->ucb = dev->ucb; in ucb1x00_ts_add()
378 ts->idev = idev; in ucb1x00_ts_add()
379 ts->adcsync = adcsync ? UCB_SYNC : UCB_NOSYNC; in ucb1x00_ts_add()
380 spin_lock_init(&ts->irq_lock); in ucb1x00_ts_add()
382 idev->name = "Touchscreen panel"; in ucb1x00_ts_add()
383 idev->id.product = ts->ucb->id; in ucb1x00_ts_add()
384 idev->open = ucb1x00_ts_open; in ucb1x00_ts_add()
385 idev->close = ucb1x00_ts_close; in ucb1x00_ts_add()
386 idev->dev.parent = &ts->ucb->dev; in ucb1x00_ts_add()
388 idev->evbit[0] = BIT_MASK(EV_ABS) | BIT_MASK(EV_KEY); in ucb1x00_ts_add()
389 idev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); in ucb1x00_ts_add()
393 ucb1x00_adc_enable(ts->ucb); in ucb1x00_ts_add()
394 ts->x_res = ucb1x00_ts_read_xres(ts); in ucb1x00_ts_add()
395 ts->y_res = ucb1x00_ts_read_yres(ts); in ucb1x00_ts_add()
396 ucb1x00_adc_disable(ts->ucb); in ucb1x00_ts_add()
398 input_set_abs_params(idev, ABS_X, 0, ts->x_res, 0, 0); in ucb1x00_ts_add()
399 input_set_abs_params(idev, ABS_Y, 0, ts->y_res, 0, 0); in ucb1x00_ts_add()
406 dev->priv = ts; in ucb1x00_ts_add()
418 struct ucb1x00_ts *ts = dev->priv; in ucb1x00_ts_remove()
420 input_unregister_device(ts->idev); in ucb1x00_ts_remove()