summaryrefslogtreecommitdiff
path: root/packages/linux/openzaurus-pxa-2.4.18-rmk7-pxa3-embedix20031107/tosa_ts.patch
blob: 678cb2e25b67eb9ac7eb56183e9469dbaab44332 (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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207

#
# Patch managed by http://www.holgerschurig.de/patcher.html
#

--- linux/drivers/char/tosa_ts.c~tosa_ts.patch
+++ linux/drivers/char/tosa_ts.c
@@ -102,6 +102,8 @@
 static int head = 0, tail = 0;
 
 #ifdef CONFIG_PM
+#include <linux/pm.h>
+static struct pm_dev* tosa_ts_pm_dev;
 static int tp_suspend = 0;
 #endif	/* CONFIG_PM */
 
@@ -495,25 +497,6 @@
 	ioctl:		ts_ioctl,
 };
 
-static void ts_exit(void)
-{
-  ts_timer_clear();
-  ts_clear();
-  free_irq(IRQ_GPIO_TP_INT, NULL);
-  wm9712_power_mode_ts(WM9712_PWR_OFF);
-  
-  pxa_ac97_put(&ac97_on);
-}
-
-#ifdef MODULE
-static void __exit ac97_ts_cleanup(void)
-{
-  ts_exit();
-  unregister_chrdev(TS_MAJOR, "ts");
-}
-module_exit(ac97_ts_cleanup);
-#endif	/* MODULE */
-
 extern int tc6393fb_lcdMode;
 
 int ac97_ad_input(int ch, unsigned short *dat)
@@ -608,7 +591,7 @@
 #endif
 }
 
-static int ts_init(void)
+static int tosa_ts_hardware_start(void)
 {
   pxa_ac97_get(&codec, &ac97_on);
 
@@ -625,7 +608,6 @@
   /* GPIO3/PENDOWN wakeup */
   ac97_bit_set(AC97_GPIO_WAKE_UP, CODEC_PENDOWN);
 
-  ts_clear();
 
   /* Init queue */
  //X	kernel_thread(ts_pendown, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND | SIGCHLD);
@@ -639,12 +621,39 @@
     return -EBUSY;
   }
 
-  //  printk(KERN_INFO "Tosa Touch Screen driver initialized\n");
-
   return 0;
 }
 
-static int __init ac97_ts_init(void)
+static void tosa_ts_hardware_stop(void)
+{
+  ts_timer_clear();
+  ts_clear();
+  free_irq(IRQ_GPIO_TP_INT, NULL);
+  wm9712_power_mode_ts(WM9712_PWR_OFF);
+  
+  pxa_ac97_put(&ac97_on);
+}
+
+#ifdef CONFIG_PM
+static int tosa_ts_pm_callback(struct pm_dev *pm_dev,
+                                  pm_request_t req, void *data)
+{
+        switch (req) {
+        case PM_SUSPEND:
+                tp_suspend = 1;
+                tosa_ts_hardware_stop();
+		break;
+        case PM_RESUME:
+                tp_suspend = 0;
+                tosa_ts_hardware_start();
+                break;
+        }
+        return 0;
+}
+#endif
+
+
+static int __init tosa_ts_init(void)
 {
   ac97_on = 0;
 
@@ -663,28 +672,37 @@
   
   if( register_chrdev(TS_MAJOR,DEV_NAME, &ts_fops) ) {
     printk("unable to get major %d for touch screen\n", TS_MAJOR);
-    ts_exit();
   }
 
   init_procinfo();
 
+  tosa_ts_hardware_start();
+
+#ifdef CONFIG_PM
+  tosa_ts_pm_dev = pm_register(PM_SYS_DEV, 0, tosa_ts_pm_callback);
+#endif
+
   kernel_thread(ts_pendown, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND | SIGCHLD);
 
   return 0;
 }
 
-module_init(ac97_ts_init);
+static int __exit tosa_ts_cleanup()
+{
+  tosa_hardware_stop();
+  pm_unregister(tosa_ts_pm_dev);
+  unregister_chrdev(TS_MAJOR, "ts");
+}
+
+module_init(tosa_ts_init);
+module_exit(tosa_ts_cleanup);
 
 /*
  * Driver functions
  */
 static int ts_open(struct inode *inode, struct file *file)
 {
-  if( ts_init() < 0 ) {
-    ts_exit();
-    return -EINVAL;
-  }
-
+  ts_clear();
   MOD_INC_USE_COUNT;
   return 0;
 }
@@ -692,7 +710,6 @@
 
 static int ts_release(struct inode *inode, struct file *file)
 {
-  ts_exit();
 
   MOD_DEC_USE_COUNT;
   return 0;
@@ -788,20 +805,3 @@
   return 0;
 }
 
-#ifdef CONFIG_PM
-void tosa_ts_suspend(void)
-{
-  DEBUG(DBG_L1, "in\n");
-  tp_suspend = 1;
-  ts_exit();
-  DEBUG(DBG_L1, "out\n");
-}
-
-void tosa_ts_resume(void)
-{
-  DEBUG(DBG_L1, "in\n");
-  tp_suspend = 0;
-  ts_init();
-  DEBUG(DBG_L1, "out\n");
-}
-#endif	/* CONFIG_PM */
--- linux/drivers/sound/pxa-ac97_tosa.c~tosa_ts.patch
+++ linux/drivers/sound/pxa-ac97_tosa.c
@@ -90,8 +90,6 @@
 #include <linux/pm.h>
 static struct pm_dev* pxa_sound_pm_dev;
 static int tosa_pm_callback(struct pm_dev *,pm_request_t, void *);
-extern void tosa_ts_suspend(void);
-extern void tosa_ts_resume(void);
 #endif	/* CONFIG_PM */
 
 /************************************************************
@@ -2195,9 +2193,6 @@
   case PM_SUSPEND:
     DEBUG(DBG_L1, "PM_SUSPEND: start\n");
     wm9712_suspend();
-#ifdef CONFIG_TOSA_TS
-    tosa_ts_suspend();
-#endif	/* CONFIG_TOSA_TS */
     if ( ac97_audio_state.rd_ref != 0 ) {
       audio_clear_buf(ac97_audio_state.input_stream);
       *ac97_audio_state.input_stream->drcmr = 0;
@@ -2239,9 +2234,6 @@
       ac97_audio_state.input_stream->dma_ch = err;
     }
     wm9712_resume();
-#ifdef CONFIG_TOSA_TS
-    tosa_ts_resume();
-#endif	/* CONFIG_TOSA_TS */
     DEBUG(DBG_L1, "PM_RESUME: done\n");
     break;
   }