From: Wolfram Sang <w.sang@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 3/3] net: miidev: properly check for MII reset
Date: Wed, 21 Mar 2012 12:18:45 +0100 [thread overview]
Message-ID: <1332328725-29753-4-git-send-email-w.sang@pengutronix.de> (raw)
In-Reply-To: <1332328725-29753-1-git-send-email-w.sang@pengutronix.de>
Wait until the reset bit is actually cleared instead of some
arbitrary delay (which caused problems with a PHY which was in some
energy saving mode).
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
---
drivers/net/miidev.c | 17 ++++++++++++-----
1 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/drivers/net/miidev.c b/drivers/net/miidev.c
index 16a3461..3b73133 100644
--- a/drivers/net/miidev.c
+++ b/drivers/net/miidev.c
@@ -31,19 +31,26 @@
int miidev_restart_aneg(struct mii_device *mdev)
{
int status, timeout;
+ uint64_t start;
- /*
- * Reset PHY, then delay 300ns
- */
status = mii_write(mdev, mdev->address, MII_BMCR, BMCR_RESET);
if (status)
return status;
+ start = get_time_ns();
+ do {
+ status = mii_read(mdev, mdev->address, MII_BMCR);
+ if (status < 0)
+ return status;
+
+ if (is_timeout(start, SECOND))
+ return -ETIMEDOUT;
+
+ } while (status & BMCR_RESET);
+
if (mdev->flags & MIIDEV_FORCE_LINK)
return 0;
- udelay(1000);
-
if (mdev->flags & MIIDEV_FORCE_10) {
printf("Forcing 10 Mbps ethernet link... ");
--
1.7.9.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2012-03-21 11:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-21 11:18 [PATCH 0/3] miidev: improve phy initialization Wolfram Sang
2012-03-21 11:18 ` [PATCH 1/3] net: miidev: check for errors when accessing bus in restart_aneg Wolfram Sang
2012-03-21 11:18 ` [PATCH 2/3] net: miidev: Refactor timeout for aneg Wolfram Sang
2012-03-21 11:18 ` Wolfram Sang [this message]
2012-03-23 7:23 ` [PATCH 0/3] miidev: improve phy initialization Sascha Hauer
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=1332328725-29753-4-git-send-email-w.sang@pengutronix.de \
--to=w.sang@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