Skip to contentSkip to conversation

pci: iproc: Add Broadcom iProc PCIe support

PATCH Applied Ray Jui 4 participants 10 messages Mar 11, 2015 – Mar 13, 2015

Subsystems (4)

v6 of 9 Applied Latest is v9 →

lore
Share & tools
lore

Ray Jui

author maintainer
#0 lore raw

v6 cover pci: iproc: Add Broadcom iProc PCIe support

This patch series adds the support for Broadcom iProc PCIe controller

pcie-iproc.c servers as the common core driver, and front-end bus interface needs to be added to support different bus interfaces

pcie-iproc-pltfm.c contains the support for the platform bus interface

Changes from v5:
- Sync code base to v4.0-rc2
- Change export symbols of common PCI functions to GPL only
- Add comment to describe how configuration register access are protected at the higher layer through 'pci_lock'
- Use generic PCI functions for configuration register access and implement 'map_bus' callback to support it
- Move 'pci_fixup_irqs' to before devices are added to the bus
- Remove 'extern' from function prototype declared in the header

Changes from v4:
- iProc PCIe driver module support was not included in patch series v4. This patch series (v5) fixes it

Changes from v3:
- Export symbols of several PCI functions so they can be used by drivers compiled as kernel module
- Add additional support to the Broadcom iProc PCIe driver so it can be installed/uninstalled as kernel loadable module

Changes from v2:
- Major rework of the PCIe driver to factor out common generic code from front-end bus interface. Support for generic platform bus interface is also added
- Adapt to several new PCI APIs that have been introduced lately

Changes from v1:
- Add standard PCI interrupt DT properties "#interrupt-cells", "interrupt-map-mask" and "interrupt-map" so legacy INTx interrupts can be supported by using standard PCI OF IRQ parsing function
- Get rid of custom IRQ mapping function in the driver. Use of_irq_parse_and_map_pci instead

Ray Jui (4):
PCI: Export symbols of PCI functions
pci: iProc: define iProc PCIe platform bus binding
pci: iproc: Add Broadcom iProc PCIe support
ARM: dts: enable PCIe support for Cygnus

 .../devicetree/bindings/pci/brcm,iproc-pcie.txt    |   63 +++++
 arch/arm/boot/dts/bcm-cygnus.dtsi                  |   42 +++
 arch/arm/boot/dts/bcm958300k.dts                   |    8 +
 drivers/pci/host/Kconfig                           |   17 ++
 drivers/pci/host/Makefile                          |    2 +
 drivers/pci/host/pcie-iproc-pltfm.c                |  108 ++++++++
 drivers/pci/host/pcie-iproc.c                      |  268 ++++++++++++++++++++
 drivers/pci/host/pcie-iproc.h                      |   42 +++
 drivers/pci/pci.c                                  |    1 +
 drivers/pci/probe.c                                |    1 +
 drivers/pci/remove.c                               |    2 +
 drivers/pci/setup-bus.c                            |    1 +
 drivers/pci/setup-irq.c                            |    1 +
 13 files changed, 556 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pci/brcm,iproc-pcie.txt
 create mode 100644 drivers/pci/host/pcie-iproc-pltfm.c
 create mode 100644 drivers/pci/host/pcie-iproc.c
 create mode 100644 drivers/pci/host/pcie-iproc.h
Signature · 1 line
1.7.9.5
author maintainer
#1 lore raw

PATCH v6 1/4 PCI: Export symbols of PCI functions

Export symbols of the following PCI functions so they can be referenced by a PCI driver compiled as a kernel loadable module:

pci_common_swizzle
pci_create_root_bus
pci_stop_root_bus
pci_remove_root_bus
pci_assign_unassigned_bus_resources
pci_fixup_irqs

---
 drivers/pci/pci.c       |    1 +
 drivers/pci/probe.c     |    1 +
 drivers/pci/remove.c    |    2 ++
 drivers/pci/setup-bus.c |    1 +
 drivers/pci/setup-irq.c |    1 +
 5 files changed, 6 insertions(+)
drivers/pci/pci.c +1 -0
index 81f06e8..14e7f3c 100644
@@ -2492,6 +2492,7 @@ u8 pci_common_swizzle(struct pci_dev *dev, u8 *pinp)
 	*pinp = pin;
 	return PCI_SLOT(dev->devfn);
 }
