ar71xx: Add QCA955X GPIO mux and function definitions
[15.05/openwrt.git] / target / linux / ar71xx / patches-3.18 / 739-MIPS-ath79-add-gpio-func-register-for-QCA955x-SoC.patch
1 --- a/arch/mips/ath79/gpio.c
2 +++ b/arch/mips/ath79/gpio.c
3 @@ -146,7 +146,8 @@ static void __iomem *ath79_gpio_get_func
4         if (soc_is_ar71xx() ||
5             soc_is_ar724x() ||
6             soc_is_ar913x() ||
7 -           soc_is_ar933x())
8 +           soc_is_ar933x() ||
9 +           soc_is_qca955x())
10                 reg = AR71XX_GPIO_REG_FUNC;
11         else if (soc_is_ar934x() ||
12                  soc_is_qca953x() || soc_is_qca956x())
13 @@ -185,15 +186,27 @@ void __init ath79_gpio_output_select(uns
14  {
15         void __iomem *base = ath79_gpio_base;
16         unsigned long flags;
17 -       unsigned int reg;
18 +       unsigned int reg, reg_base;
19 +       unsigned long gpio_count;
20         u32 t, s;
21  
22 -       BUG_ON(!soc_is_ar934x() && !soc_is_qca953x());
23 +       if (soc_is_ar934x()) {
24 +               gpio_count = AR934X_GPIO_COUNT;
25 +               reg_base = AR934X_GPIO_REG_OUT_FUNC0;
26 +       } else if (soc_is_qca953x()) {
27 +               gpio_count = QCA953X_GPIO_COUNT;
28 +               reg_base = QCA953X_GPIO_REG_OUT_FUNC0;
29 +       } else if (soc_is_qca955x()) {
30 +               gpio_count = QCA955X_GPIO_COUNT;
31 +               reg_base = QCA955X_GPIO_REG_OUT_FUNC0;
32 +       } else {
33 +               BUG();
34 +       }
35  
36 -       if (gpio >= AR934X_GPIO_COUNT)
37 +       if (gpio >= gpio_count)
38                 return;
39  
40 -       reg = AR934X_GPIO_REG_OUT_FUNC0 + 4 * (gpio / 4);
41 +       reg = reg_base + 4 * (gpio / 4);
42         s = 8 * (gpio % 4);
43  
44         spin_lock_irqsave(&ath79_gpio_lock, flags);