diff options
author | Michael Hennerich <michael.hennerich@analog.com> | 2007-12-24 07:07:03 -0500 |
---|---|---|
committer | Bryan Wu <bryan.wu@analog.com> | 2007-12-24 07:07:03 -0500 |
commit | fac3cf432ef9b6bfd64b35b95afe0b7e0079da74 (patch) | |
tree | 1075a5da95fa235a39d67cb3d2176b1434ff7a71 /arch/blackfin | |
parent | 1545a1111a02b5aafe6f141e133a6269c5741285 (diff) |
[Blackfin] arch: Fix gpio label handling
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>
Diffstat (limited to 'arch/blackfin')
-rw-r--r-- | arch/blackfin/kernel/bfin_gpio.c | 31 |
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 | ||
181 | static unsigned short reserved_gpio_map[gpio_bank(MAX_BLACKFIN_GPIOS)]; | 181 | static unsigned short reserved_gpio_map[gpio_bank(MAX_BLACKFIN_GPIOS)]; |
182 | static unsigned short reserved_peri_map[gpio_bank(MAX_BLACKFIN_GPIOS + 16)]; | 182 | static 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 | ||
187 | struct str_ident { | 186 | static 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 |
193 | static unsigned short wakeup_map[gpio_bank(MAX_BLACKFIN_GPIOS)]; | 191 | static unsigned short wakeup_map[gpio_bank(MAX_BLACKFIN_GPIOS)]; |
@@ -251,6 +249,11 @@ static char *get_label(unsigned short ident) | |||
251 | 249 | ||
252 | static int cmp_label(unsigned short ident, const char *label) | 250 | static 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 | ||
420 | static int __init bfin_gpio_init(void) | 423 | static 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 | |||
787 | unsigned short get_gpio_dir(unsigned short gpio) | ||
788 | { | ||
789 | return (0x01 & (gpio_array[gpio_bank(gpio)]->port_dir_clear >> gpio_sub_n(gpio))); | ||
790 | } | ||
791 | EXPORT_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; |