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] net fec: connect phy at probe time
Date: Fri, 26 Oct 2012 16:16:54 +0200	[thread overview]
Message-ID: <1351261014-25235-1-git-send-email-s.hauer@pengutronix.de> (raw)

Several i.MX boards (all i.MX6 boards) need to do some adjustments
to phy registers. If barebox itself does not use network, networking
won't work in the kernel if the kernel does not have the fixups. Connect
the phy at probe time so that these tweaks are done during probe so that
the kernel works without phy register tweaks. Also this has the effect
that the phy device is present and introspectable without doing fake
network transfers beforehand.

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

diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
index fde6658..29faff3 100644
--- a/drivers/net/fec_imx.c
+++ b/drivers/net/fec_imx.c
@@ -373,6 +373,26 @@ static void fec_update_linkspeed(struct eth_device *edev)
 	writel(rcntl, fec->regs + FEC_R_CNTRL);
 }
 
+static int fec_phy_connect(struct eth_device *edev)
+{
+	struct fec_priv *fec = (struct fec_priv *)edev->priv;
+	int ret;
+
+	if (fec->xcv_type == SEVENWIRE)
+		return 0;
+
+	ret = phy_device_connect(edev, &fec->miibus, fec->phy_addr,
+			 fec_update_linkspeed, fec->phy_flags,
+			 fec->interface);
+	if (ret)
+		return ret;
+
+	if (fec->phy_init)
+		fec->phy_init(edev->phydev);
+
+	return 0;
+}
+
 /**
  * Start the FEC engine
  * @param[in] edev Our device to handle
@@ -383,17 +403,6 @@ static int fec_open(struct eth_device *edev)
 	int ret;
 	u32 ecr;
 
-	if (fec->xcv_type != SEVENWIRE) {
-		ret = phy_device_connect(edev, &fec->miibus, fec->phy_addr,
-					 fec_update_linkspeed, fec->phy_flags,
-					 fec->interface);
-		if (ret)
-			return ret;
-
-		if (fec->phy_init)
-			fec->phy_init(edev->phydev);
-	}
-
 	/*
 	 * Initialize RxBD/TxBD rings
 	 */
@@ -706,9 +715,18 @@ static int fec_probe(struct device_d *dev)
 		mdiobus_register(&fec->miibus);
 	}
 
-	eth_register(edev);
+	ret = eth_register(edev);
+	if (ret)
+		goto err_free;
+
+	ret = fec_phy_connect(edev);
+	if (ret)
+		goto err_unregister;
+
 	return 0;
 
+err_unregister:
+	eth_unregister(edev);
 err_free:
 	free(fec);
 	return ret;
-- 
1.7.10.4


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

                 reply	other threads:[~2012-10-26 14:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1351261014-25235-1-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