Commit a416bfa2 authored by Christophe Leroy's avatar Christophe Leroy Committed by Greg Kroah-Hartman

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: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b60dfbae
...@@ -1213,8 +1213,32 @@ static int cpm_uart_init_port(struct device_node *np, ...@@ -1213,8 +1213,32 @@ static int cpm_uart_init_port(struct device_node *np,
goto out_pram; goto out_pram;
} }
for (i = 0; i < NUM_GPIOS; i++) for (i = 0; i < NUM_GPIOS; i++) {
pinfo->gpios[i] = of_get_gpio(np, i); int gpio;
pinfo->gpios[i] = -1;
gpio = of_get_gpio(np, i);
if (gpio_is_valid(gpio)) {
ret = gpio_request(gpio, "cpm_uart");
if (ret) {
pr_err("can't request gpio #%d: %d\n", i, ret);
continue;
}
if (i == GPIO_RTS || i == GPIO_DTR)
ret = gpio_direction_output(gpio, 0);
else
ret = gpio_direction_input(gpio);
if (ret) {
pr_err("can't set direction for gpio #%d: %d\n",
i, ret);
gpio_free(gpio);
continue;
}
pinfo->gpios[i] = gpio;
}
}
#ifdef CONFIG_PPC_EARLY_DEBUG_CPM #ifdef CONFIG_PPC_EARLY_DEBUG_CPM
udbg_putc = NULL; udbg_putc = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment