From patchwork Tue Aug 9 09:34:43 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: 9270741 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 C4E5660754 for ; Tue, 9 Aug 2016 09:37:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B48E320265 for ; Tue, 9 Aug 2016 09:37:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7BF028327; Tue, 9 Aug 2016 09:37:57 +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=unavailable 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 767E820265 for ; Tue, 9 Aug 2016 09:37:55 +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 1bX3SG-0002vU-UO; Tue, 09 Aug 2016 09:36:12 +0000 Received: from mail-cys01nam02on0600.outbound.protection.outlook.com ([2a01:111:f400:fe45::600] helo=NAM02-CY1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bX3RP-0001A4-Eb for linux-arm-kernel@lists.infradead.org; Tue, 09 Aug 2016 09:35:22 +0000 Received: from CY1NAM02FT053.eop-nam02.prod.protection.outlook.com (10.152.74.58) by CY1NAM02HT023.eop-nam02.prod.protection.outlook.com (10.152.75.56) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.567.7; Tue, 9 Aug 2016 09:34:56 +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 CY1NAM02FT053.mail.protection.outlook.com (10.152.74.165) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.567.7 via Frontend Transport; Tue, 9 Aug 2016 09:34:53 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66]:50782 helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw02 with esmtp (Exim 4.63) (envelope-from ) id 1bX3Qz-0005fk-67; Tue, 09 Aug 2016 02:34:53 -0700 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1bX3Qy-0001id-He; Tue, 09 Aug 2016 02:34:52 -0700 Received: from xsj-pvapsmtp01 (xsj-mail.xilinx.com [149.199.38.66]) by xsj-smtp-dlp1.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id u799YmXE011267; Tue, 9 Aug 2016 02:34:48 -0700 Received: from [172.23.64.208] (helo=xhdrdevl6.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1bX3Qt-0001ed-Rx; Tue, 09 Aug 2016 02:34:48 -0700 Received: by xhdrdevl6.xilinx.com (Postfix, from userid 13614) id AF60CF2000A; Tue, 9 Aug 2016 15:04:46 +0530 (IST) From: Kedareswara rao Appana To: , , , , , , , Subject: [RFC PATCH v5 3/3] net: phy: Add gmiitorgmii converter support Date: Tue, 9 Aug 2016 15:04:43 +0530 Message-ID: <1470735283-23611-4-git-send-email-appanad@xilinx.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1470735283-23611-1-git-send-email-appanad@xilinx.com> References: <1470735283-23611-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)(50944005)(189002)(199003)(81156014)(36756003)(4326007)(8676002)(229853001)(2906002)(46386002)(2950100001)(5001770100001)(2201001)(8936002)(63266004)(33646002)(19580405001)(90966002)(305945005)(7846002)(19580395003)(52956003)(47776003)(86362001)(42186005)(92566002)(106466001)(50466002)(48376002)(81166006)(103686003)(189998001)(45336002)(356003)(87936001)(36386004)(5003940100001)(586003)(4001450100002)(76176999)(50986999)(50226002)(107986001)(2004002)(2101003)(5001870100001)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1NAM02HT023; H:xsj-pvapsmtpgw02; FPR:; SPF:Pass; PTR:unknown-60-100.xilinx.com,xapps1.xilinx.com; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CY1NAM02FT053; 1:k6jtH9dnCYbUC6eI897IkNvcVwng8OWl8dGzfSpPz3XxLEJ7DwSB5wLQ1aZ1CurF0r4tvGsMpCJShrpHPJoPZZq+hEtoR6/tB1rIzwJrqQy9IHMnHe7RTe08vvLExOOOIy6igHzzLTM9x7v0EqGzZPDmFaQq8R45LdQMBHYiL9hAeEBA4DD8qt+uLsbrFSBqI4anD2pCKdKElRwbWtFBpYT339RImfz4kidee91PJFODjMwhWYwiWlF7hO7Y+eNwnitPp0nBz9IUW62t1RzqKbOqc6r8sGJsxJuR3PI2Tn1HNe2oEz1MldrD5nMBn6VuLeCQvHX+Bp0ajHF2KEh1hMYIZbeLwEPvzC4CgiWMcMHW+tlSOdI3QqtVaqd1QxYTLGl3ylq0l9nTMdcuAOJ2uagZriIiw/VqFsaeIvgDTTtkCuTxSjOAU4RMqCyrxXIHr2JWJAtefRA4eIAiK+YixGLbEmLSd2Y/5xapKpmvUGsUiU4ouFSxNPHx+w0lXHpmsXt83eqXGKCD7Bnw/jwREm53i4E0eGUIcWHiqt6AGRb9Y0AUJjD96QOnPRciCxWD0090zmOudzfSnimbKCuDTUz5IJTtUv+WfhV6Afk/QyG3ZEhA+L2Zk8eMvB8gBwUO MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 7c7c417a-98e7-4ae5-360b-08d3c0386d10 X-Microsoft-Exchange-Diagnostics: 1; CY1NAM02HT023; 2:MQRQvO6Dqok+A2elE0a9qgWb0nkfifhN9kIIk6NRzFEgNFt8NhXsRegL+7XU5AcT8y7TuL2AGfARuCt4DYIie9ExsHhFUoerMwZrPFjpInsckvHhftXjZWB7nqHQ1eZohO+rfsywsER+K/vfMQq0pDjfq2fnv9C4p4YpJDGKebps+iqB9B6Fn4E24Ocn78xK; 3:UKaG7N/PpRV1zHSw8EC+1uddr6mu3MiIsdG5AuK88G/+a8WYlUqxO5gmGec1G+IKR47nA4ewDMolVp7FQgwcHGLrMsJkWSXOEyPLZhYPKwF5EEGi2kV9XuhIWm2JdTUHQg9ziBvQl/Cu6NMMtsUogNDIXXmOsbvxlIbh1PHuQvvioYpRhVBewDDEY9+LbxbbJCxEYFzHD1oFdEOKtBHnaAx8MIC4KBKKELN377ygN9HESuz09NYTqxaXq6VBhcOb2q+jEn8x1XaAKJaVqKUgEw== X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501002); SRVR:CY1NAM02HT023; X-Microsoft-Exchange-Diagnostics: 1; CY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JiacWX9ceKW0PFaIpuGEWxcodR6yaWxZWr8XtX9A0neMZY2KhjP3/U0n0v/WM+I+OwfuAoRIs34cGn6ZeLSYMwfxzSRFOubUbnaZ1DcnIJNXSJ2N054qmRMeBjhD6gicC87o/D0nlQ7+KhICtCAlGbhAqa5xsiqD0aJu9gpnC5jehkdZ9egSL6m92NrDYmK+zvMKYe/ea/92sW2HZM2W8dGVL+9RzZqLJcW9E6aRJGqOZn+WXC3tsz6HuMppX2ohKjMB2Gqd0JCw/FrlztDVrWod5FPnved/qqMfHR638gLEcmO0m+nY1OKcfBnkZ0A0/gTI0KPuzjaQXOGLbPAJUkLBC+qS2vpAkCCli9srw8DA8gYt4K/ID6Ld3ygwYM5RWEJPyXz+7VcpU9UobkrVROF7pzExdr1Zikl+pnGY1inH9E3lP0MF3hux9aXcxgmAV3pZWEaAXoz2gIioSayPPZ8CJFZ2yX+gKaUlj29ijYWeiMRWPN9MX75 X-Microsoft-Antispam-PRVS: <8a0c891a8d4f43aabcd5705eaa1462ee@CY1NAM02HT023.eop-nam02.prod.protection.outlook.com> X-Exchange-Antispam-Report-Test: UriScan:(192813158149592); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040161)(601004)(2401047)(13018025)(8121501046)(13017025)(13024025)(13023025)(5005006)(13015025)(10201501046)(3002001)(6055026); SRVR:CY1NAM02HT023; BCL:0; PCL:0; RULEID:; SRVR:CY1NAM02HT023; X-Microsoft-Exchange-Diagnostics: 1; CY1NAM02HT023; 4:U4lVZzHw7WCnBBzhqPP7WWMp6KgvQwCSXv82+HwLk+aR6aSaWqyuugITaCYlDOwxfz75VlqAw32kcZGbQlxyYgDWcNj8AtiVp1p55KI5gxWCNQniVyXj1T25fsLIWMa4f2iFO5kBq4ZWeCURZZE9Y/iXFBpY4R1UaxEpqJxfX8wyfBJcR8MEiDeF6RdABbFvJ3hSffeoNE6t7yv+TVo2CXRrDtZVaGuu5p0rK4CQTXF8wR+mXWGvGynMhKkGXoh8IjWEy6NtyE1oqz4nyFVyierf5T0vQ655XY87HloqtBRABmuPFOjk9uKUPeDH2UFm7DLuvNSjvAlmiY6zwCp9L0EGtFHHZi/8p7wTByM8GGGuMCPMSGtKiOOqpmhNzEWHpO0+ZSwZJb1QLinOUOcYC0/NlMBRqgcE6poEg6vwIAYoTGhdNgeBx8uy2XvC5PLADPMgSHS++TQ+EPhSlc6PcqoqH6UppfwSM8vcQDjZriztM3ppS6M9RHxybRvznVblil3mDWgs8u8ZPeGaQG1shJtQq4MSWol4CN3rqX6drjE= X-Forefront-PRVS: 0029F17A3F X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1NAM02HT023; 23:8nttNgm+Qe6u/YmixmSKJ3MXgrAgmhi7Y3igVebU/?= =?us-ascii?Q?lgs47pplgSF8ifyU71FnKlRsc0tDzSo2VUyFWkdSVs4EGfZXvJ3XOi0jjB2l?= =?us-ascii?Q?Tggg0iZuv+XFah4bwCC7CNwnLLzgArVbpfpnfbebhCIrQV1I/vqS0eDTR2AW?= =?us-ascii?Q?uwN0Ep5niSZZhRrgCKQht6MPyCZzg4HGI67icK1nieHEoso63YWb+gjreCXI?= =?us-ascii?Q?fn0KHJxBMoTVgzm+AH5s4BtpVEz2XP2hZP9ai4Q0VXLAQjBFE+TdGyIg4eGA?= =?us-ascii?Q?4vUPxADqwqUmQUDO3hQo949zio1ynZuy/Qx8Y35FotkHbxj/E2ccy/tk9Ndh?= =?us-ascii?Q?lfWlGGFtQxNIg4AwiDgNXzMnIu14OuCjfFsJi6iXJ9kxktPQ+RqaX3cjIFU1?= =?us-ascii?Q?LxFy7hz3RCnEwz5gQmcmID+X1Jw944i9W/KwdFKv5gEQHNdCmI5X8p32cvw7?= =?us-ascii?Q?Ht1onVWxz7aNkjETicphNgErMIZYctXYrhbX/nRBas7zkkNbKPfg77YXT7ZM?= =?us-ascii?Q?0LJkKQtBjxHDAtnYctkCxNHMw/5OQJZ64TVtD4nteXxosb0dv2mE/TILydaJ?= =?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zEK94ERDnG4BcFfpRxlU+tQd8AW5tI1i5mTZJfdiLB3YVxDK4t6c/L9vRr+f5fXwJIwGDRFgNDBvTEwVzecPnR1tPg8D6HV6oaqX5wnUEN7NjVZAEpgTEsTaYZWQO0pCqE1drKfYwu7hs1ZPgWyrxohuQ3ThFMLdhplffeuWDxw==; 5:La8k8tY9D8ClyDedB5V3552lIrxdgeDXLuaCAZtUSjCDPzO7gVccBo5QvxW5u2snNykpglyb6OCMxP5c+MSd7PvYabqxUs/OfCKfWsJyHGBTwqHfBjaWwxiSyoU3lET5AfH/iNmvUDr44IxaUoIl4Q==; 24:+90YxDOYv36gOVJVYbVzOBZamfFLSAWW20Xq9s+wTO5sWDyhDdGc0/zhPi4bmYX9r0yMt4IxDG6XDaAYDbyQ6UCNJJ67djPvXScd+Qou6ME=; 7:z+vSiKvLiw8s1o96s46NsNgzH8Uyt8avXH5nfR2RFaOcbZNzNpJiPlIOPNDEittACTX8yjTOJIBd8p7JvwenXKXNwAsHasSn63cD9ECidoTt6hyi7JOjejMJevTyB8QgZXKfi/EGpMPmLRkzuhw7SF0haRYOJ7QLo4HhpF+/ZWx4Bv9+rhfPlh9iorIKIZywlpibXnGQc6P4z19YlO8DqwHG+n2lr6CFB8osRqfbTXu815YQczgicUBxyQiZwZu5 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2016 09:34:53.9325 (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: CY1NAM02HT023 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160809_023519_730143_3CBE4ABA X-CRM114-Status: GOOD ( 17.63 ) 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 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 | 8 +++ drivers/net/phy/Makefile | 1 + drivers/net/phy/xilinx_gmii2rgmii.c | 121 ++++++++++++++++++++++++++++++++++++ 3 files changed, 130 insertions(+) create mode 100644 drivers/net/phy/xilinx_gmii2rgmii.c diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index 1b534ea..c79f347 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig @@ -312,6 +312,14 @@ config MICROSEMI_PHY ---help--- Currently supports the VSC8531 and VSC8541 PHYs +config XILINX_GMII2RGMII + tristate "Xilinx GMII2RGMII converter driver" + default y + ---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..1456e27 --- /dev/null +++ b/drivers/net/phy/xilinx_gmii2rgmii.c @@ -0,0 +1,121 @@ +/* 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 0x2040 + +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 = (struct gmii2rgmii *)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; + + switch (phydev->speed) { + case SPEED_1000: + val |= BMCR_SPEED1000; + case SPEED_100: + val |= BMCR_SPEED100; + case SPEED_10: + 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, + }, +}; + +static int __init xgmiitorgmii_init(void) +{ + return mdio_driver_register(&xgmiitorgmii_driver); +} +module_init(xgmiitorgmii_init); + +static void __exit xgmiitorgmii_cleanup(void) +{ + mdio_driver_unregister(&xgmiitorgmii_driver); +} +module_exit(xgmiitorgmii_cleanup); + +MODULE_DESCRIPTION("Xilinx GMII2RGMII converter driver"); +MODULE_LICENSE("GPL");