Commit b31a1d8b41513b96e9c7ec2f68c5734cef0b26a4

Authored by Andy Fleming
Committed by David S. Miller
1 parent 257d938a0c

gianfar: Convert gianfar to an of_platform_driver

Does the same for the accompanying MDIO driver, and then modifies the TBI
configuration method.  The old way used fields in einfo, which no longer
exists.  The new way is to create an MDIO device-tree node for each instance
of gianfar, and create a tbi-handle property to associate ethernet controllers
with the TBI PHYs they are connected to.

Signed-off-by: Andy Fleming <afleming@freescale.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 42 changed files with 1217 additions and 424 deletions Side-by-side Diff

Documentation/powerpc/dts-bindings/fsl/tsec.txt
... ... @@ -2,8 +2,8 @@
2 2  
3 3 The MDIO is a bus to which the PHY devices are connected. For each
4 4 device that exists on this bus, a child node should be created. See
5   -the definition of the PHY node below for an example of how to define
6   -a PHY.
  5 +the definition of the PHY node in booting-without-of.txt for an example
  6 +of how to define a PHY.
7 7  
8 8 Required properties:
9 9 - reg : Offset and length of the register set for the device
... ... @@ -21,6 +21,14 @@
21 21 };
22 22 };
23 23  
  24 +* TBI Internal MDIO bus
  25 +
  26 +As of this writing, every tsec is associated with an internal TBI PHY.
  27 +This PHY is accessed through the local MDIO bus. These buses are defined
  28 +similarly to the mdio buses, except they are compatible with "fsl,gianfar-tbi".
  29 +The TBI PHYs underneath them are similar to normal PHYs, but the reg property
  30 +is considered instructive, rather than descriptive. The reg property should
  31 +be chosen so it doesn't interfere with other PHYs on the bus.
24 32  
25 33 * Gianfar-compatible ethernet nodes
26 34  
arch/powerpc/boot/dts/asp834x-redboot.dts
... ... @@ -199,8 +199,26 @@
199 199 reg = <0x2>;
200 200 device_type = "ethernet-phy";
201 201 };
  202 +
  203 + tbi0: tbi-phy@11 {
  204 + reg = <0x11>;
  205 + device_type = "tbi-phy";
  206 + };
202 207 };
203 208  
  209 + mdio@25520 {
  210 + #address-cells = <1>;
  211 + #size-cells = <0>;
  212 + compatible = "fsl,gianfar-tbi";
  213 + reg = <0x25520 0x20>;
  214 +
  215 + tbi1: tbi-phy@11 {
  216 + reg = <0x11>;
  217 + device_type = "tbi-phy";
  218 + };
  219 + };
  220 +
  221 +
204 222 enet0: ethernet@24000 {
205 223 cell-index = <0>;
206 224 device_type = "network";
... ... @@ -210,6 +228,7 @@
210 228 local-mac-address = [ 00 08 e5 11 32 33 ];
211 229 interrupts = <32 0x8 33 0x8 34 0x8>;
212 230 interrupt-parent = <&ipic>;
  231 + tbi-handle = <&tbi0>;
213 232 phy-handle = <&phy0>;
214 233 linux,network-index = <0>;
215 234 };
... ... @@ -223,6 +242,7 @@
223 242 local-mac-address = [ 00 08 e5 11 32 34 ];
224 243 interrupts = <35 0x8 36 0x8 37 0x8>;
225 244 interrupt-parent = <&ipic>;
  245 + tbi-handle = <&tbi1>;
226 246 phy-handle = <&phy1>;
227 247 linux,network-index = <1>;
228 248 };
arch/powerpc/boot/dts/ksi8560.dts
... ... @@ -141,8 +141,26 @@
141 141 reg = <0x2>;
142 142 device_type = "ethernet-phy";
143 143 };
  144 +
  145 + tbi0: tbi-phy@11 {
  146 + reg = <0x11>;
  147 + device_type = "tbi-phy";
  148 + };
144 149 };
145 150  
  151 + mdio@25520 {
  152 + #address-cells = <1>;
  153 + #size-cells = <0>;
  154 + compatible = "fsl,gianfar-tbi";
  155 + reg = <0x25520 0x20>;
  156 +
  157 + tbi1: tbi-phy@11 {
  158 + reg = <0x11>;
  159 + device_type = "tbi-phy";
  160 + };
  161 + };
  162 +
  163 +
146 164 enet0: ethernet@24000 {
147 165 device_type = "network";
148 166 model = "TSEC";
... ... @@ -152,6 +170,7 @@
152 170 local-mac-address = [ 00 00 00 00 00 00 ];
153 171 interrupts = <0x1d 0x2 0x1e 0x2 0x22 0x2>;
154 172 interrupt-parent = <&mpic>;
  173 + tbi-handle = <&tbi0>;
155 174 phy-handle = <&PHY1>;
156 175 };
157 176  
... ... @@ -164,6 +183,7 @@
164 183 local-mac-address = [ 00 00 00 00 00 00 ];
165 184 interrupts = <0x23 0x2 0x24 0x2 0x28 0x2>;
166 185 interrupt-parent = <&mpic>;
  186 + tbi-handle = <&tbi1>;
167 187 phy-handle = <&PHY2>;
168 188 };
169 189  
arch/powerpc/boot/dts/mpc8313erdb.dts
... ... @@ -190,6 +190,7 @@
190 190 local-mac-address = [ 00 00 00 00 00 00 ];
191 191 interrupts = <37 0x8 36 0x8 35 0x8>;
192 192 interrupt-parent = <&ipic>;
  193 + tbi-handle = < &tbi0 >;
193 194 phy-handle = < &phy1 >;
194 195 fsl,magic-packet;
195 196  
... ... @@ -210,6 +211,10 @@
210 211 reg = <0x4>;
211 212 device_type = "ethernet-phy";
212 213 };
  214 + tbi0: tbi-phy@11 {
  215 + reg = <0x11>;
  216 + device_type = "tbi-phy";
  217 + };
213 218 };
214 219 };
215 220  
216 221  
... ... @@ -222,9 +227,24 @@
222 227 local-mac-address = [ 00 00 00 00 00 00 ];
223 228 interrupts = <34 0x8 33 0x8 32 0x8>;
224 229 interrupt-parent = <&ipic>;
  230 + tbi-handle = < &tbi1 >;
225 231 phy-handle = < &phy4 >;
226 232 sleep = <&pmc 0x10000000>;
227 233 fsl,magic-packet;
  234 +
  235 + mdio@25520 {
  236 + #address-cells = <1>;
  237 + #size-cells = <0>;
  238 + compatible = "fsl,gianfar-tbi";
  239 + reg = <0x25520 0x20>;
  240 +
  241 + tbi1: tbi-phy@11 {
  242 + reg = <0x11>;
  243 + device_type = "tbi-phy";
  244 + };
  245 + };
  246 +
  247 +
228 248 };
229 249  
230 250 serial0: serial@4500 {
arch/powerpc/boot/dts/mpc8315erdb.dts
... ... @@ -206,8 +206,25 @@
206 206 reg = <0x1>;
207 207 device_type = "ethernet-phy";
208 208 };
  209 + tbi0: tbi-phy@11 {
  210 + reg = <0x11>;
  211 + device_type = "tbi-phy";
  212 + };
209 213 };
210 214  
  215 + mdio@25520 {
  216 + #address-cells = <1>;
  217 + #size-cells = <0>;
  218 + compatible = "fsl,gianfar-tbi";
  219 + reg = <0x25520 0x20>;
  220 +
  221 + tbi1: tbi-phy@11 {
  222 + reg = <0x11>;
  223 + device_type = "tbi-phy";
  224 + };
  225 + };
  226 +
  227 +
211 228 enet0: ethernet@24000 {
212 229 cell-index = <0>;
213 230 device_type = "network";
... ... @@ -217,6 +234,7 @@
217 234 local-mac-address = [ 00 00 00 00 00 00 ];
218 235 interrupts = <32 0x8 33 0x8 34 0x8>;
219 236 interrupt-parent = <&ipic>;
  237 + tbi-handle = <&tbi0>;
220 238 phy-handle = < &phy0 >;
221 239 };
222 240  
... ... @@ -229,6 +247,7 @@
229 247 local-mac-address = [ 00 00 00 00 00 00 ];
230 248 interrupts = <35 0x8 36 0x8 37 0x8>;
231 249 interrupt-parent = <&ipic>;
  250 + tbi-handle = <&tbi1>;
232 251 phy-handle = < &phy1 >;
233 252 };
234 253  
arch/powerpc/boot/dts/mpc8349emitx.dts
... ... @@ -184,8 +184,24 @@
184 184 reg = <0x1c>;
185 185 device_type = "ethernet-phy";
186 186 };
  187 + tbi0: tbi-phy@11 {
  188 + reg = <0x11>;
  189 + device_type = "tbi-phy";
  190 + };
187 191 };
188 192  
  193 + mdio@25520 {
  194 + #address-cells = <1>;
  195 + #size-cells = <0>;
  196 + compatible = "fsl,gianfar-tbi";
  197 + reg = <0x25520 0x20>;
  198 +
  199 + tbi1: tbi-phy@11 {
  200 + reg = <0x11>;
  201 + device_type = "tbi-phy";
  202 + };
  203 + };
  204 +
189 205 enet0: ethernet@24000 {
190 206 cell-index = <0>;
191 207 device_type = "network";
... ... @@ -195,6 +211,7 @@
195 211 local-mac-address = [ 00 00 00 00 00 00 ];
196 212 interrupts = <32 0x8 33 0x8 34 0x8>;
197 213 interrupt-parent = <&ipic>;
  214 + tbi-handle = <&tbi0>;
198 215 phy-handle = <&phy1c>;
199 216 linux,network-index = <0>;
200 217 };
... ... @@ -211,6 +228,7 @@
211 228 /* Vitesse 7385 isn't on the MDIO bus */
212 229 fixed-link = <1 1 1000 0 0>;
213 230 linux,network-index = <1>;
  231 + tbi-handle = <&tbi1>;
214 232 };
215 233  
216 234 serial0: serial@4500 {
arch/powerpc/boot/dts/mpc8349emitxgp.dts
... ... @@ -163,6 +163,10 @@
163 163 reg = <0x1c>;
164 164 device_type = "ethernet-phy";
165 165 };
  166 + tbi0: tbi-phy@11 {
  167 + reg = <0x11>;
  168 + device_type = "tbi-phy";
  169 + };
166 170 };
167 171  
168 172 enet0: ethernet@24000 {
... ... @@ -174,6 +178,7 @@
174 178 local-mac-address = [ 00 00 00 00 00 00 ];
175 179 interrupts = <32 0x8 33 0x8 34 0x8>;
176 180 interrupt-parent = <&ipic>;
  181 + tbi-handle = <&tbi0>;
177 182 phy-handle = <&phy1c>;
178 183 linux,network-index = <0>;
179 184 };
arch/powerpc/boot/dts/mpc834x_mds.dts
... ... @@ -185,8 +185,25 @@
185 185 reg = <0x1>;
186 186 device_type = "ethernet-phy";
187 187 };
  188 + tbi0: tbi-phy@11 {
  189 + reg = <0x11>;
  190 + device_type = "tbi-phy";
  191 + };
188 192 };
189 193  
  194 + mdio@25520 {
  195 + #address-cells = <1>;
  196 + #size-cells = <0>;
  197 + compatible = "fsl,gianfar-tbi";
  198 + reg = <0x25520 0x20>;
  199 +
  200 + tbi1: tbi-phy@11 {
  201 + reg = <0x11>;
  202 + device_type = "tbi-phy";
  203 + };
  204 + };
  205 +
  206 +
190 207 enet0: ethernet@24000 {
191 208 cell-index = <0>;
192 209 device_type = "network";
... ... @@ -196,6 +213,7 @@
196 213 local-mac-address = [ 00 00 00 00 00 00 ];
197 214 interrupts = <32 0x8 33 0x8 34 0x8>;
198 215 interrupt-parent = <&ipic>;
  216 + tbi-handle = <&tbi0>;
199 217 phy-handle = <&phy0>;
200 218 linux,network-index = <0>;
201 219 };
... ... @@ -209,6 +227,7 @@
209 227 local-mac-address = [ 00 00 00 00 00 00 ];
210 228 interrupts = <35 0x8 36 0x8 37 0x8>;
211 229 interrupt-parent = <&ipic>;
  230 + tbi-handle = <&tbi1>;
212 231 phy-handle = <&phy1>;
213 232 linux,network-index = <1>;
214 233 };
arch/powerpc/boot/dts/mpc8377_mds.dts
... ... @@ -193,8 +193,25 @@
193 193 reg = <0x3>;
194 194 device_type = "ethernet-phy";
195 195 };
  196 + tbi0: tbi-phy@11 {
  197 + reg = <0x11>;
  198 + device_type = "tbi-phy";
  199 + };
196 200 };
197 201  
  202 + mdio@25520 {
  203 + #address-cells = <1>;
  204 + #size-cells = <0>;
  205 + compatible = "fsl,gianfar-tbi";
  206 + reg = <0x25520 0x20>;
  207 +
  208 + tbi1: tbi-phy@11 {
  209 + reg = <0x11>;
  210 + device_type = "tbi-phy";
  211 + };
  212 + };
  213 +
  214 +
198 215 enet0: ethernet@24000 {
199 216 cell-index = <0>;
200 217 device_type = "network";
... ... @@ -205,6 +222,7 @@
205 222 interrupts = <32 0x8 33 0x8 34 0x8>;
206 223 phy-connection-type = "mii";
207 224 interrupt-parent = <&ipic>;
  225 + tbi-handle = <&tbi0>;
208 226 phy-handle = <&phy2>;
209 227 };
210 228  
... ... @@ -218,6 +236,7 @@
218 236 interrupts = <35 0x8 36 0x8 37 0x8>;
219 237 phy-connection-type = "mii";
220 238 interrupt-parent = <&ipic>;
  239 + tbi-handle = <&tbi1>;
221 240 phy-handle = <&phy3>;
222 241 };
223 242  
arch/powerpc/boot/dts/mpc8377_rdb.dts
... ... @@ -211,8 +211,25 @@
211 211 reg = <0x2>;
212 212 device_type = "ethernet-phy";
213 213 };
  214 + tbi0: tbi-phy@11 {
  215 + reg = <0x11>;
  216 + device_type = "tbi-phy";
  217 + };
214 218 };
215 219  
  220 + mdio@25520 {
  221 + #address-cells = <1>;
  222 + #size-cells = <0>;
  223 + compatible = "fsl,gianfar-tbi";
  224 + reg = <0x25520 0x20>;
  225 +
  226 + tbi1: tbi-phy@11 {
  227 + reg = <0x11>;
  228 + device_type = "tbi-phy";
  229 + };
  230 + };
  231 +
  232 +
