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.c448
1 files changed, 249 insertions, 199 deletions
diff --git a/arch/blackfin/kernel/bfin_gpio.c b/arch/blackfin/kernel/bfin_gpio.c
index 5c0800adb4dd..4c14331978f6 100644
--- a/arch/blackfin/kernel/bfin_gpio.c
+++ b/arch/blackfin/kernel/bfin_gpio.c
@@ -119,28 +119,28 @@ enum {
119#define AWA_DUMMY_READ(...) do { } while (0) 119#define AWA_DUMMY_READ(...) do { } while (0)
120#endif 120#endif
121 121
122#ifdef BF533_FAMILY 122#if defined(BF533_FAMILY) || defined(BF538_FAMILY)
123static struct gpio_port_t *gpio_bankb[gpio_bank(MAX_BLACKFIN_GPIOS)] = { 123static struct gpio_port_t *gpio_bankb[] = {
124 (struct gpio_port_t *) FIO_FLAG_D, 124 (struct gpio_port_t *) FIO_FLAG_D,
125}; 125};
126#endif 126#endif
127 127
128#if defined(BF527_FAMILY) || defined(BF537_FAMILY) 128#if defined(BF527_FAMILY) || defined(BF537_FAMILY) || defined(BF518_FAMILY)
129static struct gpio_port_t *gpio_bankb[gpio_bank(MAX_BLACKFIN_GPIOS)] = { 129static struct gpio_port_t *gpio_bankb[] = {
130 (struct gpio_port_t *) PORTFIO, 130 (struct gpio_port_t *) PORTFIO,
131 (struct gpio_port_t *) PORTGIO, 131 (struct gpio_port_t *) PORTGIO,
132 (struct gpio_port_t *) PORTHIO, 132 (struct gpio_port_t *) PORTHIO,
133}; 133};
134 134
135static unsigned short *port_fer[gpio_bank(MAX_BLACKFIN_GPIOS)] = { 135static unsigned short *port_fer[] = {
136 (unsigned short *) PORTF_FER, 136 (unsigned short *) PORTF_FER,
137 (unsigned short *) PORTG_FER, 137 (unsigned short *) PORTG_FER,
138 (unsigned short *) PORTH_FER, 138 (unsigned short *) PORTH_FER,
139}; 139};
140#endif 140#endif
141 141
142#ifdef BF527_FAMILY 142#if defined(BF527_FAMILY) || defined(BF518_FAMILY)
143static unsigned short *port_mux[gpio_bank(MAX_BLACKFIN_GPIOS)] = { 143static unsigned short *port_mux[] = {
144 (unsigned short *) PORTF_MUX, 144 (unsigned short *) PORTF_MUX,
145 (unsigned short *) PORTG_MUX, 145 (unsigned short *) PORTG_MUX,
146 (unsigned short *) PORTH_MUX, 146 (unsigned short *) PORTH_MUX,
@@ -155,7 +155,7 @@ u8 pmux_offset[][16] =
155#endif 155#endif
156 156
157#ifdef BF561_FAMILY 157#ifdef BF561_FAMILY
158static struct gpio_port_t *gpio_bankb[gpio_bank(MAX_BLACKFIN_GPIOS)] = { 158static struct gpio_port_t *gpio_bankb[] = {
159 (struct gpio_port_t *) FIO0_FLAG_D, 159 (struct gpio_port_t *) FIO0_FLAG_D,
160 (struct gpio_port_t *) FIO1_FLAG_D, 160 (struct gpio_port_t *) FIO1_FLAG_D,
161 (struct gpio_port_t *) FIO2_FLAG_D, 161 (struct gpio_port_t *) FIO2_FLAG_D,
@@ -163,7 +163,7 @@ static struct gpio_port_t *gpio_bankb[gpio_bank(MAX_BLACKFIN_GPIOS)] = {
163#endif 163#endif
164 164
165#ifdef BF548_FAMILY 165#ifdef BF548_FAMILY
166static struct gpio_port_t *gpio_array[gpio_bank(MAX_BLACKFIN_GPIOS)] = { 166static struct gpio_port_t *gpio_array[] = {
167 (struct gpio_port_t *)PORTA_FER, 167 (struct gpio_port_t *)PORTA_FER,
168 (struct gpio_port_t *)PORTB_FER, 168 (struct gpio_port_t *)PORTB_FER,
169 (struct gpio_port_t *)PORTC_FER, 169 (struct gpio_port_t *)PORTC_FER,
@@ -177,8 +177,9 @@ static struct gpio_port_t *gpio_array[gpio_bank(MAX_BLACKFIN_GPIOS)] = {
177}; 177};
178#endif 178#endif
179 179
180static unsigned short reserved_gpio_map[gpio_bank(MAX_BLACKFIN_GPIOS)]; 180static unsigned short reserved_gpio_map[GPIO_BANK_NUM];
181static unsigned short reserved_peri_map[gpio_bank(MAX_RESOURCES)]; 181static unsigned short reserved_peri_map[gpio_bank(MAX_RESOURCES)];
182static unsigned short reserved_gpio_irq_map[GPIO_BANK_NUM];
182 183
183#define RESOURCE_LABEL_SIZE 16 184#define RESOURCE_LABEL_SIZE 16
184 185
@@ -188,48 +189,46 @@ static struct str_ident {
188 189
189#if defined(CONFIG_PM) 190#if defined(CONFIG_PM)
190#if defined(CONFIG_BF54x) 191#if defined(CONFIG_BF54x)
191static struct gpio_port_s gpio_bank_saved[gpio_bank(MAX_BLACKFIN_GPIOS)]; 192static struct gpio_port_s gpio_bank_saved[GPIO_BANK_NUM];
192#else 193#else
193static unsigned short wakeup_map[gpio_bank(MAX_BLACKFIN_GPIOS)]; 194static unsigned short wakeup_map[GPIO_BANK_NUM];
194static unsigned char wakeup_flags_map[MAX_BLACKFIN_GPIOS]; 195static unsigned char wakeup_flags_map[MAX_BLACKFIN_GPIOS];
195static struct gpio_port_s gpio_bank_saved[gpio_bank(MAX_BLACKFIN_GPIOS)]; 196static struct gpio_port_s gpio_bank_saved[GPIO_BANK_NUM];
196 197
197#ifdef BF533_FAMILY 198#ifdef BF533_FAMILY
198static unsigned int sic_iwr_irqs[gpio_bank(MAX_BLACKFIN_GPIOS)] = {IRQ_PROG_INTB}; 199static unsigned int sic_iwr_irqs[] = {IRQ_PROG_INTB};
199#endif 200#endif
200 201
201#ifdef BF537_FAMILY 202#ifdef BF537_FAMILY
202static unsigned int sic_iwr_irqs[gpio_bank(MAX_BLACKFIN_GPIOS)] = {IRQ_PROG_INTB, IRQ_PORTG_INTB, IRQ_MAC_TX}; 203static unsigned int sic_iwr_irqs[] = {IRQ_PROG_INTB, IRQ_PORTG_INTB, IRQ_MAC_TX};
204#endif
205
206#ifdef BF538_FAMILY
207static unsigned int sic_iwr_irqs[] = {IRQ_PORTF_INTB};
203#endif 208#endif
204 209
205#ifdef BF527_FAMILY 210#if defined(BF527_FAMILY) || defined(BF518_FAMILY)
206static unsigned int sic_iwr_irqs[gpio_bank(MAX_BLACKFIN_GPIOS)] = {IRQ_PORTF_INTB, IRQ_PORTG_INTB, IRQ_PORTH_INTB}; 211static unsigned int sic_iwr_irqs[] = {IRQ_PORTF_INTB, IRQ_PORTG_INTB, IRQ_PORTH_INTB};
207#endif 212#endif
208 213
209#ifdef BF561_FAMILY 214#ifdef BF561_FAMILY
210static unsigned int sic_iwr_irqs[gpio_bank(MAX_BLACKFIN_GPIOS)] = {IRQ_PROG0_INTB, IRQ_PROG1_INTB, IRQ_PROG2_INTB}; 215static unsigned int sic_iwr_irqs[] = {IRQ_PROG0_INTB, IRQ_PROG1_INTB, IRQ_PROG2_INTB};
211#endif 216#endif
212#endif 217#endif
213#endif /* CONFIG_PM */ 218#endif /* CONFIG_PM */
214 219
215#if defined(BF548_FAMILY)
216inline int check_gpio(unsigned gpio) 220inline int check_gpio(unsigned gpio)
217{ 221{
222#if defined(BF548_FAMILY)
218 if (gpio == GPIO_PB15 || gpio == GPIO_PC14 || gpio == GPIO_PC15 223 if (gpio == GPIO_PB15 || gpio == GPIO_PC14 || gpio == GPIO_PC15
219 || gpio == GPIO_PH14 || gpio == GPIO_PH15 224 || gpio == GPIO_PH14 || gpio == GPIO_PH15
220 || gpio == GPIO_PJ14 || gpio == GPIO_PJ15 225 || gpio == GPIO_PJ14 || gpio == GPIO_PJ15)
221 || gpio >= MAX_BLACKFIN_GPIOS)
222 return -EINVAL; 226 return -EINVAL;
223 return 0; 227#endif
224}
225#else
226inline int check_gpio(unsigned gpio)
227{
228 if (gpio >= MAX_BLACKFIN_GPIOS) 228 if (gpio >= MAX_BLACKFIN_GPIOS)
229 return -EINVAL; 229 return -EINVAL;
230 return 0; 230 return 0;
231} 231}
232#endif
233 232
234static void gpio_error(unsigned gpio) 233static void gpio_error(unsigned gpio)
235{ 234{
@@ -258,35 +257,30 @@ static int cmp_label(unsigned short ident, const char *label)
258 } 257 }
259 258
260 if (label) 259 if (label)
261 return strncmp(str_ident[ident].name, 260 return strcmp(str_ident[ident].name, label);
262 label, strlen(label));
263 else 261 else
264 return -EINVAL; 262 return -EINVAL;
265} 263}
266 264
267#if defined(BF527_FAMILY) || defined(BF537_FAMILY)
268static void port_setup(unsigned gpio, unsigned short usage) 265static void port_setup(unsigned gpio, unsigned short usage)
269{ 266{
270 if (!check_gpio(gpio)) { 267 if (check_gpio(gpio))
271 if (usage == GPIO_USAGE) 268 return;
272 *port_fer[gpio_bank(gpio)] &= ~gpio_bit(gpio); 269
273 else 270#if defined(BF527_FAMILY) || defined(BF537_FAMILY) || defined(BF518_FAMILY)
274 *port_fer[gpio_bank(gpio)] |= gpio_bit(gpio); 271 if (usage == GPIO_USAGE)
275 SSYNC(); 272 *port_fer[gpio_bank(gpio)] &= ~gpio_bit(gpio);
276 } 273 else
277} 274 *port_fer[gpio_bank(gpio)] |= gpio_bit(gpio);
275 SSYNC();
278#elif defined(BF548_FAMILY) 276#elif defined(BF548_FAMILY)
279static void port_setup(unsigned gpio, unsigned short usage)
280{
281 if (usage == GPIO_USAGE) 277 if (usage == GPIO_USAGE)
282 gpio_array[gpio_bank(gpio)]->port_fer &= ~gpio_bit(gpio); 278 gpio_array[gpio_bank(gpio)]->port_fer &= ~gpio_bit(gpio);
283 else 279 else
284 gpio_array[gpio_bank(gpio)]->port_fer |= gpio_bit(gpio); 280 gpio_array[gpio_bank(gpio)]->port_fer |= gpio_bit(gpio);
285 SSYNC(); 281 SSYNC();
286}
287#else
288# define port_setup(...) do { } while (0)
289#endif 282#endif
283}
290 284
291#ifdef BF537_FAMILY 285#ifdef BF537_FAMILY
292static struct { 286static struct {
@@ -379,7 +373,7 @@ inline u16 get_portmux(unsigned short portno)
379 373
380 return (pmux >> (2 * gpio_sub_n(portno)) & 0x3); 374 return (pmux >> (2 * gpio_sub_n(portno)) & 0x3);
381} 375}
382#elif defined(BF527_FAMILY) 376#elif defined(BF527_FAMILY) || defined(BF518_FAMILY)
383inline void portmux_setup(unsigned short portno, unsigned short function) 377inline void portmux_setup(unsigned short portno, unsigned short function)
384{ 378{
385 u16 pmux, ident = P_IDENT(portno); 379 u16 pmux, ident = P_IDENT(portno);
@@ -428,13 +422,13 @@ arch_initcall(bfin_gpio_init);
428void set_gpio_ ## name(unsigned gpio, unsigned short arg) \ 422void set_gpio_ ## name(unsigned gpio, unsigned short arg) \
429{ \ 423{ \
430 unsigned long flags; \ 424 unsigned long flags; \
431 local_irq_save(flags); \ 425 local_irq_save_hw(flags); \
432 if (arg) \ 426 if (arg) \
433 gpio_bankb[gpio_bank(gpio)]->name |= gpio_bit(gpio); \ 427 gpio_bankb[gpio_bank(gpio)]->name |= gpio_bit(gpio); \
434 else \ 428 else \
435 gpio_bankb[gpio_bank(gpio)]->name &= ~gpio_bit(gpio); \ 429 gpio_bankb[gpio_bank(gpio)]->name &= ~gpio_bit(gpio); \
436 AWA_DUMMY_READ(name); \ 430 AWA_DUMMY_READ(name); \
437 local_irq_restore(flags); \ 431 local_irq_restore_hw(flags); \
438} \ 432} \
439EXPORT_SYMBOL(set_gpio_ ## name); 433EXPORT_SYMBOL(set_gpio_ ## name);
440 434
@@ -450,13 +444,13 @@ SET_GPIO(both)
450void set_gpio_ ## name(unsigned gpio, unsigned short arg) \ 444void set_gpio_ ## name(unsigned gpio, unsigned short arg) \
451{ \ 445{ \
452 unsigned long flags; \ 446 unsigned long flags; \
453 local_irq_save(flags); \ 447 local_irq_save_hw(flags); \
454 if (arg) \ 448 if (arg) \
455 gpio_bankb[gpio_bank(gpio)]->name ## _set = gpio_bit(gpio); \ 449 gpio_bankb[gpio_bank(gpio)]->name ## _set = gpio_bit(gpio); \
456 else \ 450 else \
457 gpio_bankb[gpio_bank(gpio)]->name ## _clear = gpio_bit(gpio); \ 451 gpio_bankb[gpio_bank(gpio)]->name ## _clear = gpio_bit(gpio); \
458 AWA_DUMMY_READ(name); \ 452 AWA_DUMMY_READ(name); \
459 local_irq_restore(flags); \ 453 local_irq_restore_hw(flags); \
460} \ 454} \
461EXPORT_SYMBOL(set_gpio_ ## name); 455EXPORT_SYMBOL(set_gpio_ ## name);
462#else 456#else
@@ -479,10 +473,10 @@ SET_GPIO_SC(data)
479void set_gpio_toggle(unsigned gpio) 473void set_gpio_toggle(unsigned gpio)
480{ 474{
481 unsigned long flags; 475 unsigned long flags;
482 local_irq_save(flags); 476 local_irq_save_hw(flags);
483 gpio_bankb[gpio_bank(gpio)]->toggle = gpio_bit(gpio); 477 gpio_bankb[gpio_bank(gpio)]->toggle = gpio_bit(gpio);
484 AWA_DUMMY_READ(toggle); 478 AWA_DUMMY_READ(toggle);
485 local_irq_restore(flags); 479 local_irq_restore_hw(flags);
486} 480}
487#else 481#else
488void set_gpio_toggle(unsigned gpio) 482void set_gpio_toggle(unsigned gpio)
@@ -500,10 +494,10 @@ EXPORT_SYMBOL(set_gpio_toggle);
500void set_gpiop_ ## name(unsigned gpio, unsigned short arg) \ 494void set_gpiop_ ## name(unsigned gpio, unsigned short arg) \
501{ \ 495{ \
502 unsigned long flags; \ 496 unsigned long flags; \
503 local_irq_save(flags); \ 497 local_irq_save_hw(flags); \
504 gpio_bankb[gpio_bank(gpio)]->name = arg; \ 498 gpio_bankb[gpio_bank(gpio)]->name = arg; \
505 AWA_DUMMY_READ(name); \ 499 AWA_DUMMY_READ(name); \
506 local_irq_restore(flags); \ 500 local_irq_restore_hw(flags); \
507} \ 501} \
508EXPORT_SYMBOL(set_gpiop_ ## name); 502EXPORT_SYMBOL(set_gpiop_ ## name);
509#else 503#else
@@ -531,10 +525,10 @@ unsigned short get_gpio_ ## name(unsigned gpio) \
531{ \ 525{ \
532 unsigned long flags; \ 526 unsigned long flags; \
533 unsigned short ret; \ 527 unsigned short ret; \
534 local_irq_save(flags); \ 528 local_irq_save_hw(flags); \
535 ret = 0x01 & (gpio_bankb[gpio_bank(gpio)]->name >> gpio_sub_n(gpio)); \ 529 ret = 0x01 & (gpio_bankb[gpio_bank(gpio)]->name >> gpio_sub_n(gpio)); \
536 AWA_DUMMY_READ(name); \ 530 AWA_DUMMY_READ(name); \
537 local_irq_restore(flags); \ 531 local_irq_restore_hw(flags); \
538 return ret; \ 532 return ret; \
539} \ 533} \
540EXPORT_SYMBOL(get_gpio_ ## name); 534EXPORT_SYMBOL(get_gpio_ ## name);
@@ -564,10 +558,10 @@ unsigned short get_gpiop_ ## name(unsigned gpio) \
564{ \ 558{ \
565 unsigned long flags; \ 559 unsigned long flags; \
566 unsigned short ret; \ 560 unsigned short ret; \
567 local_irq_save(flags); \ 561 local_irq_save_hw(flags); \
568 ret = (gpio_bankb[gpio_bank(gpio)]->name); \ 562 ret = (gpio_bankb[gpio_bank(gpio)]->name); \
569 AWA_DUMMY_READ(name); \ 563 AWA_DUMMY_READ(name); \
570 local_irq_restore(flags); \ 564 local_irq_restore_hw(flags); \
571 return ret; \ 565 return ret; \
572} \ 566} \
573EXPORT_SYMBOL(get_gpiop_ ## name); 567EXPORT_SYMBOL(get_gpiop_ ## name);
@@ -617,10 +611,10 @@ int gpio_pm_wakeup_request(unsigned gpio, unsigned char type)
617 if ((check_gpio(gpio) < 0) || !type) 611 if ((check_gpio(gpio) < 0) || !type)
618 return -EINVAL; 612 return -EINVAL;
619 613
620 local_irq_save(flags); 614 local_irq_save_hw(flags);
621 wakeup_map[gpio_bank(gpio)] |= gpio_bit(gpio); 615 wakeup_map[gpio_bank(gpio)] |= gpio_bit(gpio);
622 wakeup_flags_map[gpio] = type; 616 wakeup_flags_map[gpio] = type;
623 local_irq_restore(flags); 617 local_irq_restore_hw(flags);
624 618
625 return 0; 619 return 0;
626} 620}
@@ -633,11 +627,11 @@ void gpio_pm_wakeup_free(unsigned gpio)
633 if (check_gpio(gpio) < 0) 627 if (check_gpio(gpio) < 0)
634 return; 628 return;
635 629
636 local_irq_save(flags); 630 local_irq_save_hw(flags);
637 631
638 wakeup_map[gpio_bank(gpio)] &= ~gpio_bit(gpio); 632 wakeup_map[gpio_bank(gpio)] &= ~gpio_bit(gpio);
639 633
640 local_irq_restore(flags); 634 local_irq_restore_hw(flags);
641} 635}
642EXPORT_SYMBOL(gpio_pm_wakeup_free); 636EXPORT_SYMBOL(gpio_pm_wakeup_free);
643 637
@@ -679,7 +673,7 @@ u32 bfin_pm_standby_setup(void)
679 gpio_bankb[bank]->maskb = 0; 673 gpio_bankb[bank]->maskb = 0;
680 674
681 if (mask) { 675 if (mask) {
682#if defined(BF527_FAMILY) || defined(BF537_FAMILY) 676#if defined(BF527_FAMILY) || defined(BF537_FAMILY) || defined(BF518_FAMILY)
683 gpio_bank_saved[bank].fer = *port_fer[bank]; 677 gpio_bank_saved[bank].fer = *port_fer[bank];
684#endif 678#endif
685 gpio_bank_saved[bank].inen = gpio_bankb[bank]->inen; 679 gpio_bank_saved[bank].inen = gpio_bankb[bank]->inen;
@@ -724,7 +718,7 @@ void bfin_pm_standby_restore(void)
724 bank = gpio_bank(i); 718 bank = gpio_bank(i);
725 719
726 if (mask) { 720 if (mask) {
727#if defined(BF527_FAMILY) || defined(BF537_FAMILY) 721#if defined(BF527_FAMILY) || defined(BF537_FAMILY) || defined(BF518_FAMILY)
728 *port_fer[bank] = gpio_bank_saved[bank].fer; 722 *port_fer[bank] = gpio_bank_saved[bank].fer;
729#endif 723#endif
730 gpio_bankb[bank]->inen = gpio_bank_saved[bank].inen; 724 gpio_bankb[bank]->inen = gpio_bank_saved[bank].inen;
@@ -750,9 +744,9 @@ void bfin_gpio_pm_hibernate_suspend(void)
750 for (i = 0; i < MAX_BLACKFIN_GPIOS; i += GPIO_BANKSIZE) { 744 for (i = 0; i < MAX_BLACKFIN_GPIOS; i += GPIO_BANKSIZE) {
751 bank = gpio_bank(i); 745 bank = gpio_bank(i);
752 746
753#if defined(BF527_FAMILY) || defined(BF537_FAMILY) 747#if defined(BF527_FAMILY) || defined(BF537_FAMILY) || defined(BF518_FAMILY)
754 gpio_bank_saved[bank].fer = *port_fer[bank]; 748 gpio_bank_saved[bank].fer = *port_fer[bank];
755#ifdef BF527_FAMILY 749#if defined(BF527_FAMILY) || defined(BF518_FAMILY)
756 gpio_bank_saved[bank].mux = *port_mux[bank]; 750 gpio_bank_saved[bank].mux = *port_mux[bank];
757#else 751#else
758 if (bank == 0) 752 if (bank == 0)
@@ -778,8 +772,8 @@ void bfin_gpio_pm_hibernate_restore(void)
778 for (i = 0; i < MAX_BLACKFIN_GPIOS; i += GPIO_BANKSIZE) { 772 for (i = 0; i < MAX_BLACKFIN_GPIOS; i += GPIO_BANKSIZE) {
779 bank = gpio_bank(i); 773 bank = gpio_bank(i);
780 774
781#if defined(BF527_FAMILY) || defined(BF537_FAMILY) 775#if defined(BF527_FAMILY) || defined(BF537_FAMILY) || defined(BF518_FAMILY)
782#ifdef BF527_FAMILY 776#if defined(BF527_FAMILY) || defined(BF518_FAMILY)
783 *port_mux[bank] = gpio_bank_saved[bank].mux; 777 *port_mux[bank] = gpio_bank_saved[bank].mux;
784#else 778#else
785 if (bank == 0) 779 if (bank == 0)
@@ -873,7 +867,6 @@ EXPORT_SYMBOL(get_gpio_dir);
873* MODIFICATION HISTORY : 867* MODIFICATION HISTORY :
874**************************************************************/ 868**************************************************************/
875 869
876#ifdef BF548_FAMILY
877int peripheral_request(unsigned short per, const char *label) 870int peripheral_request(unsigned short per, const char *label)
878{ 871{
879 unsigned long flags; 872 unsigned long flags;
@@ -889,31 +882,35 @@ int peripheral_request(unsigned short per, const char *label)
889 if (!(per & P_DEFINED)) 882 if (!(per & P_DEFINED))
890 return -ENODEV; 883 return -ENODEV;
891 884
892 if (check_gpio(ident) < 0) 885 local_irq_save_hw(flags);
893 return -EINVAL;
894 886
895 local_irq_save(flags); 887 /* If a pin can be muxed as either GPIO or peripheral, make
896 888 * sure it is not already a GPIO pin when we request it.
897 if (unlikely(reserved_gpio_map[gpio_bank(ident)] & gpio_bit(ident))) { 889 */
890 if (unlikely(!check_gpio(ident) &&
891 reserved_gpio_map[gpio_bank(ident)] & gpio_bit(ident))) {
898 dump_stack(); 892 dump_stack();
899 printk(KERN_ERR 893 printk(KERN_ERR
900 "%s: Peripheral %d is already reserved as GPIO by %s !\n", 894 "%s: Peripheral %d is already reserved as GPIO by %s !\n",
901 __func__, ident, get_label(ident)); 895 __func__, ident, get_label(ident));
902 local_irq_restore(flags); 896 local_irq_restore_hw(flags);
903 return -EBUSY; 897 return -EBUSY;
904 } 898 }
905 899
906 if (unlikely(reserved_peri_map[gpio_bank(ident)] & gpio_bit(ident))) { 900 if (unlikely(reserved_peri_map[gpio_bank(ident)] & gpio_bit(ident))) {
907 901
908 u16 funct = get_portmux(ident);
909
910 /* 902 /*
911 * Pin functions like AMC address strobes my 903 * Pin functions like AMC address strobes my
912 * be requested and used by several drivers 904 * be requested and used by several drivers
913 */ 905 */
914 906
915 if (!((per & P_MAYSHARE) && (funct == P_FUNCT2MUX(per)))) { 907#ifdef BF548_FAMILY
908 u16 funct = get_portmux(ident);
916 909
910 if (!((per & P_MAYSHARE) && (funct == P_FUNCT2MUX(per)))) {
911#else
912 if (!(per & P_MAYSHARE)) {
913#endif
917 /* 914 /*
918 * Allow that the identical pin function can 915 * Allow that the identical pin function can
919 * be requested from the same driver twice 916 * be requested from the same driver twice
@@ -926,7 +923,7 @@ int peripheral_request(unsigned short per, const char *label)
926 printk(KERN_ERR 923 printk(KERN_ERR
927 "%s: Peripheral %d function %d is already reserved by %s !\n", 924 "%s: Peripheral %d function %d is already reserved by %s !\n",
928 __func__, ident, P_FUNCT2MUX(per), get_label(ident)); 925 __func__, ident, P_FUNCT2MUX(per), get_label(ident));
929 local_irq_restore(flags); 926 local_irq_restore_hw(flags);
930 return -EBUSY; 927 return -EBUSY;
931 } 928 }
932 } 929 }
@@ -934,89 +931,19 @@ int peripheral_request(unsigned short per, const char *label)
934 anyway: 931 anyway:
935 reserved_peri_map[gpio_bank(ident)] |= gpio_bit(ident); 932 reserved_peri_map[gpio_bank(ident)] |= gpio_bit(ident);
936 933
934#ifdef BF548_FAMILY
937 portmux_setup(ident, P_FUNCT2MUX(per)); 935 portmux_setup(ident, P_FUNCT2MUX(per));
938 port_setup(ident, PERIPHERAL_USAGE);
939
940 local_irq_restore(flags);
941 set_label(ident, label);
942
943 return 0;
944}
945EXPORT_SYMBOL(peripheral_request);
946#else 936#else
947
948int peripheral_request(unsigned short per, const char *label)
949{
950 unsigned long flags;
951 unsigned short ident = P_IDENT(per);
952
953 /*
954 * Don't cares are pins with only one dedicated function
955 */
956
957 if (per & P_DONTCARE)
958 return 0;
959
960 if (!(per & P_DEFINED))
961 return -ENODEV;
962
963 local_irq_save(flags);
964
965 if (!check_gpio(ident)) {
966
967 if (unlikely(reserved_gpio_map[gpio_bank(ident)] & gpio_bit(ident))) {
968 dump_stack();
969 printk(KERN_ERR
970 "%s: Peripheral %d is already reserved as GPIO by %s !\n",
971 __func__, ident, get_label(ident));
972 local_irq_restore(flags);
973 return -EBUSY;
974 }
975
976 }
977
978 if (unlikely(reserved_peri_map[gpio_bank(ident)] & gpio_bit(ident))) {
979
980 /*
981 * Pin functions like AMC address strobes my
982 * be requested and used by several drivers
983 */
984
985 if (!(per & P_MAYSHARE)) {
986
987 /*
988 * Allow that the identical pin function can
989 * be requested from the same driver twice
990 */
991
992 if (cmp_label(ident, label) == 0)
993 goto anyway;
994
995 dump_stack();
996 printk(KERN_ERR
997 "%s: Peripheral %d function %d is already"
998 " reserved by %s !\n",
999 __func__, ident, P_FUNCT2MUX(per),
1000 get_label(ident));
1001 local_irq_restore(flags);
1002 return -EBUSY;
1003 }
1004
1005 }
1006
1007 anyway:
1008 portmux_setup(per, P_FUNCT2MUX(per)); 937 portmux_setup(per, P_FUNCT2MUX(per));
1009 938#endif
1010 port_setup(ident, PERIPHERAL_USAGE); 939 port_setup(ident, PERIPHERAL_USAGE);
1011 940
1012 reserved_peri_map[gpio_bank(ident)] |= gpio_bit(ident); 941 local_irq_restore_hw(flags);
1013 local_irq_restore(flags);
1014 set_label(ident, label); 942 set_label(ident, label);
1015 943
1016 return 0; 944 return 0;
1017} 945}
1018EXPORT_SYMBOL(peripheral_request); 946EXPORT_SYMBOL(peripheral_request);
1019#endif
1020 947
1021int peripheral_request_list(const unsigned short per[], const char *label) 948int peripheral_request_list(const unsigned short per[], const char *label)
1022{ 949{
@@ -1053,10 +980,10 @@ void peripheral_free(unsigned short per)
1053 if (check_gpio(ident) < 0) 980 if (check_gpio(ident) < 0)
1054 return; 981 return;
1055 982
1056 local_irq_save(flags); 983 local_irq_save_hw(flags);
1057 984
1058 if (unlikely(!(reserved_peri_map[gpio_bank(ident)] & gpio_bit(ident)))) { 985 if (unlikely(!(reserved_peri_map[gpio_bank(ident)] & gpio_bit(ident)))) {
1059 local_irq_restore(flags); 986 local_irq_restore_hw(flags);
1060 return; 987 return;
1061 } 988 }
1062 989
@@ -1067,7 +994,7 @@ void peripheral_free(unsigned short per)
1067 994
1068 set_label(ident, "free"); 995 set_label(ident, "free");
1069 996
1070 local_irq_restore(flags); 997 local_irq_restore_hw(flags);
1071} 998}
1072EXPORT_SYMBOL(peripheral_free); 999EXPORT_SYMBOL(peripheral_free);
1073 1000
@@ -1094,14 +1021,14 @@ EXPORT_SYMBOL(peripheral_free_list);
1094* MODIFICATION HISTORY : 1021* MODIFICATION HISTORY :
1095**************************************************************/ 1022**************************************************************/
1096 1023
1097int gpio_request(unsigned gpio, const char *label) 1024int bfin_gpio_request(unsigned gpio, const char *label)
1098{ 1025{
1099 unsigned long flags; 1026 unsigned long flags;
1100 1027
1101 if (check_gpio(gpio) < 0) 1028 if (check_gpio(gpio) < 0)
1102 return -EINVAL; 1029 return -EINVAL;
1103 1030
1104 local_irq_save(flags); 1031 local_irq_save_hw(flags);
1105 1032
1106 /* 1033 /*
1107 * Allow that the identical GPIO can 1034 * Allow that the identical GPIO can
@@ -1110,15 +1037,15 @@ int gpio_request(unsigned gpio, const char *label)
1110 */ 1037 */
1111 1038
1112 if (cmp_label(gpio, label) == 0) { 1039 if (cmp_label(gpio, label) == 0) {
1113 local_irq_restore(flags); 1040 local_irq_restore_hw(flags);
1114 return 0; 1041 return 0;
1115 } 1042 }
1116 1043
1117 if (unlikely(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))) { 1044 if (unlikely(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))) {
1118 dump_stack(); 1045 dump_stack();
1119 printk(KERN_ERR "bfin-gpio: GPIO %d is already reserved by %s !\n", 1046 printk(KERN_ERR "bfin-gpio: GPIO %d is already reserved by %s !\n",
1120 gpio, get_label(gpio)); 1047 gpio, get_label(gpio));
1121 local_irq_restore(flags); 1048 local_irq_restore_hw(flags);
1122 return -EBUSY; 1049 return -EBUSY;
1123 } 1050 }
1124 if (unlikely(reserved_peri_map[gpio_bank(gpio)] & gpio_bit(gpio))) { 1051 if (unlikely(reserved_peri_map[gpio_bank(gpio)] & gpio_bit(gpio))) {
@@ -1126,34 +1053,37 @@ int gpio_request(unsigned gpio, const char *label)
1126 printk(KERN_ERR 1053 printk(KERN_ERR
1127 "bfin-gpio: GPIO %d is already reserved as Peripheral by %s !\n", 1054 "bfin-gpio: GPIO %d is already reserved as Peripheral by %s !\n",
1128 gpio, get_label(gpio)); 1055 gpio, get_label(gpio));
1129 local_irq_restore(flags); 1056 local_irq_restore_hw(flags);
1130 return -EBUSY; 1057 return -EBUSY;
1131 } 1058 }
1059 if (unlikely(reserved_gpio_irq_map[gpio_bank(gpio)] & gpio_bit(gpio)))
1060 printk(KERN_NOTICE "bfin-gpio: GPIO %d is already reserved as gpio-irq!"
1061 " (Documentation/blackfin/bfin-gpio-notes.txt)\n", gpio);
1132 1062
1133 reserved_gpio_map[gpio_bank(gpio)] |= gpio_bit(gpio); 1063 reserved_gpio_map[gpio_bank(gpio)] |= gpio_bit(gpio);
1064 set_label(gpio, label);
1134 1065
1135 local_irq_restore(flags); 1066 local_irq_restore_hw(flags);
1136 1067
1137 port_setup(gpio, GPIO_USAGE); 1068 port_setup(gpio, GPIO_USAGE);
1138 set_label(gpio, label);
1139 1069
1140 return 0; 1070 return 0;
1141} 1071}
1142EXPORT_SYMBOL(gpio_request); 1072EXPORT_SYMBOL(bfin_gpio_request);
1143 1073
1144void gpio_free(unsigned gpio) 1074void bfin_gpio_free(unsigned gpio)
1145{ 1075{
1146 unsigned long flags; 1076 unsigned long flags;
1147 1077
1148 if (check_gpio(gpio) < 0) 1078 if (check_gpio(gpio) < 0)
1149 return; 1079 return;
1150 1080
1151 local_irq_save(flags); 1081 local_irq_save_hw(flags);
1152 1082
1153 if (unlikely(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio)))) { 1083 if (unlikely(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio)))) {
1154 dump_stack(); 1084 dump_stack();
1155 gpio_error(gpio); 1085 gpio_error(gpio);
1156 local_irq_restore(flags); 1086 local_irq_restore_hw(flags);
1157 return; 1087 return;
1158 } 1088 }
1159 1089
@@ -1161,13 +1091,76 @@ void gpio_free(unsigned gpio)
1161 1091
1162 set_label(gpio, "free"); 1092 set_label(gpio, "free");
1163 1093
1164 local_irq_restore(flags); 1094 local_irq_restore_hw(flags);
1095}
1096EXPORT_SYMBOL(bfin_gpio_free);
1097
1098int bfin_gpio_irq_request(unsigned gpio, const char *label)
1099{
1100 unsigned long flags;
1101
1102 if (check_gpio(gpio) < 0)
1103 return -EINVAL;
1104
1105 local_irq_save_hw(flags);
1106
1107 if (unlikely(reserved_gpio_irq_map[gpio_bank(gpio)] & gpio_bit(gpio))) {
1108 dump_stack();
1109 printk(KERN_ERR
1110 "bfin-gpio: GPIO %d is already reserved as gpio-irq !\n",
1111 gpio);
1112 local_irq_restore_hw(flags);
1113 return -EBUSY;
1114 }
1115 if (unlikely(reserved_peri_map[gpio_bank(gpio)] & gpio_bit(gpio))) {
1116 dump_stack();
1117 printk(KERN_ERR
1118 "bfin-gpio: GPIO %d is already reserved as Peripheral by %s !\n",
1119 gpio, get_label(gpio));
1120 local_irq_restore_hw(flags);
1121 return -EBUSY;
1122 }
1123 if (unlikely(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio)))
1124 printk(KERN_NOTICE "bfin-gpio: GPIO %d is already reserved by %s! "
1125 "(Documentation/blackfin/bfin-gpio-notes.txt)\n",
1126 gpio, get_label(gpio));
1127
1128 reserved_gpio_irq_map[gpio_bank(gpio)] |= gpio_bit(gpio);
1129 set_label(gpio, label);
1130
1131 local_irq_restore_hw(flags);
1132
1133 port_setup(gpio, GPIO_USAGE);
1134
1135 return 0;
1136}
1137
1138void bfin_gpio_irq_free(unsigned gpio)
1139{
1140 unsigned long flags;
1141
1142 if (check_gpio(gpio) < 0)
1143 return;
1144
1145 local_irq_save_hw(flags);
1146
1147 if (unlikely(!(reserved_gpio_irq_map[gpio_bank(gpio)] & gpio_bit(gpio)))) {
1148 dump_stack();
1149 gpio_error(gpio);
1150 local_irq_restore_hw(flags);
1151 return;
1152 }
1153
1154 reserved_gpio_irq_map[gpio_bank(gpio)] &= ~gpio_bit(gpio);
1155
1156 set_label(gpio, "free");
1157
1158 local_irq_restore_hw(flags);
1165} 1159}
1166EXPORT_SYMBOL(gpio_free);
1167 1160
1168 1161
1169#ifdef BF548_FAMILY 1162#ifdef BF548_FAMILY
1170int gpio_direction_input(unsigned gpio) 1163int bfin_gpio_direction_input(unsigned gpio)
1171{ 1164{
1172 unsigned long flags; 1165 unsigned long flags;
1173 1166
@@ -1176,16 +1169,16 @@ int gpio_direction_input(unsigned gpio)
1176 return -EINVAL; 1169 return -EINVAL;
1177 } 1170 }
1178 1171
1179 local_irq_save(flags); 1172 local_irq_save_hw(flags);
1180 gpio_array[gpio_bank(gpio)]->port_dir_clear = gpio_bit(gpio); 1173 gpio_array[gpio_bank(gpio)]->port_dir_clear = gpio_bit(gpio);
1181 gpio_array[gpio_bank(gpio)]->port_inen |= gpio_bit(gpio); 1174 gpio_array[gpio_bank(gpio)]->port_inen |= gpio_bit(gpio);
1182 local_irq_restore(flags); 1175 local_irq_restore_hw(flags);
1183 1176
1184 return 0; 1177 return 0;
1185} 1178}
1186EXPORT_SYMBOL(gpio_direction_input); 1179EXPORT_SYMBOL(bfin_gpio_direction_input);
1187 1180
1188int gpio_direction_output(unsigned gpio, int value) 1181int bfin_gpio_direction_output(unsigned gpio, int value)
1189{ 1182{
1190 unsigned long flags; 1183 unsigned long flags;
1191 1184
@@ -1194,30 +1187,30 @@ int gpio_direction_output(unsigned gpio, int value)
1194 return -EINVAL; 1187 return -EINVAL;
1195 } 1188 }
1196 1189
1197 local_irq_save(flags); 1190 local_irq_save_hw(flags);
1198 gpio_array[gpio_bank(gpio)]->port_inen &= ~gpio_bit(gpio); 1191 gpio_array[gpio_bank(gpio)]->port_inen &= ~gpio_bit(gpio);
1199 gpio_set_value(gpio, value); 1192 gpio_set_value(gpio, value);
1200 gpio_array[gpio_bank(gpio)]->port_dir_set = gpio_bit(gpio); 1193 gpio_array[gpio_bank(gpio)]->port_dir_set = gpio_bit(gpio);
1201 local_irq_restore(flags); 1194 local_irq_restore_hw(flags);
1202 1195
1203 return 0; 1196 return 0;
1204} 1197}
1205EXPORT_SYMBOL(gpio_direction_output); 1198EXPORT_SYMBOL(bfin_gpio_direction_output);
1206 1199
1207void gpio_set_value(unsigned gpio, int arg) 1200void bfin_gpio_set_value(unsigned gpio, int arg)
1208{ 1201{
1209 if (arg) 1202 if (arg)
1210 gpio_array[gpio_bank(gpio)]->port_set = gpio_bit(gpio); 1203 gpio_array[gpio_bank(gpio)]->port_set = gpio_bit(gpio);
1211 else 1204 else
1212 gpio_array[gpio_bank(gpio)]->port_clear = gpio_bit(gpio); 1205 gpio_array[gpio_bank(gpio)]->port_clear = gpio_bit(gpio);
1213} 1206}
1214EXPORT_SYMBOL(gpio_set_value); 1207EXPORT_SYMBOL(bfin_gpio_set_value);
1215 1208
1216int gpio_get_value(unsigned gpio) 1209int bfin_gpio_get_value(unsigned gpio)
1217{ 1210{
1218 return (1 & (gpio_array[gpio_bank(gpio)]->port_data >> gpio_sub_n(gpio))); 1211 return (1 & (gpio_array[gpio_bank(gpio)]->port_data >> gpio_sub_n(gpio)));
1219} 1212}
1220EXPORT_SYMBOL(gpio_get_value); 1213EXPORT_SYMBOL(bfin_gpio_get_value);
1221 1214
1222void bfin_gpio_irq_prepare(unsigned gpio) 1215void bfin_gpio_irq_prepare(unsigned gpio)
1223{ 1216{
@@ -1225,34 +1218,34 @@ void bfin_gpio_irq_prepare(unsigned gpio)
1225 1218
1226 port_setup(gpio, GPIO_USAGE); 1219 port_setup(gpio, GPIO_USAGE);
1227 1220
1228 local_irq_save(flags); 1221 local_irq_save_hw(flags);
1229 gpio_array[gpio_bank(gpio)]->port_dir_clear = gpio_bit(gpio); 1222 gpio_array[gpio_bank(gpio)]->port_dir_clear = gpio_bit(gpio);
1230 gpio_array[gpio_bank(gpio)]->port_inen |= gpio_bit(gpio); 1223 gpio_array[gpio_bank(gpio)]->port_inen |= gpio_bit(gpio);
1231 local_irq_restore(flags); 1224 local_irq_restore_hw(flags);
1232} 1225}
1233 1226
1234#else 1227#else
1235 1228
1236int gpio_get_value(unsigned gpio) 1229int bfin_gpio_get_value(unsigned gpio)
1237{ 1230{
1238 unsigned long flags; 1231 unsigned long flags;
1239 int ret; 1232 int ret;
1240 1233
1241 if (unlikely(get_gpio_edge(gpio))) { 1234 if (unlikely(get_gpio_edge(gpio))) {
1242 local_irq_save(flags); 1235 local_irq_save_hw(flags);
1243 set_gpio_edge(gpio, 0); 1236 set_gpio_edge(gpio, 0);
1244 ret = get_gpio_data(gpio); 1237 ret = get_gpio_data(gpio);
1245 set_gpio_edge(gpio, 1); 1238 set_gpio_edge(gpio, 1);
1246 local_irq_restore(flags); 1239 local_irq_restore_hw(flags);
1247 1240
1248 return ret; 1241 return ret;
1249 } else 1242 } else
1250 return get_gpio_data(gpio); 1243 return get_gpio_data(gpio);
1251} 1244}
1252EXPORT_SYMBOL(gpio_get_value); 1245EXPORT_SYMBOL(bfin_gpio_get_value);
1253 1246
1254 1247
1255int gpio_direction_input(unsigned gpio) 1248int bfin_gpio_direction_input(unsigned gpio)
1256{ 1249{
1257 unsigned long flags; 1250 unsigned long flags;
1258 1251
@@ -1261,17 +1254,17 @@ int gpio_direction_input(unsigned gpio)
1261 return -EINVAL; 1254 return -EINVAL;
1262 } 1255 }
1263 1256
1264 local_irq_save(flags); 1257 local_irq_save_hw(flags);
1265 gpio_bankb[gpio_bank(gpio)]->dir &= ~gpio_bit(gpio); 1258 gpio_bankb[gpio_bank(gpio)]->dir &= ~gpio_bit(gpio);
1266 gpio_bankb[gpio_bank(gpio)]->inen |= gpio_bit(gpio); 1259 gpio_bankb[gpio_bank(gpio)]->inen |= gpio_bit(gpio);
1267 AWA_DUMMY_READ(inen); 1260 AWA_DUMMY_READ(inen);
1268 local_irq_restore(flags); 1261 local_irq_restore_hw(flags);
1269 1262
1270 return 0; 1263 return 0;
1271} 1264}
1272EXPORT_SYMBOL(gpio_direction_input); 1265EXPORT_SYMBOL(bfin_gpio_direction_input);
1273 1266
1274int gpio_direction_output(unsigned gpio, int value) 1267int bfin_gpio_direction_output(unsigned gpio, int value)
1275{ 1268{
1276 unsigned long flags; 1269 unsigned long flags;
1277 1270
@@ -1280,7 +1273,7 @@ int gpio_direction_output(unsigned gpio, int value)
1280 return -EINVAL; 1273 return -EINVAL;
1281 } 1274 }
1282 1275
1283 local_irq_save(flags); 1276 local_irq_save_hw(flags);
1284 gpio_bankb[gpio_bank(gpio)]->inen &= ~gpio_bit(gpio); 1277 gpio_bankb[gpio_bank(gpio)]->inen &= ~gpio_bit(gpio);
1285 1278
1286 if (value) 1279 if (value)
@@ -1290,11 +1283,11 @@ int gpio_direction_output(unsigned gpio, int value)
1290 1283
1291 gpio_bankb[gpio_bank(gpio)]->dir |= gpio_bit(gpio); 1284 gpio_bankb[gpio_bank(gpio)]->dir |= gpio_bit(gpio);
1292 AWA_DUMMY_READ(dir); 1285 AWA_DUMMY_READ(dir);
1293 local_irq_restore(flags); 1286 local_irq_restore_hw(flags);
1294 1287
1295 return 0; 1288 return 0;
1296} 1289}
1297EXPORT_SYMBOL(gpio_direction_output); 1290EXPORT_SYMBOL(bfin_gpio_direction_output);
1298 1291
1299/* If we are booting from SPI and our board lacks a strong enough pull up, 1292/* If we are booting from SPI and our board lacks a strong enough pull up,
1300 * the core can reset and execute the bootrom faster than the resistor can 1293 * the core can reset and execute the bootrom faster than the resistor can
@@ -1327,14 +1320,17 @@ void bfin_gpio_irq_prepare(unsigned gpio)
1327static int gpio_proc_read(char *buf, char **start, off_t offset, 1320static int gpio_proc_read(char *buf, char **start, off_t offset,
1328 int len, int *unused_i, void *unused_v) 1321 int len, int *unused_i, void *unused_v)
1329{ 1322{
1330 int c, outlen = 0; 1323 int c, irq, gpio, outlen = 0;
1331 1324
1332 for (c = 0; c < MAX_RESOURCES; c++) { 1325 for (c = 0; c < MAX_RESOURCES; c++) {
1333 if (!check_gpio(c) && (reserved_gpio_map[gpio_bank(c)] & gpio_bit(c))) 1326 irq = reserved_gpio_irq_map[gpio_bank(c)] & gpio_bit(c);
1334 len = sprintf(buf, "GPIO_%d: %s \t\tGPIO %s\n", c, 1327 gpio = reserved_gpio_map[gpio_bank(c)] & gpio_bit(c);
1335 get_label(c), get_gpio_dir(c) ? "OUTPUT" : "INPUT"); 1328 if (!check_gpio(c) && (gpio || irq))
1329 len = sprintf(buf, "GPIO_%d: \t%s%s \t\tGPIO %s\n", c,
1330 get_label(c), (gpio && irq) ? " *" : "",
1331 get_gpio_dir(c) ? "OUTPUT" : "INPUT");
1336 else if (reserved_peri_map[gpio_bank(c)] & gpio_bit(c)) 1332 else if (reserved_peri_map[gpio_bank(c)] & gpio_bit(c))
1337 len = sprintf(buf, "GPIO_%d: %s \t\tPeripheral\n", c, get_label(c)); 1333 len = sprintf(buf, "GPIO_%d: \t%s \t\tPeripheral\n", c, get_label(c));
1338 else 1334 else
1339 continue; 1335 continue;
1340 buf += len; 1336 buf += len;
@@ -1354,3 +1350,57 @@ static __init int gpio_register_proc(void)
1354} 1350}
1355__initcall(gpio_register_proc); 1351__initcall(gpio_register_proc);
1356#endif 1352#endif
1353
1354#ifdef CONFIG_GPIOLIB
1355int bfin_gpiolib_direction_input(struct gpio_chip *chip, unsigned gpio)
1356{
1357 return bfin_gpio_direction_input(gpio);
1358}
1359
1360int bfin_gpiolib_direction_output(struct gpio_chip *chip, unsigned gpio, int level)
1361{
1362 return bfin_gpio_direction_output(gpio, level);
1363}
1364
1365int bfin_gpiolib_get_value(struct gpio_chip *chip, unsigned gpio)
1366{
1367 return bfin_gpio_get_value(gpio);
1368}
1369
1370void bfin_gpiolib_set_value(struct gpio_chip *chip, unsigned gpio, int value)
1371{
1372#ifdef BF548_FAMILY
1373 return bfin_gpio_set_value(gpio, value);
1374#else
1375 return set_gpio_data(gpio, value);
1376#endif
1377}
1378
1379int bfin_gpiolib_gpio_request(struct gpio_chip *chip, unsigned gpio)
1380{
1381 return bfin_gpio_request(gpio, chip->label);
1382}
1383
1384void bfin_gpiolib_gpio_free(struct gpio_chip *chip, unsigned gpio)
1385{
1386 return bfin_gpio_free(gpio);
1387}
1388
1389static struct gpio_chip bfin_chip = {
1390 .label = "Blackfin-GPIOlib",
1391 .direction_input = bfin_gpiolib_direction_input,
1392 .get = bfin_gpiolib_get_value,
1393 .direction_output = bfin_gpiolib_direction_output,
1394 .set = bfin_gpiolib_set_value,
1395 .request = bfin_gpiolib_gpio_request,
1396 .free = bfin_gpiolib_gpio_free,
1397 .base = 0,
1398 .ngpio = MAX_BLACKFIN_GPIOS,
1399};
1400
1401static int __init bfin_gpiolib_setup(void)
1402{
1403 return gpiochip_add(&bfin_chip);
1404}
1405arch_initcall(bfin_gpiolib_setup);
1406#endif