Skip to contentSkip to conversation

pci: host: Broadcom STB PCIE RC controller support

PATCH In review Florian Fainelli 6 participants 16 messages May 5, 2016 – Jun 9, 2016

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover pci: host: Broadcom STB PCIE RC controller support

Hi all,

This patch series adds support for Broadcom STB SoC's PCIe root complex driver.

This was primarily tested on BCM7445 (ARM) and BCM7435 (MIPS).

Jim is the original author, and I picked up our downstream 4.1 driver and updated it to utilize the non-ARM hw_pci functions as well as made some stylistic changes.

Thanks!

Jim Quinlan (2):
Documentation: DT: bindings: Add Broadcom STB PCIe bindings
pci: host: Add Broadcom STB PCIE RC controller

 .../devicetree/bindings/pci/brcm,brcmstb-pcie.txt  |  98 +++
 MAINTAINERS                                        |   1 +
 drivers/pci/host/Kconfig                           |  17 +
 drivers/pci/host/Makefile                          |   2 +
 drivers/pci/host/pcie-brcmstb-msi.c                | 305 ++++++++
 drivers/pci/host/pcie-brcmstb.c                    | 772 +++++++++++++++++++++
 drivers/pci/host/pcie-brcmstb.h                    | 169 +++++
 7 files changed, 1364 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt
 create mode 100644 drivers/pci/host/pcie-brcmstb-msi.c
 create mode 100644 drivers/pci/host/pcie-brcmstb.c
 create mode 100644 drivers/pci/host/pcie-brcmstb.h
Signature · 1 line
2.1.0
#1 lore raw

PATCH v2 1/2 Documentation: DT: bindings: Add Broadcom STB PCIe bindings

From: Jim Quinlan <[email protected]>

This patchs adds the Device Tree bindings for the Broadcom STB PCIe root complex hardware.

---
Changes in v2:

- rewrite the binding document almost from scratch to include many more references to existing documents
- describe missing properties
- give better examples

 .../devicetree/bindings/pci/brcm,brcmstb-pcie.txt  | 98 ++++++++++++++++++++++
 1 file changed, 98 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt
Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +98 -0
new file mode 100644
index 000000000000..3682b0f0bc26
@@ -0,0 +1,98 @@
+Broadcom STB PCIe Host Controller Device Tree Bindings
+
+This document describes the binding of the PCIe Root Complex hardware found in
+Broadcom Set Top Box System-on-Chips such as BCM7425 (MIPS), BCM7435 (MIPS) and
+BCM7445 (ARMv7).
+
+Required properties:
+- compatible: must be one of: "brcm,bcm7425-pcie"
+			      "brcm,bcm7435-pcie"
+			      "brcm,bcm7445-pcie"
+
+- reg: specifies the physical base address of the controller registers and
+  its length
+
+- interrupt-parent: must be a reference (phandle) to the parent interrupt
+  controller in the system (7038-l1-intc on MIPS, GIC on ARM/ARM64)
+
+- interrrupts: first interrupt must be the Level 1 interrupt number corresponding
+  to the main PCIe RC interrupt, second interrupt must be the MSI interrupt
+  See the interrupt-parent documentation for the number of cells and their meaning:
+  MIPS: Documentation/devicetree/bindings/interrupt-controller/brcm,bcm7038-l1-intc.txt
+  ARM/ARM64: Documentation/devicetree/bindings/interrupt-controller/arm,gic.txt
+
+- interrupt-names: must be "pcie", and if present "msi"
+
+- interrupt-map: see pci.txt
+
+- interrupt-map-mask: see pci.txt
+
+- #address-cells: must be set to <3>, see pci.txt
+
+- #size-cells: must be set to <2>, see pci.txt
+
+- ranges: ranges for the PCI outbound windows, no I/O or prefetchable windows
+  must be specified here, only non-prefetchable. 32-bits windows or 64-bits
+  windows are allowed based on the host processor's capabilities (ARM w/ LPAE,
+  ARM64).
+
+- #interrupt-cells: set to <1>, see pci.txt
+
+- brcm,log2-scb-sizes: log2 size of the SCB window that is mapped to PCIe space
+  there must be exactly one value per memory controller present in the system
+  (ranges from 1 to 3)
+
+Optional properties:
+
+- msi-controller: indicates that this is a MSI controller node (when supported)
+
+- clocks: phandle to the functional clock that feeds into the PCIe RC block
+
+- clock-names: the name(s) of the clocks specified in 'clocks'.  Note
+  that if the 'clocks' property is given, 'clock-names' is mandatory,
+  and the name of the clock is expected to be "pcie".
+
+- brcm,ssc: boolean that indicates usage of spread-spectrum clocking
+
+- brcm,gen: integer that indicates desired forced generation of link: 1 => 2.5
+  Gbps, 2 => 5.0 Gbps, 3 => 8.0 Gbps. Will override the auto-negotation if
+  specified.
+
+- <*>-supply: see Documentation/devicetree/bindings/regulator/regulator.txt
+
+- <*>-supply-names: see Documentation/devicetree/bindings/regulator/regulator.txt
+
+Example Node:
+
+This example assumes that the top-level #address-cells = <2> and #size-cells =
+<2>, e.g: ARM LPAE configuration.
+
+	pcie0: pcie-controller at f0460000 {
+		reg = <0x0 0xf0460000 0x0 0x9310>;
+		interrupts = <0x0 0x33 0x4>, <0x0 0x34, 0x4>;
+		interrupt-names = "pcie", "msi";
+		compatible = "brcm,bcm7445-pcie";
+		#address-cells = <3>;
+		#size-cells = <2>;
+
+		/* Two non-prefetchable 32-bits memory space, each of 128MB
+ 		 * with the following mapping:
+		 * PCIe address		=> CPU physical address space
+		 * 0x00_0000_0000	=> 0x00_C000_0000
+		 * 0x00_0800_0000	=> 0x00_C800_0000
+		 */
+		ranges = <0x02000000 0x00000000 0x00000000 0x00000000 0xc0000000 0x00000000 0x08000000>,
+			 <0x02000000 0x00000000 0x08000000 0x00000000 0xc8000000 0x00000000 0x08000000>;
+		#interrupt-cells = <1>;
+		interrupt-map-mask = <0xf800 0 0 7>;
+		interrupt-map = <0 0 0 1 &intc 47 3
+				 0 0 0 2 &intc 48 3
+				 0 0 0 3 &intc 49 3
+				 0 0 0 4 &intc 50 3>;
+		clocks = <&pcie0>;
+		clock-names = "pcie";
+		brcm,ssc;
+		brcm,log2-scb-sizes = <0x1e 0x1e 0x1e>;
+		vreg-wifi-pwr-supply-names = "vreg-wifi-pwr";
+		vreg-wifi-pwr-supply = <&vreg-wifi-pwr>;
+	};
Signature · 1 line
2.1.0
#12 lore raw

PATCH v2 2/2 pci: host: Add Broadcom STB PCIE RC controller

In reply to Florian Fainelli

From: Jim Quinlan <[email protected]>

This patch adds support for Broadcom's STB SoC PCIE root complex controller. This controller can be found in MIPS-based chips such as BCM7425, 7429 and 7435 and ARM-based SoCs such as BCM7445.

This driver enables support for MSI, and S2/S3 suspend/resume modes.

---
Changes in v2:

- separate MSI logic into a different file
- simplify the code to utilize less bookeeping variables
- replaced fixed delays with sleeps instead
- introduce helper functions to deal with read/write config and reset
- get rid of the custom window variables, walk the resource list instead
- utilize OF aliases to determine PCIe root complex id

 MAINTAINERS                         |   1 +
 drivers/pci/host/Kconfig            |  17 +
 drivers/pci/host/Makefile           |   2 +
 drivers/pci/host/pcie-brcmstb-msi.c | 305 ++++++++++++++
 drivers/pci/host/pcie-brcmstb.c     | 769 ++++++++++++++++++++++++++++++++++++
 drivers/pci/host/pcie-brcmstb.h     | 160 ++++++++
 6 files changed, 1254 insertions(+)
 create mode 100644 drivers/pci/host/pcie-brcmstb-msi.c
 create mode 100644 drivers/pci/host/pcie-brcmstb.c
 create mode 100644 drivers/pci/host/pcie-brcmstb.h