216 233 enet0: ethernet@24000 {
217 234 cell-index = <0>;
218 235 device_type = "network";
... ... @@ -223,6 +240,7 @@
223 240 interrupts = <32 0x8 33 0x8 34 0x8>;
224 241 phy-connection-type = "mii";
225 242 interrupt-parent = <&ipic>;
  243 + tbi-handle = <&tbi0>;
226 244 phy-handle = <&phy2>;
227 245 };
228 246  
... ... @@ -237,6 +255,7 @@
237 255 phy-connection-type = "mii";
238 256 interrupt-parent = <&ipic>;
239 257 fixed-link = <1 1 1000 0 0>;
  258 + tbi-handle = <&tbi1>;
240 259 };
241 260  
242 261 serial0: serial@4500 {
arch/powerpc/boot/dts/mpc8378_mds.dts
... ... @@ -232,8 +232,25 @@
232 232 reg = <0x3>;
233 233 device_type = "ethernet-phy";
234 234 };
  235 + tbi0: tbi-phy@11 {
  236 + reg = <0x11>;
  237 + device_type = "tbi-phy";
  238 + };
235 239 };
236 240  
  241 + mdio@25520 {
  242 + #address-cells = <1>;
  243 + #size-cells = <0>;
  244 + compatible = "fsl,gianfar-tbi";
  245 + reg = <0x25520 0x20>;
  246 +
  247 + tbi1: tbi-phy@11 {
  248 + reg = <0x11>;
  249 + device_type = "tbi-phy";
  250 + };
  251 + };
  252 +
  253 +
237 254 enet0: ethernet@24000 {
238 255 cell-index = <0>;
239 256 device_type = "network";
... ... @@ -244,6 +261,7 @@
244 261 interrupts = <32 0x8 33 0x8 34 0x8>;
245 262 phy-connection-type = "mii";
246 263 interrupt-parent = <&ipic>;
  264 + tbi-handle = <&tbi0>;
247 265 phy-handle = <&phy2>;
248 266 };
249 267  
... ... @@ -257,6 +275,7 @@
257 275 interrupts = <35 0x8 36 0x8 37 0x8>;
258 276 phy-connection-type = "mii";
259 277 interrupt-parent = <&ipic>;
  278 + tbi-handle = <&tbi1>;
260 279 phy-handle = <&phy3>;
261 280 };
262 281  
arch/powerpc/boot/dts/mpc8378_rdb.dts
... ... @@ -211,7 +211,24 @@
211 211 reg = <0x2>;
212 212 device_type = "ethernet-phy";
213 213 };
  214 + tbi0: tbi-phy@11 {
  215 + reg = <0x11>;
  216 + device_type = "tbi-phy";
  217 + };
214 218 };
  219 +
  220 + mdio@25520 {
  221 + #address-cells = <1>;
  222 + #size-cells = <0>;
  223 + compatible = "fsl,gianfar-tbi";
  224 + reg = <0x25520 0x20>;
  225 +
  226 + tbi1: tbi-phy@11 {
  227 + reg = <0x11>;
  228 + device_type = "tbi-phy";
  229 + };
  230 + };
  231 +
215 232  
216 233 enet0: ethernet@24000 {
217 234 cell-index = <0>;
arch/powerpc/boot/dts/mpc8379_mds.dts
... ... @@ -232,8 +232,24 @@
232 232 reg = <0x3>;
233 233 device_type = "ethernet-phy";
234 234 };
  235 + tbi0: tbi-phy@11 {
  236 + reg = <0x11>;
  237 + device_type = "tbi-phy";
  238 + };
235 239 };
236 240  
  241 + mdio@25520 {
  242 + #address-cells = <1>;
  243 + #size-cells = <0>;
  244 + compatible = "fsl,gianfar-tbi";
  245 + reg = <0x25520 0x20>;
  246 +
  247 + tbi1: tbi-phy@11 {
  248 + reg = <0x11>;
  249 + device_type = "tbi-phy";
  250 + };
  251 + };
  252 +
237 253 enet0: ethernet@24000 {
238 254 cell-index = <0>;
239 255 device_type = "network";
... ... @@ -244,6 +260,7 @@
244 260 interrupts = <32 0x8 33 0x8 34 0x8>;
245 261 phy-connection-type = "mii";
246 262 interrupt-parent = <&ipic>;
  263 + tbi-handle = <&tbi0>;
247 264 phy-handle = <&phy2>;
248 265 };
249 266  
... ... @@ -257,6 +274,7 @@
257 274 interrupts = <35 0x8 36 0x8 37 0x8>;
258 275 phy-connection-type = "mii";
259 276 interrupt-parent = <&ipic>;
  277 + tbi-handle = <&tbi1>;
260 278 phy-handle = <&phy3>;
261 279 };
262 280  
arch/powerpc/boot/dts/mpc8379_rdb.dts
... ... @@ -211,8 +211,24 @@
211 211 reg = <0x2>;
212 212 device_type = "ethernet-phy";
213 213 };
  214 + tbi0: tbi-phy@11 {
  215 + reg = <0x11>;
  216 + device_type = "tbi-phy";
  217 + };
214 218 };
215 219  
  220 + mdio@25520 {
  221 + #address-cells = <1>;
  222 + #size-cells = <0>;
  223 + compatible = "fsl,gianfar-tbi";
  224 + reg = <0x25520 0x20>;
  225 +
  226 + tbi1: tbi-phy@11 {
  227 + reg = <0x11>;
  228 + device_type = "tbi-phy";
  229 + };
  230 + };
  231 +
216 232 enet0: ethernet@24000 {
217 233 cell-index = <0>;
218 234 device_type = "network";
... ... @@ -223,6 +239,7 @@
223 239 interrupts = <32 0x8 33 0x8 34 0x8>;
224 240 phy-connection-type = "mii";
225 241 interrupt-parent = <&ipic>;
  242 + tbi-handle = <&tbi0>;
226 243 phy-handle = <&phy2>;
227 244 };
228 245  
... ... @@ -237,6 +254,7 @@
237 254 phy-connection-type = "mii";
238 255 interrupt-parent = <&ipic>;
239 256 fixed-link = <1 1 1000 0 0>;
  257 + tbi-handle = <&tbi1>;
240 258 };
241 259  
242 260 serial0: serial@4500 {
arch/powerpc/boot/dts/mpc8536ds.dts
... ... @@ -155,8 +155,24 @@
155 155 reg = <1>;
156 156 device_type = "ethernet-phy";
157 157 };
  158 + tbi0: tbi-phy@11 {
  159 + reg = <0x11>;
  160 + device_type = "tbi-phy";
  161 + };
158 162 };
159 163  
  164 + mdio@26520 {
  165 + #address-cells = <1>;
  166 + #size-cells = <0>;
  167 + compatible = "fsl,gianfar-tbi";
  168 + reg = <0x26520 0x20>;
  169 +
  170 + tbi1: tbi-phy@11 {
  171 + reg = <0x11>;
  172 + device_type = "tbi-phy";
  173 + };
  174 + };
  175 +
160 176 usb@22000 {
161 177 compatible = "fsl,mpc8536-usb2-mph", "fsl-usb2-mph";
162 178 reg = <0x22000 0x1000>;
... ... @@ -186,6 +202,7 @@
186 202 local-mac-address = [ 00 00 00 00 00 00 ];
187 203 interrupts = <29 2 30 2 34 2>;
188 204 interrupt-parent = <&mpic>;
  205 + tbi-handle = <&tbi0>;
189 206 phy-handle = <&phy1>;
190 207 phy-connection-type = "rgmii-id";
191 208 };
... ... @@ -199,6 +216,7 @@
199 216 local-mac-address = [ 00 00 00 00 00 00 ];
200 217 interrupts = <31 2 32 2 33 2>;
201 218 interrupt-parent = <&mpic>;
  219 + tbi-handle = <&tbi1>;
202 220 phy-handle = <&phy0>;
203 221 phy-connection-type = "rgmii-id";
204 222 };
arch/powerpc/boot/dts/mpc8540ads.dts
... ... @@ -150,8 +150,36 @@
150 150 reg = <0x3>;
151 151 device_type = "ethernet-phy";
152 152 };
  153 + tbi0: tbi-phy@11 {
  154 + reg = <0x11>;
  155 + device_type = "tbi-phy";
  156 + };
153 157 };
154 158  
  159 + mdio@25520 {
  160 + #address-cells = <1>;
  161 + #size-cells = <0>;
  162 + compatible = "fsl,gianfar-tbi";
  163 + reg = <0x25520 0x20>;
  164 +
  165 + tbi1: tbi-phy@11 {
  166 + reg = <0x11>;
  167 + device_type = "tbi-phy";
  168 + };
  169 + };
  170 +
  171 + mdio@26520 {
  172 + #address-cells = <1>;
  173 + #size-cells = <0>;
  174 + compatible = "fsl,gianfar-tbi";
  175 + reg = <0x26520 0x20>;
  176 +
  177 + tbi2: tbi-phy@11 {
  178 + reg = <0x11>;
  179 + device_type = "tbi-phy";
  180 + };
  181 + };
  182 +
155 183 enet0: ethernet@24000 {
156 184 cell-index = <0>;
157 185 device_type = "network";
... ... @@ -161,6 +189,7 @@
161 189 local-mac-address = [ 00 00 00 00 00 00 ];
162 190 interrupts = <29 2 30 2 34 2>;
163 191 interrupt-parent = <&mpic>;
  192 + tbi-handle = <&tbi0>;
164 193 phy-handle = <&phy0>;
165 194 };
166 195  
... ... @@ -173,6 +202,7 @@
173 202 local-mac-address = [ 00 00 00 00 00 00 ];
174 203 interrupts = <35 2 36 2 40 2>;
175 204 interrupt-parent = <&mpic>;
  205 + tbi-handle = <&tbi1>;
176 206 phy-handle = <&phy1>;
177 207 };
178 208  
... ... @@ -185,6 +215,7 @@
185 215 local-mac-address = [ 00 00 00 00 00 00 ];
186 216 interrupts = <41 2>;
187 217 interrupt-parent = <&mpic>;
  218 + tbi-handle = <&tbi2>;
188 219 phy-handle = <&phy3>;
189 220 };
190 221  
arch/powerpc/boot/dts/mpc8541cds.dts
... ... @@ -144,8 +144,24 @@
144 144 reg = <0x1>;
145 145 device_type = "ethernet-phy";
146 146 };
  147 + tbi0: tbi-phy@11 {
  148 + reg = <0x11>;
  149 + device_type = "tbi-phy";
  150 + };
147 151 };
148 152  
  153 + mdio@25520 {
  154 + #address-cells = <1>;
  155 + #size-cells = <0>;
  156 + compatible = "fsl,gianfar-tbi";
  157 + reg = <0x25520 0x20>;
  158 +
  159 + tbi1: tbi-phy@11 {
  160 + reg = <0x11>;
  161 + device_type = "tbi-phy";
  162 + };
  163 + };
  164 +
149 165 enet0: ethernet@24000 {
150 166 cell-index = <0>;
151 167 device_type = "network";
... ... @@ -155,6 +171,7 @@
155 171 local-mac-address = [ 00 00 00 00 00 00 ];
156 172 interrupts = <29 2 30 2 34 2>;
157 173 interrupt-parent = <&mpic>;
  174 + tbi-handle = <&tbi0>;
158 175 phy-handle = <&phy0>;
159 176 };
160 177  
... ... @@ -167,6 +184,7 @@
167 184 local-mac-address = [ 00 00 00 00 00 00 ];
168 185 interrupts = <35 2 36 2 40 2>;
169 186 interrupt-parent = <&mpic>;
  187 + tbi-handle = <&tbi1>;
170 188 phy-handle = <&phy1>;
171 189 };
172 190  
arch/powerpc/boot/dts/mpc8544ds.dts
... ... @@ -116,8 +116,26 @@
116 116 reg = <0x1>;
117 117 device_type = "ethernet-phy";
118 118 };
  119 +
  120 + tbi0: tbi-phy@11 {
  121 + reg = <0x11>;
  122 + device_type = "tbi-phy";
  123 + };
119 124 };
120 125  
  126 + mdio@26520 {
  127 + #address-cells = <1>;
  128 + #size-cells = <0>;
  129 + compatible = "fsl,gianfar-tbi";
  130 + reg = <0x26520 0x20>;
  131 +
  132 + tbi1: tbi-phy@11 {
  133 + reg = <0x11>;
  134 + device_type = "tbi-phy";
  135 + };
  136 + };
  137 +
  138 +
121 139 dma@21300 {
122 140 #address-cells = <1>;
123 141 #size-cells = <1>;
... ... @@ -169,6 +187,7 @@
169 187 interrupts = <29 2 30 2 34 2>;
170 188 interrupt-parent = <&mpic>;
171 189 phy-handle = <&phy0>;
  190 + tbi-handle = <&tbi0>;
172 191 phy-connection-type = "rgmii-id";
173 192 };
174 193  
... ... @@ -182,6 +201,7 @@
182 201 interrupts = <31 2 32 2 33 2>;
183 202 interrupt-parent = <&mpic>;
184 203 phy-handle = <&phy1>;
  204 + tbi-handle = <&tbi1>;
185 205 phy-connection-type = "rgmii-id";
186 206 };
187 207  
arch/powerpc/boot/dts/mpc8548cds.dts
... ... @@ -172,8 +172,48 @@
172 172 reg = <0x3>;
173 173 device_type = "ethernet-phy";
174 174 };
  175 + tbi0: tbi-phy@11 {
  176 + reg = <0x11>;
  177 + device_type = "tbi-phy";
  178 + };
175 179 };
176 180  
  181 + mdio@25520 {
  182 + #address-cells = <1>;
  183 + #size-cells = <0>;
  184 + compatible = "fsl,gianfar-tbi";
  185 + reg = <0x25520 0x20>;
  186 +
  187 + tbi1: tbi-phy@11 {
  188 + reg = <0x11>;
  189 + device_type = "tbi-phy";
  190 + };
  191 + };
  192 +
  193 + mdio@26520 {
  194 + #address-cells = <1>;
  195 + #size-cells = <0>;
  196 + compatible = "fsl,gianfar-tbi";
  197 + reg = <0x26520 0x20>;
  198 +
  199 + tbi2: tbi-phy@11 {
  200 + reg = <0x11>;
  201 + device_type = "tbi-phy";
  202 + };
  203 + };
  204 +
  205 + mdio@27520 {
  206 + #address-cells = <1>;
  207 + #size-cells = <0>;
  208 + compatible = "fsl,gianfar-tbi";
  209 + reg = <0x27520 0x20>;
  210 +
  211 + tbi3: tbi-phy@11 {
  212 + reg = <0x11>;
  213 + device_type = "tbi-phy";
  214 + };
  215 + };
  216 +
