Skip to content

Commit 8ea8af6

Browse files
QSchulzlinusw
authored andcommitted
gpio: rockchip: request GPIO mux to pinctrl when setting direction
Before the split of gpio and pinctrl sections in their own driver, rockchip_set_mux was called in pinmux_ops.gpio_set_direction for configuring a pin in its GPIO function. This is essential for cases where pinctrl is "bypassed" by gpio consumers otherwise the GPIO function is not configured for the pin and it does not work. Such was the case for the sysfs/libgpiod userspace GPIO handling. Let's call pinctrl_gpio_direction_input/output when setting the direction of a GPIO so that the pinctrl core requests from the rockchip pinctrl driver to put the pin in its GPIO function. Fixes: 9ce9a02 ("pinctrl/rockchip: drop the gpio related codes") Fixes: 936ee26 ("gpio/rockchip: add driver for rockchip gpio") Cc: [email protected] Reviewed-by: Heiko Stuebner <[email protected]> Signed-off-by: Quentin Schulz <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent 4635c0e commit 8ea8af6

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

drivers/gpio/gpio-rockchip.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <linux/of_address.h>
2020
#include <linux/of_device.h>
2121
#include <linux/of_irq.h>
22+
#include <linux/pinctrl/consumer.h>
2223
#include <linux/pinctrl/pinconf-generic.h>
2324
#include <linux/regmap.h>
2425

@@ -156,6 +157,12 @@ static int rockchip_gpio_set_direction(struct gpio_chip *chip,
156157
unsigned long flags;
157158
u32 data = input ? 0 : 1;
158159

160+
161+
if (input)
162+
pinctrl_gpio_direction_input(bank->pin_base + offset);
163+
else
164+
pinctrl_gpio_direction_output(bank->pin_base + offset);
165+
159166
raw_spin_lock_irqsave(&bank->slock, flags);
160167
rockchip_gpio_writel_bit(bank, offset, data, bank->gpio_regs->port_ddr);
161168
raw_spin_unlock_irqrestore(&bank->slock, flags);

0 commit comments

Comments
 (0)