Skip to contentSkip to conversation

pci: Add host controller driver for Cavium ThunderX PCIe

PATCH Superseded David Daney 3 participants 5 messages Dec 22, 2015 – Jan 4, 2016

Subsystems (3)

v2 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v2 cover pci: Add host controller driver for Cavium ThunderX PCIe

From: David Daney <[email protected]>

Some Cavium ThunderX processors require quirky access methods for the config space of the PCIe bridge.

There are two patches:

1) Refactor code in pci-host-generic so that it can more easily be used by other drivers. This splits the driver for CAM and ECAM access methods to a separate file from the common host driver code.

2) Add the ThunderX PCIe driver, which leverages the code in pci-host-generic

Changes from v1: Split CAM and ECAM code from common driver code as suggested by Arnd Bergmann. Fix spelling errors in pcie-thunder-pem.txt

David Daney (2):
PCI: generic: Refactor code to enable reuse by other drivers. pci, pcie-thunder-pem: Add PCIe host driver for ThunderX processors.

 .../devicetree/bindings/pci/pcie-thunder-pem.txt   |  43 ++++
 drivers/pci/host/Kconfig                           |  11 +
 drivers/pci/host/Makefile                          |   2 +
 drivers/pci/host/pci-host-common.c                 | 194 ++++++++++++++
 drivers/pci/host/pci-host-common.h                 |  56 ++++
 drivers/pci/host/pci-host-generic.c                | 190 +-------------
 drivers/pci/host/pcie-thunder-pem.c                | 283 +++++++++++++++++++++
 7 files changed, 593 insertions(+), 186 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/pci/pcie-thunder-pem.txt
 create mode 100644 drivers/pci/host/pci-host-common.c
 create mode 100644 drivers/pci/host/pci-host-common.h
 create mode 100644 drivers/pci/host/pcie-thunder-pem.c
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH v2 1/2 PCI: generic: Refactor code to enable reuse by other drivers.

From: David Daney <[email protected]>

No change in functionality.

Move structure definitions into a separate header file. Move common code to new file with Kconfig machinery to build it. Split probe function in to two parts:

- a small driver specific probe function (gen_pci_probe)

- a common probe that can be used by other drivers (pci_host_common_probe)

---
 drivers/pci/host/Kconfig            |   4 +
 drivers/pci/host/Makefile           |   1 +
 drivers/pci/host/pci-host-common.c  | 194 ++++++++++++++++++++++++++++++++++++
 drivers/pci/host/pci-host-common.h  |  56 +++++++++++
 drivers/pci/host/pci-host-generic.c | 190 +----------------------------------
 5 files changed, 259 insertions(+), 186 deletions(-)
 create mode 100644 drivers/pci/host/pci-host-common.c
 create mode 100644 drivers/pci/host/pci-host-common.h
drivers/pci/host/Kconfig +4 -0
index f131ba9..f171459 100644
@@ -53,9 +53,13 @@ config PCI_RCAR_GEN2_PCIE
 	help
 	  Say Y here if you want PCIe controller support on R-Car Gen2 SoCs.
 
+config PCI_HOST_COMMON
+	bool
+
 config PCI_HOST_GENERIC
 	bool "Generic PCI host controller"
 	depends on (ARM || ARM64) && OF
+	select PCI_HOST_COMMON
 	help
 	  Say Y here if you want to support a simple generic PCI host
 	  controller, such as the one emulated by kvmtool.
drivers/pci/host/Makefile +1 -0
index 9d4d3c6..ba2c51f 100644
@@ -6,6 +6,7 @@ obj-$(CONFIG_PCI_MVEBU) += pci-mvebu.o
 obj-$(CONFIG_PCI_TEGRA) += pci-tegra.o
 obj-$(CONFIG_PCI_RCAR_GEN2) += pci-rcar-gen2.o
 obj-$(CONFIG_PCI_RCAR_GEN2_PCIE) += pcie-rcar.o