177 217 enet0: ethernet@24000 {
178 218 cell-index = <0>;
179 219 device_type = "network";
... ... @@ -183,6 +223,7 @@
183 223 local-mac-address = [ 00 00 00 00 00 00 ];
184 224 interrupts = <29 2 30 2 34 2>;
185 225 interrupt-parent = <&mpic>;
  226 + tbi-handle = <&tbi0>;
186 227 phy-handle = <&phy0>;
187 228 };
188 229  
... ... @@ -195,6 +236,7 @@
195 236 local-mac-address = [ 00 00 00 00 00 00 ];
196 237 interrupts = <35 2 36 2 40 2>;
197 238 interrupt-parent = <&mpic>;
  239 + tbi-handle = <&tbi1>;
198 240 phy-handle = <&phy1>;
199 241 };
200 242  
... ... @@ -208,6 +250,7 @@
208 250 local-mac-address = [ 00 00 00 00 00 00 ];
209 251 interrupts = <31 2 32 2 33 2>;
210 252 interrupt-parent = <&mpic>;
  253 + tbi-handle = <&tbi2>;
211 254 phy-handle = <&phy2>;
212 255 };
213 256  
... ... @@ -220,6 +263,7 @@
220 263 local-mac-address = [ 00 00 00 00 00 00 ];
221 264 interrupts = <37 2 38 2 39 2>;
222 265 interrupt-parent = <&mpic>;
  266 + tbi-handle = <&tbi3>;
223 267 phy-handle = <&phy3>;
224 268 };
225 269 */
arch/powerpc/boot/dts/mpc8555cds.dts
... ... @@ -144,8 +144,24 @@
144 144 reg = <0x1>;
145 145 device_type = "ethernet-phy";
146 146 };
  147 + tbi0: tbi-phy@11 {
  148 + reg = <0x11>;
  149 + device_type = "tbi-phy";
  150 + };
147 151 };
148 152  
  153 + mdio@25520 {
  154 + #address-cells = <1>;
  155 + #size-cells = <0>;
  156 + compatible = "fsl,gianfar-tbi";
  157 + reg = <0x25520 0x20>;
  158 +
  159 + tbi1: tbi-phy@11 {
  160 + reg = <0x11>;
  161 + device_type = "tbi-phy";
  162 + };
  163 + };
  164 +
149 165 enet0: ethernet@24000 {
150 166 cell-index = <0>;
151 167 device_type = "network";
... ... @@ -155,6 +171,7 @@
155 171 local-mac-address = [ 00 00 00 00 00 00 ];
156 172 interrupts = <29 2 30 2 34 2>;
157 173 interrupt-parent = <&mpic>;
  174 + tbi-handle = <&tbi0>;
158 175 phy-handle = <&phy0>;
159 176 };
160 177  
... ... @@ -167,6 +184,7 @@
167 184 local-mac-address = [ 00 00 00 00 00 00 ];
168 185 interrupts = <35 2 36 2 40 2>;
169 186 interrupt-parent = <&mpic>;
  187 + tbi-handle = <&tbi1>;
170 188 phy-handle = <&phy1>;
171 189 };
172 190  
arch/powerpc/boot/dts/mpc8560ads.dts
... ... @@ -145,8 +145,24 @@
145 145 reg = <0x3>;
146 146 device_type = "ethernet-phy";
147 147 };
  148 + tbi0: tbi-phy@11 {
  149 + reg = <0x11>;
  150 + device_type = "tbi-phy";
  151 + };
148 152 };
149 153  
  154 + mdio@25520 {
  155 + #address-cells = <1>;
  156 + #size-cells = <0>;
  157 + compatible = "fsl,gianfar-tbi";
  158 + reg = <0x25520 0x20>;
  159 +
  160 + tbi1: tbi-phy@11 {
  161 + reg = <0x11>;
  162 + device_type = "tbi-phy";
  163 + };
  164 + };
  165 +
150 166 enet0: ethernet@24000 {
151 167 cell-index = <0>;
152 168 device_type = "network";
... ... @@ -156,6 +172,7 @@
156 172 local-mac-address = [ 00 00 00 00 00 00 ];
157 173 interrupts = <29 2 30 2 34 2>;
158 174 interrupt-parent = <&mpic>;
  175 + tbi-handle = <&tbi0>;
159 176 phy-handle = <&phy0>;
160 177 };
161 178  
... ... @@ -168,6 +185,7 @@
168 185 local-mac-address = [ 00 00 00 00 00 00 ];
169 186 interrupts = <35 2 36 2 40 2>;
170 187 interrupt-parent = <&mpic>;
  188 + tbi-handle = <&tbi1>;
171 189 phy-handle = <&phy1>;
172 190 };
173 191  
arch/powerpc/boot/dts/mpc8568mds.dts
... ... @@ -179,8 +179,24 @@
179 179 reg = <0x3>;
180 180 device_type = "ethernet-phy";
181 181 };
  182 + tbi0: tbi-phy@11 {
  183 + reg = <0x11>;
  184 + device_type = "tbi-phy";
  185 + };
182 186 };
183 187  
  188 + mdio@25520 {
  189 + #address-cells = <1>;
  190 + #size-cells = <0>;
  191 + compatible = "fsl,gianfar-tbi";
  192 + reg = <0x25520 0x20>;
  193 +
  194 + tbi1: tbi-phy@11 {
  195 + reg = <0x11>;
  196 + device_type = "tbi-phy";
  197 + };
  198 + };
  199 +
184 200 enet0: ethernet@24000 {
185 201 cell-index = <0>;
186 202 device_type = "network";
... ... @@ -190,6 +206,7 @@
190 206 local-mac-address = [ 00 00 00 00 00 00 ];
191 207 interrupts = <29 2 30 2 34 2>;
192 208 interrupt-parent = <&mpic>;
  209 + tbi-handle = <&tbi0>;
193 210 phy-handle = <&phy2>;
194 211 };
195 212  
... ... @@ -202,6 +219,7 @@
202 219 local-mac-address = [ 00 00 00 00 00 00 ];
203 220 interrupts = <35 2 36 2 40 2>;
204 221 interrupt-parent = <&mpic>;
  222 + tbi-handle = <&tbi1>;
205 223 phy-handle = <&phy3>;
206 224 };
207 225  
arch/powerpc/boot/dts/mpc8572ds.dts
... ... @@ -225,8 +225,49 @@
225 225 interrupts = <10 1>;
226 226 reg = <0x3>;
227 227 };
  228 +
  229 + tbi0: tbi-phy@11 {
  230 + reg = <0x11>;
  231 + device_type = "tbi-phy";
  232 + };
228 233 };
229 234  
  235 + mdio@25520 {
  236 + #address-cells = <1>;
  237 + #size-cells = <0>;
  238 + compatible = "fsl,gianfar-tbi";
  239 + reg = <0x25520 0x20>;
  240 +
  241 + tbi1: tbi-phy@11 {
  242 + reg = <0x11>;
  243 + device_type = "tbi-phy";
  244 + };
  245 + };
  246 +
  247 + mdio@26520 {
  248 + #address-cells = <1>;
  249 + #size-cells = <0>;
  250 + compatible = "fsl,gianfar-tbi";
  251 + reg = <0x26520 0x20>;
  252 +
  253 + tbi2: tbi-phy@11 {
  254 + reg = <0x11>;
  255 + device_type = "tbi-phy";
  256 + };
  257 + };
  258 +
  259 + mdio@27520 {
  260 + #address-cells = <1>;
  261 + #size-cells = <0>;
  262 + compatible = "fsl,gianfar-tbi";
  263 + reg = <0x27520 0x20>;
  264 +
  265 + tbi3: tbi-phy@11 {
  266 + reg = <0x11>;
  267 + device_type = "tbi-phy";
  268 + };
  269 + };
  270 +
230 271 enet0: ethernet@24000 {
231 272 cell-index = <0>;
232 273 device_type = "network";
... ... @@ -236,6 +277,7 @@
236 277 local-mac-address = [ 00 00 00 00 00 00 ];
237 278 interrupts = <29 2 30 2 34 2>;
238 279 interrupt-parent = <&mpic>;
  280 + tbi-handle = <&tbi0>;
239 281 phy-handle = <&phy0>;
240 282 phy-connection-type = "rgmii-id";
241 283 };
... ... @@ -249,6 +291,7 @@
249 291 local-mac-address = [ 00 00 00 00 00 00 ];
250 292 interrupts = <35 2 36 2 40 2>;
251 293 interrupt-parent = <&mpic>;
  294 + tbi-handle = <&tbi1>;
252 295 phy-handle = <&phy1>;
253 296 phy-connection-type = "rgmii-id";
254 297 };
... ... @@ -262,6 +305,7 @@
262 305 local-mac-address = [ 00 00 00 00 00 00 ];
263 306 interrupts = <31 2 32 2 33 2>;
264 307 interrupt-parent = <&mpic>;
  308 + tbi-handle = <&tbi2>;
265 309 phy-handle = <&phy2>;
266 310 phy-connection-type = "rgmii-id";
267 311 };
... ... @@ -275,6 +319,7 @@
275 319 local-mac-address = [ 00 00 00 00 00 00 ];
276 320 interrupts = <37 2 38 2 39 2>;
277 321 interrupt-parent = <&mpic>;
  322 + tbi-handle = <&tbi3>;
278 323 phy-handle = <&phy3>;
279 324 phy-connection-type = "rgmii-id";
280 325 };
arch/powerpc/boot/dts/mpc8641_hpcn.dts
... ... @@ -205,8 +205,49 @@
205 205 reg = <3>;
206 206 device_type = "ethernet-phy";
207 207 };
  208 + tbi0: tbi-phy@11 {
  209 + reg = <0x11>;
  210 + device_type = "tbi-phy";
  211 + };
208 212 };
209 213  
  214 + mdio@25520 {
  215 + #address-cells = <1>;
  216 + #size-cells = <0>;
  217 + compatible = "fsl,gianfar-tbi";
  218 + reg = <0x25520 0x20>;
  219 +
  220 + tbi1: tbi-phy@11 {
  221 + reg = <0x11>;
  222 + device_type = "tbi-phy";
  223 + };
  224 + };
  225 +
  226 + mdio@26520 {
  227 + #address-cells = <1>;
  228 + #size-cells = <0>;
  229 + compatible = "fsl,gianfar-tbi";
  230 + reg = <0x26520 0x20>;
  231 +
  232 + tbi2: tbi-phy@11 {
  233 + reg = <0x11>;
  234 + device_type = "tbi-phy";
  235 + };
  236 + };
  237 +
  238 + mdio@27520 {
  239 + #address-cells = <1>;
  240 + #size-cells = <0>;
  241 + compatible = "fsl,gianfar-tbi";
  242 + reg = <0x27520 0x20>;
  243 +
  244 + tbi3: tbi-phy@11 {
  245 + reg = <0x11>;
  246 + device_type = "tbi-phy";
  247 + };
  248 + };
  249 +
  250 +
210 251 enet0: ethernet@24000 {
211 252 cell-index = <0>;
212 253 device_type = "network";
... ... @@ -216,6 +257,7 @@
216 257 local-mac-address = [ 00 00 00 00 00 00 ];
217 258 interrupts = <29 2 30 2 34 2>;
218 259 interrupt-parent = <&mpic>;
  260 + tbi-handle = <&tbi0>;
219 261 phy-handle = <&phy0>;
220 262 phy-connection-type = "rgmii-id";
221 263 };
... ... @@ -229,6 +271,7 @@
229 271 local-mac-address = [ 00 00 00 00 00 00 ];
230 272 interrupts = <35 2 36 2 40 2>;
231 273 interrupt-parent = <&mpic>;
  274 + tbi-handle = <&tbi1>;
232 275 phy-handle = <&phy1>;
233 276 phy-connection-type = "rgmii-id";
234 277 };
... ... @@ -242,6 +285,7 @@
242 285 local-mac-address = [ 00 00 00 00 00 00 ];
243 286 interrupts = <31 2 32 2 33 2>;
244 287 interrupt-parent = <&mpic>;
  288 + tbi-handle = <&tbi2>;
245 289 phy-handle = <&phy2>;
246 290 phy-connection-type = "rgmii-id";
247 291 };
... ... @@ -255,6 +299,7 @@
255 299 local-mac-address = [ 00 00 00 00 00 00 ];
256 300 interrupts = <37 2 38 2 39 2>;
257 301 interrupt-parent = <&mpic>;
  302 + tbi-handle = <&tbi3>;
258 303 phy-handle = <&phy3>;
259 304 phy-connection-type = "rgmii-id";
260 305 };
arch/powerpc/boot/dts/sbc8349.dts
... ... @@ -177,8 +177,24 @@
177 177 reg = <0x1a>;
178 178 device_type = "ethernet-phy";
179 179 };
  180 + tbi0: tbi-phy@11 {
  181 + reg = <0x11>;
  182 + device_type = "tbi-phy";
  183 + };
180 184 };
181 185  
  186 + mdio@25520 {
  187 + #address-cells = <1>;
  188 + #size-cells = <0>;
  189 + compatible = "fsl,gianfar-tbi";
  190 + reg = <0x25520 0x20>;
  191 +
  192 + tbi1: tbi-phy@11 {
  193 + reg = <0x11>;
  194 + device_type = "tbi-phy";
  195 + };
  196 + };
  197 +
182 198 enet0: ethernet@24000 {
183 199 cell-index = <0>;
184 200 device_type = "network";
... ... @@ -188,6 +204,7 @@
188 204 local-mac-address = [ 00 00 00 00 00 00 ];
189 205 interrupts = <32 0x8 33 0x8 34 0x8>;
190 206 interrupt-parent = <&ipic>;
  207 + tbi-handle = <&tbi0>;
191 208 phy-handle = <&phy0>;
192 209 linux,network-index = <0>;
193 210 };
... ... @@ -201,6 +218,7 @@
201 218 local-mac-address = [ 00 00 00 00 00 00 ];
202 219 interrupts = <35 0x8 36 0x8 37 0x8>;
203 220 interrupt-parent = <&ipic>;
  221 + tbi-handle = <&tbi1>;
204 222 phy-handle = <&phy1>;
205 223 linux,network-index = <1>;
206 224 };
arch/powerpc/boot/dts/sbc8548.dts
... ... @@ -252,8 +252,24 @@
252 252 reg = <0x1a>;
253 253 device_type = "ethernet-phy";
254 254 };
  255 + tbi0: tbi-phy@11 {
  256 + reg = <0x11>;
  257 + device_type = "tbi-phy";
  258 + };
255 259 };
256 260  
  261 + mdio@25520 {
  262 + #address-cells = <1>;
  263 + #size-cells = <0>;
  264 + compatible = "fsl,gianfar-tbi";
  265 + reg = <0x25520 0x20>;
  266 +
  267 + tbi1: tbi-phy@11 {
  268 + reg = <0x11>;
  269 + device_type = "tbi-phy";
  270 + };
  271 + };
  272 +