+EXPORT_SYMBOL_GPL(pci_common_swizzle);
 
 /**
  *	pci_release_region - Release a PCI bar
drivers/pci/probe.c +1 -0
index 8d2f400..f13a78a 100644
@@ -1993,6 +1993,7 @@ err_out:
 	kfree(b);
 	return NULL;
 }
+EXPORT_SYMBOL_GPL(pci_create_root_bus);
 
 int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int bus_max)
 {
drivers/pci/remove.c +2 -0
index 8bd76c9..8a280e9 100644
@@ -139,6 +139,7 @@ void pci_stop_root_bus(struct pci_bus *bus)
 	/* stop the host bridge */
 	device_release_driver(&host_bridge->dev);
 }
+EXPORT_SYMBOL_GPL(pci_stop_root_bus);
 
 void pci_remove_root_bus(struct pci_bus *bus)
 {
@@ -158,3 +159,4 @@ void pci_remove_root_bus(struct pci_bus *bus)
 	/* remove the host bridge */
 	device_unregister(&host_bridge->dev);
 }
+EXPORT_SYMBOL_GPL(pci_remove_root_bus);
drivers/pci/setup-bus.c +1 -0
index e3e17f3..8169597 100644
@@ -1750,3 +1750,4 @@ void pci_assign_unassigned_bus_resources(struct pci_bus *bus)
 	__pci_bus_assign_resources(bus, &add_list, NULL);
 	BUG_ON(!list_empty(&add_list));
 }
+EXPORT_SYMBOL_GPL(pci_assign_unassigned_bus_resources);
drivers/pci/setup-irq.c +1 -0
index 4e2d595..95c225b 100644
@@ -65,3 +65,4 @@ void pci_fixup_irqs(u8 (*swizzle)(struct pci_dev *, u8 *),
 	for_each_pci_dev(dev)
 		pdev_fixup_irq(dev, swizzle, map_irq);
 }
+EXPORT_SYMBOL_GPL(pci_fixup_irqs);
Signature · 1 line
1.7.9.5
author maintainer
#2 lore raw

PATCH v6 2/4 pci: iProc: define iProc PCIe platform bus binding

In reply to Ray Jui

Document the Broadcom iProc PCIe platform interface device tree binding

---
 .../devicetree/bindings/pci/brcm,iproc-pcie.txt    |   63 ++++++++++++++++++++
 1 file changed, 63 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pci/brcm,iproc-pcie.txt
Documentation/devicetree/bindings/pci/brcm,iproc-pcie.txt new file +63 -0
new file mode 100644
index 0000000..f7ce50e
@@ -0,0 +1,63 @@
+* Broadcom iProc PCIe controller with the platform bus interface
+
+Required properties:
+- compatible: Must be "brcm,iproc-pcie"
+- reg: base address and length of the PCIe controller I/O register space
+- #interrupt-cells: set to <1>
+- interrupt-map-mask and interrupt-map, standard PCI properties to define the
+  mapping of the PCIe interface to interrupt numbers
+- linux,pci-domain: PCI domain ID. Should be unique for each host controller
+- bus-range: PCI bus numbers covered
+- #address-cells: set to <3>
+- #size-cells: set to <2>
+- device_type: set to "pci"
+- ranges: ranges for the PCI memory and I/O regions
+
+Optional properties:
+- phys: phandle of the PCIe PHY device
+- phy-names: must be "pcie-phy"
+
+Example:
+	pcie0: pcie@18012000 {
+		compatible = "brcm,iproc-pcie";
+		reg = <0x18012000 0x1000>;
+
+		#interrupt-cells = <1>;
+		interrupt-map-mask = <0 0 0 0>;
+		interrupt-map = <0 0 0 0 &gic GIC_SPI 100 IRQ_TYPE_NONE>;
+
+		linux,pci-domain = <0>;
+
+		bus-range = <0x00 0xff>;
+
+		#address-cells = <3>;
+		#size-cells = <2>;
+		device_type = "pci";
+		ranges = <0x81000000 0 0	  0x28000000 0 0x00010000
+			  0x82000000 0 0x20000000 0x20000000 0 0x04000000>;
+
+		phys = <&phy 0 5>;
+		phy-names = "pcie-phy";
+	};
+
+	pcie1: pcie@18013000 {
+		compatible = "brcm,iproc-pcie";
+		reg = <0x18013000 0x1000>;
+
+		#interrupt-cells = <1>;
+		interrupt-map-mask = <0 0 0 0>;
+		interrupt-map = <0 0 0 0 &gic GIC_SPI 106 IRQ_TYPE_NONE>;
+
+		linux,pci-domain = <1>;
+
+		bus-range = <0x00 0xff>;
+
+		#address-cells = <3>;
+		#size-cells = <2>;
+		device_type = "pci";
+		ranges = <0x81000000 0 0	  0x48000000 0 0x00010000
+			  0x82000000 0 0x40000000 0x40000000 0 0x04000000>;
+
+		phys = <&phy 1 6>;
+		phy-names = "pcie-phy";
+	};
Signature · 1 line
1.7.9.5
maintainer
#3 lore raw

