dwc-xlgmac-pci.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* Synopsys DesignWare Core Enterprise Ethernet (XLGMAC) Driver
  2. *
  3. * Copyright (c) 2017 Synopsys, Inc. (www.synopsys.com)
  4. *
  5. * This program is dual-licensed; you may select either version 2 of
  6. * the GNU General Public License ("GPL") or BSD license ("BSD").
  7. *
  8. * This Synopsys DWC XLGMAC software driver and associated documentation
  9. * (hereinafter the "Software") is an unsupported proprietary work of
  10. * Synopsys, Inc. unless otherwise expressly agreed to in writing between
  11. * Synopsys and you. The Software IS NOT an item of Licensed Software or a
  12. * Licensed Product under any End User Software License Agreement or
  13. * Agreement for Licensed Products with Synopsys or any supplement thereto.
  14. * Synopsys is a registered trademark of Synopsys, Inc. Other names included
  15. * in the SOFTWARE may be the trademarks of their respective owners.
  16. */
  17. #include <linux/kernel.h>
  18. #include <linux/module.h>
  19. #include <linux/pci.h>
  20. #include "dwc-xlgmac.h"
  21. #include "dwc-xlgmac-reg.h"
  22. static int xlgmac_probe(struct pci_dev *pcidev, const struct pci_device_id *id)
  23. {
  24. struct device *dev = &pcidev->dev;
  25. struct xlgmac_resources res;
  26. int i, ret;
  27. ret = pcim_enable_device(pcidev);
  28. if (ret) {
  29. dev_err(dev, "ERROR: failed to enable device\n");
  30. return ret;
  31. }
  32. for (i = 0; i <= PCI_STD_RESOURCE_END; i++) {
  33. if (pci_resource_len(pcidev, i) == 0)
  34. continue;
  35. ret = pcim_iomap_regions(pcidev, BIT(i), XLGMAC_DRV_NAME);
  36. if (ret)
  37. return ret;
  38. break;
  39. }
  40. pci_set_master(pcidev);
  41. memset(&res, 0, sizeof(res));
  42. res.irq = pcidev->irq;
  43. res.addr = pcim_iomap_table(pcidev)[i];
  44. return xlgmac_drv_probe(&pcidev->dev, &res);
  45. }
  46. static void xlgmac_remove(struct pci_dev *pcidev)
  47. {
  48. xlgmac_drv_remove(&pcidev->dev);
  49. }
  50. static const struct pci_device_id xlgmac_pci_tbl[] = {
  51. { PCI_DEVICE(PCI_VENDOR_ID_SYNOPSYS, 0x7302) },
  52. { 0 }
  53. };
  54. MODULE_DEVICE_TABLE(pci, xlgmac_pci_tbl);
  55. static struct pci_driver xlgmac_pci_driver = {
  56. .name = XLGMAC_DRV_NAME,
  57. .id_table = xlgmac_pci_tbl,
  58. .probe = xlgmac_probe,
  59. .remove = xlgmac_remove,
  60. };
  61. module_pci_driver(xlgmac_pci_driver);
  62. MODULE_DESCRIPTION(XLGMAC_DRV_DESC);
  63. MODULE_VERSION(XLGMAC_DRV_VERSION);
  64. MODULE_AUTHOR("Jie Deng <jiedeng@synopsys.com>");
  65. MODULE_LICENSE("Dual BSD/GPL");