ar71xx: add function to access the GPIO function2 register
[openwrt/staging/chunkeey.git] / target / linux / ar71xx / patches-4.1 / 820-MIPS-ath79-add_gpio_function2_setup.patch
1 Add access to the function2 gpio register. This probably has to be
2 converted into a pimux driver later on. This is needed for some setup
3 functions on the Arduino Yun.
4
5 --- a/arch/mips/ath79/common.h
6 +++ b/arch/mips/ath79/common.h
7 @@ -27,6 +27,7 @@ void ath79_ddr_wb_flush(unsigned int reg
8 void ath79_gpio_function_enable(u32 mask);
9 void ath79_gpio_function_disable(u32 mask);
10 void ath79_gpio_function_setup(u32 set, u32 clear);
11 +void ath79_gpio_function2_setup(u32 set, u32 clear);
12 void ath79_gpio_output_select(unsigned gpio, u8 val);
13 int ath79_gpio_direction_select(unsigned gpio, bool oe);
14 void ath79_gpio_init(void);
15 --- a/arch/mips/ath79/gpio.c
16 +++ b/arch/mips/ath79/gpio.c
17 @@ -193,6 +193,36 @@ static void __iomem *ath79_gpio_get_func
18 return ath79_gpio_base + reg;
19 }
20
21 +static void __iomem *ath79_gpio_get_function2_reg(void)
22 +{
23 + u32 reg = 0;
24 +
25 + if (soc_is_ar71xx() ||
26 + soc_is_ar724x() ||
27 + soc_is_ar913x() ||
28 + soc_is_ar933x())
29 + reg = AR71XX_GPIO_REG_FUNC_2;
30 + else
31 + BUG();
32 +
33 + return ath79_gpio_base + reg;
34 +}
35 +
36 +
37 +void ath79_gpio_function2_setup(u32 set, u32 clear)
38 +{
39 + void __iomem *reg = ath79_gpio_get_function2_reg();
40 + unsigned long flags;
41 +
42 + spin_lock_irqsave(&ath79_gpio_lock, flags);
43 +
44 + __raw_writel((__raw_readl(reg) & ~clear) | set, reg);
45 + /* flush write */
46 + __raw_readl(reg);
47 +
48 + spin_unlock_irqrestore(&ath79_gpio_lock, flags);
49 +}
50 +
51 void ath79_gpio_function_setup(u32 set, u32 clear)
52 {
53 void __iomem *reg = ath79_gpio_get_function_reg();
54 --- a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
55 +++ b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
56 @@ -840,6 +840,7 @@
57 #define AR71XX_GPIO_REG_INT_PENDING 0x20
58 #define AR71XX_GPIO_REG_INT_ENABLE 0x24
59 #define AR71XX_GPIO_REG_FUNC 0x28
60 +#define AR71XX_GPIO_REG_FUNC_2 0x30
61
62 #define AR934X_GPIO_REG_OUT_FUNC0 0x2c
63 #define AR934X_GPIO_REG_OUT_FUNC1 0x30
64 @@ -964,6 +965,8 @@
65 #define AR724X_GPIO_FUNC_UART_EN BIT(1)
66 #define AR724X_GPIO_FUNC_JTAG_DISABLE BIT(0)
67
68 +#define AR933X_GPIO_FUNC2_JUMPSTART_DISABLE BIT(9)
69 +
70 #define AR913X_GPIO_FUNC_WMAC_LED_EN BIT(22)
71 #define AR913X_GPIO_FUNC_EXP_PORT_CS_EN BIT(21)
72 #define AR913X_GPIO_FUNC_I2S_REFCLKEN BIT(20)