+obj-$(CONFIG_PCI_HOST_COMMON) += pci-host-common.o
 obj-$(CONFIG_PCI_HOST_GENERIC) += pci-host-generic.o
 obj-$(CONFIG_PCIE_SPEAR13XX) += pcie-spear13xx.o
 obj-$(CONFIG_PCI_KEYSTONE) += pci-keystone-dw.o pci-keystone.o
drivers/pci/host/pci-host-common.c new file +194 -0

194 lines not on this page · raw message

drivers/pci/host/pci-host-common.h new file +56 -0

56 lines not on this page · raw message

drivers/pci/host/pci-host-generic.c +4 -186

212 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#2 lore raw

PATCH v2 2/2 pci, pcie-thunder-pem: Add PCIe host driver for ThunderX processors.

In reply to David Daney

From: David Daney <[email protected]>

Some Cavium ThunderX processors require quirky access methods for the config space of the PCIe bridge. Add a driver to provide these config space accessor functions. The pci-host-common code is used to configure the PCI machinery.

---
 .../devicetree/bindings/pci/pcie-thunder-pem.txt   |  43 ++++
 drivers/pci/host/Kconfig                           |   7 +
 drivers/pci/host/Makefile                          |   1 +
 drivers/pci/host/pcie-thunder-pem.c                | 283 +++++++++++++++++++++
 4 files changed, 334 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pci/pcie-thunder-pem.txt
 create mode 100644 drivers/pci/host/pcie-thunder-pem.c
Documentation/devicetree/bindings/pci/pcie-thunder-pem.txt new file +43 -0
new file mode 100644
index 0000000..52f56b3
@@ -0,0 +1,43 @@
+* ThunderX PEM PCIe host controller
+
+Firmware-initialized PCIe host controller found on some Cavium
+ThunderX processors.
+
+The properties and their meanings are identical to those described in
+host-generic-pci.txt except as listed below.
+
+Properties of the host controller node that differ from
+host-generic-pci.txt:
+
+- compatible     : Must be "cavium,pci-host-thunder-pem"
+
+- reg            : Two entries: First the configuration space for down
+                   stream devices base address and size, as accessed
+                   from the parent bus. Second, the register bank of
+                   the PEM device PCIe bridge.
+
+Example:
+
+    pem2 {
+	compatible = "cavium,pci-host-thunder-pem";
+	device_type = "pci";
+	msi-parent = <&its>;
+	msi-map = <0 &its 0x10000 0x10000>;
+	bus-range = <0x8f 0xc7>;
+	#size-cells = <2>;
+	#address-cells = <3>;
+
+	reg = <0x8880 0x8f000000 0x0 0x39000000>,  /* Configuration space */
+	      <0x87e0 0xc2000000 0x0 0x00010000>; /* PEM space */
+	ranges = <0x01000000 0x00 0x00020000 0x88b0 0x00020000 0x00 0x00010000>, /* I/O */
+		 <0x03000000 0x00 0x10000000 0x8890 0x10000000 0x0f 0xf0000000>, /* mem64 */
+		 <0x43000000 0x10 0x00000000 0x88a0 0x00000000 0x10 0x00000000>, /* mem64-pref */
+		 <0x03000000 0x87e0 0xc2f00000 0x87e0 0xc2000000 0x00 0x00100000>; /* mem64 PEM BAR4 */
+
+	#interrupt-cells = <1>;
+	interrupt-map-mask = <0 0 0 7>;
+	interrupt-map = <0 0 0 1 &gic0 0 0 0 24 4>, /* INTA */
+			<0 0 0 2 &gic0 0 0 0 25 4>, /* INTB */
+			<0 0 0 3 &gic0 0 0 0 26 4>, /* INTC */
+			<0 0 0 4 &gic0 0 0 0 27 4>; /* INTD */
+    };
drivers/pci/host/Kconfig +7 -0
index f171459..6885667 100644
@@ -176,4 +176,11 @@ config PCI_HISI
 	help
 	  Say Y here if you want PCIe controller support on HiSilicon HIP05 SoC
 
