ar71xx: add v4.14 support
[openwrt/openwrt.git] / target / linux / ar71xx / patches-4.14 / 632-MIPS-ath79-gpio-enable-set-direction.patch
1 --- a/arch/mips/ath79/common.h
2 +++ b/arch/mips/ath79/common.h
3 @@ -28,6 +28,7 @@ void ath79_gpio_function_enable(u32 mask
4 void ath79_gpio_function_disable(u32 mask);
5 void ath79_gpio_function_setup(u32 set, u32 clear);
6 void ath79_gpio_output_select(unsigned gpio, u8 val);
7 +int ath79_gpio_direction_select(unsigned gpio, bool oe);
8 void ath79_gpio_init(void);
9
10 #endif /* __ATH79_COMMON_H */
11 --- a/arch/mips/ath79/gpio.c
12 +++ b/arch/mips/ath79/gpio.c
13 @@ -83,3 +83,19 @@ void __init ath79_gpio_output_select(uns
14 /* flush write */
15 (void) __raw_readl(base + reg);
16 }
17 +
18 +int ath79_gpio_direction_select(unsigned gpio, bool oe)
19 +{
20 + void __iomem *base = ath79_gpio_base;
21 + bool ieq_1 = (soc_is_ar934x() ||
22 + soc_is_qca953x());
23 +
24 + if ((ieq_1 && oe) || (!ieq_1 && !oe))
25 + __raw_writel(__raw_readl(base + AR71XX_GPIO_REG_OE) & ~(1 << gpio),
26 + base + AR71XX_GPIO_REG_OE);
27 + else
28 + __raw_writel(__raw_readl(base + AR71XX_GPIO_REG_OE) | (1 << gpio),
29 + base + AR71XX_GPIO_REG_OE);
30 +
31 + return 0;
32 +}