From patchwork Wed May 18 23:44:19 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Fleming X-Patchwork-Id: 96271 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 85810B6F73 for ; Thu, 19 May 2011 09:44:35 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 32F832808A; Thu, 19 May 2011 01:44:32 +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 hRkEK11hX07A; Thu, 19 May 2011 01:44:31 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4E41F28082; Thu, 19 May 2011 01:44:29 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8E43628082 for ; Thu, 19 May 2011 01:44:27 +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 yr-kyT9nvvRP for ; Thu, 19 May 2011 01:44:26 +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 ch1outboundpool.messaging.microsoft.com (ch1ehsobe002.messaging.microsoft.com [216.32.181.182]) by theia.denx.de (Postfix) with ESMTPS id 06B8C2805F for ; Thu, 19 May 2011 01:44:24 +0200 (CEST) Received: from mail109-ch1-R.bigfish.com (216.32.181.171) by CH1EHSOBE012.bigfish.com (10.43.70.62) with Microsoft SMTP Server id 14.1.225.8; Wed, 18 May 2011 23:44:22 +0000 Received: from mail109-ch1 (localhost.localdomain [127.0.0.1]) by mail109-ch1-R.bigfish.com (Postfix) with ESMTP id A1C34CC8432; Wed, 18 May 2011 23:44:22 +0000 (UTC) X-SpamScore: 0 X-BigFish: VS0(zzzz1202hzz8275bhz2dh2a8h668h839h61h) X-Spam-TCS-SCL: 0:0 X-Forefront-Antispam-Report: KIP:(null); UIP:(null); IPVD:NLI; H:mail.freescale.net; RD:none; EFVD:NLI Received: from mail109-ch1 (localhost.localdomain [127.0.0.1]) by mail109-ch1 (MessageSwitch) id 1305762262433776_10396; Wed, 18 May 2011 23:44:22 +0000 (UTC) Received: from CH1EHSMHS018.bigfish.com (snatpool1.int.messaging.microsoft.com [10.43.68.243]) by mail109-ch1.bigfish.com (Postfix) with ESMTP id 60678D5004C; Wed, 18 May 2011 23:44:22 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CH1EHSMHS018.bigfish.com (10.43.70.18) with Microsoft SMTP Server (TLS) id 14.1.225.8; Wed, 18 May 2011 23:44:21 +0000 Received: from az33smr01.freescale.net (10.64.34.199) by 039-SN1MMR1-001.039d.mgd.msft.net (10.84.1.13) with Microsoft SMTP Server id 14.1.270.2; Wed, 18 May 2011 18:44:20 -0500 Received: from localhost (firefly.am.freescale.net [10.82.123.6]) by az33smr01.freescale.net (8.13.1/8.13.0) with ESMTP id p4INiKTR026250; Wed, 18 May 2011 18:44:20 -0500 (CDT) From: Andy Fleming To: Date: Wed, 18 May 2011 18:44:19 -0500 Message-ID: <1305762259-5639-1-git-send-email-afleming@freescale.com> X-Mailer: git-send-email 1.6.5.2.g6ff9a MIME-Version: 1.0 X-OriginatorOrg: freescale.com Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH] phylib: Detect link on 10G devices correctly X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de gen10g_startup() had 2 bugs: 1) It had a boolean logic error in checking the MMD mask, and always checked all of them. 2) It checked devices which don't actually report link state, which meant that it would never believe the link was fully up. Fix the boolean logic, and then mask the MMD mask so only link-reporting devices are checked. Signed-off-by: Andy Fleming Reported-by: Ed Swarthout --- drivers/net/phy/generic_10g.c | 8 ++++++-- include/linux/mdio.h | 8 ++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/generic_10g.c b/drivers/net/phy/generic_10g.c index 315c508..1c3e69e 100644 --- a/drivers/net/phy/generic_10g.c +++ b/drivers/net/phy/generic_10g.c @@ -36,7 +36,7 @@ int gen10g_shutdown(struct phy_device *phydev) int gen10g_startup(struct phy_device *phydev) { int devad, reg; - u32 mmd_mask = phydev->mmds; + u32 mmd_mask = phydev->mmds & MDIO_DEVS_LINK; phydev->link = 1; @@ -44,8 +44,12 @@ int gen10g_startup(struct phy_device *phydev) phydev->speed = SPEED_10000; phydev->duplex = DUPLEX_FULL; + /* + * Go through all the link-reporting devices, and make sure + * they're all up and happy + */ for (devad = 0; mmd_mask; devad++, mmd_mask = mmd_mask >> 1) { - if (!mmd_mask & 1) + if (!(mmd_mask & 1)) continue; /* Read twice because link state is latched and a diff --git a/include/linux/mdio.h b/include/linux/mdio.h index 022d772..f2080dd 100644 --- a/include/linux/mdio.h +++ b/include/linux/mdio.h @@ -120,6 +120,14 @@ #define MDIO_DEVS_VEND1 MDIO_DEVS_PRESENT(MDIO_MMD_VEND1) #define MDIO_DEVS_VEND2 MDIO_DEVS_PRESENT(MDIO_MMD_VEND2) +#define MDIO_DEVS_LINK (MDIO_DEVS_PMAPMD | \ + MDIO_DEVS_WIS | \ + MDIO_DEVS_PCS | \ + MDIO_DEVS_PHYXS | \ + MDIO_DEVS_DTEXS | \ + MDIO_DEVS_AN) + + /* Control register 2. */ #define MDIO_PMA_CTRL2_TYPE 0x000f /* PMA/PMD type selection */