aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Leroy <christophe.leroy@c-s.fr>2013-08-21 11:59:24 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-08-28 01:06:22 -0400
commita416bfa2a6b4e00a7bc69641b8fc2414873a5fd9 (patch)
treea4e94f9f671677209492f08ba13c1033a1ca573b
parentb60dfbae4151fe8c8a59724c43f5f3f66d51695f (diff)
tty: serial: cpm_uart: Adding proper request of GPIO used by cpm_uart driver
cpm_uart serial driver uses GPIO for control signals. In order to be used properly, GPIOs have to be reserved. Comment in gpiolib.c considers illegal the use of GPIOs without requesting them. In addition, the direction of the GPIO has to be set properly. Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/tty/serial/cpm_uart/cpm_uart_core.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
index f7672cae5321..1a535f70dc41 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
@@ -1213,8 +1213,32 @@ static int cpm_uart_init_port(struct device_node *np,
1213 goto out_pram; 1213 goto out_pram;
1214 } 1214 }
1215 1215
1216 for (i = 0; i < NUM_GPIOS; i++) 1216 for (i = 0; i < NUM_GPIOS; i++) {
1217 pinfo->gpios[i] = of_get_gpio(np, i); 1217 int gpio;
1218
1219 pinfo->gpios[i] = -1;
1220
1221 gpio = of_get_gpio(np, i);
1222
1223 if (gpio_is_valid(gpio)) {
1224 ret = gpio_request(gpio, "cpm_uart");
1225 if (ret) {
1226 pr_err("can't request gpio #%d: %d\n", i, ret);
1227 continue;
1228 }
1229 if (i == GPIO_RTS || i == GPIO_DTR)
1230 ret = gpio_direction_output(gpio, 0);
1231 else
1232 ret = gpio_direction_input(gpio);
1233 if (ret) {
1234 pr_err("can't set direction for gpio #%d: %d\n",
1235 i, ret);
1236 gpio_free(gpio);
1237 continue;
1238 }
1239 pinfo->gpios[i] = gpio;
1240 }
1241 }
1218 1242
1219#ifdef CONFIG_PPC_EARLY_DEBUG_CPM 1243#ifdef CONFIG_PPC_EARLY_DEBUG_CPM
1220 udbg_putc = NULL; 1244 udbg_putc = NULL;