linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Dale Farnsworth <dale@farnsworth.org>
To: paulus@samba.org
Cc: linuxppc-dev@ozlabs.org
Subject: [PATCH 7/9 v2] powerpc: mv643xx_eth: prepare to support multiple silicon blocks
Date: Mon, 7 Apr 2008 11:53:23 -0700	[thread overview]
Message-ID: <20080407185323.GH7438@farnsworth.org> (raw)
In-Reply-To: <20080407183228.GA7438@farnsworth.org>

From: Dale Farnsworth <dale@farnsworth.org>

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>

---
 arch/powerpc/boot/dts/prpmc2800.dts |   13 ++++--
 arch/powerpc/sysdev/mv64x60_dev.c   |   52 ++++++++++++++------------
 2 files changed, 37 insertions(+), 28 deletions(-)

Index: linux-2.6/arch/powerpc/boot/dts/prpmc2800.dts
===================================================================
--- linux-2.6.orig/arch/powerpc/boot/dts/prpmc2800.dts
+++ linux-2.6/arch/powerpc/boot/dts/prpmc2800.dts
@@ -91,21 +91,24 @@
 			};
 		};
 
-		ethernet@2000 {
+		ethernet-group@2000 {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			compatible = "mrvl,mv64360-eth-group";
 			reg = <0x2000 0x2000>;
-			eth0 {
+			ethernet@0 {
 				device_type = "network";
 				compatible = "mrvl,mv64360-eth";
-				block-index = <0>;
+				reg = <0>;
 				interrupts = <32>;
 				interrupt-parent = <&PIC>;
 				phy = <&PHY0>;
 				local-mac-address = [ 00 00 00 00 00 00 ];
 			};
-			eth1 {
+			ethernet@1 {
 				device_type = "network";
 				compatible = "mrvl,mv64360-eth";
-				block-index = <1>;
+				reg = <1>;
 				interrupts = <33>;
 				interrupt-parent = <&PIC>;
 				phy = <&PHY1>;
Index: linux-2.6/arch/powerpc/sysdev/mv64x60_dev.c
===================================================================
--- linux-2.6.orig/arch/powerpc/sysdev/mv64x60_dev.c
+++ linux-2.6/arch/powerpc/sysdev/mv64x60_dev.c
@@ -206,30 +206,24 @@ error:
 /*
  * 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 resource r[1];
 	int err;
 
-	np = of_get_parent(np);
-	if (!np)
-		return -ENODEV;
-
 	err = of_address_to_resource(np, 0, &r[0]);
-	of_node_put(np);
 	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);
-	if (IS_ERR(pdev))
-		return PTR_ERR(pdev);
-
-	return 0;
+	return pdev;
 }
 
-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 mv643xx_eth_platform_data pdata;
@@ -240,16 +234,12 @@ static int __init mv64x60_eth_device_set
 	const phandle *ph;
 	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));
 	of_irq_to_resource(np, 0, &r[0]);
 
 	memset(&pdata, 0, sizeof(pdata));
 
-	prop = of_get_property(np, "block-index", NULL);
+	prop = of_get_property(np, "reg", NULL);
 	if (!prop)
 		return -ENODEV;
 	pdata.port_number = *prop;
@@ -302,7 +292,7 @@ static int __init mv64x60_eth_device_set
 
 	of_node_put(phy);
 
-	pdev = platform_device_alloc(MV643XX_ETH_NAME, pdata.port_number);
+	pdev = platform_device_alloc(MV643XX_ETH_NAME, id);
 	if (!pdev)
 		return -ENOMEM;
 
@@ -437,8 +427,9 @@ error:
 
 static int __init mv64x60_device_setup(void)
 {
-	struct device_node *np = NULL;
-	int id;
+	struct device_node *np, *np2;
+	struct platform_device *pdev;
+	int id, id2;
 	int err;
 
 	id = 0;
@@ -447,9 +438,24 @@ static int __init mv64x60_device_setup(v
 			goto error;
 
 	id = 0;
-	for_each_compatible_node(np, "network", "mrvl,mv64360-eth")
-		if ((err = mv64x60_eth_device_setup(np, id++)))
+	id2 = 0;
+	for_each_compatible_node(np, NULL, "mrvl,mv64360-eth-group") {
+		pdev = mv64x60_eth_register_shared_pdev(np, id++);
+		if (IS_ERR(pdev)) {
+			err = PTR_ERR(pdev);
 			goto error;
+		}
+		for_each_child_of_node(np, np2) {
+			if (!of_device_is_compatible(np2,
+					"mrvl,mv64360-eth"))
+				continue;
+			err = mv64x60_eth_device_setup(np2, id2++, pdev);
+			if (err) {
+				of_node_put(np2);
+				goto error;
+			}
+		}
+	}
 
 	id = 0;
 	for_each_compatible_node(np, "i2c", "mrvl,mv64360-i2c")

  parent reply	other threads:[~2008-04-07 18:53 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-07 18:32 [PATCH 0/9 v2] powerpc: mv64x60 and prpmc2800 DTS cleanups Dale Farnsworth
2008-04-07 18:38 ` [PATCH 1/9 v2] powerpc: change FDT compatible prefix to mrvl Dale Farnsworth
2008-04-07 20:49   ` Segher Boessenkool
2008-04-07 21:53     ` Dale Farnsworth
     [not found]     ` <20080407210314.GA21993@farnsworth.org>
2008-04-08  6:34       ` Segher Boessenkool
2008-04-07 18:46 ` [PATCH 2/9 v2] powerpc: prpmc2800: convert DTS to v1 and add labels Dale Farnsworth
2008-04-07 18:47 ` [PATCH 3/9 v2] powerpc: fix frequencies in prpmc2800.dts Dale Farnsworth
2008-04-07 18:49 ` [PATCH 4/9 v2] powerpc: mv64x60: Fix FDT compatible names: mv64x60 => mv64360 Dale Farnsworth
2008-04-07 18:50 ` [PATCH 5/9 v2] powerpc: mv64x60: remove device tree absolute path references Dale Farnsworth
2008-04-07 18:51 ` [PATCH 6/9 v2] powerpc: prpmc2800: clean up dts properties Dale Farnsworth
2008-04-07 18:53 ` Dale Farnsworth [this message]
2008-04-07 18:54 ` [PATCH 8/9 v2] powerpc: Document the mv64x60 device tree bindings Dale Farnsworth
2008-04-07 18:55 ` [PATCH 9/9 v2] powerpc: prpmc2800 needs a dtbImage Dale Farnsworth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080407185323.GH7438@farnsworth.org \
    --to=dale@farnsworth.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).