0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include <linux/module.h>
0013 #include <linux/of.h>
0014 #include <linux/platform_device.h>
0015
0016 #include "stmmac.h"
0017 #include "stmmac_platform.h"
0018
0019 static int dwmac_generic_probe(struct platform_device *pdev)
0020 {
0021 struct plat_stmmacenet_data *plat_dat;
0022 struct stmmac_resources stmmac_res;
0023 int ret;
0024
0025 ret = stmmac_get_platform_resources(pdev, &stmmac_res);
0026 if (ret)
0027 return ret;
0028
0029 if (pdev->dev.of_node) {
0030 plat_dat = stmmac_probe_config_dt(pdev, stmmac_res.mac);
0031 if (IS_ERR(plat_dat)) {
0032 dev_err(&pdev->dev, "dt configuration failed\n");
0033 return PTR_ERR(plat_dat);
0034 }
0035 } else {
0036 plat_dat = dev_get_platdata(&pdev->dev);
0037 if (!plat_dat) {
0038 dev_err(&pdev->dev, "no platform data provided\n");
0039 return -EINVAL;
0040 }
0041
0042
0043 plat_dat->multicast_filter_bins = HASH_TABLE_SIZE;
0044
0045
0046 plat_dat->unicast_filter_entries = 1;
0047 }
0048
0049
0050 if (plat_dat->init) {
0051 ret = plat_dat->init(pdev, plat_dat->bsp_priv);
0052 if (ret)
0053 goto err_remove_config_dt;
0054 }
0055
0056 ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
0057 if (ret)
0058 goto err_exit;
0059
0060 return 0;
0061
0062 err_exit:
0063 if (plat_dat->exit)
0064 plat_dat->exit(pdev, plat_dat->bsp_priv);
0065 err_remove_config_dt:
0066 if (pdev->dev.of_node)
0067 stmmac_remove_config_dt(pdev, plat_dat);
0068
0069 return ret;
0070 }
0071
0072 static const struct of_device_id dwmac_generic_match[] = {
0073 { .compatible = "st,spear600-gmac"},
0074 { .compatible = "snps,dwmac-3.40a"},
0075 { .compatible = "snps,dwmac-3.50a"},
0076 { .compatible = "snps,dwmac-3.610"},
0077 { .compatible = "snps,dwmac-3.70a"},
0078 { .compatible = "snps,dwmac-3.710"},
0079 { .compatible = "snps,dwmac-4.00"},
0080 { .compatible = "snps,dwmac-4.10a"},
0081 { .compatible = "snps,dwmac"},
0082 { .compatible = "snps,dwxgmac-2.10"},
0083 { .compatible = "snps,dwxgmac"},
0084 { }
0085 };
0086 MODULE_DEVICE_TABLE(of, dwmac_generic_match);
0087
0088 static struct platform_driver dwmac_generic_driver = {
0089 .probe = dwmac_generic_probe,
0090 .remove = stmmac_pltfr_remove,
0091 .driver = {
0092 .name = STMMAC_RESOURCE_NAME,
0093 .pm = &stmmac_pltfr_pm_ops,
0094 .of_match_table = of_match_ptr(dwmac_generic_match),
0095 },
0096 };
0097 module_platform_driver(dwmac_generic_driver);
0098
0099 MODULE_DESCRIPTION("Generic dwmac driver");
0100 MODULE_LICENSE("GPL v2");