MAINTAINERS +1 -0
index ecbb2f6a3ba0..503a2a4fa4ad 100644
@@ -2458,6 +2458,7 @@ S:	Maintained
 F:	arch/arm/mach-bcm/*brcmstb*
 F:	arch/arm/boot/dts/bcm7*.dts*
 F:	drivers/bus/brcmstb_gisb.c
+F:	drivers/pci/host/pcie-brcmstb*.[ch]
 N:	brcmstb
 
 BROADCOM BMIPS MIPS ARCHITECTURE
drivers/pci/host/Kconfig +17 -0
index 7a0780d56d2d..0964aa0d36e4 100644
@@ -143,6 +143,23 @@ config PCI_VERSATILE
 	bool "ARM Versatile PB PCI controller"
 	depends on ARCH_VERSATILE
 
+config PCIE_BRCMSTB
+	tristate "Broadcom STB PCIe controller"
+	depends on OF && (ARCH_BRCMSTB || BMIPS_GENERIC)
+	default ARCH_BRCMSTB || BMIPS_GENERIC
+	help
+	  Say Y here if you want to use the Broadcom STB PCIe controller. This
+	  controller supports Broadcom's STB SoCs such a 7425, 7429, 7435 and
+	  7445 and compatible chips.
+
+config PCIE_BRCMSTB_MSI
+	bool "Broadcom STB PCIe MSI feature"
+	depends on PCIE_BRCMSTB && PCI_MSI
+	select PCI_MSI_IRQ_DOMAIN
+	default PCIE_BRCMSTB
+	help
+	  Say Y here if you want PCIe MSI support for the Broadcom STB PCIe RC.
+
 config PCIE_IPROC
 	tristate
 	help
drivers/pci/host/Makefile +2 -0
index d85b5faf9bbc..f51ef13454b4 100644
@@ -18,6 +18,8 @@ obj-$(CONFIG_PCI_XGENE) += pci-xgene.o
 obj-$(CONFIG_PCI_XGENE_MSI) += pci-xgene-msi.o
 obj-$(CONFIG_PCI_LAYERSCAPE) += pci-layerscape.o
 obj-$(CONFIG_PCI_VERSATILE) += pci-versatile.o
+obj-$(CONFIG_PCIE_BRCMSTB) += pcie-brcmstb.o
+obj-$(CONFIG_PCIE_BRCMSTB_MSI) += pcie-brcmstb-msi.o
 obj-$(CONFIG_PCIE_IPROC) += pcie-iproc.o
 obj-$(CONFIG_PCIE_IPROC_MSI) += pcie-iproc-msi.o
 obj-$(CONFIG_PCIE_IPROC_PLATFORM) += pcie-iproc-platform.o
drivers/pci/host/pcie-brcmstb-msi.c new file +305 -0

305 lines not on this page · raw message

drivers/pci/host/pcie-brcmstb.c new file +769 -0

769 lines not on this page · raw message

drivers/pci/host/pcie-brcmstb.h new file +160 -0

160 lines not on this page · raw message

Signature · 1 line
2.1.0
#2 lore raw

Re: [PATCH v2 1/2] Documentation: DT: bindings: Add Broadcom STB PCIe bindings

In reply to Florian Fainelli
Quoted 39 lines · On Thursday 05 May 2016 12:14:59 Florian Fainelli wrote:

From: Jim Quinlan <[email protected]>

This patchs adds the Device Tree bindings for the Broadcom STB PCIe root complex hardware.

---
Changes in v2:

- rewrite the binding document almost from scratch to include many more references to existing documents
- describe missing properties
- give better examples

 .../devicetree/bindings/pci/brcm,brcmstb-pcie.txt  | 98 ++++++++++++++++++++++
 1 file changed, 98 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt
Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +14 -0
new file mode 100644
index 000000000000..3682b0f0bc26
@@ -0,0 +1,98 @@
+Broadcom STB PCIe Host Controller Device Tree Bindings
+
+This document describes the binding of the PCIe Root Complex hardware found in
+Broadcom Set Top Box System-on-Chips such as BCM7425 (MIPS), BCM7435 (MIPS) and
+BCM7445 (ARMv7).
+
+Required properties:
+- compatible: must be one of: "brcm,bcm7425-pcie"
+			      "brcm,bcm7435-pcie"
+			      "brcm,bcm7445-pcie"
+
+- reg: specifies the physical base address of the controller registers and
+  its length
+

Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt line 24

Quoted 10 lines
Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +10 -0
+- interrupt-parent: must be a reference (phandle) to the parent interrupt
+  controller in the system (7038-l1-intc on MIPS, GIC on ARM/ARM64)
+
+- interrrupts: first interrupt must be the Level 1 interrupt number corresponding
+  to the main PCIe RC interrupt, second interrupt must be the MSI interrupt
+  See the interrupt-parent documentation for the number of cells and their meaning:
+  MIPS: Documentation/devicetree/bindings/interrupt-controller/brcm,bcm7038-l1-intc.txt
+  ARM/ARM64: Documentation/devicetree/bindings/interrupt-controller/arm,gic.txt
+
+- interrupt-names: must be "pcie", and if present "msi"

When I suggested splitting out the MSI support, I was thinking (but not writing) that you'd use an msi-parent property to refer to the node that holds the msi-controller as well.

Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt line 37

Quoted 4 lines
Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +4 -0
+- ranges: ranges for the PCI outbound windows, no I/O or prefetchable windows
+  must be specified here, only non-prefetchable. 32-bits windows or 64-bits
+  windows are allowed based on the host processor's capabilities (ARM w/ LPAE,
+  ARM64).

So this supports 64-bit non-prefetchable windows? Usually 64-bit windows are prefetchable.

Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt line 43

Quoted 3 lines
Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +3 -0
+- brcm,log2-scb-sizes: log2 size of the SCB window that is mapped to PCIe space
+  there must be exactly one value per memory controller present in the system
+  (ranges from 1 to 3)

I'm still not too happy with this property. I see no reason for the log2 format (rather than length in bytes, or offset/length tuples, or dma-ranges, or phandles pointing to the memory controllers). I think we need to discuss this some more.

Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt line 59

Quoted 3 lines
Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +3 -0
+- brcm,gen: integer that indicates desired forced generation of link: 1 => 2.5
+  Gbps, 2 => 5.0 Gbps, 3 => 8.0 Gbps. Will override the auto-negotation if
+  specified.

to repeat my earlier comment from v1:

Shouldn't the link generation be probed automatically?

Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt line 63

Quoted 3 lines
Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +3 -0
+- <*>-supply: see Documentation/devicetree/bindings/regulator/regulator.txt
+
+- <*>-supply-names: see Documentation/devicetree/bindings/regulator/regulator.txt

I don't see supply-names documented there.

Arnd

maintainer
#3 lore raw

Re: [PATCH v2 1/2] Documentation: DT: bindings: Add Broadcom STB PCIe bindings

Quoted 46 lines · Arnd Bergmann
Quoted 45 lines · On Thursday 05 May 2016 12:14:59 Florian Fainelli wrote:

From: Jim Quinlan <[email protected]>

This patchs adds the Device Tree bindings for the Broadcom STB PCIe root complex hardware.

---
Changes in v2:

- rewrite the binding document almost from scratch to include many more references to existing documents
- describe missing properties
- give better examples

 .../devicetree/bindings/pci/brcm,brcmstb-pcie.txt  | 98 ++++++++++++++++++++++
 1 file changed, 98 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt
Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +20 -0
new file mode 100644
index 000000000000..3682b0f0bc26
@@ -0,0 +1,98 @@
+Broadcom STB PCIe Host Controller Device Tree Bindings
+
+This document describes the binding of the PCIe Root Complex hardware found in
+Broadcom Set Top Box System-on-Chips such as BCM7425 (MIPS), BCM7435 (MIPS) and
+BCM7445 (ARMv7).
+
+Required properties:
+- compatible: must be one of: "brcm,bcm7425-pcie"
+			      "brcm,bcm7435-pcie"
+			      "brcm,bcm7445-pcie"
+
+- reg: specifies the physical base address of the controller registers and
+  its length
+
+- interrupt-parent: must be a reference (phandle) to the parent interrupt
+  controller in the system (7038-l1-intc on MIPS, GIC on ARM/ARM64)
+
+- interrrupts: first interrupt must be the Level 1 interrupt number corresponding
+  to the main PCIe RC interrupt, second interrupt must be the MSI interrupt
+  See the interrupt-parent documentation for the number of cells and their meaning:
Quoted 8 lines

Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt line 24

Quoted 4 lines
Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +4 -0
+  MIPS: Documentation/devicetree/bindings/interrupt-controller/brcm,bcm7038-l1-intc.txt
+  ARM/ARM64: Documentation/devicetree/bindings/interrupt-controller/arm,gic.txt
+
+- interrupt-names: must be "pcie", and if present "msi"

When I suggested splitting out the MSI support, I was thinking (but not writing) that you'd use an msi-parent property to refer to the node that holds the msi-controller as well.

Humm fair enough.

Quoted 9 lines

Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt line 37

Quoted 5 lines
Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +4 -0
+- ranges: ranges for the PCI outbound windows, no I/O or prefetchable windows
+  must be specified here, only non-prefetchable. 32-bits windows or 64-bits
+  windows are allowed based on the host processor's capabilities (ARM w/ LPAE,
+  ARM64).

So this supports 64-bit non-prefetchable windows? Usually 64-bit windows are prefetchable.

Quoted 8 lines

Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt line 43

Quoted 3 lines
Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +3 -0
+- brcm,log2-scb-sizes: log2 size of the SCB window that is mapped to PCIe space
+  there must be exactly one value per memory controller present in the system
+  (ranges from 1 to 3)

I'm still not too happy with this property. I see no reason for the log2 format (rather than length in bytes, or offset/length tuples, or dma-ranges, or phandles pointing to the memory controllers). I think we need to discuss this some more.

Sure, works for me.

Quoted 8 lines

Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt line 59

Quoted 4 lines
Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +3 -0
+- brcm,gen: integer that indicates desired forced generation of link: 1 => 2.5
+  Gbps, 2 => 5.0 Gbps, 3 => 8.0 Gbps. Will override the auto-negotation if
+  specified.

to repeat my earlier comment from v1:

Shouldn't the link generation be probed automatically?

It is, but if the property is present, we can foce the link negotiation, We have had cases where this was desired and helpful.

Quoted 6 lines

Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt line 63

Quoted 4 lines
Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +3 -0
+- <*>-supply: see Documentation/devicetree/bindings/regulator/regulator.txt
+
+- <*>-supply-names: see Documentation/devicetree/bindings/regulator/regulator.txt

I don't see supply-names documented there.

Meh, I read that wrong, will fix that.

Thanks!

Signature · 1 line
Florian
#4 lore raw

Re: [PATCH v2 1/2] Documentation: DT: bindings: Add Broadcom STB PCIe bindings

Quoted 6 lines · On Thursday 05 May 2016 14:46:22 Florian Fainelli wrote:
Quoted 6 lines
Quoted 5 lines

+- brcm,gen: integer that indicates desired forced generation of link: 1 => 2.5

Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +2 -0
+  Gbps, 2 => 5.0 Gbps, 3 => 8.0 Gbps. Will override the auto-negotation if
+  specified.
Quoted 7 lines
Quoted 3 lines

to repeat my earlier comment from v1:

Shouldn't the link generation be probed automatically?

It is, but if the property is present, we can foce the link negotiation, We have had cases where this was desired and helpful.

Right, I missed that this is listed as 'optional', so that seems perfectly fine.

Thanks,

Arnd

maintainer
#7 lore raw

Re: [PATCH v2 1/2] Documentation: DT: bindings: Add Broadcom STB PCIe bindings

In reply to Florian Fainelli
Quoted 70 lines · Florian Fainelli

From: Jim Quinlan <[email protected]>

This patchs adds the Device Tree bindings for the Broadcom STB PCIe root complex hardware.

---
Changes in v2:

- rewrite the binding document almost from scratch to include many more references to existing documents
- describe missing properties
- give better examples

 .../devicetree/bindings/pci/brcm,brcmstb-pcie.txt  | 98 ++++++++++++++++++++++
 1 file changed, 98 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt
Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +45 -0
new file mode 100644
index 000000000000..3682b0f0bc26
@@ -0,0 +1,98 @@
+Broadcom STB PCIe Host Controller Device Tree Bindings
+
+This document describes the binding of the PCIe Root Complex hardware found in
+Broadcom Set Top Box System-on-Chips such as BCM7425 (MIPS), BCM7435 (MIPS) and
+BCM7445 (ARMv7).
+
+Required properties:
+- compatible: must be one of: "brcm,bcm7425-pcie"
+			      "brcm,bcm7435-pcie"
+			      "brcm,bcm7445-pcie"
+
+- reg: specifies the physical base address of the controller registers and
+  its length
+
+- interrupt-parent: must be a reference (phandle) to the parent interrupt
+  controller in the system (7038-l1-intc on MIPS, GIC on ARM/ARM64)
+
+- interrrupts: first interrupt must be the Level 1 interrupt number corresponding
+  to the main PCIe RC interrupt, second interrupt must be the MSI interrupt
+  See the interrupt-parent documentation for the number of cells and their meaning:
+  MIPS: Documentation/devicetree/bindings/interrupt-controller/brcm,bcm7038-l1-intc.txt
+  ARM/ARM64: Documentation/devicetree/bindings/interrupt-controller/arm,gic.txt
+
+- interrupt-names: must be "pcie", and if present "msi"
+
+- interrupt-map: see pci.txt
+
+- interrupt-map-mask: see pci.txt
+
+- #address-cells: must be set to <3>, see pci.txt
+
+- #size-cells: must be set to <2>, see pci.txt
+
+- ranges: ranges for the PCI outbound windows, no I/O or prefetchable windows
+  must be specified here, only non-prefetchable. 32-bits windows or 64-bits
+  windows are allowed based on the host processor's capabilities (ARM w/ LPAE,
+  ARM64).
+
+- #interrupt-cells: set to <1>, see pci.txt
+
+- brcm,log2-scb-sizes: log2 size of the SCB window that is mapped to PCIe space
+  there must be exactly one value per memory controller present in the system
+  (ranges from 1 to 3)
+
+Optional properties:

Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt line 55

Quoted 10 lines
Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +10 -0
+
+- msi-controller: indicates that this is a MSI controller node (when supported)
+
+- clocks: phandle to the functional clock that feeds into the PCIe RC block
+
+- clock-names: the name(s) of the clocks specified in 'clocks'.  Note
+  that if the 'clocks' property is given, 'clock-names' is mandatory,
+  and the name of the clock is expected to be "pcie".
+
+- brcm,ssc: boolean that indicates usage of spread-spectrum clocking

Shouldn't this be a property of the phy? Is there no separate phy to control?

Quoted 7 lines
Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +7 -0
+
+- brcm,gen: integer that indicates desired forced generation of link: 1 => 2.5
+  Gbps, 2 => 5.0 Gbps, 3 => 8.0 Gbps. Will override the auto-negotation if
+  specified.
+
+- <*>-supply: see Documentation/devicetree/bindings/regulator/regulator.txt
+

Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt line 72

Quoted 10 lines
Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +10 -0
+- <*>-supply-names: see Documentation/devicetree/bindings/regulator/regulator.txt
+
+Example Node:
+
+This example assumes that the top-level #address-cells = <2> and #size-cells =
+<2>, e.g: ARM LPAE configuration.
+
+	pcie0: pcie-controller at f0460000 {
+		reg = <0x0 0xf0460000 0x0 0x9310>;
+		interrupts = <0x0 0x33 0x4>, <0x0 0x34, 0x4>;
                                                      ^

typo

Quoted 15 lines
Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +15 -0
+		interrupt-names = "pcie", "msi";
+		compatible = "brcm,bcm7445-pcie";
+		#address-cells = <3>;
+		#size-cells = <2>;
+
+		/* Two non-prefetchable 32-bits memory space, each of 128MB
+ 		 * with the following mapping:
+		 * PCIe address		=> CPU physical address space
+		 * 0x00_0000_0000	=> 0x00_C000_0000
+		 * 0x00_0800_0000	=> 0x00_C800_0000
+		 */
+		ranges = <0x02000000 0x00000000 0x00000000 0x00000000 0xc0000000 0x00000000 0x08000000>,
+			 <0x02000000 0x00000000 0x08000000 0x00000000 0xc8000000 0x00000000 0x08000000>;
+		#interrupt-cells = <1>;
+		interrupt-map-mask = <0xf800 0 0 7>;

Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt line 97

