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