From patchwork Thu Apr 24 02:17:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shengzhou Liu X-Patchwork-Id: 342066 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id B19831400F6 for ; Thu, 24 Apr 2014 13:01:55 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752342AbaDXDBk (ORCPT ); Wed, 23 Apr 2014 23:01:40 -0400 Received: from mail-bl2lp0211.outbound.protection.outlook.com ([207.46.163.211]:40943 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752316AbaDXDBh (ORCPT ); Wed, 23 Apr 2014 23:01:37 -0400 Received: from DM2PR03CA010.namprd03.prod.outlook.com (10.141.52.158) by DM2PR03MB398.namprd03.prod.outlook.com (10.141.84.140) with Microsoft SMTP Server (TLS) id 15.0.921.12; Thu, 24 Apr 2014 03:01:22 +0000 Received: from BN1AFFO11FD037.protection.gbl (2a01:111:f400:7c10::121) by DM2PR03CA010.outlook.office365.com (2a01:111:e400:2414::30) with Microsoft SMTP Server (TLS) id 15.0.921.12 via Frontend Transport; Thu, 24 Apr 2014 03:01:21 +0000 Received: from az84smr01.freescale.net (192.88.158.246) by BN1AFFO11FD037.mail.protection.outlook.com (10.58.52.241) with Microsoft SMTP Server (TLS) id 15.0.929.8 via Frontend Transport; Thu, 24 Apr 2014 03:01:21 +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 s3O31ItF019399; Wed, 23 Apr 2014 20:01:19 -0700 From: Shengzhou Liu To: CC: , Shengzhou Liu Subject: [PATCH] net/phy: tune get_phy_c45_ids to support more c45 phy Date: Thu, 24 Apr 2014 10:17:36 +0800 Message-ID: <1398305856-9761-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)(189002)(199002)(80976001)(44976005)(92566001)(77156001)(81342001)(87286001)(81542001)(87936001)(92726001)(50466002)(89996001)(19580395003)(62966002)(48376002)(99396002)(83322001)(6806004)(88136002)(4396001)(19580405001)(80022001)(83072002)(85852003)(74662001)(86362001)(79102001)(76482001)(47776003)(20776003)(31966008)(50986999)(50226001)(46102001)(77096999)(74502001)(93916002)(77982001)(36756003); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR03MB398; H:az84smr01.freescale.net; FPR:7A4FF17A.BC234918.6ED82B90.80E2DA1A.201DD; MLV:sfv; PTR:gate-az5.freescale.com; MX:3; A:1; LANG:en; MIME-Version: 1.0 X-Forefront-PRVS: 01917B1794 Received-SPF: None (: freescale.com does not designate permitted sender hosts) X-OriginatorOrg: freescale.com Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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; + } } }