Re: [PATCH v6 2/4] pci: iProc: define iProc PCIe platform bus binding

[+cc Rob, Pawel, Mark, Ian, Kumar]

Quoted 4 lines · Ray Jui

Document the Broadcom iProc PCIe platform interface device tree binding

I'd like to get an ack for this from Arnd, Rob, or other device tree folks (CC'd).

Quoted 77 lines
---
 .../devicetree/bindings/pci/brcm,iproc-pcie.txt    |   63 ++++++++++++++++++++
 1 file changed, 63 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pci/brcm,iproc-pcie.txt
Documentation/devicetree/bindings/pci/brcm,iproc-pcie.txt new file +63 -0
new file mode 100644
index 0000000..f7ce50e
@@ -0,0 +1,63 @@
+* Broadcom iProc PCIe controller with the platform bus interface
+
+Required properties:
+- compatible: Must be "brcm,iproc-pcie"
+- reg: base address and length of the PCIe controller I/O register space
+- #interrupt-cells: set to <1>
+- interrupt-map-mask and interrupt-map, standard PCI properties to define the
+  mapping of the PCIe interface to interrupt numbers
+- linux,pci-domain: PCI domain ID. Should be unique for each host controller
+- bus-range: PCI bus numbers covered
+- #address-cells: set to <3>
+- #size-cells: set to <2>
+- device_type: set to "pci"
+- ranges: ranges for the PCI memory and I/O regions
+
+Optional properties:
+- phys: phandle of the PCIe PHY device
+- phy-names: must be "pcie-phy"
+
+Example:
+	pcie0: pcie at 18012000 {
+		compatible = "brcm,iproc-pcie";
+		reg = <0x18012000 0x1000>;
+
+		#interrupt-cells = <1>;
+		interrupt-map-mask = <0 0 0 0>;
+		interrupt-map = <0 0 0 0 &gic GIC_SPI 100 IRQ_TYPE_NONE>;
+
+		linux,pci-domain = <0>;
+
+		bus-range = <0x00 0xff>;
+
+		#address-cells = <3>;
+		#size-cells = <2>;
+		device_type = "pci";
+		ranges = <0x81000000 0 0	  0x28000000 0 0x00010000
+			  0x82000000 0 0x20000000 0x20000000 0 0x04000000>;
+
+		phys = <&phy 0 5>;
+		phy-names = "pcie-phy";
+	};
+
+	pcie1: pcie at 18013000 {
+		compatible = "brcm,iproc-pcie";
+		reg = <0x18013000 0x1000>;
+
+		#interrupt-cells = <1>;
+		interrupt-map-mask = <0 0 0 0>;
+		interrupt-map = <0 0 0 0 &gic GIC_SPI 106 IRQ_TYPE_NONE>;
+
+		linux,pci-domain = <1>;
+
+		bus-range = <0x00 0xff>;
+
+		#address-cells = <3>;
+		#size-cells = <2>;
+		device_type = "pci";
+		ranges = <0x81000000 0 0	  0x48000000 0 0x00010000
+			  0x82000000 0 0x40000000 0x40000000 0 0x04000000>;
+
+		phys = <&phy 1 6>;
+		phy-names = "pcie-phy";
+	};
Signature · 1 line
1.7.9.5
Acked-by
#4 lore raw

Re: [PATCH v6 2/4] pci: iProc: define iProc PCIe platform bus binding

Quoted 11 lines · On Thursday 12 March 2015 16:14:48 Bjorn Helgaas wrote:

[+cc Rob, Pawel, Mark, Ian, Kumar]

Quoted 4 lines · Ray Jui

Document the Broadcom iProc PCIe platform interface device tree binding

I'd like to get an ack for this from Arnd, Rob, or other device tree folks (CC'd).

Sorry, I should have given my ack earlier. I've carefully reviewed the previous versions and am happy with the current one.

