dwmac-generic.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 = devm_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. return devm_stmmac_pltfr_probe(pdev, plat_dat, &stmmac_res);
  42. }
  43. static const struct of_device_id dwmac_generic_match[] = {
  44. { .compatible = "st,spear600-gmac"},
  45. { .compatible = "snps,dwmac-3.40a"},
  46. { .compatible = "snps,dwmac-3.50a"},
  47. { .compatible = "snps,dwmac-3.610"},
  48. { .compatible = "snps,dwmac-3.70a"},
  49. { .compatible = "snps,dwmac-3.710"},
  50. { .compatible = "snps,dwmac-3.72a"},
  51. { .compatible = "snps,dwmac-4.00"},
  52. { .compatible = "snps,dwmac-4.10a"},
  53. { .compatible = "snps,dwmac"},
  54. { .compatible = "snps,dwxgmac-2.10"},
  55. { .compatible = "snps,dwxgmac"},
  56. { }
  57. };
  58. MODULE_DEVICE_TABLE(of, dwmac_generic_match);
  59. static struct platform_driver dwmac_generic_driver = {
  60. .probe = dwmac_generic_probe,
  61. .driver = {
  62. .name = STMMAC_RESOURCE_NAME,
  63. .pm = &stmmac_pltfr_pm_ops,
  64. .of_match_table = dwmac_generic_match,
  65. },
  66. };
  67. module_platform_driver(dwmac_generic_driver);
  68. MODULE_DESCRIPTION("Generic dwmac driver");
  69. MODULE_LICENSE("GPL v2");