0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #include <linux/kernel.h>
0019 #include <linux/module.h>
0020 #include <linux/pci.h>
0021
0022 #include "dwc-xlgmac.h"
0023 #include "dwc-xlgmac-reg.h"
0024
0025 static int xlgmac_probe(struct pci_dev *pcidev, const struct pci_device_id *id)
0026 {
0027 struct device *dev = &pcidev->dev;
0028 struct xlgmac_resources res;
0029 int i, ret;
0030
0031 ret = pcim_enable_device(pcidev);
0032 if (ret) {
0033 dev_err(dev, "ERROR: failed to enable device\n");
0034 return ret;
0035 }
0036
0037 for (i = 0; i < PCI_STD_NUM_BARS; i++) {
0038 if (pci_resource_len(pcidev, i) == 0)
0039 continue;
0040 ret = pcim_iomap_regions(pcidev, BIT(i), XLGMAC_DRV_NAME);
0041 if (ret)
0042 return ret;
0043 break;
0044 }
0045
0046 pci_set_master(pcidev);
0047
0048 memset(&res, 0, sizeof(res));
0049 res.irq = pcidev->irq;
0050 res.addr = pcim_iomap_table(pcidev)[i];
0051
0052 return xlgmac_drv_probe(&pcidev->dev, &res);
0053 }
0054
0055 static void xlgmac_remove(struct pci_dev *pcidev)
0056 {
0057 xlgmac_drv_remove(&pcidev->dev);
0058 }
0059
0060 static const struct pci_device_id xlgmac_pci_tbl[] = {
0061 { PCI_DEVICE(PCI_VENDOR_ID_SYNOPSYS, 0x7302) },
0062 { 0 }
0063 };
0064 MODULE_DEVICE_TABLE(pci, xlgmac_pci_tbl);
0065
0066 static struct pci_driver xlgmac_pci_driver = {
0067 .name = XLGMAC_DRV_NAME,
0068 .id_table = xlgmac_pci_tbl,
0069 .probe = xlgmac_probe,
0070 .remove = xlgmac_remove,
0071 };
0072
0073 module_pci_driver(xlgmac_pci_driver);
0074
0075 MODULE_DESCRIPTION(XLGMAC_DRV_DESC);
0076 MODULE_VERSION(XLGMAC_DRV_VERSION);
0077 MODULE_AUTHOR("Jie Deng <jiedeng@synopsys.com>");
0078 MODULE_LICENSE("Dual BSD/GPL");