Linux Audio

Check our new training course

Loading...
v6.8
 1/*
 2 * Generic DWMAC platform driver
 3 *
 4 * Copyright (C) 2007-2011  STMicroelectronics Ltd
 5 * Copyright (C) 2015 Joachim Eastwood <manabian@gmail.com>
 6 *
 7 * This file is licensed under the terms of the GNU General Public
 8 * License version 2. This program is licensed "as is" without any
 9 * warranty of any kind, whether express or implied.
10 */
11
12#include <linux/module.h>
13#include <linux/of.h>
14#include <linux/platform_device.h>
15
16#include "stmmac.h"
17#include "stmmac_platform.h"
18
19static int dwmac_generic_probe(struct platform_device *pdev)
20{
21	struct plat_stmmacenet_data *plat_dat;
22	struct stmmac_resources stmmac_res;
23	int ret;
24
25	ret = stmmac_get_platform_resources(pdev, &stmmac_res);
26	if (ret)
27		return ret;
28
29	if (pdev->dev.of_node) {
30		plat_dat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac);
31		if (IS_ERR(plat_dat)) {
32			dev_err(&pdev->dev, "dt configuration failed\n");
33			return PTR_ERR(plat_dat);
34		}
35	} else {
36		plat_dat = dev_get_platdata(&pdev->dev);
37		if (!plat_dat) {
38			dev_err(&pdev->dev, "no platform data provided\n");
39			return  -EINVAL;
40		}
41
42		/* Set default value for multicast hash bins */
43		plat_dat->multicast_filter_bins = HASH_TABLE_SIZE;
44
45		/* Set default value for unicast filter entries */
46		plat_dat->unicast_filter_entries = 1;
47	}
48
49	return devm_stmmac_pltfr_probe(pdev, plat_dat, &stmmac_res);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50}
51
52static const struct of_device_id dwmac_generic_match[] = {
53	{ .compatible = "st,spear600-gmac"},
54	{ .compatible = "snps,dwmac-3.40a"},
55	{ .compatible = "snps,dwmac-3.50a"},
56	{ .compatible = "snps,dwmac-3.610"},
57	{ .compatible = "snps,dwmac-3.70a"},
58	{ .compatible = "snps,dwmac-3.710"},
59	{ .compatible = "snps,dwmac-4.00"},
60	{ .compatible = "snps,dwmac-4.10a"},
61	{ .compatible = "snps,dwmac"},
62	{ .compatible = "snps,dwxgmac-2.10"},
63	{ .compatible = "snps,dwxgmac"},
64	{ }
65};
66MODULE_DEVICE_TABLE(of, dwmac_generic_match);
67
68static struct platform_driver dwmac_generic_driver = {
69	.probe  = dwmac_generic_probe,
 
70	.driver = {
71		.name           = STMMAC_RESOURCE_NAME,
72		.pm		= &stmmac_pltfr_pm_ops,
73		.of_match_table = dwmac_generic_match,
74	},
75};
76module_platform_driver(dwmac_generic_driver);
77
78MODULE_DESCRIPTION("Generic dwmac driver");
79MODULE_LICENSE("GPL v2");
v4.10.11
 1/*
 2 * Generic DWMAC platform driver
 3 *
 4 * Copyright (C) 2007-2011  STMicroelectronics Ltd
 5 * Copyright (C) 2015 Joachim Eastwood <manabian@gmail.com>
 6 *
 7 * This file is licensed under the terms of the GNU General Public
 8 * License version 2. This program is licensed "as is" without any
 9 * warranty of any kind, whether express or implied.
10 */
11
12#include <linux/module.h>
13#include <linux/of.h>
14#include <linux/platform_device.h>
15
16#include "stmmac.h"
17#include "stmmac_platform.h"
18
19static int dwmac_generic_probe(struct platform_device *pdev)
20{
21	struct plat_stmmacenet_data *plat_dat;
22	struct stmmac_resources stmmac_res;
23	int ret;
24
25	ret = stmmac_get_platform_resources(pdev, &stmmac_res);
26	if (ret)
27		return ret;
28
29	if (pdev->dev.of_node) {
30		plat_dat = stmmac_probe_config_dt(pdev, &stmmac_res.mac);
31		if (IS_ERR(plat_dat)) {
32			dev_err(&pdev->dev, "dt configuration failed\n");
33			return PTR_ERR(plat_dat);
34		}
35	} else {
36		plat_dat = dev_get_platdata(&pdev->dev);
37		if (!plat_dat) {
38			dev_err(&pdev->dev, "no platform data provided\n");
39			return  -EINVAL;
40		}
41
42		/* Set default value for multicast hash bins */
43		plat_dat->multicast_filter_bins = HASH_TABLE_SIZE;
44
45		/* Set default value for unicast filter entries */
46		plat_dat->unicast_filter_entries = 1;
47	}
48
49	/* Custom initialisation (if needed) */
50	if (plat_dat->init) {
51		ret = plat_dat->init(pdev, plat_dat->bsp_priv);
52		if (ret)
53			goto err_remove_config_dt;
54	}
55
56	ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
57	if (ret)
58		goto err_exit;
59
60	return 0;
61
62err_exit:
63	if (plat_dat->exit)
64		plat_dat->exit(pdev, plat_dat->bsp_priv);
65err_remove_config_dt:
66	if (pdev->dev.of_node)
67		stmmac_remove_config_dt(pdev, plat_dat);
68
69	return ret;
70}
71
72static const struct of_device_id dwmac_generic_match[] = {
73	{ .compatible = "st,spear600-gmac"},
 
74	{ .compatible = "snps,dwmac-3.50a"},
75	{ .compatible = "snps,dwmac-3.610"},
76	{ .compatible = "snps,dwmac-3.70a"},
77	{ .compatible = "snps,dwmac-3.710"},
78	{ .compatible = "snps,dwmac-4.00"},
79	{ .compatible = "snps,dwmac-4.10a"},
80	{ .compatible = "snps,dwmac"},
 
 
81	{ }
82};
83MODULE_DEVICE_TABLE(of, dwmac_generic_match);
84
85static struct platform_driver dwmac_generic_driver = {
86	.probe  = dwmac_generic_probe,
87	.remove = stmmac_pltfr_remove,
88	.driver = {
89		.name           = STMMAC_RESOURCE_NAME,
90		.pm		= &stmmac_pltfr_pm_ops,
91		.of_match_table = of_match_ptr(dwmac_generic_match),
92	},
93};
94module_platform_driver(dwmac_generic_driver);
95
96MODULE_DESCRIPTION("Generic dwmac driver");
97MODULE_LICENSE("GPL v2");