]> err.no Git - linux-2.6/commitdiff
[Blackfin] arch: Fix gpio label handling
authorMichael Hennerich <michael.hennerich@analog.com>
Mon, 24 Dec 2007 12:07:03 +0000 (20:07 +0800)
committerBryan Wu <bryan.wu@analog.com>
Mon, 24 Dec 2007 12:07:03 +0000 (20:07 +0800)
early serial init also utilizes the peripheral request api - however
at this point bfin_gpio_init didn't allocate memory for the labels.
So we always have two zombies (allocated pin functions without labels)

This happens before the initcalls - We now allocate memory statically.
Define MAX_RESOURCES individually for each cpu.

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Bryan Wu <bryan.wu@analog.com>
arch/blackfin/kernel/bfin_gpio.c
include/asm-blackfin/mach-bf527/portmux.h
include/asm-blackfin/mach-bf533/portmux.h
include/asm-blackfin/mach-bf537/portmux.h
include/asm-blackfin/mach-bf548/portmux.h
include/asm-blackfin/mach-bf561/portmux.h

index ea13d2a22d69dfb3b44d05cccbeca45318c8615d..ffee3691028832807cc74a13d93042451182d536 100644 (file)
@@ -179,15 +179,13 @@ static struct gpio_port_t *gpio_array[gpio_bank(MAX_BLACKFIN_GPIOS)] = {
 #endif
 
 static unsigned short reserved_gpio_map[gpio_bank(MAX_BLACKFIN_GPIOS)];
-static unsigned short reserved_peri_map[gpio_bank(MAX_BLACKFIN_GPIOS + 16)];
+static unsigned short reserved_peri_map[gpio_bank(MAX_RESOURCES)];
 
-#define MAX_RESOURCES          256
 #define RESOURCE_LABEL_SIZE    16
 
-struct str_ident {
+static struct str_ident {
        char name[RESOURCE_LABEL_SIZE];
-} *str_ident;
-
+} str_ident[MAX_RESOURCES];
 
 #ifdef CONFIG_PM
 static unsigned short wakeup_map[gpio_bank(MAX_BLACKFIN_GPIOS)];
@@ -251,6 +249,11 @@ static char *get_label(unsigned short ident)
 
 static int cmp_label(unsigned short ident, const char *label)
 {
+       if (label == NULL) {
+               dump_stack();
+               printk(KERN_ERR "Please provide none-null label\n");
+       }
+
        if (label && str_ident)
                return strncmp(str_ident[ident].name,
                                 label, strlen(label));
@@ -419,12 +422,6 @@ static void default_gpio(unsigned short gpio)
 
 static int __init bfin_gpio_init(void)
 {
-       str_ident = kcalloc(MAX_RESOURCES,
-                                sizeof(struct str_ident), GFP_KERNEL);
-       if (str_ident == NULL)
-               return -ENOMEM;
-
-       memset(str_ident, 0, MAX_RESOURCES * sizeof(struct str_ident));
 
        printk(KERN_INFO "Blackfin GPIO Controller\n");
 
@@ -785,6 +782,14 @@ void gpio_pm_restore(void)
 }
 
 #endif
+#else /* BF548_FAMILY */
+
+unsigned short get_gpio_dir(unsigned short gpio)
+{
+       return (0x01 & (gpio_array[gpio_bank(gpio)]->port_dir_clear >> gpio_sub_n(gpio)));
+}
+EXPORT_SYMBOL(get_gpio_dir);
+
 #endif /* BF548_FAMILY */
 
 /***********************************************************
@@ -1204,10 +1209,10 @@ static int gpio_proc_read(char *buf, char **start, off_t offset,
 
        for (c = 0; c < MAX_RESOURCES; c++) {
                if (!check_gpio(c) && (reserved_gpio_map[gpio_bank(c)] & gpio_bit(c)))
-                       len = sprintf(buf, "GPIO_%d: %s \tGPIO %s\n", c,
+                       len = sprintf(buf, "GPIO_%d: %s \t\tGPIO %s\n", c,
                                 get_label(c), get_gpio_dir(c) ? "OUTPUT" : "INPUT");
                else if (reserved_peri_map[gpio_bank(c)] & gpio_bit(c))
-                       len = sprintf(buf, "GPIO_%d: %s \tPeripheral\n", c, get_label(c));
+                       len = sprintf(buf, "GPIO_%d: %s \t\tPeripheral\n", c, get_label(c));
                else
                        continue;
                buf += len;
index dcf001adc63ce138f7370fca6950af3e68717027..ae4d205bfcf5bb764b87d35e8879536399e82457 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef _MACH_PORTMUX_H_
 #define _MACH_PORTMUX_H_
 
+#define MAX_RESOURCES  MAX_BLACKFIN_GPIOS
+
 #define P_PPI0_D0      (P_DEFINED | P_IDENT(GPIO_PF0) | P_FUNCT(0))
 #define P_PPI0_D1      (P_DEFINED | P_IDENT(GPIO_PF1) | P_FUNCT(0))
 #define P_PPI0_D2      (P_DEFINED | P_IDENT(GPIO_PF2) | P_FUNCT(0))
index 137f4884acfe3ef59d952c992310e3a30acc6a79..685a2651dcda305d07ae85525e4ed1af96965740 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef _MACH_PORTMUX_H_
 #define _MACH_PORTMUX_H_
 
+#define MAX_RESOURCES  MAX_BLACKFIN_GPIOS
+
 #define P_PPI0_CLK     (P_DONTCARE)
 #define P_PPI0_FS1     (P_DONTCARE)
 #define P_PPI0_FS2     (P_DONTCARE)
index 5a3f7d3bf73d0b7696585383dacd46b23ca8658c..78fee6e0f23730cb2fc621b80ede4cb4f3fa21df 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef _MACH_PORTMUX_H_
 #define _MACH_PORTMUX_H_
 
+#define MAX_RESOURCES  (MAX_BLACKFIN_GPIOS + GPIO_BANKSIZE)    /* We additionally handle PORTJ */
+
 #define P_UART0_TX     (P_DEFINED | P_IDENT(GPIO_PF0) | P_FUNCT(0))
 #define P_UART0_RX     (P_DEFINED | P_IDENT(GPIO_PF1) | P_FUNCT(0))
 #define P_UART1_TX     (P_DEFINED | P_IDENT(GPIO_PF2) | P_FUNCT(0))
index 6b485120015f85a4b6243aad03f5446444a218ea..8177a567dcdbd0eae89c16f13e409ea838ea49b2 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef _MACH_PORTMUX_H_
 #define _MACH_PORTMUX_H_
 
+#define MAX_RESOURCES  MAX_BLACKFIN_GPIOS
+
 #define P_SPORT2_TFS   (P_DEFINED | P_IDENT(GPIO_PA0) | P_FUNCT(0))
 #define P_SPORT2_DTSEC (P_DEFINED | P_IDENT(GPIO_PA1) | P_FUNCT(0))
 #define P_SPORT2_DTPRI (P_DEFINED | P_IDENT(GPIO_PA2) | P_FUNCT(0))
index 132ad31665e3337af2612a7746f47fd21abfe349..a6ee8206efb6dd9a68337a4fab2afa5fb9d1f97c 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef _MACH_PORTMUX_H_
 #define _MACH_PORTMUX_H_
 
+#define MAX_RESOURCES  MAX_BLACKFIN_GPIOS
+
 #define P_PPI0_CLK     (P_DONTCARE)
 #define P_PPI0_FS1     (P_DONTCARE)
 #define P_PPI0_FS2     (P_DONTCARE)