aboutsummaryrefslogtreecommitdiffstats
path: root/arch/blackfin/kernel/bfin_gpio.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/blackfin/kernel/bfin_gpio.c')
-rw-r--r--arch/blackfin/kernel/bfin_gpio.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/arch/blackfin/kernel/bfin_gpio.c b/arch/blackfin/kernel/bfin_gpio.c
index ea13d2a22d69..ffee36910288 100644
--- a/arch/blackfin/kernel/bfin_gpio.c
+++ b/arch/blackfin/kernel/bfin_gpio.c
@@ -179,15 +179,13 @@ static struct gpio_port_t *gpio_array[gpio_bank(MAX_BLACKFIN_GPIOS)] = {
179#endif 179#endif
180 180
181static unsigned short reserved_gpio_map[gpio_bank(MAX_BLACKFIN_GPIOS)]; 181static unsigned short reserved_gpio_map[gpio_bank(MAX_BLACKFIN_GPIOS)];
182static unsigned short reserved_peri_map[gpio_bank(MAX_BLACKFIN_GPIOS + 16)]; 182static unsigned short reserved_peri_map[gpio_bank(MAX_RESOURCES)];
183 183
184#define MAX_RESOURCES 256
185#define RESOURCE_LABEL_SIZE 16 184#define RESOURCE_LABEL_SIZE 16
186 185
187struct str_ident { 186static struct str_ident {
188 char name[RESOURCE_LABEL_SIZE]; 187 char name[RESOURCE_LABEL_SIZE];
189} *str_ident; 188} str_ident[MAX_RESOURCES];
190
191 189
192#ifdef CONFIG_PM 190#ifdef CONFIG_PM
193static unsigned short wakeup_map[gpio_bank(MAX_BLACKFIN_GPIOS)]; 191static unsigned short wakeup_map[gpio_bank(MAX_BLACKFIN_GPIOS)];
@@ -251,6 +249,11 @@ static char *get_label(unsigned short ident)
251 249
252static int cmp_label(unsigned short ident, const char *label) 250static int cmp_label(unsigned short ident, const char *label)
253{ 251{
252 if (label == NULL) {
253 dump_stack();
254 printk(KERN_ERR "Please provide none-null label\n");
255 }
256
254 if (label && str_ident) 257 if (label && str_ident)
255 return strncmp(str_ident[ident].name, 258 return strncmp(str_ident[ident].name,
256 label, strlen(label)); 259 label, strlen(label));
@@ -419,12 +422,6 @@ static void default_gpio(unsigned short gpio)
419 422
420static int __init bfin_gpio_init(void) 423static int __init bfin_gpio_init(void)
421{ 424{
422 str_ident = kcalloc(MAX_RESOURCES,
423 sizeof(struct str_ident), GFP_KERNEL);
424 if (str_ident == NULL)
425 return -ENOMEM;
426
427 memset(str_ident, 0, MAX_RESOURCES * sizeof(struct str_ident));
428 425
429 printk(KERN_INFO "Blackfin GPIO Controller\n"); 426 printk(KERN_INFO "Blackfin GPIO Controller\n");
430 427
@@ -785,6 +782,14 @@ void gpio_pm_restore(void)
785} 782}
786 783
787#endif 784#endif
785#else /* BF548_FAMILY */
786
787unsigned short get_gpio_dir(unsigned short gpio)
788{
789 return (0x01 & (gpio_array[gpio_bank(gpio)]->port_dir_clear >> gpio_sub_n(gpio)));
790}
791EXPORT_SYMBOL(get_gpio_dir);
792
788#endif /* BF548_FAMILY */ 793#endif /* BF548_FAMILY */
789 794
790/*********************************************************** 795/***********************************************************
@@ -1204,10 +1209,10 @@ static int gpio_proc_read(char *buf, char **start, off_t offset,
1204 1209
1205 for (c = 0; c < MAX_RESOURCES; c++) { 1210 for (c = 0; c < MAX_RESOURCES; c++) {
1206 if (!check_gpio(c) && (reserved_gpio_map[gpio_bank(c)] & gpio_bit(c))) 1211 if (!check_gpio(c) && (reserved_gpio_map[gpio_bank(c)] & gpio_bit(c)))
1207 len = sprintf(buf, "GPIO_%d: %s \tGPIO %s\n", c, 1212 len = sprintf(buf, "GPIO_%d: %s \t\tGPIO %s\n", c,
1208 get_label(c), get_gpio_dir(c) ? "OUTPUT" : "INPUT"); 1213 get_label(c), get_gpio_dir(c) ? "OUTPUT" : "INPUT");
1209 else if (reserved_peri_map[gpio_bank(c)] & gpio_bit(c)) 1214 else if (reserved_peri_map[gpio_bank(c)] & gpio_bit(c))
1210 len = sprintf(buf, "GPIO_%d: %s \tPeripheral\n", c, get_label(c)); 1215 len = sprintf(buf, "GPIO_%d: %s \t\tPeripheral\n", c, get_label(c));
1211 else 1216 else
1212 continue; 1217 continue;
1213 buf += len; 1218 buf += len;