diff options
author | Michael Hennerich <michael.hennerich@analog.com> | 2008-01-22 05:36:20 -0500 |
---|---|---|
committer | Bryan Wu <bryan.wu@analog.com> | 2008-01-22 05:36:20 -0500 |
commit | acbcd2631975cf6f0be5cd294cbfd12226cd9958 (patch) | |
tree | fc603be9957970892395b145547af3e17add7084 /arch/blackfin/kernel/bfin_gpio.c | |
parent | b97b8a998397e8c64699559099fa9febffae2b4d (diff) |
[Blackfin] arch: Fix BUG gpio_direction_output API is not compatitable with GENERIC_GPIO API interface
signef-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Bryan Wu <bryan.wu@analog.com>
Diffstat (limited to 'arch/blackfin/kernel/bfin_gpio.c')
-rw-r--r-- | arch/blackfin/kernel/bfin_gpio.c | 55 |
1 files changed, 42 insertions, 13 deletions
diff --git a/arch/blackfin/kernel/bfin_gpio.c b/arch/blackfin/kernel/bfin_gpio.c index ffee36910288..7312011a4211 100644 --- a/arch/blackfin/kernel/bfin_gpio.c +++ b/arch/blackfin/kernel/bfin_gpio.c | |||
@@ -229,6 +229,11 @@ inline int check_gpio(unsigned short gpio) | |||
229 | } | 229 | } |
230 | #endif | 230 | #endif |
231 | 231 | ||
232 | void gpio_error(unsigned gpio) | ||
233 | { | ||
234 | printk(KERN_ERR "bfin-gpio: GPIO %d wasn't requested!\n", gpio); | ||
235 | } | ||
236 | |||
232 | static void set_label(unsigned short ident, const char *label) | 237 | static void set_label(unsigned short ident, const char *label) |
233 | { | 238 | { |
234 | 239 | ||
@@ -1034,7 +1039,7 @@ EXPORT_SYMBOL(peripheral_free_list); | |||
1034 | * MODIFICATION HISTORY : | 1039 | * MODIFICATION HISTORY : |
1035 | **************************************************************/ | 1040 | **************************************************************/ |
1036 | 1041 | ||
1037 | int gpio_request(unsigned short gpio, const char *label) | 1042 | int gpio_request(unsigned gpio, const char *label) |
1038 | { | 1043 | { |
1039 | unsigned long flags; | 1044 | unsigned long flags; |
1040 | 1045 | ||
@@ -1081,7 +1086,7 @@ int gpio_request(unsigned short gpio, const char *label) | |||
1081 | } | 1086 | } |
1082 | EXPORT_SYMBOL(gpio_request); | 1087 | EXPORT_SYMBOL(gpio_request); |
1083 | 1088 | ||
1084 | void gpio_free(unsigned short gpio) | 1089 | void gpio_free(unsigned gpio) |
1085 | { | 1090 | { |
1086 | unsigned long flags; | 1091 | unsigned long flags; |
1087 | 1092 | ||
@@ -1091,7 +1096,7 @@ void gpio_free(unsigned short gpio) | |||
1091 | local_irq_save(flags); | 1096 | local_irq_save(flags); |
1092 | 1097 | ||
1093 | if (unlikely(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio)))) { | 1098 | if (unlikely(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio)))) { |
1094 | printk(KERN_ERR "bfin-gpio: GPIO %d wasn't reserved!\n", gpio); | 1099 | gpio_error(gpio); |
1095 | dump_stack(); | 1100 | dump_stack(); |
1096 | local_irq_restore(flags); | 1101 | local_irq_restore(flags); |
1097 | return; | 1102 | return; |
@@ -1107,34 +1112,47 @@ void gpio_free(unsigned short gpio) | |||
1107 | } | 1112 | } |
1108 | EXPORT_SYMBOL(gpio_free); | 1113 | EXPORT_SYMBOL(gpio_free); |
1109 | 1114 | ||
1115 | |||
1110 | #ifdef BF548_FAMILY | 1116 | #ifdef BF548_FAMILY |
1111 | void gpio_direction_input(unsigned short gpio) | 1117 | int gpio_direction_input(unsigned gpio) |
1112 | { | 1118 | { |
1113 | unsigned long flags; | 1119 | unsigned long flags; |
1114 | 1120 | ||
1115 | BUG_ON(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))); | 1121 | if (!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))) { |
1122 | gpio_error(gpio); | ||
1123 | return -EINVAL; | ||
1124 | } | ||
1125 | |||
1116 | 1126 | ||
1117 | local_irq_save(flags); | 1127 | local_irq_save(flags); |
1118 | gpio_array[gpio_bank(gpio)]->port_dir_clear = gpio_bit(gpio); | 1128 | gpio_array[gpio_bank(gpio)]->port_dir_clear = gpio_bit(gpio); |
1119 | gpio_array[gpio_bank(gpio)]->port_inen |= gpio_bit(gpio); | 1129 | gpio_array[gpio_bank(gpio)]->port_inen |= gpio_bit(gpio); |
1120 | local_irq_restore(flags); | 1130 | local_irq_restore(flags); |
1131 | |||
1132 | return 0; | ||
1121 | } | 1133 | } |
1122 | EXPORT_SYMBOL(gpio_direction_input); | 1134 | EXPORT_SYMBOL(gpio_direction_input); |
1123 | 1135 | ||
1124 | void gpio_direction_output(unsigned short gpio) | 1136 | int gpio_direction_output(unsigned gpio, int value) |
1125 | { | 1137 | { |
1126 | unsigned long flags; | 1138 | unsigned long flags; |
1127 | 1139 | ||
1128 | BUG_ON(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))); | 1140 | if (!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))) { |
1141 | gpio_error(gpio); | ||
1142 | return -EINVAL; | ||
1143 | } | ||
1129 | 1144 | ||
1130 | local_irq_save(flags); | 1145 | local_irq_save(flags); |
1131 | gpio_array[gpio_bank(gpio)]->port_inen &= ~gpio_bit(gpio); | 1146 | gpio_array[gpio_bank(gpio)]->port_inen &= ~gpio_bit(gpio); |
1147 | gpio_set_value(gpio, value); | ||
1132 | gpio_array[gpio_bank(gpio)]->port_dir_set = gpio_bit(gpio); | 1148 | gpio_array[gpio_bank(gpio)]->port_dir_set = gpio_bit(gpio); |
1133 | local_irq_restore(flags); | 1149 | local_irq_restore(flags); |
1150 | |||
1151 | return 0; | ||
1134 | } | 1152 | } |
1135 | EXPORT_SYMBOL(gpio_direction_output); | 1153 | EXPORT_SYMBOL(gpio_direction_output); |
1136 | 1154 | ||
1137 | void gpio_set_value(unsigned short gpio, unsigned short arg) | 1155 | void gpio_set_value(unsigned gpio, int arg) |
1138 | { | 1156 | { |
1139 | if (arg) | 1157 | if (arg) |
1140 | gpio_array[gpio_bank(gpio)]->port_set = gpio_bit(gpio); | 1158 | gpio_array[gpio_bank(gpio)]->port_set = gpio_bit(gpio); |
@@ -1144,7 +1162,7 @@ void gpio_set_value(unsigned short gpio, unsigned short arg) | |||
1144 | } | 1162 | } |
1145 | EXPORT_SYMBOL(gpio_set_value); | 1163 | EXPORT_SYMBOL(gpio_set_value); |
1146 | 1164 | ||
1147 | unsigned short gpio_get_value(unsigned short gpio) | 1165 | int gpio_get_value(unsigned gpio) |
1148 | { | 1166 | { |
1149 | return (1 & (gpio_array[gpio_bank(gpio)]->port_data >> gpio_sub_n(gpio))); | 1167 | return (1 & (gpio_array[gpio_bank(gpio)]->port_data >> gpio_sub_n(gpio))); |
1150 | } | 1168 | } |
@@ -1152,31 +1170,42 @@ EXPORT_SYMBOL(gpio_get_value); | |||
1152 | 1170 | ||
1153 | #else | 1171 | #else |
1154 | 1172 | ||
1155 | void gpio_direction_input(unsigned short gpio) | 1173 | int gpio_direction_input(unsigned gpio) |
1156 | { | 1174 | { |
1157 | unsigned long flags; | 1175 | unsigned long flags; |
1158 | 1176 | ||
1159 | BUG_ON(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))); | 1177 | if (!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))) { |
1178 | gpio_error(gpio); | ||
1179 | return -EINVAL; | ||
1180 | } | ||
1160 | 1181 | ||
1161 | local_irq_save(flags); | 1182 | local_irq_save(flags); |
1162 | gpio_bankb[gpio_bank(gpio)]->dir &= ~gpio_bit(gpio); | 1183 | gpio_bankb[gpio_bank(gpio)]->dir &= ~gpio_bit(gpio); |
1163 | gpio_bankb[gpio_bank(gpio)]->inen |= gpio_bit(gpio); | 1184 | gpio_bankb[gpio_bank(gpio)]->inen |= gpio_bit(gpio); |
1164 | AWA_DUMMY_READ(inen); | 1185 | AWA_DUMMY_READ(inen); |
1165 | local_irq_restore(flags); | 1186 | local_irq_restore(flags); |
1187 | |||
1188 | return 0; | ||
1166 | } | 1189 | } |
1167 | EXPORT_SYMBOL(gpio_direction_input); | 1190 | EXPORT_SYMBOL(gpio_direction_input); |
1168 | 1191 | ||
1169 | void gpio_direction_output(unsigned short gpio) | 1192 | int gpio_direction_output(unsigned gpio, int value) |
1170 | { | 1193 | { |
1171 | unsigned long flags; | 1194 | unsigned long flags; |
1172 | 1195 | ||
1173 | BUG_ON(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))); | 1196 | if (!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))) { |
1197 | gpio_error(gpio); | ||
1198 | return -EINVAL; | ||
1199 | } | ||
1174 | 1200 | ||
1175 | local_irq_save(flags); | 1201 | local_irq_save(flags); |
1176 | gpio_bankb[gpio_bank(gpio)]->inen &= ~gpio_bit(gpio); | 1202 | gpio_bankb[gpio_bank(gpio)]->inen &= ~gpio_bit(gpio); |
1203 | gpio_set_value(gpio, value); | ||
1177 | gpio_bankb[gpio_bank(gpio)]->dir |= gpio_bit(gpio); | 1204 | gpio_bankb[gpio_bank(gpio)]->dir |= gpio_bit(gpio); |
1178 | AWA_DUMMY_READ(dir); | 1205 | AWA_DUMMY_READ(dir); |
1179 | local_irq_restore(flags); | 1206 | local_irq_restore(flags); |
1207 | |||
1208 | return 0; | ||
1180 | } | 1209 | } |
1181 | EXPORT_SYMBOL(gpio_direction_output); | 1210 | EXPORT_SYMBOL(gpio_direction_output); |
1182 | 1211 | ||