257 273 enet0: ethernet@24000 {
258 274 cell-index = <0>;
259 275 device_type = "network";
... ... @@ -263,6 +279,7 @@
263 279 local-mac-address = [ 00 00 00 00 00 00 ];
264 280 interrupts = <0x1d 0x2 0x1e 0x2 0x22 0x2>;
265 281 interrupt-parent = <&mpic>;
  282 + tbi-handle = <&tbi0>;
266 283 phy-handle = <&phy0>;
267 284 };
268 285  
... ... @@ -275,6 +292,7 @@
275 292 local-mac-address = [ 00 00 00 00 00 00 ];
276 293 interrupts = <0x23 0x2 0x24 0x2 0x28 0x2>;
277 294 interrupt-parent = <&mpic>;
  295 + tbi-handle = <&tbi1>;
278 296 phy-handle = <&phy1>;
279 297 };
280 298  
arch/powerpc/boot/dts/sbc8560.dts
... ... @@ -168,8 +168,24 @@
168 168 reg = <0x1c>;
169 169 device_type = "ethernet-phy";
170 170 };
  171 + tbi0: tbi-phy@11 {
  172 + reg = <0x11>;
  173 + device_type = "tbi-phy";
  174 + };
171 175 };
172 176  
  177 + mdio@25520 {
  178 + #address-cells = <1>;
  179 + #size-cells = <0>;
  180 + compatible = "fsl,gianfar-tbi";
  181 + reg = <0x25520 0x20>;
  182 +
  183 + tbi1: tbi-phy@11 {
  184 + reg = <0x11>;
  185 + device_type = "tbi-phy";
  186 + };
  187 + };
  188 +
173 189 enet0: ethernet@24000 {
174 190 cell-index = <0>;
175 191 device_type = "network";
... ... @@ -179,6 +195,7 @@
179 195 local-mac-address = [ 00 00 00 00 00 00 ];
180 196 interrupts = <0x1d 0x2 0x1e 0x2 0x22 0x2>;
181 197 interrupt-parent = <&mpic>;
  198 + tbi-handle = <&tbi0>;
182 199 phy-handle = <&phy0>;
183 200 };
184 201  
... ... @@ -191,6 +208,7 @@
191 208 local-mac-address = [ 00 00 00 00 00 00 ];
192 209 interrupts = <0x23 0x2 0x24 0x2 0x28 0x2>;
193 210 interrupt-parent = <&mpic>;
  211 + tbi-handle = <&tbi1>;
194 212 phy-handle = <&phy1>;
195 213 };
196 214  
arch/powerpc/boot/dts/sbc8641d.dts
... ... @@ -222,8 +222,48 @@
222 222 reg = <2>;
223 223 device_type = "ethernet-phy";
224 224 };
  225 + tbi0: tbi-phy@11 {
  226 + reg = <0x11>;
  227 + device_type = "tbi-phy";
  228 + };
225 229 };
226 230  
  231 + mdio@25520 {
  232 + #address-cells = <1>;
  233 + #size-cells = <0>;
  234 + compatible = "fsl,gianfar-tbi";
  235 + reg = <0x25520 0x20>;
  236 +
  237 + tbi1: tbi-phy@11 {
  238 + reg = <0x11>;
  239 + device_type = "tbi-phy";
  240 + };
  241 + };
  242 +
  243 + mdio@26520 {
  244 + #address-cells = <1>;
  245 + #size-cells = <0>;
  246 + compatible = "fsl,gianfar-tbi";
  247 + reg = <0x26520 0x20>;
  248 +
  249 + tbi2: tbi-phy@11 {
  250 + reg = <0x11>;
  251 + device_type = "tbi-phy";
  252 + };
  253 + };
  254 +
  255 + mdio@27520 {
  256 + #address-cells = <1>;
  257 + #size-cells = <0>;
  258 + compatible = "fsl,gianfar-tbi";
  259 + reg = <0x27520 0x20>;
  260 +
  261 + tbi3: tbi-phy@11 {
  262 + reg = <0x11>;
  263 + device_type = "tbi-phy";
  264 + };
  265 + };
  266 +
227 267 enet0: ethernet@24000 {
228 268 cell-index = <0>;
229 269 device_type = "network";
... ... @@ -233,6 +273,7 @@
233 273 local-mac-address = [ 00 00 00 00 00 00 ];
234 274 interrupts = <29 2 30 2 34 2>;
235 275 interrupt-parent = <&mpic>;
  276 + tbi-handle = <&tbi0>;
236 277 phy-handle = <&phy0>;
237 278 phy-connection-type = "rgmii-id";
238 279 };
... ... @@ -246,6 +287,7 @@
246 287 local-mac-address = [ 00 00 00 00 00 00 ];
247 288 interrupts = <35 2 36 2 40 2>;
248 289 interrupt-parent = <&mpic>;
  290 + tbi-handle = <&tbi1>;
249 291 phy-handle = <&phy1>;
250 292 phy-connection-type = "rgmii-id";
251 293 };
... ... @@ -259,6 +301,7 @@
259 301 local-mac-address = [ 00 00 00 00 00 00 ];
260 302 interrupts = <31 2 32 2 33 2>;
261 303 interrupt-parent = <&mpic>;
  304 + tbi-handle = <&tbi2>;
262 305 phy-handle = <&phy2>;
263 306 phy-connection-type = "rgmii-id";
264 307 };
... ... @@ -272,6 +315,7 @@
272 315 local-mac-address = [ 00 00 00 00 00 00 ];
273 316 interrupts = <37 2 38 2 39 2>;
274 317 interrupt-parent = <&mpic>;
  318 + tbi-handle = <&tbi3>;
275 319 phy-handle = <&phy3>;
276 320 phy-connection-type = "rgmii-id";
277 321 };
arch/powerpc/boot/dts/stx_gp3_8560.dts
... ... @@ -142,8 +142,24 @@
142 142 reg = <4>;
143 143 device_type = "ethernet-phy";
144 144 };
  145 + tbi0: tbi-phy@11 {
  146 + reg = <0x11>;
  147 + device_type = "tbi-phy";
  148 + };
145 149 };
146 150  
  151 + mdio@25520 {
  152 + #address-cells = <1>;
  153 + #size-cells = <0>;
  154 + compatible = "fsl,gianfar-tbi";
  155 + reg = <0x25520 0x20>;
  156 +
  157 + tbi1: tbi-phy@11 {
  158 + reg = <0x11>;
  159 + device_type = "tbi-phy";
  160 + };
  161 + };
  162 +
147 163 enet0: ethernet@24000 {
148 164 cell-index = <0>;
149 165 device_type = "network";
... ... @@ -153,6 +169,7 @@
153 169 local-mac-address = [ 00 00 00 00 00 00 ];
154 170 interrupts = <29 2 30 2 34 2>;
155 171 interrupt-parent = <&mpic>;
  172 + tbi-handle = <&tbi0>;
156 173 phy-handle = <&phy2>;
157 174 };
158 175  
... ... @@ -165,6 +182,7 @@
165 182 local-mac-address = [ 00 00 00 00 00 00 ];
166 183 interrupts = <35 2 36 2 40 2>;
167 184 interrupt-parent = <&mpic>;
  185 + tbi-handle = <&tbi1>;
168 186 phy-handle = <&phy4>;
169 187 };
170 188  
arch/powerpc/boot/dts/tqm8540.dts
... ... @@ -155,6 +155,34 @@
155 155 reg = <3>;
156 156 device_type = "ethernet-phy";
157 157 };
  158 + tbi0: tbi-phy@11 {
  159 + reg = <0x11>;
  160 + device_type = "tbi-phy";
  161 + };
  162 + };
  163 +
  164 + mdio@25520 {
  165 + #address-cells = <1>;
  166 + #size-cells = <0>;
  167 + compatible = "fsl,gianfar-tbi";
  168 + reg = <0x25520 0x20>;
  169 +
  170 + tbi1: tbi-phy@11 {
  171 + reg = <0x11>;
  172 + device_type = "tbi-phy";
  173 + };
  174 + };
  175 +
  176 + mdio@26520 {
  177 + #address-cells = <1>;
  178 + #size-cells = <0>;
  179 + compatible = "fsl,gianfar-tbi";
  180 + reg = <0x26520 0x20>;
  181 +
  182 + tbi2: tbi-phy@11 {
  183 + reg = <0x11>;
  184 + device_type = "tbi-phy";
  185 + };
158 186 };
159 187  
160 188 enet0: ethernet@24000 {
arch/powerpc/boot/dts/tqm8541.dts
... ... @@ -154,8 +154,24 @@
154 154 reg = <3>;
155 155 device_type = "ethernet-phy";
156 156 };
  157 + tbi0: tbi-phy@11 {
  158 + reg = <0x11>;
  159 + device_type = "tbi-phy";
  160 + };
157 161 };
158 162  
  163 + mdio@25520 {
  164 + #address-cells = <1>;
  165 + #size-cells = <0>;
  166 + compatible = "fsl,gianfar-tbi";
  167 + reg = <0x25520 0x20>;
  168 +
  169 + tbi1: tbi-phy@11 {
  170 + reg = <0x11>;
  171 + device_type = "tbi-phy";
  172 + };
  173 + };
  174 +
159 175 enet0: ethernet@24000 {
160 176 cell-index = <0>;
161 177 device_type = "network";
... ... @@ -165,6 +181,7 @@
165 181 local-mac-address = [ 00 00 00 00 00 00 ];
166 182 interrupts = <29 2 30 2 34 2>;
167 183 interrupt-parent = <&mpic>;
  184 + tbi-handle = <&tbi0>;
168 185 phy-handle = <&phy2>;
169 186 };
170 187  
... ... @@ -177,6 +194,7 @@
177 194 local-mac-address = [ 00 00 00 00 00 00 ];
178 195 interrupts = <35 2 36 2 40 2>;
179 196 interrupt-parent = <&mpic>;
  197 + tbi-handle = <&tbi1>;
180 198 phy-handle = <&phy1>;
181 199 };
182 200  
arch/powerpc/boot/dts/tqm8548-bigflash.dts
... ... @@ -179,8 +179,48 @@
179 179 reg = <5>;
180 180 device_type = "ethernet-phy";
181 181 };
  182 + tbi0: tbi-phy@11 {
  183 + reg = <0x11>;
  184 + device_type = "tbi-phy";
  185 + };
182 186 };
183 187  
  188 + mdio@25520 {
  189 + #address-cells = <1>;
  190 + #size-cells = <0>;
  191 + compatible = "fsl,gianfar-tbi";
  192 + reg = <0x25520 0x20>;
  193 +
  194 + tbi1: tbi-phy@11 {
  195 + reg = <0x11>;
  196 + device_type = "tbi-phy";
  197 + };
  198 + };
  199 +
  200 + mdio@26520 {
  201 + #address-cells = <1>;
  202 + #size-cells = <0>;
  203 + compatible = "fsl,gianfar-tbi";
  204 + reg = <0x26520 0x20>;
  205 +
  206 + tbi2: tbi-phy@11 {
  207 + reg = <0x11>;
  208 + device_type = "tbi-phy";
  209 + };
  210 + };
  211 +
  212 + mdio@27520 {
  213 + #address-cells = <1>;
  214 + #size-cells = <0>;
  215 + compatible = "fsl,gianfar-tbi";
  216 + reg = <0x27520 0x20>;
  217 +
  218 + tbi3: tbi-phy@11 {
  219 + reg = <0x11>;
  220 + device_type = "tbi-phy";
  221 + };
  222 + };
  223 +
184 224 enet0: ethernet@24000 {
185 225 cell-index = <0>;
186 226 device_type = "network";
... ... @@ -190,6 +230,7 @@
190 230 local-mac-address = [ 00 00 00 00 00 00 ];
191 231 interrupts = <29 2 30 2 34 2>;
192 232 interrupt-parent = <&mpic>;
  233 + tbi-handle = <&tbi0>;
193 234 phy-handle = <&phy2>;
194 235 };
195 236  
... ... @@ -202,6 +243,7 @@
202 243 local-mac-address = [ 00 00 00 00 00 00 ];
203 244 interrupts = <35 2 36 2 40 2>;
204 245 interrupt-parent = <&mpic>;
  246 + tbi-handle = <&tbi1>;
205 247 phy-handle = <&phy1>;
206 248 };
207 249  
... ... @@ -214,6 +256,7 @@
214 256 local-mac-address = [ 00 00 00 00 00 00 ];
215 257 interrupts = <31 2 32 2 33 2>;
216 258 interrupt-parent = <&mpic>;
  259 + tbi-handle = <&tbi2>;
217 260 phy-handle = <&phy3>;
218 261 };
219 262  
... ... @@ -226,6 +269,7 @@
226 269 local-mac-address = [ 00 00 00 00 00 00 ];
227 270 interrupts = <37 2 38 2 39 2>;
228 271 interrupt-parent = <&mpic>;
  272 + tbi-handle = <&tbi3>;
229 273 phy-handle = <&phy4>;
230 274 };
231 275  
arch/powerpc/boot/dts/tqm8548.dts
... ... @@ -179,8 +179,48 @@
179 179 reg = <5>;
180 180 device_type = "ethernet-phy";
181 181 };
  182 + tbi0: tbi-phy@11 {
  183 + reg = <0x11>;
  184 + device_type = "tbi-phy";
  185 + };
182 186 };
183 187  
  188 + mdio@25520 {
  189 + #address-cells = <1>;
  190 + #size-cells = <0>;
  191 + compatible = "fsl,gianfar-tbi";
  192 + reg = <0x25520 0x20>;
  193 +
  194 + tbi1: tbi-phy@11 {
  195 + reg = <0x11>;
  196 + device_type = "tbi-phy";
  197 + };
  198 + };
  199 +
  200 + mdio@26520 {
  201 + #address-cells = <1>;
  202 + #size-cells = <0>;
  203 + compatible = "fsl,gianfar-tbi";
  204 + reg = <0x26520 0x20>;
  205 +
  206 + tbi2: tbi-phy@11 {
  207 + reg = <0x11>;
  208 + device_type = "tbi-phy";
  209 + };
  210 + };
  211 +
  212 + mdio@27520 {
  213 + #address-cells = <1>;
  214 + #size-cells = <0>;
  215 + compatible = "fsl,gianfar-tbi";
  216 + reg = <0x27520 0x20>;
  217 +
  218 + tbi3: tbi-phy@11 {
  219 + reg = <0x11>;
  220 + device_type = "tbi-phy";
  221 + };
  222 + };
  223 +
