From patchwork Wed Apr 23 09:55:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shengzhou Liu X-Patchwork-Id: 341772 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 6D1321401A0 for ; Wed, 23 Apr 2014 20:54:44 +1000 (EST) X-Greylist: delayed 875 seconds by postgrey-1.34 at bilbo; Wed, 23 Apr 2014 20:54:13 EST Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1blp0189.outbound.protection.outlook.com [207.46.163.189]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 0D6C714008B for ; Wed, 23 Apr 2014 20:54:12 +1000 (EST) Received: from DM2PR03CA006.namprd03.prod.outlook.com (10.141.52.154) by BLUPR03MB391.namprd03.prod.outlook.com (10.141.78.21) with Microsoft SMTP Server (TLS) id 15.0.921.12; Wed, 23 Apr 2014 10:39:32 +0000 Received: from BY2FFO11FD045.protection.gbl (2a01:111:f400:7c0c::156) by DM2PR03CA006.outlook.office365.com (2a01:111:e400:2414::26) with Microsoft SMTP Server (TLS) id 15.0.921.12 via Frontend Transport; Wed, 23 Apr 2014 10:39:31 +0000 Received: from az84smr01.freescale.net (192.88.158.246) by BY2FFO11FD045.mail.protection.outlook.com (10.1.15.177) with Microsoft SMTP Server (TLS) id 15.0.929.8 via Frontend Transport; Wed, 23 Apr 2014 10:39:31 +0000 Received: from rock.ap.freescale.net (rock.ap.freescale.net [10.193.20.106]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id s3NAdSw5002715; Wed, 23 Apr 2014 03:39:29 -0700 From: Shengzhou Liu To: , , Subject: [PATCH] net/phy: tune get_phy_c45_ids to support more c45 phy Date: Wed, 23 Apr 2014 17:55:51 +0800 Message-ID: <1398246951-27303-1-git-send-email-Shengzhou.Liu@freescale.com> X-Mailer: git-send-email 1.8.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:192.88.158.246; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009001)(6009001)(428001)(199002)(189002)(99396002)(93916002)(81542001)(89996001)(87936001)(92566001)(88136002)(85852003)(83072002)(77156001)(81342001)(4396001)(87286001)(92726001)(50226001)(79102001)(47776003)(20776003)(80022001)(50466002)(76482001)(62966002)(74502001)(2201001)(36756003)(77096999)(50986999)(6806004)(80976001)(77982001)(31966008)(74662001)(46102001)(48376002)(19580395003)(83322001)(86362001)(19580405001)(44976005); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR03MB391; H:az84smr01.freescale.net; FPR:7A4FF17A.BC234918.6ED82B90.80E2DA1A.201DD; MLV:sfv; PTR:gate-az5.freescale.com; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Forefront-PRVS: 01901B3451 Received-SPF: None (: freescale.com does not designate permitted sender hosts) X-OriginatorOrg: freescale.com Cc: Shengzhou Liu X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" As some C45 10G PHYs(e.g. Cortina CS4315/CS4340 PHY) have zero Devices In package, current driver can't get correct devices_in_package value by non-zero Devices In package. so let's probe more with zero Devices In package to support more C45 PHYs which have zero Devices In package. Signed-off-by: Shengzhou Liu --- Tested with CS4315 on T2080RDB, this patch have no impact on previous XAUI phy with verification. drivers/net/phy/phy_device.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index cfb5110..8fd777e 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -244,12 +244,29 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id, return -EIO; c45_ids->devices_in_package |= (phy_reg & 0xffff); - /* If mostly Fs, there is no device there, - * let's get out of here. + /* If mostly Fs, let's continue to probe more + * as some 10G PHYs have zero Devices In package + * e.g. Cortina CS4315/CS4340 PHY. */ if ((c45_ids->devices_in_package & 0x1fffffff) == 0x1fffffff) { - *phy_id = 0xffffffff; - return 0; + reg_addr = MII_ADDR_C45 | 0 << 16 | 6; + phy_reg = mdiobus_read(bus, addr, reg_addr); + if (phy_reg < 0) + return -EIO; + c45_ids->devices_in_package = (phy_reg & 0xffff) << 16; + reg_addr = MII_ADDR_C45 | 0 << 16 | 5; + phy_reg = mdiobus_read(bus, addr, reg_addr); + if (phy_reg < 0) + return -EIO; + c45_ids->devices_in_package |= (phy_reg & 0xffff); + /* If mostly Fs, there is no device there, + * let's get out of here. + */ + if ((c45_ids->devices_in_package & 0x1fffffff) == + 0x1fffffff) { + *phy_id = 0xffffffff; + return 0; + } } }