for the whole series.

Arnd

author maintainer
#5 lore raw

PATCH v6 3/4 pci: iproc: Add Broadcom iProc PCIe support

In reply to Ray Jui

This adds the support for Broadcom iProc PCIe controller

pcie-iproc.c servers as the common core driver, and front-end bus interface needs to be added to support different bus interfaces

pcie-iproc-pltfm.c contains the support for the platform bus interface

---
 drivers/pci/host/Kconfig            |   17 +++
 drivers/pci/host/Makefile           |    2 +
 drivers/pci/host/pcie-iproc-pltfm.c |  108 ++++++++++++++
 drivers/pci/host/pcie-iproc.c       |  268 +++++++++++++++++++++++++++++++++++
 drivers/pci/host/pcie-iproc.h       |   42 ++++++
 5 files changed, 437 insertions(+)
 create mode 100644 drivers/pci/host/pcie-iproc-pltfm.c
 create mode 100644 drivers/pci/host/pcie-iproc.c
 create mode 100644 drivers/pci/host/pcie-iproc.h
drivers/pci/host/Kconfig +17 -0
index 7b892a9..f4d9c90 100644
@@ -106,4 +106,21 @@ config PCI_VERSATILE
 	bool "ARM Versatile PB PCI controller"
 	depends on ARCH_VERSATILE
 
+config PCIE_IPROC
+	tristate "Broadcom iProc PCIe controller"
+	help
+	  This enables the iProc PCIe core controller support for Broadcom's
+	  iProc family of SoCs. An appropriate bus interface driver also needs
+	  to be enabled
+
+config PCIE_IPROC_PLTFM
+	tristate "Broadcom iProc PCIe platform bus driver"
+	depends on ARCH_BCM_IPROC || COMPILE_TEST
+	depends on OF
+	select PCIE_IPROC
+	default ARCH_BCM_IPROC
+	help
+	  Say Y here if you want to use the Broadcom iProc PCIe controller
+	  through the generic platform bus interface
+
 endmenu
drivers/pci/host/Makefile +2 -0
index e61d91c..2e02d20 100644
@@ -13,3 +13,5 @@ obj-$(CONFIG_PCIE_XILINX) += pcie-xilinx.o
 obj-$(CONFIG_PCI_XGENE) += pci-xgene.o
 obj-$(CONFIG_PCI_LAYERSCAPE) += pci-layerscape.o
 obj-$(CONFIG_PCI_VERSATILE) += pci-versatile.o
+obj-$(CONFIG_PCIE_IPROC) += pcie-iproc.o
+obj-$(CONFIG_PCIE_IPROC_PLTFM) += pcie-iproc-pltfm.o
drivers/pci/host/pcie-iproc-pltfm.c new file +108 -0

108 lines not on this page · raw message

drivers/pci/host/pcie-iproc.c new file +268 -0

268 lines not on this page · raw message

drivers/pci/host/pcie-iproc.h new file +42 -0

42 lines not on this page · raw message

Signature · 1 line
1.7.9.5
maintainer
#6 lore raw
Quoted 12 lines · Ray Jui

This adds the support for Broadcom iProc PCIe controller

pcie-iproc.c servers as the common core driver, and front-end bus interface needs to be added to support different bus interfaces

pcie-iproc-pltfm.c contains the support for the platform bus interface

...

drivers/pci/host/pcie-iproc.c new file +1 -0
+static int iproc_pcie_check_link(struct iproc_pcie *pcie, struct pci_bus *bus)

drivers/pci/host/pcie-iproc.c line 136

