[ar71xx] preliminary support for the Ubiquiti RouterStation Pro
[openwrt.git] / target / linux / s3c24xx / patches-2.6.24 / 1089-debug-suspend-dump-gpio-states-add-GPA.patch.patch
1 From 475826b7d7ef66e80b64d97ea9e8aca56d97e313 Mon Sep 17 00:00:00 2001
2 From: Andy Green <andy@openmoko.com>
3 Date: Sun, 13 Apr 2008 07:25:49 +0100
4 Subject: [PATCH] debug-suspend-dump-gpio-states-add-GPA.patch
5
6 Add support for GPA[] GPIO bus since we have some NCs
7 but they seem to output-only IO cells so no matter
8
9 Signed-off-by: Andy Green <andy@openmoko.com>
10 ---
11 arch/arm/plat-s3c24xx/gpio.c | 420 ++++++++++++++++++++++++++++++++++++++++++
12 1 files changed, 420 insertions(+), 0 deletions(-)
13
14 diff --git a/arch/arm/plat-s3c24xx/gpio.c b/arch/arm/plat-s3c24xx/gpio.c
15 index ec3a09c..7cab212 100644
16 --- a/arch/arm/plat-s3c24xx/gpio.c
17 +++ b/arch/arm/plat-s3c24xx/gpio.c
18 @@ -32,6 +32,7 @@
19 #include <asm/io.h>
20
21 #include <asm/arch/regs-gpio.h>
22 +#include <asm/arch/regs-gpioj.h>
23
24 void s3c2410_gpio_cfgpin(unsigned int pin, unsigned int function)
25 {
26 @@ -186,3 +187,422 @@ int s3c2410_gpio_getirq(unsigned int pin)
27 }
28
29 EXPORT_SYMBOL(s3c2410_gpio_getirq);
30 +
31 +static void pretty_dump(u32 cfg, u32 state, u32 pull,
32 + const char ** function_names_2,
33 + const char ** function_names_3,
34 + const char * prefix,
35 + int count)
36 +{
37 + int n;
38 + const char *tag_type = NULL,
39 + *tag_state = NULL,
40 + *tag_pulldown = NULL,
41 + * level0 = "0",
42 + * level1 = "1";
43 +
44 + for (n = 0; n < count; n++) {
45 + switch ((cfg >> (2 * n)) & 3) {
46 + case 0:
47 + tag_type = "input ";
48 + break;
49 + case 1:
50 + tag_type = "OUTPUT ";
51 + break;
52 + case 2:
53 + if (function_names_2) {
54 + if (function_names_2[n])
55 + tag_type = function_names_2[n];
56 + else
57 + tag_type = "*** ILLEGAL CFG (2) *** ";
58 + } else
59 + tag_type = "(function) ";
60 + break;
61 + default:
62 + if (function_names_3) {
63 + if (function_names_3[n])
64 + tag_type = function_names_3[n];
65 + else
66 + tag_type = "*** ILLEGAL CFG (3) *** ";
67 + } else
68 + tag_type = "(function) ";
69 + break;
70 + }
71 + if ((state >> n) & 1)
72 + tag_state = level1;
73 + else
74 + tag_state = level0;
75 +
76 + if (((pull >> n) & 1))
77 + tag_pulldown = "";
78 + else
79 + tag_pulldown = "(pulldown)";
80 +
81 + printk(KERN_INFO"%s%02d: %s %s %s\n", prefix, n, tag_type,
82 + tag_state, tag_pulldown);
83 + }
84 + printk(KERN_INFO"\n");
85 +}
86 +
87 +static void pretty_dump_a(u32 cfg, u32 state,
88 + const char ** function_names,
89 + const char * prefix,
90 + int count)
91 +{
92 + int n;
93 + const char *tag_type = NULL,
94 + *tag_state = NULL,
95 + * level0 = "0",
96 + * level1 = "1";
97 +
98 + for (n = 0; n < count; n++) {
99 + switch ((cfg >> n) & 1) {
100 + case 0:
101 + tag_type = "OUTPUT ";
102 + break;
103 + default:
104 + if (function_names) {
105 + if (function_names[n])
106 + tag_type = function_names[n];
107 + else
108 + tag_type = "*** ILLEGAL CFG *** ";
109 + } else
110 + tag_type = "(function) ";
111 + break;
112 + }
113 + if ((state >> n) & 1)
114 + tag_state = level1;
115 + else
116 + tag_state = level0;
117 +
118 + printk(KERN_INFO"%s%02d: %s %s\n", prefix, n, tag_type,
119 + tag_state);
120 + }
121 + printk(KERN_INFO"\n");
122 +}
123 +
124 +static const char * funcs_a[] = {
125 + "ADDR0 ",
126 + "ADDR16 ",
127 + "ADDR17 ",
128 + "ADDR18 ",
129 + "ADDR19 ",
130 + "ADDR20 ",
131 + "ADDR21 ",
132 + "ADDR22 ",
133 + "ADDR23 ",
134 + "ADDR24 ",
135 + "ADDR25 ",
136 + "ADDR26 ",
137 + "nGCS[1] ",
138 + "nGCS[2] ",
139 + "nGCS[3] ",
140 + "nGCS[4] ",
141 + "nGCS[5] ",
142 + "CLE ",
143 + "ALE ",
144 + "nFWE ",
145 + "nFRE ",
146 + "nRSTOUT ",
147 + "nFCE ",
148 + NULL,
149 + NULL
150 +};
151 +
152 +
153 +static const char * funcs_b2[] = {
154 + "TOUT0 ",
155 + "TOUT1 ",
156 + "TOUT2 ",
157 + "TOUT3 ",
158 + "TCLK[0] ",
159 + "nXBACK ",
160 + "nXBREQ ",
161 + "nXDACK1 ",
162 + "nXDREQ1 ",
163 + "nXDACK0 ",
164 + "nXDREQ0 ",
165 +};
166 +static const char * funcs_b3[] = {
167 + NULL,
168 + NULL,
169 + NULL,
170 + NULL,
171 + NULL,
172 + NULL,
173 + NULL,
174 + NULL,
175 + NULL,
176 + NULL,
177 + NULL,
178 +};
179 +
180 +static const char * funcs_c2[] = {
181 + "LEND ",
182 + "VCLK ",
183 + "VLINE ",
184 + "VFRAME ",
185 + "VM ",
186 + "LCD_LPCOE ",
187 + "LCD_LPCREV ",
188 + "LCD_LPCREVB",
189 + "VD[0] ",
190 + "VD[1] ",
191 + "VD[2] ",
192 + "VD[3] ",
193 + "VD[4] ",
194 + "VD[5] ",
195 + "VD[6] ",
196 + "VD[7] ",
197 +};
198 +static const char * funcs_c3[] = {
199 + NULL,
200 + NULL,
201 + NULL,
202 + NULL,
203 + "I2SSDI ",
204 + NULL,
205 + NULL,
206 + NULL,
207 + NULL,
208 + NULL,
209 + NULL,
210 + NULL,
211 + NULL,
212 + NULL,
213 + NULL,
214 + NULL,
215 +};
216 +
217 +static const char * funcs_d2[] = {
218 + "VD[8] ",
219 + "VD[9] ",
220 + "VD[10] ",
221 + "VD[11] ",
222 + "VD[12] ",
223 + "VD[13] ",
224 + "VD[14] ",
225 + "VD[15] ",
226 + "VD[16] ",
227 + "VD[17] ",
228 + "VD[18] ",
229 + "VD[19] ",
230 + "VD[20] ",
231 + "VD[21] ",
232 + "VD[22] ",
233 + "VD[23] ",
234 +};
235 +static const char * funcs_d3[] = {
236 + "nSPICS1 ",
237 + "SPICLK1 ",
238 + NULL,
239 + NULL,
240 + NULL,
241 + NULL,
242 + NULL,
243 + NULL,
244 + "SPIMISO1 ",
245 + "SPIMOSI1 ",
246 + "SPICLK1 ",
247 + NULL,
248 + NULL,
249 + NULL,
250 + "nSS1 ",
251 + "nSS0 ",
252 +};
253 +
254 +static const char * funcs_e2[] = {
255 + "I2SLRCK ",
256 + "I2SSCLK ",
257 + "CDCLK ",
258 + "I2SDI ",
259 + "I2SDO ",
260 + "SDCLK ",
261 + "SDCMD ",
262 + "SDDAT0 ",
263 + "SDDAT1 ",
264 + "SDDAT2 ",
265 + "SDDAT3 ",
266 + "SPIMISO0 ",
267 + "SPIMOSI0 ",
268 + "SPICLK0 ",
269 + "IICSCL ",
270 + "IICSDA ",
271 +};
272 +static const char * funcs_e3[] = {
273 + NULL,
274 + NULL,
275 + NULL,
276 + NULL,
277 + NULL,
278 + NULL,
279 + NULL,
280 + NULL,
281 + NULL,
282 + NULL,
283 + NULL,
284 + NULL,
285 + NULL,
286 + NULL,
287 + NULL,
288 + NULL,
289 +};
290 +
291 +static const char * funcs_f2[] = {
292 + "EINT[0] ",
293 + "EINT[1] ",
294 + "EINT[2] ",
295 + "EINT[3] ",
296 + "EINT[4] ",
297 + "EINT[5] ",
298 + "EINT[6] ",
299 + "EINT[7] ",
300 +};
301 +static const char * funcs_f3[] = {
302 + NULL,
303 + NULL,
304 + NULL,
305 + NULL,
306 + NULL,
307 + NULL,
308 + NULL,
309 + NULL,
310 +};
311 +
312 +
313 +static const char * funcs_g2[] = {
314 + "EINT[8] ",
315 + "EINT[9] ",
316 + "EINT[10] ",
317 + "EINT[11] ",
318 + "EINT[12] ",
319 + "EINT[13] ",
320 + "EINT[14] ",
321 + "EINT[15] ",
322 + "EINT[16] ",
323 + "EINT[17] ",
324 + "EINT[18] ",
325 + "EINT[19] ",
326 + "EINT[20] ",
327 + "EINT[21] ",
328 + "EINT[22] ",
329 + "EINT[23] ",
330 +};
331 +static const char * funcs_g3[] = {
332 + NULL,
333 + NULL,
334 + "nSS0 ",
335 + "nSS1 ",
336 + "LCD_PWRDN ",
337 + "SPIMISO1 ",
338 + "SPIMOSI1 ",
339 + "SPICLK1 ",
340 + NULL,
341 + "nRTS1 ",
342 + "nCTS1 ",
343 + "TCLK[1] ",
344 + "nSPICS0 ",
345 + NULL,
346 + NULL,
347 + NULL,
348 +};
349 +
350 +static const char * funcs_h2[] = {
351 + "nCTS0 ",
352 + "nRTS0 ",
353 + "TXD[0] ",
354 + "RXD[0] ",
355 + "TXD[1] ",
356 + "RXD[1] ",
357 + "TXD[2] ",
358 + "RXD[2] ",
359 + "UEXTCLK ",
360 + "CLKOUT0 ",
361 + "CLKOUT1 ",
362 +};
363 +static const char * funcs_h3[] = {
364 + NULL,
365 + NULL,
366 + NULL,
367 + NULL,
368 + NULL,
369 + NULL,
370 + "nRTS1 ",
371 + "nCTS1 ",
372 + NULL,
373 + "nSPICS0 ",
374 + NULL,
375 +};
376 +
377 +static const char * funcs_j2[] = {
378 + "CAMDATA[0] ",
379 + "CAMDATA[1] ",
380 + "CAMDATA[2] ",
381 + "CAMDATA[3] ",
382 + "CAMDATA[4] ",
383 + "CAMDATA[5] ",
384 + "CAMDATA[6] ",
385 + "CAMDATA[7] ",
386 + "CAMPCLK ",
387 + "CAMVSYNC ",
388 + "CAMHREF ",
389 + "CAMCLKOUT ",
390 + "CAMRESET ",
391 +};
392 +static const char * funcs_j3[] = {
393 + NULL,
394 + NULL,
395 + NULL,
396 + NULL,
397 + NULL,
398 + NULL,
399 + NULL,
400 + NULL,
401 + NULL,
402 + NULL,
403 + NULL,
404 + NULL,
405 + NULL,
406 +};
407 +
408 +/* used to dump GPIO states at suspend */
409 +void s3c24xx_dump_gpio_states(void)
410 +{
411 + pretty_dump_a(__raw_readl(S3C2410_GPACON),
412 + __raw_readl(S3C2410_GPADAT),
413 + funcs_a, "GPA", 25);
414 + pretty_dump(__raw_readl(S3C2410_GPBCON),
415 + __raw_readl(S3C2410_GPBDAT),
416 + __raw_readl(S3C2410_GPBUP),
417 + funcs_b2, funcs_b3, "GPB", 11);
418 + pretty_dump(__raw_readl(S3C2410_GPCCON),
419 + __raw_readl(S3C2410_GPCDAT),
420 + __raw_readl(S3C2410_GPCUP),
421 + funcs_c2, funcs_c3, "GPC", 16);
422 + pretty_dump(__raw_readl(S3C2410_GPDCON),
423 + __raw_readl(S3C2410_GPDDAT),
424 + __raw_readl(S3C2410_GPDUP),
425 + funcs_d2, funcs_d3, "GPD", 16);
426 + pretty_dump(__raw_readl(S3C2410_GPECON),
427 + __raw_readl(S3C2410_GPEDAT),
428 + __raw_readl(S3C2410_GPEUP),
429 + funcs_e2, funcs_e3, "GPE", 16);
430 + pretty_dump(__raw_readl(S3C2410_GPFCON),
431 + __raw_readl(S3C2410_GPFDAT),
432 + __raw_readl(S3C2410_GPFUP),
433 + funcs_f2, funcs_f3, "GPF", 8);
434 + pretty_dump(__raw_readl(S3C2410_GPGCON),
435 + __raw_readl(S3C2410_GPGDAT),
436 + __raw_readl(S3C2410_GPGUP),
437 + funcs_g2, funcs_g3, "GPG", 16);
438 + pretty_dump(__raw_readl(S3C2410_GPHCON),
439 + __raw_readl(S3C2410_GPHDAT),
440 + __raw_readl(S3C2410_GPHUP),
441 + funcs_h2, funcs_h3, "GPH", 11);
442 + pretty_dump(__raw_readl(S3C2440_GPJCON),
443 + __raw_readl(S3C2440_GPJDAT),
444 + __raw_readl(S3C2440_GPJUP),
445 + funcs_j2, funcs_j3, "GPJ", 13);
446 +
447 +}
448 +EXPORT_SYMBOL(s3c24xx_dump_gpio_states);
449 --
450 1.5.6.5
451
This page took 0.065055 seconds and 5 git commands to generate.