xref: /openbmc/linux/drivers/mfd/ucb1x00-ts.c (revision 1393c3ed)
1acb45439SRussell King /*
25437775eSPavel Machek  *  Touchscreen driver for UCB1x00-based touchscreens
3acb45439SRussell King  *
4acb45439SRussell King  *  Copyright (C) 2001 Russell King, All Rights Reserved.
55437775eSPavel Machek  *  Copyright (C) 2005 Pavel Machek
6acb45439SRussell King  *
7acb45439SRussell King  * This program is free software; you can redistribute it and/or modify
8acb45439SRussell King  * it under the terms of the GNU General Public License version 2 as
9acb45439SRussell King  * published by the Free Software Foundation.
10acb45439SRussell King  *
11acb45439SRussell King  * 21-Jan-2002 <jco@ict.es> :
12acb45439SRussell King  *
13acb45439SRussell King  * Added support for synchronous A/D mode. This mode is useful to
14acb45439SRussell King  * avoid noise induced in the touchpanel by the LCD, provided that
15acb45439SRussell King  * the UCB1x00 has a valid LCD sync signal routed to its ADCSYNC pin.
16acb45439SRussell King  * It is important to note that the signal connected to the ADCSYNC
17acb45439SRussell King  * pin should provide pulses even when the LCD is blanked, otherwise
18acb45439SRussell King  * a pen touch needed to unblank the LCD will never be read.
19acb45439SRussell King  */
20acb45439SRussell King #include <linux/config.h>
21acb45439SRussell King #include <linux/module.h>
22acb45439SRussell King #include <linux/moduleparam.h>
23acb45439SRussell King #include <linux/init.h>
24acb45439SRussell King #include <linux/smp.h>
25acb45439SRussell King #include <linux/smp_lock.h>
26acb45439SRussell King #include <linux/sched.h>
27acb45439SRussell King #include <linux/completion.h>
28acb45439SRussell King #include <linux/delay.h>
29acb45439SRussell King #include <linux/string.h>
30acb45439SRussell King #include <linux/input.h>
31acb45439SRussell King #include <linux/device.h>
32acb45439SRussell King #include <linux/suspend.h>
33acb45439SRussell King #include <linux/slab.h>
345437775eSPavel Machek #include <linux/kthread.h>
3517532989SPavel Machek #include <linux/delay.h>
36acb45439SRussell King 
37acb45439SRussell King #include <asm/dma.h>
38acb45439SRussell King #include <asm/semaphore.h>
3917532989SPavel Machek #include <asm/arch/collie.h>
4017532989SPavel Machek #include <asm/mach-types.h>
41acb45439SRussell King 
42acb45439SRussell King #include "ucb1x00.h"
43acb45439SRussell King 
44acb45439SRussell King 
45acb45439SRussell King struct ucb1x00_ts {
46bd622663SDmitry Torokhov 	struct input_dev	*idev;
47acb45439SRussell King 	struct ucb1x00		*ucb;
48acb45439SRussell King 
49acb45439SRussell King 	wait_queue_head_t	irq_wait;
50acb45439SRussell King 	struct task_struct	*rtask;
51acb45439SRussell King 	u16			x_res;
52acb45439SRussell King 	u16			y_res;
53acb45439SRussell King 
546b9ea421SRussell King 	unsigned int		restart:1;
556b9ea421SRussell King 	unsigned int		adcsync:1;
56acb45439SRussell King };
57acb45439SRussell King 
58acb45439SRussell King static int adcsync;
59acb45439SRussell King 
60acb45439SRussell King static inline void ucb1x00_ts_evt_add(struct ucb1x00_ts *ts, u16 pressure, u16 x, u16 y)
61acb45439SRussell King {
621393c3edSNicolas Pitre 	struct input_dev *idev = ts->idev;
631393c3edSNicolas Pitre 	input_report_abs(idev, ABS_X, x);
641393c3edSNicolas Pitre 	input_report_abs(idev, ABS_Y, y);
651393c3edSNicolas Pitre 	input_report_abs(idev, ABS_PRESSURE, pressure);
661393c3edSNicolas Pitre 	input_sync(idev);
67acb45439SRussell King }
68acb45439SRussell King 
69acb45439SRussell King static inline void ucb1x00_ts_event_release(struct ucb1x00_ts *ts)
70acb45439SRussell King {
711393c3edSNicolas Pitre 	struct input_dev *idev = ts->idev;
721393c3edSNicolas Pitre 	input_report_abs(idev, ABS_PRESSURE, 0);
731393c3edSNicolas Pitre 	input_sync(idev);
74acb45439SRussell King }
75acb45439SRussell King 
76acb45439SRussell King /*
77acb45439SRussell King  * Switch to interrupt mode.
78acb45439SRussell King  */
79acb45439SRussell King static inline void ucb1x00_ts_mode_int(struct ucb1x00_ts *ts)
80acb45439SRussell King {
81acb45439SRussell King 	ucb1x00_reg_write(ts->ucb, UCB_TS_CR,
82acb45439SRussell King 			UCB_TS_CR_TSMX_POW | UCB_TS_CR_TSPX_POW |
83acb45439SRussell King 			UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_GND |
84acb45439SRussell King 			UCB_TS_CR_MODE_INT);
85acb45439SRussell King }
86acb45439SRussell King 
87acb45439SRussell King /*
88acb45439SRussell King  * Switch to pressure mode, and read pressure.  We don't need to wait
89acb45439SRussell King  * here, since both plates are being driven.
90acb45439SRussell King  */
91acb45439SRussell King static inline unsigned int ucb1x00_ts_read_pressure(struct ucb1x00_ts *ts)
92acb45439SRussell King {
9317532989SPavel Machek 	if (machine_is_collie()) {
9417532989SPavel Machek 		ucb1x00_io_write(ts->ucb, COLLIE_TC35143_GPIO_TBL_CHK, 0);
9517532989SPavel Machek 		ucb1x00_reg_write(ts->ucb, UCB_TS_CR,
9617532989SPavel Machek 				  UCB_TS_CR_TSPX_POW | UCB_TS_CR_TSMX_POW |
9717532989SPavel Machek 				  UCB_TS_CR_MODE_POS | UCB_TS_CR_BIAS_ENA);
9817532989SPavel Machek 
9917532989SPavel Machek 		udelay(55);
10017532989SPavel Machek 
10117532989SPavel Machek 		return ucb1x00_adc_read(ts->ucb, UCB_ADC_INP_AD2, ts->adcsync);
10217532989SPavel Machek 	} else {
103acb45439SRussell King 		ucb1x00_reg_write(ts->ucb, UCB_TS_CR,
104acb45439SRussell King 				  UCB_TS_CR_TSMX_POW | UCB_TS_CR_TSPX_POW |
105acb45439SRussell King 				  UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_GND |
106acb45439SRussell King 				  UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA);
107acb45439SRussell King 
108acb45439SRussell King 		return ucb1x00_adc_read(ts->ucb, UCB_ADC_INP_TSPY, ts->adcsync);
109acb45439SRussell King 	}
11017532989SPavel Machek }
111acb45439SRussell King 
112acb45439SRussell King /*
113acb45439SRussell King  * Switch to X position mode and measure Y plate.  We switch the plate
114acb45439SRussell King  * configuration in pressure mode, then switch to position mode.  This
115acb45439SRussell King  * gives a faster response time.  Even so, we need to wait about 55us
116acb45439SRussell King  * for things to stabilise.
117acb45439SRussell King  */
118acb45439SRussell King static inline unsigned int ucb1x00_ts_read_xpos(struct ucb1x00_ts *ts)
119acb45439SRussell King {
12017532989SPavel Machek 	if (machine_is_collie())
12117532989SPavel Machek 		ucb1x00_io_write(ts->ucb, 0, COLLIE_TC35143_GPIO_TBL_CHK);
12217532989SPavel Machek 	else {
123acb45439SRussell King 		ucb1x00_reg_write(ts->ucb, UCB_TS_CR,
124acb45439SRussell King 				  UCB_TS_CR_TSMX_GND | UCB_TS_CR_TSPX_POW |
125acb45439SRussell King 				  UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA);
126acb45439SRussell King 		ucb1x00_reg_write(ts->ucb, UCB_TS_CR,
127acb45439SRussell King 				  UCB_TS_CR_TSMX_GND | UCB_TS_CR_TSPX_POW |
128acb45439SRussell King 				  UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA);
12917532989SPavel Machek 	}
130acb45439SRussell King 	ucb1x00_reg_write(ts->ucb, UCB_TS_CR,
131acb45439SRussell King 			UCB_TS_CR_TSMX_GND | UCB_TS_CR_TSPX_POW |
132acb45439SRussell King 			UCB_TS_CR_MODE_POS | UCB_TS_CR_BIAS_ENA);
133acb45439SRussell King 
134acb45439SRussell King 	udelay(55);
135acb45439SRussell King 
136acb45439SRussell King 	return ucb1x00_adc_read(ts->ucb, UCB_ADC_INP_TSPY, ts->adcsync);
137acb45439SRussell King }
138acb45439SRussell King 
139acb45439SRussell King /*
140acb45439SRussell King  * Switch to Y position mode and measure X plate.  We switch the plate
141acb45439SRussell King  * configuration in pressure mode, then switch to position mode.  This
142acb45439SRussell King  * gives a faster response time.  Even so, we need to wait about 55us
143acb45439SRussell King  * for things to stabilise.
144acb45439SRussell King  */
145acb45439SRussell King static inline unsigned int ucb1x00_ts_read_ypos(struct ucb1x00_ts *ts)
146acb45439SRussell King {
14717532989SPavel Machek 	if (machine_is_collie())
14817532989SPavel Machek 		ucb1x00_io_write(ts->ucb, 0, COLLIE_TC35143_GPIO_TBL_CHK);
14917532989SPavel Machek 	else {
150acb45439SRussell King 		ucb1x00_reg_write(ts->ucb, UCB_TS_CR,
151acb45439SRussell King 				  UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_POW |
152acb45439SRussell King 				  UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA);
153acb45439SRussell King 		ucb1x00_reg_write(ts->ucb, UCB_TS_CR,
154acb45439SRussell King 				  UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_POW |
155acb45439SRussell King 				  UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA);
15617532989SPavel Machek 	}
15717532989SPavel Machek 
158acb45439SRussell King 	ucb1x00_reg_write(ts->ucb, UCB_TS_CR,
159acb45439SRussell King 			UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_POW |
160acb45439SRussell King 			UCB_TS_CR_MODE_POS | UCB_TS_CR_BIAS_ENA);
161acb45439SRussell King 
162acb45439SRussell King 	udelay(55);
163acb45439SRussell King 
164acb45439SRussell King 	return ucb1x00_adc_read(ts->ucb, UCB_ADC_INP_TSPX, ts->adcsync);
165acb45439SRussell King }
166acb45439SRussell King 
167acb45439SRussell King /*
168acb45439SRussell King  * Switch to X plate resistance mode.  Set MX to ground, PX to
169acb45439SRussell King  * supply.  Measure current.
170acb45439SRussell King  */
171acb45439SRussell King static inline unsigned int ucb1x00_ts_read_xres(struct ucb1x00_ts *ts)
172acb45439SRussell King {
173acb45439SRussell King 	ucb1x00_reg_write(ts->ucb, UCB_TS_CR,
174acb45439SRussell King 			UCB_TS_CR_TSMX_GND | UCB_TS_CR_TSPX_POW |
175acb45439SRussell King 			UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA);
176acb45439SRussell King 	return ucb1x00_adc_read(ts->ucb, 0, ts->adcsync);
177acb45439SRussell King }
178acb45439SRussell King 
179acb45439SRussell King /*
180acb45439SRussell King  * Switch to Y plate resistance mode.  Set MY to ground, PY to
181acb45439SRussell King  * supply.  Measure current.
182acb45439SRussell King  */
183acb45439SRussell King static inline unsigned int ucb1x00_ts_read_yres(struct ucb1x00_ts *ts)
184acb45439SRussell King {
185acb45439SRussell King 	ucb1x00_reg_write(ts->ucb, UCB_TS_CR,
186acb45439SRussell King 			UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_POW |
187acb45439SRussell King 			UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA);
188acb45439SRussell King 	return ucb1x00_adc_read(ts->ucb, 0, ts->adcsync);
189acb45439SRussell King }
190acb45439SRussell King 
19117532989SPavel Machek static inline int ucb1x00_ts_pen_down(struct ucb1x00_ts *ts)
19217532989SPavel Machek {
19317532989SPavel Machek 	unsigned int val = ucb1x00_reg_read(ts->ucb, UCB_TS_CR);
19417532989SPavel Machek 	if (machine_is_collie())
19517532989SPavel Machek 		return (!(val & (UCB_TS_CR_TSPX_LOW)));
19617532989SPavel Machek 	else
19717532989SPavel Machek 		return (val & (UCB_TS_CR_TSPX_LOW | UCB_TS_CR_TSMX_LOW));
19817532989SPavel Machek }
19917532989SPavel Machek 
200acb45439SRussell King /*
201acb45439SRussell King  * This is a RT kernel thread that handles the ADC accesses
202acb45439SRussell King  * (mainly so we can use semaphores in the UCB1200 core code
203acb45439SRussell King  * to serialise accesses to the ADC).
204acb45439SRussell King  */
205acb45439SRussell King static int ucb1x00_thread(void *_ts)
206acb45439SRussell King {
207acb45439SRussell King 	struct ucb1x00_ts *ts = _ts;
208acb45439SRussell King 	struct task_struct *tsk = current;
209acb45439SRussell King 	DECLARE_WAITQUEUE(wait, tsk);
210acb45439SRussell King 	int valid;
211acb45439SRussell King 
212acb45439SRussell King 	/*
213acb45439SRussell King 	 * We could run as a real-time thread.  However, thus far
214acb45439SRussell King 	 * this doesn't seem to be necessary.
215acb45439SRussell King 	 */
216acb45439SRussell King //	tsk->policy = SCHED_FIFO;
217acb45439SRussell King //	tsk->rt_priority = 1;
218acb45439SRussell King 
219acb45439SRussell King 	valid = 0;
220acb45439SRussell King 
221acb45439SRussell King 	add_wait_queue(&ts->irq_wait, &wait);
2225437775eSPavel Machek 	while (!kthread_should_stop()) {
22317532989SPavel Machek 		unsigned int x, y, p;
224acb45439SRussell King 		signed long timeout;
225acb45439SRussell King 
226acb45439SRussell King 		ts->restart = 0;
227acb45439SRussell King 
228acb45439SRussell King 		ucb1x00_adc_enable(ts->ucb);
229acb45439SRussell King 
230acb45439SRussell King 		x = ucb1x00_ts_read_xpos(ts);
231acb45439SRussell King 		y = ucb1x00_ts_read_ypos(ts);
232acb45439SRussell King 		p = ucb1x00_ts_read_pressure(ts);
233acb45439SRussell King 
234acb45439SRussell King 		/*
235acb45439SRussell King 		 * Switch back to interrupt mode.
236acb45439SRussell King 		 */
237acb45439SRussell King 		ucb1x00_ts_mode_int(ts);
238acb45439SRussell King 		ucb1x00_adc_disable(ts->ucb);
239acb45439SRussell King 
2405437775eSPavel Machek 		msleep(10);
241acb45439SRussell King 
242acb45439SRussell King 		ucb1x00_enable(ts->ucb);
243acb45439SRussell King 
24417532989SPavel Machek 
24517532989SPavel Machek 		if (ucb1x00_ts_pen_down(ts)) {
246acb45439SRussell King 			set_task_state(tsk, TASK_INTERRUPTIBLE);
247acb45439SRussell King 
24817532989SPavel Machek 			ucb1x00_enable_irq(ts->ucb, UCB_IRQ_TSPX, machine_is_collie() ? UCB_RISING : UCB_FALLING);
249acb45439SRussell King 			ucb1x00_disable(ts->ucb);
250acb45439SRussell King 
251acb45439SRussell King 			/*
252acb45439SRussell King 			 * If we spat out a valid sample set last time,
253acb45439SRussell King 			 * spit out a "pen off" sample here.
254acb45439SRussell King 			 */
255acb45439SRussell King 			if (valid) {
256acb45439SRussell King 				ucb1x00_ts_event_release(ts);
257acb45439SRussell King 				valid = 0;
258acb45439SRussell King 			}
259acb45439SRussell King 
260acb45439SRussell King 			timeout = MAX_SCHEDULE_TIMEOUT;
261acb45439SRussell King 		} else {
262acb45439SRussell King 			ucb1x00_disable(ts->ucb);
263acb45439SRussell King 
264acb45439SRussell King 			/*
265acb45439SRussell King 			 * Filtering is policy.  Policy belongs in user
266acb45439SRussell King 			 * space.  We therefore leave it to user space
267acb45439SRussell King 			 * to do any filtering they please.
268acb45439SRussell King 			 */
269acb45439SRussell King 			if (!ts->restart) {
270acb45439SRussell King 				ucb1x00_ts_evt_add(ts, p, x, y);
271acb45439SRussell King 				valid = 1;
272acb45439SRussell King 			}
273acb45439SRussell King 
274acb45439SRussell King 			set_task_state(tsk, TASK_INTERRUPTIBLE);
275acb45439SRussell King 			timeout = HZ / 100;
276acb45439SRussell King 		}
277acb45439SRussell King 
278acb45439SRussell King 		try_to_freeze();
279acb45439SRussell King 
280acb45439SRussell King 		schedule_timeout(timeout);
281acb45439SRussell King 	}
282acb45439SRussell King 
283acb45439SRussell King 	remove_wait_queue(&ts->irq_wait, &wait);
284acb45439SRussell King 
285acb45439SRussell King 	ts->rtask = NULL;
2865437775eSPavel Machek 	return 0;
287acb45439SRussell King }
288acb45439SRussell King 
289acb45439SRussell King /*
290acb45439SRussell King  * We only detect touch screen _touches_ with this interrupt
291acb45439SRussell King  * handler, and even then we just schedule our task.
292acb45439SRussell King  */
293acb45439SRussell King static void ucb1x00_ts_irq(int idx, void *id)
294acb45439SRussell King {
295acb45439SRussell King 	struct ucb1x00_ts *ts = id;
296acb45439SRussell King 	ucb1x00_disable_irq(ts->ucb, UCB_IRQ_TSPX, UCB_FALLING);
297acb45439SRussell King 	wake_up(&ts->irq_wait);
298acb45439SRussell King }
299acb45439SRussell King 
300acb45439SRussell King static int ucb1x00_ts_open(struct input_dev *idev)
301acb45439SRussell King {
3021393c3edSNicolas Pitre 	struct ucb1x00_ts *ts = idev->private;
303acb45439SRussell King 	int ret = 0;
304acb45439SRussell King 
3055437775eSPavel Machek 	BUG_ON(ts->rtask);
306acb45439SRussell King 
307acb45439SRussell King 	init_waitqueue_head(&ts->irq_wait);
308acb45439SRussell King 	ret = ucb1x00_hook_irq(ts->ucb, UCB_IRQ_TSPX, ucb1x00_ts_irq, ts);
309acb45439SRussell King 	if (ret < 0)
310acb45439SRussell King 		goto out;
311acb45439SRussell King 
312acb45439SRussell King 	/*
313acb45439SRussell King 	 * If we do this at all, we should allow the user to
314acb45439SRussell King 	 * measure and read the X and Y resistance at any time.
315acb45439SRussell King 	 */
316acb45439SRussell King 	ucb1x00_adc_enable(ts->ucb);
317acb45439SRussell King 	ts->x_res = ucb1x00_ts_read_xres(ts);
318acb45439SRussell King 	ts->y_res = ucb1x00_ts_read_yres(ts);
319acb45439SRussell King 	ucb1x00_adc_disable(ts->ucb);
320acb45439SRussell King 
3215437775eSPavel Machek 	ts->rtask = kthread_run(ucb1x00_thread, ts, "ktsd");
3225437775eSPavel Machek 	if (!IS_ERR(ts->rtask)) {
323acb45439SRussell King 		ret = 0;
324acb45439SRussell King 	} else {
325acb45439SRussell King 		ucb1x00_free_irq(ts->ucb, UCB_IRQ_TSPX, ts);
3265437775eSPavel Machek 		ts->rtask = NULL;
3275437775eSPavel Machek 		ret = -EFAULT;
328acb45439SRussell King 	}
329acb45439SRussell King 
330acb45439SRussell King  out:
331acb45439SRussell King 	return ret;
332acb45439SRussell King }
333acb45439SRussell King 
334acb45439SRussell King /*
335acb45439SRussell King  * Release touchscreen resources.  Disable IRQs.
336acb45439SRussell King  */
337acb45439SRussell King static void ucb1x00_ts_close(struct input_dev *idev)
338acb45439SRussell King {
3391393c3edSNicolas Pitre 	struct ucb1x00_ts *ts = idev->private;
340acb45439SRussell King 
3415437775eSPavel Machek 	if (ts->rtask)
3425437775eSPavel Machek 		kthread_stop(ts->rtask);
343acb45439SRussell King 
344acb45439SRussell King 	ucb1x00_enable(ts->ucb);
345acb45439SRussell King 	ucb1x00_free_irq(ts->ucb, UCB_IRQ_TSPX, ts);
346acb45439SRussell King 	ucb1x00_reg_write(ts->ucb, UCB_TS_CR, 0);
347acb45439SRussell King 	ucb1x00_disable(ts->ucb);
348acb45439SRussell King }
349acb45439SRussell King 
350acb45439SRussell King #ifdef CONFIG_PM
351acb45439SRussell King static int ucb1x00_ts_resume(struct ucb1x00_dev *dev)
352acb45439SRussell King {
353acb45439SRussell King 	struct ucb1x00_ts *ts = dev->priv;
354acb45439SRussell King 
355acb45439SRussell King 	if (ts->rtask != NULL) {
356acb45439SRussell King 		/*
357acb45439SRussell King 		 * Restart the TS thread to ensure the
358acb45439SRussell King 		 * TS interrupt mode is set up again
359acb45439SRussell King 		 * after sleep.
360acb45439SRussell King 		 */
361acb45439SRussell King 		ts->restart = 1;
362acb45439SRussell King 		wake_up(&ts->irq_wait);
363acb45439SRussell King 	}
364acb45439SRussell King 	return 0;
365acb45439SRussell King }
366acb45439SRussell King #else
367acb45439SRussell King #define ucb1x00_ts_resume NULL
368acb45439SRussell King #endif
369acb45439SRussell King 
370acb45439SRussell King 
371acb45439SRussell King /*
372acb45439SRussell King  * Initialisation.
373acb45439SRussell King  */
374acb45439SRussell King static int ucb1x00_ts_add(struct ucb1x00_dev *dev)
375acb45439SRussell King {
376acb45439SRussell King 	struct ucb1x00_ts *ts;
377acb45439SRussell King 
378bd622663SDmitry Torokhov 	ts = kzalloc(sizeof(struct ucb1x00_ts), GFP_KERNEL);
379acb45439SRussell King 	if (!ts)
380acb45439SRussell King 		return -ENOMEM;
381acb45439SRussell King 
382bd622663SDmitry Torokhov 	ts->idev = input_allocate_device();
383bd622663SDmitry Torokhov 	if (!ts->idev) {
384bd622663SDmitry Torokhov 		kfree(ts);
385bd622663SDmitry Torokhov 		return -ENOMEM;
386bd622663SDmitry Torokhov 	}
387acb45439SRussell King 
388acb45439SRussell King 	ts->ucb = dev->ucb;
389acb45439SRussell King 	ts->adcsync = adcsync ? UCB_SYNC : UCB_NOSYNC;
390acb45439SRussell King 
3911393c3edSNicolas Pitre 	ts->idev->private = ts;
392bd622663SDmitry Torokhov 	ts->idev->name       = "Touchscreen panel";
393bd622663SDmitry Torokhov 	ts->idev->id.product = ts->ucb->id;
394bd622663SDmitry Torokhov 	ts->idev->open       = ucb1x00_ts_open;
395bd622663SDmitry Torokhov 	ts->idev->close      = ucb1x00_ts_close;
396acb45439SRussell King 
397bd622663SDmitry Torokhov 	__set_bit(EV_ABS, ts->idev->evbit);
398bd622663SDmitry Torokhov 	__set_bit(ABS_X, ts->idev->absbit);
399bd622663SDmitry Torokhov 	__set_bit(ABS_Y, ts->idev->absbit);
400bd622663SDmitry Torokhov 	__set_bit(ABS_PRESSURE, ts->idev->absbit);
401acb45439SRussell King 
402bd622663SDmitry Torokhov 	input_register_device(ts->idev);
403acb45439SRussell King 
404acb45439SRussell King 	dev->priv = ts;
405acb45439SRussell King 
406acb45439SRussell King 	return 0;
407acb45439SRussell King }
408acb45439SRussell King 
409acb45439SRussell King static void ucb1x00_ts_remove(struct ucb1x00_dev *dev)
410acb45439SRussell King {
411acb45439SRussell King 	struct ucb1x00_ts *ts = dev->priv;
412bd622663SDmitry Torokhov 
413bd622663SDmitry Torokhov 	input_unregister_device(ts->idev);
414acb45439SRussell King 	kfree(ts);
415acb45439SRussell King }
416acb45439SRussell King 
417acb45439SRussell King static struct ucb1x00_driver ucb1x00_ts_driver = {
418acb45439SRussell King 	.add		= ucb1x00_ts_add,
419acb45439SRussell King 	.remove		= ucb1x00_ts_remove,
420acb45439SRussell King 	.resume		= ucb1x00_ts_resume,
421acb45439SRussell King };
422acb45439SRussell King 
423acb45439SRussell King static int __init ucb1x00_ts_init(void)
424acb45439SRussell King {
425acb45439SRussell King 	return ucb1x00_register_driver(&ucb1x00_ts_driver);
426acb45439SRussell King }
427acb45439SRussell King 
428acb45439SRussell King static void __exit ucb1x00_ts_exit(void)
429acb45439SRussell King {
430acb45439SRussell King 	ucb1x00_unregister_driver(&ucb1x00_ts_driver);
431acb45439SRussell King }
432acb45439SRussell King 
433acb45439SRussell King module_param(adcsync, int, 0444);
434acb45439SRussell King module_init(ucb1x00_ts_init);
435acb45439SRussell King module_exit(ucb1x00_ts_exit);
436acb45439SRussell King 
437acb45439SRussell King MODULE_AUTHOR("Russell King <rmk@arm.linux.org.uk>");
438acb45439SRussell King MODULE_DESCRIPTION("UCB1x00 touchscreen driver");
439acb45439SRussell King MODULE_LICENSE("GPL");
440