kernel: update 3.10 to 3.10.18
[openwrt/staging/stintel.git] / target / linux / ramips / patches-3.10 / 0122-pinmux.patch
index f31e47689ffcfea670603d37e5a509a7348295a7..20fc4286f275824b432d18e74598ee63514f47de 100644 (file)
@@ -51,7 +51,7 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
  obj-$(CONFIG_ARCH_SHMOBILE)   += sh-pfc/
 --- /dev/null
 +++ b/drivers/pinctrl/pinctrl-rt2880.c
-@@ -0,0 +1,456 @@
+@@ -0,0 +1,466 @@
 +/*
 + *  linux/drivers/pinctrl/pinctrl-rt2880.c
 + *
@@ -275,7 +275,8 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
 +      if (func == 0) {
 +              int i;
 +
-+              mode |= p->groups[group].mask << p->groups[group].shift;
++
++              mode |= p->groups[group].gpio << p->groups[group].shift;
 +              /* mark the pins as gpio */
 +              for (i = 0; i < p->groups[group].func[0].pin_count; i++)
 +                      p->gpio[p->groups[group].func[0].pins[i]] = 1;
@@ -284,6 +285,7 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
 +      }
 +      rt_sysc_w32(mode, SYSC_REG_GPIO_MODE);
 +
++
 +      return 0;
 +}
 +
@@ -362,8 +364,6 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
 +      /* add remaining functions */
 +      for (i = 0; i < p->group_count; i++) {
 +              for (j = 0; j < p->groups[i].func_count; j++) {
-+                      int k;
-+
 +                      f[c] = &p->groups[i].func[j];
 +                      f[c]->groups = devm_kzalloc(p->dev, sizeof(int), GFP_KERNEL);
 +                      f[c]->groups[0] = i;
@@ -406,6 +406,15 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
 +              return -ENOMEM;
 +      }
 +
++      memset(p->gpio, 1, sizeof(uint8_t) * p->max_pins);
++      for (i = 0; i < p->func_count; i++) {
++              if (!p->func[i]->pin_count)
++                      continue;
++
++              for (j = 0; j < p->func[i]->pin_count; j++)
++                      p->gpio[p->func[i]->pins[j]] = 0;
++      }
++
 +      /* pin 0 is always a gpio */
 +      p->gpio[0] = 1;
 +
@@ -481,6 +490,7 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
 +              sprintf(name, "pio");
 +              range->npins = __be32_to_cpu(*ngpio);
 +              range->base = __be32_to_cpu(*gpiobase);
++              range->pin_base = range->base;
 +              pinctrl_add_gpio_range(dev, range);
 +      }
 +
@@ -510,7 +520,7 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
 +core_initcall_sync(rt2880_pinmux_init);
 --- /dev/null
 +++ b/arch/mips/include/asm/mach-ralink/pinmux.h
-@@ -0,0 +1,47 @@
+@@ -0,0 +1,53 @@
 +/*
 + *  This program is free software; you can redistribute it and/or modify
 + *  it under the terms of the GNU General Public License version 2 as
@@ -525,7 +535,12 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
 +#define FUNC(name, value, pin_first, pin_count) { name, value, pin_first, pin_count }
 +#define GRP(_name, _func, _mask, _shift) \
 +      { .name = _name, .mask = _mask, .shift = _shift, \
-+        .func = _func, \
++        .func = _func, .gpio = _mask, \
++        .func_count = ARRAY_SIZE(_func) }
++
++#define GRP_G(_name, _func, _mask, _gpio, _shift) \
++      { .name = _name, .mask = _mask, .shift = _shift, \
++        .func = _func, .gpio = _gpio, \
 +        .func_count = ARRAY_SIZE(_func) }
 +
 +struct rt2880_pmx_group;
@@ -550,6 +565,7 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
 +
 +      const u32 shift;
 +      const char mask;
++      const char gpio;
 +
 +      struct rt2880_pmx_func *func;
 +      int func_count;
@@ -568,7 +584,7 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
  
  #include "common.h"
  
-@@ -48,118 +49,40 @@ static int dram_type;
+@@ -48,118 +49,58 @@ static int dram_type;
  /* the pll dividers */
  static u32 mt7620_clk_divider[] = { 2, 3, 4, 8 };
  
@@ -635,8 +651,16 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
 -              .gpio_first = 72,
 -              .gpio_last = 72,
 -      }, {0}
