aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Hennerich <michael.hennerich@analog.com>2008-01-22 05:36:20 -0500
committerBryan Wu <bryan.wu@analog.com>2008-01-22 05:36:20 -0500
commitacbcd2631975cf6f0be5cd294cbfd12226cd9958 (patch)
treefc603be9957970892395b145547af3e17add7084
parentb97b8a998397e8c64699559099fa9febffae2b4d (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>
-rw-r--r--arch/blackfin/kernel/bfin_gpio.c55
-rw-r--r--arch/blackfin/mach-bf527/boards/ezkit.c7
-rw-r--r--arch/blackfin/mach-bf537/boards/generic_board.c6
-rw-r--r--arch/blackfin/mach-bf537/boards/pnav10.c6
-rw-r--r--arch/blackfin/mach-bf537/boards/stamp.c7
-rw-r--r--drivers/video/bf54x-lq043fb.c3
-rw-r--r--include/asm-blackfin/gpio.h12
-rw-r--r--include/asm-blackfin/mach-bf527/bfin_serial_5xx.h2
-rw-r--r--include/asm-blackfin/mach-bf533/bfin_serial_5xx.h2
-rw-r--r--include/asm-blackfin/mach-bf537/bfin_serial_5xx.h2
-rw-r--r--include/asm-blackfin/mach-bf548/bfin_serial_5xx.h2
-rw-r--r--include/asm-blackfin/mach-bf561/bfin_serial_5xx.h2
12 files changed, 58 insertions, 48 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
232void gpio_error(unsigned gpio)
233{
234 printk(KERN_ERR "bfin-gpio: GPIO %d wasn't requested!\n", gpio);
235}
236
232static void set_label(unsigned short ident, const char *label) 237static 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
1037int gpio_request(unsigned short gpio, const char *label) 1042int 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}
1082EXPORT_SYMBOL(gpio_request); 1087EXPORT_SYMBOL(gpio_request);
1083 1088
1084void gpio_free(unsigned short gpio) 1089void 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}
1108EXPORT_SYMBOL(gpio_free); 1113EXPORT_SYMBOL(gpio_free);
1109 1114
1115
1110#ifdef BF548_FAMILY 1116#ifdef BF548_FAMILY
1111void gpio_direction_input(unsigned short gpio) 1117int 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}
1122EXPORT_SYMBOL(gpio_direction_input); 1134EXPORT_SYMBOL(gpio_direction_input);
1123 1135
1124void gpio_direction_output(unsigned short gpio) 1136int 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}
1135EXPORT_SYMBOL(gpio_direction_output); 1153EXPORT_SYMBOL(gpio_direction_output);
1136 1154
1137void gpio_set_value(unsigned short gpio, unsigned short arg) 1155void 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}
1145EXPORT_SYMBOL(gpio_set_value); 1163EXPORT_SYMBOL(gpio_set_value);
1146 1164
1147unsigned short gpio_get_value(unsigned short gpio) 1165int 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
1155void gpio_direction_input(unsigned short gpio) 1173int 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}
1167EXPORT_SYMBOL(gpio_direction_input); 1190EXPORT_SYMBOL(gpio_direction_input);
1168 1191
1169void gpio_direction_output(unsigned short gpio) 1192int 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}
1181EXPORT_SYMBOL(gpio_direction_output); 1210EXPORT_SYMBOL(gpio_direction_output);
1182 1211
diff --git a/arch/blackfin/mach-bf527/boards/ezkit.c b/arch/blackfin/mach-bf527/boards/ezkit.c
index bc256811a5e3..6d70aae4cc9b 100644
--- a/arch/blackfin/mach-bf527/boards/ezkit.c
+++ b/arch/blackfin/mach-bf527/boards/ezkit.c
@@ -317,12 +317,7 @@ static struct resource sl811_hcd_resources[] = {
317void sl811_port_power(struct device *dev, int is_on) 317void sl811_port_power(struct device *dev, int is_on)
318{ 318{
319 gpio_request(CONFIG_USB_SL811_BFIN_GPIO_VBUS, "usb:SL811_VBUS"); 319 gpio_request(CONFIG_USB_SL811_BFIN_GPIO_VBUS, "usb:SL811_VBUS");
320 gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS); 320 gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS, is_on);
321
322 if (is_on)
323 gpio_set_value(CONFIG_USB_SL811_BFIN_GPIO_VBUS, 1);
324 else
325 gpio_set_value(CONFIG_USB_SL811_BFIN_GPIO_VBUS, 0);
326} 321}
327#endif 322#endif
328 323
diff --git a/arch/blackfin/mach-bf537/boards/generic_board.c b/arch/blackfin/mach-bf537/boards/generic_board.c
index 1c97219a2ab5..3225b1588398 100644
--- a/arch/blackfin/mach-bf537/boards/generic_board.c
+++ b/arch/blackfin/mach-bf537/boards/generic_board.c
@@ -205,12 +205,8 @@ static struct resource sl811_hcd_resources[] = {
205void sl811_port_power(struct device *dev, int is_on) 205void sl811_port_power(struct device *dev, int is_on)
206{ 206{
207 gpio_request(CONFIG_USB_SL811_BFIN_GPIO_VBUS, "usb:SL811_VBUS"); 207 gpio_request(CONFIG_USB_SL811_BFIN_GPIO_VBUS, "usb:SL811_VBUS");
208 gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS); 208 gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS, is_on);
209 209
210 if (is_on)
211 gpio_set_value(CONFIG_USB_SL811_BFIN_GPIO_VBUS, 1);
212 else
213 gpio_set_value(CONFIG_USB_SL811_BFIN_GPIO_VBUS, 0);
214} 210}
215#endif 211#endif
216 212
diff --git a/arch/blackfin/mach-bf537/boards/pnav10.c b/arch/blackfin/mach-bf537/boards/pnav10.c
index 23e10c7dab5b..4c4870590bd8 100644
--- a/arch/blackfin/mach-bf537/boards/pnav10.c
+++ b/arch/blackfin/mach-bf537/boards/pnav10.c
@@ -134,12 +134,8 @@ static struct resource sl811_hcd_resources[] = {
134void sl811_port_power(struct device *dev, int is_on) 134void sl811_port_power(struct device *dev, int is_on)
135{ 135{
136 gpio_request(CONFIG_USB_SL811_BFIN_GPIO_VBUS, "usb:SL811_VBUS"); 136 gpio_request(CONFIG_USB_SL811_BFIN_GPIO_VBUS, "usb:SL811_VBUS");
137 gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS); 137 gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS, is_on);
138 138
139 if (is_on)
140 gpio_set_value(CONFIG_USB_SL811_BFIN_GPIO_VBUS, 1);
141 else
142 gpio_set_value(CONFIG_USB_SL811_BFIN_GPIO_VBUS, 0);
143} 139}
144#endif 140#endif
145 141
diff --git a/arch/blackfin/mach-bf537/boards/stamp.c b/arch/blackfin/mach-bf537/boards/stamp.c
index 3e0ad04d8d75..37759ac7df2a 100644
--- a/arch/blackfin/mach-bf537/boards/stamp.c
+++ b/arch/blackfin/mach-bf537/boards/stamp.c
@@ -250,12 +250,7 @@ static struct resource sl811_hcd_resources[] = {
250void sl811_port_power(struct device *dev, int is_on) 250void sl811_port_power(struct device *dev, int is_on)
251{ 251{
252 gpio_request(CONFIG_USB_SL811_BFIN_GPIO_VBUS, "usb:SL811_VBUS"); 252 gpio_request(CONFIG_USB_SL811_BFIN_GPIO_VBUS, "usb:SL811_VBUS");
253 gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS); 253 gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS, is_on);
254
255 if (is_on)
256 gpio_set_value(CONFIG_USB_SL811_BFIN_GPIO_VBUS, 1);
257 else
258 gpio_set_value(CONFIG_USB_SL811_BFIN_GPIO_VBUS, 0);
259} 254}
260#endif 255#endif
261 256
diff --git a/drivers/video/bf54x-lq043fb.c b/drivers/video/bf54x-lq043fb.c
index 1b7e54de0d76..c8e7427a0bc8 100644
--- a/drivers/video/bf54x-lq043fb.c
+++ b/drivers/video/bf54x-lq043fb.c
@@ -264,8 +264,7 @@ static int request_ports(struct bfin_bf54xfb_info *fbi)
264 } 264 }
265 } 265 }
266 266
267 gpio_direction_output(disp); 267 gpio_direction_output(disp, 1);
268 gpio_set_value(disp, 1);
269 268
270 return 0; 269 return 0;
271} 270}
diff --git a/include/asm-blackfin/gpio.h b/include/asm-blackfin/gpio.h
index 33ce98ef7e0f..7bba9b17654e 100644
--- a/include/asm-blackfin/gpio.h
+++ b/include/asm-blackfin/gpio.h
@@ -426,19 +426,19 @@ struct gpio_port_s {
426* MODIFICATION HISTORY : 426* MODIFICATION HISTORY :
427**************************************************************/ 427**************************************************************/
428 428
429int gpio_request(unsigned short, const char *); 429int gpio_request(unsigned, const char *);
430void gpio_free(unsigned short); 430void gpio_free(unsigned);
431 431
432void gpio_set_value(unsigned short gpio, unsigned short arg); 432void gpio_set_value(unsigned gpio, int arg);
433unsigned short gpio_get_value(unsigned short gpio); 433int gpio_get_value(unsigned gpio);
434 434
435#ifndef BF548_FAMILY 435#ifndef BF548_FAMILY
436#define gpio_get_value(gpio) get_gpio_data(gpio) 436#define gpio_get_value(gpio) get_gpio_data(gpio)
437#define gpio_set_value(gpio, value) set_gpio_data(gpio, value) 437#define gpio_set_value(gpio, value) set_gpio_data(gpio, value)
438#endif 438#endif
439 439
440void gpio_direction_input(unsigned short gpio); 440int gpio_direction_input(unsigned gpio);
441void gpio_direction_output(unsigned short gpio); 441int gpio_direction_output(unsigned gpio, int value);
442 442
443#include <asm-generic/gpio.h> /* cansleep wrappers */ 443#include <asm-generic/gpio.h> /* cansleep wrappers */
444#include <asm/irq.h> 444#include <asm/irq.h>
diff --git a/include/asm-blackfin/mach-bf527/bfin_serial_5xx.h b/include/asm-blackfin/mach-bf527/bfin_serial_5xx.h
index 0b867e6a76c4..15dbc21eed8b 100644
--- a/include/asm-blackfin/mach-bf527/bfin_serial_5xx.h
+++ b/include/asm-blackfin/mach-bf527/bfin_serial_5xx.h
@@ -146,7 +146,7 @@ static void bfin_serial_hw_init(struct bfin_serial_port *uart)
146 146
147 if (uart->rts_pin >= 0) { 147 if (uart->rts_pin >= 0) {
148 gpio_request(uart->rts_pin, DRIVER_NAME); 148 gpio_request(uart->rts_pin, DRIVER_NAME);
149 gpio_direction_output(uart->rts_pin); 149 gpio_direction_output(uart->rts_pin, 0);
150 } 150 }
151#endif 151#endif
152} 152}
diff --git a/include/asm-blackfin/mach-bf533/bfin_serial_5xx.h b/include/asm-blackfin/mach-bf533/bfin_serial_5xx.h
index 69b9f8e120e9..7871d4313f49 100644
--- a/include/asm-blackfin/mach-bf533/bfin_serial_5xx.h
+++ b/include/asm-blackfin/mach-bf533/bfin_serial_5xx.h
@@ -111,7 +111,7 @@ static void bfin_serial_hw_init(struct bfin_serial_port *uart)
111 } 111 }
112 if (uart->rts_pin >= 0) { 112 if (uart->rts_pin >= 0) {
113 gpio_request(uart->rts_pin, DRIVER_NAME); 113 gpio_request(uart->rts_pin, DRIVER_NAME);
114 gpio_direction_input(uart->rts_pin); 114 gpio_direction_input(uart->rts_pin, 0);
115 } 115 }
116#endif 116#endif
117} 117}
diff --git a/include/asm-blackfin/mach-bf537/bfin_serial_5xx.h b/include/asm-blackfin/mach-bf537/bfin_serial_5xx.h
index 6fb328f5186a..86e45c379838 100644
--- a/include/asm-blackfin/mach-bf537/bfin_serial_5xx.h
+++ b/include/asm-blackfin/mach-bf537/bfin_serial_5xx.h
@@ -146,7 +146,7 @@ static void bfin_serial_hw_init(struct bfin_serial_port *uart)
146 146
147 if (uart->rts_pin >= 0) { 147 if (uart->rts_pin >= 0) {
148 gpio_request(uart->rts_pin, DRIVER_NAME); 148 gpio_request(uart->rts_pin, DRIVER_NAME);
149 gpio_direction_output(uart->rts_pin); 149 gpio_direction_output(uart->rts_pin, 0);
150 } 150 }
151#endif 151#endif
152} 152}
diff --git a/include/asm-blackfin/mach-bf548/bfin_serial_5xx.h b/include/asm-blackfin/mach-bf548/bfin_serial_5xx.h
index f21a1620e6bd..3770aa38ee9f 100644
--- a/include/asm-blackfin/mach-bf548/bfin_serial_5xx.h
+++ b/include/asm-blackfin/mach-bf548/bfin_serial_5xx.h
@@ -186,7 +186,7 @@ static void bfin_serial_hw_init(struct bfin_serial_port *uart)
186 186
187 if (uart->rts_pin >= 0) { 187 if (uart->rts_pin >= 0) {
188 gpio_request(uart->rts_pin, DRIVER_NAME); 188 gpio_request(uart->rts_pin, DRIVER_NAME);
189 gpio_direction_output(uart->rts_pin); 189 gpio_direction_output(uart->rts_pin, 0);
190 } 190 }
191#endif 191#endif
192} 192}
diff --git a/include/asm-blackfin/mach-bf561/bfin_serial_5xx.h b/include/asm-blackfin/mach-bf561/bfin_serial_5xx.h
index 69b9f8e120e9..7871d4313f49 100644
--- a/include/asm-blackfin/mach-bf561/bfin_serial_5xx.h
+++ b/include/asm-blackfin/mach-bf561/bfin_serial_5xx.h
@@ -111,7 +111,7 @@ static void bfin_serial_hw_init(struct bfin_serial_port *uart)
111 } 111 }
112 if (uart->rts_pin >= 0) { 112 if (uart->rts_pin >= 0) {
113 gpio_request(uart->rts_pin, DRIVER_NAME); 113 gpio_request(uart->rts_pin, DRIVER_NAME);
114 gpio_direction_input(uart->rts_pin); 114 gpio_direction_input(uart->rts_pin, 0);
115 } 115 }
116#endif 116#endif
117} 117}