d5bab9ec65fa4bf6dc965c2a6401b248b4b5a990
[openwrt.git] / target / linux / gemini / patches-3.10 / 121-arm-gemini-register-ethernet.patch
1 --- a/arch/arm/mach-gemini/board-nas4220b.c             2011-04-21 13:19:09.878432930 +0200
2 +++ b/arch/arm/mach-gemini/board-nas4220b.c             2011-04-21 13:30:37.555082365 +0200
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 @@ -107,9 +125,39 @@
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 @@ -96,6 +144,8 @@
72         platform_device_register(&ib4220b_key_device);
73         platform_register_rtc();
74         platform_register_watchdog();
75 +       platform_device_register(&ib4220b_phy_device);
76 +       platform_register_ethernet(&ib4220b_gmac_data);
77  }
78  
79  MACHINE_START(NAS4220B, "Raidsonic NAS IB-4220-B")
80 --- a/arch/arm/mach-gemini/board-wbd111.c
81 +++ b/arch/arm/mach-gemini/board-wbd111.c
82 @@ -22,9 +22,29 @@
83  #include <asm/mach/arch.h>
84  #include <asm/mach/time.h>
85  
86 +#include <mach/gmac.h>
87  
88  #include "common.h"
89  
90 +static struct mdio_gpio_platform_data wbd111_mdio = {
91 +       .mdc            = 22,
92 +       .mdio           = 21,
93 +       .phy_mask       = ~(1 << 1),
94 +};
95 +
96 +static struct platform_device wbd111_phy_device = {
97 +       .name   = "mdio-gpio",
98 +       .id     = 0,
99 +       .dev    = {
100 +               .platform_data = &wbd111_mdio,
101 +       },
102 +};
103 +
104 +static struct gemini_gmac_platform_data gmac_data = {
105 +       .bus_id[0] = "gpio-0:01",
106 +       .interface[0] = PHY_INTERFACE_MODE_MII,
107 +};
108 +
109  static struct gpio_keys_button wbd111_keys[] = {
110         {
111                 .code           = KEY_SETUP,
112 @@ -123,6 +143,8 @@ static void __init wbd111_init(void)
113         platform_device_register(&wbd111_keys_device);
114         platform_register_rtc();
115         platform_register_watchdog();
116 +       platform_device_register(&wbd111_phy_device);
117 +       platform_register_ethernet(&gmac_data);
118  }
119  
120  MACHINE_START(WBD111, "Wiliboard WBD-111")
121 --- a/arch/arm/mach-gemini/board-wbd222.c
122 +++ b/arch/arm/mach-gemini/board-wbd222.c
123 @@ -22,9 +22,31 @@
124  #include <asm/mach/arch.h>
125  #include <asm/mach/time.h>
126  
127 +#include <mach/gmac.h>
128  
129  #include "common.h"
130  
131 +static struct mdio_gpio_platform_data wbd222_mdio = {
132 +       .mdc            = 22,
133 +       .mdio           = 21,
134 +       .phy_mask       = ~((1 << 1) | (1 << 3)),
135 +};
136 +
137 +static struct platform_device wbd222_phy_device = {
138 +       .name   = "mdio-gpio",
139 +       .id     = 0,
140 +       .dev    = {
141 +               .platform_data = &wbd222_mdio,
142 +       },
143 +};
144 +
145 +static struct gemini_gmac_platform_data gmac_data = {
146 +       .bus_id[0] = "gpio-0:01",
147 +       .interface[0] = PHY_INTERFACE_MODE_MII,
148 +       .bus_id[1] = "gpio-0:03",
149 +        .interface[1] = PHY_INTERFACE_MODE_MII,
150 +};
151 +
152  static struct gpio_keys_button wbd222_keys[] = {
153         {
154                 .code           = KEY_SETUP,
155 @@ -123,6 +145,8 @@ static void __init wbd222_init(void)
156         platform_device_register(&wbd222_keys_device);
157         platform_register_rtc();
158         platform_register_watchdog();
159 +       platform_device_register(&wbd222_phy_device);
160 +       platform_register_ethernet(&gmac_data);
161  }
162  
163  MACHINE_START(WBD222, "Wiliboard WBD-222")
164 --- a/arch/arm/mach-gemini/board-rut1xx.c
165 +++ b/arch/arm/mach-gemini/board-rut1xx.c
166 @@ -15,13 +15,35 @@
167  #include <linux/input.h>
168  #include <linux/gpio_keys.h>
169  #include <linux/sizes.h>
170 +#include <linux/mdio-gpio.h>
171  
172  #include <asm/mach-types.h>
173  #include <asm/mach/arch.h>
174  #include <asm/mach/time.h>
175  
176 +#include <mach/gmac.h>
177 +
178  #include "common.h"
179  
180 +static struct mdio_gpio_platform_data rut1xx_mdio = {
181 +       .mdc            = 22,
182 +       .mdio           = 21,
183 +       .phy_mask       = ~(1 << 1),
184 +};
185 +
186 +static struct platform_device rut1xx_phy_device = {
187 +       .name   = "mdio-gpio",
188 +       .id     = 0,
189 +       .dev    = {
190 +               .platform_data = &rut1xx_mdio,
191 +       },
192 +};
193 +
194 +static struct gemini_gmac_platform_data gmac_data = {
195 +       .bus_id[0] = "gpio-0:01",
196 +       .interface[0] = PHY_INTERFACE_MODE_MII,
197 +};
198 +
199  static struct gpio_keys_button rut1xx_keys[] = {
200         {
201                 .code           = KEY_SETUP,
202 @@ -81,6 +103,8 @@ static void __init rut1xx_init(void)
203         platform_device_register(&rut1xx_keys_device);
204         platform_register_rtc();
205         platform_register_watchdog();
206 +       platform_device_register(&rut1xx_phy_device);
207 +       platform_register_ethernet(&gmac_data);
208  }
209  
210  MACHINE_START(RUT100, "Teltonika RUT100")