-+static struct rt2880_pmx_func i2c_grp[] =  { FUNC("i2c", 1, 1, 2) };
-+static struct rt2880_pmx_func spi_grp[] = { FUNC("spi", 1, 3, 4) };
++static struct rt2880_pmx_func i2c_grp[] =  { FUNC("i2c", 0, 1, 2) };
++static struct rt2880_pmx_func spi_grp[] = { FUNC("spi", 0, 3, 4) };
++static struct rt2880_pmx_func uartlite_grp[] = { FUNC("uartlite", 0, 15, 2) };
++static struct rt2880_pmx_func mdio_grp[] = { FUNC("mdio", 0, 22, 2) };
++static struct rt2880_pmx_func rgmii1_grp[] = { FUNC("rgmii1", 0, 24, 12) };
++static struct rt2880_pmx_func refclk_grp[] = { FUNC("spi refclk", 0, 37, 3) };
++static struct rt2880_pmx_func ephy_grp[] = { FUNC("ephy", 0, 40, 5) };
++static struct rt2880_pmx_func rgmii2_grp[] = { FUNC("rgmii2", 0, 60, 12) };
++static struct rt2880_pmx_func wled_grp[] = { FUNC("wled", 0, 72, 1) };
++static struct rt2880_pmx_func pa_grp[] = { FUNC("pa", 0, 18, 4) };
 +static struct rt2880_pmx_func uartf_grp[] = {
 +      FUNC("uartf", MT7620_GPIO_MODE_UARTF, 7, 8),
 +      FUNC("pcm uartf", MT7620_GPIO_MODE_PCM_UARTF, 7, 8),
@@ -687,40 +711,48 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
 -              .name = "gpio",
 -              .mask = MT7620_GPIO_MODE_GPIO,
 -      }, {0}
