gemini: add 4.1 support
[openwrt.git] / target / linux / gemini / patches-4.1 / 121-arm-gemini-register-ethernet.patch
1 --- a/arch/arm/mach-gemini/board-nas4220b.c
2 +++ b/arch/arm/mach-gemini/board-nas4220b.c
3 @@ -28,9 +28,27 @@
4  
5  #include <mach/hardware.h>
6  #include <mach/global_reg.h>
7 +#include <mach/gmac.h>
8  
9  #include "common.h"
10  
11 +static struct mdio_gpio_platform_data ib4220b_mdio = {
12 +       .mdc            = 22,
13 +       .mdio           = 21,
14 +       .phy_mask       = ~(1 << 1),
15 +};
16 +
17 +static struct platform_device ib4220b_phy_device = {
18 +       .name   = "mdio-gpio",
19 +       .id     = 0,
20 +       .dev    = { .platform_data = &ib4220b_mdio, },
21 +};
22 +
23 +static struct gemini_gmac_platform_data ib4220b_gmac_data = {
24 +       .bus_id[0]      = "gpio-0:01",
25 +       .interface[0]   = PHY_INTERFACE_MODE_RGMII,
26 +};
27 +
28  static struct gpio_led ib4220b_leds[] = {
29         {
30                 .name                   = "nas4220b:orange:hdd",
31 @@ -87,15 +105,47 @@ static struct platform_device ib4220b_ke
32         },
33  };
34  
35 +static void __init ib4220b_gmac_init(void)
36 +{
37 +       unsigned int val;
38 +
39 +       val = readl((void __iomem*)(IO_ADDRESS(GEMINI_GLOBAL_BASE) +
40 +               GLOBAL_IO_DRIVING_CTRL));
41 +       val |= (0x3 << GMAC0_PADS_SHIFT) | (0x3 << GMAC1_PADS_SHIFT);
42 +       writel(val, (void __iomem*)(IO_ADDRESS(GEMINI_GLOBAL_BASE) +
43 +               GLOBAL_IO_DRIVING_CTRL));
44 +
45 +       val = (0x0 << GMAC0_RXDV_SKEW_SHIFT) | (0xf << GMAC0_RXC_SKEW_SHIFT) |
46 +               (0x7 << GMAC0_TXEN_SKEW_SHIFT) | (0xb << GMAC0_TXC_SKEW_SHIFT) |
47 +               (0x0 << GMAC1_RXDV_SKEW_SHIFT) | (0xf << GMAC1_RXC_SKEW_SHIFT) |
48 +               (0x7 << GMAC1_TXEN_SKEW_SHIFT) | (0xa << GMAC1_TXC_SKEW_SHIFT);
49 +       writel(val, (void __iomem*)(IO_ADDRESS(GEMINI_GLOBAL_BASE) +
50 +               GLOBAL_GMAC_CTRL_SKEW_CTRL));
51 +
52 +       writel(0x77777777, (void __iomem*)(IO_ADDRESS(GEMINI_GLOBAL_BASE) +
53 +               GLOBAL_GMAC0_DATA_SKEW_CTRL));
54 +       writel(0x77777777, (void __iomem*)(IO_ADDRESS(GEMINI_GLOBAL_BASE) +
55 +               GLOBAL_GMAC1_DATA_SKEW_CTRL));
56 +
57 +       val = readl((void __iomem*)(IO_ADDRESS(GEMINI_GLOBAL_BASE) +
58 +               GLOBAL_ARBITRATION1_CTRL)) & ~BURST_LENGTH_MASK;
59 +       val |= (0x20 << BURST_LENGTH_SHIFT) | GMAC0_HIGH_PRIO | GMAC1_HIGH_PRIO;
60 +       writel(val, (void __iomem*)(IO_ADDRESS(GEMINI_GLOBAL_BASE) +
61 +               GLOBAL_ARBITRATION1_CTRL));
62 +}
63 +
64  static void __init ib4220b_init(void)
65  {
66         gemini_gpio_init();
67 +       ib4220b_gmac_init();
68         platform_register_uart();
69         platform_register_pflash(SZ_16M, NULL, 0);
70         platform_device_register(&ib4220b_led_device);
71         platform_device_register(&ib4220b_key_device);
72         platform_register_rtc();
73         platform_register_watchdog();
74 +       platform_device_register(&ib4220b_phy_device);
75 +       platform_register_ethernet(&ib4220b_gmac_data);
76  }
77  
78  MACHINE_START(NAS4220B, "Raidsonic NAS IB-4220-B")
79 --- a/arch/arm/mach-gemini/board-wbd111.c
80 +++ b/arch/arm/mach-gemini/board-wbd111.c
81 @@ -22,9 +22,29 @@
82  #include <asm/mach/arch.h>
83  #include <asm/mach/time.h>
84  
85 +#include <mach/gmac.h>
86  
87  #include "common.h"
88  
89 +static struct mdio_gpio_platform_data wbd111_mdio = {
90 +       .mdc            = 22,
91 +       .mdio           = 21,
92 +       .phy_mask       = ~(1 << 1),
93 +};
94 +
95 +static struct platform_device wbd111_phy_device = {
96 +       .name   = "mdio-gpio",
97 +       .id     = 0,
98 +       .dev    = {
99 +               .platform_data = &wbd111_mdio,
100 +       },
101 +};
102 +
103 +static struct gemini_gmac_platform_data gmac_data = {
104 +       .bus_id[0] = "gpio-0:01",
105 +       .interface[0] = PHY_INTERFACE_MODE_MII,
106 +};
107 +
108  static struct gpio_keys_button wbd111_keys[] = {
109         {
110                 .code           = KEY_SETUP,
111 @@ -123,6 +143,8 @@ static void __init wbd111_init(void)
112         platform_device_register(&wbd111_keys_device);
113         platform_register_rtc();
114         platform_register_watchdog();
115 +       platform_device_register(&wbd111_phy_device);
116 +       platform_register_ethernet(&gmac_data);
117  }
118  
119  MACHINE_START(WBD111, "Wiliboard WBD-111")
120 --- a/arch/arm/mach-gemini/board-wbd222.c
121 +++ b/arch/arm/mach-gemini/board-wbd222.c
122 @@ -22,9 +22,31 @@
123  #include <asm/mach/arch.h>
124  #include <asm/mach/time.h>
125  
126 +#include <mach/gmac.h>
127  
128  #include "common.h"
129  
130 +static struct mdio_gpio_platform_data wbd222_mdio = {
131 +       .mdc            = 22,
132 +       .mdio           = 21,
133 +       .phy_mask       = ~((1 << 1) | (1 << 3)),
134 +};
135 +
136 +static struct platform_device wbd222_phy_device = {
137 +       .name   = "mdio-gpio",
138 +       .id     = 0,
139 +       .dev    = {
140 +               .platform_data = &wbd222_mdio,
141 +       },
142 +};
143 +
144 +static struct gemini_gmac_platform_data gmac_data = {
145 +       .bus_id[0] = "gpio-0:01",
146 +       .interface[0] = PHY_INTERFACE_MODE_MII,
147 +       .bus_id[1] = "gpio-0:03",
148 +        .interface[1] = PHY_INTERFACE_MODE_MII,
149 +};
150 +
151  static struct gpio_keys_button wbd222_keys[] = {
152         {
153                 .code           = KEY_SETUP,
154 @@ -123,6 +145,8 @@ static void __init wbd222_init(void)
155         platform_device_register(&wbd222_keys_device);
156         platform_register_rtc();
157         platform_register_watchdog();
158 +       platform_device_register(&wbd222_phy_device);
159 +       platform_register_ethernet(&gmac_data);
160  }
161  
162  MACHINE_START(WBD222, "Wiliboard WBD-222")
163 --- a/arch/arm/mach-gemini/board-rut1xx.c
164 +++ b/arch/arm/mach-gemini/board-rut1xx.c
165 @@ -15,13 +15,35 @@
166  #include <linux/input.h>
167  #include <linux/gpio_keys.h>
168  #include <linux/sizes.h>
169 +#include <linux/mdio-gpio.h>
170  
171  #include <asm/mach-types.h>
172  #include <asm/mach/arch.h>
173  #include <asm/mach/time.h>
174  
175 +#include <mach/gmac.h>
176 +
177  #include "common.h"
178  
179 +static struct mdio_gpio_platform_data rut1xx_mdio = {
180 +       .mdc            = 22,
181 +       .mdio           = 21,
182 +       .phy_mask       = ~(1 << 1),
183 +};
184 +
185 +static struct platform_device rut1xx_phy_device = {
186 +       .name   = "mdio-gpio",
187 +       .id     = 0,
188 +       .dev    = {
189 +               .platform_data = &rut1xx_mdio,
190 +       },
191 +};
192 +
193 +static struct gemini_gmac_platform_data gmac_data = {
194 +       .bus_id[0] = "gpio-0:01",
195 +       .interface[0] = PHY_INTERFACE_MODE_MII,
196 +};
197 +
198  static struct gpio_keys_button rut1xx_keys[] = {
199         {
200                 .code           = KEY_SETUP,
201 @@ -81,6 +103,8 @@ static void __init rut1xx_init(void)
202         platform_device_register(&rut1xx_keys_device);
203         platform_register_rtc();
204         platform_register_watchdog();
205 +       platform_device_register(&rut1xx_phy_device);
206 +       platform_register_ethernet(&gmac_data);
207  }
208  
209  MACHINE_START(RUT100, "Teltonika RUT100")