Quoted 10 lines
Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +10 -0
+		interrupt-map = <0 0 0 1 &intc 47 3
+				 0 0 0 2 &intc 48 3
+				 0 0 0 3 &intc 49 3
+				 0 0 0 4 &intc 50 3>;
+		clocks = <&pcie0>;
+		clock-names = "pcie";
+		brcm,ssc;
+		brcm,log2-scb-sizes = <0x1e 0x1e 0x1e>;
+		vreg-wifi-pwr-supply-names = "vreg-wifi-pwr";
+		vreg-wifi-pwr-supply = <&vreg-wifi-pwr>;

The supply for the PCIE RC is called "vreg-wifi-pwr"? Seems a bit strange.

Rob

maintainer
#8 lore raw

Re: [PATCH v2 1/2] Documentation: DT: bindings: Add Broadcom STB PCIe bindings

Quoted 76 lines · Rob Herring
Quoted 75 lines · Florian Fainelli

From: Jim Quinlan <[email protected]>

This patchs adds the Device Tree bindings for the Broadcom STB PCIe root complex hardware.

---
Changes in v2:

- rewrite the binding document almost from scratch to include many more references to existing documents
- describe missing properties
- give better examples

 .../devicetree/bindings/pci/brcm,brcmstb-pcie.txt  | 98 ++++++++++++++++++++++
 1 file changed, 98 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt
Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +50 -0
new file mode 100644
index 000000000000..3682b0f0bc26
@@ -0,0 +1,98 @@
+Broadcom STB PCIe Host Controller Device Tree Bindings
+
+This document describes the binding of the PCIe Root Complex hardware found in
+Broadcom Set Top Box System-on-Chips such as BCM7425 (MIPS), BCM7435 (MIPS) and
+BCM7445 (ARMv7).
+
+Required properties:
+- compatible: must be one of: "brcm,bcm7425-pcie"
+			      "brcm,bcm7435-pcie"
+			      "brcm,bcm7445-pcie"
+
+- reg: specifies the physical base address of the controller registers and
+  its length
+
+- interrupt-parent: must be a reference (phandle) to the parent interrupt
+  controller in the system (7038-l1-intc on MIPS, GIC on ARM/ARM64)
+
+- interrrupts: first interrupt must be the Level 1 interrupt number corresponding
+  to the main PCIe RC interrupt, second interrupt must be the MSI interrupt
+  See the interrupt-parent documentation for the number of cells and their meaning:
+  MIPS: Documentation/devicetree/bindings/interrupt-controller/brcm,bcm7038-l1-intc.txt
+  ARM/ARM64: Documentation/devicetree/bindings/interrupt-controller/arm,gic.txt
+
+- interrupt-names: must be "pcie", and if present "msi"
+
+- interrupt-map: see pci.txt
+
+- interrupt-map-mask: see pci.txt
+
+- #address-cells: must be set to <3>, see pci.txt
+
+- #size-cells: must be set to <2>, see pci.txt
+
+- ranges: ranges for the PCI outbound windows, no I/O or prefetchable windows
+  must be specified here, only non-prefetchable. 32-bits windows or 64-bits
+  windows are allowed based on the host processor's capabilities (ARM w/ LPAE,
+  ARM64).
+
+- #interrupt-cells: set to <1>, see pci.txt
+
+- brcm,log2-scb-sizes: log2 size of the SCB window that is mapped to PCIe space
+  there must be exactly one value per memory controller present in the system
+  (ranges from 1 to 3)
+
+Optional properties:
+
+- msi-controller: indicates that this is a MSI controller node (when supported)
+
+- clocks: phandle to the functional clock that feeds into the PCIe RC block
+
Quoted 8 lines

Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt line 55