184 224 enet0: ethernet@24000 {
185 225 cell-index = <0>;
186 226 device_type = "network";
... ... @@ -190,6 +230,7 @@
190 230 local-mac-address = [ 00 00 00 00 00 00 ];
191 231 interrupts = <29 2 30 2 34 2>;
192 232 interrupt-parent = <&mpic>;
  233 + tbi-handle = <&tbi0>;
193 234 phy-handle = <&phy2>;
194 235 };
195 236  
... ... @@ -202,6 +243,7 @@
202 243 local-mac-address = [ 00 00 00 00 00 00 ];
203 244 interrupts = <35 2 36 2 40 2>;
204 245 interrupt-parent = <&mpic>;
  246 + tbi-handle = <&tbi1>;
205 247 phy-handle = <&phy1>;
206 248 };
207 249  
... ... @@ -214,6 +256,7 @@
214 256 local-mac-address = [ 00 00 00 00 00 00 ];
215 257 interrupts = <31 2 32 2 33 2>;
216 258 interrupt-parent = <&mpic>;
  259 + tbi-handle = <&tbi2>;
217 260 phy-handle = <&phy3>;
218 261 };
219 262  
... ... @@ -226,6 +269,7 @@
226 269 local-mac-address = [ 00 00 00 00 00 00 ];
227 270 interrupts = <37 2 38 2 39 2>;
228 271 interrupt-parent = <&mpic>;
  272 + tbi-handle = <&tbi3>;
229 273 phy-handle = <&phy4>;
230 274 };
231 275  
arch/powerpc/boot/dts/tqm8555.dts
... ... @@ -154,8 +154,24 @@
154 154 reg = <3>;
155 155 device_type = "ethernet-phy";
156 156 };
  157 + tbi0: tbi-phy@11 {
  158 + reg = <0x11>;
  159 + device_type = "tbi-phy";
  160 + };
157 161 };
158 162  
  163 + mdio@25520 {
  164 + #address-cells = <1>;
  165 + #size-cells = <0>;
  166 + compatible = "fsl,gianfar-tbi";
  167 + reg = <0x25520 0x20>;
  168 +
  169 + tbi1: tbi-phy@11 {
  170 + reg = <0x11>;
  171 + device_type = "tbi-phy";
  172 + };
  173 + };
  174 +
159 175 enet0: ethernet@24000 {
160 176 cell-index = <0>;
161 177 device_type = "network";
... ... @@ -165,6 +181,7 @@
165 181 local-mac-address = [ 00 00 00 00 00 00 ];
166 182 interrupts = <29 2 30 2 34 2>;
167 183 interrupt-parent = <&mpic>;
  184 + tbi-handle = <&tbi0>;
168 185 phy-handle = <&phy2>;
169 186 };
170 187  
... ... @@ -177,6 +194,7 @@
177 194 local-mac-address = [ 00 00 00 00 00 00 ];
178 195 interrupts = <35 2 36 2 40 2>;
179 196 interrupt-parent = <&mpic>;
  197 + tbi-handle = <&tbi1>;
180 198 phy-handle = <&phy1>;
181 199 };
182 200  
arch/powerpc/boot/dts/tqm8560.dts
... ... @@ -156,8 +156,24 @@
156 156 reg = <3>;
157 157 device_type = "ethernet-phy";
158 158 };
  159 + tbi0: tbi-phy@11 {
  160 + reg = <0x11>;
  161 + device_type = "tbi-phy";
  162 + };
159 163 };
160 164  
  165 + mdio@25520 {
  166 + #address-cells = <1>;
  167 + #size-cells = <0>;
  168 + compatible = "fsl,gianfar-tbi";
  169 + reg = <0x25520 0x20>;
  170 +
  171 + tbi1: tbi-phy@11 {
  172 + reg = <0x11>;
  173 + device_type = "tbi-phy";
  174 + };
  175 + };
  176 +
161 177 enet0: ethernet@24000 {
162 178 cell-index = <0>;
163 179 device_type = "network";
... ... @@ -167,6 +183,7 @@
167 183 local-mac-address = [ 00 00 00 00 00 00 ];
168 184 interrupts = <29 2 30 2 34 2>;
169 185 interrupt-parent = <&mpic>;
  186 + tbi-handle = <&tbi0>;
170 187 phy-handle = <&phy2>;
171 188 };
172 189  
... ... @@ -179,6 +196,7 @@
179 196 local-mac-address = [ 00 00 00 00 00 00 ];
180 197 interrupts = <35 2 36 2 40 2>;
181 198 interrupt-parent = <&mpic>;
  199 + tbi-handle = <&tbi1>;
182 200 phy-handle = <&phy1>;
183 201 };
184 202  
arch/powerpc/sysdev/fsl_soc.c
... ... @@ -207,236 +207,51 @@
207 207 arch_initcall(of_add_fixed_phys);
208 208 #endif /* CONFIG_FIXED_PHY */
209 209  
210   -static int gfar_mdio_of_init_one(struct device_node *np)
  210 +#ifdef CONFIG_PPC_83xx
  211 +static int __init mpc83xx_wdt_init(void)
