linux/drivers/net/ethernet/synopsys/dwc-xlgmac-pci.c
<<
>>
Prefs
   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
  18#include <linux/kernel.h>
  19#include <linux/module.h>
  20#include <linux/pci.h>
  21
  22#include "dwc-xlgmac.h"
  23#include "dwc-xlgmac-reg.h"
  24
  25static int xlgmac_probe(struct pci_dev *pcidev, const struct pci_device_id *id)
  26{
  27        struct device *dev = &pcidev->dev;
  28        struct xlgmac_resources res;
  29        int i, ret;
  30
  31        ret = pcim_enable_device(pcidev);
  32        if (ret) {
  33                dev_err(dev, "ERROR: failed to enable device\n");
  34                return ret;
  35        }
  36
  37        for (i = 0; i <= PCI_STD_RESOURCE_END; i++) {
  38                if (pci_resource_len(pcidev, i) == 0)
  39                        continue;
  40                ret = pcim_iomap_regions(pcidev, BIT(i), XLGMAC_DRV_NAME);
  41                if (ret)
  42                        return ret;
  43                break;
  44        }
  45
  46        pci_set_master(pcidev);
  47
  48        memset(&res, 0, sizeof(res));
  49        res.irq = pcidev->irq;
  50        res.addr = pcim_iomap_table(pcidev)[i];
  51
  52        return xlgmac_drv_probe(&pcidev->dev, &res);
  53}
  54
  55static void xlgmac_remove(struct pci_dev *pcidev)
  56{
  57        xlgmac_drv_remove(&pcidev->dev);
  58}
  59
  60static const struct pci_device_id xlgmac_pci_tbl[] = {
  61        { PCI_DEVICE(PCI_VENDOR_ID_SYNOPSYS, 0x7302) },
  62        { 0 }
  63};
  64MODULE_DEVICE_TABLE(pci, xlgmac_pci_tbl);
  65
  66static struct pci_driver xlgmac_pci_driver = {
  67        .name           = XLGMAC_DRV_NAME,
  68        .id_table       = xlgmac_pci_tbl,
  69        .probe          = xlgmac_probe,
  70        .remove         = xlgmac_remove,
  71};
  72
  73module_pci_driver(xlgmac_pci_driver);
  74
  75MODULE_DESCRIPTION(XLGMAC_DRV_DESC);
  76MODULE_VERSION(XLGMAC_DRV_VERSION);
  77MODULE_AUTHOR("Jie Deng <jiedeng@synopsys.com>");
  78MODULE_LICENSE("Dual BSD/GPL");
  79