Quoted 10 lines
drivers/pci/host/pcie-iproc.c new file +10 -0
+{
+	u8 hdr_type;
+	u32 link_ctrl;
+	u16 pos, link_status;
+	int link_is_active = 0;
+
+	/* make sure we are not in EP mode */
+	pci_bus_read_config_byte(bus, 0, PCI_HEADER_TYPE, &hdr_type);
+	if ((hdr_type & 0x7f) != PCI_HEADER_TYPE_BRIDGE) {
+		dev_err(pcie->dev, "in EP mode, hdr=0x08%x\n", hdr_type);

"0x08%x" doesn't look right. I changed it to "%#02x"; is that what you intended?

author maintainer
#7 lore raw
Quoted 12 lines · Bjorn Helgaas
Quoted 10 lines · Ray Jui

This adds the support for Broadcom iProc PCIe controller

pcie-iproc.c servers as the common core driver, and front-end bus interface needs to be added to support different bus interfaces

pcie-iproc-pltfm.c contains the support for the platform bus interface

...

Quoted 15 lines

drivers/pci/host/pcie-iproc.c line 136

Quoted 11 lines
drivers/pci/host/pcie-iproc.c new file +11 -0
+static int iproc_pcie_check_link(struct iproc_pcie *pcie, struct pci_bus *bus)
+{
+	u8 hdr_type;
+	u32 link_ctrl;
+	u16 pos, link_status;
+	int link_is_active = 0;
+
+	/* make sure we are not in EP mode */
+	pci_bus_read_config_byte(bus, 0, PCI_HEADER_TYPE, &hdr_type);
+	if ((hdr_type & 0x7f) != PCI_HEADER_TYPE_BRIDGE) {
+		dev_err(pcie->dev, "in EP mode, hdr=0x08%x\n", hdr_type);

"0x08%x" doesn't look right. I changed it to "%#02x"; is that what you intended?

You are right. Will fix it along with the Kconfig fix (so it won't get compiled for non-ARM platforms). I'll submit v7?

Thanks,

Ray

author maintainer
#8 lore raw

PATCH v6 4/4 ARM: dts: enable PCIe support for Cygnus

In reply to Ray Jui

Add PCIe device nodes in bcm-cygnus.dtsi but keep them disabled there. Only enable them for bcm958300k where PCIe interfaces are populated

---
 arch/arm/boot/dts/bcm-cygnus.dtsi |   42 +++++++++++++++++++++++++++++++++++++
 arch/arm/boot/dts/bcm958300k.dts  |    8 +++++++
 2 files changed, 50 insertions(+)
arch/arm/boot/dts/bcm-cygnus.dtsi +42 -0
index ff5fb6a..ee0c6e4 100644
@@ -90,6 +90,48 @@
 		status = "disabled";
 	};
 
+	pcie0: pcie@18012000 {
+		compatible = "brcm,iproc-pcie";
+		reg = <0x18012000 0x1000>;
+
+		#interrupt-cells = <1>;
+		interrupt-map-mask = <0 0 0 0>;
+		interrupt-map = <0 0 0 0 &gic GIC_SPI 100 IRQ_TYPE_NONE>;
+
+		linux,pci-domain = <0>;
+
+		bus-range = <0x00 0xff>;
+
+		#address-cells = <3>;
+		#size-cells = <2>;
+		device_type = "pci";
+		ranges = <0x81000000 0 0	  0x28000000 0 0x00010000
+			  0x82000000 0 0x20000000 0x20000000 0 0x04000000>;
+
+		status = "disabled";
+	};
+
+	pcie1: pcie@18013000 {
+		compatible = "brcm,iproc-pcie";
+		reg = <0x18013000 0x1000>;
+
+		#interrupt-cells = <1>;
+		interrupt-map-mask = <0 0 0 0>;
+		interrupt-map = <0 0 0 0 &gic GIC_SPI 106 IRQ_TYPE_NONE>;
+
+		linux,pci-domain = <1>;
+
+		bus-range = <0x00 0xff>;
+
+		#address-cells = <3>;
+		#size-cells = <2>;
+		device_type = "pci";
+		ranges = <0x81000000 0 0	  0x48000000 0 0x00010000
+			  0x82000000 0 0x40000000 0x40000000 0 0x04000000>;
+
+		status = "disabled";
+	};
+
 	uart0: serial@18020000 {
 		compatible = "snps,dw-apb-uart";
 		reg = <0x18020000 0x100>;
arch/arm/boot/dts/bcm958300k.dts +8 -0
index f1bb36f..c9eb856 100644
@@ -47,6 +47,14 @@
 		bootargs = "console=ttyS0,115200";
 	};
 
+	pcie0: pcie@18012000 {
+		status = "okay";
+	};
+
+	pcie1: pcie@18013000 {
+		status = "okay";
+	};
+
 	uart3: serial@18023000 {
 		status = "okay";
 	};
Signature · 1 line
1.7.9.5
#9 lore raw

Re: [PATCH v6 4/4] ARM: dts: enable PCIe support for Cygnus

Quoted 5 lines · Ray Jui

Add PCIe device nodes in bcm-cygnus.dtsi but keep them disabled there. Only enable them for bcm958300k where PCIe interfaces are populated

Applied to devicetree/next with Arnd's acked-by, thanks!

Signature · 1 line
Florian