mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 2/2] net: fec: probe phy_mode from devicetree
Date: Tue, 26 Mar 2013 10:15:16 +0100	[thread overview]
Message-ID: <1364289316-1998-2-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1364289316-1998-1-git-send-email-s.hauer@pengutronix.de>

This allows to parse the phy mode from the devicetree.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/net/fec_imx.c | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
index 37d88cd..1a85d15 100644
--- a/drivers/net/fec_imx.c
+++ b/drivers/net/fec_imx.c
@@ -26,6 +26,7 @@
 #include <linux/phy.h>
 #include <linux/clk.h>
 #include <linux/err.h>
+#include <of_net.h>
 
 #include <asm/mmu.h>
 
@@ -628,6 +629,25 @@ static int fec_alloc_receive_packets(struct fec_priv *fec, int count, int size)
 	return 0;
 }
 
+#ifdef CONFIG_OFDEVICE
+static int fec_probe_dt(struct device_d *dev, struct fec_priv *fec)
+{
+	int ret;
+
+	ret = of_get_phy_mode(dev->device_node);
+	if (ret < 0)
+		fec->interface = PHY_INTERFACE_MODE_MII;
+	else
+		fec->interface = ret;
+
+	return 0;
+}
+#else
+static int fec_probe_dt(struct device_d *dev, struct fec_priv *fec)
+{
+	return -ENODEV;
+}
+#endif
 static int fec_probe(struct device_d *dev)
 {
         struct fec_platform_data *pdata = (struct fec_platform_data *)dev->platform_data;
@@ -685,7 +705,9 @@ static int fec_probe(struct device_d *dev)
 
 	fec_alloc_receive_packets(fec, FEC_RBD_NUM, FEC_MAX_PKT_SIZE);
 
-	if (pdata) {
+	if (dev->device_node) {
+		ret = fec_probe_dt(dev, fec);
+	} else if (pdata) {
 		fec->interface = pdata->xcv_type;
 		fec->phy_init = pdata->phy_init;
 		fec->phy_addr = pdata->phy_addr;
@@ -694,6 +716,9 @@ static int fec_probe(struct device_d *dev)
 		fec->phy_addr = -1;
 	}
 
+	if (ret)
+		goto err_free;
+
 	fec_init(edev);
 
 	fec->miibus.read = fec_miibus_read;
-- 
1.8.2.rc2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      reply	other threads:[~2013-03-26  9:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-26  9:15 [PATCH 1/2] of/net: Add net related of helpers Sascha Hauer
2013-03-26  9:15 ` Sascha Hauer [this message]

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=1364289316-1998-2-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.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