sh_eth: fix EESIPR values for SH77{34|63}
[linux/fpc-iii.git] / drivers / pci / host / pcie-iproc-bcma.c
blobbd4c9ec25edc22531ae450b2bb08f1d2aecd7b62
1 /*
2 * Copyright (C) 2015 Broadcom Corporation
3 * Copyright (C) 2015 Hauke Mehrtens <hauke@hauke-m.de>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation version 2.
9 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
10 * kind, whether express or implied; without even the implied warranty
11 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
15 #include <linux/kernel.h>
16 #include <linux/pci.h>
17 #include <linux/module.h>
18 #include <linux/slab.h>
19 #include <linux/phy/phy.h>
20 #include <linux/bcma/bcma.h>
21 #include <linux/ioport.h>
23 #include "pcie-iproc.h"
26 /* NS: CLASS field is R/O, and set to wrong 0x200 value */
27 static void bcma_pcie2_fixup_class(struct pci_dev *dev)
29 dev->class = PCI_CLASS_BRIDGE_PCI << 8;
31 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_BROADCOM, 0x8011, bcma_pcie2_fixup_class);
32 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_BROADCOM, 0x8012, bcma_pcie2_fixup_class);
34 static int iproc_pcie_bcma_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
36 struct pci_sys_data *sys = dev->sysdata;
37 struct iproc_pcie *pcie = sys->private_data;
38 struct bcma_device *bdev = container_of(pcie->dev, struct bcma_device, dev);
40 return bcma_core_irq(bdev, 5);
43 static int iproc_pcie_bcma_probe(struct bcma_device *bdev)
45 struct device *dev = &bdev->dev;
46 struct iproc_pcie *pcie;
47 LIST_HEAD(res);
48 struct resource res_mem;
49 int ret;
51 pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL);
52 if (!pcie)
53 return -ENOMEM;
55 pcie->dev = dev;
57 pcie->type = IPROC_PCIE_PAXB_BCMA;
58 pcie->base = bdev->io_addr;
59 if (!pcie->base) {
60 dev_err(dev, "no controller registers\n");
61 return -ENOMEM;
64 pcie->base_addr = bdev->addr;
66 res_mem.start = bdev->addr_s[0];
67 res_mem.end = bdev->addr_s[0] + SZ_128M - 1;
68 res_mem.name = "PCIe MEM space";
69 res_mem.flags = IORESOURCE_MEM;
70 pci_add_resource(&res, &res_mem);
72 pcie->map_irq = iproc_pcie_bcma_map_irq;
74 ret = iproc_pcie_setup(pcie, &res);
75 if (ret)
76 dev_err(dev, "PCIe controller setup failed\n");
78 pci_free_resource_list(&res);
80 bcma_set_drvdata(bdev, pcie);
81 return ret;
84 static void iproc_pcie_bcma_remove(struct bcma_device *bdev)
86 struct iproc_pcie *pcie = bcma_get_drvdata(bdev);
88 iproc_pcie_remove(pcie);
91 static const struct bcma_device_id iproc_pcie_bcma_table[] = {
92 BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_NS_PCIEG2, BCMA_ANY_REV, BCMA_ANY_CLASS),
93 {},
95 MODULE_DEVICE_TABLE(bcma, iproc_pcie_bcma_table);
97 static struct bcma_driver iproc_pcie_bcma_driver = {
98 .name = KBUILD_MODNAME,
99 .id_table = iproc_pcie_bcma_table,
100 .probe = iproc_pcie_bcma_probe,
101 .remove = iproc_pcie_bcma_remove,
104 static int __init iproc_pcie_bcma_init(void)
106 return bcma_driver_register(&iproc_pcie_bcma_driver);
108 module_init(iproc_pcie_bcma_init);
110 static void __exit iproc_pcie_bcma_exit(void)
112 bcma_driver_unregister(&iproc_pcie_bcma_driver);
114 module_exit(iproc_pcie_bcma_exit);
116 MODULE_AUTHOR("Hauke Mehrtens");
117 MODULE_DESCRIPTION("Broadcom iProc PCIe BCMA driver");
118 MODULE_LICENSE("GPL v2");