+config PCIE_HOST_THUNDER_PEM
+	bool "Cavium Thunder PCIe controller to off-chip devices"
+	depends on OF && ARM64
+	select PCI_HOST_COMMON
+	help
+	  Say Y here if you want PCIe support for CN88XX Cavium Thunder SoCs.
+
 endmenu
drivers/pci/host/Makefile +1 -0
index ba2c51f..e3f3c78 100644
@@ -21,3 +21,4 @@ obj-$(CONFIG_PCIE_IPROC_BCMA) += pcie-iproc-bcma.o
 obj-$(CONFIG_PCIE_ALTERA) += pcie-altera.o
 obj-$(CONFIG_PCIE_ALTERA_MSI) += pcie-altera-msi.o
 obj-$(CONFIG_PCI_HISI) += pcie-hisi.o
+obj-$(CONFIG_PCIE_HOST_THUNDER_PEM) += pcie-thunder-pem.o
drivers/pci/host/pcie-thunder-pem.c new file +283 -0

283 lines not on this page · raw message

Signature · 1 line
1.8.3.1
maintainer
#3 lore raw

Re: [PATCH v2 2/2] pci, pcie-thunder-pem: Add PCIe host driver for ThunderX processors.

Quoted 6 lines · David Daney

From: David Daney <[email protected]>

Some Cavium ThunderX processors require quirky access methods for the config space of the PCIe bridge. Add a driver to provide these config space accessor functions. The pci-host-common code is used to configure the PCI machinery.

Same comments again...

Quoted 18 lines
---
 .../devicetree/bindings/pci/pcie-thunder-pem.txt   |  43 ++++
 drivers/pci/host/Kconfig                           |   7 +
 drivers/pci/host/Makefile                          |   1 +
 drivers/pci/host/pcie-thunder-pem.c                | 283 +++++++++++++++++++++
 4 files changed, 334 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pci/pcie-thunder-pem.txt
 create mode 100644 drivers/pci/host/pcie-thunder-pem.c
Documentation/devicetree/bindings/pci/pcie-thunder-pem.txt new file +2 -0
new file mode 100644
index 0000000..52f56b3
@@ -0,0 +1,43 @@
+* ThunderX PEM PCIe host controller
+

Documentation/devicetree/bindings/pci/pcie-thunder-pem.txt line 12

Quoted 10 lines
Documentation/devicetree/bindings/pci/pcie-thunder-pem.txt new file +10 -0
+Firmware-initialized PCIe host controller found on some Cavium
+ThunderX processors.
+
+The properties and their meanings are identical to those described in
+host-generic-pci.txt except as listed below.
+
+Properties of the host controller node that differ from
+host-generic-pci.txt:
+
+- compatible     : Must be "cavium,pci-host-thunder-pem"

pcie rather than pci?

Documentation/devicetree/bindings/pci/pcie-thunder-pem.txt line 21

