diff options
-rw-r--r-- | arch/powerpc/boot/dts/prpmc2800.dts | 13 | ||||
-rw-r--r-- | arch/powerpc/sysdev/mv64x60_dev.c | 52 |
2 files changed, 37 insertions, 28 deletions
diff --git a/arch/powerpc/boot/dts/prpmc2800.dts b/arch/powerpc/boot/dts/prpmc2800.dts index 88a1a895985f..1ee6ff43dd57 100644 --- a/arch/powerpc/boot/dts/prpmc2800.dts +++ b/arch/powerpc/boot/dts/prpmc2800.dts | |||
@@ -91,21 +91,24 @@ | |||
91 | }; | 91 | }; |
92 | }; | 92 | }; |
93 | 93 | ||
94 | ethernet@2000 { | 94 | ethernet-group@2000 { |
95 | #address-cells = <1>; | ||
96 | #size-cells = <0>; | ||
97 | compatible = "marvell,mv64360-eth-group"; | ||
95 | reg = <0x2000 0x2000>; | 98 | reg = <0x2000 0x2000>; |
96 | eth0 { | 99 | ethernet@0 { |
97 | device_type = "network"; | 100 | device_type = "network"; |
98 | compatible = "marvell,mv64360-eth"; | 101 | compatible = "marvell,mv64360-eth"; |
99 | block-index = <0>; | 102 | reg = <0>; |
100 | interrupts = <32>; | 103 | interrupts = <32>; |
101 | interrupt-parent = <&PIC>; | 104 | interrupt-parent = <&PIC>; |
102 | phy = <&PHY0>; | 105 | phy = <&PHY0>; |
103 | local-mac-address = [ 00 00 00 00 00 00 ]; | 106 | local-mac-address = [ 00 00 00 00 00 00 ]; |
104 | }; | 107 | }; |
105 | eth1 { | 108 | ethernet@1 { |
106 | device_type = "network"; | 109 | device_type = "network"; |
107 | compatible = "marvell,mv64360-eth"; | 110 | compatible = "marvell,mv64360-eth"; |
108 | block-index = <1>; | 111 | reg = <1>; |
109 | interrupts = <33>; | 112 | interrupts = <33>; |
110 | interrupt-parent = <&PIC>; | 113 | interrupt-parent = <&PIC>; |
111 | phy = <&PHY1>; | 114 | phy = <&PHY1>; |
diff --git a/arch/powerpc/sysdev/mv64x60_dev.c b/arch/powerpc/sysdev/mv64x60_dev.c index 90f2c14d5b60..047b31027fa6 100644 --- a/arch/powerpc/sysdev/mv64x60_dev.c +++ b/arch/powerpc/sysdev/mv64x60_dev.c | |||
@@ -206,30 +206,24 @@ error: | |||
206 | /* | 206 | /* |
207 | * Create mv64x60_eth platform devices | 207 | * Create mv64x60_eth platform devices |
208 | */ | 208 | */ |
209 | static int __init eth_register_shared_pdev(struct device_node *np) | 209 | static struct platform_device * __init mv64x60_eth_register_shared_pdev( |
210 | struct device_node *np, int id) | ||
210 | { | 211 | { |
211 | struct platform_device *pdev; | 212 | struct platform_device *pdev; |
212 | struct resource r[1]; | 213 | struct resource r[1]; |
213 | int err; | 214 | int err; |
214 | 215 | ||
215 | np = of_get_parent(np); | ||
216 | if (!np) | ||
217 | return -ENODEV; | ||
218 | |||
219 | err = of_address_to_resource(np, 0, &r[0]); | 216 | err = of_address_to_resource(np, 0, &r[0]); |
220 | of_node_put(np); | ||
221 | if (err) | 217 | if (err) |
222 | return err; | 218 | return ERR_PTR(err); |
223 | 219 | ||
224 | pdev = platform_device_register_simple(MV643XX_ETH_SHARED_NAME, 0, | 220 | pdev = platform_device_register_simple(MV643XX_ETH_SHARED_NAME, id, |
225 | r, 1); | 221 | r, 1); |
226 | if (IS_ERR(pdev)) | 222 | return pdev; |
227 | return PTR_ERR(pdev); | ||
228 | |||
229 | return 0; | ||
230 | } | 223 | } |
231 | 224 | ||
232 | static int __init mv64x60_eth_device_setup(struct device_node *np, int id) | 225 | static int __init mv64x60_eth_device_setup(struct device_node *np, int id, |
226 | struct platform_device *shared_pdev) | ||
233 | { | 227 | { |
234 | struct resource r[1]; | 228 | struct resource r[1]; |
235 | struct mv643xx_eth_platform_data pdata; | 229 | struct mv643xx_eth_platform_data pdata; |
@@ -240,16 +234,12 @@ static int __init mv64x60_eth_device_setup(struct device_node *np, int id) | |||
240 | const phandle *ph; | 234 | const phandle *ph; |
241 | int err; | 235 | int err; |
242 | 236 | ||
243 | /* only register the shared platform device the first time through */ | ||
244 | if (id == 0 && (err = eth_register_shared_pdev(np))) | ||
245 | return err; | ||
246 | |||
247 | memset(r, 0, sizeof(r)); | 237 | memset(r, 0, sizeof(r)); |
248 | of_irq_to_resource(np, 0, &r[0]); | 238 | of_irq_to_resource(np, 0, &r[0]); |
249 | 239 | ||
250 | memset(&pdata, 0, sizeof(pdata)); | 240 | memset(&pdata, 0, sizeof(pdata)); |
251 | 241 | ||
252 | prop = of_get_property(np, "block-index", NULL); | 242 | prop = of_get_property(np, "reg", NULL); |
253 | if (!prop) | 243 | if (!prop) |
254 | return -ENODEV; | 244 | return -ENODEV; |
255 | pdata.port_number = *prop; | 245 | pdata.port_number = *prop; |
@@ -302,7 +292,7 @@ static int __init mv64x60_eth_device_setup(struct device_node *np, int id) | |||
302 | 292 | ||
303 | of_node_put(phy); | 293 | of_node_put(phy); |
304 | 294 | ||
305 | pdev = platform_device_alloc(MV643XX_ETH_NAME, pdata.port_number); | 295 | pdev = platform_device_alloc(MV643XX_ETH_NAME, id); |
306 | if (!pdev) | 296 | if (!pdev) |
307 | return -ENOMEM; | 297 | return -ENOMEM; |
308 | 298 | ||
@@ -437,8 +427,9 @@ error: | |||
437 | 427 | ||
438 | static int __init mv64x60_device_setup(void) | 428 | static int __init mv64x60_device_setup(void) |
439 | { | 429 | { |
440 | struct device_node *np = NULL; | 430 | struct device_node *np, *np2; |
441 | int id; | 431 | struct platform_device *pdev; |
432 | int id, id2; | ||
442 | int err; | 433 | int err; |
443 | 434 | ||
444 | id = 0; | 435 | id = 0; |
@@ -447,9 +438,24 @@ static int __init mv64x60_device_setup(void) | |||
447 | goto error; | 438 | goto error; |
448 | 439 | ||
449 | id = 0; | 440 | id = 0; |
450 | for_each_compatible_node(np, "network", "marvell,mv64360-eth") | 441 | id2 = 0; |
451 | if ((err = mv64x60_eth_device_setup(np, id++))) | 442 | for_each_compatible_node(np, NULL, "marvell,mv64360-eth-group") { |
443 | pdev = mv64x60_eth_register_shared_pdev(np, id++); | ||
444 | if (IS_ERR(pdev)) { | ||
445 | err = PTR_ERR(pdev); | ||
452 | goto error; | 446 | goto error; |
447 | } | ||
448 | for_each_child_of_node(np, np2) { | ||
449 | if (!of_device_is_compatible(np2, | ||
450 | "marvell,mv64360-eth")) | ||
451 | continue; | ||
452 | err = mv64x60_eth_device_setup(np2, id2++, pdev); | ||
453 | if (err) { | ||
454 | of_node_put(np2); | ||
455 | goto error; | ||
456 | } | ||
457 | } | ||
458 | } | ||
453 | 459 | ||
454 | id = 0; | 460 | id = 0; |
455 | for_each_compatible_node(np, "i2c", "marvell,mv64360-i2c") | 461 | for_each_compatible_node(np, "i2c", "marvell,mv64360-i2c") |