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