Quoted 5 lines
Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +5 -0
+- clock-names: the name(s) of the clocks specified in 'clocks'.  Note
+  that if the 'clocks' property is given, 'clock-names' is mandatory,
+  and the name of the clock is expected to be "pcie".
+
+- brcm,ssc: boolean that indicates usage of spread-spectrum clocking

Shouldn't this be a property of the phy? Is there no separate phy to control?

No, the PHY is baked into the PCIe root complex, which is why this is a property of the root complex node since the two are conflated.

Quoted 19 lines
Quoted 8 lines
Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +7 -0
+
+- brcm,gen: integer that indicates desired forced generation of link: 1 => 2.5
+  Gbps, 2 => 5.0 Gbps, 3 => 8.0 Gbps. Will override the auto-negotation if
+  specified.
+
+- <*>-supply: see Documentation/devicetree/bindings/regulator/regulator.txt
+

Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt line 72

Quoted 10 lines
Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +10 -0
+- <*>-supply-names: see Documentation/devicetree/bindings/regulator/regulator.txt
+
+Example Node:
+
+This example assumes that the top-level #address-cells = <2> and #size-cells =
+<2>, e.g: ARM LPAE configuration.
+
+	pcie0: pcie-controller at f0460000 {
+		reg = <0x0 0xf0460000 0x0 0x9310>;
+		interrupts = <0x0 0x33 0x4>, <0x0 0x34, 0x4>;
                                                      ^
Quoted 1 line

typo

Whoops, thanks.

Quoted 21 lines
Quoted 21 lines
Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +20 -0
+		interrupt-names = "pcie", "msi";
+		compatible = "brcm,bcm7445-pcie";
+		#address-cells = <3>;
+		#size-cells = <2>;
+
+		/* Two non-prefetchable 32-bits memory space, each of 128MB
+ 		 * with the following mapping:
+		 * PCIe address		=> CPU physical address space
+		 * 0x00_0000_0000	=> 0x00_C000_0000
+		 * 0x00_0800_0000	=> 0x00_C800_0000
+		 */
+		ranges = <0x02000000 0x00000000 0x00000000 0x00000000 0xc0000000 0x00000000 0x08000000>,
+			 <0x02000000 0x00000000 0x08000000 0x00000000 0xc8000000 0x00000000 0x08000000>;
+		#interrupt-cells = <1>;
+		interrupt-map-mask = <0xf800 0 0 7>;
+		interrupt-map = <0 0 0 1 &intc 47 3
+				 0 0 0 2 &intc 48 3
+				 0 0 0 3 &intc 49 3
+				 0 0 0 4 &intc 50 3>;
+		clocks = <&pcie0>;
Quoted 8 lines

Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt line 97

Quoted 5 lines
Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +5 -0
+		clock-names = "pcie";
+		brcm,ssc;
+		brcm,log2-scb-sizes = <0x1e 0x1e 0x1e>;
+		vreg-wifi-pwr-supply-names = "vreg-wifi-pwr";
+		vreg-wifi-pwr-supply = <&vreg-wifi-pwr>;

The supply for the PCIE RC is called "vreg-wifi-pwr"? Seems a bit strange.

It can be called anything, this just happens to be the example, but I can certainly drop that, since a) this is optional and b) we need to rework that in the driver anyway.

Signature · 1 line
Florian
#9 lore raw

Re: [PATCH v2 1/2] Documentation: DT: bindings: Add Broadcom STB PCIe bindings

In reply to Rob Herring
Quoted 76 lines · Rob Herring
Quoted 75 lines · Florian Fainelli

From: Jim Quinlan <[email protected]>

This patchs adds the Device Tree bindings for the Broadcom STB PCIe root complex hardware.

---
Changes in v2:

- rewrite the binding document almost from scratch to include many more references to existing documents
- describe missing properties
- give better examples

 .../devicetree/bindings/pci/brcm,brcmstb-pcie.txt  | 98 ++++++++++++++++++++++
 1 file changed, 98 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt
Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +50 -0
new file mode 100644
index 000000000000..3682b0f0bc26
@@ -0,0 +1,98 @@
+Broadcom STB PCIe Host Controller Device Tree Bindings
+
+This document describes the binding of the PCIe Root Complex hardware found in
+Broadcom Set Top Box System-on-Chips such as BCM7425 (MIPS), BCM7435 (MIPS) and
+BCM7445 (ARMv7).
+
+Required properties:
+- compatible: must be one of: "brcm,bcm7425-pcie"
+			      "brcm,bcm7435-pcie"
+			      "brcm,bcm7445-pcie"
+
+- reg: specifies the physical base address of the controller registers and
+  its length
+
+- interrupt-parent: must be a reference (phandle) to the parent interrupt
+  controller in the system (7038-l1-intc on MIPS, GIC on ARM/ARM64)
+
+- interrrupts: first interrupt must be the Level 1 interrupt number corresponding
+  to the main PCIe RC interrupt, second interrupt must be the MSI interrupt
+  See the interrupt-parent documentation for the number of cells and their meaning:
+  MIPS: Documentation/devicetree/bindings/interrupt-controller/brcm,bcm7038-l1-intc.txt
+  ARM/ARM64: Documentation/devicetree/bindings/interrupt-controller/arm,gic.txt
+
+- interrupt-names: must be "pcie", and if present "msi"
+
+- interrupt-map: see pci.txt
+
+- interrupt-map-mask: see pci.txt
+
+- #address-cells: must be set to <3>, see pci.txt
+
+- #size-cells: must be set to <2>, see pci.txt
+
+- ranges: ranges for the PCI outbound windows, no I/O or prefetchable windows
+  must be specified here, only non-prefetchable. 32-bits windows or 64-bits
+  windows are allowed based on the host processor's capabilities (ARM w/ LPAE,
+  ARM64).
+
+- #interrupt-cells: set to <1>, see pci.txt
+
+- brcm,log2-scb-sizes: log2 size of the SCB window that is mapped to PCIe space
+  there must be exactly one value per memory controller present in the system
+  (ranges from 1 to 3)
+
+Optional properties:
+
+- msi-controller: indicates that this is a MSI controller node (when supported)
+
+- clocks: phandle to the functional clock that feeds into the PCIe RC block
+
Quoted 8 lines

Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt line 55

Quoted 5 lines
Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +5 -0
+- clock-names: the name(s) of the clocks specified in 'clocks'.  Note
+  that if the 'clocks' property is given, 'clock-names' is mandatory,
+  and the name of the clock is expected to be "pcie".
+
+- brcm,ssc: boolean that indicates usage of spread-spectrum clocking

Shouldn't this be a property of the phy? Is there no separate phy to control?

No, the PHY is baked into the PCIe root complex, which is why this is a property of the root complex node since the two are conflated.

Quoted 19 lines
Quoted 8 lines
Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +7 -0
+
+- brcm,gen: integer that indicates desired forced generation of link: 1 => 2.5
+  Gbps, 2 => 5.0 Gbps, 3 => 8.0 Gbps. Will override the auto-negotation if
+  specified.
+
+- <*>-supply: see Documentation/devicetree/bindings/regulator/regulator.txt
+

Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt line 72

Quoted 10 lines
Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +10 -0
+- <*>-supply-names: see Documentation/devicetree/bindings/regulator/regulator.txt
+
+Example Node:
+
+This example assumes that the top-level #address-cells = <2> and #size-cells =
+<2>, e.g: ARM LPAE configuration.
+
+	pcie0: pcie-controller at f0460000 {
+		reg = <0x0 0xf0460000 0x0 0x9310>;
+		interrupts = <0x0 0x33 0x4>, <0x0 0x34, 0x4>;
                                                      ^
Quoted 1 line

typo

Whoops, thanks.

Quoted 21 lines
Quoted 21 lines
Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +20 -0
+		interrupt-names = "pcie", "msi";
+		compatible = "brcm,bcm7445-pcie";
+		#address-cells = <3>;
+		#size-cells = <2>;
+
+		/* Two non-prefetchable 32-bits memory space, each of 128MB
+ 		 * with the following mapping:
+		 * PCIe address		=> CPU physical address space
+		 * 0x00_0000_0000	=> 0x00_C000_0000
+		 * 0x00_0800_0000	=> 0x00_C800_0000
+		 */
+		ranges = <0x02000000 0x00000000 0x00000000 0x00000000 0xc0000000 0x00000000 0x08000000>,
+			 <0x02000000 0x00000000 0x08000000 0x00000000 0xc8000000 0x00000000 0x08000000>;
+		#interrupt-cells = <1>;
+		interrupt-map-mask = <0xf800 0 0 7>;
+		interrupt-map = <0 0 0 1 &intc 47 3
+				 0 0 0 2 &intc 48 3
+				 0 0 0 3 &intc 49 3
+				 0 0 0 4 &intc 50 3>;
+		clocks = <&pcie0>;
Quoted 8 lines

Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt line 97

Quoted 5 lines
Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +5 -0
+		clock-names = "pcie";
+		brcm,ssc;
+		brcm,log2-scb-sizes = <0x1e 0x1e 0x1e>;
+		vreg-wifi-pwr-supply-names = "vreg-wifi-pwr";
+		vreg-wifi-pwr-supply = <&vreg-wifi-pwr>;

The supply for the PCIE RC is called "vreg-wifi-pwr"? Seems a bit strange.

It can be called anything, this just happens to be the example, but I can certainly drop that, since a) this is optional and b) we need to rework that in the driver anyway.

Signature · 1 line
Florian
#5 lore raw

Re: [PATCH v2 1/2] Documentation: DT: bindings: Add Broadcom STB PCIe bindings

In reply to Arnd Bergmann
Quoted 14 lines · Arnd Bergmann
Quoted 14 lines
Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +14 -0
+Required properties:
+- compatible: must be one of: "brcm,bcm7425-pcie"
+			      "brcm,bcm7435-pcie"
+			      "brcm,bcm7445-pcie"
+
+- reg: specifies the physical base address of the controller registers and
+  its length
+
+- interrupt-parent: must be a reference (phandle) to the parent interrupt
+  controller in the system (7038-l1-intc on MIPS, GIC on ARM/ARM64)
+
+- interrrupts: first interrupt must be the Level 1 interrupt number corresponding
+  to the main PCIe RC interrupt, second interrupt must be the MSI interrupt
+  See the interrupt-parent documentation for the number of cells and their meaning:
Quoted 8 lines

Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt line 24

Quoted 4 lines
Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +4 -0
+  MIPS: Documentation/devicetree/bindings/interrupt-controller/brcm,bcm7038-l1-intc.txt
+  ARM/ARM64: Documentation/devicetree/bindings/interrupt-controller/arm,gic.txt
+
+- interrupt-names: must be "pcie", and if present "msi"

When I suggested splitting out the MSI support, I was thinking (but not writing) that you'd use an msi-parent property to refer to the node that holds the msi-controller as well.

Oh got it now, and it can actually refer to iself.

Quoted 8 lines

Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt line 37

Quoted 5 lines

+- ranges: ranges for the PCI outbound windows, no I/O or prefetchable windows

Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +3 -0
+  must be specified here, only non-prefetchable. 32-bits windows or 64-bits
+  windows are allowed based on the host processor's capabilities (ARM w/ LPAE,
+  ARM64).

So this supports 64-bit non-prefetchable windows? Usually 64-bit windows are prefetchable.

I have yet to verify this, but on ARM64-based STB this should indeed be the case.

Quoted 9 lines

Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt line 43

Quoted 4 lines

+- brcm,log2-scb-sizes: log2 size of the SCB window that is mapped to PCIe space

Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +2 -0
+  there must be exactly one value per memory controller present in the system
+  (ranges from 1 to 3)

I'm still not too happy with this property. I see no reason for the log2 format (rather than length in bytes, or offset/length tuples, or dma-ranges, or phandles pointing to the memory controllers). I think we need to discuss this some more.

The two critical pieces of information that the PCIe RC needs are:

- number of memory controllers present in the system to avoid configuring a window to a non-existing or non-populated memory controller

- size of the memory populated on the memory controller

You would think that we should somehow be able to derive this information from the "memory" node, but there are a few caveats:

- on MIPS platforms, we have discontiguous physical memory ranges (256MB @ 0x0, then 768MB or 1792MB @ 0x 0x20000000 and 1GB @ 0x90000000), yet the PCIe RC does not know about the hole(s)

- on ARM platforms, we have an identiy mapping for the PAs below 4GB, but when we cross it, we have additional non-linear memory regions

Both of these memory nodes would imply we know how to identify which physical address belongs to which memory controller, while this is actually possible and known, it creates a dependency on another piece of driver to provide that information.

We do have memory controller nodes populated in the Device Tree, however their binding (out of tree for the moment) does only specify their programmable register interface, and not how how much physical memory and where they provide to the system.

It does seem like we should be able to utilize the "dma-ranges" property to determine both the memory controller number and their respective populated memory sizes.

In the case where we have an identiy mapping though, this seems a little redundant, but less of a stretch than our custom properties and nodes.

Does that sound reasonable to you?

Signature · 1 line
Florian
#6 lore raw

Re: [PATCH v2 1/2] Documentation: DT: bindings: Add Broadcom STB PCIe bindings

