From patchwork Wed Aug 10 05:50:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Appana Durga Kedareswara rao X-Patchwork-Id: 9272697 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AC0A4600CB for ; Wed, 10 Aug 2016 05:54:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8FFD6282EC for ; Wed, 10 Aug 2016 05:54:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8450928339; Wed, 10 Aug 2016 05:54:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D8F95282EC for ; Wed, 10 Aug 2016 05:54:08 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bXMQS-0002yP-8u; Wed, 10 Aug 2016 05:51:36 +0000 Received: from mail-cys01nam02on0071.outbound.protection.outlook.com ([104.47.37.71] helo=NAM02-CY1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bXMPd-0002js-CP for linux-arm-kernel@lists.infradead.org; Wed, 10 Aug 2016 05:50:47 +0000 Received: from CY1NAM02FT022.eop-nam02.prod.protection.outlook.com (10.152.74.58) by CY1NAM02HT175.eop-nam02.prod.protection.outlook.com (10.152.74.205) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.567.7; Wed, 10 Aug 2016 05:50:23 +0000 Authentication-Results: spf=pass (sender IP is 149.199.60.100) smtp.mailfrom=xilinx.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.60.100 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.100; helo=xsj-pvapsmtpgw02; Received: from xsj-pvapsmtpgw02 (149.199.60.100) by CY1NAM02FT022.mail.protection.outlook.com (10.152.75.185) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.567.7 via Frontend Transport; Wed, 10 Aug 2016 05:50:22 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66]:50562 helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw02 with esmtp (Exim 4.63) (envelope-from ) id 1bXMPG-0002y9-AT; Tue, 09 Aug 2016 22:50:22 -0700 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1bXMPF-0003bP-Jr; Tue, 09 Aug 2016 22:50:21 -0700 Received: from xsj-pvapsmtp01 (maildrop.xilinx.com [149.199.38.66]) by xsj-smtp-dlp1.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id u7A5oDkp026552; Tue, 9 Aug 2016 22:50:13 -0700 Received: from [172.23.64.208] (helo=xhdrdevl6.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1bXMP7-0003Xp-0q; Tue, 09 Aug 2016 22:50:13 -0700 Received: by xhdrdevl6.xilinx.com (Postfix, from userid 13614) id B984BF20010; Wed, 10 Aug 2016 11:20:11 +0530 (IST) From: Kedareswara rao Appana To: , , , , , , , Subject: [PATCH v6 3/3] net: phy: Add gmiitorgmii converter support Date: Wed, 10 Aug 2016 11:20:08 +0530 Message-ID: <1470808208-32133-4-git-send-email-appanad@xilinx.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1470808208-32133-1-git-send-email-appanad@xilinx.com> References: <1470808208-32133-1-git-send-email-appanad@xilinx.com> X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.0.0.1202-22502.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:149.199.60.100; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(438002)(199003)(50944005)(189002)(229853001)(48376002)(33646002)(50226002)(106466001)(103686003)(36756003)(50986999)(87936001)(92566002)(19580405001)(5001770100001)(81166006)(189998001)(86362001)(19580395003)(36386004)(8936002)(47776003)(46386002)(2201001)(8676002)(76176999)(4001450100002)(7846002)(81156014)(45336002)(50466002)(2906002)(2950100001)(90966002)(586003)(52956003)(356003)(305945005)(4326007)(5003940100001)(42186005)(63266004)(2004002)(107986001)(2101003)(5001870100001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1NAM02HT175; H:xsj-pvapsmtpgw02; FPR:; SPF:Pass; PTR:xapps1.xilinx.com,unknown-60-100.xilinx.com; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CY1NAM02FT022; 1:v+UXf65Yv0yepHPbONQCEffikrUtfVHnWsXZUAAtSC8tFdCEkwdMKKR9zqWnLpL/BSiWTFX4crKbpuZEjx8aTYLv/ob6bVeTnN2AEh7mfMD6CdkD4GbIumsn4jWXVRwckA3qYwubndxczat1vHKU/AFhf2VtqYCwpAH2H87i6DqsQAhEJGNBsr8JdBUYxO0YvBXCxrRPEC3UCdPGJKh152gqGAItSCmmCfQQw3kp1A8siww/syrSTdvdkgbHFkyLKyT55otkmKeJLJEx8uyqPs9+devyk2Fd+gR1sIOWHkDQIV8b4DBmg9EWYo+Afxtt747gbG+jV5+Me3qDD6WrmCkdWuJ9jYsZM9x5R6AQ46pM/hyo7e4g9CPog04Cq4qBQTU9Pfm7GffHmIGg41M1WijWvhAsTT7gsC8LlFgZoSKLFq+r2aq4S/Nsc2OAGzzzNxvxqtjuoOFeHX2U8mk/QQB9l7mBBiDuSVEkMDOj55kK52y0edJynC90LUjtq+uFNDuwF8q+T6SlmL3H8F52/RL2qVtD/IBF8T0tsDv70uGNnUzDHBgWIHBAPT2/LpAxOsc0J+Z5FlkvUDR/UiIM+bRSpxvIPQu3BCQjIqAywftaN1Qs0aF7nJ/4bcbuUKRh MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 358f2361-69b9-4c0c-7baa-08d3c0e23849 X-Microsoft-Exchange-Diagnostics: 1; CY1NAM02HT175; 2:OZQJZ5dtJR5+8iFGnmEdN+0nut26gSxdnxEDLyBN6gz35LHK3NA0FQf7UmiRsnzIQXm4XFuZ0VChjRsVPyK8PawlFEyJjp+vB7if1I/GmPLWcCFVy7/2sJSlyJzSmUgwbRzwb+0Yb2d4ul5sBvuLm8AAIaCBi/of2ywY5ivO8RJBbZB+6CPQvd20gge6mepL; 3:RdNJmwOySHS9IB0zUH8CYQVbuSzZNeWzlmuxGhBHkXjT0L0UXLb7uJEhV2xOKU91QAHTfvv+U2G78poiFovjP/HimTltF8zpgN0YJgoHzUUwNRbSAr0pxYRICA9Nr5kS9t27/1TsSfDnlJeSQZZLsX6wB9aWi+21U+nt2rrFAjm+ZnqW7MTKaXOp1b5CN9B+PYqpqhGh7rb8PXVGNh2BbgnOnu3b9eRRMuH3hrLsqpcWL4FnvM6nANRciUnyr2R5fXoD88EKfpkbeLS18JCuKg== X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501002); SRVR:CY1NAM02HT175; X-Microsoft-Exchange-Diagnostics: 1; CY1NAM02HT175; 25:a1c+eD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agOdSuqgOXQB4DZCKjEYKMN0XIqEVUKHAFGfEjvsEAKotrbpcH6ZmqmcNuonZE3Y3JoxEUnVLVHQeQtxNPBig42mdFkr83xTRqvXhaUX+Qo0cn+FiqepC918vJSBE84zl5r2q/YeIgrGxcEexWOyKGdijY8yP8IKCAC8pOxgKRMATRiqGVsIIMKHaE8EWZoZze0Rfl0Cd8TBgqxRgOQxwCfmvRX0s4gBP70dw+xiqPjViJAKd+uXUaAj3VdHtVu6PDDDYx+shrjATyFhIW5EHGLLvbIYERUegLIgukxkwMOE3kyEUdu9geYwTnPtSbzIgiqktzeSeBhNzilxnKrxCQNKD8D9hGyaGnvA+DBfG+2BcHaGlIVteZRWOPxh0ouQw/yu46Ok5dOewntme73SQmTYYFxN/HECz2RzULjOldGlUp9NDTuJoJIZu1EvQDVz0NhpoqMIcoXM6rPVc0lncj/H36bGycrJZ6K X-Microsoft-Antispam-PRVS: <7d7ea706f29d4fc986fb2c5b9fe392ae@CY1NAM02HT175.eop-nam02.prod.protection.outlook.com> X-Exchange-Antispam-Report-Test: UriScan:(192813158149592); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040164)(601004)(2401047)(5005006)(13018025)(13017025)(13015025)(13024025)(8121501046)(13023025)(3002001)(10201501046)(6055026); SRVR:CY1NAM02HT175; BCL:0; PCL:0; RULEID:; SRVR:CY1NAM02HT175; X-Microsoft-Exchange-Diagnostics: 1; CY1NAM02HT175; 4:Gp4cKiKbFlHEiq1R3kLxTRaoYFQDeP8VePtE9EgwG3sEogl/Z4FhCNPLeI+mT+pk7W+vk4x+x4roxmXc9rovwPwrVV2B2fAoaZHQHOJGHfoFdepQLydpd17pnwCeC881l6dqeZbOTSndZLangD+xI3O57/4VNmKRP4FdVABEzhxsRbp8CWtGcsgkF4/d748L2Uvfszb1/aRztJwhvUNQa0+8H2ZAq2D7GiEtsa0FzGyv3OgvTx2yeAySbnX2GYrtZMDf2DDeUWIcOlf+MGb7QQeIbpHC9PH3XxOpwbBDxO2mvddT4glOqanRKI0S4XCp9KY7sMThJo2zsqv3BtE/Bc2okB/hBTunHaIuree9z0TYs6f58IRfba3yZUqqXZUB/CRVWMJMeruKc5c0MEzuiT5gCTIbXqEaK9BM1T89yPchVqJp6cXL9+F0CWUnURhwsxUn0T1Yyl/zMnDZNaVN4qK7b+MNXFJQjKf63muYLUw8cXeZFqHEFp/inReYo5i66ll18YPlYRlsPr+2sPEH7e9YJcorS4zbMn/1qU6dmZU= X-Forefront-PRVS: 0030839EEE X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1NAM02HT175; 23:iN11ALsnTqAPZ8mEOMKxE1RmXkYbVPeJubFhyJmhv?= =?us-ascii?Q?9owUlNxEg7e2RcrheHoL2TXgsUxijDVFCHhYidmR5vG9+y1uGwttjulcmCE3?= =?us-ascii?Q?38W4ok09qX3lIT4Ih9JOR1C1AdWlY58GZK0rZQ1q7TdCydcWyyPg/U9oVIJM?= =?us-ascii?Q?WdaUpcGGdAoUJhycO9JG61fETrqJ0Uc0QsyWjB6H3oOkheRO0Pvpa8mdHpt2?= =?us-ascii?Q?JLbs3Uw6Z+bLI0WgM23tvjv2zNPC6fDPEjgLUBmZwp9eyNyMKS7iHNgVfQOj?= =?us-ascii?Q?vyO/t/YEhezcghF+jlBNu++y7Qbb3QeoGcanWH7/0ZQsofppjLV/7nm63cdg?= =?us-ascii?Q?NJQpvb20f5GdqQC6f9rTc4DTlhqypniPOYSKnG6t+Xmib9iI00fAEiVGtTgJ?= =?us-ascii?Q?7VVtlS2mYX6sJ9Og++G7dUvajDKh+z8yXRR4Wx205NpZUBOsXa2MBfM8e6mG?= =?us-ascii?Q?f3pUnrw1ieU/La/LnhMiayQuhLJteha1pwxKPRRgReRCnT9iU1C3TOCEc5d+?= =?us-ascii?Q?imr+RQRsRY7EovFOk/0EmmquZXHR8bzah/4ZoCC619gMzkdjKj9YYTHAQ5ca?= =?us-ascii?Q?ceNS4UHRVGCsJRExL03Z1J609QUazn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/ClseIAMPBslqFDVD35Edsua2Jq1UVyiOUCDa0dTDHNTDBhJkHuMdO1W1VeXc1idESaxYm78H7U3+5kCR0Jav0wXe45MUxIaw+GGOQetFZ00s6ffftA==; 5:QwyzQjPPVqM2w2F/HgKjLI9noJys0uNoaG7ZdH8mP/dJ0ULOwZFl9gey3Urth+ul3vOsQbXNhhxgzqsolc05nIAR+hAdKio9tJLmU1tqd4Ve9L45oPznSuymVhWTw138lqIHCNcxllLvuENK9o/6tg==; 24:EZ30FBEs1s/EX2tUYRMB3Xyq1WxsLLdSac6Zi7Dqifw4OfVRXweHCVti3UX0BP3hiDjirB7vdKJA7OOPS54OH2VH5Lya2XoIkF9IFJI3YtM=; 7:XnZ2cXhcXO+77axyothPFEAa5UUlS8L8ygXoU3HVnS5XULR2U7FNgw4osIzx3m1LKTaLq6BMky/bAFcCwgxM8VKdVhb2FtMbyeBw3rjTpYMnhVKbU1ztyTqOUbp6PdZZRGLJfeWTIMt6/gD7Rp2hBVD4IZHMsdiuKYr7EVz8SrIBnUBY8g8Mthj6K0t1r89URic4SA2J4U1ZCtrBgWbRRPw/XcMYX94QIPvT80RprtcurAQj7eRSmw5QBL05r1CX SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Aug 2016 05:50:22.3228 (UTC) X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.60.100]; Helo=[xsj-pvapsmtpgw02] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1NAM02HT175 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160809_225045_640166_67438DB3 X-CRM114-Status: GOOD ( 16.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds support for gmiitorgmii converter. The GMII to RGMII IP core provides the Reduced Gigabit Media Independent Interface (RGMII) between Ethernet physical media Devices and the Gigabit Ethernet controller. This core can Switch dynamically between the three different speed modes of Operation by configuring the converter register through mdio write. MDIO interface is used to set operating speed of Ethernet MAC. This converter sits between the MAC and the external phy MAC <==> GMII2RGMII <==> RGMII_PHY Signed-off-by: Kedareswara rao Appana --- Thanks a lot Andrew for your inputs. Changes for v6: --> Don't force phy to default enabled as suggested by Florian. --> Fix Mask value as suggested by Florian. --> Used mdio_module_driver as suggested by Florian. --> Remove switch case and used if-else conditions for phy speed checking as suggested by Florian. Changes for v5: --> Fixed return values in the probe as suggested by punnaiah. --> Added a mask for the converter speed as suggested by punnaiah. Changes for v4: --> Updated phydev speed for all 3 speeds as suggested by zhuyj. Changes for v3: --> Updated the driver as suggested by Andrew. Changes for v2: --> Passed struct xphy pointer directly to the fix_mac_speed API as suggested by the Florian. --> Added checks for the phy-node fail case as suggested by the Florian drivers/net/phy/Kconfig | 7 +++ drivers/net/phy/Makefile | 1 + drivers/net/phy/xilinx_gmii2rgmii.c | 109 ++++++++++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+) create mode 100644 drivers/net/phy/xilinx_gmii2rgmii.c diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index 1b534ea..d66133bf 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig @@ -312,6 +312,13 @@ config MICROSEMI_PHY ---help--- Currently supports the VSC8531 and VSC8541 PHYs +config XILINX_GMII2RGMII + tristate "Xilinx GMII2RGMII converter driver" + ---help--- + This driver support xilinx GMII to RGMII IP core it provides + the Reduced Gigabit Media Independent Interface(RGMII) between + Ethernet physical media devices and the Gigabit Ethernet controller. + endif # PHYLIB config MICREL_KS8995MA diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile index a713bd4..73d65ce 100644 --- a/drivers/net/phy/Makefile +++ b/drivers/net/phy/Makefile @@ -50,3 +50,4 @@ obj-$(CONFIG_MDIO_BCM_IPROC) += mdio-bcm-iproc.o obj-$(CONFIG_INTEL_XWAY_PHY) += intel-xway.o obj-$(CONFIG_MDIO_HISI_FEMAC) += mdio-hisi-femac.o obj-$(CONFIG_MDIO_XGENE) += mdio-xgene.o +obj-$(CONFIG_XILINX_GMII2RGMII) += xilinx_gmii2rgmii.o diff --git a/drivers/net/phy/xilinx_gmii2rgmii.c b/drivers/net/phy/xilinx_gmii2rgmii.c new file mode 100644 index 0000000..8e980ad --- /dev/null +++ b/drivers/net/phy/xilinx_gmii2rgmii.c @@ -0,0 +1,109 @@ +/* Xilinx GMII2RGMII Converter driver + * + * Copyright (C) 2016 Xilinx, Inc. + * + * Author: Kedareswara rao Appana + * + * Description: + * This driver is developed for Xilinx GMII2RGMII Converter + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ +#include +#include +#include +#include +#include +#include + +#define XILINX_GMII2RGMII_REG 0x10 +#define XILINX_GMII2RGMII_SPEED_MASK (BMCR_SPEED1000 | BMCR_SPEED100) + +struct gmii2rgmii { + struct phy_device *phy_dev; + struct phy_driver *phy_drv; + struct phy_driver conv_phy_drv; + int addr; +}; + +static int xgmiitorgmii_read_status(struct phy_device *phydev) +{ + struct gmii2rgmii *priv = phydev->priv; + u16 val = 0; + + priv->phy_drv->read_status(phydev); + + val = mdiobus_read(phydev->mdio.bus, priv->addr, XILINX_GMII2RGMII_REG); + val &= XILINX_GMII2RGMII_SPEED_MASK; + + if (phydev->speed == SPEED_1000) + val |= BMCR_SPEED1000; + else if (phydev->speed == SPEED_100) + val |= BMCR_SPEED100; + else + val |= BMCR_SPEED10; + + mdiobus_write(phydev->mdio.bus, priv->addr, XILINX_GMII2RGMII_REG, val); + + return 0; +} + +int xgmiitorgmii_probe(struct mdio_device *mdiodev) +{ + struct device *dev = &mdiodev->dev; + struct device_node *np = dev->of_node, *phy_node; + struct gmii2rgmii *priv; + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + phy_node = of_parse_phandle(np, "phy-handle", 0); + if (IS_ERR(phy_node)) { + dev_err(dev, "Couldn't parse phy-handle\n"); + return -ENODEV; + } + + priv->phy_dev = of_phy_find_device(phy_node); + if (!priv->phy_dev) { + dev_info(dev, "Couldn't find phydev\n"); + return -EPROBE_DEFER; + } + + priv->addr = mdiodev->addr; + priv->phy_drv = priv->phy_dev->drv; + memcpy(&priv->conv_phy_drv, priv->phy_dev->drv, + sizeof(struct phy_driver)); + priv->conv_phy_drv.read_status = xgmiitorgmii_read_status; + priv->phy_dev->priv = priv; + priv->phy_dev->drv = &priv->conv_phy_drv; + + return 0; +} + +static const struct of_device_id xgmiitorgmii_of_match[] = { + { .compatible = "xlnx,gmii-to-rgmii-1.0" }, + {}, +}; +MODULE_DEVICE_TABLE(of, xgmiitorgmii_of_match); + +static struct mdio_driver xgmiitorgmii_driver = { + .probe = xgmiitorgmii_probe, + .mdiodrv.driver = { + .name = "xgmiitorgmii", + .of_match_table = xgmiitorgmii_of_match, + }, +}; + +mdio_module_driver(xgmiitorgmii_driver); + +MODULE_DESCRIPTION("Xilinx GMII2RGMII converter driver"); +MODULE_LICENSE("GPL");