aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@rpsys.net>2005-09-13 04:25:33 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-09-13 11:22:31 -0400
commit513b6e1afaf81b42cacbb24ef1aa7eea5e9661c2 (patch)
treed30c0a6ae0af38948e981f5d83a740f12f14a196 /drivers/input
parent9fc7896b62b48714fafecf9266d9dc14c1cd6e33 (diff)
[PATCH] SharpSL: Abstract c7x0 specifics from Corgi Touchscreen driver
Separate out the Sharp Zaurus c7x0 series specific code from the Corgi Touchscreen driver. Use the new functions in corgi_lcd.c via sharpsl.h for hsync handling and pass the IRQ as a platform device resource. Move a function prototype into the w100fb header file where it belongs. This enables the driver to be used by the Zaurus cxx00 series. Signed-Off-by: Richard Purdie <rpurdie@rpsys.net> Cc: Vojtech Pavlik <vojtech@suse.cz> Cc: Russell King <rmk@arm.linux.org.uk> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/touchscreen/Kconfig6
-rw-r--r--drivers/input/touchscreen/corgi_ts.c70
2 files changed, 45 insertions, 31 deletions
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index 0489af5a80c9..21d55ed4b88a 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -24,17 +24,17 @@ config TOUCHSCREEN_BITSY
24 module will be called h3600_ts_input. 24 module will be called h3600_ts_input.
25 25
26config TOUCHSCREEN_CORGI 26config TOUCHSCREEN_CORGI
27 tristate "Corgi touchscreen (for Sharp SL-C7xx)" 27 tristate "SharpSL (Corgi and Spitz series) touchscreen driver"
28 depends on PXA_SHARPSL 28 depends on PXA_SHARPSL
29 default y 29 default y
30 help 30 help
31 Say Y here to enable the driver for the touchscreen on the 31 Say Y here to enable the driver for the touchscreen on the
32 Sharp SL-C7xx series of PDAs. 32 Sharp SL-C7xx and SL-Cxx00 series of PDAs.
33 33
34 If unsure, say N. 34 If unsure, say N.
35 35
36 To compile this driver as a module, choose M here: the 36 To compile this driver as a module, choose M here: the
37 module will be called ads7846_ts. 37 module will be called corgi_ts.
38 38
39config TOUCHSCREEN_GUNZE 39config TOUCHSCREEN_GUNZE
40 tristate "Gunze AHL-51S touchscreen" 40 tristate "Gunze AHL-51S touchscreen"
diff --git a/drivers/input/touchscreen/corgi_ts.c b/drivers/input/touchscreen/corgi_ts.c
index 5d19261b884f..4c7fbe550365 100644
--- a/drivers/input/touchscreen/corgi_ts.c
+++ b/drivers/input/touchscreen/corgi_ts.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Touchscreen driver for Sharp Corgi models (SL-C7xx) 2 * Touchscreen driver for Sharp SL-C7xx and SL-Cxx00 models
3 * 3 *
4 * Copyright (c) 2004-2005 Richard Purdie 4 * Copyright (c) 2004-2005 Richard Purdie
5 * 5 *
@@ -19,7 +19,7 @@
19#include <linux/slab.h> 19#include <linux/slab.h>
20#include <asm/irq.h> 20#include <asm/irq.h>
21 21
22#include <asm/arch/corgi.h> 22#include <asm/arch/sharpsl.h>
23#include <asm/arch/hardware.h> 23#include <asm/arch/hardware.h>
24#include <asm/arch/pxa-regs.h> 24#include <asm/arch/pxa-regs.h>
25 25
@@ -47,15 +47,20 @@ struct corgi_ts {
47 struct ts_event tc; 47 struct ts_event tc;
48 int pendown; 48 int pendown;
49 int power_mode; 49 int power_mode;
50 int irq_gpio;
51 struct corgits_machinfo *machinfo;
50}; 52};
51 53
52#define STATUS_HSYNC (GPLR(CORGI_GPIO_HSYNC) & GPIO_bit(CORGI_GPIO_HSYNC)) 54#ifdef CONFIG_PXA25x
53
54#define SyncHS() while((STATUS_HSYNC) == 0); while((STATUS_HSYNC) != 0);
55#define CCNT(a) asm volatile ("mrc p14, 0, %0, C1, C0, 0" : "=r"(a)) 55#define CCNT(a) asm volatile ("mrc p14, 0, %0, C1, C0, 0" : "=r"(a))
56#define PMNC_GET(x) asm volatile ("mrc p14, 0, %0, C0, C0, 0" : "=r"(x)) 56#define PMNC_GET(x) asm volatile ("mrc p14, 0, %0, C0, C0, 0" : "=r"(x))
57#define PMNC_SET(x) asm volatile ("mcr p14, 0, %0, C0, C0, 0" : : "r"(x)) 57#define PMNC_SET(x) asm volatile ("mcr p14, 0, %0, C0, C0, 0" : : "r"(x))
58 58#endif
59#ifdef CONFIG_PXA27x
60#define CCNT(a) asm volatile ("mrc p14, 0, %0, C1, C1, 0" : "=r"(a))
61#define PMNC_GET(x) asm volatile ("mrc p14, 0, %0, C0, C1, 0" : "=r"(x))
62#define PMNC_SET(x) asm volatile ("mcr p14, 0, %0, C0, C1, 0" : : "r"(x))
63#endif
59 64
60/* ADS7846 Touch Screen Controller bit definitions */ 65/* ADS7846 Touch Screen Controller bit definitions */
61#define ADSCTRL_PD0 (1u << 0) /* PD0 */ 66#define ADSCTRL_PD0 (1u << 0) /* PD0 */
@@ -66,12 +71,11 @@ struct corgi_ts {
66#define ADSCTRL_STS (1u << 7) /* Start Bit */ 71#define ADSCTRL_STS (1u << 7) /* Start Bit */
67 72
68/* External Functions */ 73/* External Functions */
69extern unsigned long w100fb_get_hsynclen(struct device *dev);
70extern unsigned int get_clk_frequency_khz(int info); 74extern unsigned int get_clk_frequency_khz(int info);
71 75
72static unsigned long calc_waittime(void) 76static unsigned long calc_waittime(struct corgi_ts *corgi_ts)
73{ 77{
74 unsigned long hsync_len = w100fb_get_hsynclen(&corgifb_device.dev); 78 unsigned long hsync_len = corgi_ts->machinfo->get_hsync_len();
75 79
76 if (hsync_len) 80 if (hsync_len)
77 return get_clk_frequency_khz(0)*1000/hsync_len; 81 return get_clk_frequency_khz(0)*1000/hsync_len;
@@ -79,7 +83,8 @@ static unsigned long calc_waittime(void)
79 return 0; 83 return 0;
80} 84}
81 85
82static int sync_receive_data_send_cmd(int doRecive, int doSend, unsigned int address, unsigned long wait_time) 86static int sync_receive_data_send_cmd(struct corgi_ts *corgi_ts, int doRecive, int doSend,
87 unsigned int address, unsigned long wait_time)
83{ 88{
84 unsigned long timer1 = 0, timer2, pmnc = 0; 89 unsigned long timer1 = 0, timer2, pmnc = 0;
85 int pos = 0; 90 int pos = 0;
@@ -90,7 +95,7 @@ static int sync_receive_data_send_cmd(int doRecive, int doSend, unsigned int add
90 PMNC_SET(0x01); 95 PMNC_SET(0x01);
91 96
92 /* polling HSync */ 97 /* polling HSync */
93 SyncHS(); 98 corgi_ts->machinfo->wait_hsync();
94 /* get CCNT */ 99 /* get CCNT */
95 CCNT(timer1); 100 CCNT(timer1);
96 } 101 }
@@ -109,7 +114,7 @@ static int sync_receive_data_send_cmd(int doRecive, int doSend, unsigned int add
109 CCNT(timer2); 114 CCNT(timer2);
110 if (timer2-timer1 > wait_time) { 115 if (timer2-timer1 > wait_time) {
111 /* too slow - timeout, try again */ 116 /* too slow - timeout, try again */
112 SyncHS(); 117 corgi_ts->machinfo->wait_hsync();
113 /* get OSCR */ 118 /* get OSCR */
114 CCNT(timer1); 119 CCNT(timer1);
115 /* Wait after HSync */ 120 /* Wait after HSync */
@@ -133,23 +138,23 @@ static int read_xydata(struct corgi_ts *corgi_ts)
133 /* critical section */ 138 /* critical section */
134 local_irq_save(flags); 139 local_irq_save(flags);
135 corgi_ssp_ads7846_lock(); 140 corgi_ssp_ads7846_lock();
136 wait_time=calc_waittime(); 141 wait_time = calc_waittime(corgi_ts);
137 142
138 /* Y-axis */ 143 /* Y-axis */
139 sync_receive_data_send_cmd(0, 1, 1u, wait_time); 144 sync_receive_data_send_cmd(corgi_ts, 0, 1, 1u, wait_time);
140 145
141 /* Y-axis */ 146 /* Y-axis */
142 sync_receive_data_send_cmd(1, 1, 1u, wait_time); 147 sync_receive_data_send_cmd(corgi_ts, 1, 1, 1u, wait_time);
143 148
144 /* X-axis */ 149 /* X-axis */
145 y = sync_receive_data_send_cmd(1, 1, 5u, wait_time); 150 y = sync_receive_data_send_cmd(corgi_ts, 1, 1, 5u, wait_time);
146 151
147 /* Z1 */ 152 /* Z1 */
148 x = sync_receive_data_send_cmd(1, 1, 3u, wait_time); 153 x = sync_receive_data_send_cmd(corgi_ts, 1, 1, 3u, wait_time);
149 154
150 /* Z2 */ 155 /* Z2 */
151 z1 = sync_receive_data_send_cmd(1, 1, 4u, wait_time); 156 z1 = sync_receive_data_send_cmd(corgi_ts, 1, 1, 4u, wait_time);
152 z2 = sync_receive_data_send_cmd(1, 0, 4u, wait_time); 157 z2 = sync_receive_data_send_cmd(corgi_ts, 1, 0, 4u, wait_time);
153 158
154 /* Power-Down Enable */ 159 /* Power-Down Enable */
155 corgi_ssp_ads7846_put((1u << ADSCTRL_ADR_SH) | ADSCTRL_STS); 160 corgi_ssp_ads7846_put((1u << ADSCTRL_ADR_SH) | ADSCTRL_STS);
@@ -189,9 +194,9 @@ static void new_data(struct corgi_ts *corgi_ts, struct pt_regs *regs)
189 194
190static void ts_interrupt_main(struct corgi_ts *corgi_ts, int isTimer, struct pt_regs *regs) 195static void ts_interrupt_main(struct corgi_ts *corgi_ts, int isTimer, struct pt_regs *regs)
191{ 196{
192 if ((GPLR(CORGI_GPIO_TP_INT) & GPIO_bit(CORGI_GPIO_TP_INT)) == 0) { 197 if ((GPLR(IRQ_TO_GPIO(corgi_ts->irq_gpio)) & GPIO_bit(IRQ_TO_GPIO(corgi_ts->irq_gpio))) == 0) {
193 /* Disable Interrupt */ 198 /* Disable Interrupt */
194 set_irq_type(CORGI_IRQ_GPIO_TP_INT, IRQT_NOEDGE); 199 set_irq_type(corgi_ts->irq_gpio, IRQT_NOEDGE);
195 if (read_xydata(corgi_ts)) { 200 if (read_xydata(corgi_ts)) {
196 corgi_ts->pendown = 1; 201 corgi_ts->pendown = 1;
197 new_data(corgi_ts, regs); 202 new_data(corgi_ts, regs);
@@ -210,7 +215,7 @@ static void ts_interrupt_main(struct corgi_ts *corgi_ts, int isTimer, struct pt_
210 } 215 }
211 216
212 /* Enable Falling Edge */ 217 /* Enable Falling Edge */
213 set_irq_type(CORGI_IRQ_GPIO_TP_INT, IRQT_FALLING); 218 set_irq_type(corgi_ts->irq_gpio, IRQT_FALLING);
214 corgi_ts->pendown = 0; 219 corgi_ts->pendown = 0;
215 } 220 }
216} 221}
@@ -254,7 +259,7 @@ static int corgits_resume(struct device *dev, uint32_t level)
254 259
255 corgi_ssp_ads7846_putget((4u << ADSCTRL_ADR_SH) | ADSCTRL_STS); 260 corgi_ssp_ads7846_putget((4u << ADSCTRL_ADR_SH) | ADSCTRL_STS);
256 /* Enable Falling Edge */ 261 /* Enable Falling Edge */
257 set_irq_type(CORGI_IRQ_GPIO_TP_INT, IRQT_FALLING); 262 set_irq_type(corgi_ts->irq_gpio, IRQT_FALLING);
258 corgi_ts->power_mode = PWR_MODE_ACTIVE; 263 corgi_ts->power_mode = PWR_MODE_ACTIVE;
259 } 264 }
260 return 0; 265 return 0;
@@ -267,6 +272,7 @@ static int corgits_resume(struct device *dev, uint32_t level)
267static int __init corgits_probe(struct device *dev) 272static int __init corgits_probe(struct device *dev)
268{ 273{
269 struct corgi_ts *corgi_ts; 274 struct corgi_ts *corgi_ts;
275 struct platform_device *pdev = to_platform_device(dev);
270 276
271 if (!(corgi_ts = kmalloc(sizeof(struct corgi_ts), GFP_KERNEL))) 277 if (!(corgi_ts = kmalloc(sizeof(struct corgi_ts), GFP_KERNEL)))
272 return -ENOMEM; 278 return -ENOMEM;
@@ -275,6 +281,14 @@ static int __init corgits_probe(struct device *dev)
275 281
276 memset(corgi_ts, 0, sizeof(struct corgi_ts)); 282 memset(corgi_ts, 0, sizeof(struct corgi_ts));
277 283
284 corgi_ts->machinfo = dev->platform_data;
285 corgi_ts->irq_gpio = platform_get_irq(pdev, 0);
286
287 if (corgi_ts->irq_gpio < 0) {
288 kfree(corgi_ts);
289 return -ENODEV;
290 }
291
278 init_input_dev(&corgi_ts->input); 292 init_input_dev(&corgi_ts->input);
279 corgi_ts->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 293 corgi_ts->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
280 corgi_ts->input.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); 294 corgi_ts->input.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
@@ -293,8 +307,7 @@ static int __init corgits_probe(struct device *dev)
293 corgi_ts->input.id.product = 0x0002; 307 corgi_ts->input.id.product = 0x0002;
294 corgi_ts->input.id.version = 0x0100; 308 corgi_ts->input.id.version = 0x0100;
295 309
296 pxa_gpio_mode(CORGI_GPIO_TP_INT | GPIO_IN); 310 pxa_gpio_mode(IRQ_TO_GPIO(corgi_ts->irq_gpio) | GPIO_IN);
297 pxa_gpio_mode(CORGI_GPIO_HSYNC | GPIO_IN);
298 311
299 /* Initiaize ADS7846 Difference Reference mode */ 312 /* Initiaize ADS7846 Difference Reference mode */
300 corgi_ssp_ads7846_putget((1u << ADSCTRL_ADR_SH) | ADSCTRL_STS); 313 corgi_ssp_ads7846_putget((1u << ADSCTRL_ADR_SH) | ADSCTRL_STS);
@@ -313,14 +326,14 @@ static int __init corgits_probe(struct device *dev)
313 input_register_device(&corgi_ts->input); 326 input_register_device(&corgi_ts->input);
314 corgi_ts->power_mode = PWR_MODE_ACTIVE; 327 corgi_ts->power_mode = PWR_MODE_ACTIVE;
315 328
316 if (request_irq(CORGI_IRQ_GPIO_TP_INT, ts_interrupt, SA_INTERRUPT, "ts", corgi_ts)) { 329 if (request_irq(corgi_ts->irq_gpio, ts_interrupt, SA_INTERRUPT, "ts", corgi_ts)) {
317 input_unregister_device(&corgi_ts->input); 330 input_unregister_device(&corgi_ts->input);
318 kfree(corgi_ts); 331 kfree(corgi_ts);
319 return -EBUSY; 332 return -EBUSY;
320 } 333 }
321 334
322 /* Enable Falling Edge */ 335 /* Enable Falling Edge */
323 set_irq_type(CORGI_IRQ_GPIO_TP_INT, IRQT_FALLING); 336 set_irq_type(corgi_ts->irq_gpio, IRQT_FALLING);
324 337
325 printk(KERN_INFO "input: Corgi Touchscreen Registered\n"); 338 printk(KERN_INFO "input: Corgi Touchscreen Registered\n");
326 339
@@ -331,8 +344,9 @@ static int corgits_remove(struct device *dev)
331{ 344{
332 struct corgi_ts *corgi_ts = dev_get_drvdata(dev); 345 struct corgi_ts *corgi_ts = dev_get_drvdata(dev);
333 346
334 free_irq(CORGI_IRQ_GPIO_TP_INT, NULL); 347 free_irq(corgi_ts->irq_gpio, NULL);
335 del_timer_sync(&corgi_ts->timer); 348 del_timer_sync(&corgi_ts->timer);
349 corgi_ts->machinfo->put_hsync();
336 input_unregister_device(&corgi_ts->input); 350 input_unregister_device(&corgi_ts->input);
337 kfree(corgi_ts); 351 kfree(corgi_ts);
338 return 0; 352 return 0;