Quoted 6 lines · On Tuesday 10 May 2016 10:00:12 Florian Fainelli wrote:

The two critical pieces of information that the PCIe RC needs are:

- number of memory controllers present in the system to avoid configuring a window to a non-existing or non-populated memory controller

Quoted 8 lines

- size of the memory populated on the memory controller

You would think that we should somehow be able to derive this information from the "memory" node, but there are a few caveats:

- on MIPS platforms, we have discontiguous physical memory ranges (256MB @ 0x0, then 768MB or 1792MB @ 0x 0x20000000 and 1GB @ 0x90000000), yet the PCIe RC does not know about the hole(s)

That sounds like you need a dma-ranges property anyway to describe how the DMA addresses are mapped.

Quoted 13 lines

- on ARM platforms, we have an identiy mapping for the PAs below 4GB, but when we cross it, we have additional non-linear memory regions

Both of these memory nodes would imply we know how to identify which physical address belongs to which memory controller, while this is actually possible and known, it creates a dependency on another piece of driver to provide that information.

We do have memory controller nodes populated in the Device Tree, however their binding (out of tree for the moment) does only specify their programmable register interface, and not how how much physical memory and where they provide to the system.

Quoted 8 lines

It does seem like we should be able to utilize the "dma-ranges" property to determine both the memory controller number and their respective populated memory sizes.

In the case where we have an identiy mapping though, this seems a little redundant, but less of a stretch than our custom properties and nodes.

Does that sound reasonable to you?

I'd have to look at an example first. Ideally, each line in the dma-ranges property would refer to one memory controller, and that would be very easy to mandate, but it sounds like in the MIPS case you end up with an extra entry for the first 256MB that is on the same memory controller as the second 768MB.

Arnd

#10 lore raw

RE: [PATCH v2 1/2] Documentation: DT: bindings: Add Broadcom STB PCIe bindings

In reply to Florian Fainelli
Quoted 62 lines
 .../devicetree/bindings/pci/brcm,brcmstb-pcie.txt  | 98
++++++++++++++++++++++
 1 file changed, 98 insertions(+)
 create mode 100644

Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt

Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +25 -0
new file mode 100644
index 000000000000..3682b0f0bc26
@@ -0,0 +1,98 @@
+Broadcom STB PCIe Host Controller Device Tree Bindings
+
+This document describes the binding of the PCIe Root Complex hardware
+found in Broadcom Set Top Box System-on-Chips such as BCM7425 (MIPS),
+BCM7435 (MIPS) and
+BCM7445 (ARMv7).
+
+Required properties:
+- compatible: must be one of: "brcm,bcm7425-pcie"
+			      "brcm,bcm7435-pcie"
+			      "brcm,bcm7445-pcie"
+
+- reg: specifies the physical base address of the controller registers
+and
+  its length
+
+- interrupt-parent: must be a reference (phandle) to the parent
+interrupt
+  controller in the system (7038-l1-intc on MIPS, GIC on ARM/ARM64)
+
+- interrrupts: first interrupt must be the Level 1 interrupt number
+corresponding
+  to the main PCIe RC interrupt, second interrupt must be the MSI
+interrupt
+  See the interrupt-parent documentation for the number of cells and their

meaning:

Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +2 -0
+  MIPS:
+Documentation/devicetree/bindings/interrupt-controller/brcm,bcm7038-

l1-

Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +19 -0
+intc.txt
+  ARM/ARM64:
+Documentation/devicetree/bindings/interrupt-controller/arm,gic.txt
+
+- interrupt-names: must be "pcie", and if present "msi"
+
+- interrupt-map: see pci.txt
+
+- interrupt-map-mask: see pci.txt
+
+- #address-cells: must be set to <3>, see pci.txt
+
+- #size-cells: must be set to <2>, see pci.txt
+
+- ranges: ranges for the PCI outbound windows, no I/O or prefetchable
+windows
+  must be specified here, only non-prefetchable. 32-bits windows or
+64-bits
+  windows are allowed based on the host processor's capabilities (ARM

Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt line 43

Quoted 10 lines
Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +10 -0
+w/ LPAE,
+  ARM64).
+
+- #interrupt-cells: set to <1>, see pci.txt
+
+- brcm,log2-scb-sizes: log2 size of the SCB window that is mapped to
+PCIe space
+  there must be exactly one value per memory controller present in the
+system
+  (ranges from 1 to 3)

Can you please give more insight on what does this property do ?

Bharat

Quoted 71 lines
Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +41 -0
+
+Optional properties:
+
+- msi-controller: indicates that this is a MSI controller node (when
+supported)
+
+- clocks: phandle to the functional clock that feeds into the PCIe RC
+block
+
+- clock-names: the name(s) of the clocks specified in 'clocks'.  Note
+  that if the 'clocks' property is given, 'clock-names' is mandatory,
+  and the name of the clock is expected to be "pcie".
+
+- brcm,ssc: boolean that indicates usage of spread-spectrum clocking
+
+- brcm,gen: integer that indicates desired forced generation of link: 1
+=> 2.5
+  Gbps, 2 => 5.0 Gbps, 3 => 8.0 Gbps. Will override the auto-negotation
+if
+  specified.
+
+- <*>-supply: see
+Documentation/devicetree/bindings/regulator/regulator.txt
+
+- <*>-supply-names: see
+Documentation/devicetree/bindings/regulator/regulator.txt
+
+Example Node:
+
+This example assumes that the top-level #address-cells = <2> and
+#size-cells = <2>, e.g: ARM LPAE configuration.
+
+	pcie0: pcie-controller at f0460000 {
+		reg = <0x0 0xf0460000 0x0 0x9310>;
+		interrupts = <0x0 0x33 0x4>, <0x0 0x34, 0x4>;
+		interrupt-names = "pcie", "msi";
+		compatible = "brcm,bcm7445-pcie";
+		#address-cells = <3>;
+		#size-cells = <2>;
+
+		/* Two non-prefetchable 32-bits memory space, each of

128MB

Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +6 -0
+ 		 * with the following mapping:
+		 * PCIe address		=> CPU physical address space
+		 * 0x00_0000_0000	=> 0x00_C000_0000
+		 * 0x00_0800_0000	=> 0x00_C800_0000
+		 */
+		ranges = <0x02000000 0x00000000 0x00000000 0x00000000

0xc0000000 0x00000000 0x08000000>,

Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +1 -0
+			 <0x02000000 0x00000000 0x08000000 0x00000000

0xc8000000 0x00000000 0x08000000>;

Documentation/devicetree/bindings/pci/brcm,brcmstb-pcie.txt new file +13 -1
+		#interrupt-cells = <1>;
+		interrupt-map-mask = <0xf800 0 0 7>;
+		interrupt-map = <0 0 0 1 &intc 47 3
+				 0 0 0 2 &intc 48 3
+				 0 0 0 3 &intc 49 3
+				 0 0 0 4 &intc 50 3>;
+		clocks = <&pcie0>;
+		clock-names = "pcie";
+		brcm,ssc;
+		brcm,log2-scb-sizes = <0x1e 0x1e 0x1e>;
+		vreg-wifi-pwr-supply-names = "vreg-wifi-pwr";
+		vreg-wifi-pwr-supply = <&vreg-wifi-pwr>;
+	};
--

2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo at vger.kernel.org More majordomo info at
http://vger.kernel.org/majordomo-info.html

#13 lore raw

RE: [PATCH v2 2/2] pci: host: Add Broadcom STB PCIE RC controller

