aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/sysdev/mv64x60_dev.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc/sysdev/mv64x60_dev.c')
-rw-r--r--arch/powerpc/sysdev/mv64x60_dev.c52
1 files changed, 29 insertions, 23 deletions
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 */
209static int __init eth_register_shared_pdev(struct device_node *np) 209static 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
232static int __init mv64x60_eth_device_setup(struct device_node *np, int id) 225static 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
438static int __init mv64x60_device_setup(void) 428static 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")