netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonas Bonn <jonas@southpole.se>
To: netdev@vger.kernel.org
Cc: Jonas Bonn <jonas@southpole.se>
Subject: [PATCH 1/8] ethoc: Add device tree configuration
Date: Thu, 25 Nov 2010 13:30:25 +0100	[thread overview]
Message-ID: <1290688232-25142-2-git-send-email-jonas@southpole.se> (raw)
In-Reply-To: <1290688232-25142-1-git-send-email-jonas@southpole.se>

This patch adds the ability to describe ethernet devices via a flattened
device tree.  As device tree remains an optional feature, these bits all
need to be guarded by CONFIG_OF ifdefs.

MAC address is settable via the device tree parameter "local-mac-address";
however, the selection of the phy id is limited to probing, for now.

Signed-off-by: Jonas Bonn <jonas@southpole.se>
---
 drivers/net/ethoc.c |   32 ++++++++++++++++++++++++++++++--
 1 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethoc.c b/drivers/net/ethoc.c
index c5a2fe0..9ea3c54 100644
--- a/drivers/net/ethoc.c
+++ b/drivers/net/ethoc.c
@@ -19,6 +19,7 @@
 #include <linux/platform_device.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
+#include <linux/of.h>
 #include <net/ethoc.h>
 
 static int buffer_size = 0x8000; /* 32 KBytes */
@@ -982,10 +983,23 @@ static int __devinit ethoc_probe(struct platform_device *pdev)
 
 	/* Allow the platform setup code to pass in a MAC address. */
 	if (pdev->dev.platform_data) {
-		struct ethoc_platform_data *pdata =
-			(struct ethoc_platform_data *)pdev->dev.platform_data;
+		struct ethoc_platform_data *pdata = pdev->dev.platform_data;
 		memcpy(netdev->dev_addr, pdata->hwaddr, IFHWADDRLEN);
 		priv->phy_id = pdata->phy_id;
+	} else {
+		priv->phy_id = -1;
+
+#ifdef CONFIG_OF
+		{
+		const uint8_t* mac;
+
+		mac = of_get_property(pdev->dev.of_node,
+				      "local-mac-address",
+				      NULL);
+		if (mac)
+			memcpy(netdev->dev_addr, mac, IFHWADDRLEN);
+		}
+#endif
 	}
 
 	/* Check that the given MAC address is valid. If it isn't, read the
@@ -1113,6 +1127,16 @@ static int ethoc_resume(struct platform_device *pdev)
 # define ethoc_resume  NULL
 #endif
 
+#ifdef CONFIG_OF
+static struct of_device_id ethoc_match[] = {
+	{
+		.compatible = "opencores,ethoc",
+	},
+	{},
+};
+MODULE_DEVICE_TABLE(of, ethoc_match);
+#endif
+
 static struct platform_driver ethoc_driver = {
 	.probe   = ethoc_probe,
 	.remove  = __devexit_p(ethoc_remove),
@@ -1120,6 +1144,10 @@ static struct platform_driver ethoc_driver = {
 	.resume  = ethoc_resume,
 	.driver  = {
 		.name = "ethoc",
+		.owner = THIS_MODULE,
+#ifdef CONFIG_OF
+		.of_match_table = ethoc_match,
+#endif
 	},
 };
 
-- 
1.7.1


  reply	other threads:[~2010-11-25 12:30 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-25 12:30 ethoc driver changes (version 2) Jonas Bonn
2010-11-25 12:30 ` Jonas Bonn [this message]
2010-11-25 12:30 ` [PATCH 2/8] ethoc: remove unused spinlock Jonas Bonn
2010-11-25 12:30 ` [PATCH 3/8] ethoc: enable interrupts after napi_complete Jonas Bonn
2010-11-25 12:30 ` [PATCH 4/8] ethoc: Double check pending RX packet Jonas Bonn
2010-11-25 12:30 ` [PATCH 5/8] ethoc: rework interrupt handling Jonas Bonn
2010-11-25 12:30 ` [PATCH 6/8] ethoc: rework mdio read/write Jonas Bonn
2010-11-25 12:30 ` [PATCH 7/8] ethoc: fix function return type Jonas Bonn
2010-11-25 12:30 ` [PATCH 8/8] ethoc: remove division from loops Jonas Bonn
2010-11-28 19:17 ` ethoc driver changes (version 2) David Miller
  -- strict thread matches above, loose matches on Subject: below --
2010-11-24 13:40 ethoc driver updates Jonas Bonn
2010-11-24 13:40 ` [PATCH 1/8] ethoc: Add device tree configuration Jonas Bonn
2010-11-24 19:35   ` David Miller

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=1290688232-25142-2-git-send-email-jonas@southpole.se \
    --to=jonas@southpole.se \
    --cc=netdev@vger.kernel.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).