--};
--
++static struct rt2880_pmx_func wdt_grp[] = {
++      FUNC("wdt rst", 0, 17, 1),
++      FUNC("wdt refclk", 0, 17, 1),
++      };
++static struct rt2880_pmx_func pcie_rst_grp[] = {
++      FUNC("pcie rst", MT7620_GPIO_MODE_PCIE_RST, 36, 1),
++      FUNC("pcie refclk", MT7620_GPIO_MODE_PCIE_REF, 36, 1)
++};
++static struct rt2880_pmx_func nd_sd_grp[] = {
++      FUNC("nand", MT7620_GPIO_MODE_NAND, 45, 15),
++      FUNC("sd", MT7620_GPIO_MODE_SD, 45, 15)
+ };
 -struct ralink_pinmux rt_gpio_pinmux = {
 -      .mode = mode_mux,
 -      .uart = uart_mux,
 -      .uart_shift = MT7620_GPIO_MODE_UART0_SHIFT,
 -      .uart_mask = MT7620_GPIO_MODE_UART0_MASK,
-+static struct rt2880_pmx_func uartlite_grp[] = { FUNC("uartlite", 1, 15, 2) };
-+static struct rt2880_pmx_func wdt_grp[] = { FUNC("wdt", 1, 17, 1) };
-+static struct rt2880_pmx_func mdio_grp[] = { FUNC("mdio", 1, 22, 2) };
-+static struct rt2880_pmx_func rgmii1_grp[] = { FUNC("rgmii1", 1, 24, 12) };
-+static struct rt2880_pmx_func refclk_grp[] = { FUNC("spi refclk", 1, 37, 3) };
-+static struct rt2880_pmx_func ephy_grp[] = { FUNC("ephy", 1, 40, 5) };
-+static struct rt2880_pmx_func rgmii2_grp[] = { FUNC("rgmii2", 1, 60, 12) };
-+static struct rt2880_pmx_func wled_grp[] = { FUNC("wled", 1, 72, 1) };
-+
 +static struct rt2880_pmx_group mt7620a_pinmux_data[] = {
 +      GRP("i2c", i2c_grp, 1, MT7620_GPIO_MODE_I2C),
++      GRP("uartf", uartf_grp, MT7620_GPIO_MODE_UART0_MASK,
++              MT7620_GPIO_MODE_UART0_SHIFT),
 +      GRP("spi", spi_grp, 1, MT7620_GPIO_MODE_SPI),
 +      GRP("uartlite", uartlite_grp, 1, MT7620_GPIO_MODE_UART1),
-+      GRP("wdt", wdt_grp, 1, MT7620_GPIO_MODE_WDT),
++      GRP_G("wdt", wdt_grp, MT7620_GPIO_MODE_WDT_MASK,
++              MT7620_GPIO_MODE_WDT_GPIO, MT7620_GPIO_MODE_WDT_SHIFT),
 +      GRP("mdio", mdio_grp, 1, MT7620_GPIO_MODE_MDIO),
 +      GRP("rgmii1", rgmii1_grp, 1, MT7620_GPIO_MODE_RGMII1),
 +      GRP("spi refclk", refclk_grp, 1, MT7620_GPIO_MODE_SPI_REF_CLK),
++      GRP_G("pcie", pcie_rst_grp, MT7620_GPIO_MODE_PCIE_MASK,
++              MT7620_GPIO_MODE_PCIE_GPIO, MT7620_GPIO_MODE_PCIE_SHIFT),
++      GRP_G("nd_sd", nd_sd_grp, MT7620_GPIO_MODE_ND_SD_MASK,
++              MT7620_GPIO_MODE_ND_SD_GPIO, MT7620_GPIO_MODE_ND_SD_SHIFT),
 +      GRP("rgmii2", rgmii2_grp, 1, MT7620_GPIO_MODE_RGMII2),
-+      GRP("ephy", ephy_grp, 1, MT7620_GPIO_MODE_EPHY),
 +      GRP("wled", wled_grp, 1, MT7620_GPIO_MODE_WLED),
-+      GRP("uartf", uartf_grp, MT7620_GPIO_MODE_UART0_MASK,
-+              MT7620_GPIO_MODE_UART0_SHIFT),
++      GRP("ephy", ephy_grp, 1, MT7620_GPIO_MODE_EPHY),
++      GRP("pa", pa_grp, 1, MT7620_GPIO_MODE_PA),
 +      { 0 }
  };
  
  void __init ralink_clk_init(void)
-@@ -281,4 +204,6 @@ void prom_soc_init(struct ralink_soc_inf
+@@ -281,4 +222,6 @@ void prom_soc_init(struct ralink_soc_inf
                (pmu0 & PMU_SW_SET) ? ("sw") : ("hw"));
        pr_info("Digital PMU set to %s control\n",
                (pmu1 & DIG_SW_SEL) ? ("sw") : ("hw"));
@@ -788,7 +820,7 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
 +      FUNC("gpio i2s", RT305X_GPIO_MODE_GPIO_I2S, 7, 4),
 +};
 +static struct rt2880_pmx_func uartlite_func[] = { FUNC("uartlite", 0, 15, 2) };
-+static struct rt2880_pmx_func jtag_func[] = { FUNC("jtag", 0, 17, 25) };
++static struct rt2880_pmx_func jtag_func[] = { FUNC("jtag", 0, 17, 5) };
 +static struct rt2880_pmx_func mdio_func[] = { FUNC("mdio", 0, 22, 2) };
 +static struct rt2880_pmx_func rt5350_led_func[] = { FUNC("led", 0, 22, 5) };
 +static struct rt2880_pmx_func sdram_func[] = { FUNC("sdram", 0, 24, 16) };
@@ -964,7 +996,7 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
  #define MT7620_GPIO_MODE_UART0_SHIFT  2
  #define MT7620_GPIO_MODE_UART0_MASK   0x7
  #define MT7620_GPIO_MODE_UART0(x)     ((x) << MT7620_GPIO_MODE_UART0_SHIFT)
-@@ -71,15 +70,17 @@
+@@ -71,15 +70,35 @@
  #define MT7620_GPIO_MODE_GPIO_UARTF   0x5
  #define MT7620_GPIO_MODE_GPIO_I2S     0x6
  #define MT7620_GPIO_MODE_GPIO         0x7
@@ -979,6 +1011,24 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
 -#define MT7620_GPIO_MODE_EPHY         BIT(15)
 -#define MT7620_GPIO_MODE_WDT          BIT(22)
 +
++#define MT7620_GPIO_MODE_NAND         0
++#define MT7620_GPIO_MODE_SD           1
++#define MT7620_GPIO_MODE_ND_SD_GPIO   2
++#define MT7620_GPIO_MODE_ND_SD_MASK   0x3
++#define MT7620_GPIO_MODE_ND_SD_SHIFT  18
++
++#define MT7620_GPIO_MODE_PCIE_RST     0
++#define MT7620_GPIO_MODE_PCIE_REF     1
++#define MT7620_GPIO_MODE_PCIE_GPIO    2
++#define MT7620_GPIO_MODE_PCIE_MASK    0x3
++#define MT7620_GPIO_MODE_PCIE_SHIFT   16
++
++#define MT7620_GPIO_MODE_WDT_RST      0
++#define MT7620_GPIO_MODE_WDT_REF      1
++#define MT7620_GPIO_MODE_WDT_GPIO     2
++#define MT7620_GPIO_MODE_WDT_MASK     0x3
++#define MT7620_GPIO_MODE_WDT_SHIFT    21
++
 +#define MT7620_GPIO_MODE_I2C          0
 +#define MT7620_GPIO_MODE_UART1                5
 +#define MT7620_GPIO_MODE_MDIO         8
@@ -989,7 +1039,7 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
 +#define MT7620_GPIO_MODE_WLED         13
 +#define MT7620_GPIO_MODE_JTAG         15
 +#define MT7620_GPIO_MODE_EPHY         15
-+#define MT7620_GPIO_MODE_WDT          22
++#define MT7620_GPIO_MODE_PA           20
  
  #endif
 --- a/arch/mips/include/asm/mach-ralink/rt3883.h
@@ -1167,7 +1217,7 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
 -              .mask = RT3883_GPIO_MODE_GPIO,
 -      }, {0}
 +static struct rt2880_pmx_func uartlite_func[] = { FUNC("uartlite", 0, 15, 2) };
-+static struct rt2880_pmx_func jtag_func[] = { FUNC("jtag", 0, 17, 25) };
++static struct rt2880_pmx_func jtag_func[] = { FUNC("jtag", 0, 17, 5) };
 +static struct rt2880_pmx_func mdio_func[] = { FUNC("mdio", 0, 22, 2) };
 +static struct rt2880_pmx_func lna_a_func[] = { FUNC("lna a", 0, 32, 3) };
 +static struct rt2880_pmx_func lna_g_func[] = { FUNC("lna a", 0, 35, 3) };