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
6 Add support for GPA[] GPIO bus since we have some NCs
7 but they seem to output-only IO cells so no matter
9 Signed-off-by: Andy Green <andy@openmoko.com>
11 arch/arm/plat-s3c24xx/gpio.c | 420 ++++++++++++++++++++++++++++++++++++++++++
12 1 files changed, 420 insertions(+), 0 deletions(-)
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
21 #include <asm/arch/regs-gpio.h>
22 +#include <asm/arch/regs-gpioj.h>
24 void s3c2410_gpio_cfgpin(unsigned int pin, unsigned int function)
26 @@ -186,3 +187,422 @@ int s3c2410_gpio_getirq(unsigned int pin)
29 EXPORT_SYMBOL(s3c2410_gpio_getirq);
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,
38 + const char *tag_type = NULL,
40 + *tag_pulldown = NULL,
44 + for (n = 0; n < count; n++) {
45 + switch ((cfg >> (2 * n)) & 3) {
47 + tag_type = "input ";
50 + tag_type = "OUTPUT ";
53 + if (function_names_2) {
54 + if (function_names_2[n])
55 + tag_type = function_names_2[n];
57 + tag_type = "*** ILLEGAL CFG (2) *** ";
59 + tag_type = "(function) ";
62 + if (function_names_3) {
63 + if (function_names_3[n])
64 + tag_type = function_names_3[n];
66 + tag_type = "*** ILLEGAL CFG (3) *** ";
68 + tag_type = "(function) ";
71 + if ((state >> n) & 1)
76 + if (((pull >> n) & 1))
79 + tag_pulldown = "(pulldown)";
81 + printk(KERN_INFO"%s%02d: %s %s %s\n", prefix, n, tag_type,
82 + tag_state, tag_pulldown);
84 + printk(KERN_INFO"\n");
87 +static void pretty_dump_a(u32 cfg, u32 state,
88 + const char ** function_names,
89 + const char * prefix,
93 + const char *tag_type = NULL,
98 + for (n = 0; n < count; n++) {
99 + switch ((cfg >> n) & 1) {
101 + tag_type = "OUTPUT ";
104 + if (function_names) {
105 + if (function_names[n])
106 + tag_type = function_names[n];
108 + tag_type = "*** ILLEGAL CFG *** ";
110 + tag_type = "(function) ";
113 + if ((state >> n) & 1)
114 + tag_state = level1;
116 + tag_state = level0;
118 + printk(KERN_INFO"%s%02d: %s %s\n", prefix, n, tag_type,
121 + printk(KERN_INFO"\n");
124 +static const char * funcs_a[] = {
153 +static const char * funcs_b2[] = {
166 +static const char * funcs_b3[] = {
180 +static const char * funcs_c2[] = {
198 +static const char * funcs_c3[] = {
217 +static const char * funcs_d2[] = {
235 +static const char * funcs_d3[] = {
254 +static const char * funcs_e2[] = {
272 +static const char * funcs_e3[] = {
291 +static const char * funcs_f2[] = {
301 +static const char * funcs_f3[] = {
313 +static const char * funcs_g2[] = {
331 +static const char * funcs_g3[] = {
350 +static const char * funcs_h2[] = {
363 +static const char * funcs_h3[] = {
377 +static const char * funcs_j2[] = {
392 +static const char * funcs_j3[] = {
408 +/* used to dump GPIO states at suspend */
409 +void s3c24xx_dump_gpio_states(void)
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);
448 +EXPORT_SYMBOL(s3c24xx_dump_gpio_states);