Skip to contentSkip to conversation

Add host controller drivers for Cavium ThunderX PCI

PATCH Superseded David Daney 2 participants 5 messages Feb 8, 2016 – Feb 24, 2016

Subsystems (3)

v6 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v6 cover Add host controller drivers for Cavium ThunderX PCI

From: David Daney <[email protected]>

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

There are now three 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 to external PCIe buses, which leverages the code in pci-host-generic

3) Add ThunderX PCI driver for internel SoC buses used on early ThunderX chip revisions.

Changes from v5: Added Acked-by Rob Herring for the device tree binding in 3/3. Fixed typo and split large functions as suggested by Bjorn Helgaas.

Changes from v4: Added patch 3/3. Stylistic changes to 2/3 suggested by Bjorn Helgaas. When expanding config write width to 32-bits, mask out unintened writes to W1C bits, also suggested by Bjorn Helgaas.

Changes from v3: Add some Acked-by, rebased to v4.5.0-rc1

Changes from v2: Improve device tree binding example as noted by Rob Herring. Rename pcie-thunder-pem.* to pci-thunder-pem.* for better consistency. Update MAINTAINERS to reflect the changes.

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 (3):
PCI: generic: Refactor code to enable reuse by other drivers. pci, pci-thunder-pem: Add PCIe host driver for ThunderX processors. pci, pci-thunder-ecam: Add driver for ThunderX-pass1 on-chip devices

 .../devicetree/bindings/pci/pci-thunder-ecam.txt   |  30 ++
 .../devicetree/bindings/pci/pci-thunder-pem.txt    |  43 +++
 MAINTAINERS                                        |   9 +
 drivers/pci/host/Kconfig                           |  18 ++
 drivers/pci/host/Makefile                          |   3 +
 drivers/pci/host/pci-host-common.c                 | 194 +++++++++++
 drivers/pci/host/pci-host-common.h                 |  47 +++
 drivers/pci/host/pci-host-generic.c                | 181 +----------
 drivers/pci/host/pci-thunder-ecam.c                | 358 +++++++++++++++++++++
 drivers/pci/host/pci-thunder-pem.c                 | 347 ++++++++++++++++++++
 10 files changed, 1053 insertions(+), 177 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/pci/pci-thunder-ecam.txt
 create mode 100644 Documentation/devicetree/bindings/pci/pci-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/pci-thunder-ecam.c
 create mode 100644 drivers/pci/host/pci-thunder-pem.c
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH v6 1/3 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)

---
 MAINTAINERS                         |   1 +
 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  |  47 +++++++++
 drivers/pci/host/pci-host-generic.c | 181 +--------------------------------
 6 files changed, 251 insertions(+), 177 deletions(-)
 create mode 100644 drivers/pci/host/pci-host-common.c
 create mode 100644 drivers/pci/host/pci-host-common.h
MAINTAINERS +1 -0
index 7f1fa4f..f95ac7f 100644
@@ -8365,6 +8365,7 @@ L:	linux-pci at vger.kernel.org
 L:	linux-arm-kernel at lists.infradead.org (moderated for non-subscribers)
 S:	Maintained
 F:	Documentation/devicetree/bindings/pci/host-generic-pci.txt
+F:	drivers/pci/host/pci-host-common.c
 F:	drivers/pci/host/pci-host-generic.c
 
 PCI DRIVER FOR INTEL VOLUME MANAGEMENT DEVICE (VMD)
drivers/pci/host/Kconfig +4 -0
index 75a6054..65709b4 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 7b2f20c..3b24af8 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 +47 -0

47 lines not on this page · raw message

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

203 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#2 lore raw

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

In reply to David Daney

From: David Daney <[email protected]>

The root complexes used to access off-chip PCIe devices (called PEM units in the hardware manuals) on 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/pci-thunder-pem.txt    |  43 +++
 MAINTAINERS                                        |   8 +
 drivers/pci/host/Kconfig                           |   7 +
 drivers/pci/host/Makefile                          |   1 +
 drivers/pci/host/pci-thunder-pem.c                 | 347 +++++++++++++++++++++
 5 files changed, 406 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pci/pci-thunder-pem.txt
 create mode 100644 drivers/pci/host/pci-thunder-pem.c