211 212 {
212   - int k;
213   - struct device_node *child = NULL;
214   - struct gianfar_mdio_data mdio_data;
215   - struct platform_device *mdio_dev;
216   - struct resource res;
  213 + struct resource r;
  214 + struct device_node *np;
  215 + struct platform_device *dev;
  216 + u32 freq = fsl_get_sys_freq();
217 217 int ret;
218 218  
219   - memset(&res, 0, sizeof(res));
220   - memset(&mdio_data, 0, sizeof(mdio_data));
  219 + np = of_find_compatible_node(NULL, "watchdog", "mpc83xx_wdt");
221 220  
222   - ret = of_address_to_resource(np, 0, &res);
223   - if (ret)
224   - return ret;
  221 + if (!np) {
  222 + ret = -ENODEV;
  223 + goto nodev;
  224 + }
225 225  
226   - /* The gianfar device will try to use the same ID created below to find
227   - * this bus, to coordinate register access (since they share). */
228   - mdio_dev = platform_device_register_simple("fsl-gianfar_mdio",
229   - res.start&0xfffff, &res, 1);
230   - if (IS_ERR(mdio_dev))
231   - return PTR_ERR(mdio_dev);
  226 + memset(&r, 0, sizeof(r));
232 227  
233   - for (k = 0; k < 32; k++)
234   - mdio_data.irq[k] = PHY_POLL;
  228 + ret = of_address_to_resource(np, 0, &r);
  229 + if (ret)
  230 + goto err;
235 231  
236   - while ((child = of_get_next_child(np, child)) != NULL) {
237   - int irq = irq_of_parse_and_map(child, 0);
238   - if (irq != NO_IRQ) {
239   - const u32 *id = of_get_property(child, "reg", NULL);
240   - mdio_data.irq[*id] = irq;
241   - }
  232 + dev = platform_device_register_simple("mpc83xx_wdt", 0, &r, 1);
  233 + if (IS_ERR(dev)) {
  234 + ret = PTR_ERR(dev);
  235 + goto err;
242 236 }
243 237  
244   - ret = platform_device_add_data(mdio_dev, &mdio_data,
245   - sizeof(struct gianfar_mdio_data));
  238 + ret = platform_device_add_data(dev, &freq, sizeof(freq));
246 239 if (ret)
247   - platform_device_unregister(mdio_dev);
  240 + goto unreg;
248 241  
249   - return ret;
250   -}
251   -
252   -static int __init gfar_mdio_of_init(void)
253   -{
254   - struct device_node *np = NULL;
255   -
256   - for_each_compatible_node(np, NULL, "fsl,gianfar-mdio")
257   - gfar_mdio_of_init_one(np);
258   -
259   - /* try the deprecated version */
260   - for_each_compatible_node(np, "mdio", "gianfar");
261   - gfar_mdio_of_init_one(np);
262   -
  242 + of_node_put(np);
263 243 return 0;
264   -}
265 244  
266   -arch_initcall(gfar_mdio_of_init);
267   -
268   -static const char *gfar_tx_intr = "tx";
269   -static const char *gfar_rx_intr = "rx";
270   -static const char *gfar_err_intr = "error";
271   -
272   -static int __init gfar_of_init(void)
273   -{
274   - struct device_node *np;
275   - unsigned int i;
276   - struct platform_device *gfar_dev;
277   - struct resource res;
278   - int ret;
279   -
280   - for (np = NULL, i = 0;
281   - (np = of_find_compatible_node(np, "network", "gianfar")) != NULL;
282   - i++) {
283   - struct resource r[4];
284   - struct device_node *phy, *mdio;
285   - struct gianfar_platform_data gfar_data;
286   - const unsigned int *id;
287   - const char *model;
288   - const char *ctype;
289   - const void *mac_addr;
290   - const phandle *ph;
291   - int n_res = 2;
292   -
293   - if (!of_device_is_available(np))
294   - continue;
295   -
296   - memset(r, 0, sizeof(r));
297   - memset(&gfar_data, 0, sizeof(gfar_data));
298   -
299   - ret = of_address_to_resource(np, 0, &r[0]);
300   - if (ret)
301   - goto err;
302   -
303   - of_irq_to_resource(np, 0, &r[1]);
304   -
305   - model = of_get_property(np, "model", NULL);
306   -
307   - /* If we aren't the FEC we have multiple interrupts */
308   - if (model && strcasecmp(model, "FEC")) {
309   - r[1].name = gfar_tx_intr;
310   -
311   - r[2].name = gfar_rx_intr;
312   - of_irq_to_resource(np, 1, &r[2]);
313   -
314   - r[3].name = gfar_err_intr;
315   - of_irq_to_resource(np, 2, &r[3]);
316   -
317   - n_res += 2;
318   - }
319   -
320   - gfar_dev =
321   - platform_device_register_simple("fsl-gianfar", i, &r[0],
322   - n_res);
323   -
324   - if (IS_ERR(gfar_dev)) {
325   - ret = PTR_ERR(gfar_dev);
326   - goto err;
327   - }
328   -
329   - mac_addr = of_get_mac_address(np);
330   - if (mac_addr)
331   - memcpy(gfar_data.mac_addr, mac_addr, 6);
332   -
333   - if (model && !strcasecmp(model, "TSEC"))
334   - gfar_data.device_flags =
335   - FSL_GIANFAR_DEV_HAS_GIGABIT |
336   - FSL_GIANFAR_DEV_HAS_COALESCE |
337   - FSL_GIANFAR_DEV_HAS_RMON |
338   - FSL_GIANFAR_DEV_HAS_MULTI_INTR;
339   - if (model && !strcasecmp(model, "eTSEC"))
340   - gfar_data.device_flags =
341   - FSL_GIANFAR_DEV_HAS_GIGABIT |
342   - FSL_GIANFAR_DEV_HAS_COALESCE |
343   - FSL_GIANFAR_DEV_HAS_RMON |
344   - FSL_GIANFAR_DEV_HAS_MULTI_INTR |
345   - FSL_GIANFAR_DEV_HAS_CSUM |
346   - FSL_GIANFAR_DEV_HAS_VLAN |
347   - FSL_GIANFAR_DEV_HAS_EXTENDED_HASH;
348   -
349   - ctype = of_get_property(np, "phy-connection-type", NULL);
350   -
351   - /* We only care about rgmii-id. The rest are autodetected */
352   - if (ctype && !strcmp(ctype, "rgmii-id"))
353   - gfar_data.interface = PHY_INTERFACE_MODE_RGMII_ID;
354   - else
355   - gfar_data.interface = PHY_INTERFACE_MODE_MII;
356   -
357   - if (of_get_property(np, "fsl,magic-packet", NULL))
358   - gfar_data.device_flags |= FSL_GIANFAR_DEV_HAS_MAGIC_PACKET;
359   -
360   - ph = of_get_property(np, "phy-handle", NULL);
361   - if (ph == NULL) {
362   - u32 *fixed_link;
363   -
364   - fixed_link = (u32 *)of_get_property(np, "fixed-link",
365   - NULL);
366   - if (!fixed_link) {
367   - ret = -ENODEV;
368   - goto unreg;
369   - }
370   -
371   - snprintf(gfar_data.bus_id, MII_BUS_ID_SIZE, "0");
372   - gfar_data.phy_id = fixed_link[0];
373   - } else {
374   - phy = of_find_node_by_phandle(*ph);
375   -
376   - if (phy == NULL) {
377   - ret = -ENODEV;
378   - goto unreg;
379   - }
380   -
381   - mdio = of_get_parent(phy);
382   -
383   - id = of_get_property(phy, "reg", NULL);
384   - ret = of_address_to_resource(mdio, 0, &res);
385   - if (ret) {
386   - of_node_put(phy);
387   - of_node_put(mdio);
388   - goto unreg;
389   - }
390   -
391   - gfar_data.phy_id = *id;
392   - snprintf(gfar_data.bus_id, MII_BUS_ID_SIZE, "%llx",
393   - (unsigned long long)res.start&0xfffff);
394   -
395   - of_node_put(phy);
396   - of_node_put(mdio);
397   - }
398   -
399   - /* Get MDIO bus controlled by this eTSEC, if any. Normally only
400   - * eTSEC 1 will control an MDIO bus, not necessarily the same
401   - * bus that its PHY is on ('mdio' above), so we can't just use
402   - * that. What we do is look for a gianfar mdio device that has
403   - * overlapping registers with this device. That's really the
404   - * whole point, to find the device sharing our registers to
405   - * coordinate access with it.
406   - */
407   - for_each_compatible_node(mdio, NULL, "fsl,gianfar-mdio") {
408   - if (of_address_to_resource(mdio, 0, &res))
409   - continue;
410   -
411   - if (res.start >= r[0].start && res.end <= r[0].end) {
412   - /* Get the ID the mdio bus platform device was
413   - * registered with. gfar_data.bus_id is
414   - * different because it's for finding a PHY,
415   - * while this is for finding a MII bus.
416   - */
417   - gfar_data.mdio_bus = res.start&0xfffff;
418   - of_node_put(mdio);
419   - break;
420   - }
421   - }
422   -
423   - ret =
424   - platform_device_add_data(gfar_dev, &gfar_data,
425   - sizeof(struct
426   - gianfar_platform_data));
427   - if (ret)
428   - goto unreg;
429   - }
430   -
431   - return 0;
432   -
433 245 unreg:
434   - platform_device_unregister(gfar_dev);
  246 + platform_device_unregister(dev);
435 247 err:
  248 + of_node_put(np);
  249 +nodev:
436 250 return ret;
437 251 }
438 252  
439   -arch_initcall(gfar_of_init);
  253 +arch_initcall(mpc83xx_wdt_init);
  254 +#endif
440 255  
441 256 static enum fsl_usb2_phy_modes determine_usb_phy(const char *phy_type)
442 257 {
drivers/net/gianfar.c
... ... @@ -25,11 +25,8 @@
25 25 *
26 26 * Theory of operation
27 27 *
28   - * The driver is initialized through platform_device. Structures which
29   - * define the configuration needed by the board are defined in a
30   - * board structure in arch/ppc/platforms (though I do not
31   - * discount the possibility that other architectures could one
32   - * day be supported.
  28 + * The driver is initialized through of_device. Configuration information
  29 + * is therefore conveyed through an OF-style device tree.
33 30 *
34 31 * The Gianfar Ethernet Controller uses a ring of buffer
35 32 * descriptors. The beginning is indicated by a register
... ... @@ -78,7 +75,7 @@
78 75 #include <linux/if_vlan.h>
79 76 #include <linux/spinlock.h>
80 77 #include <linux/mm.h>
81   -#include <linux/platform_device.h>
  78 +#include <linux/of_platform.h>
82 79 #include <linux/ip.h>
83 80 #include <linux/tcp.h>
84 81 #include <linux/udp.h>
... ... @@ -92,6 +89,8 @@
92 89 #include <linux/crc32.h>
93 90 #include <linux/mii.h>
94 91 #include <linux/phy.h>
  92 +#include <linux/phy_fixed.h>
  93 +#include <linux/of.h>
95 94  
96 95 #include "gianfar.h"
97 96 #include "gianfar_mii.h"
... ... @@ -119,8 +118,9 @@
119 118 static void adjust_link(struct net_device *dev);
120 119 static void init_registers(struct net_device *dev);
121 120 static int init_phy(struct net_device *dev);
122   -static int gfar_probe(struct platform_device *pdev);
123   -static int gfar_remove(struct platform_device *pdev);
  121 +static int gfar_probe(struct of_device *ofdev,
  122 + const struct of_device_id *match);
  123 +static int gfar_remove(struct of_device *ofdev);
124 124 static void free_skb_resources(struct gfar_private *priv);
125 125 static void gfar_set_multi(struct net_device *dev);
126 126 static void gfar_set_hash_for_addr(struct net_device *dev, u8 *addr);
127 127  
128 128  
129 129  
... ... @@ -152,26 +152,159 @@
152 152 return (priv->vlan_enable || priv->rx_csum_enable);
153 153 }
154 154  
  155 +static int gfar_of_init(struct net_device *dev)
  156 +{
  157 + struct device_node *phy, *mdio;
  158 + const unsigned int *id;
  159 + const char *model;
  160 + const char *ctype;
  161 + const void *mac_addr;
  162 + const phandle *ph;
  163 + u64 addr, size;
  164 + int err = 0;
  165 + struct gfar_private *priv = netdev_priv(dev);
  166 + struct device_node *np = priv->node;
  167 + char bus_name[MII_BUS_ID_SIZE];
  168 +
  169 + if (!np || !of_device_is_available(np))
  170 + return -ENODEV;
  171 +
  172 + /* get a pointer to the register memory */
  173 + addr = of_translate_address(np, of_get_address(np, 0, &size, NULL));
  174 + priv->regs = ioremap(addr, size);
  175 +
  176 + if (priv->regs == NULL)
  177 + return -ENOMEM;
  178 +
  179 + priv->interruptTransmit = irq_of_parse_and_map(np, 0);
  180 +
  181 + model = of_get_property(np, "model", NULL);
  182 +
  183 + /* If we aren't the FEC we have multiple interrupts */
  184 + if (model && strcasecmp(model, "FEC")) {
  185 + priv->interruptReceive = irq_of_parse_and_map(np, 1);
  186 +
  187 + priv->interruptError = irq_of_parse_and_map(np, 2);
  188 +
  189 + if (priv->interruptTransmit < 0 ||
  190 + priv->interruptReceive < 0 ||
  191 + priv->interruptError < 0) {
  192 + err = -EINVAL;
  193 + goto err_out;
  194 + }
  195 + }
  196 +
  197 + mac_addr = of_get_mac_address(np);
  198 + if (mac_addr)
  199 + memcpy(dev->dev_addr, mac_addr, MAC_ADDR_LEN);
  200 +
  201 + if (model && !strcasecmp(model, "TSEC"))
  202 + priv->device_flags =
  203 + FSL_GIANFAR_DEV_HAS_GIGABIT |
  204 + FSL_GIANFAR_DEV_HAS_COALESCE |
  205 + FSL_GIANFAR_DEV_HAS_RMON |
  206 + FSL_GIANFAR_DEV_HAS_MULTI_INTR;
  207 + if (model && !strcasecmp(model, "eTSEC"))
  208 + priv->device_flags =
  209 + FSL_GIANFAR_DEV_HAS_GIGABIT |
  210 + FSL_GIANFAR_DEV_HAS_COALESCE |
  211 + FSL_GIANFAR_DEV_HAS_RMON |
  212 + FSL_GIANFAR_DEV_HAS_MULTI_INTR |
  213 + FSL_GIANFAR_DEV_HAS_CSUM |
  214 + FSL_GIANFAR_DEV_HAS_VLAN |
  215 + FSL_GIANFAR_DEV_HAS_MAGIC_PACKET |
  216 + FSL_GIANFAR_DEV_HAS_EXTENDED_HASH;
  217 +
  218 + ctype = of_get_property(np, "phy-connection-type", NULL);
  219 +
  220 + /* We only care about rgmii-id. The rest are autodetected */
  221 + if (ctype && !strcmp(ctype, "rgmii-id"))
  222 + priv->interface = PHY_INTERFACE_MODE_RGMII_ID;
  223 + else
  224 + priv->interface = PHY_INTERFACE_MODE_MII;
  225 +
  226 + if (of_get_property(np, "fsl,magic-packet", NULL))
  227 + priv->device_flags |= FSL_GIANFAR_DEV_HAS_MAGIC_PACKET;
  228 +
  229 + ph = of_get_property(np, "phy-handle", NULL);
  230 + if (ph == NULL) {
  231 + u32 *fixed_link;
  232 +
  233 + fixed_link = (u32 *)of_get_property(np, "fixed-link", NULL);
  234 + if (!fixed_link) {
  235 + err = -ENODEV;
  236 + goto err_out;
  237 + }
  238 +
  239 + snprintf(priv->phy_bus_id, BUS_ID_SIZE, PHY_ID_FMT, "0",
  240 + fixed_link[0]);
  241 + } else {
  242 + phy = of_find_node_by_phandle(*ph);
  243 +
  244 + if (phy == NULL) {
  245 + err = -ENODEV;
  246 + goto err_out;
  247 + }
  248 +
  249 + mdio = of_get_parent(phy);
  250 +
  251 + id = of_get_property(phy, "reg", NULL);
  252 +
  253 + of_node_put(phy);
  254 + of_node_put(mdio);
  255 +
  256 + gfar_mdio_bus_name(bus_name, mdio);
  257 + snprintf(priv->phy_bus_id, BUS_ID_SIZE, "%s:%02x",
  258 + bus_name, *id);
  259 + }
  260 +
  261 + /* Find the TBI PHY. If it's not there, we don't support SGMII */
  262 + ph = of_get_property(np, "tbi-handle", NULL);
  263 + if (ph) {
  264 + struct device_node *tbi = of_find_node_by_phandle(*ph);
  265 + struct of_device *ofdev;
  266 + struct mii_bus *bus;
  267 +
  268 + if (!tbi)
  269 + return 0;
  270 +
  271 + mdio = of_get_parent(tbi);
  272 + if (!mdio)
  273 + return 0;
  274 +
  275 + ofdev = of_find_device_by_node(mdio);
  276 +
  277 + of_node_put(mdio);
  278 +
  279 + id = of_get_property(tbi, "reg", NULL);
  280 + if (!id)
  281 + return 0;
  282 +
  283 + of_node_put(tbi);
  284 +
  285 + bus = dev_get_drvdata(&ofdev->dev);
  286 +
  287 + priv->tbiphy = bus->phy_map[*id];
  288 + }
  289 +
  290 + return 0;
  291 +
  292 +err_out:
  293 + iounmap(priv->regs);
  294 + return err;
  295 +}
  296 +
155 297 /* Set up the ethernet device structure, private data,
156 298 * and anything else we need before we start */
157   -static int gfar_probe(struct platform_device *pdev)
  299 +static int gfar_probe(struct of_device *ofdev,
  300 + const struct of_device_id *match)
158 301 {
159 302 u32 tempval;
160 303 struct net_device *dev = NULL;
161 304 struct gfar_private *priv = NULL;
162   - struct gianfar_platform_data *einfo;
163   - struct resource *r;
164   - int err = 0, irq;
  305 + int err = 0;
  306 + DECLARE_MAC_BUF(mac);
165 307  
166   - einfo = (struct gianfar_platform_data *) pdev->dev.platform_data;
167   -
168   - if (NULL == einfo) {
169   - printk(KERN_ERR "gfar %d: Missing additional data!\n",
170   - pdev->id);
171   -
172   - return -ENODEV;
173   - }
174   -
175 308 /* Create an ethernet device instance */
176 309 dev = alloc_etherdev(sizeof (*priv));
177 310  
178 311  
179 312  
180 313  
181 314  
... ... @@ -180,48 +313,19 @@
180 313  
181 314 priv = netdev_priv(dev);
182 315 priv->dev = dev;
  316 + priv->node = ofdev->node;
183 317  
184   - /* Set the info in the priv to the current info */
185   - priv->einfo = einfo;
  318 + err = gfar_of_init(dev);
186 319  
187   - /* fill out IRQ fields */
188   - if (einfo->device_flags & FSL_GIANFAR_DEV_HAS_MULTI_INTR) {
189   - irq = platform_get_irq_byname(pdev, "tx");
190   - if (irq < 0)
191   - goto regs_fail;
192   - priv->interruptTransmit = irq;
193   -
194   - irq = platform_get_irq_byname(pdev, "rx");
195   - if (irq < 0)
196   - goto regs_fail;
197   - priv->interruptReceive = irq;
198   -
199   - irq = platform_get_irq_byname(pdev, "error");
200   - if (irq < 0)
201   - goto regs_fail;
202   - priv->interruptError = irq;
203   - } else {
204   - irq = platform_get_irq(pdev, 0);
205   - if (irq < 0)
206   - goto regs_fail;
207   - priv->interruptTransmit = irq;
208   - }
209   -
210   - /* get a pointer to the register memory */
211   - r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
212   - priv->regs = ioremap(r->start, sizeof (struct gfar));
213   -
214   - if (NULL == priv->regs) {
215   - err = -ENOMEM;
  320 + if (err)
216 321 goto regs_fail;
217   - }
218 322  
219 323 spin_lock_init(&priv->txlock);
220 324 spin_lock_init(&priv->rxlock);
221 325 spin_lock_init(&priv->bflock);
222 326 INIT_WORK(&priv->reset_task, gfar_reset_task);
223 327  
224   - platform_set_drvdata(pdev, dev);
  328 + dev_set_drvdata(&ofdev->dev, priv);
225 329  
226 330 /* Stop the DMA engine now, in case it was running before */
227 331 /* (The firmware could have used it, and left it running). */
228 332  
... ... @@ -239,13 +343,10 @@
239 343 /* Initialize ECNTRL */
240 344 gfar_write(&priv->regs->ecntrl, ECNTRL_INIT_SETTINGS);
241 345  
242   - /* Copy the station address into the dev structure, */
243   - memcpy(dev->dev_addr, einfo->mac_addr, MAC_ADDR_LEN);
244   -
245 346 /* Set the dev->base_addr to the gfar reg region */
246 347 dev->base_addr = (unsigned long) (priv->regs);
247 348  
248   - SET_NETDEV_DEV(dev, &pdev->dev);
  349 + SET_NETDEV_DEV(dev, &ofdev->dev);
249 350  
250 351 /* Fill in the dev structure */
251 352 dev->open = gfar_enet_open;
... ... @@ -263,7 +364,7 @@
263 364  
264 365 dev->ethtool_ops = &gfar_ethtool_ops;
265 366  
266   - if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_CSUM) {
  367 + if (priv->device_flags & FSL_GIANFAR_DEV_HAS_CSUM) {
267 368 priv->rx_csum_enable = 1;
268 369 dev->features |= NETIF_F_IP_CSUM;
269 370 } else
... ... @@ -271,7 +372,7 @@
271 372  
272 373 priv->vlgrp = NULL;
273 374  
274   - if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_VLAN) {
  375 + if (priv->device_flags & FSL_GIANFAR_DEV_HAS_VLAN) {
275 376 dev->vlan_rx_register = gfar_vlan_rx_register;
276 377  
277 378 dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
... ... @@ -279,7 +380,7 @@
279 380 priv->vlan_enable = 1;
280 381 }
281 382  
282   - if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_EXTENDED_HASH) {
  383 + if (priv->device_flags & FSL_GIANFAR_DEV_HAS_EXTENDED_HASH) {
283 384 priv->extended_hash = 1;
284 385 priv->hash_width = 9;
285 386  
... ... @@ -314,7 +415,7 @@
314 415 priv->hash_regs[7] = &priv->regs->gaddr7;
315 416 }
316 417  
317   - if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_PADDING)
  418 + if (priv->device_flags & FSL_GIANFAR_DEV_HAS_PADDING)
318 419 priv->padding = DEFAULT_PADDING;
319 420 else
320 421 priv->padding = 0;
321 422  
322 423  
323 424  
324 425  
325 426  
326 427  
... ... @@ -368,29 +469,28 @@
368 469 return err;
369 470 }
370 471  
371   -static int gfar_remove(struct platform_device *pdev)
  472 +static int gfar_remove(struct of_device *ofdev)
372 473 {
373   - struct net_device *dev = platform_get_drvdata(pdev);
374   - struct gfar_private *priv = netdev_priv(dev);
  474 + struct gfar_private *priv = dev_get_drvdata(&ofdev->dev);
375 475  
376   - platform_set_drvdata(pdev, NULL);
  476 + dev_set_drvdata(&ofdev->dev, NULL);
377 477  
378 478 iounmap(priv->regs);
379   - free_netdev(dev);
  479 + free_netdev(priv->dev);
380 480  
381 481 return 0;
382 482 }
383 483  
384 484 #ifdef CONFIG_PM
385   -static int gfar_suspend(struct platform_device *pdev, pm_message_t state)
  485 +static int gfar_suspend(struct of_device *ofdev, pm_message_t state)
386 486 {
387   - struct net_device *dev = platform_get_drvdata(pdev);
388   - struct gfar_private *priv = netdev_priv(dev);
  487 + struct gfar_private *priv = dev_get_drvdata(&ofdev->dev);
  488 + struct net_device *dev = priv->dev;
389 489 unsigned long flags;
390 490 u32 tempval;
391 491  
392 492 int magic_packet = priv->wol_en &&
393   - (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_MAGIC_PACKET);
  493 + (priv->device_flags & FSL_GIANFAR_DEV_HAS_MAGIC_PACKET);
394 494  
395 495 netif_device_detach(dev);
396 496  
397 497  
398 498  
... ... @@ -431,14 +531,14 @@
431 531 return 0;
432 532 }
433 533  
434   -static int gfar_resume(struct platform_device *pdev)
  534 +static int gfar_resume(struct of_device *ofdev)
435 535 {
436   - struct net_device *dev = platform_get_drvdata(pdev);
437   - struct gfar_private *priv = netdev_priv(dev);
  536 + struct gfar_private *priv = dev_get_drvdata(&ofdev->dev);
  537 + struct net_device *dev = priv->dev;
438 538 unsigned long flags;
439 539 u32 tempval;
440 540 int magic_packet = priv->wol_en &&
441   - (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_MAGIC_PACKET);
  541 + (priv->device_flags & FSL_GIANFAR_DEV_HAS_MAGIC_PACKET);
442 542  
443 543 if (!netif_running(dev)) {
444 544 netif_device_attach(dev);
... ... @@ -497,7 +597,7 @@
497 597 if (ecntrl & ECNTRL_REDUCED_MII_MODE)
498 598 return PHY_INTERFACE_MODE_RMII;
499 599 else {
500   - phy_interface_t interface = priv->einfo->interface;
  600 + phy_interface_t interface = priv->interface;
501 601  
502 602 /*
503 603 * This isn't autodetected right now, so it must
... ... @@ -510,7 +610,7 @@
510 610 }
511 611 }
512 612  
513   - if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_GIGABIT)
  613 + if (priv->device_flags & FSL_GIANFAR_DEV_HAS_GIGABIT)
514 614 return PHY_INTERFACE_MODE_GMII;
515 615  
516 616 return PHY_INTERFACE_MODE_MII;
517 617  
518 618  
519 619  
... ... @@ -524,21 +624,18 @@
524 624 {
525 625 struct gfar_private *priv = netdev_priv(dev);
526 626 uint gigabit_support =
527   - priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_GIGABIT ?
  627 + priv->device_flags & FSL_GIANFAR_DEV_HAS_GIGABIT ?
528 628 SUPPORTED_1000baseT_Full : 0;
529 629 struct phy_device *phydev;
530   - char phy_id[BUS_ID_SIZE];
531 630 phy_interface_t interface;
532 631  
533 632 priv->oldlink = 0;
534 633 priv->oldspeed = 0;
535 634 priv->oldduplex = -1;
536 635  
537   - snprintf(phy_id, sizeof(phy_id), PHY_ID_FMT, priv->einfo->bus_id, priv->einfo->phy_id);
538   -
539 636 interface = gfar_get_interface(dev);
540 637  
541   - phydev = phy_connect(dev, phy_id, &adjust_link, 0, interface);
  638 + phydev = phy_connect(dev, priv->phy_bus_id, &adjust_link, 0, interface);
542 639  
543 640 if (interface == PHY_INTERFACE_MODE_SGMII)
544 641 gfar_configure_serdes(dev);
545 642  
546 643  
547 644  
548 645  
549 646  
550 647  
551 648  
... ... @@ -569,35 +666,31 @@
569 666 static void gfar_configure_serdes(struct net_device *dev)
570 667 {
571 668 struct gfar_private *priv = netdev_priv(dev);
572   - struct gfar_mii __iomem *regs =
573   - (void __iomem *)&priv->regs->gfar_mii_regs;
574   - int tbipa = gfar_read(&priv->regs->tbipa);
575   - struct mii_bus *bus = gfar_get_miibus(priv);
576 669  
577   - if (bus)
578   - mutex_lock(&bus->mdio_lock);
  670 + if (!priv->tbiphy) {
  671 + printk(KERN_WARNING "SGMII mode requires that the device "
  672 + "tree specify a tbi-handle\n");
  673 + return;
  674 + }
579 675  
580   - /* If the link is already up, we must already be ok, and don't need to
  676 + /*
  677 + * If the link is already up, we must already be ok, and don't need to
581 678 * configure and reset the TBI<->SerDes link. Maybe U-Boot configured
582 679 * everything for us? Resetting it takes the link down and requires
583 680 * several seconds for it to come back.
584 681 */
585   - if (gfar_local_mdio_read(regs, tbipa, MII_BMSR) & BMSR_LSTATUS)
586   - goto done;
  682 + if (phy_read(priv->tbiphy, MII_BMSR) & BMSR_LSTATUS)
  683 + return;
587 684  
588 685 /* Single clk mode, mii mode off(for serdes communication) */
589   - gfar_local_mdio_write(regs, tbipa, MII_TBICON, TBICON_CLK_SELECT);
  686 + phy_write(priv->tbiphy, MII_TBICON, TBICON_CLK_SELECT);
590 687  
591   - gfar_local_mdio_write(regs, tbipa, MII_ADVERTISE,
  688 + phy_write(priv->tbiphy, MII_ADVERTISE,
592 689 ADVERTISE_1000XFULL | ADVERTISE_1000XPAUSE |
593 690 ADVERTISE_1000XPSE_ASYM);
594 691  
595   - gfar_local_mdio_write(regs, tbipa, MII_BMCR, BMCR_ANENABLE |
  692 + phy_write(priv->tbiphy, MII_BMCR, BMCR_ANENABLE |
596 693 BMCR_ANRESTART | BMCR_FULLDPLX | BMCR_SPEED1000);
597   -
598   - done:
599   - if (bus)
600   - mutex_unlock(&bus->mdio_lock);
601 694 }
602 695  
603 696 static void init_registers(struct net_device *dev)
... ... @@ -630,7 +723,7 @@
630 723 gfar_write(&priv->regs->gaddr7, 0);
631 724  
632 725 /* Zero out the rmon mib registers if it has them */
633   - if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_RMON) {
  726 + if (priv->device_flags & FSL_GIANFAR_DEV_HAS_RMON) {
634 727 memset_io(&(priv->regs->rmon), 0, sizeof (struct rmon_mib));
635 728  
636 729 /* Mask off the CAM interrupts */
... ... @@ -705,7 +798,7 @@
705 798 spin_unlock_irqrestore(&priv->txlock, flags);
706 799  
707 800 /* Free the IRQs */
708   - if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_MULTI_INTR) {
  801 + if (priv->device_flags & FSL_GIANFAR_DEV_HAS_MULTI_INTR) {
709 802 free_irq(priv->interruptError, dev);
710 803 free_irq(priv->interruptTransmit, dev);
711 804 free_irq(priv->interruptReceive, dev);
... ... @@ -919,7 +1012,7 @@
919 1012  
920 1013 /* If the device has multiple interrupts, register for
921 1014 * them. Otherwise, only register for the one */
922   - if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_MULTI_INTR) {
  1015 + if (priv->device_flags & FSL_GIANFAR_DEV_HAS_MULTI_INTR) {
923 1016 /* Install our interrupt handlers for Error,
924 1017 * Transmit, and Receive */
925 1018 if (request_irq(priv->interruptError, gfar_error,
... ... @@ -1751,7 +1844,7 @@
1751 1844 struct gfar_private *priv = netdev_priv(dev);
1752 1845  
1753 1846 /* If the device has multiple interrupts, run tx/rx */
1754   - if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_MULTI_INTR) {
  1847 + if (priv->device_flags & FSL_GIANFAR_DEV_HAS_MULTI_INTR) {
1755 1848 disable_irq(priv->interruptTransmit);
1756 1849 disable_irq(priv->interruptReceive);
1757 1850 disable_irq(priv->interruptError);
... ... @@ -2045,7 +2138,7 @@
2045 2138 gfar_write(&priv->regs->ievent, events & IEVENT_ERR_MASK);
2046 2139  
2047 2140 /* Magic Packet is not an error. */
2048   - if ((priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_MAGIC_PACKET) &&
  2141 + if ((priv->device_flags & FSL_GIANFAR_DEV_HAS_MAGIC_PACKET) &&
2049 2142 (events & IEVENT_MAG))
2050 2143 events &= ~IEVENT_MAG;
2051 2144  
2052 2145  
2053 2146  
... ... @@ -2111,16 +2204,24 @@
2111 2204 /* work with hotplug and coldplug */
2112 2205 MODULE_ALIAS("platform:fsl-gianfar");
2113 2206  
  2207 +static struct of_device_id gfar_match[] =
  2208 +{
  2209 + {
  2210 + .type = "network",
  2211 + .compatible = "gianfar",
  2212 + },
  2213 + {},
  2214 +};
  2215 +
2114 2216 /* Structure for a device driver */
2115   -static struct platform_driver gfar_driver = {
  2217 +static struct of_platform_driver gfar_driver = {
  2218 + .name = "fsl-gianfar",
  2219 + .match_table = gfar_match,
  2220 +
2116 2221 .probe = gfar_probe,
2117 2222 .remove = gfar_remove,
2118 2223 .suspend = gfar_suspend,
2119 2224 .resume = gfar_resume,
2120   - .driver = {
2121   - .name = "fsl-gianfar",
2122   - .owner = THIS_MODULE,
2123   - },
2124 2225 };
2125 2226  
2126 2227 static int __init gfar_init(void)
... ... @@ -2130,7 +2231,7 @@
2130 2231 if (err)
2131 2232 return err;
2132 2233  
2133   - err = platform_driver_register(&gfar_driver);
  2234 + err = of_register_platform_driver(&gfar_driver);
2134 2235  
2135 2236 if (err)
2136 2237 gfar_mdio_exit();
... ... @@ -2140,7 +2241,7 @@
2140 2241  
2141 2242 static void __exit gfar_exit(void)
2142 2243 {
2143   - platform_driver_unregister(&gfar_driver);
  2244 + of_unregister_platform_driver(&gfar_driver);
2144 2245 gfar_mdio_exit();
2145 2246 }
2146 2247  
drivers/net/gianfar.h
... ... @@ -657,6 +657,19 @@
657 657  
658 658 };
659 659  
  660 +/* Flags related to gianfar device features */
  661 +#define FSL_GIANFAR_DEV_HAS_GIGABIT 0x00000001
  662 +#define FSL_GIANFAR_DEV_HAS_COALESCE 0x00000002
  663 +#define FSL_GIANFAR_DEV_HAS_RMON 0x00000004
  664 +#define FSL_GIANFAR_DEV_HAS_MULTI_INTR 0x00000008
  665 +#define FSL_GIANFAR_DEV_HAS_CSUM 0x00000010
  666 +#define FSL_GIANFAR_DEV_HAS_VLAN 0x00000020
  667 +#define FSL_GIANFAR_DEV_HAS_EXTENDED_HASH 0x00000040
  668 +#define FSL_GIANFAR_DEV_HAS_PADDING 0x00000080
  669 +#define FSL_GIANFAR_DEV_HAS_MAGIC_PACKET 0x00000100
  670 +#define FSL_GIANFAR_DEV_HAS_BD_STASHING 0x00000200
  671 +#define FSL_GIANFAR_DEV_HAS_BUF_STASHING 0x00000400
  672 +
660 673 /* Struct stolen almost completely (and shamelessly) from the FCC enet source
661 674 * (Ok, that's not so true anymore, but there is a family resemblence)
662 675 * The GFAR buffer descriptors track the ring buffers. The rx_bd_base
... ... @@ -694,6 +707,7 @@
694 707 /* RX Locked fields */
695 708 spinlock_t rxlock;
696 709  
  710 + struct device_node *node;
697 711 struct net_device *dev;
698 712 struct napi_struct napi;
699 713  
... ... @@ -733,6 +747,9 @@
733 747 /* Bitfield update lock */
734 748 spinlock_t bflock;
735 749  
  750 + phy_interface_t interface;
  751 + char phy_bus_id[BUS_ID_SIZE];
  752 + u32 device_flags;
736 753 unsigned char vlan_enable:1,
737 754 rx_csum_enable:1,
738 755 extended_hash:1,
739 756  
... ... @@ -744,11 +761,9 @@
744 761 unsigned int interruptReceive;
745 762 unsigned int interruptError;
746 763  
747   - /* info structure initialized by platform code */
748   - struct gianfar_platform_data *einfo;
749   -
750 764 /* PHY stuff */
751 765 struct phy_device *phydev;
  766 + struct phy_device *tbiphy;
752 767 struct mii_bus *mii_bus;
753 768 int oldspeed;
754 769 int oldduplex;
drivers/net/gianfar_ethtool.c
... ... @@ -121,7 +121,7 @@
121 121 {
122 122 struct gfar_private *priv = netdev_priv(dev);
123 123  
124   - if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_RMON)
  124 + if (priv->device_flags & FSL_GIANFAR_DEV_HAS_RMON)
125 125 memcpy(buf, stat_gstrings, GFAR_STATS_LEN * ETH_GSTRING_LEN);
126 126 else
127 127 memcpy(buf, stat_gstrings,
... ... @@ -138,7 +138,7 @@
138 138 struct gfar_private *priv = netdev_priv(dev);
139 139 u64 *extra = (u64 *) & priv->extra_stats;
140 140  
141   - if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_RMON) {
  141 + if (priv->device_flags & FSL_GIANFAR_DEV_HAS_RMON) {
142 142 u32 __iomem *rmon = (u32 __iomem *) & priv->regs->rmon;
143 143 struct gfar_stats *stats = (struct gfar_stats *) buf;
144 144  
... ... @@ -158,7 +158,7 @@
158 158  
159 159 switch (sset) {
160 160 case ETH_SS_STATS:
161   - if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_RMON)
  161 + if (priv->device_flags & FSL_GIANFAR_DEV_HAS_RMON)
162 162 return GFAR_STATS_LEN;
163 163 else
164 164 return GFAR_EXTRA_STATS_LEN;
... ... @@ -280,7 +280,7 @@
280 280 {
281 281 struct gfar_private *priv = netdev_priv(dev);
282 282  
283   - if (!(priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_COALESCE))
  283 + if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_COALESCE))
284 284 return -EOPNOTSUPP;
285 285  
286 286 if (NULL == priv->phydev)
... ... @@ -332,7 +332,7 @@
332 332 {
333 333 struct gfar_private *priv = netdev_priv(dev);
334 334  
335   - if (!(priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_COALESCE))
  335 + if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_COALESCE))
336 336 return -EOPNOTSUPP;
337 337  
338 338 /* Set up rx coalescing */
... ... @@ -482,7 +482,7 @@
482 482 unsigned long flags;
483 483 int err = 0;
484 484  
485   - if (!(priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_CSUM))
  485 + if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_CSUM))
486 486 return -EOPNOTSUPP;
487 487  
488 488 if (dev->flags & IFF_UP) {
... ... @@ -515,7 +515,7 @@
515 515 {
516 516 struct gfar_private *priv = netdev_priv(dev);
517 517  
518   - if (!(priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_CSUM))
  518 + if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_CSUM))
519 519 return 0;
520 520  
521 521 return priv->rx_csum_enable;
... ... @@ -526,7 +526,7 @@
526 526 unsigned long flags;
527 527 struct gfar_private *priv = netdev_priv(dev);
528 528  
529   - if (!(priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_CSUM))
  529 + if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_CSUM))
530 530 return -EOPNOTSUPP;
531 531  
532 532 spin_lock_irqsave(&priv->txlock, flags);
... ... @@ -547,7 +547,7 @@
547 547 {
548 548 struct gfar_private *priv = netdev_priv(dev);
549 549  
550   - if (!(priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_CSUM))
  550 + if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_CSUM))
551 551 return 0;
552 552  
553 553 return (dev->features & NETIF_F_IP_CSUM) != 0;
... ... @@ -570,7 +570,7 @@
570 570 {
571 571 struct gfar_private *priv = netdev_priv(dev);
572 572  
573   - if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_MAGIC_PACKET) {
  573 + if (priv->device_flags & FSL_GIANFAR_DEV_HAS_MAGIC_PACKET) {
574 574 wol->supported = WAKE_MAGIC;
575 575 wol->wolopts = priv->wol_en ? WAKE_MAGIC : 0;
576 576 } else {
... ... @@ -583,7 +583,7 @@
583 583 struct gfar_private *priv = netdev_priv(dev);
584 584 unsigned long flags;
585 585  
586   - if (!(priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_MAGIC_PACKET) &&
  586 + if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_MAGIC_PACKET) &&
587 587 wol->wolopts != 0)
588 588 return -EINVAL;
589 589  
drivers/net/gianfar_mii.c
... ... @@ -34,6 +34,8 @@
34 34 #include <linux/crc32.h>
35 35 #include <linux/mii.h>
36 36 #include <linux/phy.h>
  37 +#include <linux/of.h>
  38 +#include <linux/of_platform.h>
37 39  
38 40 #include <asm/io.h>
39 41 #include <asm/irq.h>
40 42  
41 43  
42 44  
43 45  
... ... @@ -150,20 +152,84 @@
150 152 return 0;
151 153 }
152 154  
  155 +/* Allocate an array which provides irq #s for each PHY on the given bus */
  156 +static int *create_irq_map(struct device_node *np)
  157 +{
  158 + int *irqs;
  159 + int i;
  160 + struct device_node *child = NULL;
153 161  
154   -static int gfar_mdio_probe(struct device *dev)
  162 + irqs = kcalloc(PHY_MAX_ADDR, sizeof(int), GFP_KERNEL);
  163 +
  164 + if (!irqs)
  165 + return NULL;
  166 +
  167 + for (i = 0; i < PHY_MAX_ADDR; i++)
  168 + irqs[i] = PHY_POLL;
  169 +
  170 + while ((child = of_get_next_child(np, child)) != NULL) {
  171 + int irq = irq_of_parse_and_map(child, 0);
  172 + const u32 *id;
  173 +
  174 + if (irq == NO_IRQ)
  175 + continue;
  176 +
  177 + id = of_get_property(child, "reg", NULL);
  178 +
  179 + if (!id)
  180 + continue;
  181 +
  182 + if (*id < PHY_MAX_ADDR && *id >= 0)
  183 + irqs[*id] = irq;
  184 + else
  185 + printk(KERN_WARNING "%s: "
  186 + "%d is not a valid PHY address\n",
  187 + np->full_name, *id);
  188 + }
  189 +
  190 + return irqs;
  191 +}
  192 +
  193 +
  194 +void gfar_mdio_bus_name(char *name, struct device_node *np)
155 195 {
156   - struct platform_device *pdev = to_platform_device(dev);
157   - struct gianfar_mdio_data *pdata;
  196 + const u32 *reg;
  197 +
  198 + reg = of_get_property(np, "reg", NULL);
  199 +
  200 + snprintf(name, MII_BUS_ID_SIZE, "%s@%x", np->name, reg ? *reg : 0);
  201 +}
  202 +
  203 +/* Scan the bus in reverse, looking for an empty spot */
  204 +static int gfar_mdio_find_free(struct mii_bus *new_bus)
  205 +{
  206 + int i;
  207 +
  208 + for (i = PHY_MAX_ADDR; i > 0; i--) {
  209 + u32 phy_id;
  210 +
  211 + if (get_phy_id(new_bus, i, &phy_id))
  212 + return -1;
  213 +
  214 + if (phy_id == 0xffffffff)
  215 + break;
  216 + }
  217 +
  218 + return i;
  219 +}
  220 +
  221 +static int gfar_mdio_probe(struct of_device *ofdev,
  222 + const struct of_device_id *match)
  223 +{
158 224 struct gfar_mii __iomem *regs;
159 225 struct gfar __iomem *enet_regs;
160 226 struct mii_bus *new_bus;
161   - struct resource *r;
162   - int i, err = 0;
  227 + int err = 0;
  228 + u64 addr, size;
  229 + struct device_node *np = ofdev->node;
  230 + struct device_node *tbi;
  231 + int tbiaddr = -1;
163 232  
164   - if (NULL == dev)
165   - return -EINVAL;
166   -
167 233 new_bus = mdiobus_alloc();
168 234 if (NULL == new_bus)
169 235 return -ENOMEM;
170 236  
171 237  
172 238  
173 239  
174 240  
175 241  
... ... @@ -172,32 +238,29 @@
172 238 new_bus->read = &gfar_mdio_read,
173 239 new_bus->write = &gfar_mdio_write,
174 240 new_bus->reset = &gfar_mdio_reset,
175   - snprintf(new_bus->id, MII_BUS_ID_SIZE, "%x", pdev->id);
  241 + gfar_mdio_bus_name(new_bus->id, np);
176 242  
177   - pdata = (struct gianfar_mdio_data *)pdev->dev.platform_data;
178   -
179   - if (NULL == pdata) {
180   - printk(KERN_ERR "gfar mdio %d: Missing platform data!\n", pdev->id);
181   - return -ENODEV;
182   - }
183   -
184   - r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
185   -
186 243 /* Set the PHY base address */
187   - regs = ioremap(r->start, sizeof (struct gfar_mii));
  244 + addr = of_translate_address(np, of_get_address(np, 0, &size, NULL));
  245 + regs = ioremap(addr, size);
188 246  
189 247 if (NULL == regs) {
190 248 err = -ENOMEM;
191   - goto reg_map_fail;
  249 + goto err_free_bus;
192 250 }
193 251  
194 252 new_bus->priv = (void __force *)regs;
195 253  
196   - new_bus->irq = pdata->irq;
  254 + new_bus->irq = create_irq_map(np);
197 255  
198   - new_bus->parent = dev;
199   - dev_set_drvdata(dev, new_bus);
  256 + if (new_bus->irq == NULL) {
  257 + err = -ENOMEM;
  258 + goto err_unmap_regs;
  259 + }
200 260  
  261 + new_bus->parent = &ofdev->dev;
  262 + dev_set_drvdata(&ofdev->dev, new_bus);
  263 +
201 264 /*
202 265 * This is mildly evil, but so is our hardware for doing this.
203 266 * Also, we have to cast back to struct gfar_mii because of
204 267  
205 268  
206 269  
207 270  
208 271  
209 272  
210 273  
211 274  
212 275  
213 276  
214 277  
215 278  
216 279  
217 280  
218 281  
219 282  
220 283  
221 284  
222 285  
... ... @@ -206,97 +269,110 @@
206 269 enet_regs = (struct gfar __iomem *)
207 270 ((char *)regs - offsetof(struct gfar, gfar_mii_regs));
208 271  
209   - /* Scan the bus, looking for an empty spot for TBIPA */
210   - gfar_write(&enet_regs->tbipa, 0);
211   - for (i = PHY_MAX_ADDR; i > 0; i--) {
212   - u32 phy_id;
  272 + for_each_child_of_node(np, tbi) {
  273 + if (!strncmp(tbi->type, "tbi-phy", 8))
  274 + break;
  275 + }
213 276  
214   - err = get_phy_id(new_bus, i, &phy_id);
215   - if (err)
216   - goto bus_register_fail;
  277 + if (tbi) {
  278 + const u32 *prop = of_get_property(tbi, "reg", NULL);
217 279  
218   - if (phy_id == 0xffffffff)
219   - break;
  280 + if (prop)
  281 + tbiaddr = *prop;
220 282 }
221 283  
222   - /* The bus is full. We don't support using 31 PHYs, sorry */
223   - if (i == 0) {
  284 + if (tbiaddr == -1) {
  285 + gfar_write(&enet_regs->tbipa, 0);
  286 +
  287 + tbiaddr = gfar_mdio_find_free(new_bus);
  288 + }
  289 +
  290 + /*
  291 + * We define TBIPA at 0 to be illegal, opting to fail for boards that
  292 + * have PHYs at 1-31, rather than change tbipa and rescan.
  293 + */
  294 + if (tbiaddr == 0) {
224 295 err = -EBUSY;
225 296  
226   - goto bus_register_fail;
  297 + goto err_free_irqs;
227 298 }
228 299  
229   - gfar_write(&enet_regs->tbipa, i);
  300 + gfar_write(&enet_regs->tbipa, tbiaddr);
230 301  
  302 + /*
  303 + * The TBIPHY-only buses will find PHYs at every address,
  304 + * so we mask them all but the TBI
  305 + */
  306 + if (!of_device_is_compatible(np, "fsl,gianfar-mdio"))
  307 + new_bus->phy_mask = ~(1 << tbiaddr);
  308 +
231 309 err = mdiobus_register(new_bus);
232 310  
233   - if (0 != err) {
  311 + if (err != 0) {
234 312 printk (KERN_ERR "%s: Cannot register as MDIO bus\n",
235 313 new_bus->name);
236   - goto bus_register_fail;
  314 + goto err_free_irqs;
237 315 }
238 316  
239 317 return 0;
240 318  
241   -bus_register_fail:
  319 +err_free_irqs:
  320 + kfree(new_bus->irq);
  321 +err_unmap_regs:
242 322 iounmap(regs);
243   -reg_map_fail:
  323 +err_free_bus:
244 324 mdiobus_free(new_bus);
245 325  
246 326 return err;
247 327 }
248 328  
249 329  
250   -static int gfar_mdio_remove(struct device *dev)
  330 +static int gfar_mdio_remove(struct of_device *ofdev)
251 331 {
252   - struct mii_bus *bus = dev_get_drvdata(dev);
  332 + struct mii_bus *bus = dev_get_drvdata(&ofdev->dev);
253 333  
254 334 mdiobus_unregister(bus);
255 335  
256   - dev_set_drvdata(dev, NULL);
  336 + dev_set_drvdata(&ofdev->dev, NULL);
257 337  
258 338 iounmap((void __iomem *)bus->priv);
259 339 bus->priv = NULL;
  340 + kfree(bus->irq);
260 341 mdiobus_free(bus);
261 342  
262 343 return 0;
263 344 }
264 345  
265   -static struct device_driver gianfar_mdio_driver = {
  346 +static struct of_device_id gfar_mdio_match[] =
  347 +{
  348 + {
  349 + .compatible = "fsl,gianfar-mdio",
  350 + },
  351 + {
  352 + .compatible = "fsl,gianfar-tbi",
  353 + },
  354 + {
  355 + .type = "mdio",
  356 + .compatible = "gianfar",
  357 + },
  358 + {},
  359 +};
  360 +
  361 +static struct of_platform_driver gianfar_mdio_driver = {
266 362 .name = "fsl-gianfar_mdio",
267   - .bus = &platform_bus_type,
  363 + .match_table = gfar_mdio_match,
  364 +
268 365 .probe = gfar_mdio_probe,
269 366 .remove = gfar_mdio_remove,
270 367 };
271 368  
272   -static int match_mdio_bus(struct device *dev, void *data)
273   -{
274   - const struct gfar_private *priv = data;
275   - const struct platform_device *pdev = to_platform_device(dev);
276   -
277   - return !strcmp(pdev->name, gianfar_mdio_driver.name) &&
278   - pdev->id == priv->einfo->mdio_bus;
279   -}
280   -
281   -/* Given a gfar_priv structure, find the mii_bus controlled by this device (not
282   - * necessarily the same as the bus the gfar's PHY is on), if one exists.
283   - * Normally only the first gianfar controls a mii_bus. */
284   -struct mii_bus *gfar_get_miibus(const struct gfar_private *priv)
285   -{
286   - /*const*/ struct device *d;
287   -
288   - d = bus_find_device(gianfar_mdio_driver.bus, NULL, (void *)priv,
289   - match_mdio_bus);
290   - return d ? dev_get_drvdata(d) : NULL;
291   -}
292   -
293 369 int __init gfar_mdio_init(void)
294 370 {
295   - return driver_register(&gianfar_mdio_driver);
  371 + return of_register_platform_driver(&gianfar_mdio_driver);
296 372 }
297 373  
298 374 void gfar_mdio_exit(void)
299 375 {
300   - driver_unregister(&gianfar_mdio_driver);
  376 + of_unregister_platform_driver(&gianfar_mdio_driver);
301 377 }
drivers/net/gianfar_mii.h
... ... @@ -49,5 +49,7 @@
49 49 struct mii_bus *gfar_get_miibus(const struct gfar_private *priv);
50 50 int __init gfar_mdio_init(void);
51 51 void gfar_mdio_exit(void);
  52 +
  53 +void gfar_mdio_bus_name(char *name, struct device_node *np);
52 54 #endif /* GIANFAR_PHY_H */
include/linux/fsl_devices.h
... ... @@ -47,12 +47,7 @@
47 47 struct gianfar_platform_data {
48 48 /* device specific information */
49 49 u32 device_flags;
50   - /* board specific information */
51   - u32 board_flags;
52   - int mdio_bus; /* Bus controlled by us */
53   - char bus_id[MII_BUS_ID_SIZE]; /* Bus PHY is on */
54   - u32 phy_id;
55   - u8 mac_addr[6];
  50 + char bus_id[BUS_ID_SIZE];
56 51 phy_interface_t interface;
57 52 };
58 53  
... ... @@ -60,17 +55,6 @@
60 55 /* board specific information */
61 56 int irq[32];
62 57 };
63   -
64   -/* Flags related to gianfar device features */
65   -#define FSL_GIANFAR_DEV_HAS_GIGABIT 0x00000001
66   -#define FSL_GIANFAR_DEV_HAS_COALESCE 0x00000002
67   -#define FSL_GIANFAR_DEV_HAS_RMON 0x00000004
68   -#define FSL_GIANFAR_DEV_HAS_MULTI_INTR 0x00000008
69   -#define FSL_GIANFAR_DEV_HAS_CSUM 0x00000010
70   -#define FSL_GIANFAR_DEV_HAS_VLAN 0x00000020
71   -#define FSL_GIANFAR_DEV_HAS_EXTENDED_HASH 0x00000040
72   -#define FSL_GIANFAR_DEV_HAS_PADDING 0x00000080
73   -#define FSL_GIANFAR_DEV_HAS_MAGIC_PACKET 0x00000100
74 58  
75 59 /* Flags in gianfar_platform_data */
76 60 #define FSL_GIANFAR_BRD_HAS_PHY_INTR 0x00000001 /* set or use a timer */