[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>
This commit is contained in:
parent
1791f91bc7
commit
a0916bd64a
2 changed files with 37 additions and 28 deletions
|
@ -91,21 +91,24 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
ethernet@2000 {
|
ethernet-group@2000 {
|
||||||
|
#address-cells = <1>;
|
||||||
|
#size-cells = <0>;
|
||||||
|
compatible = "marvell,mv64360-eth-group";
|
||||||
reg = <0x2000 0x2000>;
|
reg = <0x2000 0x2000>;
|
||||||
eth0 {
|
ethernet@0 {
|
||||||
device_type = "network";
|
device_type = "network";
|
||||||
compatible = "marvell,mv64360-eth";
|
compatible = "marvell,mv64360-eth";
|
||||||
block-index = <0>;
|
reg = <0>;
|
||||||
interrupts = <32>;
|
interrupts = <32>;
|
||||||
interrupt-parent = <&PIC>;
|
interrupt-parent = <&PIC>;
|
||||||
phy = <&PHY0>;
|
phy = <&PHY0>;
|
||||||
local-mac-address = [ 00 00 00 00 00 00 ];
|
local-mac-address = [ 00 00 00 00 00 00 ];
|
||||||
};
|
};
|
||||||
eth1 {
|
ethernet@1 {
|
||||||
device_type = "network";
|
device_type = "network";
|
||||||
compatible = "marvell,mv64360-eth";
|
compatible = "marvell,mv64360-eth";
|
||||||
block-index = <1>;
|
reg = <1>;
|
||||||
interrupts = <33>;
|
interrupts = <33>;
|
||||||
interrupt-parent = <&PIC>;
|
interrupt-parent = <&PIC>;
|
||||||
phy = <&PHY1>;
|
phy = <&PHY1>;
|
||||||
|
|
|
@ -206,30 +206,24 @@ static int __init mv64x60_mpsc_device_setup(struct device_node *np, int id)
|
||||||
/*
|
/*
|
||||||
* Create mv64x60_eth platform devices
|
* Create mv64x60_eth platform devices
|
||||||
*/
|
*/
|
||||||
static int __init eth_register_shared_pdev(struct device_node *np)
|
static struct platform_device * __init mv64x60_eth_register_shared_pdev(
|
||||||
|
struct device_node *np, int id)
|
||||||
{
|
{
|
||||||
struct platform_device *pdev;
|
struct platform_device *pdev;
|
||||||
struct resource r[1];
|
struct resource r[1];
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
np = of_get_parent(np);
|
|
||||||
if (!np)
|
|
||||||
return -ENODEV;
|
|
||||||
|
|
||||||
err = of_address_to_resource(np, 0, &r[0]);
|
err = of_address_to_resource(np, 0, &r[0]);
|
||||||
of_node_put(np);
|
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return ERR_PTR(err);
|
||||||
|
|
||||||
pdev = platform_device_register_simple(MV643XX_ETH_SHARED_NAME, 0,
|
pdev = platform_device_register_simple(MV643XX_ETH_SHARED_NAME, id,
|
||||||
r, 1);
|
r, 1);
|
||||||
if (IS_ERR(pdev))
|
return pdev;
|
||||||
return PTR_ERR(pdev);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __init mv64x60_eth_device_setup(struct device_node *np, int id)
|
static int __init mv64x60_eth_device_setup(struct device_node *np, int id,
|
||||||
|
struct platform_device *shared_pdev)
|
||||||
{
|
{
|
||||||
struct resource r[1];
|
struct resource r[1];
|
||||||
struct mv643xx_eth_platform_data pdata;
|
struct mv643xx_eth_platform_data pdata;
|
||||||
|
@ -240,16 +234,12 @@ static int __init mv64x60_eth_device_setup(struct device_node *np, int id)
|
||||||
const phandle *ph;
|
const phandle *ph;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
/* only register the shared platform device the first time through */
|
|
||||||
if (id == 0 && (err = eth_register_shared_pdev(np)))
|
|
||||||
return err;
|
|
||||||
|
|
||||||
memset(r, 0, sizeof(r));
|
memset(r, 0, sizeof(r));
|
||||||
of_irq_to_resource(np, 0, &r[0]);
|
of_irq_to_resource(np, 0, &r[0]);
|
||||||
|
|
||||||
memset(&pdata, 0, sizeof(pdata));
|
memset(&pdata, 0, sizeof(pdata));
|
||||||
|
|
||||||
prop = of_get_property(np, "block-index", NULL);
|
prop = of_get_property(np, "reg", NULL);
|
||||||
if (!prop)
|
if (!prop)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
pdata.port_number = *prop;
|
pdata.port_number = *prop;
|
||||||
|
@ -302,7 +292,7 @@ static int __init mv64x60_eth_device_setup(struct device_node *np, int id)
|
||||||
|
|
||||||
of_node_put(phy);
|
of_node_put(phy);
|
||||||
|
|
||||||
pdev = platform_device_alloc(MV643XX_ETH_NAME, pdata.port_number);
|
pdev = platform_device_alloc(MV643XX_ETH_NAME, id);
|
||||||
if (!pdev)
|
if (!pdev)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
@ -437,8 +427,9 @@ static int __init mv64x60_wdt_device_setup(struct device_node *np, int id)
|
||||||
|
|
||||||
static int __init mv64x60_device_setup(void)
|
static int __init mv64x60_device_setup(void)
|
||||||
{
|
{
|
||||||
struct device_node *np = NULL;
|
struct device_node *np, *np2;
|
||||||
int id;
|
struct platform_device *pdev;
|
||||||
|
int id, id2;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
id = 0;
|
id = 0;
|
||||||
|
@ -447,9 +438,24 @@ static int __init mv64x60_device_setup(void)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
id = 0;
|
id = 0;
|
||||||
for_each_compatible_node(np, "network", "marvell,mv64360-eth")
|
id2 = 0;
|
||||||
if ((err = mv64x60_eth_device_setup(np, id++)))
|
for_each_compatible_node(np, NULL, "marvell,mv64360-eth-group") {
|
||||||
|
pdev = mv64x60_eth_register_shared_pdev(np, id++);
|
||||||
|
if (IS_ERR(pdev)) {
|
||||||
|
err = PTR_ERR(pdev);
|
||||||
goto error;
|
goto error;
|
||||||
|
}
|
||||||
|
for_each_child_of_node(np, np2) {
|
||||||
|
if (!of_device_is_compatible(np2,
|
||||||
|
"marvell,mv64360-eth"))
|
||||||
|
continue;
|
||||||
|
err = mv64x60_eth_device_setup(np2, id2++, pdev);
|
||||||
|
if (err) {
|
||||||
|
of_node_put(np2);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
id = 0;
|
id = 0;
|
||||||
for_each_compatible_node(np, "i2c", "marvell,mv64360-i2c")
|
for_each_compatible_node(np, "i2c", "marvell,mv64360-i2c")
|
||||||
|
|
Loading…
Reference in a new issue