Joachim Eastwood | ba25020 | 2015-05-14 12:10:59 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Generic DWMAC platform driver |
| 3 | * |
Joachim Eastwood | 50649ab | 2015-05-14 12:11:06 +0200 | [diff] [blame] | 4 | * Copyright (C) 2007-2011 STMicroelectronics Ltd |
Joachim Eastwood | ba25020 | 2015-05-14 12:10:59 +0200 | [diff] [blame] | 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 | |
Joachim Eastwood | 50649ab | 2015-05-14 12:11:06 +0200 | [diff] [blame] | 16 | #include "stmmac.h" |
Joachim Eastwood | ba25020 | 2015-05-14 12:10:59 +0200 | [diff] [blame] | 17 | #include "stmmac_platform.h" |
| 18 | |
Joachim Eastwood | 85d89e6 | 2015-07-29 00:08:57 +0200 | [diff] [blame^] | 19 | static 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 setup (if needed) */ |
| 50 | if (plat_dat->setup) { |
| 51 | plat_dat->bsp_priv = plat_dat->setup(pdev); |
| 52 | if (IS_ERR(plat_dat->bsp_priv)) |
| 53 | return PTR_ERR(plat_dat->bsp_priv); |
| 54 | } |
| 55 | |
| 56 | /* Custom initialisation (if needed) */ |
| 57 | if (plat_dat->init) { |
| 58 | ret = plat_dat->init(pdev, plat_dat->bsp_priv); |
| 59 | if (ret) |
| 60 | return ret; |
| 61 | } |
| 62 | |
| 63 | return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); |
| 64 | } |
| 65 | |
Joachim Eastwood | ba25020 | 2015-05-14 12:10:59 +0200 | [diff] [blame] | 66 | static const struct of_device_id dwmac_generic_match[] = { |
| 67 | { .compatible = "st,spear600-gmac"}, |
| 68 | { .compatible = "snps,dwmac-3.610"}, |
| 69 | { .compatible = "snps,dwmac-3.70a"}, |
| 70 | { .compatible = "snps,dwmac-3.710"}, |
| 71 | { .compatible = "snps,dwmac"}, |
| 72 | { } |
| 73 | }; |
| 74 | MODULE_DEVICE_TABLE(of, dwmac_generic_match); |
| 75 | |
| 76 | static struct platform_driver dwmac_generic_driver = { |
Joachim Eastwood | 85d89e6 | 2015-07-29 00:08:57 +0200 | [diff] [blame^] | 77 | .probe = dwmac_generic_probe, |
Joachim Eastwood | ba25020 | 2015-05-14 12:10:59 +0200 | [diff] [blame] | 78 | .remove = stmmac_pltfr_remove, |
| 79 | .driver = { |
Joachim Eastwood | 50649ab | 2015-05-14 12:11:06 +0200 | [diff] [blame] | 80 | .name = STMMAC_RESOURCE_NAME, |
Joachim Eastwood | ba25020 | 2015-05-14 12:10:59 +0200 | [diff] [blame] | 81 | .pm = &stmmac_pltfr_pm_ops, |
| 82 | .of_match_table = of_match_ptr(dwmac_generic_match), |
| 83 | }, |
| 84 | }; |
| 85 | module_platform_driver(dwmac_generic_driver); |
| 86 | |
| 87 | MODULE_DESCRIPTION("Generic dwmac driver"); |
| 88 | MODULE_LICENSE("GPL v2"); |