From patchwork Fri Nov 29 05:47:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: shaohui xie X-Patchwork-Id: 295148 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 9C2E82C0085 for ; Fri, 29 Nov 2013 18:08:19 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753689Ab3K2HIB (ORCPT ); Fri, 29 Nov 2013 02:08:01 -0500 Received: from mail-db9lp0249.outbound.messaging.microsoft.com ([213.199.154.249]:28279 "EHLO db9outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753582Ab3K2HIA (ORCPT ); Fri, 29 Nov 2013 02:08:00 -0500 Received: from mail8-db9-R.bigfish.com (10.174.16.248) by DB9EHSOBE028.bigfish.com (10.174.14.91) with Microsoft SMTP Server id 14.1.225.22; Fri, 29 Nov 2013 07:07:58 +0000 Received: from mail8-db9 (localhost [127.0.0.1]) by mail8-db9-R.bigfish.com (Postfix) with ESMTP id B41A9100542; Fri, 29 Nov 2013 07:07:58 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 6 X-BigFish: VS6(z1039mzzz1f42h1ee6h1ce5h1fdah201ch2073h2146h1202h1fd0h1e76h1d1ah1cabh1d2ah1fc6hzz1de098h8275bh1de097hz31h87h2a8h839hd24he5bhf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h15a8h162dh1631h1758h17eeh1898h18e1h1946h19b5h1ad9h1b0ah1b2fh224fh1fb3h1d0ch1d2eh1d3fh1dc1h1dfeh1dffh1e23h1fe8h1ff5h2218h2216h226dh22d0h2327h2336h129fi1151h1155h) Received-SPF: softfail (mail8-db9: transitioning domain of gmail.com does not designate 70.37.183.190 as permitted sender) client-ip=70.37.183.190; envelope-from=shh.xie@gmail.com; helo=mail.freescale.net ; reescale.net ; X-FB-DOMAIN-IP-MATCH: fail Received: from mail8-db9 (localhost.localdomain [127.0.0.1]) by mail8-db9 (MessageSwitch) id 1385708876576629_14615; Fri, 29 Nov 2013 07:07:56 +0000 (UTC) Received: from DB9EHSMHS006.bigfish.com (unknown [10.174.16.228]) by mail8-db9.bigfish.com (Postfix) with ESMTP id 86BCA2007E; Fri, 29 Nov 2013 07:07:56 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by DB9EHSMHS006.bigfish.com (10.174.14.16) with Microsoft SMTP Server (TLS) id 14.16.227.3; Fri, 29 Nov 2013 07:07:56 +0000 Received: from tx30smr01.am.freescale.net (10.81.153.31) by 039-SN1MMR1-005.039d.mgd.msft.net (10.84.1.17) with Microsoft SMTP Server (TLS) id 14.3.158.2; Fri, 29 Nov 2013 07:07:54 +0000 Received: from Tank.am.freescale.net (tank.ap.freescale.net [10.193.20.104]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id rAT77p1G020137; Fri, 29 Nov 2013 00:07:52 -0700 From: To: , , , , , CC: Subject: [PATCH 4/6][v3] phylib: Add generic 10G driver Date: Fri, 29 Nov 2013 13:47:38 +0800 Message-ID: <1385704058-12916-1-git-send-email-shh.xie@gmail.com> X-Mailer: git-send-email 1.8.4.1 MIME-Version: 1.0 X-OriginatorOrg: sigmatel.com X-FOPE-CONNECTOR: Id%0$Dn%*$RO%0$TLS%0$FQDN%$TlsDn% Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Andy Fleming Very incomplete, but will allow for binding an ethernet controller to it. Signed-off-by: Andy Fleming Signed-off-by: Shaohui Xie --- v3 changes: splitted from v2 patch 3/5. drivers/net/phy/phy_device.c | 80 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index a5926a6..79142de 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -55,6 +56,7 @@ static void phy_device_release(struct device *dev) enum genphy_driver { GENPHY_DRV_1G, + GENPHY_DRV_10G, GENPHY_DRV_MAX }; @@ -697,6 +699,12 @@ static int genphy_config_advert(struct phy_device *phydev) return changed; } +int gen10g_config_advert(struct phy_device *dev) +{ + return 0; +} +EXPORT_SYMBOL(gen10g_config_advert); + /** * genphy_setup_forced - configures/forces speed/duplex from @phydev * @phydev: target phy_device struct @@ -750,6 +758,11 @@ int genphy_restart_aneg(struct phy_device *phydev) } EXPORT_SYMBOL(genphy_restart_aneg); +int gen10g_restart_aneg(struct phy_device *phydev) +{ + return 0; +} +EXPORT_SYMBOL(gen10g_restart_aneg); /** * genphy_config_aneg - restart auto-negotiation or write BMCR @@ -792,6 +805,12 @@ int genphy_config_aneg(struct phy_device *phydev) } EXPORT_SYMBOL(genphy_config_aneg); +int gen10g_config_aneg(struct phy_device *phydev) +{ + return 0; +} +EXPORT_SYMBOL(gen10g_config_aneg); + /** * genphy_update_link - update link status in @phydev * @phydev: target phy_device struct @@ -921,6 +940,34 @@ int genphy_read_status(struct phy_device *phydev) } EXPORT_SYMBOL(genphy_read_status); +int gen10g_read_status(struct phy_device *phydev) +{ + int devad, reg; + u32 mmd_mask = phydev->c45_ids.devices_in_package; + + phydev->link = 1; + + /* For now just lie and say it's 10G all the time */ + phydev->speed = SPEED_10000; + phydev->duplex = DUPLEX_FULL; + + for (devad = 0; mmd_mask; devad++, mmd_mask = mmd_mask >> 1) { + if (!(mmd_mask & 1)) + continue; + + /* Read twice because link state is latched and a + * read moves the current state into the register + */ + phy_read_mmd(phydev, devad, MDIO_STAT1); + reg = phy_read_mmd(phydev, devad, MDIO_STAT1); + if (reg < 0 || !(reg & MDIO_STAT1_LSTATUS)) + phydev->link = 0; + } + + return 0; +} +EXPORT_SYMBOL(gen10g_read_status); + static int genphy_config_init(struct phy_device *phydev) { int val; @@ -967,6 +1014,16 @@ static int genphy_config_init(struct phy_device *phydev) return 0; } + +static int gen10g_config_init(struct phy_device *phydev) +{ + /* Temporarily just say we support everything */ + phydev->supported = SUPPORTED_10000baseT_Full; + phydev->advertising = SUPPORTED_10000baseT_Full; + + return 0; +} + int genphy_suspend(struct phy_device *phydev) { int value; @@ -982,6 +1039,12 @@ int genphy_suspend(struct phy_device *phydev) } EXPORT_SYMBOL(genphy_suspend); +int gen10g_suspend(struct phy_device *phydev) +{ + return 0; +} +EXPORT_SYMBOL(gen10g_suspend); + int genphy_resume(struct phy_device *phydev) { int value; @@ -997,6 +1060,12 @@ int genphy_resume(struct phy_device *phydev) } EXPORT_SYMBOL(genphy_resume); +int gen10g_resume(struct phy_device *phydev) +{ + return 0; +} +EXPORT_SYMBOL(gen10g_resume); + /** * phy_probe - probe and init a PHY device * @dev: device to probe and init @@ -1136,6 +1205,17 @@ static struct phy_driver genphy_driver[] = { .suspend = genphy_suspend, .resume = genphy_resume, .driver = {.owner= THIS_MODULE, }, +}, { + .phy_id = 0xffffffff, + .phy_id_mask = 0xffffffff, + .name = "Generic 10G PHY", + .config_init = gen10g_config_init, + .features = 0, + .config_aneg = gen10g_config_aneg, + .read_status = gen10g_read_status, + .suspend = gen10g_suspend, + .resume = gen10g_resume, + .driver = {.owner = THIS_MODULE, }, } }; static int __init phy_init(void)