linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: mika.westerberg@iki.fi (Mika Westerberg)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ep93xx-eth: convert to phylib
Date: Wed, 15 Jun 2011 22:15:05 +0300	[thread overview]
Message-ID: <20110615191505.GA2595@acer> (raw)
In-Reply-To: <20110609203059.GZ16318@ibawizard.net>

On Thu, Jun 09, 2011 at 10:30:59PM +0200, Petr ?tetiar wrote:
> 
> just FYI, I wanted to test recent Mika's DMA/ep93xx_eth fixes, so I've added
> this patch also and it oopsed. If I revert this patch, it seems to work so
> far. You can find the whole patchset I've been testing on the GitHub[1]. I've
> tested it on ts-7250 and ts-7300, the oops is same. Here's the oops:
> 
> 	ep93xx-eth version 0.1 loading
> 	ep93xx_eth_mii: probed
> 	ep93xx_eth:ep93xx_mii_probe: no PHY found
> 	ep93xx-eth ep93xx-eth: failed to probe MII bus

I ran into same problem when I tried this patch on my TS-7260. It turned out
that call to mdiobus_register() tries to access PHY registers and the hardware
is not fully initialized yet. On Sim.One there is no such problem and I guess
that the bootloader leaves the hardware in more consistent state or something.

I was able to boot both TS-7260 and Sim.One with following hack on top of
this patch:

diff --git a/drivers/net/arm/ep93xx_eth.c b/drivers/net/arm/ep93xx_eth.c
index 21cc0ee..06eeb10 100644
--- a/drivers/net/arm/ep93xx_eth.c
+++ b/drivers/net/arm/ep93xx_eth.c
@@ -241,6 +241,13 @@ static int ep93xx_mdiobus_write(struct mii_bus *bus, int phy_id, int reg, u16 da
 
 static int ep93xx_mdiobus_reset(struct mii_bus *bus)
 {
+	struct ep93xx_priv *ep = netdev_priv(bus->priv);
+
+	/*
+	 * Make sure that the PHY clock divisor is valid before trying to
+	 * access any of it's registers.
+	 */
+	wrl(ep, REG_SELFCTL, ((ep->mdc_divisor - 1) << 9));
 	return 0;
 }
 
@@ -631,10 +638,8 @@ err:
 	return 1;
 }
 
-static int ep93xx_start_hw(struct net_device *dev)
+static void ep93xx_reset_hw(struct ep93xx_priv *ep)
 {
-	struct ep93xx_priv *ep = netdev_priv(dev);
-	unsigned long addr;
 	int i;
 
 	wrl(ep, REG_SELFCTL, REG_SELFCTL_RESET);
@@ -644,12 +649,15 @@ static int ep93xx_start_hw(struct net_device *dev)
 		msleep(1);
 	}
 
-	if (i == 10) {
+	if (i == 10)
 		pr_crit("hw failed to reset\n");
-		return 1;
-	}
+}
 
-	wrl(ep, REG_SELFCTL, ((ep->mdc_divisor - 1) << 9));
+static int ep93xx_start_hw(struct net_device *dev)
+{
+	struct ep93xx_priv *ep = netdev_priv(dev);
+	unsigned long addr;
+	int i;
 
 	/* Does the PHY support preamble suppress?  */
 	if ((ep93xx_mdiobus_read(ep->mii_bus, ep->phy_addr, MII_BMSR) & 0x0040) != 0)
@@ -715,18 +723,7 @@ static int ep93xx_start_hw(struct net_device *dev)
 
 static void ep93xx_stop_hw(struct net_device *dev)
 {
-	struct ep93xx_priv *ep = netdev_priv(dev);
-	int i;
-
-	wrl(ep, REG_SELFCTL, REG_SELFCTL_RESET);
-	for (i = 0; i < 10; i++) {
-		if ((rdl(ep, REG_SELFCTL) & REG_SELFCTL_RESET) == 0)
-			break;
-		msleep(1);
-	}
-
-	if (i == 10)
-		pr_crit("hw failed to reset\n");
+	ep93xx_reset_hw(netdev_priv(dev));
 }
 
 static int ep93xx_open(struct net_device *dev)
@@ -934,6 +931,8 @@ static int ep93xx_eth_probe(struct platform_device *pdev)
 	}
 	ep->irq = irq;
 
+	ep93xx_reset_hw(ep);
+
 	ep->mii_bus = mdiobus_alloc();
 	if (!ep->mii_bus) {
 		dev_err(&pdev->dev, "Failed to allocate mdiobus\n");

      parent reply	other threads:[~2011-06-15 19:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-05 17:57 [PATCH] ep93xx-eth: convert to phylib Florian Fainelli
2011-06-05 18:29 ` Florian Fainelli
2011-06-05 21:06   ` David Miller
2011-06-06  5:15     ` Florian Fainelli
2011-06-06 17:34       ` Lennert Buytenhek
2011-06-09 20:30   ` Petr Štetiar
2011-06-10  9:46     ` Florian Fainelli
2011-06-15 19:15     ` Mika Westerberg [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=20110615191505.GA2595@acer \
    --to=mika.westerberg@iki.fi \
    --cc=linux-arm-kernel@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;
as well as URLs for NNTP newsgroup(s).