Quoted 9 lines
Documentation/devicetree/bindings/pci/pcie-thunder-pem.txt new file +9 -0
+
+- reg            : Two entries: First the configuration space for down
+                   stream devices base address and size, as accessed
+                   from the parent bus. Second, the register bank of
+                   the PEM device PCIe bridge.
+
+Example:
+
+    pem2 {

pcie-controller at ... instead of pem2.

Quoted 22 lines
Documentation/devicetree/bindings/pci/pcie-thunder-pem.txt new file +22 -0
+	compatible = "cavium,pci-host-thunder-pem";
+	device_type = "pci";
+	msi-parent = <&its>;
+	msi-map = <0 &its 0x10000 0x10000>;
+	bus-range = <0x8f 0xc7>;
+	#size-cells = <2>;
+	#address-cells = <3>;
+
+	reg = <0x8880 0x8f000000 0x0 0x39000000>,  /* Configuration space */
+	      <0x87e0 0xc2000000 0x0 0x00010000>; /* PEM space */
+	ranges = <0x01000000 0x00 0x00020000 0x88b0 0x00020000 0x00 0x00010000>, /* I/O */
+		 <0x03000000 0x00 0x10000000 0x8890 0x10000000 0x0f 0xf0000000>, /* mem64 */
+		 <0x43000000 0x10 0x00000000 0x88a0 0x00000000 0x10 0x00000000>, /* mem64-pref */
+		 <0x03000000 0x87e0 0xc2f00000 0x87e0 0xc2000000 0x00 0x00100000>; /* mem64 PEM BAR4 */
+
+	#interrupt-cells = <1>;
+	interrupt-map-mask = <0 0 0 7>;
+	interrupt-map = <0 0 0 1 &gic0 0 0 0 24 4>, /* INTA */
+			<0 0 0 2 &gic0 0 0 0 25 4>, /* INTB */
+			<0 0 0 3 &gic0 0 0 0 26 4>, /* INTC */
+			<0 0 0 4 &gic0 0 0 0 27 4>; /* INTD */
+    };
#4 lore raw

Re: [PATCH v2 2/2] pci, pcie-thunder-pem: Add PCIe host driver for ThunderX processors.

Quoted 9 lines · Rob Herring
Quoted 6 lines · David Daney

From: David Daney <[email protected]>

Some Cavium ThunderX processors require quirky access methods for the config space of the PCIe bridge. Add a driver to provide these config space accessor functions. The pci-host-common code is used to configure the PCI machinery.

Same comments again...

Yes, I think your initial reply and my v2 must have crossed in mid-flight. Then I was on holiday, but now I can respond...

Quoted 23 lines
Quoted 23 lines
---
  .../devicetree/bindings/pci/pcie-thunder-pem.txt   |  43 ++++
  drivers/pci/host/Kconfig                           |   7 +
  drivers/pci/host/Makefile                          |   1 +
  drivers/pci/host/pcie-thunder-pem.c                | 283 +++++++++++++++++++++
  4 files changed, 334 insertions(+)

create mode 100644 Documentation/devicetree/bindings/pci/pcie-thunder-pem.txt create mode 100644 drivers/pci/host/pcie-thunder-pem.c

Documentation/devicetree/bindings/pci/pcie-thunder-pem.txt new file +6 -0
new file mode 100644
index 0000000..52f56b3
@@ -0,0 +1,43 @@
+* ThunderX PEM PCIe host controller
+
+Firmware-initialized PCIe host controller found on some Cavium
+ThunderX processors.
+
+The properties and their meanings are identical to those described in
Quoted 8 lines

Documentation/devicetree/bindings/pci/pcie-thunder-pem.txt line 12

Quoted 6 lines
Documentation/devicetree/bindings/pci/pcie-thunder-pem.txt new file +6 -0
+host-generic-pci.txt except as listed below.
+
+Properties of the host controller node that differ from
+host-generic-pci.txt:
+
+- compatible     : Must be "cavium,pci-host-thunder-pem"

pcie rather than pci?

Technically it is a PCI host controller at the root, and doesn't become PCIe until we traverse a PCIe RC bridge, Because of this, and also because there is deployed firmware supplying this compatible string, I would like to keep the name as is.

If you really want consistency, we could rename the driver (and this binding description file) to be pci-thunder-pem.

Quoted 12 lines

Documentation/devicetree/bindings/pci/pcie-thunder-pem.txt line 21

Quoted 10 lines
Documentation/devicetree/bindings/pci/pcie-thunder-pem.txt new file +9 -0
+
+- reg            : Two entries: First the configuration space for down
+                   stream devices base address and size, as accessed
+                   from the parent bus. Second, the register bank of
+                   the PEM device PCIe bridge.
+
+Example:
+
+    pem2 {

pcie-controller at ... instead of pem2.

That is purely cosmetic, as the names are not used for anything. I can change it as you suggest.

[...]

Thanks,
David Daney