aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2005-09-11 05:26:57 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2005-09-11 05:26:57 -0400
commitacb45439a89c6830349c02405f00a7208db0a66b (patch)
tree4a1a1f2d5012029b70bdfeed46e6cb65c5d82867 /drivers/mfd
parent05c45ca9aa4ec57e8e22341633c7a98cc879423d (diff)
[MFD] Add code UCB1200/UCB1300 touchscreen support
Add support for Philips UCB1200 and UCB1300 touchscreen interfaces found on ARM devices. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'drivers/mfd')
-rw-r--r--drivers/mfd/Kconfig4
-rw-r--r--drivers/mfd/Makefile1
-rw-r--r--drivers/mfd/ucb1x00-ts.c430
3 files changed, 435 insertions, 0 deletions
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 1f8563bde4..550f297448 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -18,4 +18,8 @@ config MCP_UCB1200
18 tristate "Support for UCB1200 / UCB1300" 18 tristate "Support for UCB1200 / UCB1300"
19 depends on MCP 19 depends on MCP
20 20
21config MCP_UCB1200_TS
22 tristate "Touchscreen interface support"
23 depends on MCP_UCB1200 && INPUT
24
21endmenu 25endmenu
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 90815b2840..a05cd1599a 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -5,3 +5,4 @@
5obj-$(CONFIG_MCP) += mcp-core.o 5obj-$(CONFIG_MCP) += mcp-core.o
6obj-$(CONFIG_MCP_SA11X0) += mcp-sa11x0.o 6obj-$(CONFIG_MCP_SA11X0) += mcp-sa11x0.o
7obj-$(CONFIG_MCP_UCB1200) += ucb1x00-core.o 7obj-$(CONFIG_MCP_UCB1200) += ucb1x00-core.o
8obj-$(CONFIG_MCP_UCB1200_TS) += ucb1x00-ts.o
diff --git a/drivers/mfd/ucb1x00-ts.c b/drivers/mfd/ucb1x00-ts.c
new file mode 100644
index 0000000000..52e0699eeb
--- /dev/null
+++ b/drivers/mfd/ucb1x00-ts.c
@@ -0,0 +1,430 @@
1/*
2 * linux/drivers/mfd/ucb1x00-ts.c
3 *
4 * Copyright (C) 2001 Russell King, All Rights Reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * 21-Jan-2002 <jco@ict.es> :
11 *
12 * Added support for synchronous A/D mode. This mode is useful to
13 * avoid noise induced in the touchpanel by the LCD, provided that
14 * the UCB1x00 has a valid LCD sync signal routed to its ADCSYNC pin.
15 * It is important to note that the signal connected to the ADCSYNC
16 * pin should provide pulses even when the LCD is blanked, otherwise
17 * a pen touch needed to unblank the LCD will never be read.
18 */
19#include <linux/config.h>
20#include <linux/module.h>
21#include <linux/moduleparam.h>
22#include <linux/init.h>
23#include <linux/smp.h>
24#include <linux/smp_lock.h>
25#include <linux/sched.h>
26#include <linux/completion.h>
27#include <linux/delay.h>
28#include <linux/string.h>
29#include <linux/input.h>
30#include <linux/device.h>
31#include <linux/suspend.h>
32#include <linux/slab.h>
33
34#include <asm/dma.h>
35#include <asm/semaphore.h>
36
37#include "ucb1x00.h"
38
39
40struct ucb1x00_ts {
41 struct input_dev idev;
42 struct ucb1x00 *ucb;
43
44 wait_queue_head_t irq_wait;
45 struct semaphore sem;
46 struct completion init_exit;
47 struct task_struct *rtask;
48 int use_count;
49 u16 x_res;
50 u16 y_res;
51
52 int restart:1;
53 int adcsync:1;
54};
55
56static int adcsync;
57
58static inline void ucb1x00_ts_evt_add(struct ucb1x00_ts *ts, u16 pressure, u16 x, u16 y)
59{
60 input_report_abs(&ts->idev, ABS_X, x);
61 input_report_abs(&ts->idev, ABS_Y, y);
62 input_report_abs(&ts->idev, ABS_PRESSURE, pressure);
63 input_sync(&ts->idev);
64}
65
66static inline void ucb1x00_ts_event_release(struct ucb1x00_ts *ts)
67{
68 input_report_abs(&ts->idev, ABS_PRESSURE, 0);
69 input_sync(&ts->idev);
70}
71
72/*
73 * Switch to interrupt mode.
74 */
75static inline void ucb1x00_ts_mode_int(struct ucb1x00_ts *ts)
76{
77 ucb1x00_reg_write(ts->ucb, UCB_TS_CR,
78 UCB_TS_CR_TSMX_POW | UCB_TS_CR_TSPX_POW |
79 UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_GND |
80 UCB_TS_CR_MODE_INT);
81}
82
83/*
84 * Switch to pressure mode, and read pressure. We don't need to wait
85 * here, since both plates are being driven.
86 */
87static inline unsigned int ucb1x00_ts_read_pressure(struct ucb1x00_ts *ts)
88{
89 ucb1x00_reg_write(ts->ucb, UCB_TS_CR,
90 UCB_TS_CR_TSMX_POW | UCB_TS_CR_TSPX_POW |
91 UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_GND |
92 UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA);
93
94 return ucb1x00_adc_read(ts->ucb, UCB_ADC_INP_TSPY, ts->adcsync);
95}
96
97/*
98 * Switch to X position mode and measure Y plate. We switch the plate
99 * configuration in pressure mode, then switch to position mode. This
100 * gives a faster response time. Even so, we need to wait about 55us
101 * for things to stabilise.
102 */
103static inline unsigned int ucb1x00_ts_read_xpos(struct ucb1x00_ts *ts)
104{
105 ucb1x00_reg_write(ts->ucb, UCB_TS_CR,
106 UCB_TS_CR_TSMX_GND | UCB_TS_CR_TSPX_POW |
107 UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA);
108 ucb1x00_reg_write(ts->ucb, UCB_TS_CR,
109 UCB_TS_CR_TSMX_GND | UCB_TS_CR_TSPX_POW |
110 UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA);
111 ucb1x00_reg_write(ts->ucb, UCB_TS_CR,
112 UCB_TS_CR_TSMX_GND | UCB_TS_CR_TSPX_POW |
113 UCB_TS_CR_MODE_POS | UCB_TS_CR_BIAS_ENA);
114
115 udelay(55);
116
117 return ucb1x00_adc_read(ts->ucb, UCB_ADC_INP_TSPY, ts->adcsync);
118}
119
120/*
121 * Switch to Y position mode and measure X plate. We switch the plate
122 * configuration in pressure mode, then switch to position mode. This
123 * gives a faster response time. Even so, we need to wait about 55us
124 * for things to stabilise.
125 */
126static inline unsigned int ucb1x00_ts_read_ypos(struct ucb1x00_ts *ts)
127{
128 ucb1x00_reg_write(ts->ucb, UCB_TS_CR,
129 UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_POW |
130 UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA);
131 ucb1x00_reg_write(ts->ucb, UCB_TS_CR,
132 UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_POW |
133 UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA);
134 ucb1x00_reg_write(ts->ucb, UCB_TS_CR,
135 UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_POW |
136 UCB_TS_CR_MODE_POS | UCB_TS_CR_BIAS_ENA);
137
138 udelay(55);
139
140 return ucb1x00_adc_read(ts->ucb, UCB_ADC_INP_TSPX, ts->adcsync);
141}
142
143/*
144 * Switch to X plate resistance mode. Set MX to ground, PX to
145 * supply. Measure current.
146 */
147static inline unsigned int ucb1x00_ts_read_xres(struct ucb1x00_ts *ts)
148{
149 ucb1x00_reg_write(ts->ucb, UCB_TS_CR,
150 UCB_TS_CR_TSMX_GND | UCB_TS_CR_TSPX_POW |
151 UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA);
152 return ucb1x00_adc_read(ts->ucb, 0, ts->adcsync);
153}
154
155/*
156 * Switch to Y plate resistance mode. Set MY to ground, PY to
157 * supply. Measure current.
158 */
159static inline unsigned int ucb1x00_ts_read_yres(struct ucb1x00_ts *ts)
160{
161 ucb1x00_reg_write(ts->ucb, UCB_TS_CR,
162 UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_POW |
163 UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA);
164 return ucb1x00_adc_read(ts->ucb, 0, ts->adcsync);
165}
166
167/*
168 * This is a RT kernel thread that handles the ADC accesses
169 * (mainly so we can use semaphores in the UCB1200 core code
170 * to serialise accesses to the ADC).
171 */
172static int ucb1x00_thread(void *_ts)
173{
174 struct ucb1x00_ts *ts = _ts;
175 struct task_struct *tsk = current;
176 DECLARE_WAITQUEUE(wait, tsk);
177 int valid;
178
179 ts->rtask = tsk;
180
181 daemonize("ktsd");
182 /* only want to receive SIGKILL */
183 allow_signal(SIGKILL);
184
185 /*
186 * We could run as a real-time thread. However, thus far
187 * this doesn't seem to be necessary.
188 */
189// tsk->policy = SCHED_FIFO;
190// tsk->rt_priority = 1;
191
192 complete(&ts->init_exit);
193
194 valid = 0;
195
196 add_wait_queue(&ts->irq_wait, &wait);
<