netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steve Glendinning <steve.glendinning@smsc.com>
To: netdev@vger.kernel.org
Subject: [PATCH 2/6] smsc95xx: wait for PHY to complete reset during init
Date: Wed, 10 Mar 2010 18:32:35 +0000	[thread overview]
Message-ID: <1268245959-13861-3-git-send-email-steve.glendinning@smsc.com> (raw)
In-Reply-To: <1268245959-13861-2-git-send-email-steve.glendinning@smsc.com>

This patch ensures the PHY correctly completes its reset before
setting register values.

Signed-off-by: Steve Glendinning <steve.glendinning@smsc.com>
---
 drivers/net/usb/smsc95xx.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index 4db0840..a2cb77d 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -709,6 +709,8 @@ static void smsc95xx_start_rx_path(struct usbnet *dev)
 
 static int smsc95xx_phy_initialize(struct usbnet *dev)
 {
+	int bmcr, timeout = 0;
+
 	/* Initialize MII structure */
 	dev->mii.dev = dev->net;
 	dev->mii.mdio_read = smsc95xx_mdio_read;
@@ -717,7 +719,20 @@ static int smsc95xx_phy_initialize(struct usbnet *dev)
 	dev->mii.reg_num_mask = 0x1f;
 	dev->mii.phy_id = SMSC95XX_INTERNAL_PHY_ID;
 
+	/* reset phy and wait for reset to complete */
 	smsc95xx_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET);
+
+	do {
+		msleep(10);
+		bmcr = smsc95xx_mdio_read(dev->net, dev->mii.phy_id, MII_BMCR);
+		timeout++;
+	} while ((bmcr & MII_BMCR) && (timeout < 100));
+
+	if (timeout >= 100) {
+		netdev_warn(dev->net, "timeout on PHY Reset");
+		return -EIO;
+	}
+
 	smsc95xx_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE,
 		ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP |
 		ADVERTISE_PAUSE_ASYM);
-- 
1.6.6.1


  reply	other threads:[~2010-03-10 18:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-10 18:32 [PATCH 0/6] smsc95xx: minor fixes and tidy-ups Steve Glendinning
2010-03-10 18:32 ` [PATCH 1/6] smsc95xx: change hard_header_len to include csum offload bytes Steve Glendinning
2010-03-10 18:32   ` Steve Glendinning [this message]
2010-03-10 18:32     ` [PATCH 3/6] smsc95xx: add constant definition for SMSC USB vendor id Steve Glendinning
2010-03-10 18:32       ` [PATCH 4/6] smsc95xx: sleep before read for lengthy operations Steve Glendinning
2010-03-10 18:32         ` [PATCH 5/6] smsc95xx: check return code from control messages Steve Glendinning
2010-03-10 18:32           ` [PATCH 6/6] smsc95xx: remove unnecessary variables Steve Glendinning
2010-03-12 13:32           ` [PATCH 5/6] smsc95xx: check return code from control messages Steve.Glendinning
2010-03-15 22:39       ` [PATCH 3/6] smsc95xx: add constant definition for SMSC USB vendor id 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=1268245959-13861-3-git-send-email-steve.glendinning@smsc.com \
    --to=steve.glendinning@smsc.com \
    --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).