aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHauke Mehrtens <hauke@hauke-m.de>2015-05-12 17:23:01 -0400
committerBjorn Helgaas <bhelgaas@google.com>2015-05-20 10:46:06 -0400
commit4785ffbdc9b52e308e43b9e2dcc1dca44f056d76 (patch)
tree3f2d1e08aae565ef575c1d6e4646890a1b954c62
parentc1e02ceaf5739d32f092ac07bf886a0281ec40b1 (diff)
PCI: iproc: Add BCMA PCIe driver
This driver adds support for the PCIe 2.0 controller found on the BCMA bus. This controller can be found on (mostly) all Broadcom BCM470X / BCM5301X ARM SoCs. The driver found in the Broadcom SDK does some more stuff, like setting up some DMA memory areas, chaining MPS and MRRS to 512 and also some PHY changes like "improving" the PCIe jitter and doing some special initialization for the 3rd PCIe port. This was tested on a bcm4708 board with 2 PCIe ports and wireless cards connected to them. PCI_DOMAINS is needed by this driver, because normally there is more than one PCIe controller and without PCI_DOMAINS only the first controller gets registered. This controller gets 6 IRQs; the last one is trigged by all IRQ events. [bhelgaas: fix "GPLv2" MODULE_LICENSE typo] Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Acked-by: Rafał Miłecki <zajec5@gmail.com> Acked-by: Ray Jui <rjui@broadcom.com.com>
-rw-r--r--drivers/pci/host/Kconfig11
-rw-r--r--drivers/pci/host/Makefile1
-rw-r--r--drivers/pci/host/pcie-iproc-bcma.c112
3 files changed, 124 insertions, 0 deletions
diff --git a/drivers/pci/host/Kconfig b/drivers/pci/host/Kconfig
index 1dfb567b3522..9ca90d2415f5 100644
--- a/drivers/pci/host/Kconfig
+++ b/drivers/pci/host/Kconfig
@@ -125,4 +125,15 @@ config PCIE_IPROC_PLATFORM
125 Say Y here if you want to use the Broadcom iProc PCIe controller 125 Say Y here if you want to use the Broadcom iProc PCIe controller
126 through the generic platform bus interface 126 through the generic platform bus interface
127 127
128config PCIE_IPROC_BCMA
129 bool "Broadcom iProc PCIe BCMA bus driver"
130 depends on ARCH_BCM_IPROC || (ARM && COMPILE_TEST)
131 select PCIE_IPROC
132 select BCMA
133 select PCI_DOMAINS
134 default ARCH_BCM_5301X
135 help
136 Say Y here if you want to use the Broadcom iProc PCIe controller
137 through the BCMA bus interface
138
128endmenu 139endmenu
diff --git a/drivers/pci/host/Makefile b/drivers/pci/host/Makefile
index f733b4e27642..2f7c36f08d6b 100644
--- a/drivers/pci/host/Makefile
+++ b/drivers/pci/host/Makefile
@@ -15,3 +15,4 @@ obj-$(CONFIG_PCI_LAYERSCAPE) += pci-layerscape.o
15obj-$(CONFIG_PCI_VERSATILE) += pci-versatile.o 15obj-$(CONFIG_PCI_VERSATILE) += pci-versatile.o
16obj-$(CONFIG_PCIE_IPROC) += pcie-iproc.o 16obj-$(CONFIG_PCIE_IPROC) += pcie-iproc.o
17obj-$(CONFIG_PCIE_IPROC_PLATFORM) += pcie-iproc-platform.o 17obj-$(CONFIG_PCIE_IPROC_PLATFORM) += pcie-iproc-platform.o
18obj-$(CONFIG_PCIE_IPROC_BCMA) += pcie-iproc-bcma.o
diff --git a/drivers/pci/host/pcie-iproc-bcma.c b/drivers/pci/host/pcie-iproc-bcma.c
new file mode 100644
index 000000000000..32119af0fe6a
--- /dev/null
+++ b/drivers/pci/host/pcie-iproc-bcma.c
@@ -0,0 +1,112 @@
1/*
2 * Copyright (C) 2015 Broadcom Corporation
3 * Copyright (C) 2015 Hauke Mehrtens <hauke@hauke-m.de>
4 *
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.
8 *
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.
13 */
14
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>
22
23#include "pcie-iproc.h"
24
25
26/* NS: CLASS field is R/O, and set to wrong 0x200 value */
27static void bcma_pcie2_fixup_class(struct pci_dev *dev)
28{
29 dev->class = PCI_CLASS_BRIDGE_PCI << 8;
30}
31DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_BROADCOM, 0x8011, bcma_pcie2_fixup_class);
32DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_BROADCOM, 0x8012, bcma_pcie2_fixup_class);
33
34static int iproc_pcie_bcma_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
35{
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);
39
40 return bcma_core_irq(bdev, 5);
41}
42
43static int iproc_pcie_bcma_probe(struct bcma_device *bdev)
44{
45 struct iproc_pcie *pcie;
46 LIST_HEAD(res);
47 struct resource res_mem;
48 int ret;
49
50 pcie = devm_kzalloc(&bdev->dev, sizeof(*pcie), GFP_KERNEL);
51 if (!pcie)
52 return -ENOMEM;
53
54 pcie->dev = &bdev->dev;
55 bcma_set_drvdata(bdev, pcie);
56
57 pcie->base = bdev->io_addr;
58
59 res_mem.start = bdev->addr_s[0];
60 res_mem.end = bdev->addr_s[0] + SZ_128M - 1;
61 res_mem.name = "PCIe MEM space";
62 res_mem.flags = IORESOURCE_MEM;
63 pci_add_resource(&res, &res_mem);
64
65 pcie->resources = &res;
66
67 pcie->map_irq = iproc_pcie_bcma_map_irq;
68
69 ret = iproc_pcie_setup(pcie);
70 if (ret) {
71 dev_err(pcie->dev, "PCIe controller setup failed\n");
72 return ret;
73 }
74
75 return 0;
76}
77
78static void iproc_pcie_bcma_remove(struct bcma_device *bdev)
79{
80 struct iproc_pcie *pcie = bcma_get_drvdata(bdev);
81
82 iproc_pcie_remove(pcie);
83}
84
85static const struct bcma_device_id iproc_pcie_bcma_table[] = {
86 BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_NS_PCIEG2, BCMA_ANY_REV, BCMA_ANY_CLASS),
87 {},
88};
89MODULE_DEVICE_TABLE(bcma, iproc_pcie_bcma_table);
90
91static struct bcma_driver iproc_pcie_bcma_driver = {
92 .name = KBUILD_MODNAME,
93 .id_table = iproc_pcie_bcma_table,
94 .probe = iproc_pcie_bcma_probe,
95 .remove = iproc_pcie_bcma_remove,
96};
97
98static int __init iproc_pcie_bcma_init(void)
99{
100 return bcma_driver_register(&iproc_pcie_bcma_driver);
101}
102module_init(iproc_pcie_bcma_init);
103
104static void __exit iproc_pcie_bcma_exit(void)
105{
106 bcma_driver_unregister(&iproc_pcie_bcma_driver);
107}
108module_exit(iproc_pcie_bcma_exit);
109
110MODULE_AUTHOR("Hauke Mehrtens");
111MODULE_DESCRIPTION("Broadcom iProc PCIe BCMA driver");
112MODULE_LICENSE("GPL v2");