ramips: fix mt7621 boot on v4.9
[openwrt/openwrt.git] / target / linux / ar71xx / patches-4.4 / 505-MIPS-ath79-add-ath79_gpio_function_select.patch
1 --- a/arch/mips/ath79/common.h
2 +++ b/arch/mips/ath79/common.h
3 @@ -28,6 +28,7 @@ void ath79_ddr_wb_flush(unsigned int reg
4 void ath79_gpio_function_enable(u32 mask);
5 void ath79_gpio_function_disable(u32 mask);
6 void ath79_gpio_function_setup(u32 set, u32 clear);
7 +void ath79_gpio_output_select(unsigned gpio, u8 val);
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 @@ -57,3 +57,26 @@ void ath79_gpio_function_disable(u32 mas
14 {
15 ath79_gpio_function_setup(0, mask);
16 }
17 +
18 +void __init ath79_gpio_output_select(unsigned gpio, u8 val)
19 +{
20 + void __iomem *base = ath79_gpio_base;
21 + unsigned int reg;
22 + u32 t, s;
23 +
24 + BUG_ON(!soc_is_ar934x());
25 +
26 + if (gpio >= AR934X_GPIO_COUNT)
27 + return;
28 +
29 + reg = AR934X_GPIO_REG_OUT_FUNC0 + 4 * (gpio / 4);
30 + s = 8 * (gpio % 4);
31 +
32 + t = __raw_readl(base + reg);
33 + t &= ~(0xff << s);
34 + t |= val << s;
35 + __raw_writel(t, base + reg);
36 +
37 + /* flush write */
38 + (void) __raw_readl(base + reg);
39 +}