aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/blackfin/kernel/bfin_gpio.c89
1 files changed, 11 insertions, 78 deletions
diff --git a/arch/blackfin/kernel/bfin_gpio.c b/arch/blackfin/kernel/bfin_gpio.c
index 4aa3c053297f..8d12853a64fd 100644
--- a/arch/blackfin/kernel/bfin_gpio.c
+++ b/arch/blackfin/kernel/bfin_gpio.c
@@ -870,7 +870,6 @@ EXPORT_SYMBOL(get_gpio_dir);
870* MODIFICATION HISTORY : 870* MODIFICATION HISTORY :
871**************************************************************/ 871**************************************************************/
872 872
873#ifdef BF548_FAMILY
874int peripheral_request(unsigned short per, const char *label) 873int peripheral_request(unsigned short per, const char *label)
875{ 874{
876 unsigned long flags; 875 unsigned long flags;
@@ -886,15 +885,16 @@ int peripheral_request(unsigned short per, const char *label)
886 if (!(per & P_DEFINED)) 885 if (!(per & P_DEFINED))
887 return -ENODEV; 886 return -ENODEV;
888 887
889 if (check_gpio(ident) < 0) 888 if (check_gpio(ident))
890 return -EINVAL; 889 return -EINVAL;
891 890
892 local_irq_save(flags); 891 local_irq_save(flags);
893 892
893 /* Can't do GPIO and peripheral at the same time */
894 if (unlikely(reserved_gpio_map[gpio_bank(ident)] & gpio_bit(ident))) { 894 if (unlikely(reserved_gpio_map[gpio_bank(ident)] & gpio_bit(ident))) {
895 dump_stack(); 895 dump_stack();
896 printk(KERN_ERR 896 printk(KERN_ERR
897 "%s: Peripheral %d is already reserved as GPIO by %s !\n", 897 "%s: Peripheral %d is already reserved as GPIO by %s !\n",
898 __func__, ident, get_label(ident)); 898 __func__, ident, get_label(ident));
899 local_irq_restore(flags); 899 local_irq_restore(flags);
900 return -EBUSY; 900 return -EBUSY;
@@ -902,15 +902,18 @@ int peripheral_request(unsigned short per, const char *label)
902 902
903 if (unlikely(reserved_peri_map[gpio_bank(ident)] & gpio_bit(ident))) { 903 if (unlikely(reserved_peri_map[gpio_bank(ident)] & gpio_bit(ident))) {
904 904
905 u16 funct = get_portmux(ident);
906
907 /* 905 /*
908 * Pin functions like AMC address strobes my 906 * Pin functions like AMC address strobes my
909 * be requested and used by several drivers 907 * be requested and used by several drivers
910 */ 908 */
911 909
912 if (!((per & P_MAYSHARE) && (funct == P_FUNCT2MUX(per)))) { 910#ifdef BF548_FAMILY
911 u16 funct = get_portmux(ident);
913 912
913 if (!((per & P_MAYSHARE) && (funct == P_FUNCT2MUX(per)))) {
914#else
915 if (!(per & P_MAYSHARE)) {
916#endif
914 /* 917 /*
915 * Allow that the identical pin function can 918 * Allow that the identical pin function can
916 * be requested from the same driver twice 919 * be requested from the same driver twice
@@ -931,89 +934,19 @@ int peripheral_request(unsigned short per, const char *label)
931 anyway: 934 anyway:
932 reserved_peri_map[gpio_bank(ident)] |= gpio_bit(ident); 935 reserved_peri_map[gpio_bank(ident)] |= gpio_bit(ident);
933 936
937#ifdef BF548_FAMILY
934 portmux_setup(ident, P_FUNCT2MUX(per)); 938 portmux_setup(ident, P_FUNCT2MUX(per));
935 port_setup(ident, PERIPHERAL_USAGE);
936
937 local_irq_restore(flags);
938 set_label(ident, label);
939
940 return 0;
941}
942EXPORT_SYMBOL(peripheral_request);
943#else 939#else
944
945int peripheral_request(unsigned short per, const char *label)
946{
947 unsigned long flags;
948 unsigned short ident = P_IDENT(per);
949
950 /*
951 * Don't cares are pins with only one dedicated function
952 */
953
954 if (per & P_DONTCARE)
955 return 0;
956
957 if (!(per & P_DEFINED))
958 return -ENODEV;
959
960 local_irq_save(flags);
961
962 if (!check_gpio(ident)) {
963
964 if (unlikely(reserved_gpio_map[gpio_bank(ident)] & gpio_bit(ident))) {
965 dump_stack();
966 printk(KERN_ERR
967 "%s: Peripheral %d is already reserved as GPIO by %s !\n",
968 __func__, ident, get_label(ident));
969 local_irq_restore(flags);
970 return -EBUSY;
971 }
972
973 }
974
975 if (unlikely(reserved_peri_map[gpio_bank(ident)] & gpio_bit(ident))) {
976
977 /*
978 * Pin functions like AMC address strobes my
979 * be requested and used by several drivers
980 */
981
982 if (!(per & P_MAYSHARE)) {
983
984 /*
985 * Allow that the identical pin function can
986 * be requested from the same driver twice
987 */
988
989 if (cmp_label(ident, label) == 0)
990 goto anyway;
991
992 dump_stack();
993 printk(KERN_ERR
994 "%s: Peripheral %d function %d is already"
995 " reserved by %s !\n",
996 __func__, ident, P_FUNCT2MUX(per),
997 get_label(ident));
998 local_irq_restore(flags);
999 return -EBUSY;
1000 }
1001
1002 }
1003
1004 anyway:
1005 portmux_setup(per, P_FUNCT2MUX(per)); 940 portmux_setup(per, P_FUNCT2MUX(per));
1006 941#endif
1007 port_setup(ident, PERIPHERAL_USAGE); 942 port_setup(ident, PERIPHERAL_USAGE);
1008 943
1009 reserved_peri_map[gpio_bank(ident)] |= gpio_bit(ident);
1010 local_irq_restore(flags); 944 local_irq_restore(flags);
1011 set_label(ident, label); 945 set_label(ident, label);
1012 946
1013 return 0; 947 return 0;
1014} 948}
1015EXPORT_SYMBOL(peripheral_request); 949EXPORT_SYMBOL(peripheral_request);
1016#endif
1017 950
1018int peripheral_request_list(const unsigned short per[], const char *label) 951int peripheral_request_list(const unsigned short per[], const char *label)
1019{ 952{