Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[POWERPC] mv643xx_eth: Prepare to support multiple silicon blocks

The mv643xx_eth driver is being modified to support multiple instances
of the ethernet silicon block on the same platform. Each block contains
a single register bank containing the registers for up to three ports
interleaved within that bank. This patch updates the PowerPC OF to
platform_device glue code to support multiple silicon blocks, each
with up to three ethernet ports. The main difference is that we now
allow multiple mv64x60_shared platform_devices to be registered and
we provide each port platform_device with a pointer to its associated
shared platform_device. The pointer will not be used until the
mv643xx_eth driver changes are committed.

Signed-off-by: Dale Farnsworth <dale@farnsworth.org>
Acked-by: Mark Greer <mgreer@mvista.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>

authored by

Dale Farnsworth and committed by
Paul Mackerras
a0916bd6 1791f91b

+37 -28
+8 -5
arch/powerpc/boot/dts/prpmc2800.dts
··· 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 98 reg = <0x2000 0x2000>; 96 - eth0 { 99 + ethernet@0 { 97 100 device_type = "network"; 98 101 compatible = "marvell,mv64360-eth"; 99 - block-index = <0>; 102 + reg = <0>; 100 103 interrupts = <32>; 101 104 interrupt-parent = <&PIC>; 102 105 phy = <&PHY0>; 103 106 local-mac-address = [ 00 00 00 00 00 00 ]; 104 107 }; 105 - eth1 { 108 + ethernet@1 { 106 109 device_type = "network"; 107 110 compatible = "marvell,mv64360-eth"; 108 - block-index = <1>; 111 + reg = <1>; 109 112 interrupts = <33>; 110 113 interrupt-parent = <&PIC>; 111 114 phy = <&PHY1>;
+29 -23
arch/powerpc/sysdev/mv64x60_dev.c
··· 206 206 /* 207 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 212 struct platform_device *pdev; 212 213 struct resource r[1]; 213 214 int err; 214 215 215 - np = of_get_parent(np); 216 - if (!np) 217 - return -ENODEV; 218 - 219 216 err = of_address_to_resource(np, 0, &r[0]); 220 - of_node_put(np); 221 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 221 r, 1); 226 - if (IS_ERR(pdev)) 227 - return PTR_ERR(pdev); 228 - 229 - return 0; 222 + return pdev; 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 228 struct resource r[1]; 235 229 struct mv643xx_eth_platform_data pdata; ··· 234 240 const phandle *ph; 235 241 int err; 236 242 237 - /* only register the shared platform device the first time through */ 238 - if (id == 0 && (err = eth_register_shared_pdev(np))) 239 - return err; 240 - 241 243 memset(r, 0, sizeof(r)); 242 244 of_irq_to_resource(np, 0, &r[0]); 243 245 244 246 memset(&pdata, 0, sizeof(pdata)); 245 247 246 - prop = of_get_property(np, "block-index", NULL); 248 + prop = of_get_property(np, "reg", NULL); 247 249 if (!prop) 248 250 return -ENODEV; 249 251 pdata.port_number = *prop; ··· 292 302 293 303 of_node_put(phy); 294 304 295 - pdev = platform_device_alloc(MV643XX_ETH_NAME, pdata.port_number); 305 + pdev = platform_device_alloc(MV643XX_ETH_NAME, id); 296 306 if (!pdev) 297 307 return -ENOMEM; 298 308 ··· 427 437 428 438 static int __init mv64x60_device_setup(void) 429 439 { 430 - struct device_node *np = NULL; 431 - int id; 440 + struct device_node *np, *np2; 441 + struct platform_device *pdev; 442 + int id, id2; 432 443 int err; 433 444 434 445 id = 0; ··· 438 447 goto error; 439 448 440 449 id = 0; 441 - for_each_compatible_node(np, "network", "marvell,mv64360-eth") 442 - if ((err = mv64x60_eth_device_setup(np, id++))) 450 + id2 = 0; 451 + for_each_compatible_node(np, NULL, "marvell,mv64360-eth-group") { 452 + pdev = mv64x60_eth_register_shared_pdev(np, id++); 453 + if (IS_ERR(pdev)) { 454 + err = PTR_ERR(pdev); 443 455 goto error; 456 + } 457 + for_each_child_of_node(np, np2) { 458 + if (!of_device_is_compatible(np2, 459 + "marvell,mv64360-eth")) 460 + continue; 461 + err = mv64x60_eth_device_setup(np2, id2++, pdev); 462 + if (err) { 463 + of_node_put(np2); 464 + goto error; 465 + } 466 + } 467 + } 444 468 445 469 id = 0; 446 470 for_each_compatible_node(np, "i2c", "marvell,mv64360-i2c")