18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * AMD 10Gb Ethernet driver
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * This file is available to you under your choice of the following two
58c2ecf20Sopenharmony_ci * licenses:
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * License 1: GPLv2
88c2ecf20Sopenharmony_ci *
98c2ecf20Sopenharmony_ci * Copyright (c) 2014-2016 Advanced Micro Devices, Inc.
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci * This file is free software; you may copy, redistribute and/or modify
128c2ecf20Sopenharmony_ci * it under the terms of the GNU General Public License as published by
138c2ecf20Sopenharmony_ci * the Free Software Foundation, either version 2 of the License, or (at
148c2ecf20Sopenharmony_ci * your option) any later version.
158c2ecf20Sopenharmony_ci *
168c2ecf20Sopenharmony_ci * This file is distributed in the hope that it will be useful, but
178c2ecf20Sopenharmony_ci * WITHOUT ANY WARRANTY; without even the implied warranty of
188c2ecf20Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
198c2ecf20Sopenharmony_ci * General Public License for more details.
208c2ecf20Sopenharmony_ci *
218c2ecf20Sopenharmony_ci * You should have received a copy of the GNU General Public License
228c2ecf20Sopenharmony_ci * along with this program.  If not, see <http://www.gnu.org/licenses/>.
238c2ecf20Sopenharmony_ci *
248c2ecf20Sopenharmony_ci * This file incorporates work covered by the following copyright and
258c2ecf20Sopenharmony_ci * permission notice:
268c2ecf20Sopenharmony_ci *     The Synopsys DWC ETHER XGMAC Software Driver and documentation
278c2ecf20Sopenharmony_ci *     (hereinafter "Software") is an unsupported proprietary work of Synopsys,
288c2ecf20Sopenharmony_ci *     Inc. unless otherwise expressly agreed to in writing between Synopsys
298c2ecf20Sopenharmony_ci *     and you.
308c2ecf20Sopenharmony_ci *
318c2ecf20Sopenharmony_ci *     The Software IS NOT an item of Licensed Software or Licensed Product
328c2ecf20Sopenharmony_ci *     under any End User Software License Agreement or Agreement for Licensed
338c2ecf20Sopenharmony_ci *     Product with Synopsys or any supplement thereto.  Permission is hereby
348c2ecf20Sopenharmony_ci *     granted, free of charge, to any person obtaining a copy of this software
358c2ecf20Sopenharmony_ci *     annotated with this license and the Software, to deal in the Software
368c2ecf20Sopenharmony_ci *     without restriction, including without limitation the rights to use,
378c2ecf20Sopenharmony_ci *     copy, modify, merge, publish, distribute, sublicense, and/or sell copies
388c2ecf20Sopenharmony_ci *     of the Software, and to permit persons to whom the Software is furnished
398c2ecf20Sopenharmony_ci *     to do so, subject to the following conditions:
408c2ecf20Sopenharmony_ci *
418c2ecf20Sopenharmony_ci *     The above copyright notice and this permission notice shall be included
428c2ecf20Sopenharmony_ci *     in all copies or substantial portions of the Software.
438c2ecf20Sopenharmony_ci *
448c2ecf20Sopenharmony_ci *     THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"
458c2ecf20Sopenharmony_ci *     BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
468c2ecf20Sopenharmony_ci *     TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
478c2ecf20Sopenharmony_ci *     PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS
488c2ecf20Sopenharmony_ci *     BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
498c2ecf20Sopenharmony_ci *     CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
508c2ecf20Sopenharmony_ci *     SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
518c2ecf20Sopenharmony_ci *     INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
528c2ecf20Sopenharmony_ci *     CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
538c2ecf20Sopenharmony_ci *     ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
548c2ecf20Sopenharmony_ci *     THE POSSIBILITY OF SUCH DAMAGE.
558c2ecf20Sopenharmony_ci *
568c2ecf20Sopenharmony_ci *
578c2ecf20Sopenharmony_ci * License 2: Modified BSD
588c2ecf20Sopenharmony_ci *
598c2ecf20Sopenharmony_ci * Copyright (c) 2014-2016 Advanced Micro Devices, Inc.
608c2ecf20Sopenharmony_ci * All rights reserved.
618c2ecf20Sopenharmony_ci *
628c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or without
638c2ecf20Sopenharmony_ci * modification, are permitted provided that the following conditions are met:
648c2ecf20Sopenharmony_ci *     * Redistributions of source code must retain the above copyright
658c2ecf20Sopenharmony_ci *       notice, this list of conditions and the following disclaimer.
668c2ecf20Sopenharmony_ci *     * Redistributions in binary form must reproduce the above copyright
678c2ecf20Sopenharmony_ci *       notice, this list of conditions and the following disclaimer in the
688c2ecf20Sopenharmony_ci *       documentation and/or other materials provided with the distribution.
698c2ecf20Sopenharmony_ci *     * Neither the name of Advanced Micro Devices, Inc. nor the
708c2ecf20Sopenharmony_ci *       names of its contributors may be used to endorse or promote products
718c2ecf20Sopenharmony_ci *       derived from this software without specific prior written permission.
728c2ecf20Sopenharmony_ci *
738c2ecf20Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
748c2ecf20Sopenharmony_ci * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
758c2ecf20Sopenharmony_ci * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
768c2ecf20Sopenharmony_ci * ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
778c2ecf20Sopenharmony_ci * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
788c2ecf20Sopenharmony_ci * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
798c2ecf20Sopenharmony_ci * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
808c2ecf20Sopenharmony_ci * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
818c2ecf20Sopenharmony_ci * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
828c2ecf20Sopenharmony_ci * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
838c2ecf20Sopenharmony_ci *
848c2ecf20Sopenharmony_ci * This file incorporates work covered by the following copyright and
858c2ecf20Sopenharmony_ci * permission notice:
868c2ecf20Sopenharmony_ci *     The Synopsys DWC ETHER XGMAC Software Driver and documentation
878c2ecf20Sopenharmony_ci *     (hereinafter "Software") is an unsupported proprietary work of Synopsys,
888c2ecf20Sopenharmony_ci *     Inc. unless otherwise expressly agreed to in writing between Synopsys
898c2ecf20Sopenharmony_ci *     and you.
908c2ecf20Sopenharmony_ci *
918c2ecf20Sopenharmony_ci *     The Software IS NOT an item of Licensed Software or Licensed Product
928c2ecf20Sopenharmony_ci *     under any End User Software License Agreement or Agreement for Licensed
938c2ecf20Sopenharmony_ci *     Product with Synopsys or any supplement thereto.  Permission is hereby
948c2ecf20Sopenharmony_ci *     granted, free of charge, to any person obtaining a copy of this software
958c2ecf20Sopenharmony_ci *     annotated with this license and the Software, to deal in the Software
968c2ecf20Sopenharmony_ci *     without restriction, including without limitation the rights to use,
978c2ecf20Sopenharmony_ci *     copy, modify, merge, publish, distribute, sublicense, and/or sell copies
988c2ecf20Sopenharmony_ci *     of the Software, and to permit persons to whom the Software is furnished
998c2ecf20Sopenharmony_ci *     to do so, subject to the following conditions:
1008c2ecf20Sopenharmony_ci *
1018c2ecf20Sopenharmony_ci *     The above copyright notice and this permission notice shall be included
1028c2ecf20Sopenharmony_ci *     in all copies or substantial portions of the Software.
1038c2ecf20Sopenharmony_ci *
1048c2ecf20Sopenharmony_ci *     THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"
1058c2ecf20Sopenharmony_ci *     BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
1068c2ecf20Sopenharmony_ci *     TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
1078c2ecf20Sopenharmony_ci *     PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS
1088c2ecf20Sopenharmony_ci *     BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1098c2ecf20Sopenharmony_ci *     CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1108c2ecf20Sopenharmony_ci *     SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1118c2ecf20Sopenharmony_ci *     INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1128c2ecf20Sopenharmony_ci *     CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1138c2ecf20Sopenharmony_ci *     ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
1148c2ecf20Sopenharmony_ci *     THE POSSIBILITY OF SUCH DAMAGE.
1158c2ecf20Sopenharmony_ci */
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ci#include <linux/module.h>
1188c2ecf20Sopenharmony_ci#include <linux/device.h>
1198c2ecf20Sopenharmony_ci#include <linux/platform_device.h>
1208c2ecf20Sopenharmony_ci#include <linux/spinlock.h>
1218c2ecf20Sopenharmony_ci#include <linux/netdevice.h>
1228c2ecf20Sopenharmony_ci#include <linux/etherdevice.h>
1238c2ecf20Sopenharmony_ci#include <linux/io.h>
1248c2ecf20Sopenharmony_ci#include <linux/of.h>
1258c2ecf20Sopenharmony_ci#include <linux/of_net.h>
1268c2ecf20Sopenharmony_ci#include <linux/of_address.h>
1278c2ecf20Sopenharmony_ci#include <linux/of_platform.h>
1288c2ecf20Sopenharmony_ci#include <linux/of_device.h>
1298c2ecf20Sopenharmony_ci#include <linux/clk.h>
1308c2ecf20Sopenharmony_ci#include <linux/property.h>
1318c2ecf20Sopenharmony_ci#include <linux/acpi.h>
1328c2ecf20Sopenharmony_ci#include <linux/mdio.h>
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ci#include "xgbe.h"
1358c2ecf20Sopenharmony_ci#include "xgbe-common.h"
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_ci#ifdef CONFIG_ACPI
1388c2ecf20Sopenharmony_cistatic const struct acpi_device_id xgbe_acpi_match[];
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_cistatic struct xgbe_version_data *xgbe_acpi_vdata(struct xgbe_prv_data *pdata)
1418c2ecf20Sopenharmony_ci{
1428c2ecf20Sopenharmony_ci	const struct acpi_device_id *id;
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_ci	id = acpi_match_device(xgbe_acpi_match, pdata->dev);
1458c2ecf20Sopenharmony_ci
1468c2ecf20Sopenharmony_ci	return id ? (struct xgbe_version_data *)id->driver_data : NULL;
1478c2ecf20Sopenharmony_ci}
1488c2ecf20Sopenharmony_ci
1498c2ecf20Sopenharmony_cistatic int xgbe_acpi_support(struct xgbe_prv_data *pdata)
1508c2ecf20Sopenharmony_ci{
1518c2ecf20Sopenharmony_ci	struct device *dev = pdata->dev;
1528c2ecf20Sopenharmony_ci	u32 property;
1538c2ecf20Sopenharmony_ci	int ret;
1548c2ecf20Sopenharmony_ci
1558c2ecf20Sopenharmony_ci	/* Obtain the system clock setting */
1568c2ecf20Sopenharmony_ci	ret = device_property_read_u32(dev, XGBE_ACPI_DMA_FREQ, &property);
1578c2ecf20Sopenharmony_ci	if (ret) {
1588c2ecf20Sopenharmony_ci		dev_err(dev, "unable to obtain %s property\n",
1598c2ecf20Sopenharmony_ci			XGBE_ACPI_DMA_FREQ);
1608c2ecf20Sopenharmony_ci		return ret;
1618c2ecf20Sopenharmony_ci	}
1628c2ecf20Sopenharmony_ci	pdata->sysclk_rate = property;
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_ci	/* Obtain the PTP clock setting */
1658c2ecf20Sopenharmony_ci	ret = device_property_read_u32(dev, XGBE_ACPI_PTP_FREQ, &property);
1668c2ecf20Sopenharmony_ci	if (ret) {
1678c2ecf20Sopenharmony_ci		dev_err(dev, "unable to obtain %s property\n",
1688c2ecf20Sopenharmony_ci			XGBE_ACPI_PTP_FREQ);
1698c2ecf20Sopenharmony_ci		return ret;
1708c2ecf20Sopenharmony_ci	}
1718c2ecf20Sopenharmony_ci	pdata->ptpclk_rate = property;
1728c2ecf20Sopenharmony_ci
1738c2ecf20Sopenharmony_ci	return 0;
1748c2ecf20Sopenharmony_ci}
1758c2ecf20Sopenharmony_ci#else   /* CONFIG_ACPI */
1768c2ecf20Sopenharmony_cistatic struct xgbe_version_data *xgbe_acpi_vdata(struct xgbe_prv_data *pdata)
1778c2ecf20Sopenharmony_ci{
1788c2ecf20Sopenharmony_ci	return NULL;
1798c2ecf20Sopenharmony_ci}
1808c2ecf20Sopenharmony_ci
1818c2ecf20Sopenharmony_cistatic int xgbe_acpi_support(struct xgbe_prv_data *pdata)
1828c2ecf20Sopenharmony_ci{
1838c2ecf20Sopenharmony_ci	return -EINVAL;
1848c2ecf20Sopenharmony_ci}
1858c2ecf20Sopenharmony_ci#endif  /* CONFIG_ACPI */
1868c2ecf20Sopenharmony_ci
1878c2ecf20Sopenharmony_ci#ifdef CONFIG_OF
1888c2ecf20Sopenharmony_cistatic const struct of_device_id xgbe_of_match[];
1898c2ecf20Sopenharmony_ci
1908c2ecf20Sopenharmony_cistatic struct xgbe_version_data *xgbe_of_vdata(struct xgbe_prv_data *pdata)
1918c2ecf20Sopenharmony_ci{
1928c2ecf20Sopenharmony_ci	const struct of_device_id *id;
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_ci	id = of_match_device(xgbe_of_match, pdata->dev);
1958c2ecf20Sopenharmony_ci
1968c2ecf20Sopenharmony_ci	return id ? (struct xgbe_version_data *)id->data : NULL;
1978c2ecf20Sopenharmony_ci}
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_cistatic int xgbe_of_support(struct xgbe_prv_data *pdata)
2008c2ecf20Sopenharmony_ci{
2018c2ecf20Sopenharmony_ci	struct device *dev = pdata->dev;
2028c2ecf20Sopenharmony_ci
2038c2ecf20Sopenharmony_ci	/* Obtain the system clock setting */
2048c2ecf20Sopenharmony_ci	pdata->sysclk = devm_clk_get(dev, XGBE_DMA_CLOCK);
2058c2ecf20Sopenharmony_ci	if (IS_ERR(pdata->sysclk)) {
2068c2ecf20Sopenharmony_ci		dev_err(dev, "dma devm_clk_get failed\n");
2078c2ecf20Sopenharmony_ci		return PTR_ERR(pdata->sysclk);
2088c2ecf20Sopenharmony_ci	}
2098c2ecf20Sopenharmony_ci	pdata->sysclk_rate = clk_get_rate(pdata->sysclk);
2108c2ecf20Sopenharmony_ci
2118c2ecf20Sopenharmony_ci	/* Obtain the PTP clock setting */
2128c2ecf20Sopenharmony_ci	pdata->ptpclk = devm_clk_get(dev, XGBE_PTP_CLOCK);
2138c2ecf20Sopenharmony_ci	if (IS_ERR(pdata->ptpclk)) {
2148c2ecf20Sopenharmony_ci		dev_err(dev, "ptp devm_clk_get failed\n");
2158c2ecf20Sopenharmony_ci		return PTR_ERR(pdata->ptpclk);
2168c2ecf20Sopenharmony_ci	}
2178c2ecf20Sopenharmony_ci	pdata->ptpclk_rate = clk_get_rate(pdata->ptpclk);
2188c2ecf20Sopenharmony_ci
2198c2ecf20Sopenharmony_ci	return 0;
2208c2ecf20Sopenharmony_ci}
2218c2ecf20Sopenharmony_ci
2228c2ecf20Sopenharmony_cistatic struct platform_device *xgbe_of_get_phy_pdev(struct xgbe_prv_data *pdata)
2238c2ecf20Sopenharmony_ci{
2248c2ecf20Sopenharmony_ci	struct device *dev = pdata->dev;
2258c2ecf20Sopenharmony_ci	struct device_node *phy_node;
2268c2ecf20Sopenharmony_ci	struct platform_device *phy_pdev;
2278c2ecf20Sopenharmony_ci
2288c2ecf20Sopenharmony_ci	phy_node = of_parse_phandle(dev->of_node, "phy-handle", 0);
2298c2ecf20Sopenharmony_ci	if (phy_node) {
2308c2ecf20Sopenharmony_ci		/* Old style device tree:
2318c2ecf20Sopenharmony_ci		 *   The XGBE and PHY resources are separate
2328c2ecf20Sopenharmony_ci		 */
2338c2ecf20Sopenharmony_ci		phy_pdev = of_find_device_by_node(phy_node);
2348c2ecf20Sopenharmony_ci		of_node_put(phy_node);
2358c2ecf20Sopenharmony_ci	} else {
2368c2ecf20Sopenharmony_ci		/* New style device tree:
2378c2ecf20Sopenharmony_ci		 *   The XGBE and PHY resources are grouped together with
2388c2ecf20Sopenharmony_ci		 *   the PHY resources listed last
2398c2ecf20Sopenharmony_ci		 */
2408c2ecf20Sopenharmony_ci		get_device(dev);
2418c2ecf20Sopenharmony_ci		phy_pdev = pdata->platdev;
2428c2ecf20Sopenharmony_ci	}
2438c2ecf20Sopenharmony_ci
2448c2ecf20Sopenharmony_ci	return phy_pdev;
2458c2ecf20Sopenharmony_ci}
2468c2ecf20Sopenharmony_ci#else   /* CONFIG_OF */
2478c2ecf20Sopenharmony_cistatic struct xgbe_version_data *xgbe_of_vdata(struct xgbe_prv_data *pdata)
2488c2ecf20Sopenharmony_ci{
2498c2ecf20Sopenharmony_ci	return NULL;
2508c2ecf20Sopenharmony_ci}
2518c2ecf20Sopenharmony_ci
2528c2ecf20Sopenharmony_cistatic int xgbe_of_support(struct xgbe_prv_data *pdata)
2538c2ecf20Sopenharmony_ci{
2548c2ecf20Sopenharmony_ci	return -EINVAL;
2558c2ecf20Sopenharmony_ci}
2568c2ecf20Sopenharmony_ci
2578c2ecf20Sopenharmony_cistatic struct platform_device *xgbe_of_get_phy_pdev(struct xgbe_prv_data *pdata)
2588c2ecf20Sopenharmony_ci{
2598c2ecf20Sopenharmony_ci	return NULL;
2608c2ecf20Sopenharmony_ci}
2618c2ecf20Sopenharmony_ci#endif  /* CONFIG_OF */
2628c2ecf20Sopenharmony_ci
2638c2ecf20Sopenharmony_cistatic unsigned int xgbe_resource_count(struct platform_device *pdev,
2648c2ecf20Sopenharmony_ci					unsigned int type)
2658c2ecf20Sopenharmony_ci{
2668c2ecf20Sopenharmony_ci	unsigned int count;
2678c2ecf20Sopenharmony_ci	int i;
2688c2ecf20Sopenharmony_ci
2698c2ecf20Sopenharmony_ci	for (i = 0, count = 0; i < pdev->num_resources; i++) {
2708c2ecf20Sopenharmony_ci		struct resource *res = &pdev->resource[i];
2718c2ecf20Sopenharmony_ci
2728c2ecf20Sopenharmony_ci		if (type == resource_type(res))
2738c2ecf20Sopenharmony_ci			count++;
2748c2ecf20Sopenharmony_ci	}
2758c2ecf20Sopenharmony_ci
2768c2ecf20Sopenharmony_ci	return count;
2778c2ecf20Sopenharmony_ci}
2788c2ecf20Sopenharmony_ci
2798c2ecf20Sopenharmony_cistatic struct platform_device *xgbe_get_phy_pdev(struct xgbe_prv_data *pdata)
2808c2ecf20Sopenharmony_ci{
2818c2ecf20Sopenharmony_ci	struct platform_device *phy_pdev;
2828c2ecf20Sopenharmony_ci
2838c2ecf20Sopenharmony_ci	if (pdata->use_acpi) {
2848c2ecf20Sopenharmony_ci		get_device(pdata->dev);
2858c2ecf20Sopenharmony_ci		phy_pdev = pdata->platdev;
2868c2ecf20Sopenharmony_ci	} else {
2878c2ecf20Sopenharmony_ci		phy_pdev = xgbe_of_get_phy_pdev(pdata);
2888c2ecf20Sopenharmony_ci	}
2898c2ecf20Sopenharmony_ci
2908c2ecf20Sopenharmony_ci	return phy_pdev;
2918c2ecf20Sopenharmony_ci}
2928c2ecf20Sopenharmony_ci
2938c2ecf20Sopenharmony_cistatic struct xgbe_version_data *xgbe_get_vdata(struct xgbe_prv_data *pdata)
2948c2ecf20Sopenharmony_ci{
2958c2ecf20Sopenharmony_ci	return pdata->use_acpi ? xgbe_acpi_vdata(pdata)
2968c2ecf20Sopenharmony_ci			       : xgbe_of_vdata(pdata);
2978c2ecf20Sopenharmony_ci}
2988c2ecf20Sopenharmony_ci
2998c2ecf20Sopenharmony_cistatic int xgbe_platform_probe(struct platform_device *pdev)
3008c2ecf20Sopenharmony_ci{
3018c2ecf20Sopenharmony_ci	struct xgbe_prv_data *pdata;
3028c2ecf20Sopenharmony_ci	struct device *dev = &pdev->dev;
3038c2ecf20Sopenharmony_ci	struct platform_device *phy_pdev;
3048c2ecf20Sopenharmony_ci	const char *phy_mode;
3058c2ecf20Sopenharmony_ci	unsigned int phy_memnum, phy_irqnum;
3068c2ecf20Sopenharmony_ci	unsigned int dma_irqnum, dma_irqend;
3078c2ecf20Sopenharmony_ci	enum dev_dma_attr attr;
3088c2ecf20Sopenharmony_ci	int ret;
3098c2ecf20Sopenharmony_ci
3108c2ecf20Sopenharmony_ci	pdata = xgbe_alloc_pdata(dev);
3118c2ecf20Sopenharmony_ci	if (IS_ERR(pdata)) {
3128c2ecf20Sopenharmony_ci		ret = PTR_ERR(pdata);
3138c2ecf20Sopenharmony_ci		goto err_alloc;
3148c2ecf20Sopenharmony_ci	}
3158c2ecf20Sopenharmony_ci
3168c2ecf20Sopenharmony_ci	pdata->platdev = pdev;
3178c2ecf20Sopenharmony_ci	pdata->adev = ACPI_COMPANION(dev);
3188c2ecf20Sopenharmony_ci	platform_set_drvdata(pdev, pdata);
3198c2ecf20Sopenharmony_ci
3208c2ecf20Sopenharmony_ci	/* Check if we should use ACPI or DT */
3218c2ecf20Sopenharmony_ci	pdata->use_acpi = dev->of_node ? 0 : 1;
3228c2ecf20Sopenharmony_ci
3238c2ecf20Sopenharmony_ci	/* Get the version data */
3248c2ecf20Sopenharmony_ci	pdata->vdata = xgbe_get_vdata(pdata);
3258c2ecf20Sopenharmony_ci
3268c2ecf20Sopenharmony_ci	phy_pdev = xgbe_get_phy_pdev(pdata);
3278c2ecf20Sopenharmony_ci	if (!phy_pdev) {
3288c2ecf20Sopenharmony_ci		dev_err(dev, "unable to obtain phy device\n");
3298c2ecf20Sopenharmony_ci		ret = -EINVAL;
3308c2ecf20Sopenharmony_ci		goto err_phydev;
3318c2ecf20Sopenharmony_ci	}
3328c2ecf20Sopenharmony_ci	pdata->phy_platdev = phy_pdev;
3338c2ecf20Sopenharmony_ci	pdata->phy_dev = &phy_pdev->dev;
3348c2ecf20Sopenharmony_ci
3358c2ecf20Sopenharmony_ci	if (pdev == phy_pdev) {
3368c2ecf20Sopenharmony_ci		/* New style device tree or ACPI:
3378c2ecf20Sopenharmony_ci		 *   The XGBE and PHY resources are grouped together with
3388c2ecf20Sopenharmony_ci		 *   the PHY resources listed last
3398c2ecf20Sopenharmony_ci		 */
3408c2ecf20Sopenharmony_ci		phy_memnum = xgbe_resource_count(pdev, IORESOURCE_MEM) - 3;
3418c2ecf20Sopenharmony_ci		phy_irqnum = xgbe_resource_count(pdev, IORESOURCE_IRQ) - 1;
3428c2ecf20Sopenharmony_ci		dma_irqnum = 1;
3438c2ecf20Sopenharmony_ci		dma_irqend = phy_irqnum;
3448c2ecf20Sopenharmony_ci	} else {
3458c2ecf20Sopenharmony_ci		/* Old style device tree:
3468c2ecf20Sopenharmony_ci		 *   The XGBE and PHY resources are separate
3478c2ecf20Sopenharmony_ci		 */
3488c2ecf20Sopenharmony_ci		phy_memnum = 0;
3498c2ecf20Sopenharmony_ci		phy_irqnum = 0;
3508c2ecf20Sopenharmony_ci		dma_irqnum = 1;
3518c2ecf20Sopenharmony_ci		dma_irqend = xgbe_resource_count(pdev, IORESOURCE_IRQ);
3528c2ecf20Sopenharmony_ci	}
3538c2ecf20Sopenharmony_ci
3548c2ecf20Sopenharmony_ci	/* Obtain the mmio areas for the device */
3558c2ecf20Sopenharmony_ci	pdata->xgmac_regs = devm_platform_ioremap_resource(pdev, 0);
3568c2ecf20Sopenharmony_ci	if (IS_ERR(pdata->xgmac_regs)) {
3578c2ecf20Sopenharmony_ci		dev_err(dev, "xgmac ioremap failed\n");
3588c2ecf20Sopenharmony_ci		ret = PTR_ERR(pdata->xgmac_regs);
3598c2ecf20Sopenharmony_ci		goto err_io;
3608c2ecf20Sopenharmony_ci	}
3618c2ecf20Sopenharmony_ci	if (netif_msg_probe(pdata))
3628c2ecf20Sopenharmony_ci		dev_dbg(dev, "xgmac_regs = %p\n", pdata->xgmac_regs);
3638c2ecf20Sopenharmony_ci
3648c2ecf20Sopenharmony_ci	pdata->xpcs_regs = devm_platform_ioremap_resource(pdev, 1);
3658c2ecf20Sopenharmony_ci	if (IS_ERR(pdata->xpcs_regs)) {
3668c2ecf20Sopenharmony_ci		dev_err(dev, "xpcs ioremap failed\n");
3678c2ecf20Sopenharmony_ci		ret = PTR_ERR(pdata->xpcs_regs);
3688c2ecf20Sopenharmony_ci		goto err_io;
3698c2ecf20Sopenharmony_ci	}
3708c2ecf20Sopenharmony_ci	if (netif_msg_probe(pdata))
3718c2ecf20Sopenharmony_ci		dev_dbg(dev, "xpcs_regs  = %p\n", pdata->xpcs_regs);
3728c2ecf20Sopenharmony_ci
3738c2ecf20Sopenharmony_ci	pdata->rxtx_regs = devm_platform_ioremap_resource(phy_pdev,
3748c2ecf20Sopenharmony_ci							  phy_memnum++);
3758c2ecf20Sopenharmony_ci	if (IS_ERR(pdata->rxtx_regs)) {
3768c2ecf20Sopenharmony_ci		dev_err(dev, "rxtx ioremap failed\n");
3778c2ecf20Sopenharmony_ci		ret = PTR_ERR(pdata->rxtx_regs);
3788c2ecf20Sopenharmony_ci		goto err_io;
3798c2ecf20Sopenharmony_ci	}
3808c2ecf20Sopenharmony_ci	if (netif_msg_probe(pdata))
3818c2ecf20Sopenharmony_ci		dev_dbg(dev, "rxtx_regs  = %p\n", pdata->rxtx_regs);
3828c2ecf20Sopenharmony_ci
3838c2ecf20Sopenharmony_ci	pdata->sir0_regs = devm_platform_ioremap_resource(phy_pdev,
3848c2ecf20Sopenharmony_ci							  phy_memnum++);
3858c2ecf20Sopenharmony_ci	if (IS_ERR(pdata->sir0_regs)) {
3868c2ecf20Sopenharmony_ci		dev_err(dev, "sir0 ioremap failed\n");
3878c2ecf20Sopenharmony_ci		ret = PTR_ERR(pdata->sir0_regs);
3888c2ecf20Sopenharmony_ci		goto err_io;
3898c2ecf20Sopenharmony_ci	}
3908c2ecf20Sopenharmony_ci	if (netif_msg_probe(pdata))
3918c2ecf20Sopenharmony_ci		dev_dbg(dev, "sir0_regs  = %p\n", pdata->sir0_regs);
3928c2ecf20Sopenharmony_ci
3938c2ecf20Sopenharmony_ci	pdata->sir1_regs = devm_platform_ioremap_resource(phy_pdev,
3948c2ecf20Sopenharmony_ci							  phy_memnum++);
3958c2ecf20Sopenharmony_ci	if (IS_ERR(pdata->sir1_regs)) {
3968c2ecf20Sopenharmony_ci		dev_err(dev, "sir1 ioremap failed\n");
3978c2ecf20Sopenharmony_ci		ret = PTR_ERR(pdata->sir1_regs);
3988c2ecf20Sopenharmony_ci		goto err_io;
3998c2ecf20Sopenharmony_ci	}
4008c2ecf20Sopenharmony_ci	if (netif_msg_probe(pdata))
4018c2ecf20Sopenharmony_ci		dev_dbg(dev, "sir1_regs  = %p\n", pdata->sir1_regs);
4028c2ecf20Sopenharmony_ci
4038c2ecf20Sopenharmony_ci	/* Retrieve the MAC address */
4048c2ecf20Sopenharmony_ci	ret = device_property_read_u8_array(dev, XGBE_MAC_ADDR_PROPERTY,
4058c2ecf20Sopenharmony_ci					    pdata->mac_addr,
4068c2ecf20Sopenharmony_ci					    sizeof(pdata->mac_addr));
4078c2ecf20Sopenharmony_ci	if (ret || !is_valid_ether_addr(pdata->mac_addr)) {
4088c2ecf20Sopenharmony_ci		dev_err(dev, "invalid %s property\n", XGBE_MAC_ADDR_PROPERTY);
4098c2ecf20Sopenharmony_ci		if (!ret)
4108c2ecf20Sopenharmony_ci			ret = -EINVAL;
4118c2ecf20Sopenharmony_ci		goto err_io;
4128c2ecf20Sopenharmony_ci	}
4138c2ecf20Sopenharmony_ci
4148c2ecf20Sopenharmony_ci	/* Retrieve the PHY mode - it must be "xgmii" */
4158c2ecf20Sopenharmony_ci	ret = device_property_read_string(dev, XGBE_PHY_MODE_PROPERTY,
4168c2ecf20Sopenharmony_ci					  &phy_mode);
4178c2ecf20Sopenharmony_ci	if (ret || strcmp(phy_mode, phy_modes(PHY_INTERFACE_MODE_XGMII))) {
4188c2ecf20Sopenharmony_ci		dev_err(dev, "invalid %s property\n", XGBE_PHY_MODE_PROPERTY);
4198c2ecf20Sopenharmony_ci		if (!ret)
4208c2ecf20Sopenharmony_ci			ret = -EINVAL;
4218c2ecf20Sopenharmony_ci		goto err_io;
4228c2ecf20Sopenharmony_ci	}
4238c2ecf20Sopenharmony_ci	pdata->phy_mode = PHY_INTERFACE_MODE_XGMII;
4248c2ecf20Sopenharmony_ci
4258c2ecf20Sopenharmony_ci	/* Check for per channel interrupt support */
4268c2ecf20Sopenharmony_ci	if (device_property_present(dev, XGBE_DMA_IRQS_PROPERTY)) {
4278c2ecf20Sopenharmony_ci		pdata->per_channel_irq = 1;
4288c2ecf20Sopenharmony_ci		pdata->channel_irq_mode = XGBE_IRQ_MODE_EDGE;
4298c2ecf20Sopenharmony_ci	}
4308c2ecf20Sopenharmony_ci
4318c2ecf20Sopenharmony_ci	/* Obtain device settings unique to ACPI/OF */
4328c2ecf20Sopenharmony_ci	if (pdata->use_acpi)
4338c2ecf20Sopenharmony_ci		ret = xgbe_acpi_support(pdata);
4348c2ecf20Sopenharmony_ci	else
4358c2ecf20Sopenharmony_ci		ret = xgbe_of_support(pdata);
4368c2ecf20Sopenharmony_ci	if (ret)
4378c2ecf20Sopenharmony_ci		goto err_io;
4388c2ecf20Sopenharmony_ci
4398c2ecf20Sopenharmony_ci	/* Set the DMA coherency values */
4408c2ecf20Sopenharmony_ci	attr = device_get_dma_attr(dev);
4418c2ecf20Sopenharmony_ci	if (attr == DEV_DMA_NOT_SUPPORTED) {
4428c2ecf20Sopenharmony_ci		dev_err(dev, "DMA is not supported");
4438c2ecf20Sopenharmony_ci		ret = -ENODEV;
4448c2ecf20Sopenharmony_ci		goto err_io;
4458c2ecf20Sopenharmony_ci	}
4468c2ecf20Sopenharmony_ci	pdata->coherent = (attr == DEV_DMA_COHERENT);
4478c2ecf20Sopenharmony_ci	if (pdata->coherent) {
4488c2ecf20Sopenharmony_ci		pdata->arcr = XGBE_DMA_OS_ARCR;
4498c2ecf20Sopenharmony_ci		pdata->awcr = XGBE_DMA_OS_AWCR;
4508c2ecf20Sopenharmony_ci	} else {
4518c2ecf20Sopenharmony_ci		pdata->arcr = XGBE_DMA_SYS_ARCR;
4528c2ecf20Sopenharmony_ci		pdata->awcr = XGBE_DMA_SYS_AWCR;
4538c2ecf20Sopenharmony_ci	}
4548c2ecf20Sopenharmony_ci
4558c2ecf20Sopenharmony_ci	/* Set the maximum fifo amounts */
4568c2ecf20Sopenharmony_ci	pdata->tx_max_fifo_size = pdata->vdata->tx_max_fifo_size;
4578c2ecf20Sopenharmony_ci	pdata->rx_max_fifo_size = pdata->vdata->rx_max_fifo_size;
4588c2ecf20Sopenharmony_ci
4598c2ecf20Sopenharmony_ci	/* Set the hardware channel and queue counts */
4608c2ecf20Sopenharmony_ci	xgbe_set_counts(pdata);
4618c2ecf20Sopenharmony_ci
4628c2ecf20Sopenharmony_ci	/* Always have XGMAC and XPCS (auto-negotiation) interrupts */
4638c2ecf20Sopenharmony_ci	pdata->irq_count = 2;
4648c2ecf20Sopenharmony_ci
4658c2ecf20Sopenharmony_ci	/* Get the device interrupt */
4668c2ecf20Sopenharmony_ci	ret = platform_get_irq(pdev, 0);
4678c2ecf20Sopenharmony_ci	if (ret < 0)
4688c2ecf20Sopenharmony_ci		goto err_io;
4698c2ecf20Sopenharmony_ci	pdata->dev_irq = ret;
4708c2ecf20Sopenharmony_ci
4718c2ecf20Sopenharmony_ci	/* Get the per channel DMA interrupts */
4728c2ecf20Sopenharmony_ci	if (pdata->per_channel_irq) {
4738c2ecf20Sopenharmony_ci		unsigned int i, max = ARRAY_SIZE(pdata->channel_irq);
4748c2ecf20Sopenharmony_ci
4758c2ecf20Sopenharmony_ci		for (i = 0; (i < max) && (dma_irqnum < dma_irqend); i++) {
4768c2ecf20Sopenharmony_ci			ret = platform_get_irq(pdata->platdev, dma_irqnum++);
4778c2ecf20Sopenharmony_ci			if (ret < 0)
4788c2ecf20Sopenharmony_ci				goto err_io;
4798c2ecf20Sopenharmony_ci
4808c2ecf20Sopenharmony_ci			pdata->channel_irq[i] = ret;
4818c2ecf20Sopenharmony_ci		}
4828c2ecf20Sopenharmony_ci
4838c2ecf20Sopenharmony_ci		pdata->channel_irq_count = max;
4848c2ecf20Sopenharmony_ci
4858c2ecf20Sopenharmony_ci		pdata->irq_count += max;
4868c2ecf20Sopenharmony_ci	}
4878c2ecf20Sopenharmony_ci
4888c2ecf20Sopenharmony_ci	/* Get the auto-negotiation interrupt */
4898c2ecf20Sopenharmony_ci	ret = platform_get_irq(phy_pdev, phy_irqnum++);
4908c2ecf20Sopenharmony_ci	if (ret < 0)
4918c2ecf20Sopenharmony_ci		goto err_io;
4928c2ecf20Sopenharmony_ci	pdata->an_irq = ret;
4938c2ecf20Sopenharmony_ci
4948c2ecf20Sopenharmony_ci	/* Configure the netdev resource */
4958c2ecf20Sopenharmony_ci	ret = xgbe_config_netdev(pdata);
4968c2ecf20Sopenharmony_ci	if (ret)
4978c2ecf20Sopenharmony_ci		goto err_io;
4988c2ecf20Sopenharmony_ci
4998c2ecf20Sopenharmony_ci	netdev_notice(pdata->netdev, "net device enabled\n");
5008c2ecf20Sopenharmony_ci
5018c2ecf20Sopenharmony_ci	return 0;
5028c2ecf20Sopenharmony_ci
5038c2ecf20Sopenharmony_cierr_io:
5048c2ecf20Sopenharmony_ci	platform_device_put(phy_pdev);
5058c2ecf20Sopenharmony_ci
5068c2ecf20Sopenharmony_cierr_phydev:
5078c2ecf20Sopenharmony_ci	xgbe_free_pdata(pdata);
5088c2ecf20Sopenharmony_ci
5098c2ecf20Sopenharmony_cierr_alloc:
5108c2ecf20Sopenharmony_ci	dev_notice(dev, "net device not enabled\n");
5118c2ecf20Sopenharmony_ci
5128c2ecf20Sopenharmony_ci	return ret;
5138c2ecf20Sopenharmony_ci}
5148c2ecf20Sopenharmony_ci
5158c2ecf20Sopenharmony_cistatic int xgbe_platform_remove(struct platform_device *pdev)
5168c2ecf20Sopenharmony_ci{
5178c2ecf20Sopenharmony_ci	struct xgbe_prv_data *pdata = platform_get_drvdata(pdev);
5188c2ecf20Sopenharmony_ci
5198c2ecf20Sopenharmony_ci	xgbe_deconfig_netdev(pdata);
5208c2ecf20Sopenharmony_ci
5218c2ecf20Sopenharmony_ci	platform_device_put(pdata->phy_platdev);
5228c2ecf20Sopenharmony_ci
5238c2ecf20Sopenharmony_ci	xgbe_free_pdata(pdata);
5248c2ecf20Sopenharmony_ci
5258c2ecf20Sopenharmony_ci	return 0;
5268c2ecf20Sopenharmony_ci}
5278c2ecf20Sopenharmony_ci
5288c2ecf20Sopenharmony_ci#ifdef CONFIG_PM_SLEEP
5298c2ecf20Sopenharmony_cistatic int xgbe_platform_suspend(struct device *dev)
5308c2ecf20Sopenharmony_ci{
5318c2ecf20Sopenharmony_ci	struct xgbe_prv_data *pdata = dev_get_drvdata(dev);
5328c2ecf20Sopenharmony_ci	struct net_device *netdev = pdata->netdev;
5338c2ecf20Sopenharmony_ci	int ret = 0;
5348c2ecf20Sopenharmony_ci
5358c2ecf20Sopenharmony_ci	DBGPR("-->xgbe_suspend\n");
5368c2ecf20Sopenharmony_ci
5378c2ecf20Sopenharmony_ci	if (netif_running(netdev))
5388c2ecf20Sopenharmony_ci		ret = xgbe_powerdown(netdev, XGMAC_DRIVER_CONTEXT);
5398c2ecf20Sopenharmony_ci
5408c2ecf20Sopenharmony_ci	pdata->lpm_ctrl = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_CTRL1);
5418c2ecf20Sopenharmony_ci	pdata->lpm_ctrl |= MDIO_CTRL1_LPOWER;
5428c2ecf20Sopenharmony_ci	XMDIO_WRITE(pdata, MDIO_MMD_PCS, MDIO_CTRL1, pdata->lpm_ctrl);
5438c2ecf20Sopenharmony_ci
5448c2ecf20Sopenharmony_ci	DBGPR("<--xgbe_suspend\n");
5458c2ecf20Sopenharmony_ci
5468c2ecf20Sopenharmony_ci	return ret;
5478c2ecf20Sopenharmony_ci}
5488c2ecf20Sopenharmony_ci
5498c2ecf20Sopenharmony_cistatic int xgbe_platform_resume(struct device *dev)
5508c2ecf20Sopenharmony_ci{
5518c2ecf20Sopenharmony_ci	struct xgbe_prv_data *pdata = dev_get_drvdata(dev);
5528c2ecf20Sopenharmony_ci	struct net_device *netdev = pdata->netdev;
5538c2ecf20Sopenharmony_ci	int ret = 0;
5548c2ecf20Sopenharmony_ci
5558c2ecf20Sopenharmony_ci	DBGPR("-->xgbe_resume\n");
5568c2ecf20Sopenharmony_ci
5578c2ecf20Sopenharmony_ci	pdata->lpm_ctrl &= ~MDIO_CTRL1_LPOWER;
5588c2ecf20Sopenharmony_ci	XMDIO_WRITE(pdata, MDIO_MMD_PCS, MDIO_CTRL1, pdata->lpm_ctrl);
5598c2ecf20Sopenharmony_ci
5608c2ecf20Sopenharmony_ci	if (netif_running(netdev)) {
5618c2ecf20Sopenharmony_ci		ret = xgbe_powerup(netdev, XGMAC_DRIVER_CONTEXT);
5628c2ecf20Sopenharmony_ci
5638c2ecf20Sopenharmony_ci		/* Schedule a restart in case the link or phy state changed
5648c2ecf20Sopenharmony_ci		 * while we were powered down.
5658c2ecf20Sopenharmony_ci		 */
5668c2ecf20Sopenharmony_ci		schedule_work(&pdata->restart_work);
5678c2ecf20Sopenharmony_ci	}
5688c2ecf20Sopenharmony_ci
5698c2ecf20Sopenharmony_ci	DBGPR("<--xgbe_resume\n");
5708c2ecf20Sopenharmony_ci
5718c2ecf20Sopenharmony_ci	return ret;
5728c2ecf20Sopenharmony_ci}
5738c2ecf20Sopenharmony_ci#endif /* CONFIG_PM_SLEEP */
5748c2ecf20Sopenharmony_ci
5758c2ecf20Sopenharmony_cistatic const struct xgbe_version_data xgbe_v1 = {
5768c2ecf20Sopenharmony_ci	.init_function_ptrs_phy_impl	= xgbe_init_function_ptrs_phy_v1,
5778c2ecf20Sopenharmony_ci	.xpcs_access			= XGBE_XPCS_ACCESS_V1,
5788c2ecf20Sopenharmony_ci	.tx_max_fifo_size		= 81920,
5798c2ecf20Sopenharmony_ci	.rx_max_fifo_size		= 81920,
5808c2ecf20Sopenharmony_ci	.tx_tstamp_workaround		= 1,
5818c2ecf20Sopenharmony_ci};
5828c2ecf20Sopenharmony_ci
5838c2ecf20Sopenharmony_ci#ifdef CONFIG_ACPI
5848c2ecf20Sopenharmony_cistatic const struct acpi_device_id xgbe_acpi_match[] = {
5858c2ecf20Sopenharmony_ci	{ .id = "AMDI8001",
5868c2ecf20Sopenharmony_ci	  .driver_data = (kernel_ulong_t)&xgbe_v1 },
5878c2ecf20Sopenharmony_ci	{},
5888c2ecf20Sopenharmony_ci};
5898c2ecf20Sopenharmony_ci
5908c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(acpi, xgbe_acpi_match);
5918c2ecf20Sopenharmony_ci#endif
5928c2ecf20Sopenharmony_ci
5938c2ecf20Sopenharmony_ci#ifdef CONFIG_OF
5948c2ecf20Sopenharmony_cistatic const struct of_device_id xgbe_of_match[] = {
5958c2ecf20Sopenharmony_ci	{ .compatible = "amd,xgbe-seattle-v1a",
5968c2ecf20Sopenharmony_ci	  .data = &xgbe_v1 },
5978c2ecf20Sopenharmony_ci	{},
5988c2ecf20Sopenharmony_ci};
5998c2ecf20Sopenharmony_ci
6008c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(of, xgbe_of_match);
6018c2ecf20Sopenharmony_ci#endif
6028c2ecf20Sopenharmony_ci
6038c2ecf20Sopenharmony_cistatic SIMPLE_DEV_PM_OPS(xgbe_platform_pm_ops,
6048c2ecf20Sopenharmony_ci			 xgbe_platform_suspend, xgbe_platform_resume);
6058c2ecf20Sopenharmony_ci
6068c2ecf20Sopenharmony_cistatic struct platform_driver xgbe_driver = {
6078c2ecf20Sopenharmony_ci	.driver = {
6088c2ecf20Sopenharmony_ci		.name = XGBE_DRV_NAME,
6098c2ecf20Sopenharmony_ci#ifdef CONFIG_ACPI
6108c2ecf20Sopenharmony_ci		.acpi_match_table = xgbe_acpi_match,
6118c2ecf20Sopenharmony_ci#endif
6128c2ecf20Sopenharmony_ci#ifdef CONFIG_OF
6138c2ecf20Sopenharmony_ci		.of_match_table = xgbe_of_match,
6148c2ecf20Sopenharmony_ci#endif
6158c2ecf20Sopenharmony_ci		.pm = &xgbe_platform_pm_ops,
6168c2ecf20Sopenharmony_ci	},
6178c2ecf20Sopenharmony_ci	.probe = xgbe_platform_probe,
6188c2ecf20Sopenharmony_ci	.remove = xgbe_platform_remove,
6198c2ecf20Sopenharmony_ci};
6208c2ecf20Sopenharmony_ci
6218c2ecf20Sopenharmony_ciint xgbe_platform_init(void)
6228c2ecf20Sopenharmony_ci{
6238c2ecf20Sopenharmony_ci	return platform_driver_register(&xgbe_driver);
6248c2ecf20Sopenharmony_ci}
6258c2ecf20Sopenharmony_ci
6268c2ecf20Sopenharmony_civoid xgbe_platform_exit(void)
6278c2ecf20Sopenharmony_ci{
6288c2ecf20Sopenharmony_ci	platform_driver_unregister(&xgbe_driver);
6298c2ecf20Sopenharmony_ci}
630