Documentation/devicetree/bindings/pci/pci-thunder-pem.txt new file +43 -0
new file mode 100644
index 0000000..f131fae
@@ -0,0 +1,43 @@
+* ThunderX PEM PCIe host controller
+
+Firmware-initialized PCI 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:
+
+    pci at 87e0,c2000000 {
+	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 */
+    };
MAINTAINERS +8 -0
index f95ac7f..650e8f3 100644
@@ -8411,6 +8411,14 @@ L:     linux-arm-msm at vger.kernel.org
 S:     Maintained
 F:     drivers/pci/host/*qcom*
 
+PCIE DRIVER FOR CAVIUM THUNDERX
+M:	David Daney <[email protected]>
+L:	linux-pci at vger.kernel.org
+L:	linux-arm-kernel at lists.infradead.org (moderated for non-subscribers)
+S:	Supported
+F:	Documentation/devicetree/bindings/pci/pci-thunder-*
+F:	drivers/pci/host/pci-thunder-*
+
 PCMCIA SUBSYSTEM
 P:	Linux PCMCIA Team
 L:	linux-pcmcia at lists.infradead.org
drivers/pci/host/Kconfig +7 -0
index 65709b4..184df22 100644
@@ -195,4 +195,11 @@ config PCIE_QCOM
 	  PCIe controller uses the Designware core plus Qualcomm-specific
 	  hardware wrappers.
 
+config PCI_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 3b24af8..8903172 100644
@@ -23,3 +23,4 @@ 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_QCOM) += pcie-qcom.o
+obj-$(CONFIG_PCI_HOST_THUNDER_PEM) += pci-thunder-pem.o
drivers/pci/host/pci-thunder-pem.c new file +347 -0

347 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#3 lore raw

PATCH v6 3/3 pci, pci-thunder-ecam: Add driver for ThunderX-pass1 on-chip devices

In reply to David Daney

From: David Daney <[email protected]>

The cavium,pci-thunder-ecam devices are exactly ECAM based PCI root complexes. These root complexes (loosely referred to as ECAM units in the hardware manuals) are used to access the Thunder on-chips devices. They are special in that all the BARs on devices behind these root complexes are at fixed addresses. To handle this in a manner compatible with the core PCI code, we have the config access functions synthesize Enhanced Allocation (EA) capability entries for each BAR.

Since this EA synthesis is needed for exactly one chip model, we can hard code some assumptions about the device topology and the properties of specific DEVFNs in the driver.

---
 .../devicetree/bindings/pci/pci-thunder-ecam.txt   |  30 ++
 drivers/pci/host/Kconfig                           |   7 +
 drivers/pci/host/Makefile                          |   1 +
 drivers/pci/host/pci-thunder-ecam.c                | 358 +++++++++++++++++++++
 4 files changed, 396 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pci/pci-thunder-ecam.txt
 create mode 100644 drivers/pci/host/pci-thunder-ecam.c
Documentation/devicetree/bindings/pci/pci-thunder-ecam.txt new file +30 -0
new file mode 100644
index 0000000..0202dd1
@@ -0,0 +1,30 @@
+* ThunderX PCI host controller for pass-1.x silicon
+
+Firmware-initialized PCI host controller to on-chip devices found on
+some Cavium ThunderX processors.  These devices have ECAM based config
+access, but the BARs are all at fixed addresses.  We handle the fixed
+addresses by synthesizing Enhanced Allocation (EA) capabilities for
+these devices.
+
+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-ecam"
+
+Example:
+
+	pcie at 84b000000000 {
+		compatible = "cavium,pci-host-thunder-ecam";
+		device_type = "pci";
+		msi-parent = <&its>;
+		msi-map = <0 &its 0x30000 0x10000>;
+		bus-range = <0 31>;
+		#size-cells = <2>;
+		#address-cells = <3>;
+		#stream-id-cells = <1>;
+		reg = <0x84b0 0x00000000 0 0x02000000>;  /* Configuration space */
+		ranges = <0x03000000 0x8180 0x00000000 0x8180 0x00000000 0x80 0x00000000>; /* mem ranges */
+	};
drivers/pci/host/Kconfig +7 -0
index 184df22..f8912c6 100644
@@ -202,4 +202,11 @@ config PCI_HOST_THUNDER_PEM
 	help
 	  Say Y here if you want PCIe support for CN88XX Cavium Thunder SoCs.
 
