diff options
| author | Michael Hennerich <michael.hennerich@analog.com> | 2007-10-03 12:35:05 -0400 |
|---|---|---|
| committer | Bryan Wu <bryan.wu@analog.com> | 2007-10-03 12:35:05 -0400 |
| commit | c58c2140f08de4ad0b0dbd48f6e78168dc321042 (patch) | |
| tree | ee7381b9db76340295229c56350adcca44d218b1 | |
| parent | 0b95f22bd3b91c7114c6892bbfbb5a8576b27fbe (diff) | |
Blackfin arch: gpio pinmux and resource allocation API required by BF537 on chip ethernet mac driver
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Bryan Wu <bryan.wu@analog.com>
| -rw-r--r-- | arch/blackfin/kernel/bfin_gpio.c | 272 | ||||
| -rw-r--r-- | include/asm-blackfin/mach-bf533/bfin_serial_5xx.h | 11 | ||||
| -rw-r--r-- | include/asm-blackfin/mach-bf537/bfin_serial_5xx.h | 23 | ||||
| -rw-r--r-- | include/asm-blackfin/mach-bf537/portmux.h | 2 | ||||
| -rw-r--r-- | include/asm-blackfin/mach-bf561/bfin_serial_5xx.h | 11 | ||||
| -rw-r--r-- | include/asm-blackfin/portmux.h | 55 |
6 files changed, 329 insertions, 45 deletions
diff --git a/arch/blackfin/kernel/bfin_gpio.c b/arch/blackfin/kernel/bfin_gpio.c index bafcfa52142b..9f3094800248 100644 --- a/arch/blackfin/kernel/bfin_gpio.c +++ b/arch/blackfin/kernel/bfin_gpio.c | |||
| @@ -84,6 +84,7 @@ | |||
| 84 | #include <linux/err.h> | 84 | #include <linux/err.h> |
| 85 | #include <asm/blackfin.h> | 85 | #include <asm/blackfin.h> |
| 86 | #include <asm/gpio.h> | 86 | #include <asm/gpio.h> |
| 87 | #include <asm/portmux.h> | ||
| 87 | #include <linux/irq.h> | 88 | #include <linux/irq.h> |
| 88 | 89 | ||
| 89 | #ifdef BF533_FAMILY | 90 | #ifdef BF533_FAMILY |
| @@ -115,7 +116,11 @@ static struct gpio_port_t *gpio_bankb[gpio_bank(MAX_BLACKFIN_GPIOS)] = { | |||
| 115 | }; | 116 | }; |
| 116 | #endif | 117 | #endif |
| 117 | 118 | ||
| 118 | static unsigned short reserved_map[gpio_bank(MAX_BLACKFIN_GPIOS)]; | 119 | static unsigned short reserved_gpio_map[gpio_bank(MAX_BLACKFIN_GPIOS)]; |
| 120 | static unsigned short reserved_peri_map[gpio_bank(MAX_BLACKFIN_GPIOS + 16)]; | ||
| 121 | char *str_ident = NULL; | ||
| 122 | |||
| 123 | #define RESOURCE_LABEL_SIZE 16 | ||
| 119 | 124 | ||
| 120 | #ifdef CONFIG_PM | 125 | #ifdef CONFIG_PM |
| 121 | static unsigned short wakeup_map[gpio_bank(MAX_BLACKFIN_GPIOS)]; | 126 | static unsigned short wakeup_map[gpio_bank(MAX_BLACKFIN_GPIOS)]; |
| @@ -143,13 +148,39 @@ inline int check_gpio(unsigned short gpio) | |||
| 143 | return 0; | 148 | return 0; |
| 144 | } | 149 | } |
| 145 | 150 | ||
| 151 | static void set_label(unsigned short ident, const char *label) | ||
| 152 | { | ||
| 153 | |||
| 154 | if (label && str_ident) { | ||
| 155 | strncpy(str_ident + ident * RESOURCE_LABEL_SIZE, label, | ||
| 156 | RESOURCE_LABEL_SIZE); | ||
| 157 | str_ident[ident * RESOURCE_LABEL_SIZE + | ||
| 158 | RESOURCE_LABEL_SIZE - 1] = 0; | ||
| 159 | } | ||
| 160 | } | ||
| 161 | |||
| 162 | static char *get_label(unsigned short ident) | ||
| 163 | { | ||
| 164 | if (!str_ident) | ||
| 165 | return "UNKNOWN"; | ||
| 166 | |||
| 167 | return (str_ident[ident * RESOURCE_LABEL_SIZE] ? | ||
| 168 | (str_ident + ident * RESOURCE_LABEL_SIZE) : "UNKNOWN"); | ||
| 169 | } | ||
| 170 | |||
| 171 | static int cmp_label(unsigned short ident, const char *label) | ||
| 172 | { | ||
| 173 | if (label && str_ident) | ||
| 174 | return strncmp(str_ident + ident * RESOURCE_LABEL_SIZE, | ||
| 175 | label, strlen(label)); | ||
| 176 | else | ||
| 177 | return -EINVAL; | ||
| 178 | } | ||
| 179 | |||
| 146 | #ifdef BF537_FAMILY | 180 | #ifdef BF537_FAMILY |
| 147 | static void port_setup(unsigned short gpio, unsigned short usage) | 181 | static void port_setup(unsigned short gpio, unsigned short usage) |
| 148 | { | 182 | { |
| 149 | if (usage == GPIO_USAGE) { | 183 | if (usage == GPIO_USAGE) { |
| 150 | if (*port_fer[gpio_bank(gpio)] & gpio_bit(gpio)) | ||
| 151 | printk(KERN_WARNING "bfin-gpio: Possible Conflict with Peripheral " | ||
| 152 | "usage and GPIO %d detected!\n", gpio); | ||
| 153 | *port_fer[gpio_bank(gpio)] &= ~gpio_bit(gpio); | 184 | *port_fer[gpio_bank(gpio)] &= ~gpio_bit(gpio); |
| 154 | } else | 185 | } else |
| 155 | *port_fer[gpio_bank(gpio)] |= gpio_bit(gpio); | 186 | *port_fer[gpio_bank(gpio)] |= gpio_bit(gpio); |
| @@ -159,6 +190,56 @@ static void port_setup(unsigned short gpio, unsigned short usage) | |||
| 159 | # define port_setup(...) do { } while (0) | 190 | # define port_setup(...) do { } while (0) |
| 160 | #endif | 191 | #endif |
| 161 | 192 | ||
| 193 | #ifdef BF537_FAMILY | ||
| 194 | |||
| 195 | #define PMUX_LUT_RES 0 | ||
| 196 | #define PMUX_LUT_OFFSET 1 | ||
| 197 | #define PMUX_LUT_ENTRIES 41 | ||
| 198 | #define PMUX_LUT_SIZE 2 | ||
| 199 | |||
| 200 | static unsigned short port_mux_lut[PMUX_LUT_ENTRIES][PMUX_LUT_SIZE] = { | ||
| 201 | {P_PPI0_D13, 11}, {P_PPI0_D14, 11}, {P_PPI0_D15, 11}, | ||
| 202 | {P_SPORT1_TFS, 11}, {P_SPORT1_TSCLK, 11}, {P_SPORT1_DTPRI, 11}, | ||
| 203 | {P_PPI0_D10, 10}, {P_PPI0_D11, 10}, {P_PPI0_D12, 10}, | ||
| 204 | {P_SPORT1_RSCLK, 10}, {P_SPORT1_RFS, 10}, {P_SPORT1_DRPRI, 10}, | ||
| 205 | {P_PPI0_D8, 9}, {P_PPI0_D9, 9}, {P_SPORT1_DRSEC, 9}, | ||
| 206 | {P_SPORT1_DTSEC, 9}, {P_TMR2, 8}, {P_PPI0_FS3, 8}, {P_TMR3, 7}, | ||
| 207 | {P_SPI0_SSEL4, 7}, {P_TMR4, 6}, {P_SPI0_SSEL5, 6}, {P_TMR5, 5}, | ||
| 208 | {P_SPI0_SSEL6, 5}, {P_UART1_RX, 4}, {P_UART1_TX, 4}, {P_TMR6, 4}, | ||
| 209 | {P_TMR7, 4}, {P_UART0_RX, 3}, {P_UART0_TX, 3}, {P_DMAR0, 3}, | ||
| 210 | {P_DMAR1, 3}, {P_SPORT0_DTSEC, 1}, {P_SPORT0_DRSEC, 1}, | ||
| 211 | {P_CAN0_RX, 1}, {P_CAN0_TX, 1}, {P_SPI0_SSEL7, 1}, | ||
| 212 | {P_SPORT0_TFS, 0}, {P_SPORT0_DTPRI, 0}, {P_SPI0_SSEL2, 0}, | ||
| 213 | {P_SPI0_SSEL3, 0} | ||
| 214 | }; | ||
| 215 | |||
| 216 | static void portmux_setup(unsigned short per, unsigned short function) | ||
| 217 | { | ||
| 218 | u16 y, muxreg, offset; | ||
| 219 | |||
| 220 | for (y = 0; y < PMUX_LUT_ENTRIES; y++) { | ||
| 221 | if (port_mux_lut[y][PMUX_LUT_RES] == per) { | ||
| 222 | |||
| 223 | /* SET PORTMUX REG */ | ||
| 224 | |||
| 225 | offset = port_mux_lut[y][PMUX_LUT_OFFSET]; | ||
| 226 | muxreg = bfin_read_PORT_MUX(); | ||
| 227 | |||
| 228 | if (offset != 1) { | ||
| 229 | muxreg &= ~(1 << offset); | ||
| 230 | } else { | ||
| 231 | muxreg &= ~(3 << 1); | ||
| 232 | } | ||
| 233 | |||
| 234 | muxreg |= (function << offset); | ||
| 235 | bfin_write_PORT_MUX(muxreg); | ||
| 236 | } | ||
| 237 | } | ||
| 238 | } | ||
| 239 | |||
| 240 | #else | ||
| 241 | # define portmux_setup(...) do { } while (0) | ||
| 242 | #endif | ||
| 162 | 243 | ||
| 163 | static void default_gpio(unsigned short gpio) | 244 | static void default_gpio(unsigned short gpio) |
| 164 | { | 245 | { |
| @@ -179,22 +260,15 @@ static void default_gpio(unsigned short gpio) | |||
| 179 | 260 | ||
| 180 | static int __init bfin_gpio_init(void) | 261 | static int __init bfin_gpio_init(void) |
| 181 | { | 262 | { |
| 182 | int i; | ||
| 183 | |||
| 184 | printk(KERN_INFO "Blackfin GPIO Controller\n"); | ||
| 185 | 263 | ||
| 186 | for (i = 0; i < MAX_BLACKFIN_GPIOS; i += GPIO_BANKSIZE) | 264 | str_ident = kzalloc(RESOURCE_LABEL_SIZE * 256, GFP_KERNEL); |
| 187 | reserved_map[gpio_bank(i)] = 0; | 265 | if (!str_ident) |
| 266 | return -ENOMEM; | ||
| 188 | 267 | ||
| 189 | #if defined(BF537_FAMILY) && (defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)) | 268 | printk(KERN_INFO "Blackfin GPIO Controller\n"); |
| 190 | # if defined(CONFIG_BFIN_MAC_RMII) | ||
| 191 | reserved_map[gpio_bank(PORT_H)] = 0xC373; | ||
| 192 | # else | ||
| 193 | reserved_map[gpio_bank(PORT_H)] = 0xFFFF; | ||
| 194 | # endif | ||
| 195 | #endif | ||
| 196 | 269 | ||
| 197 | return 0; | 270 | return 0; |
| 271 | |||
| 198 | } | 272 | } |
| 199 | 273 | ||
| 200 | arch_initcall(bfin_gpio_init); | 274 | arch_initcall(bfin_gpio_init); |
| @@ -223,7 +297,7 @@ arch_initcall(bfin_gpio_init); | |||
| 223 | void set_gpio_ ## name(unsigned short gpio, unsigned short arg) \ | 297 | void set_gpio_ ## name(unsigned short gpio, unsigned short arg) \ |
| 224 | { \ | 298 | { \ |
| 225 | unsigned long flags; \ | 299 | unsigned long flags; \ |
| 226 | BUG_ON(!(reserved_map[gpio_bank(gpio)] & gpio_bit(gpio))); \ | 300 | BUG_ON(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))); \ |
| 227 | local_irq_save(flags); \ | 301 | local_irq_save(flags); \ |
| 228 | if (arg) \ | 302 | if (arg) \ |
| 229 | gpio_bankb[gpio_bank(gpio)]->name |= gpio_bit(gpio); \ | 303 | gpio_bankb[gpio_bank(gpio)]->name |= gpio_bit(gpio); \ |
| @@ -243,7 +317,7 @@ SET_GPIO(both) | |||
| 243 | #define SET_GPIO_SC(name) \ | 317 | #define SET_GPIO_SC(name) \ |
| 244 | void set_gpio_ ## name(unsigned short gpio, unsigned short arg) \ | 318 | void set_gpio_ ## name(unsigned short gpio, unsigned short arg) \ |
| 245 | { \ | 319 | { \ |
| 246 | BUG_ON(!(reserved_map[gpio_bank(gpio)] & gpio_bit(gpio))); \ | 320 | BUG_ON(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))); \ |
| 247 | if (arg) \ | 321 | if (arg) \ |
| 248 | gpio_bankb[gpio_bank(gpio)]->name ## _set = gpio_bit(gpio); \ | 322 | gpio_bankb[gpio_bank(gpio)]->name ## _set = gpio_bit(gpio); \ |
| 249 | else \ | 323 | else \ |
| @@ -258,7 +332,7 @@ SET_GPIO_SC(maskb) | |||
| 258 | void set_gpio_data(unsigned short gpio, unsigned short arg) | 332 | void set_gpio_data(unsigned short gpio, unsigned short arg) |
| 259 | { | 333 | { |
| 260 | unsigned long flags; | 334 | unsigned long flags; |
| 261 | BUG_ON(!(reserved_map[gpio_bank(gpio)] & gpio_bit(gpio))); | 335 | BUG_ON(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))); |
| 262 | local_irq_save(flags); | 336 | local_irq_save(flags); |
| 263 | if (arg) | 337 | if (arg) |
| 264 | gpio_bankb[gpio_bank(gpio)]->data_set = gpio_bit(gpio); | 338 | gpio_bankb[gpio_bank(gpio)]->data_set = gpio_bit(gpio); |
| @@ -277,7 +351,7 @@ SET_GPIO_SC(data) | |||
| 277 | void set_gpio_toggle(unsigned short gpio) | 351 | void set_gpio_toggle(unsigned short gpio) |
| 278 | { | 352 | { |
| 279 | unsigned long flags; | 353 | unsigned long flags; |
| 280 | BUG_ON(!(reserved_map[gpio_bank(gpio)] & gpio_bit(gpio))); | 354 | BUG_ON(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))); |
| 281 | local_irq_save(flags); | 355 | local_irq_save(flags); |
| 282 | gpio_bankb[gpio_bank(gpio)]->toggle = gpio_bit(gpio); | 356 | gpio_bankb[gpio_bank(gpio)]->toggle = gpio_bit(gpio); |
| 283 | bfin_read_CHIPID(); | 357 | bfin_read_CHIPID(); |
| @@ -286,7 +360,7 @@ void set_gpio_toggle(unsigned short gpio) | |||
| 286 | #else | 360 | #else |
| 287 | void set_gpio_toggle(unsigned short gpio) | 361 | void set_gpio_toggle(unsigned short gpio) |
| 288 | { | 362 | { |
| 289 | BUG_ON(!(reserved_map[gpio_bank(gpio)] & gpio_bit(gpio))); | 363 | BUG_ON(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))); |
| 290 | gpio_bankb[gpio_bank(gpio)]->toggle = gpio_bit(gpio); | 364 | gpio_bankb[gpio_bank(gpio)]->toggle = gpio_bit(gpio); |
| 291 | } | 365 | } |
| 292 | #endif | 366 | #endif |
| @@ -350,7 +424,7 @@ unsigned short get_gpio_data(unsigned short gpio) | |||
| 350 | { | 424 | { |
| 351 | unsigned long flags; | 425 | unsigned long flags; |
| 352 | unsigned short ret; | 426 | unsigned short ret; |
| 353 | BUG_ON(!(reserved_map[gpio_bank(gpio)] & gpio_bit(gpio))); | 427 | BUG_ON(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))); |
| 354 | local_irq_save(flags); | 428 | local_irq_save(flags); |
| 355 | ret = 0x01 & (gpio_bankb[gpio_bank(gpio)]->data >> gpio_sub_n(gpio)); | 429 | ret = 0x01 & (gpio_bankb[gpio_bank(gpio)]->data >> gpio_sub_n(gpio)); |
| 356 | bfin_read_CHIPID(); | 430 | bfin_read_CHIPID(); |
| @@ -494,13 +568,14 @@ u32 gpio_pm_setup(void) | |||
| 494 | gpio_bank_saved[bank].dir = gpio_bankb[bank]->dir; | 568 | gpio_bank_saved[bank].dir = gpio_bankb[bank]->dir; |
| 495 | gpio_bank_saved[bank].edge = gpio_bankb[bank]->edge; | 569 | gpio_bank_saved[bank].edge = gpio_bankb[bank]->edge; |
| 496 | gpio_bank_saved[bank].both = gpio_bankb[bank]->both; | 570 | gpio_bank_saved[bank].both = gpio_bankb[bank]->both; |
| 497 | gpio_bank_saved[bank].reserved = reserved_map[bank]; | 571 | gpio_bank_saved[bank].reserved = |
| 572 | reserved_gpio_map[bank]; | ||
| 498 | 573 | ||
| 499 | gpio = i; | 574 | gpio = i; |
| 500 | 575 | ||
| 501 | while (mask) { | 576 | while (mask) { |
| 502 | if (mask & 1) { | 577 | if (mask & 1) { |
| 503 | reserved_map[gpio_bank(gpio)] |= | 578 | reserved_gpio_map[gpio_bank(gpio)] |= |
| 504 | gpio_bit(gpio); | 579 | gpio_bit(gpio); |
| 505 | bfin_gpio_wakeup_type(gpio, | 580 | bfin_gpio_wakeup_type(gpio, |
| 506 | wakeup_flags_map[gpio]); | 581 | wakeup_flags_map[gpio]); |
| @@ -540,7 +615,8 @@ void gpio_pm_restore(void) | |||
| 540 | gpio_bankb[bank]->edge = gpio_bank_saved[bank].edge; | 615 | gpio_bankb[bank]->edge = gpio_bank_saved[bank].edge; |
| 541 | gpio_bankb[bank]->both = gpio_bank_saved[bank].both; | 616 | gpio_bankb[bank]->both = gpio_bank_saved[bank].both; |
| 542 | 617 | ||
| 543 | reserved_map[bank] = gpio_bank_saved[bank].reserved; | 618 | reserved_gpio_map[bank] = |
| 619 | gpio_bank_saved[bank].reserved; | ||
| 544 | 620 | ||
| 545 | } | 621 | } |
| 546 | 622 | ||
| @@ -550,6 +626,140 @@ void gpio_pm_restore(void) | |||
| 550 | 626 | ||
| 551 | #endif | 627 | #endif |
| 552 | 628 | ||
| 629 | |||
| 630 | |||
| 631 | |||
| 632 | int peripheral_request(unsigned short per, const char *label) | ||
| 633 | { | ||
| 634 | unsigned long flags; | ||
| 635 | unsigned short ident = P_IDENT(per); | ||
| 636 | |||
| 637 | /* | ||
| 638 | * Don't cares are pins with only one dedicated function | ||
| 639 | */ | ||
| 640 | |||
| 641 | if (per & P_DONTCARE) | ||
| 642 | return 0; | ||
| 643 | |||
| 644 | if (!(per & P_DEFINED)) | ||
| 645 | return -ENODEV; | ||
| 646 | |||
| 647 | if (check_gpio(ident) < 0) | ||
| 648 | return -EINVAL; | ||
| 649 | |||
| 650 | local_irq_save(flags); | ||
| 651 | |||
| 652 | if (unlikely(reserved_gpio_map[gpio_bank(ident)] & gpio_bit(ident))) { | ||
| 653 | printk(KERN_ERR | ||
| 654 | "%s: Peripheral %d is already reserved as GPIO by %s !\n", | ||
| 655 | __FUNCTION__, ident, get_label(ident)); | ||
| 656 | dump_stack(); | ||
| 657 | local_irq_restore(flags); | ||
| 658 | return -EBUSY; | ||
| 659 | } | ||
| 660 | |||
| 661 | if (unlikely(reserved_peri_map[gpio_bank(ident)] & gpio_bit(ident))) { | ||
| 662 | |||
| 663 | /* | ||
| 664 | * Pin functions like AMC address strobes my | ||
| 665 | * be requested and used by several drivers | ||
| 666 | */ | ||
| 667 | |||
| 668 | if (!(per & P_MAYSHARE)) { | ||
| 669 | |||
| 670 | /* | ||
| 671 | * Allow that the identical pin function can | ||
| 672 | * be requested from the same driver twice | ||
| 673 | */ | ||
| 674 | |||
| 675 | if (cmp_label(ident, label) == 0) | ||
| 676 | goto anyway; | ||
| 677 | |||
| 678 | printk(KERN_ERR | ||
| 679 | "%s: Peripheral %d function %d is already" | ||
| 680 | "reserved by %s !\n", | ||
| 681 | __FUNCTION__, ident, P_FUNCT2MUX(per), | ||
| 682 | get_label(ident)); | ||
| 683 | dump_stack(); | ||
| 684 | local_irq_restore(flags); | ||
| 685 | return -EBUSY; | ||
| 686 | } | ||
| 687 | |||
| 688 | } | ||
| 689 | |||
| 690 | anyway: | ||
| 691 | |||
| 692 | |||
| 693 | portmux_setup(per, P_FUNCT2MUX(per)); | ||
| 694 | |||
| 695 | port_setup(ident, PERIPHERAL_USAGE); | ||
| 696 | |||
| 697 | reserved_peri_map[gpio_bank(ident)] |= gpio_bit(ident); | ||
| 698 | local_irq_restore(flags); | ||
| 699 | set_label(ident, label); | ||
| 700 | |||
| 701 | return 0; | ||
| 702 | } | ||
| 703 | EXPORT_SYMBOL(peripheral_request); | ||
| 704 | |||
| 705 | int peripheral_request_list(unsigned short per[], const char *label) | ||
| 706 | { | ||
| 707 | u16 cnt; | ||
| 708 | int ret; | ||
| 709 | |||
| 710 | for (cnt = 0; per[cnt] != 0; cnt++) { | ||
| 711 | ret = peripheral_request(per[cnt], label); | ||
| 712 | if (ret < 0) | ||
| 713 | return ret; | ||
| 714 | } | ||
| 715 | |||
| 716 | return 0; | ||
| 717 | } | ||
| 718 | EXPORT_SYMBOL(peripheral_request_list); | ||
| 719 | |||
| 720 | void peripheral_free(unsigned short per) | ||
| 721 | { | ||
| 722 | unsigned long flags; | ||
| 723 | unsigned short ident = P_IDENT(per); | ||
| 724 | |||
| 725 | if (per & P_DONTCARE) | ||
| 726 | return; | ||
| 727 | |||
| 728 | if (!(per & P_DEFINED)) | ||
| 729 | return; | ||
| 730 | |||
| 731 | if (check_gpio(ident) < 0) | ||
| 732 | return; | ||
| 733 | |||
| 734 | local_irq_save(flags); | ||
| 735 | |||
| 736 | if (unlikely(!(reserved_peri_map[gpio_bank(ident)] | ||
| 737 | & gpio_bit(ident)))) { | ||
| 738 | local_irq_restore(flags); | ||
| 739 | return; | ||
| 740 | } | ||
| 741 | |||
| 742 | if (!(per & P_MAYSHARE)) { | ||
| 743 | port_setup(ident, GPIO_USAGE); | ||
| 744 | } | ||
| 745 | |||
| 746 | reserved_peri_map[gpio_bank(ident)] &= ~gpio_bit(ident); | ||
| 747 | |||
| 748 | local_irq_restore(flags); | ||
| 749 | } | ||
| 750 | EXPORT_SYMBOL(peripheral_free); | ||
| 751 | |||
| 752 | void peripheral_free_list(unsigned short per[]) | ||
| 753 | { | ||
| 754 | u16 cnt; | ||
| 755 | |||
| 756 | for (cnt = 0; per[cnt] != 0; cnt++) { | ||
| 757 | peripheral_free(per[cnt]); | ||
| 758 | } | ||
| 759 | |||
| 760 | } | ||
| 761 | EXPORT_SYMBOL(peripheral_free_list); | ||
| 762 | |||
| 553 | /*********************************************************** | 763 | /*********************************************************** |
| 554 | * | 764 | * |
| 555 | * FUNCTIONS: Blackfin GPIO Driver | 765 | * FUNCTIONS: Blackfin GPIO Driver |
| @@ -574,13 +784,13 @@ int gpio_request(unsigned short gpio, const char *label) | |||
| 574 | 784 | ||
| 575 | local_irq_save(flags); | 785 | local_irq_save(flags); |
| 576 | 786 | ||
| 577 | if (unlikely(reserved_map[gpio_bank(gpio)] & gpio_bit(gpio))) { | 787 | if (unlikely(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))) { |
| 578 | printk(KERN_ERR "bfin-gpio: GPIO %d is already reserved!\n", gpio); | 788 | printk(KERN_ERR "bfin-gpio: GPIO %d is already reserved!\n", gpio); |
| 579 | dump_stack(); | 789 | dump_stack(); |
| 580 | local_irq_restore(flags); | 790 | local_irq_restore(flags); |
| 581 | return -EBUSY; | 791 | return -EBUSY; |
| 582 | } | 792 | } |
| 583 | reserved_map[gpio_bank(gpio)] |= gpio_bit(gpio); | 793 | reserved_gpio_map[gpio_bank(gpio)] |= gpio_bit(gpio); |
| 584 | 794 | ||
| 585 | local_irq_restore(flags); | 795 | local_irq_restore(flags); |
| 586 | 796 | ||
| @@ -599,7 +809,7 @@ void gpio_free(unsigned short gpio) | |||
| 599 | 809 | ||
| 600 | local_irq_save(flags); | 810 | local_irq_save(flags); |
| 601 | 811 | ||
| 602 | if (unlikely(!(reserved_map[gpio_bank(gpio)] & gpio_bit(gpio)))) { | 812 | if (unlikely(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio)))) { |
| 603 | printk(KERN_ERR "bfin-gpio: GPIO %d wasn't reserved!\n", gpio); | 813 | printk(KERN_ERR "bfin-gpio: GPIO %d wasn't reserved!\n", gpio); |
| 604 | dump_stack(); | 814 | dump_stack(); |
| 605 | local_irq_restore(flags); | 815 | local_irq_restore(flags); |
| @@ -608,7 +818,7 @@ void gpio_free(unsigned short gpio) | |||
| 608 | 818 | ||
| 609 | default_gpio(gpio); | 819 | default_gpio(gpio); |
| 610 | 820 | ||
| 611 | reserved_map[gpio_bank(gpio)] &= ~gpio_bit(gpio); | 821 | reserved_gpio_map[gpio_bank(gpio)] &= ~gpio_bit(gpio); |
| 612 | 822 | ||
| 613 | local_irq_restore(flags); | 823 | local_irq_restore(flags); |
| 614 | } | 824 | } |
| @@ -618,7 +828,7 @@ void gpio_direction_input(unsigned short gpio) | |||
| 618 | { | 828 | { |
| 619 | unsigned long flags; | 829 | unsigned long flags; |
| 620 | 830 | ||
| 621 | BUG_ON(!(reserved_map[gpio_bank(gpio)] & gpio_bit(gpio))); | 831 | BUG_ON(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))); |
| 622 | 832 | ||
| 623 | local_irq_save(flags); | 833 | local_irq_save(flags); |
| 624 | gpio_bankb[gpio_bank(gpio)]->dir &= ~gpio_bit(gpio); | 834 | gpio_bankb[gpio_bank(gpio)]->dir &= ~gpio_bit(gpio); |
| @@ -631,7 +841,7 @@ void gpio_direction_output(unsigned short gpio) | |||
| 631 | { | 841 | { |
| 632 | unsigned long flags; | 842 | unsigned long flags; |
| 633 | 843 | ||
| 634 | BUG_ON(!(reserved_map[gpio_bank(gpio)] & gpio_bit(gpio))); | 844 | BUG_ON(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))); |
| 635 | 845 | ||
| 636 | local_irq_save(flags); | 846 | local_irq_save(flags); |
| 637 | gpio_bankb[gpio_bank(gpio)]->inen &= ~gpio_bit(gpio); | 847 | gpio_bankb[gpio_bank(gpio)]->inen &= ~gpio_bit(gpio); |
diff --git a/include/asm-blackfin/mach-bf533/bfin_serial_5xx.h b/include/asm-blackfin/mach-bf533/bfin_serial_5xx.h index e043cafa3c42..69b9f8e120e9 100644 --- a/include/asm-blackfin/mach-bf533/bfin_serial_5xx.h +++ b/include/asm-blackfin/mach-bf533/bfin_serial_5xx.h | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | #include <linux/serial.h> | 1 | #include <linux/serial.h> |
| 2 | #include <asm/dma.h> | 2 | #include <asm/dma.h> |
| 3 | #include <asm/portmux.h> | ||
| 3 | 4 | ||
| 4 | #define NR_PORTS 1 | 5 | #define NR_PORTS 1 |
| 5 | 6 | ||
| @@ -92,18 +93,24 @@ struct bfin_serial_res bfin_serial_resource[] = { | |||
| 92 | } | 93 | } |
| 93 | }; | 94 | }; |
| 94 | 95 | ||
| 96 | #define DRIVER_NAME "bfin-uart" | ||
| 95 | 97 | ||
| 96 | int nr_ports = NR_PORTS; | 98 | int nr_ports = NR_PORTS; |
| 97 | static void bfin_serial_hw_init(struct bfin_serial_port *uart) | 99 | static void bfin_serial_hw_init(struct bfin_serial_port *uart) |
| 98 | { | 100 | { |
| 99 | 101 | ||
| 102 | #ifdef CONFIG_SERIAL_BFIN_UART0 | ||
| 103 | peripheral_request(P_UART0_TX, DRIVER_NAME); | ||
| 104 | peripheral_request(P_UART0_RX, DRIVER_NAME); | ||
| 105 | #endif | ||
| 106 | |||
| 100 | #ifdef CONFIG_SERIAL_BFIN_CTSRTS | 107 | #ifdef CONFIG_SERIAL_BFIN_CTSRTS |
| 101 | if (uart->cts_pin >= 0) { | 108 | if (uart->cts_pin >= 0) { |
| 102 | gpio_request(uart->cts_pin, NULL); | 109 | gpio_request(uart->cts_pin, DRIVER_NAME); |
| 103 | gpio_direction_input(uart->cts_pin); | 110 | gpio_direction_input(uart->cts_pin); |
| 104 | } | 111 | } |
| 105 | if (uart->rts_pin >= 0) { | 112 | if (uart->rts_pin >= 0) { |
| 106 | gpio_request(uart->rts_pin, NULL); | 113 | gpio_request(uart->rts_pin, DRIVER_NAME); |
| 107 | gpio_direction_input(uart->rts_pin); | 114 | gpio_direction_input(uart->rts_pin); |
| 108 | } | 115 | } |
| 109 | #endif | 116 | #endif |
diff --git a/include/asm-blackfin/mach-bf537/bfin_serial_5xx.h b/include/asm-blackfin/mach-bf537/bfin_serial_5xx.h index 8f5d9c4d8d5b..6fb328f5186a 100644 --- a/include/asm-blackfin/mach-bf537/bfin_serial_5xx.h +++ b/include/asm-blackfin/mach-bf537/bfin_serial_5xx.h | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | #include <linux/serial.h> | 1 | #include <linux/serial.h> |
| 2 | #include <asm/dma.h> | 2 | #include <asm/dma.h> |
| 3 | #include <asm/portmux.h> | ||
| 3 | 4 | ||
| 4 | #define NR_PORTS 2 | 5 | #define NR_PORTS 2 |
| 5 | 6 | ||
| @@ -122,25 +123,29 @@ struct bfin_serial_res bfin_serial_resource[] = { | |||
| 122 | 123 | ||
| 123 | int nr_ports = ARRAY_SIZE(bfin_serial_resource); | 124 | int nr_ports = ARRAY_SIZE(bfin_serial_resource); |
| 124 | 125 | ||
| 126 | #define DRIVER_NAME "bfin-uart" | ||
| 127 | |||
| 125 | static void bfin_serial_hw_init(struct bfin_serial_port *uart) | 128 | static void bfin_serial_hw_init(struct bfin_serial_port *uart) |
| 126 | { | 129 | { |
| 127 | unsigned short val; | ||
| 128 | val = bfin_read16(BFIN_PORT_MUX); | ||
| 129 | val &= ~(PFDE | PFTE); | ||
| 130 | bfin_write16(BFIN_PORT_MUX, val); | ||
| 131 | 130 | ||
| 132 | val = bfin_read16(PORTF_FER); | 131 | #ifdef CONFIG_SERIAL_BFIN_UART0 |
| 133 | val |= 0xF; | 132 | peripheral_request(P_UART0_TX, DRIVER_NAME); |
| 134 | bfin_write16(PORTF_FER, val); | 133 | peripheral_request(P_UART0_RX, DRIVER_NAME); |
| 134 | #endif | ||
| 135 | |||
| 136 | #ifdef CONFIG_SERIAL_BFIN_UART1 | ||
| 137 | peripheral_request(P_UART1_TX, DRIVER_NAME); | ||
| 138 | peripheral_request(P_UART1_RX, DRIVER_NAME); | ||
| 139 | #endif | ||
| 135 | 140 | ||
| 136 | #ifdef CONFIG_SERIAL_BFIN_CTSRTS | 141 | #ifdef CONFIG_SERIAL_BFIN_CTSRTS |
| 137 | if (uart->cts_pin >= 0) { | 142 | if (uart->cts_pin >= 0) { |
| 138 | gpio_request(uart->cts_pin, NULL); | 143 | gpio_request(uart->cts_pin, DRIVER_NAME); |
| 139 | gpio_direction_input(uart->cts_pin); | 144 | gpio_direction_input(uart->cts_pin); |
| 140 | } | 145 | } |
| 141 | 146 | ||
| 142 | if (uart->rts_pin >= 0) { | 147 | if (uart->rts_pin >= 0) { |
| 143 | gpio_request(uart->rts_pin, NULL); | 148 | gpio_request(uart->rts_pin, DRIVER_NAME); |
| 144 | gpio_direction_output(uart->rts_pin); | 149 | gpio_direction_output(uart->rts_pin); |
| 145 | } | 150 | } |
| 146 | #endif | 151 | #endif |
diff --git a/include/asm-blackfin/mach-bf537/portmux.h b/include/asm-blackfin/mach-bf537/portmux.h index 23e13c5abc4d..7daa2479a731 100644 --- a/include/asm-blackfin/mach-bf537/portmux.h +++ b/include/asm-blackfin/mach-bf537/portmux.h | |||
| @@ -106,4 +106,4 @@ | |||
| 106 | #define P_SPI0_SSEL2 (P_DEFINED | P_IDENT(PORT_PJ11) | P_FUNCT(1)) | 106 | #define P_SPI0_SSEL2 (P_DEFINED | P_IDENT(PORT_PJ11) | P_FUNCT(1)) |
| 107 | #define P_SPI0_SSEL7 (P_DEFINED | P_IDENT(PORT_PJ5) | P_FUNCT(2)) | 107 | #define P_SPI0_SSEL7 (P_DEFINED | P_IDENT(PORT_PJ5) | P_FUNCT(2)) |
| 108 | 108 | ||
| 109 | #endif /* _MACH_PORTMUX_H_ */ | 109 | #endif /* _MACH_PORTMUX_H_ */ |
diff --git a/include/asm-blackfin/mach-bf561/bfin_serial_5xx.h b/include/asm-blackfin/mach-bf561/bfin_serial_5xx.h index e043cafa3c42..69b9f8e120e9 100644 --- a/include/asm-blackfin/mach-bf561/bfin_serial_5xx.h +++ b/include/asm-blackfin/mach-bf561/bfin_serial_5xx.h | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | #include <linux/serial.h> | 1 | #include <linux/serial.h> |
| 2 | #include <asm/dma.h> | 2 | #include <asm/dma.h> |
| 3 | #include <asm/portmux.h> | ||
| 3 | 4 | ||
| 4 | #define NR_PORTS 1 | 5 | #define NR_PORTS 1 |
| 5 | 6 | ||
| @@ -92,18 +93,24 @@ struct bfin_serial_res bfin_serial_resource[] = { | |||
| 92 | } | 93 | } |
| 93 | }; | 94 | }; |
| 94 | 95 | ||
| 96 | #define DRIVER_NAME "bfin-uart" | ||
| 95 | 97 | ||
| 96 | int nr_ports = NR_PORTS; | 98 | int nr_ports = NR_PORTS; |
| 97 | static void bfin_serial_hw_init(struct bfin_serial_port *uart) | 99 | static void bfin_serial_hw_init(struct bfin_serial_port *uart) |
| 98 | { | 100 | { |
| 99 | 101 | ||
| 102 | #ifdef CONFIG_SERIAL_BFIN_UART0 | ||
| 103 | peripheral_request(P_UART0_TX, DRIVER_NAME); | ||
| 104 | peripheral_request(P_UART0_RX, DRIVER_NAME); | ||
| 105 | #endif | ||
| 106 | |||
| 100 | #ifdef CONFIG_SERIAL_BFIN_CTSRTS | 107 | #ifdef CONFIG_SERIAL_BFIN_CTSRTS |
| 101 | if (uart->cts_pin >= 0) { | 108 | if (uart->cts_pin >= 0) { |
| 102 | gpio_request(uart->cts_pin, NULL); | 109 | gpio_request(uart->cts_pin, DRIVER_NAME); |
| 103 | gpio_direction_input(uart->cts_pin); | 110 | gpio_direction_input(uart->cts_pin); |
| 104 | } | 111 | } |
| 105 | if (uart->rts_pin >= 0) { | 112 | if (uart->rts_pin >= 0) { |
| 106 | gpio_request(uart->rts_pin, NULL); | 113 | gpio_request(uart->rts_pin, DRIVER_NAME); |
| 107 | gpio_direction_input(uart->rts_pin); | 114 | gpio_direction_input(uart->rts_pin); |
| 108 | } | 115 | } |
| 109 | #endif | 116 | #endif |
diff --git a/include/asm-blackfin/portmux.h b/include/asm-blackfin/portmux.h index 9d3681e42111..0d3f650d2d99 100644 --- a/include/asm-blackfin/portmux.h +++ b/include/asm-blackfin/portmux.h | |||
| @@ -14,6 +14,12 @@ | |||
| 14 | #define P_MAYSHARE 0x2000 | 14 | #define P_MAYSHARE 0x2000 |
| 15 | #define P_DONTCARE 0x1000 | 15 | #define P_DONTCARE 0x1000 |
| 16 | 16 | ||
| 17 | |||
| 18 | int peripheral_request(unsigned short per, const char *label); | ||
| 19 | void peripheral_free(unsigned short per); | ||
| 20 | int peripheral_request_list(unsigned short per[], const char *label); | ||
| 21 | void peripheral_free_list(unsigned short per[]); | ||
| 22 | |||
| 17 | #include <asm/gpio.h> | 23 | #include <asm/gpio.h> |
| 18 | #include <asm/mach/portmux.h> | 24 | #include <asm/mach/portmux.h> |
| 19 | 25 | ||
| @@ -145,6 +151,22 @@ | |||
| 145 | #define P_SPI2_SSEL3 P_UNDEF | 151 | #define P_SPI2_SSEL3 P_UNDEF |
| 146 | #endif | 152 | #endif |
| 147 | 153 | ||
| 154 | #ifndef P_SPI2_SSEL4 | ||
| 155 | #define P_SPI2_SSEL4 P_UNDEF | ||
| 156 | #endif | ||
| 157 | |||
| 158 | #ifndef P_SPI2_SSEL5 | ||
| 159 | #define P_SPI2_SSEL5 P_UNDEF | ||
| 160 | #endif | ||
| 161 | |||
| 162 | #ifndef P_SPI2_SSEL6 | ||
| 163 | #define P_SPI2_SSEL6 P_UNDEF | ||
| 164 | #endif | ||
| 165 | |||
| 166 | #ifndef P_SPI2_SSEL7 | ||
| 167 | #define P_SPI2_SSEL7 P_UNDEF | ||
| 168 | #endif | ||
| 169 | |||
| 148 | #ifndef P_SPI2_SCK | 170 | #ifndef P_SPI2_SCK |
| 149 | #define P_SPI2_SCK P_UNDEF | 171 | #define P_SPI2_SCK P_UNDEF |
| 150 | #endif | 172 | #endif |
| @@ -513,6 +535,22 @@ | |||
| 513 | #define P_SPI0_SSEL3 P_UNDEF | 535 | #define P_SPI0_SSEL3 P_UNDEF |
| 514 | #endif | 536 | #endif |
| 515 | 537 | ||
| 538 | #ifndef P_SPI0_SSEL4 | ||
| 539 | #define P_SPI0_SSEL4 P_UNDEF | ||
| 540 | #endif | ||
| 541 | |||
| 542 | #ifndef P_SPI0_SSEL5 | ||
| 543 | #define P_SPI0_SSEL5 P_UNDEF | ||
| 544 | #endif | ||
| 545 | |||
| 546 | #ifndef P_SPI0_SSEL6 | ||
| 547 | #define P_SPI0_SSEL6 P_UNDEF | ||
| 548 | #endif | ||
| 549 | |||
| 550 | #ifndef P_SPI0_SSEL7 | ||
| 551 | #define P_SPI0_SSEL7 P_UNDEF | ||
| 552 | #endif | ||
| 553 | |||
| 516 | #ifndef P_UART0_TX | 554 | #ifndef P_UART0_TX |
| 517 | #define P_UART0_TX P_UNDEF | 555 | #define P_UART0_TX P_UNDEF |
| 518 | #endif | 556 | #endif |
| @@ -741,6 +779,23 @@ | |||
| 741 | #define P_SPI1_SSEL3 P_UNDEF | 779 | #define P_SPI1_SSEL3 P_UNDEF |
| 742 | #endif | 780 | #endif |
| 743 | 781 | ||
| 782 | |||
| 783 | #ifndef P_SPI1_SSEL4 | ||
| 784 | #define P_SPI1_SSEL4 P_UNDEF | ||
| 785 | #endif | ||
| 786 | |||
| 787 | #ifndef P_SPI1_SSEL5 | ||
| 788 | #define P_SPI1_SSEL5 P_UNDEF | ||
| 789 | #endif | ||
| 790 | |||
| 791 | #ifndef P_SPI1_SSEL6 | ||
| 792 | #define P_SPI1_SSEL6 P_UNDEF | ||
| 793 | #endif | ||
| 794 | |||
| 795 | #ifndef P_SPI1_SSEL7 | ||
| 796 | #define P_SPI1_SSEL7 P_UNDEF | ||
| 797 | #endif | ||
| 798 | |||
| 744 | #ifndef P_SPI1_SCK | 799 | #ifndef P_SPI1_SCK |
| 745 | #define P_SPI1_SCK P_UNDEF | 800 | #define P_SPI1_SCK P_UNDEF |
| 746 | #endif | 801 | #endif |
