Back to home page

OSCL-LXR

 
 

    


0001 /* Synopsys DesignWare Core Enterprise Ethernet (XLGMAC) Driver
0002  *
0003  * Copyright (c) 2017 Synopsys, Inc. (www.synopsys.com)
0004  *
0005  * This program is dual-licensed; you may select either version 2 of
0006  * the GNU General Public License ("GPL") or BSD license ("BSD").
0007  *
0008  * This Synopsys DWC XLGMAC software driver and associated documentation
0009  * (hereinafter the "Software") is an unsupported proprietary work of
0010  * Synopsys, Inc. unless otherwise expressly agreed to in writing between
0011  * Synopsys and you. The Software IS NOT an item of Licensed Software or a
0012  * Licensed Product under any End User Software License Agreement or
0013  * Agreement for Licensed Products with Synopsys or any supplement thereto.
0014  * Synopsys is a registered trademark of Synopsys, Inc. Other names included
0015  * in the SOFTWARE may be the trademarks of their respective owners.
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");