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