dwmac-generic.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. #include <linux/module.h>
  12. #include <linux/of.h>
  13. #include <linux/platform_device.h>
  14. #include "stmmac.h"
  15. #include "stmmac_platform.h"
  16. static int dwmac_generic_probe(struct platform_device *pdev)
  17. {
  18. struct plat_stmmacenet_data *plat_dat;
  19. struct stmmac_resources stmmac_res;
  20. int ret;
  21. ret = stmmac_get_platform_resources(pdev, &stmmac_res);
  22. if (ret)
  23. return ret;
  24. if (pdev->dev.of_node) {
  25. plat_dat = stmmac_probe_config_dt(pdev, &stmmac_res.mac);
  26. if (IS_ERR(plat_dat)) {
  27. dev_err(&pdev->dev, "dt configuration failed\n");
  28. return PTR_ERR(plat_dat);
  29. }
  30. } else {
  31. plat_dat = dev_get_platdata(&pdev->dev);
  32. if (!plat_dat) {
  33. dev_err(&pdev->dev, "no platform data provided\n");
  34. return -EINVAL;
  35. }
  36. /* Set default value for multicast hash bins */
  37. plat_dat->multicast_filter_bins = HASH_TABLE_SIZE;
  38. /* Set default value for unicast filter entries */
  39. plat_dat->unicast_filter_entries = 1;
  40. }
  41. /* Custom initialisation (if needed) */
  42. if (plat_dat->init) {
  43. ret = plat_dat->init(pdev, plat_dat->bsp_priv);
  44. if (ret)
  45. return ret;
  46. }
  47. return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
  48. }
  49. static const struct of_device_id dwmac_generic_match[] = {
  50. { .compatible = "st,spear600-gmac"},
  51. { .compatible = "snps,dwmac-3.610"},
  52. { .compatible = "snps,dwmac-3.70a"},
  53. { .compatible = "snps,dwmac-3.710"},
  54. { .compatible = "snps,dwmac"},
  55. { }
  56. };
  57. MODULE_DEVICE_TABLE(of, dwmac_generic_match);
  58. static struct platform_driver dwmac_generic_driver = {
  59. .probe = dwmac_generic_probe,
  60. .remove = stmmac_pltfr_remove,
  61. .driver = {
  62. .name = STMMAC_RESOURCE_NAME,
  63. .pm = &stmmac_pltfr_pm_ops,
  64. .of_match_table = of_match_ptr(dwmac_generic_match),
  65. },
  66. };
  67. module_platform_driver(dwmac_generic_driver);
  68. MODULE_DESCRIPTION("Generic dwmac driver");
  69. MODULE_LICENSE("GPL v2");