+config PCI_HOST_THUNDER_ECAM
+	bool "Cavium Thunder ECAMe controller to on-chip devices on pass-1.x silicon"
+	depends on OF && ARM64
+	select PCI_HOST_COMMON
+	help
+	  Say Y here if you want ECAM support for CN88XX-Pass-1.x Cavium Thunder SoCs.
+
 endmenu
drivers/pci/host/Makefile +1 -0
index 8903172..d6af3ba 100644
@@ -23,4 +23,5 @@ 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_QCOM) += pcie-qcom.o
+obj-$(CONFIG_PCI_HOST_THUNDER_ECAM) += pci-thunder-ecam.o
 obj-$(CONFIG_PCI_HOST_THUNDER_PEM) += pci-thunder-pem.o
drivers/pci/host/pci-thunder-ecam.c new file +358 -0

358 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#4 lore raw
In reply to David Daney

Bjorn,

I haven't seen any feedback on this revision of the patch set.

Are there any remaining issues that you are aware of that are blocking these?

Thanks in advance,
David Daney

Quoted 58 lines · David Daney

From: David Daney <[email protected]>

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

There are now three 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 to external PCIe buses, which leverages the code in pci-host-generic

3) Add ThunderX PCI driver for internel SoC buses used on early ThunderX chip revisions.

Changes from v5: Added Acked-by Rob Herring for the device tree binding in 3/3. Fixed typo and split large functions as suggested by Bjorn Helgaas.

Changes from v4: Added patch 3/3. Stylistic changes to 2/3 suggested by Bjorn Helgaas. When expanding config write width to 32-bits, mask out unintened writes to W1C bits, also suggested by Bjorn Helgaas.

Changes from v3: Add some Acked-by, rebased to v4.5.0-rc1

Changes from v2: Improve device tree binding example as noted by Rob Herring. Rename pcie-thunder-pem.* to pci-thunder-pem.* for better consistency. Update MAINTAINERS to reflect the changes.

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 (3):
PCI: generic: Refactor code to enable reuse by other drivers. pci, pci-thunder-pem: Add PCIe host driver for ThunderX processors. pci, pci-thunder-ecam: Add driver for ThunderX-pass1 on-chip devices

  .../devicetree/bindings/pci/pci-thunder-ecam.txt   |  30 ++
  .../devicetree/bindings/pci/pci-thunder-pem.txt    |  43 +++
  MAINTAINERS                                        |   9 +
  drivers/pci/host/Kconfig                           |  18 ++
  drivers/pci/host/Makefile                          |   3 +
  drivers/pci/host/pci-host-common.c                 | 194 +++++++++++
  drivers/pci/host/pci-host-common.h                 |  47 +++
  drivers/pci/host/pci-host-generic.c                | 181 +----------
  drivers/pci/host/pci-thunder-ecam.c                | 358 +++++++++++++++++++++
  drivers/pci/host/pci-thunder-pem.c                 | 347 ++++++++++++++++++++
  10 files changed, 1053 insertions(+), 177 deletions(-)

create mode 100644 Documentation/devicetree/bindings/pci/pci-thunder-ecam.txt create mode 100644 Documentation/devicetree/bindings/pci/pci-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/pci-thunder-ecam.c
create mode 100644 drivers/pci/host/pci-thunder-pem.c