In reply to Florian Fainelli
Quoted 76 lines
drivers/pci/host/pcie-brcmstb.c new file +18 -0
+
+static struct pci_ops brcm_pcie_ops = {
+	.read = brcm_pcie_read_config,
+	.write = brcm_pcie_write_config,
+};
+
+static int brcm_pcie_probe(struct platform_device *pdev) {
+	struct device_node *dn = pdev->dev.of_node;
+	const u32 *log2_scb_sizes, *dma_ranges;
+	const struct brcm_pcie_cfg_data *data;
+	const struct of_device_id *of_id;
+	struct brcm_pcie *pcie;
+	void __iomem *base;
+	struct resource *r;
+	int i, rlen, ret;
+	u32 tmp;
+
+	pcie = devm_kzalloc(&pdev->dev, sizeof(struct brcm_pcie),

GFP_KERNEL);

drivers/pci/host/pcie-brcmstb.c new file +48 -0
+	if (!pcie)
+		return -ENOMEM;
+
+	of_id = of_match_node(brcm_pcie_match, dn);
+	if (!of_id)
+		return -EINVAL;
+
+	data = of_id->data;
+	pcie->type = data->type;
+	pcie->ops = &data->ops;
+
+	platform_set_drvdata(pdev, pcie);
+
+	INIT_LIST_HEAD(&pcie->resource);
+
+	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	base = devm_ioremap_resource(&pdev->dev, r);
+	if (IS_ERR(base))
+		return PTR_ERR(base);
+
+	ret = of_alias_get_id(dn, "pcie");
+	if (ret >= 0)
+		pcie->num = ret;
+
+	pcie->clk = devm_clk_get(&pdev->dev, "pcie");
+	if (IS_ERR(pcie->clk)) {
+		dev_err(&pdev->dev, "could not get clock\n");
+		pcie->clk = NULL;
+	}
+
+	ret = clk_prepare_enable(pcie->clk);
+	if (ret) {
+		dev_err(&pdev->dev, "could not enable clock\n");
+		return ret;
+	}
+
+	pcie->dn = dn;
+	pcie->base = base;
+	pcie->dev = &pdev->dev;
+	pcie->dev->of_node = dn;
+	pcie->gen = 0;
+
+	ret = of_property_read_u32(dn, "brcm,gen", &tmp);
+	if (ret == 0) {
+		if (tmp > 0 && tmp < 3)
+			pcie->gen = (int)tmp;
+		else
+			dev_warn(pcie->dev, "bad DT value for prop

'brcm,gen");

drivers/pci/host/pcie-brcmstb.c new file +8 -0
+	} else if (ret != -EINVAL) {
+		dev_warn(pcie->dev, "error reading DT prop 'brcm,gen");
+	}
+
+	pcie->ssc = of_property_read_bool(dn, "brcm,ssc");
+
+	/* Get the value for the log2 of the scb sizes. Subtract 15 from
+	 * each because the target register field has 0==disabled and 1==6KB.

drivers/pci/host/pcie-brcmstb.c line 686

Quoted 10 lines
drivers/pci/host/pcie-brcmstb.c new file +10 -0
+	 */
+	log2_scb_sizes = of_get_property(dn, "brcm,log2-scb-sizes", &rlen);
+	if (log2_scb_sizes) {
+		for (i = 0; i < rlen / sizeof(u32); i++) {
+			pcie->scb_size_vals[i]
+				= (int)of_read_number(log2_scb_sizes + i, 1)
+					- 15;
+			pcie->num_memc++;
+		}
+	}

In your device tree documentation this is required property, what if this property is missing ?

Quoted 256 lines
drivers/pci/host/pcie-brcmstb.c new file +4 -0
+
+	/* Look for the dma-ranges property.  If it exists, issue a warning
+	 * as PCIe drivers may not work.  This is because the identity
+	 * mapping between system memory and PCIe space is not

preserved,

drivers/pci/host/pcie-brcmstb.c new file +12 -0
+	 * and we need Linux to massage the dma_addr_t values it gets
+	 * from dma memory allocation.  This functionality will be added
+	 * in the near future.
+	 */
+	dma_ranges = of_get_property(dn, "dma-ranges", &rlen);
+	if (dma_ranges != NULL)
+		dev_warn(pcie->dev, "no identity map; PCI drivers may fail");
+
+	if (IS_ENABLED(CONFIG_PCI_MSI)) {
+		ret = irq_of_parse_and_map(pdev->dev.of_node, 1);
+		if (ret == 0)
+			dev_warn(pcie->dev, "cannot get msi intr; MSI

disabled\n");

drivers/pci/host/pcie-brcmstb.c new file +21 -0
+		else
+			pcie->msi_irq = ret;
+	}
+
+	ret = of_pci_get_host_bridge_resources(dn, 0, 0xff,
+					       &pcie->resource, NULL);
+	if (ret) {
+		dev_err(pcie->dev, "ranges parsing failed\n");
+		return ret;
+	}
+
+	ret = brcm_pcie_setup_early(pcie);
+	if (ret)
+		goto out_err_clk;
+
+	/* If setup bridge fails, it cleans up behind itself */
+	ret = brcm_setup_pcie_bridge(pcie);
+	if (ret)
+		goto out_err;
+
+	pcie->bus = pci_scan_root_bus(pcie->dev, pcie->num,

&brcm_pcie_ops,

drivers/pci/host/pcie-brcmstb.c new file +45 -0
+				      pcie, &pcie->resource);
+	if (!pcie->bus) {
+		ret = -ENOMEM;
+		goto out_err_bus;
+	}
+
+	if (IS_ENABLED(CONFIG_PCI_MSI))
+		brcm_pcie_msi_chip_set(pcie);
+
+	pci_bus_size_bridges(pcie->bus);
+	pci_bus_assign_resources(pcie->bus);
+
+	pci_fixup_irqs(pci_common_swizzle, of_irq_parse_and_map_pci);
+	pci_bus_add_devices(pcie->bus);
+
+	return 0;
+
+out_err_bus:
+	brcm_pcie_enter_l23(pcie);
+	brcm_pcie_turn_off(pcie);
+out_err_clk:
+	clk_disable_unprepare(pcie->clk);
+out_err:
+	return ret;
+}
+
+static int brcm_pcie_remove(struct platform_device *pdev) {
+	return brcm_pcie_suspend(&pdev->dev);
+}
+
+static struct platform_driver brcm_pcie_driver = {
+	.probe = brcm_pcie_probe,
+	.remove = brcm_pcie_remove,
+	.driver = {
+		.name = "brcm-pcie",
+		.owner = THIS_MODULE,
+		.of_match_table = brcm_pcie_match,
+		.pm = &brcm_pcie_pm_ops,
+	},
+};
+module_platform_driver(brcm_pcie_driver);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Broadcom STB PCIE RC driver");
+MODULE_AUTHOR("Broadcom");
drivers/pci/host/pcie- renamed from drivers/pci/host/pcie-brcmstb.h +0 -0

brcmstb.h new file mode 100644 index 000000000000..b4a507423bb0

drivers/pci/host/pcie-brcmstb.h new file +8 -0
@@ -0,0 +1,160 @@
+#ifndef __PCIE_BRCMSTB_H
+#define __PCIE_BRCMSTB_H
+
+#include <linux/io.h>
+
+/* Broadcom PCIE Offsets */
+#define PCIE_RC_CFG_PCIE_LINK_CAPABILITY		0x00b8
+#define PCIE_RC_CFG_PCIE_LINK_STATUS_CONTROL
	0x00bc
drivers/pci/host/pcie-brcmstb.h new file +2 -0
+#define PCIE_RC_CFG_PCIE_ROOT_CAP_CONTROL		0x00c8
+#define PCIE_RC_CFG_PCIE_LINK_STATUS_CONTROL_2
	0x00dc
+#define PCIE_RC_CFG_VENDOR_VENDOR_SPECIFIC_REG1
	0x0188
drivers/pci/host/pcie-brcmstb.h new file +3 -0
+#define PCIE_RC_CFG_PRIV1_ID_VAL3			0x043c
+#define PCIE_RC_DL_MDIO_ADDR				0x1100
+#define PCIE_RC_DL_MDIO_WR_DATA
	0x1104
+#define PCIE_RC_DL_MDIO_RD_DATA
	0x1108
drivers/pci/host/pcie-brcmstb.h new file +17 -0
+#define PCIE_MISC_MISC_CTRL				0x4008
+#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LO		0x400c
+#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_HI		0x4010
+#define PCIE_MISC_RC_BAR1_CONFIG_LO			0x402c
+#define PCIE_MISC_RC_BAR1_CONFIG_HI			0x4030
+#define PCIE_MISC_RC_BAR2_CONFIG_LO			0x4034
+#define PCIE_MISC_RC_BAR2_CONFIG_HI			0x4038
+#define PCIE_MISC_RC_BAR3_CONFIG_LO			0x403c
+#define PCIE_MISC_RC_BAR3_CONFIG_HI			0x4040
+#define PCIE_MISC_MSI_BAR_CONFIG_LO			0x4044
+#define PCIE_MISC_MSI_BAR_CONFIG_HI			0x4048
+#define PCIE_MISC_MSI_DATA_CONFIG			0x404c
+#define PCIE_MISC_PCIE_CTRL				0x4064
+#define PCIE_MISC_PCIE_STATUS				0x4068
+#define PCIE_MISC_REVISION				0x406c
+#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_LIMIT	0x4070
+#define PCIE_MISC_HARD_PCIE_HARD_DEBUG
	0x4204
drivers/pci/host/pcie-brcmstb.h new file +121 -1
+#define PCIE_INTR2_CPU_BASE				0x4300
+#define PCIE_MSI_INTR2_BASE				0x4500
+
+#define PCIE_RGR1_SW_INIT_1				0x9210
+#define PCIE_EXT_CFG_INDEX				0x9000
+#define PCIE_EXT_CFG_DATA				0x9004
+
+/* BCM7425 specific register offsets */
+#define BCM7425_PCIE_RGR1_SW_INIT_1			0x8010
+#define BCM7425_PCIE_EXT_CFG_INDEX			0x8300
+#define BCM7425_PCIE_EXT_CFG_DATA			0x8304
+
+#define PCI_BUSNUM_SHIFT		20
+#define PCI_SLOT_SHIFT			15
+#define PCI_FUNC_SHIFT			12
+
+#define BRCM_NUM_PCI_OUT_WINS		4
+#define BRCM_MAX_SCB			4
+
+/* Offsets from PCIE_INTR2_CPU_BASE and PCIE_MSI_INTR2_BASE */
+#define STATUS				0x0
+#define SET				0x4
+#define CLR				0x8
+#define MASK_STATUS			0xc
+#define MASK_SET			0x10
+#define MASK_CLR			0x14
+
+enum brcm_pcie_type {
+	BCM7425,
+	BCM7435,
+	GENERIC,
+};
+
+struct brcm_pcie;
+
+/* Chip-specific PCIe operations (read/write config and reset) */
+struct brcm_pcie_ll_ops {
+	u32 (*read_config)(struct brcm_pcie *pcie, int cfg_idx);
+	void (*write_config)(struct brcm_pcie *pcie, int cfg_idx, u32 val);
+	void (*rgr1_sw_init)(struct brcm_pcie *pcie, u32 mask,
+			     int shift, u32 val);
+};
+
+struct brcm_pcie_cfg_data {
+	const enum brcm_pcie_type type;
+	const struct brcm_pcie_ll_ops ops;
+};
+
+struct brcm_msi;
+
+/* Internal Bus Controller Information.*/ struct brcm_pcie {
+	void __iomem		*base;
+	bool			suspended;
+	struct clk		*clk;
+	struct device_node	*dn;
+	bool			ssc;
+	int			gen;
+	int			scb_size_vals[BRCM_MAX_SCB];
+	struct pci_bus		*bus;
+	struct device		*dev;
+	struct list_head	resource;
+	int			msi_irq;
+	struct brcm_msi		*msi;
+	unsigned int		rev;
+	unsigned int		num;
+	bool			bridge_setup_done;
+	enum brcm_pcie_type	type;
+	const struct brcm_pcie_ll_ops *ops;
+	unsigned int		num_memc;
+};
+
+/* Helper functions to access read/write config space and software init
+which
+ * are chip-specific
+ */
+static inline u32 brcm_pcie_ll_read_config(struct brcm_pcie *pcie, int
+cfg_idx) {
+	return pcie->ops->read_config(pcie, cfg_idx); }
+
+static inline void brcm_pcie_ll_write_config(struct brcm_pcie *pcie,
+					     int cfg_idx, u32 val)
+{
+	pcie->ops->write_config(pcie, cfg_idx, val); }
+
+static inline void brcm_pcie_rgr1_sw_init(struct brcm_pcie *pcie, u32 mask,
+					  int shift, u32 val)
+{
+	pcie->ops->rgr1_sw_init(pcie, mask, shift, val); }
+
+/*
+ * MIPS endianness is configured by boot strap, which also reverses all
+ * bus endianness (i.e., big-endian CPU + big endian bus ==> native
+ * endian I/O).
+ *
+ * Other architectures (e.g., ARM) either do not support big endian, or
+ * else leave I/O in little endian mode.
+ */
+static inline u32 bpcie_readl(void __iomem *base) {
+	if (IS_ENABLED(CONFIG_MIPS))
+		return __raw_readl(base);
+	else
+		return readl(base);
+}
+
+static inline void bpcie_writel(u32 val, void __iomem *base) {
+	if (IS_ENABLED(CONFIG_MIPS))
+		__raw_writel(val, base);
+	else
+		writel(val, base);
+}
+
+#ifdef CONFIG_PCIE_BRCMSTB_MSI
+int brcm_pcie_enable_msi(struct brcm_pcie *pcie, int nr); void
+brcm_pcie_msi_chip_set(struct brcm_pcie *pcie); #else static inline int
+brcm_pcie_enable_msi(struct brcm_pcie *pcie, int nr) {
+	return 0;
+}
+static inline void brcm_pcie_msi_chip_set(struct brcm_pcie *pcie) { }
+#endif
+
+#endif /* __PCIE_BRCMSTB_H */
--

2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo at vger.kernel.org More majordomo info at
http://vger.kernel.org/majordomo-info.html

#14 lore raw

Re: [PATCH v2 2/2] pci: host: Add Broadcom STB PCIE RC controller

On 05/11/2016 07:47 AM, Bharat Kumar Gogada wrote:

[snip]

Quoted 6 lines
Quoted 6 lines
drivers/pci/host/pcie-brcmstb.c new file +6 -0
+	/* Get the value for the log2 of the scb sizes. Subtract 15 from
+	 * each because the target register field has 0==disabled and 1==6KB.
+	 */
+	log2_scb_sizes = of_get_property(dn, "brcm,log2-scb-sizes", &rlen);
+	if (log2_scb_sizes) {
+		for (i = 0; i < rlen / sizeof(u32); i++) {
Quoted 8 lines

drivers/pci/host/pcie-brcmstb.c line 686

Quoted 6 lines
drivers/pci/host/pcie-brcmstb.c new file +6 -0
+			pcie->scb_size_vals[i]
+				= (int)of_read_number(log2_scb_sizes + i, 1)
+					- 15;
+			pcie->num_memc++;
+		}
+	}

In your device tree documentation this is required property, what if this property is missing ?

If you look at the driver, you will see that it assumes a 1GB SCB window size if this property is absent.

PS: Do you mind trimming your replies in the future just to quote the relevant part? Pretty much like I just did, this greatly improves the ability to jump right to where the comments are. Thanks

Signature · 1 line
Florian
#11 lore raw

Re: [PATCH v2 1/2] Documentation: DT: bindings: Add Broadcom STB PCIe bindings

In reply to Bharat Kumar Gogada
Quoted 7 lines · Bharat Kumar Gogada

Review

Quoted 5 lines

+- brcm,log2-scb-sizes: log2 size of the SCB window that is mapped to

(quoted diff) +4 -0
+PCIe space
+  there must be exactly one value per memory controller present in the
+system
+  (ranges from 1 to 3)

Can you please give more insight on what does this property do ?

There is another part of the thread that should tell you a bit more what this is about, here is where it starts:

http://www.spinics.net/lists/linux-pci/msg50973.html

And this is where we discuss what we should be doing about it:

http://www.spinics.net/lists/linux-pci/msg51070.html

Signature · 1 line
Florian
#15 lore raw
In reply to Florian Fainelli
Quoted 10 lines · Florian Fainelli

Hi all,

This patch series adds support for Broadcom STB SoC's PCIe root complex driver.

This was primarily tested on BCM7445 (ARM) and BCM7435 (MIPS).

Jim is the original author, and I picked up our downstream 4.1 driver and updated it to utilize the non-ARM hw_pci functions as well as made some stylistic changes.

Quoted 5 lines

Thanks!

Jim Quinlan (2):
Documentation: DT: bindings: Add Broadcom STB PCIe bindings
pci: host: Add Broadcom STB PCIE RC controller

Hi Florian,

There was some discussion about these patches, so I assume you'll post a new version addressing that. When you do, can you include /proc/iomem and /proc/ioports contents?

I'm looking to avoid problems like this:
http://lkml.kernel.org/r/20160606230537.20936.2892.stgit at bhelgaas-glaptop2.roam.corp.google.com

Also, it will save me time if you take note of this:
http://lkml.kernel.org/r/20160607231326.GA4759 at localhost

Bjorn