From patchwork Wed Jun 15 19:15:05 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mika Westerberg X-Patchwork-Id: 883222 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p5FJI6kZ022841 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 15 Jun 2011 19:18:27 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QWvb9-00045i-Iy; Wed, 15 Jun 2011 19:17:55 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QWvb9-0005Dc-5N; Wed, 15 Jun 2011 19:17:55 +0000 Received: from mail-ew0-f49.google.com ([209.85.215.49]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QWvb6-0005DJ-17 for linux-arm-kernel@lists.infradead.org; Wed, 15 Jun 2011 19:17:53 +0000 Received: by ewy3 with SMTP id 3so320906ewy.36 for ; Wed, 15 Jun 2011 12:17:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:sender:date:from:to:cc:subject:message-id :references:mime-version:content-type:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=+XtR8KmWcWe9kssGQkeuCek/rSh3v1T2c/nVD06U7m0=; b=xsaboeyolBnu3hPWP8AicJNHus5iXeYqbVa4D/nQefFVgLOo27aUKHFmt9MpVW0hr4 P9LA476PcvNBKYVMjvRgP6omKlM2trMmGmMY0WbFx/XxlirfHf8im9DxI9rTQkkWlu2R KvU/zb6VTP0TaFYfV1Q4TdYaiG4gRq9bmXNKA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:content-transfer-encoding :in-reply-to:user-agent; b=F+/g8l1kTDZxPCgiFhmLIy2wWlIxEHTOHGW5WhCRnRhaMYm1R8FhwirkjAVIYAQd+G rqYeElpAr0XmfneTrzXJEhkNfjRlfcGADrKVUX41vdL27s3P/LqxnNN/YpGYamfmMBt4 Dy6eFfxac7k1lYdivBy1uUz03QMkkNJ16PUxU= Received: by 10.213.31.80 with SMTP id x16mr14582ebc.128.1308165468853; Wed, 15 Jun 2011 12:17:48 -0700 (PDT) Received: from acer (a88-115-37-157.elisa-laajakaista.fi [88.115.37.157]) by mx.google.com with ESMTPS id 67sm681286eet.2.2011.06.15.12.17.46 (version=SSLv3 cipher=OTHER); Wed, 15 Jun 2011 12:17:47 -0700 (PDT) Date: Wed, 15 Jun 2011 22:15:05 +0300 From: Mika Westerberg To: Petr =?utf-8?Q?=C5=A0tetiar?= Subject: Re: [PATCH] ep93xx-eth: convert to phylib Message-ID: <20110615191505.GA2595@acer> References: <201106051957.36492.florian@openwrt.org> <201106052029.24742.f.fainelli@gmail.com> <20110609203059.GZ16318@ibawizard.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20110609203059.GZ16318@ibawizard.net> User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110615_151752_353918_18DD0395 X-CRM114-Status: GOOD ( 23.14 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is freemail (mika.westerberg[at]gmail.com) -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.215.49 listed in list.dnswl.org] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 RFC_ABUSE_POST Both abuse and postmaster missing on sender domain Cc: Lennert Buytenhek , Florian Fainelli , netdev@vger.kernel.org, Herbert Valerio Riedel , hsweeten@visionengravers.com, ryan@bluewatersys.com, davem@davemloft.net, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Wed, 15 Jun 2011 19:18:27 +0000 (UTC) X-MIME-Autoconverted: from base64 to 8bit by demeter2.kernel.org id p5FJI6kZ022841 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");