diff options
author | Michael Hennerich <michael.hennerich@analog.com> | 2008-01-22 04:20:10 -0500 |
---|---|---|
committer | Bryan Wu <bryan.wu@analog.com> | 2008-01-22 04:20:10 -0500 |
commit | a2c8cfef6abb33ee49d80c58391ebfc4f94221ef (patch) | |
tree | 2d81734c98f8d72889b3f7de4dc5399e2edb8692 /arch/blackfin | |
parent | acbcd2631975cf6f0be5cd294cbfd12226cd9958 (diff) |
[Blackfin] arch: GPIO API cleanup and anomaly update
- Add anomaly workaround for bfin_gpio_reset_spi0_ssel1
- Fix style
- Update copyright
- Remove BUG_ON checks for functions intended to be used only by arch
support. GPIO users should only access using the generic GPIO API
- Make all GPIO identifier unsigned int
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 | 63 |
1 files changed, 28 insertions, 35 deletions
diff --git a/arch/blackfin/kernel/bfin_gpio.c b/arch/blackfin/kernel/bfin_gpio.c index 7312011a4211..6bbe0a2fccb8 100644 --- a/arch/blackfin/kernel/bfin_gpio.c +++ b/arch/blackfin/kernel/bfin_gpio.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * Description: GPIO Abstraction Layer | 7 | * Description: GPIO Abstraction Layer |
8 | * | 8 | * |
9 | * Modified: | 9 | * Modified: |
10 | * Copyright 2007 Analog Devices Inc. | 10 | * Copyright 2008 Analog Devices Inc. |
11 | * | 11 | * |
12 | * Bugs: Enter bugs at http://blackfin.uclinux.org/ | 12 | * Bugs: Enter bugs at http://blackfin.uclinux.org/ |
13 | * | 13 | * |
@@ -137,7 +137,6 @@ static unsigned short *port_fer[gpio_bank(MAX_BLACKFIN_GPIOS)] = { | |||
137 | (unsigned short *) PORTG_FER, | 137 | (unsigned short *) PORTG_FER, |
138 | (unsigned short *) PORTH_FER, | 138 | (unsigned short *) PORTH_FER, |
139 | }; | 139 | }; |
140 | |||
141 | #endif | 140 | #endif |
142 | 141 | ||
143 | #ifdef BF527_FAMILY | 142 | #ifdef BF527_FAMILY |
@@ -211,7 +210,7 @@ static unsigned int sic_iwr_irqs[gpio_bank(MAX_BLACKFIN_GPIOS)] = {IRQ_PROG0_INT | |||
211 | #endif /* CONFIG_PM */ | 210 | #endif /* CONFIG_PM */ |
212 | 211 | ||
213 | #if defined(BF548_FAMILY) | 212 | #if defined(BF548_FAMILY) |
214 | inline int check_gpio(unsigned short gpio) | 213 | inline int check_gpio(unsigned gpio) |
215 | { | 214 | { |
216 | if (gpio == GPIO_PB15 || gpio == GPIO_PC14 || gpio == GPIO_PC15 | 215 | if (gpio == GPIO_PB15 || gpio == GPIO_PC14 || gpio == GPIO_PC15 |
217 | || gpio == GPIO_PH14 || gpio == GPIO_PH15 | 216 | || gpio == GPIO_PH14 || gpio == GPIO_PH15 |
@@ -221,7 +220,7 @@ inline int check_gpio(unsigned short gpio) | |||
221 | return 0; | 220 | return 0; |
222 | } | 221 | } |
223 | #else | 222 | #else |
224 | inline int check_gpio(unsigned short gpio) | 223 | inline int check_gpio(unsigned gpio) |
225 | { | 224 | { |
226 | if (gpio >= MAX_BLACKFIN_GPIOS) | 225 | if (gpio >= MAX_BLACKFIN_GPIOS) |
227 | return -EINVAL; | 226 | return -EINVAL; |
@@ -236,7 +235,6 @@ void gpio_error(unsigned gpio) | |||
236 | 235 | ||
237 | static void set_label(unsigned short ident, const char *label) | 236 | static void set_label(unsigned short ident, const char *label) |
238 | { | 237 | { |
239 | |||
240 | if (label && str_ident) { | 238 | if (label && str_ident) { |
241 | strncpy(str_ident[ident].name, label, | 239 | strncpy(str_ident[ident].name, label, |
242 | RESOURCE_LABEL_SIZE); | 240 | RESOURCE_LABEL_SIZE); |
@@ -267,7 +265,7 @@ static int cmp_label(unsigned short ident, const char *label) | |||
267 | } | 265 | } |
268 | 266 | ||
269 | #if defined(BF527_FAMILY) || defined(BF537_FAMILY) | 267 | #if defined(BF527_FAMILY) || defined(BF537_FAMILY) |
270 | static void port_setup(unsigned short gpio, unsigned short usage) | 268 | static void port_setup(unsigned gpio, unsigned short usage) |
271 | { | 269 | { |
272 | if (!check_gpio(gpio)) { | 270 | if (!check_gpio(gpio)) { |
273 | if (usage == GPIO_USAGE) | 271 | if (usage == GPIO_USAGE) |
@@ -278,7 +276,7 @@ static void port_setup(unsigned short gpio, unsigned short usage) | |||
278 | } | 276 | } |
279 | } | 277 | } |
280 | #elif defined(BF548_FAMILY) | 278 | #elif defined(BF548_FAMILY) |
281 | static void port_setup(unsigned short gpio, unsigned short usage) | 279 | static void port_setup(unsigned gpio, unsigned short usage) |
282 | { | 280 | { |
283 | if (usage == GPIO_USAGE) | 281 | if (usage == GPIO_USAGE) |
284 | gpio_array[gpio_bank(gpio)]->port_fer &= ~gpio_bit(gpio); | 282 | gpio_array[gpio_bank(gpio)]->port_fer &= ~gpio_bit(gpio); |
@@ -399,7 +397,7 @@ inline void portmux_setup(unsigned short portno, unsigned short function) | |||
399 | #endif | 397 | #endif |
400 | 398 | ||
401 | #ifndef BF548_FAMILY | 399 | #ifndef BF548_FAMILY |
402 | static void default_gpio(unsigned short gpio) | 400 | static void default_gpio(unsigned gpio) |
403 | { | 401 | { |
404 | unsigned short bank, bitmask; | 402 | unsigned short bank, bitmask; |
405 | unsigned long flags; | 403 | unsigned long flags; |
@@ -419,7 +417,6 @@ static void default_gpio(unsigned short gpio) | |||
419 | gpio_bankb[bank]->edge &= ~bitmask; | 417 | gpio_bankb[bank]->edge &= ~bitmask; |
420 | AWA_DUMMY_READ(edge); | 418 | AWA_DUMMY_READ(edge); |
421 | local_irq_restore(flags); | 419 | local_irq_restore(flags); |
422 | |||
423 | } | 420 | } |
424 | #else | 421 | #else |
425 | # define default_gpio(...) do { } while (0) | 422 | # define default_gpio(...) do { } while (0) |
@@ -457,10 +454,9 @@ arch_initcall(bfin_gpio_init); | |||
457 | /* Set a specific bit */ | 454 | /* Set a specific bit */ |
458 | 455 | ||
459 | #define SET_GPIO(name) \ | 456 | #define SET_GPIO(name) \ |
460 | void set_gpio_ ## name(unsigned short gpio, unsigned short arg) \ | 457 | void set_gpio_ ## name(unsigned gpio, unsigned short arg) \ |
461 | { \ | 458 | { \ |
462 | unsigned long flags; \ | 459 | unsigned long flags; \ |
463 | BUG_ON(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))); \ | ||
464 | local_irq_save(flags); \ | 460 | local_irq_save(flags); \ |
465 | if (arg) \ | 461 | if (arg) \ |
466 | gpio_bankb[gpio_bank(gpio)]->name |= gpio_bit(gpio); \ | 462 | gpio_bankb[gpio_bank(gpio)]->name |= gpio_bit(gpio); \ |
@@ -480,10 +476,9 @@ SET_GPIO(both) | |||
480 | 476 | ||
481 | #if ANOMALY_05000311 || ANOMALY_05000323 | 477 | #if ANOMALY_05000311 || ANOMALY_05000323 |
482 | #define SET_GPIO_SC(name) \ | 478 | #define SET_GPIO_SC(name) \ |
483 | void set_gpio_ ## name(unsigned short gpio, unsigned short arg) \ | 479 | void set_gpio_ ## name(unsigned gpio, unsigned short arg) \ |
484 | { \ | 480 | { \ |
485 | unsigned long flags; \ | 481 | unsigned long flags; \ |
486 | BUG_ON(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))); \ | ||
487 | local_irq_save(flags); \ | 482 | local_irq_save(flags); \ |
488 | if (arg) \ | 483 | if (arg) \ |
489 | gpio_bankb[gpio_bank(gpio)]->name ## _set = gpio_bit(gpio); \ | 484 | gpio_bankb[gpio_bank(gpio)]->name ## _set = gpio_bit(gpio); \ |
@@ -495,9 +490,8 @@ void set_gpio_ ## name(unsigned short gpio, unsigned short arg) \ | |||
495 | EXPORT_SYMBOL(set_gpio_ ## name); | 490 | EXPORT_SYMBOL(set_gpio_ ## name); |
496 | #else | 491 | #else |
497 | #define SET_GPIO_SC(name) \ | 492 | #define SET_GPIO_SC(name) \ |
498 | void set_gpio_ ## name(unsigned short gpio, unsigned short arg) \ | 493 | void set_gpio_ ## name(unsigned gpio, unsigned short arg) \ |
499 | { \ | 494 | { \ |
500 | BUG_ON(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))); \ | ||
501 | if (arg) \ | 495 | if (arg) \ |
502 | gpio_bankb[gpio_bank(gpio)]->name ## _set = gpio_bit(gpio); \ | 496 | gpio_bankb[gpio_bank(gpio)]->name ## _set = gpio_bit(gpio); \ |
503 | else \ | 497 | else \ |
@@ -511,19 +505,17 @@ SET_GPIO_SC(maskb) | |||
511 | SET_GPIO_SC(data) | 505 | SET_GPIO_SC(data) |
512 | 506 | ||
513 | #if ANOMALY_05000311 || ANOMALY_05000323 | 507 | #if ANOMALY_05000311 || ANOMALY_05000323 |
514 | void set_gpio_toggle(unsigned short gpio) | 508 | void set_gpio_toggle(unsigned gpio) |
515 | { | 509 | { |
516 | unsigned long flags; | 510 | unsigned long flags; |
517 | BUG_ON(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))); | ||
518 | local_irq_save(flags); | 511 | local_irq_save(flags); |
519 | gpio_bankb[gpio_bank(gpio)]->toggle = gpio_bit(gpio); | 512 | gpio_bankb[gpio_bank(gpio)]->toggle = gpio_bit(gpio); |
520 | AWA_DUMMY_READ(toggle); | 513 | AWA_DUMMY_READ(toggle); |
521 | local_irq_restore(flags); | 514 | local_irq_restore(flags); |
522 | } | 515 | } |
523 | #else | 516 | #else |
524 | void set_gpio_toggle(unsigned short gpio) | 517 | void set_gpio_toggle(unsigned gpio) |
525 | { | 518 | { |
526 | BUG_ON(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))); | ||
527 | gpio_bankb[gpio_bank(gpio)]->toggle = gpio_bit(gpio); | 519 | gpio_bankb[gpio_bank(gpio)]->toggle = gpio_bit(gpio); |
528 | } | 520 | } |
529 | #endif | 521 | #endif |
@@ -534,7 +526,7 @@ EXPORT_SYMBOL(set_gpio_toggle); | |||
534 | 526 | ||
535 | #if ANOMALY_05000311 || ANOMALY_05000323 | 527 | #if ANOMALY_05000311 || ANOMALY_05000323 |
536 | #define SET_GPIO_P(name) \ | 528 | #define SET_GPIO_P(name) \ |
537 | void set_gpiop_ ## name(unsigned short gpio, unsigned short arg) \ | 529 | void set_gpiop_ ## name(unsigned gpio, unsigned short arg) \ |
538 | { \ | 530 | { \ |
539 | unsigned long flags; \ | 531 | unsigned long flags; \ |
540 | local_irq_save(flags); \ | 532 | local_irq_save(flags); \ |
@@ -545,7 +537,7 @@ void set_gpiop_ ## name(unsigned short gpio, unsigned short arg) \ | |||
545 | EXPORT_SYMBOL(set_gpiop_ ## name); | 537 | EXPORT_SYMBOL(set_gpiop_ ## name); |
546 | #else | 538 | #else |
547 | #define SET_GPIO_P(name) \ | 539 | #define SET_GPIO_P(name) \ |
548 | void set_gpiop_ ## name(unsigned short gpio, unsigned short arg) \ | 540 | void set_gpiop_ ## name(unsigned gpio, unsigned short arg) \ |
549 | { \ | 541 | { \ |
550 | gpio_bankb[gpio_bank(gpio)]->name = arg; \ | 542 | gpio_bankb[gpio_bank(gpio)]->name = arg; \ |
551 | } \ | 543 | } \ |
@@ -561,11 +553,10 @@ SET_GPIO_P(both) | |||
561 | SET_GPIO_P(maska) | 553 | SET_GPIO_P(maska) |
562 | SET_GPIO_P(maskb) | 554 | SET_GPIO_P(maskb) |
563 | 555 | ||
564 | |||
565 | /* Get a specific bit */ | 556 | /* Get a specific bit */ |
566 | #if ANOMALY_05000311 || ANOMALY_05000323 | 557 | #if ANOMALY_05000311 || ANOMALY_05000323 |
567 | #define GET_GPIO(name) \ | 558 | #define GET_GPIO(name) \ |
568 | unsigned short get_gpio_ ## name(unsigned short gpio) \ | 559 | unsigned short get_gpio_ ## name(unsigned gpio) \ |
569 | { \ | 560 | { \ |
570 | unsigned long flags; \ | 561 | unsigned long flags; \ |
571 | unsigned short ret; \ | 562 | unsigned short ret; \ |
@@ -578,7 +569,7 @@ unsigned short get_gpio_ ## name(unsigned short gpio) \ | |||
578 | EXPORT_SYMBOL(get_gpio_ ## name); | 569 | EXPORT_SYMBOL(get_gpio_ ## name); |
579 | #else | 570 | #else |
580 | #define GET_GPIO(name) \ | 571 | #define GET_GPIO(name) \ |
581 | unsigned short get_gpio_ ## name(unsigned short gpio) \ | 572 | unsigned short get_gpio_ ## name(unsigned gpio) \ |
582 | { \ | 573 | { \ |
583 | return (0x01 & (gpio_bankb[gpio_bank(gpio)]->name >> gpio_sub_n(gpio))); \ | 574 | return (0x01 & (gpio_bankb[gpio_bank(gpio)]->name >> gpio_sub_n(gpio))); \ |
584 | } \ | 575 | } \ |
@@ -598,7 +589,7 @@ GET_GPIO(maskb) | |||
598 | 589 | ||
599 | #if ANOMALY_05000311 || ANOMALY_05000323 | 590 | #if ANOMALY_05000311 || ANOMALY_05000323 |
600 | #define GET_GPIO_P(name) \ | 591 | #define GET_GPIO_P(name) \ |
601 | unsigned short get_gpiop_ ## name(unsigned short gpio) \ | 592 | unsigned short get_gpiop_ ## name(unsigned gpio) \ |
602 | { \ | 593 | { \ |
603 | unsigned long flags; \ | 594 | unsigned long flags; \ |
604 | unsigned short ret; \ | 595 | unsigned short ret; \ |
@@ -611,7 +602,7 @@ unsigned short get_gpiop_ ## name(unsigned short gpio) \ | |||
611 | EXPORT_SYMBOL(get_gpiop_ ## name); | 602 | EXPORT_SYMBOL(get_gpiop_ ## name); |
612 | #else | 603 | #else |
613 | #define GET_GPIO_P(name) \ | 604 | #define GET_GPIO_P(name) \ |
614 | unsigned short get_gpiop_ ## name(unsigned short gpio) \ | 605 | unsigned short get_gpiop_ ## name(unsigned gpio) \ |
615 | { \ | 606 | { \ |
616 | return (gpio_bankb[gpio_bank(gpio)]->name);\ | 607 | return (gpio_bankb[gpio_bank(gpio)]->name);\ |
617 | } \ | 608 | } \ |
@@ -648,7 +639,7 @@ GET_GPIO_P(maskb) | |||
648 | ************************************************************* | 639 | ************************************************************* |
649 | * MODIFICATION HISTORY : | 640 | * MODIFICATION HISTORY : |
650 | **************************************************************/ | 641 | **************************************************************/ |
651 | int gpio_pm_wakeup_request(unsigned short gpio, unsigned char type) | 642 | int gpio_pm_wakeup_request(unsigned gpio, unsigned char type) |
652 | { | 643 | { |
653 | unsigned long flags; | 644 | unsigned long flags; |
654 | 645 | ||
@@ -656,7 +647,6 @@ int gpio_pm_wakeup_request(unsigned short gpio, unsigned char type) | |||
656 | return -EINVAL; | 647 | return -EINVAL; |
657 | 648 | ||
658 | local_irq_save(flags); | 649 | local_irq_save(flags); |
659 | |||
660 | wakeup_map[gpio_bank(gpio)] |= gpio_bit(gpio); | 650 | wakeup_map[gpio_bank(gpio)] |= gpio_bit(gpio); |
661 | wakeup_flags_map[gpio] = type; | 651 | wakeup_flags_map[gpio] = type; |
662 | local_irq_restore(flags); | 652 | local_irq_restore(flags); |
@@ -665,7 +655,7 @@ int gpio_pm_wakeup_request(unsigned short gpio, unsigned char type) | |||
665 | } | 655 | } |
666 | EXPORT_SYMBOL(gpio_pm_wakeup_request); | 656 | EXPORT_SYMBOL(gpio_pm_wakeup_request); |
667 | 657 | ||
668 | void gpio_pm_wakeup_free(unsigned short gpio) | 658 | void gpio_pm_wakeup_free(unsigned gpio) |
669 | { | 659 | { |
670 | unsigned long flags; | 660 | unsigned long flags; |
671 | 661 | ||
@@ -680,7 +670,7 @@ void gpio_pm_wakeup_free(unsigned short gpio) | |||
680 | } | 670 | } |
681 | EXPORT_SYMBOL(gpio_pm_wakeup_free); | 671 | EXPORT_SYMBOL(gpio_pm_wakeup_free); |
682 | 672 | ||
683 | static int bfin_gpio_wakeup_type(unsigned short gpio, unsigned char type) | 673 | static int bfin_gpio_wakeup_type(unsigned gpio, unsigned char type) |
684 | { | 674 | { |
685 | port_setup(gpio, GPIO_USAGE); | 675 | port_setup(gpio, GPIO_USAGE); |
686 | set_gpio_dir(gpio, 0); | 676 | set_gpio_dir(gpio, 0); |
@@ -789,7 +779,7 @@ void gpio_pm_restore(void) | |||
789 | #endif | 779 | #endif |
790 | #else /* BF548_FAMILY */ | 780 | #else /* BF548_FAMILY */ |
791 | 781 | ||
792 | unsigned short get_gpio_dir(unsigned short gpio) | 782 | unsigned short get_gpio_dir(unsigned gpio) |
793 | { | 783 | { |
794 | return (0x01 & (gpio_array[gpio_bank(gpio)]->port_dir_clear >> gpio_sub_n(gpio))); | 784 | return (0x01 & (gpio_array[gpio_bank(gpio)]->port_dir_clear >> gpio_sub_n(gpio))); |
795 | } | 785 | } |
@@ -1123,7 +1113,6 @@ int gpio_direction_input(unsigned gpio) | |||
1123 | return -EINVAL; | 1113 | return -EINVAL; |
1124 | } | 1114 | } |
1125 | 1115 | ||
1126 | |||
1127 | local_irq_save(flags); | 1116 | local_irq_save(flags); |
1128 | gpio_array[gpio_bank(gpio)]->port_dir_clear = gpio_bit(gpio); | 1117 | gpio_array[gpio_bank(gpio)]->port_dir_clear = gpio_bit(gpio); |
1129 | gpio_array[gpio_bank(gpio)]->port_inen |= gpio_bit(gpio); | 1118 | gpio_array[gpio_bank(gpio)]->port_inen |= gpio_bit(gpio); |
@@ -1158,7 +1147,6 @@ void gpio_set_value(unsigned gpio, int arg) | |||
1158 | gpio_array[gpio_bank(gpio)]->port_set = gpio_bit(gpio); | 1147 | gpio_array[gpio_bank(gpio)]->port_set = gpio_bit(gpio); |
1159 | else | 1148 | else |
1160 | gpio_array[gpio_bank(gpio)]->port_clear = gpio_bit(gpio); | 1149 | gpio_array[gpio_bank(gpio)]->port_clear = gpio_bit(gpio); |
1161 | |||
1162 | } | 1150 | } |
1163 | EXPORT_SYMBOL(gpio_set_value); | 1151 | EXPORT_SYMBOL(gpio_set_value); |
1164 | 1152 | ||
@@ -1200,7 +1188,12 @@ int gpio_direction_output(unsigned gpio, int value) | |||
1200 | 1188 | ||
1201 | local_irq_save(flags); | 1189 | local_irq_save(flags); |
1202 | gpio_bankb[gpio_bank(gpio)]->inen &= ~gpio_bit(gpio); | 1190 | gpio_bankb[gpio_bank(gpio)]->inen &= ~gpio_bit(gpio); |
1203 | gpio_set_value(gpio, value); | 1191 | |
1192 | if (value) | ||
1193 | gpio_bankb[gpio_bank(gpio)]->data_set = gpio_bit(gpio); | ||
1194 | else | ||
1195 | gpio_bankb[gpio_bank(gpio)]->data_clear = gpio_bit(gpio); | ||
1196 | |||
1204 | gpio_bankb[gpio_bank(gpio)]->dir |= gpio_bit(gpio); | 1197 | gpio_bankb[gpio_bank(gpio)]->dir |= gpio_bit(gpio); |
1205 | AWA_DUMMY_READ(dir); | 1198 | AWA_DUMMY_READ(dir); |
1206 | local_irq_restore(flags); | 1199 | local_irq_restore(flags); |
@@ -1225,6 +1218,7 @@ void bfin_gpio_reset_spi0_ssel1(void) | |||
1225 | 1218 | ||
1226 | port_setup(gpio, GPIO_USAGE); | 1219 | port_setup(gpio, GPIO_USAGE); |
1227 | gpio_bankb[gpio_bank(gpio)]->data_set = gpio_bit(gpio); | 1220 | gpio_bankb[gpio_bank(gpio)]->data_set = gpio_bit(gpio); |
1221 | AWA_DUMMY_READ(data_set); | ||
1228 | udelay(1); | 1222 | udelay(1); |
1229 | } | 1223 | } |
1230 | 1224 | ||
@@ -1259,6 +1253,5 @@ static __init int gpio_register_proc(void) | |||
1259 | proc_gpio->read_proc = gpio_proc_read; | 1253 | proc_gpio->read_proc = gpio_proc_read; |
1260 | return proc_gpio != NULL; | 1254 | return proc_gpio != NULL; |
1261 | } | 1255 | } |
1262 | |||
1263 | __initcall(gpio_register_proc); | 1256 | __initcall(gpio_register_proc); |
1264 | #endif | 1257 | #endif |