From patchwork Thu Apr 19 08:55:30 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timo Ketola X-Patchwork-Id: 153695 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 7E9EDB7023 for ; Thu, 19 Apr 2012 18:56:58 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AF568280A4; Thu, 19 Apr 2012 10:56:42 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jpPLxGLwBkFm; Thu, 19 Apr 2012 10:56:42 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C4B54280D1; Thu, 19 Apr 2012 10:56:28 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B33D8280A7 for ; Thu, 19 Apr 2012 10:56:19 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id un147fOPu-V8 for ; Thu, 19 Apr 2012 10:56:19 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from exertus.fi (unknown [193.210.47.2]) by theia.denx.de (Postfix) with ESMTP id E78D0280A0 for ; Thu, 19 Apr 2012 10:56:08 +0200 (CEST) Received: from timo-CELSIUS ([10.3.1.192]) by exertus.fi with Microsoft SMTPSVC(6.0.3790.4675); Thu, 19 Apr 2012 11:55:54 +0300 Received: by timo-CELSIUS (sSMTP sendmail emulation); Thu, 19 Apr 2012 11:55:50 +0300 From: "Timo Ketola" To: u-boot@lists.denx.de Date: Thu, 19 Apr 2012 11:55:30 +0300 Message-Id: <1334825735-27992-4-git-send-email-timo@exertus.fi> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1334825735-27992-1-git-send-email-timo@exertus.fi> References: <1334223234-23383-1-git-send-email-timo@exertus.fi> <1334825735-27992-1-git-send-email-timo@exertus.fi> X-OriginalArrivalTime: 19 Apr 2012 08:55:54.0035 (UTC) FILETIME=[3A4EA030:01CD1E0A] X-MS-Exchange-Organization-SCL: 1 Cc: scottwood@freescale.com Subject: [U-Boot] [PATCH V4 3/8] imx: fec: Resolve speed before configuring gasket X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Gasket needs a different configuration for 10BaseT than for higher speeds. Signed-off-by: Timo Ketola Acked-by: Stefano Babic --- Changes in v4: - Rewrapped commit message Changes in v2: - Dropped patches 2 and 3 so this one changed from 5 to 3 - Rebased to u-boot-imx next - Removed the remove of 'miiphy_duplex' call - Changed 'speed == _100BASET' to 'speed != _10BASET' to not to break _1000BASET - Changed configuration option to put gasket into RMII mode from !CONFIG_MII to CONFIG_RMII. I'm not too sure how this should be done though. !CONFIG_MII is normally used for this but its original purpose was to enable MII *management* interface, I think... drivers/net/fec_mxc.c | 43 ++++++++++++++++++++++++------------------- 1 files changed, 24 insertions(+), 19 deletions(-) diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c index 824a199..48a69d4 100644 --- a/drivers/net/fec_mxc.c +++ b/drivers/net/fec_mxc.c @@ -440,6 +440,22 @@ static int fec_open(struct eth_device *edev) */ writel(readl(&fec->eth->ecntrl) | FEC_ECNTRL_ETHER_EN, &fec->eth->ecntrl); +#ifdef CONFIG_PHYLIB + if (!fec->phydev) + fec_eth_phy_config(edev); + if (fec->phydev) { + /* Start up the PHY */ + phy_startup(fec->phydev); + speed = fec->phydev->speed; + } else { + speed = _100BASET; + } +#else + miiphy_wait_aneg(edev); + speed = miiphy_speed(edev->name, fec->phy_id); + miiphy_duplex(edev->name, fec->phy_id); +#endif + #if defined(CONFIG_MX25) || defined(CONFIG_MX53) udelay(100); /* @@ -453,9 +469,14 @@ static int fec_open(struct eth_device *edev) while (readw(&fec->eth->miigsk_enr) & MIIGSK_ENR_READY) udelay(2); -#if !defined(CONFIG_MII) - /* configure gasket for RMII, 50 MHz, no loopback, and no echo */ - writew(MIIGSK_CFGR_IF_MODE_RMII, &fec->eth->miigsk_cfgr); +#if defined(CONFIG_RMII) + if (speed != _10BASET) + /* configure gasket for RMII, 50MHz, no loopback, and no echo */ + writew(MIIGSK_CFGR_IF_MODE_RMII, &fec->eth->miigsk_cfgr); + else + /* configure gasket for RMII, 5MHz, no loopback, and no echo */ + writew(MIIGSK_CFGR_IF_MODE_RMII | MIIGSK_CFGR_FRCONT, + &fec->eth->miigsk_cfgr); #else /* configure gasket for MII, no loopback, and no echo */ writew(MIIGSK_CFGR_IF_MODE_MII, &fec->eth->miigsk_cfgr); @@ -474,22 +495,6 @@ static int fec_open(struct eth_device *edev) } #endif -#ifdef CONFIG_PHYLIB - if (!fec->phydev) - fec_eth_phy_config(edev); - if (fec->phydev) { - /* Start up the PHY */ - phy_startup(fec->phydev); - speed = fec->phydev->speed; - } else { - speed = _100BASET; - } -#else - miiphy_wait_aneg(edev); - speed = miiphy_speed(edev->name, fec->phy_id); - miiphy_duplex(edev->name, fec->phy_id); -#endif - #ifdef FEC_QUIRK_ENET_MAC { u32 ecr = readl(&fec->eth->ecntrl) & ~FEC_ECNTRL_SPEED;