1 Index: linux-2.6.19/arch/arm/mach-s3c2410/devs.c
2 ===================================================================
3 --- linux-2.6.19.orig/arch/arm/mach-s3c2410/devs.c
4 +++ linux-2.6.19/arch/arm/mach-s3c2410/devs.c
6 #include <asm/hardware.h>
9 +#include <asm/arch/ts.h>
11 #include <asm/arch/regs-serial.h>
13 @@ -204,6 +205,23 @@ struct platform_device s3c_device_nand =
15 EXPORT_SYMBOL(s3c_device_nand);
18 +struct platform_device s3c_device_ts = {
19 + .name = "s3c2410-ts",
23 +EXPORT_SYMBOL(s3c_device_ts);
25 +static struct s3c2410_ts_mach_info s3c2410ts_info;
27 +void __init set_s3c2410ts_info(struct s3c2410_ts_mach_info *hard_s3c2410ts_info)
29 + memcpy(&s3c2410ts_info,hard_s3c2410ts_info,sizeof(struct s3c2410_ts_mach_info));
30 + s3c_device_ts.dev.platform_data = &s3c2410ts_info;
32 +EXPORT_SYMBOL(set_s3c2410ts_info);
34 /* USB Device (Gadget)*/
36 static struct resource s3c_usbgadget_resource[] = {
37 Index: linux-2.6.19/arch/arm/mach-s3c2410/devs.h
38 ===================================================================
39 --- linux-2.6.19.orig/arch/arm/mach-s3c2410/devs.h
40 +++ linux-2.6.19/arch/arm/mach-s3c2410/devs.h
41 @@ -41,6 +41,7 @@ extern struct platform_device s3c_device
42 extern struct platform_device s3c_device_timer3;
44 extern struct platform_device s3c_device_usbgadget;
45 +extern struct platform_device s3c_device_ts;
47 /* s3c2440 specific devices */
49 Index: linux-2.6.19/drivers/input/touchscreen/Kconfig
50 ===================================================================
51 --- linux-2.6.19.orig/drivers/input/touchscreen/Kconfig
52 +++ linux-2.6.19/drivers/input/touchscreen/Kconfig
53 @@ -49,6 +49,24 @@ config TOUCHSCREEN_CORGI
54 To compile this driver as a module, choose M here: the
55 module will be called corgi_ts.
57 +config TOUCHSCREEN_S3C2410
58 + tristate "Samsung S3C2410 touchscreen input driver"
59 + depends on ARCH_S3C2410 && INPUT && INPUT_TOUCHSCREEN
62 + Say Y here if you have the s3c2410 touchscreen.
66 + To compile this driver as a module, choose M here: the
67 + module will be called s3c2410_ts.
69 +config TOUCHSCREEN_S3C2410_DEBUG
70 + boolean "Samsung S3C2410 touchscreen debug messages"
71 + depends on TOUCHSCREEN_S3C2410
73 + Select this if you want debug messages
75 config TOUCHSCREEN_GUNZE
76 tristate "Gunze AHL-51S touchscreen"
78 Index: linux-2.6.19/drivers/input/touchscreen/Makefile
79 ===================================================================
80 --- linux-2.6.19.orig/drivers/input/touchscreen/Makefile
81 +++ linux-2.6.19/drivers/input/touchscreen/Makefile
82 @@ -15,3 +15,5 @@ obj-$(CONFIG_TOUCHSCREEN_HP600) += hp680
83 obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o
84 obj-$(CONFIG_TOUCHSCREEN_TOUCHRIGHT) += touchright.o
85 obj-$(CONFIG_TOUCHSCREEN_TOUCHWIN) += touchwin.o
86 +obj-$(CONFIG_TOUCHSCREEN_S3C2410) += s3c2410_ts.o
88 Index: linux-2.6.19/drivers/input/touchscreen/s3c2410_ts.c
89 ===================================================================
91 +++ linux-2.6.19/drivers/input/touchscreen/s3c2410_ts.c
94 + * This program is free software; you can redistribute it and/or modify
95 + * it under the terms of the GNU General Public License as published by
96 + * the Free Software Foundation; either version 2 of the License, or
97 + * (at your option) any later version.
99 + * This program is distributed in the hope that it will be useful,
100 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
101 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
102 + * GNU General Public License for more details.
104 + * You should have received a copy of the GNU General Public License
105 + * along with this program; if not, write to the Free Software
106 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
108 + * Copyright (c) 2004 Arnaud Patard <arnaud.patard@rtp-net.org>
109 + * iPAQ H1940 touchscreen support
113 + * 2004-09-05: Herbert Pƶtzl <herbert@13thfloor.at>
114 + * - added clock (de-)allocation code
116 + * 2005-03-06: Arnaud Patard <arnaud.patard@rtp-net.org>
117 + * - h1940_ -> s3c2410 (this driver is now also used on the n30
119 + * - Debug messages are now enabled with the config option
120 + * TOUCHSCREEN_S3C2410_DEBUG
121 + * - Changed the way the value are read
122 + * - Input subsystem should now work
123 + * - Use ioremap and readl/writel
125 + * 2005-03-23: Arnaud Patard <arnaud.patard@rtp-net.org>
126 + * - Make use of some undocumented features of the touchscreen
131 +#include <linux/errno.h>
132 +#include <linux/kernel.h>
133 +#include <linux/module.h>
134 +#include <linux/slab.h>
135 +#include <linux/input.h>
136 +#include <linux/init.h>
137 +#include <linux/serio.h>
138 +#include <linux/delay.h>
139 +#include <linux/platform_device.h>
140 +#include <linux/clk.h>
142 +#include <asm/irq.h>
144 +#include <asm/arch/regs-adc.h>
145 +#include <asm/arch/regs-gpio.h>
146 +#include <asm/arch/ts.h>
148 +/* For ts.dev.id.version */
149 +#define S3C2410TSVERSION 0x0101
151 +#define WAIT4INT(x) (((x)<<8) | \
152 + S3C2410_ADCTSC_YM_SEN | S3C2410_ADCTSC_YP_SEN | S3C2410_ADCTSC_XP_SEN | \
153 + S3C2410_ADCTSC_XY_PST(3))
155 +#define AUTOPST (S3C2410_ADCTSC_YM_SEN | S3C2410_ADCTSC_YP_SEN | S3C2410_ADCTSC_XP_SEN | \
156 + S3C2410_ADCTSC_AUTO_PST | S3C2410_ADCTSC_XY_PST(0))
158 +#define DEBUG_LVL KERN_DEBUG
160 +MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>");
161 +MODULE_DESCRIPTION("s3c2410 touchscreen driver");
162 +MODULE_LICENSE("GPL");
165 + * Definitions & global arrays.
169 +static char *s3c2410ts_name = "s3c2410 TouchScreen";
172 + * Per-touchscreen data.
176 + struct input_dev *dev;
183 +static struct s3c2410ts ts;
184 +static void __iomem *base_addr;
186 +static inline void s3c2410_ts_connect(void)
188 + s3c2410_gpio_cfgpin(S3C2410_GPG12, S3C2410_GPG12_XMON);
189 + s3c2410_gpio_cfgpin(S3C2410_GPG13, S3C2410_GPG13_nXPON);
190 + s3c2410_gpio_cfgpin(S3C2410_GPG14, S3C2410_GPG14_YMON);
191 + s3c2410_gpio_cfgpin(S3C2410_GPG15, S3C2410_GPG15_nYPON);
194 +static void touch_timer_fire(unsigned long data)
196 + unsigned long data0;
197 + unsigned long data1;
200 + data0 = readl(base_addr+S3C2410_ADCDAT0);
201 + data1 = readl(base_addr+S3C2410_ADCDAT1);
203 + updown = (!(data0 & S3C2410_ADCDAT0_UPDOWN)) && (!(data1 & S3C2410_ADCDAT0_UPDOWN));
206 + if (ts.count != 0) {
207 + ts.xp >>= ts.shift;
208 + ts.yp >>= ts.shift;
210 +#ifdef CONFIG_TOUCHSCREEN_S3C2410_DEBUG
213 + do_gettimeofday(&tv);
214 + printk(DEBUG_LVL "T: %06d, X: %03ld, Y: %03ld\n", (int)tv.tv_usec, ts.xp, ts.yp);
218 + input_report_abs(ts.dev, ABS_X, ts.xp);
219 + input_report_abs(ts.dev, ABS_Y, ts.yp);
221 + input_report_key(ts.dev, BTN_TOUCH, 1);
222 + input_report_abs(ts.dev, ABS_PRESSURE, 1);
223 + input_sync(ts.dev);
230 + writel(S3C2410_ADCTSC_PULL_UP_DISABLE | AUTOPST, base_addr+S3C2410_ADCTSC);
231 + writel(readl(base_addr+S3C2410_ADCCON) | S3C2410_ADCCON_ENABLE_START, base_addr+S3C2410_ADCCON);
235 + input_report_key(ts.dev, BTN_TOUCH, 0);
236 + input_report_abs(ts.dev, ABS_PRESSURE, 0);
237 + input_sync(ts.dev);
239 + writel(WAIT4INT(0), base_addr+S3C2410_ADCTSC);
243 +static struct timer_list touch_timer =
244 + TIMER_INITIALIZER(touch_timer_fire, 0, 0);
246 +static irqreturn_t stylus_updown(int irq, void *dev_id, struct pt_regs *regs)
248 + unsigned long data0;
249 + unsigned long data1;
252 + data0 = readl(base_addr+S3C2410_ADCDAT0);
253 + data1 = readl(base_addr+S3C2410_ADCDAT1);
255 + updown = (!(data0 & S3C2410_ADCDAT0_UPDOWN)) && (!(data1 & S3C2410_ADCDAT0_UPDOWN));
257 + /* TODO we should never get an interrupt with updown set while
258 + * the timer is running, but maybe we ought to verify that the
259 + * timer isn't running anyways. */
262 + touch_timer_fire(0);
264 + return IRQ_HANDLED;
268 +static irqreturn_t stylus_action(int irq, void *dev_id, struct pt_regs *regs)
270 + unsigned long data0;
271 + unsigned long data1;
273 + data0 = readl(base_addr+S3C2410_ADCDAT0);
274 + data1 = readl(base_addr+S3C2410_ADCDAT1);
276 + ts.xp += data0 & S3C2410_ADCDAT0_XPDATA_MASK;
277 + ts.yp += data1 & S3C2410_ADCDAT1_YPDATA_MASK;
280 + if (ts.count < (1<<ts.shift)) {
281 + writel(S3C2410_ADCTSC_PULL_UP_DISABLE | AUTOPST, base_addr+S3C2410_ADCTSC);
282 + writel(readl(base_addr+S3C2410_ADCCON) | S3C2410_ADCCON_ENABLE_START, base_addr+S3C2410_ADCCON);
284 + mod_timer(&touch_timer, jiffies+1);
285 + writel(WAIT4INT(1), base_addr+S3C2410_ADCTSC);
288 + return IRQ_HANDLED;
291 +static struct clk *adc_clock;
294 + * The functions for inserting/removing us as a module.
297 +static int __init s3c2410ts_probe(struct platform_device *pdev)
299 + struct s3c2410_ts_mach_info *info;
300 + struct input_dev *input_dev;
302 + info = ( struct s3c2410_ts_mach_info *)pdev->dev.platform_data;
306 + printk(KERN_ERR "Hm... too bad : no platform data for ts\n");
310 +#ifdef CONFIG_TOUCHSCREEN_S3C2410_DEBUG
311 + printk(DEBUG_LVL "Entering s3c2410ts_init\n");
314 + adc_clock = clk_get(NULL, "adc");
316 + printk(KERN_ERR "failed to get adc clock source\n");
319 + clk_enable(adc_clock);
321 +#ifdef CONFIG_TOUCHSCREEN_S3C2410_DEBUG
322 + printk(DEBUG_LVL "got and enabled clock\n");
325 + base_addr=ioremap(S3C2410_PA_ADC,0x20);
326 + if (base_addr == NULL) {
327 + printk(KERN_ERR "Failed to remap register block\n");
332 + /* Configure GPIOs */
333 + s3c2410_ts_connect();
335 + if ((info->presc&0xff) > 0)
336 + writel(S3C2410_ADCCON_PRSCEN | S3C2410_ADCCON_PRSCVL(info->presc&0xFF),\
337 + base_addr+S3C2410_ADCCON);
339 + writel(0,base_addr+S3C2410_ADCCON);
342 + /* Initialise registers */
343 + if ((info->delay&0xffff) > 0)
344 + writel(info->delay & 0xffff, base_addr+S3C2410_ADCDLY);
346 + writel(WAIT4INT(0), base_addr+S3C2410_ADCTSC);
348 + /* Initialise input stuff */
349 + memset(&ts, 0, sizeof(struct s3c2410ts));
350 + input_dev = input_allocate_device();
353 + printk(KERN_ERR "Unable to allocate the input device !!\n");
357 + ts.dev = input_dev;
358 + ts.dev->evbit[0] = BIT(EV_SYN) | BIT(EV_KEY) | BIT(EV_ABS);
359 + ts.dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
360 + input_set_abs_params(ts.dev, ABS_X, 0, 0x3FF, 0, 0);
361 + input_set_abs_params(ts.dev, ABS_Y, 0, 0x3FF, 0, 0);
362 + input_set_abs_params(ts.dev, ABS_PRESSURE, 0, 1, 0, 0);
364 + ts.dev->private = &ts;
365 + ts.dev->name = s3c2410ts_name;
366 + ts.dev->id.bustype = BUS_RS232;
367 + ts.dev->id.vendor = 0xDEAD;
368 + ts.dev->id.product = 0xBEEF;
369 + ts.dev->id.version = S3C2410TSVERSION;
371 + ts.shift = info->oversampling_shift;
374 + if (request_irq(IRQ_ADC, stylus_action, SA_SAMPLE_RANDOM,
375 + "s3c2410_action", ts.dev)) {
376 + printk(KERN_ERR "s3c2410_ts.c: Could not allocate ts IRQ_ADC !\n");
377 + iounmap(base_addr);
380 + if (request_irq(IRQ_TC, stylus_updown, SA_SAMPLE_RANDOM,
381 + "s3c2410_action", ts.dev)) {
382 + printk(KERN_ERR "s3c2410_ts.c: Could not allocate ts IRQ_TC !\n");
383 + iounmap(base_addr);
387 + printk(KERN_INFO "%s successfully loaded\n", s3c2410ts_name);
389 + /* All went ok, so register to the input system */
390 + input_register_device(ts.dev);
395 +static int s3c2410ts_remove(struct platform_device *pdev)
397 + disable_irq(IRQ_ADC);
398 + disable_irq(IRQ_TC);
399 + free_irq(IRQ_TC,ts.dev);
400 + free_irq(IRQ_ADC,ts.dev);
403 + clk_disable(adc_clock);
404 + clk_put(adc_clock);
408 + input_unregister_device(ts.dev);
409 + iounmap(base_addr);
414 +static struct platform_driver s3c2410ts_driver = {
416 + .name = "s3c2410-ts",
417 + .owner = THIS_MODULE,
419 + .probe = s3c2410ts_probe,
420 + .remove = s3c2410ts_remove,
424 +static int __init s3c2410ts_init(void)
426 + return platform_driver_register(&s3c2410ts_driver);
429 +static void __exit s3c2410ts_exit(void)
431 + platform_driver_unregister(&s3c2410ts_driver);
434 +module_init(s3c2410ts_init);
435 +module_exit(s3c2410ts_exit);
439 + compile-command: "make ARCH=arm CROSS_COMPILE=/usr/local/arm/3.3.2/bin/arm-linux- -k -C ../../.."
443 Index: linux-2.6.19/include/asm-arm/arch-s3c2410/regs-adc.h
444 ===================================================================
445 --- linux-2.6.19.orig/include/asm-arm/arch-s3c2410/regs-adc.h
446 +++ linux-2.6.19/include/asm-arm/arch-s3c2410/regs-adc.h
448 #define S3C2410_ADCTSC_XP_SEN (1<<4)
449 #define S3C2410_ADCTSC_PULL_UP_DISABLE (1<<3)
450 #define S3C2410_ADCTSC_AUTO_PST (1<<2)
451 -#define S3C2410_ADCTSC_XY_PST (0x3<<0)
452 +#define S3C2410_ADCTSC_XY_PST(x) (((x)&0x3)<<0)
455 #define S3C2410_ADCDAT0_UPDOWN (1<<15)
456 Index: linux-2.6.19/include/asm-arm/arch-s3c2410/ts.h
457 ===================================================================
459 +++ linux-2.6.19/include/asm-arm/arch-s3c2410/ts.h
461 +/* linux/include/asm/arch-s3c2410/ts.h
463 + * Copyright (c) 2005 Arnaud Patard <arnaud.patard@rtp-net.org>
466 + * This program is free software; you can redistribute it and/or modify
467 + * it under the terms of the GNU General Public License version 2 as
468 + * published by the Free Software Foundation.
472 + * 24-Mar-2005 RTP Created file
473 + * 03-Aug-2005 RTP Renamed to ts.h
476 +#ifndef __ASM_ARM_TS_H
477 +#define __ASM_ARM_TS_H
479 +struct s3c2410_ts_mach_info {
482 + int oversampling_shift;
485 +void __init set_s3c2410ts_info(struct s3c2410_ts_mach_info *hard_s3c2410ts_info);
487 +#endif /* __ASM_ARM_TS_H */
489 Index: linux-2.6.19/arch/arm/mach-s3c2410/mach-smdk2440.c
490 ===================================================================
491 --- linux-2.6.19.orig/arch/arm/mach-s3c2410/mach-smdk2440.c
492 +++ linux-2.6.19/arch/arm/mach-s3c2410/mach-smdk2440.c
494 #include <asm/arch/regs-serial.h>
495 #include <asm/arch/regs-gpio.h>
496 #include <asm/arch/regs-lcd.h>
497 +#include <asm/arch/ts.h>
499 #include <asm/arch/idle.h>
500 #include <asm/arch/fb.h>
501 @@ -177,6 +178,7 @@ static struct platform_device *smdk2440_
508 static struct s3c24xx_board smdk2440_board __initdata = {
509 @@ -184,6 +186,12 @@ static struct s3c24xx_board smdk2440_boa
510 .devices_count = ARRAY_SIZE(smdk2440_devices)
513 +static struct s3c2410_ts_mach_info qt2410_ts_cfg = {
516 + .oversampling_shift = 2,
519 static void __init smdk2440_map_io(void)
521 s3c24xx_init_io(smdk2440_iodesc, ARRAY_SIZE(smdk2440_iodesc));
522 @@ -195,6 +203,7 @@ static void __init smdk2440_map_io(void)
523 static void __init smdk2440_machine_init(void)
525 s3c24xx_fb_set_platdata(&smdk2440_lcd_cfg);
526 + set_s3c2410ts_info(&qt2410_ts_cfg);