aboutsummaryrefslogtreecommitdiffstats
path: root/arch/blackfin/kernel
diff options
context:
space:
mode:
authorMichael Hennerich <michael.hennerich@analog.com>2008-11-18 04:48:22 -0500
committerBryan Wu <cooloney@kernel.org>2008-11-18 04:48:22 -0500
commita4f0b32c331a3da1dd1336f1691504268c63fc14 (patch)
treefe511ea71747c4a27cad8e56990681e67345f926 /arch/blackfin/kernel
parent8d0223744f531168d4ae87f33354d12a50402779 (diff)
Blackfin arch: Convert Blackfin GPIO driver to use common gpiolib/gpiochip infrastructure
- This patch adds support for ARCH_WANT_OPTIONAL_GPIOLIB. - It may be changed in future to ARCH_REQUIRE_GPIOLIB. - Change GPIO_BANK_NUM use DIV_ROUND_UP( , ) macro Signed-off-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Bryan Wu <cooloney@kernel.org>
Diffstat (limited to 'arch/blackfin/kernel')
-rw-r--r--arch/blackfin/kernel/bfin_gpio.c90
1 files changed, 72 insertions, 18 deletions
diff --git a/arch/blackfin/kernel/bfin_gpio.c b/arch/blackfin/kernel/bfin_gpio.c
index 6939272e9ed4..f8d666e6741b 100644
--- a/arch/blackfin/kernel/bfin_gpio.c
+++ b/arch/blackfin/kernel/bfin_gpio.c
@@ -1020,7 +1020,7 @@ EXPORT_SYMBOL(peripheral_free_list);
1020* MODIFICATION HISTORY : 1020* MODIFICATION HISTORY :
1021**************************************************************/ 1021**************************************************************/
1022 1022
1023int gpio_request(unsigned gpio, const char *label) 1023int bfin_gpio_request(unsigned gpio, const char *label)
1024{ 1024{
1025 unsigned long flags; 1025 unsigned long flags;
1026 1026
@@ -1065,9 +1065,9 @@ int gpio_request(unsigned gpio, const char *label)
1065 1065
1066 return 0; 1066 return 0;
1067} 1067}
1068EXPORT_SYMBOL(gpio_request); 1068EXPORT_SYMBOL(bfin_gpio_request);
1069 1069
1070void gpio_free(unsigned gpio) 1070void bfin_gpio_free(unsigned gpio)
1071{ 1071{
1072 unsigned long flags; 1072 unsigned long flags;
1073 1073
@@ -1089,11 +1089,11 @@ void gpio_free(unsigned gpio)
1089 1089
1090 local_irq_restore(flags); 1090 local_irq_restore(flags);
1091} 1091}
1092EXPORT_SYMBOL(gpio_free); 1092EXPORT_SYMBOL(bfin_gpio_free);
1093 1093
1094 1094
1095#ifdef BF548_FAMILY 1095#ifdef BF548_FAMILY
1096int gpio_direction_input(unsigned gpio) 1096int bfin_gpio_direction_input(unsigned gpio)
1097{ 1097{
1098 unsigned long flags; 1098 unsigned long flags;
1099 1099
@@ -1109,9 +1109,9 @@ int gpio_direction_input(unsigned gpio)
1109 1109
1110 return 0; 1110 return 0;
1111} 1111}
1112EXPORT_SYMBOL(gpio_direction_input); 1112EXPORT_SYMBOL(bfin_gpio_direction_input);
1113 1113
1114int gpio_direction_output(unsigned gpio, int value) 1114int bfin_gpio_direction_output(unsigned gpio, int value)
1115{ 1115{
1116 unsigned long flags; 1116 unsigned long flags;
1117 1117
@@ -1128,22 +1128,22 @@ int gpio_direction_output(unsigned gpio, int value)
1128 1128
1129 return 0; 1129 return 0;
1130} 1130}
1131EXPORT_SYMBOL(gpio_direction_output); 1131EXPORT_SYMBOL(bfin_gpio_direction_output);
1132 1132
1133void gpio_set_value(unsigned gpio, int arg) 1133void bfin_gpio_set_value(unsigned gpio, int arg)
1134{ 1134{
1135 if (arg) 1135 if (arg)
1136 gpio_array[gpio_bank(gpio)]->port_set = gpio_bit(gpio); 1136 gpio_array[gpio_bank(gpio)]->port_set = gpio_bit(gpio);
1137 else 1137 else
1138 gpio_array[gpio_bank(gpio)]->port_clear = gpio_bit(gpio); 1138 gpio_array[gpio_bank(gpio)]->port_clear = gpio_bit(gpio);
1139} 1139}
1140EXPORT_SYMBOL(gpio_set_value); 1140EXPORT_SYMBOL(bfin_gpio_set_value);
1141 1141
1142int gpio_get_value(unsigned gpio) 1142int bfin_gpio_get_value(unsigned gpio)
1143{ 1143{
1144 return (1 & (gpio_array[gpio_bank(gpio)]->port_data >> gpio_sub_n(gpio))); 1144 return (1 & (gpio_array[gpio_bank(gpio)]->port_data >> gpio_sub_n(gpio)));
1145} 1145}
1146EXPORT_SYMBOL(gpio_get_value); 1146EXPORT_SYMBOL(bfin_gpio_get_value);
1147 1147
1148void bfin_gpio_irq_prepare(unsigned gpio) 1148void bfin_gpio_irq_prepare(unsigned gpio)
1149{ 1149{
@@ -1159,7 +1159,7 @@ void bfin_gpio_irq_prepare(unsigned gpio)
1159 1159
1160#else 1160#else
1161 1161
1162int gpio_get_value(unsigned gpio) 1162int bfin_gpio_get_value(unsigned gpio)
1163{ 1163{
1164 unsigned long flags; 1164 unsigned long flags;
1165 int ret; 1165 int ret;
@@ -1175,10 +1175,10 @@ int gpio_get_value(unsigned gpio)
1175 } else 1175 } else
1176 return get_gpio_data(gpio); 1176 return get_gpio_data(gpio);
1177} 1177}
1178EXPORT_SYMBOL(gpio_get_value); 1178EXPORT_SYMBOL(bfin_gpio_get_value);
1179 1179
1180 1180
1181int gpio_direction_input(unsigned gpio) 1181int bfin_gpio_direction_input(unsigned gpio)
1182{ 1182{
1183 unsigned long flags; 1183 unsigned long flags;
1184 1184
@@ -1195,9 +1195,9 @@ int gpio_direction_input(unsigned gpio)
1195 1195
1196 return 0; 1196 return 0;
1197} 1197}
1198EXPORT_SYMBOL(gpio_direction_input); 1198EXPORT_SYMBOL(bfin_gpio_direction_input);
1199 1199
1200int gpio_direction_output(unsigned gpio, int value) 1200int bfin_gpio_direction_output(unsigned gpio, int value)
1201{ 1201{
1202 unsigned long flags; 1202 unsigned long flags;
1203 1203
@@ -1220,7 +1220,7 @@ int gpio_direction_output(unsigned gpio, int value)
1220 1220
1221 return 0; 1221 return 0;
1222} 1222}
1223EXPORT_SYMBOL(gpio_direction_output); 1223EXPORT_SYMBOL(bfin_gpio_direction_output);
1224 1224
1225/* If we are booting from SPI and our board lacks a strong enough pull up, 1225/* If we are booting from SPI and our board lacks a strong enough pull up,
1226 * the core can reset and execute the bootrom faster than the resistor can 1226 * the core can reset and execute the bootrom faster than the resistor can
@@ -1280,3 +1280,57 @@ static __init int gpio_register_proc(void)
1280} 1280}
1281__initcall(gpio_register_proc); 1281__initcall(gpio_register_proc);
1282#endif 1282#endif
1283
1284#ifdef CONFIG_GPIOLIB
1285int bfin_gpiolib_direction_input(struct gpio_chip *chip, unsigned gpio)
1286{
1287 return bfin_gpio_direction_input(gpio);
1288}
1289
1290int bfin_gpiolib_direction_output(struct gpio_chip *chip, unsigned gpio, int level)
1291{
1292 return bfin_gpio_direction_output(gpio, level);
1293}
1294
1295int bfin_gpiolib_get_value(struct gpio_chip *chip, unsigned gpio)
1296{
1297 return bfin_gpio_get_value(gpio);
1298}
1299
1300void bfin_gpiolib_set_value(struct gpio_chip *chip, unsigned gpio, int value)
1301{
1302#ifdef BF548_FAMILY
1303 return bfin_gpio_set_value(gpio, value);
1304#else
1305 return set_gpio_data(gpio, value);
1306#endif
1307}
1308
1309int bfin_gpiolib_gpio_request(struct gpio_chip *chip, unsigned gpio)
1310{
1311 return bfin_gpio_request(gpio, chip->label);
1312}
1313
1314void bfin_gpiolib_gpio_free(struct gpio_chip *chip, unsigned gpio)
1315{
1316 return bfin_gpio_free(gpio);
1317}
1318
1319static struct gpio_chip bfin_chip = {
1320 .label = "Blackfin-GPIOlib",
1321 .direction_input = bfin_gpiolib_direction_input,
1322 .get = bfin_gpiolib_get_value,
1323 .direction_output = bfin_gpiolib_direction_output,
1324 .set = bfin_gpiolib_set_value,
1325 .request = bfin_gpiolib_gpio_request,
1326 .free = bfin_gpiolib_gpio_free,
1327 .base = 0,
1328 .ngpio = MAX_BLACKFIN_GPIOS,
1329};
1330
1331static int __init bfin_gpiolib_setup(void)
1332{
1333 return gpiochip_add(&bfin_chip);
1334}
1335arch_initcall(bfin_gpiolib_setup);
1336#endif