summaryrefslogtreecommitdiff
path: root/recipes/linux/linux-rp-2.6.23/tosa-lcdnoise-r1.patch
blob: 21f3cf66b10c417940aaab668c623dbb3576abe4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
From 564b757ba44b517ac6d693b94a177708bb5d3887 Mon Sep 17 00:00:00 2001
From: Dmitry Baryshkov <dbaryshkov@gmail.com>
Date: Fri, 19 Oct 2007 17:30:30 +0400
Subject: [PATCH] tosa-lcdnoise-r1.patch

---
 drivers/input/touchscreen/Kconfig   |   13 +++++
 drivers/input/touchscreen/Makefile  |    1 +
 drivers/input/touchscreen/tosa_ts.c |  102 +++++++++++++++++++++++++++++++++++
 3 files changed, 116 insertions(+), 0 deletions(-)

diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index 3ac01b4..6862e8f 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -219,6 +219,19 @@ config TOUCHSCREEN_USB_DMC_TSC10
 	bool "DMC TSC-10/25 device support" if EMBEDDED
 	depends on TOUCHSCREEN_USB_COMPOSITE
 
+config TOUCHSCREEN_TOSA
+    tristate "Sharp Tosa touchscreen driver"
+    depends on TOUCHSCREEN_WM97XX && MACH_TOSA
+    default n
+    help
+      Say Y here to enable the driver for the touchscreen on the
+      Sharp Tosa PDA.
+      depends on TOUCHSCREEN_WM97XX && MACH_TOSA
+      If unsure, say N.
+
+      To compile this driver as a module, choose M here: the
+      module will be called tosa_ts.
+
 config TOUCHSCREEN_TSC2101
 	tristate "TI TSC2101 touchscreen input driver"
 	depends on MACH_HX2750 && INPUT && INPUT_TOUCHSCREEN
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
index f64d1a5..4fc0e17 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -22,6 +22,7 @@ obj-$(CONFIG_TOUCHSCREEN_UCB1400)	+= ucb1400_ts.o
 obj-$(CONFIG_TOUCHSCREEN_TSC2101)	+= tsc2101_ts.o
 obj-$(CONFIG_TOUCHSCREEN_WM97XX)    	+= wm97xx-ts.o
 obj-$(CONFIG_TOUCHSCREEN_WM97XX_PXA)    += pxa-wm97xx.o
+obj-$(CONFIG_TOUCHSCREEN_TOSA)        	+= tosa_ts.o
 
 ifeq ($(CONFIG_TOUCHSCREEN_WM9713),y)
 wm97xx-ts-objs += wm9713.o
diff --git a/drivers/input/touchscreen/tosa_ts.c b/drivers/input/touchscreen/tosa_ts.c
new file mode 100644
index 0000000..bc733e9
--- /dev/null
+++ b/drivers/input/touchscreen/tosa_ts.c
@@ -0,0 +1,102 @@
+/*
+ * tosa_ts.c  --  Touchscreen driver for Sharp SL-6000 (Tosa).
+ *
+ * Copyright 2006 Wolfson Microelectronics PLC.
+ * Author: Mike Arthur
+ *         linux@wolfsonmicro.com
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ *  Revision history
+ *     1st Sep 2006  Initial version.
+ *
+ */
+
+#include <linux/wm97xx.h>
+#include <asm/arch/tosa.h>
+#include <asm/arch/hardware.h>
+#include <asm/arch/pxa-regs.h>
+
+/* Taken from the Sharp 2.4 kernel code */
+#define CCNT(a)     asm volatile ("mrc p14, 0, %0, C1, C1, 0" : "=r"(a))
+#define CCNT_ON()   asm("mcr p14, 0, %0, C0, C0, 0" : : "r"(1))
+#define CCNT_OFF()  asm("mcr p14, 0, %0, C0, C0, 0" : : "r"(1))
+
+static inline void tosa_lcd_wait_hsync(void)
+{
+	/* Waits for a rising edge on the VGA line */
+	while((GPLR(TOSA_GPIO_VGA_LINE) & GPIO_bit(TOSA_GPIO_VGA_LINE)) == 0);
+	while((GPLR(TOSA_GPIO_VGA_LINE) & GPIO_bit(TOSA_GPIO_VGA_LINE)) != 0);
+}
+
+/* On the Sharp SL-6000 (Tosa), due to a noisy LCD, we need to perform a wait
+ * before sampling the Y axis of the touchscreen */
+void tosa_lcd_sync_on(int adcsel) {
+	unsigned long timer1 = 0, timer2 = 0, wait_time = 0;
+	if (adcsel == WM97XX_ADCSEL_Y) {
+		wait_time = tosa_lcd_get_hsync_time();
+		CCNT_ON();
+
+		if (wait_time) {
+			/* wait for LCD rising edge */
+			tosa_lcd_wait_hsync();
+			/* get clock */
+			CCNT(timer1);
+			CCNT(timer2);
+
+			while ((timer2 - timer1) < wait_time) {
+				CCNT(timer2);
+			}
+		}
+	}
+}
+
+void tosa_lcd_sync_off(void) {
+	CCNT_OFF();
+}
+
+static struct wm97xx_mach_ops tosa_mach_ops = {
+	.pre_sample =  tosa_lcd_sync_on,
+	.post_sample = tosa_lcd_sync_off,
+};
+
+int tosa_ts_probe(struct device *dev) {
+	struct wm97xx *wm = dev->driver_data;
+	return wm97xx_register_mach_ops (wm, &tosa_mach_ops);
+}
+
+
+int tosa_ts_remove(struct device *dev) {
+	struct wm97xx *wm = dev->driver_data;
+	wm97xx_unregister_mach_ops (wm);
+	return 0;
+}
+
+static struct device_driver tosa_ts_driver = {
+	.name = "wm97xx-touchscreen",
+	.bus = &wm97xx_bus_type,
+	.owner = THIS_MODULE,
+	.probe = tosa_ts_probe,
+	.remove = tosa_ts_remove,
+};
+
+static int __init tosa_ts_init(void)
+{
+	return driver_register(&tosa_ts_driver);
+}
+
+static void __exit tosa_ts_exit(void)
+{
+	driver_unregister(&tosa_ts_driver);
+}
+
+module_init(tosa_ts_init);
+module_exit(tosa_ts_exit);
+
+/* Module information */
+MODULE_AUTHOR("Mike Arthur, mike@mikearthur.co.uk, www.wolfsonmicro.com");
+MODULE_DESCRIPTION("Sharp SL6000 Tosa Touch Screen Driver");
+MODULE_LICENSE("GPL");
-- 
1.4.4.4