Add PCIe support for bcm2712
Subsystems (7)
v2 cover Add PCIe support for bcm2712
Hello,
Here is a v2 of adding PCIe support for bcm2712 (RPi5), the fisrt version can be found at [1].
v2 is based on linux-next plus latest changes in pcie-brcmstb driver [2]. The changes recently made by Jim leaded to a simplified patchset for bcm2712 enablement coparing with previous version of this series.
Noticeable changes are:
- Use of msi-range property in the MIP MSI-X controller and DT which make possible to avoid few private DT properties. The other noticeable change is moving of msi-pci-addr private property to a second 'reg' region. I'll appreciate comments on this.
- Now the PCIe DT nodes are on separate axi{} simple-bus because adding it on soc{} adds too much churn in the node (Florian).
- Added 'quirks' field in pcie_cfg_data to work around an issue (hw bug?) with bridge_reset on bcm2712 SoC.
regards,
~Stan
[1] https://patchwork.kernel.org/project/linux-pci/cover/[email protected]/
[2] https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git/log/?h=controller/brcmstb
Stanimir Varbanov (11):
dt-bindings: interrupt-controller: Add bcm2712 MSI-X DT bindings
dt-bindings: PCI: brcmstb: Update bindings for PCIe on bcm2712
irqchip: mip: Add Broadcom bcm2712 MSI-X interrupt controller
PCI: brcmstb: Expand inbound size calculation helper
PCI: brcmstb: Restore CRS in RootCtl after prstn_n
PCI: brcmstb: Enable external MSI-X if available
PCI: brcmstb: Avoid turn off of bridge reset
PCI: brcmstb: Add bcm2712 support
PCI: brcmstb: Reuse config structure
arm64: dts: broadcom: bcm2712: Add PCIe DT nodes
arm64: dts: broadcom: bcm2712-rpi-5-b: Enable PCIe DT nodes
.../brcm,bcm2712-msix.yaml | 69 ++++ .../bindings/pci/brcm,stb-pcie.yaml | 5 +- .../boot/dts/broadcom/bcm2712-rpi-5-b.dts | 8 + arch/arm64/boot/dts/broadcom/bcm2712.dtsi | 166 ++++++++++ drivers/irqchip/Kconfig | 12 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-bcm2712-mip.c | 310 ++++++++++++++++++ drivers/pci/controller/pcie-brcmstb.c | 172 +++++++--- 8 files changed, 694 insertions(+), 49 deletions(-) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/brcm,bcm2712-msix.yaml create mode 100644 drivers/irqchip/irq-bcm2712-mip.c
Signature · 1 line
2.35.3
PATCH v2 1/11 dt-bindings: interrupt-controller: Add bcm2712 MSI-X DT bindings
Adds DT bindings for bcm2712 MSI-X interrupt peripheral controller.
--- .../brcm,bcm2712-msix.yaml | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/brcm,bcm2712-msix.yaml
Documentation/devicetree/bindings/interrupt-controller/brcm,bcm2712-msix.yaml new file +69 -0
@@ -0,0 +1,69 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/interrupt-controller/brcm,bcm2712-msix.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Broadcom bcm2712 MSI-X Interrupt Peripheral support + +maintainers: + - Stanimir Varbanov <[email protected]> + +description: > + This interrupt controller is used to provide interrupt vectors to the + generic interrupt controller (GIC) on bcm2712. It will be used as + external MSI-X controller for PCIe root complex. + +allOf: + - $ref: /schemas/interrupt-controller/msi-controller.yaml# + +properties: + compatible: + const: brcm,bcm2712-mip + + reg: + items: + - description: base registers address + - description: pcie message address + + interrupt-controller: true + + "#interrupt-cells": + const: 2 + + msi-controller: true + + "#msi-cells": + enum: [0] + + msi-ranges: true + +additionalProperties: false + +required: + - compatible + - reg + - interrupt-controller + - "#interrupt-cells" + - msi-controller + - msi-ranges + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + + axi { + #address-cells = <2>; + #size-cells = <2>; + + msi-controller@1000130000 { + compatible = "brcm,bcm2712-mip"; + reg = <0x10 0x00130000 0x00 0xc0>, + <0xff 0xfffff000 0x00 0x1000>; + msi-controller; + #msi-cells = <0>; + interrupt-controller; + #interrupt-cells = <2>; + msi-ranges = <&gicv2 GIC_SPI 128 IRQ_TYPE_EDGE_RISING 64>; + }; + };
Signature · 1 line
2.35.3
Rob Herring
maintainerRe: [PATCH v2 -next 01/11] dt-bindings: interrupt-controller: Add bcm2712 MSI-X DT bindings
Quoted 16 lines · Stanimir Varbanov
Adds DT bindings for bcm2712 MSI-X interrupt peripheral controller.
Signed-off-by Stanimir Varbanov <[email protected]>--- .../brcm,bcm2712-msix.yaml | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/brcm,bcm2712-msix.yamlDocumentation/devicetree/bindings/interrupt-controller/brcm,bcm2712-msix.yaml new file +2
-0@@ -0,0 +1,69 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2
Documentation/devicetree/bindings/interrupt-controller/brcm,bcm2712-msix.yaml line 12
Quoted 10 lines
Documentation/devicetree/bindings/interrupt-controller/brcm,bcm2712-msix.yaml new file +10
-0+--- +$id: http://devicetree.org/schemas/interrupt-controller/brcm,bcm2712-msix.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Broadcom bcm2712 MSI-X Interrupt Peripheral support + +maintainers: + - Stanimir Varbanov <[email protected]> + +description: >
Don't need '>' here.
Quoted 10 lines
Documentation/devicetree/bindings/interrupt-controller/brcm,bcm2712-msix.yaml new file +10
-0+ This interrupt controller is used to provide interrupt vectors to the + generic interrupt controller (GIC) on bcm2712. It will be used as + external MSI-X controller for PCIe root complex. + +allOf: + - $ref: /schemas/interrupt-controller/msi-controller.yaml# + +properties: + compatible: + const: brcm,bcm2712-mip
Documentation/devicetree/bindings/interrupt-controller/brcm,bcm2712-msix.yaml line 32
Quoted 10 lines
Documentation/devicetree/bindings/interrupt-controller/brcm,bcm2712-msix.yaml new file +10
-0+ + reg: + items: + - description: base registers address + - description: pcie message address + + interrupt-controller: true + + "#interrupt-cells": + const: 2
What goes in these cells?
But really, what interrupts does an MSI controller handle? Or are we just putting "interrupt-controller" in here so that kernel handles this with IRQCHIP_DECLARE()?
Documentation/devicetree/bindings/interrupt-controller/brcm,bcm2712-msix.yaml line 34
Quoted 2 lines
Documentation/devicetree/bindings/interrupt-controller/brcm,bcm2712-msix.yaml new file +2
-0+ + msi-controller: true
Drop and use 'unevaluatedProperties'.
Documentation/devicetree/bindings/interrupt-controller/brcm,bcm2712-msix.yaml line 37
Quoted 3 lines
Documentation/devicetree/bindings/interrupt-controller/brcm,bcm2712-msix.yaml new file +3
-0+ + "#msi-cells": + enum: [0]
const: 0
Documentation/devicetree/bindings/interrupt-controller/brcm,bcm2712-msix.yaml line 39
Quoted 2 lines
Documentation/devicetree/bindings/interrupt-controller/brcm,bcm2712-msix.yaml new file +2
-0+ + msi-ranges: true
Drop.
Quoted 33 lines
Documentation/devicetree/bindings/interrupt-controller/brcm,bcm2712-msix.yaml new file +30
-0+ +additionalProperties: false + +required: + - compatible + - reg + - interrupt-controller + - "#interrupt-cells" + - msi-controller + - msi-ranges + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + + axi { + #address-cells = <2>; + #size-cells = <2>; + + msi-controller@1000130000 { + compatible = "brcm,bcm2712-mip"; + reg = <0x10 0x00130000 0x00 0xc0>, + <0xff 0xfffff000 0x00 0x1000>; + msi-controller; + #msi-cells = <0>; + interrupt-controller; + #interrupt-cells = <2>; + msi-ranges = <&gicv2 GIC_SPI 128 IRQ_TYPE_EDGE_RISING 64>; + }; + };Signature · 1 line
2.35.3
Re: [PATCH v2 -next 01/11] dt-bindings: interrupt-controller: Add bcm2712 MSI-X DT bindings
Hi Rob,
Thank you for the review comments!
Quoted 21 lines · Rob Herring
Quoted 20 lines · Stanimir Varbanov
Adds DT bindings for bcm2712 MSI-X interrupt peripheral controller.
Signed-off-by Stanimir Varbanov <[email protected]>--- .../brcm,bcm2712-msix.yaml | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/brcm,bcm2712-msix.yamlDocumentation/devicetree/bindings/interrupt-controller/brcm,bcm2712-msix.yaml new file +6
-0@@ -0,0 +1,69 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/interrupt-controller/brcm,bcm2712-msix.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# +
Quoted 8 lines
Documentation/devicetree/bindings/interrupt-controller/brcm,bcm2712-msix.yaml line 12
Quoted 6 lines
Documentation/devicetree/bindings/interrupt-controller/brcm,bcm2712-msix.yaml new file +6
-0+title: Broadcom bcm2712 MSI-X Interrupt Peripheral support + +maintainers: + - Stanimir Varbanov <[email protected]> + +description: >Don't need '>' here.
OK.
Quoted 24 lines
Quoted 11 lines
Documentation/devicetree/bindings/interrupt-controller/brcm,bcm2712-msix.yaml new file +10
-0+ This interrupt controller is used to provide interrupt vectors to the + generic interrupt controller (GIC) on bcm2712. It will be used as + external MSI-X controller for PCIe root complex. + +allOf: + - $ref: /schemas/interrupt-controller/msi-controller.yaml# + +properties: + compatible: + const: brcm,bcm2712-mipDocumentation/devicetree/bindings/interrupt-controller/brcm,bcm2712-msix.yaml line 32
Quoted 10 lines
Documentation/devicetree/bindings/interrupt-controller/brcm,bcm2712-msix.yaml new file +10
-0+ + reg: + items: + - description: base registers address + - description: pcie message address + + interrupt-controller: true + + "#interrupt-cells": + const: 2What goes in these cells?
Quoted 4 lines
But really, what interrupts does an MSI controller handle? Or are we just putting "interrupt-controller" in here so that kernel handles this with
IRQCHIP_DECLARE()?
Yes, looks like interrupt-controller property is need by IRQCHIP_DECLARE().
I will drop interrupt-controller/cells and convert the driver to use IRQCHIP_PLATFORM_DRIVER_BEGIN/END().
Quoted 4 lines
Documentation/devicetree/bindings/interrupt-controller/brcm,bcm2712-msix.yaml line 34
Quoted 2 lines
Documentation/devicetree/bindings/interrupt-controller/brcm,bcm2712-msix.yaml new file +2
-0+ + msi-controller: trueDrop and use 'unevaluatedProperties'.
OK.
Quoted 6 lines
Documentation/devicetree/bindings/interrupt-controller/brcm,bcm2712-msix.yaml line 37
Quoted 4 lines
Documentation/devicetree/bindings/interrupt-controller/brcm,bcm2712-msix.yaml new file +3
-0+ + "#msi-cells": + enum: [0]const: 0
OK.
Quoted 5 lines
Documentation/devicetree/bindings/interrupt-controller/brcm,bcm2712-msix.yaml line 39
Quoted 3 lines
Documentation/devicetree/bindings/interrupt-controller/brcm,bcm2712-msix.yaml new file +2
-0+ + msi-ranges: trueDrop.
OK.
Quoted 34 lines
Quoted 34 lines
Documentation/devicetree/bindings/interrupt-controller/brcm,bcm2712-msix.yaml new file +30
-0+ +additionalProperties: false + +required: + - compatible + - reg + - interrupt-controller + - "#interrupt-cells" + - msi-controller + - msi-ranges + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + + axi { + #address-cells = <2>; + #size-cells = <2>; + + msi-controller@1000130000 { + compatible = "brcm,bcm2712-mip"; + reg = <0x10 0x00130000 0x00 0xc0>, + <0xff 0xfffff000 0x00 0x1000>; + msi-controller; + #msi-cells = <0>; + interrupt-controller; + #interrupt-cells = <2>; + msi-ranges = <&gicv2 GIC_SPI 128 IRQ_TYPE_EDGE_RISING 64>; + }; + };Signature · 1 line
2.35.3
PATCH v2 2/11 dt-bindings: PCI: brcmstb: Update bindings for PCIe on bcm2712
In reply to Stanimir VarbanovUpdate brcmstb PCIe controller bindings with bcm2712 compatible and add new resets.
--- Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml +4 -1
@@ -14,6 +14,7 @@ properties: items: - enum: - brcm,bcm2711-pcie # The Raspberry Pi 4 + - brcm,bcm2712-pcie # Raspberry Pi 5 - brcm,bcm4908-pcie - brcm,bcm7211-pcie # Broadcom STB version of RPi4 - brcm,bcm7216-pcie # Broadcom 7216 Arm
@@ -158,7 +159,9 @@ allOf: properties: compatible: contains: - const: brcm,bcm7712-pcie + enum: + - brcm,bcm7712-pcie + - brcm,bcm2712-pcie then: properties: resets:
Signature · 1 line
2.35.3
Re: [PATCH v2 -next 02/11] dt-bindings: PCI: brcmstb: Update bindings for PCIe on bcm2712
Quoted 8 lines · Stanimir Varbanov
Update brcmstb PCIe controller bindings with bcm2712 compatible and add new resets.
Signed-off-by Stanimir Varbanov <[email protected]>--- Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Re: [PATCH v2 -next 02/11] dt-bindings: PCI: brcmstb: Update bindings for PCIe on bcm2712
In reply to Stanimir VarbanovQuoted 4 lines · Stanimir Varbanov
Update brcmstb PCIe controller bindings with bcm2712 compatible and add new resets.
Signed-off-by Stanimir Varbanov <[email protected]>
Signature · 1 line
Florian
PATCH v2 3/11 irqchip: mip: Add Broadcom bcm2712 MSI-X interrupt controller
In reply to Stanimir VarbanovAdd an interrupt controller driver for MSI-X Interrupt Peripheral (MIP) hardware block found in bcm2712. The interrupt controller is used to handle MSI-X interrupts from peripherials behind PCIe endpoints like RP1 south bridge found in RPi5.
There are two MIPs on bcm2712, the first has 64 consecutive SPIs assigned to 64 output vectors, and the second has 17 SPIs, but only 8 of them are consecutive starting at the 8th output vector.
--- drivers/irqchip/Kconfig | 12 ++ drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-bcm2712-mip.c | 310 ++++++++++++++++++++++++++++++ 3 files changed, 323 insertions(+) create mode 100644 drivers/irqchip/irq-bcm2712-mip.c
drivers/irqchip/Kconfig +12 -0
@@ -116,6 +116,18 @@ config I8259 bool select IRQ_DOMAIN +config BCM2712_MIP + bool "Broadcom BCM2712 MSI-X Interrupt Peripheral support" + depends on ARCH_BRCMSTB + default ARCH_BRCMSTB + depends on ARM_GIC + select GENERIC_IRQ_CHIP + select IRQ_DOMAIN + help + Enable support for the Broadcom BCM2712 MSI-X target peripheral + (MIP) needed by PCIe brcmstb to handle MSI-X interrupts on + Raspberry Pi 5. + config BCM6345_L1_IRQ bool select GENERIC_IRQ_CHIP
drivers/irqchip/Makefile +1 -0
@@ -62,6 +62,7 @@ obj-$(CONFIG_XTENSA_MX) += irq-xtensa-mx.o obj-$(CONFIG_XILINX_INTC) += irq-xilinx-intc.o obj-$(CONFIG_IRQ_CROSSBAR) += irq-crossbar.o obj-$(CONFIG_SOC_VF610) += irq-vf610-mscm-ir.o +obj-$(CONFIG_BCM2712_MIP) += irq-bcm2712-mip.o obj-$(CONFIG_BCM6345_L1_IRQ) += irq-bcm6345-l1.o obj-$(CONFIG_BCM7038_L1_IRQ) += irq-bcm7038-l1.o obj-$(CONFIG_BCM7120_L2_IRQ) += irq-bcm7120-l2.o
drivers/irqchip/irq-bcm2712-mip.c new file +310 -0
310 lines not on this page · raw message
Signature · 1 line
2.35.3
Re: [PATCH v2 -next 03/11] irqchip: mip: Add Broadcom bcm2712 MSI-X interrupt controller
drivers/irqchip/irq-bcm2712-mip.c line 35
Quoted 10 lines · Stanimir Varbanov
drivers/irqchip/irq-bcm2712-mip.c new file +10
-0+ +struct mip_priv { +/* used to protect bitmap alloc/free */ +spinlock_t lock; +void __iomem *base; +u64 msg_addr; +u32 msi_base; +u32 num_msis; +unsigned long *bitmap; +struct irq_domain *parent;
And please read the rest of the document too.
drivers/irqchip/irq-bcm2712-mip.c line 47
Quoted 12 lines
drivers/irqchip/irq-bcm2712-mip.c new file +12
-0+}; + +static void mip_mask_msi_irq (struct irq_data *d) +{ +pci_msi_mask_irq (d); +irq_chip_mask_parent (d); +} + +static void mip_unmask_msi_irq (struct irq_data *d) +{ +pci_msi_unmask_irq (d); +irq_chip_unmask_parent (d);
This is asymmetric vs. mask(), but that's just the usual copy & pasta problem.
Quoted 9 lines
drivers/irqchip/irq-bcm2712-mip.c new file +9
-0+} +static int mip_init_domains (struct mip_priv *priv,struct device_node *np) +{ +struct irq_domain *middle_domain, *msi_domain; + + middle_domain =irq_domain_add_hierarchy (priv->parent,0 , + priv->num_msis, np, + &mip_middle_domain_ops, + priv);
drivers/irqchip/irq-bcm2712-mip.c line 217
Quoted 10 lines
drivers/irqchip/irq-bcm2712-mip.c new file +10
-0+if (!middle_domain) +return -ENOMEM ; + + msi_domain =pci_msi_create_irq_domain (of_node_to_fwnode (np), + &mip_msi_domain_info, + middle_domain); +if (!msi_domain) { +irq_domain_remove (middle_domain); +return -ENOMEM ; + }
This is not much different. Please convert this to a proper MSI parent domain and let the PCI/MSI core handle the PCI/MSI part.
See
https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/log/?h=irq-msi-2024-07-22
for reference.
Thanks,
tglx
Re: [PATCH v2 -next 03/11] irqchip: mip: Add Broadcom bcm2712 MSI-X interrupt controller
Hi Thomas,
Thank you for the comments!
Quoted 14 lines · Thomas Gleixner
drivers/irqchip/irq-bcm2712-mip.c line 35
Quoted 10 lines · Stanimir Varbanov
drivers/irqchip/irq-bcm2712-mip.c new file +10
-0+ +struct mip_priv { +/* used to protect bitmap alloc/free */ +spinlock_t lock; +void __iomem *base; +u64 msg_addr; +u32 msi_base; +u32 num_msis; +unsigned long *bitmap; +struct irq_domain *parent;
Quoted 1 line
And please read the rest of the document too.
Sure.
Quoted 16 lines
drivers/irqchip/irq-bcm2712-mip.c line 47
Quoted 13 lines
drivers/irqchip/irq-bcm2712-mip.c new file +12
-0+}; + +static void mip_mask_msi_irq (struct irq_data *d) +{ +pci_msi_mask_irq (d); +irq_chip_mask_parent (d); +} + +static void mip_unmask_msi_irq (struct irq_data *d) +{ +pci_msi_unmask_irq (d); +irq_chip_unmask_parent (d);This is asymmetric vs.
mask(), but that's just the usual copy & pasta problem.
Correct, but this will disappear when convert to MSI parent.
Quoted 15 lines
Quoted 15 lines
drivers/irqchip/irq-bcm2712-mip.c new file +14
-0+} +static int mip_init_domains (struct mip_priv *priv,struct device_node *np) +{ +struct irq_domain *middle_domain, *msi_domain; + + middle_domain =irq_domain_add_hierarchy (priv->parent,0 , + priv->num_msis, np, + &mip_middle_domain_ops, + priv); +if (!middle_domain) +return -ENOMEM ; + + msi_domain = pci_msi_create_irq_domain(of_node_to_fwnode(np), + &mip_msi_domain_info,
Quoted 8 lines
drivers/irqchip/irq-bcm2712-mip.c line 217
Quoted 5 lines
drivers/irqchip/irq-bcm2712-mip.c new file +5
-0+ middle_domain); +if (!msi_domain) { +irq_domain_remove (middle_domain); +return -ENOMEM ; + }This is not much different. Please convert this to a proper MSI parent domain and let the PCI/MSI core handle the PCI/MSI part.
I apologize, but I wasn't able to make it work on time. The good news is that I made it now and will send it in next version of the series.
regards,
~Stan
PATCH v2 4/11 PCI: brcmstb: Expand inbound size calculation helper
In reply to Stanimir VarbanovExpand the inbound size calculation in helper function up to 64GB.
--- drivers/pci/controller/pcie-brcmstb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/controller/pcie-brcmstb.c +2 -2
@@ -309,8 +309,8 @@ static int brcm_pcie_encode_ibar_size(u64 size)if (log2_in >=12 && log2_in <=15 )/* Covers 4KB to 32KB (inclusive) */ return (log2_in -12 ) +0x1c ; -else if (log2_in >=16 && log2_in <=35 ) -/* Covers 64KB to 32GB, (inclusive) */ +else if (log2_in >=16 && log2_in <=36 ) +/* Covers 64KB to 64GB, (inclusive) */ return log2_in -15 ;/* Something is awry so disable */ return 0 ;
Signature · 1 line
2.35.3
Re: [PATCH v2 -next 04/11] PCI: brcmstb: Expand inbound size calculation helper
Quoted 2 lines · Stanimir Varbanov
Expand the inbound size calculation in helper function up to 64GB.
Nit, we could explain why, which is that BCM2712's memory map supports up to 64GB of DRAM. With that:
Signature · 1 line
Florian
Re: [PATCH v2 -next 04/11] PCI: brcmstb: Expand inbound size calculation helper
Quoted 6 lines · Florian Fainelli
Quoted 2 lines · Stanimir Varbanov
Expand the inbound size calculation in helper function up to 64GB.
Nit, we could explain why, which is that BCM2712's memory map supports up to 64GB of DRAM. With that:
Sure.
Quoted 2 lines
Reviewed-by Florian Fainelli <[email protected]>
Thank you!
regards,
~Stan
PATCH v2 5/11 PCI: brcmstb: Restore CRS in RootCtl after prstn_n
In reply to Stanimir VarbanovRootCtl bits might reset by perst_n during probe, re-enable CRS SVE here in pcie_start_link.
--- drivers/pci/controller/pcie-brcmstb.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/pci/controller/pcie-brcmstb.c +12 -1
@@ -1271,7 +1271,7 @@ static int brcm_pcie_start_link(struct brcm_pcie *pcie) {struct device *dev = pcie->dev;void __iomem *base = pcie->base; -u16 nlw, cls, lnksta; +u16 nlw, cls, lnksta, tmp16;bool ssc_good = false;int ret, i;
@@ -1319,6 +1319,17 @@ static int brcm_pcie_start_link(struct brcm_pcie *pcie)pci_speed_string (pcie_link_speed[cls]), nlw, ssc_good ? "(SSC)" : "(!SSC)"); +/* +* RootCtl bits are reset by perst_n, which undoes pci_enable_crs() +* called prior to pci_add_new_bus() during probe. Re-enable here. +*/ + tmp16 =readw (base +BRCM_PCIE_CAP_REGS +PCI_EXP_RTCAP ); +if (tmp16 &PCI_EXP_RTCAP_CRSVIS ) { + tmp16 =readw (base +BRCM_PCIE_CAP_REGS +PCI_EXP_RTCTL ); +u16p_replace_bits (&tmp16,1 ,PCI_EXP_RTCTL_CRSSVE ); +writew (tmp16, base +BRCM_PCIE_CAP_REGS +PCI_EXP_RTCTL ); + } +return 0 ; }
Signature · 1 line
2.35.3
Florian Fainelli
maintainerRe: [PATCH v2 -next 05/11] PCI: brcmstb: Restore CRS in RootCtl after prstn_n
Quoted 4 lines · Stanimir Varbanov
RootCtl bits might reset by
perst_nduring probe, re-enable CRS SVE here inpcie_start_link.Signed-off-by Stanimir Varbanov <[email protected]>
This looks like a bug fix, and we should explain what is the user visible effect of that, if any.
Signature · 1 line
Florian
Re: [PATCH v2 -next 05/11] PCI: brcmstb: Restore CRS in RootCtl after prstn_n
Hi Florian,
Quoted 8 lines · Florian Fainelli
Quoted 4 lines · Stanimir Varbanov
RootCtl bits might reset by
perst_nduring probe, re-enable CRS SVE here inpcie_start_link.Signed-off-by Stanimir Varbanov <[email protected]>This looks like a bug fix, and we should explain what is the user visible effect of that, if any.
It is definitely a bugfix. Otherwise, CRS Software Visibility is important feature from pcie1.1. Not enabling it on Root Port could lead to infinite configuration retry cycles when enumerate endpoints which supports CRS. For more information [1] and [2].
I spent some time debugging it and found that this is not the proper solution. I think the issue comes from wrongly implemented .add_bus pci_ops. Looks like .add_bus op shouldn't call brcm_pcie_start_link() but invoke before pci_host_probe(), then the issue will fix by itself.
What I observed is that pci_enable_crs() is setting CSR Software Visibility Enable bit but the controller is ignoring it without error (reading the Root Control register returns zero). This means that the controller is not ready to accept configuration write requests at that time, that's why I tried the following diff which seems to work:
static struct pci_ops brcm_pcie_ops = {
.map_bus = brcm_pcie_map_bus,
.read = pci_generic_config_read,
.write = pci_generic_config_write,
- .add_bus = brcm_pcie_add_bus,
- .remove_bus = brcm_pcie_remove_bus,
};
static struct pci_ops brcm7425_pcie_ops = {
@@ -1983,6 +2018,9 @@ static int brcm_pcie_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, pcie);
+ //TODO: check for error
+ brcm_pcie_start_link(pcie);
+
ret = pci_host_probe(bridge);
if (!ret && !brcm_pcie_link_up(pcie))
ret = -ENODEV;Of course this change would work on RPi5 because there are no regulators.
I will drop the patch from the series for now and work on a proper solution.
regards,
~Stan
[1]
https://patchwork.kernel.org/project/linux-pci/patch/[email protected]/
[2]
https://blog.linuxplumbersconf.org/2017/ocw/system/presentations/4732/original/crs.pdf
PATCH v2 6/11 PCI: brcmstb: Enable external MSI-X if available
In reply to Stanimir VarbanovOn RPi5 there is an external MIP MSI-X interrupt controller which can handle up to 64 interrupts.
--- drivers/pci/controller/pcie-brcmstb.c | 63 +++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 4 deletions(-)
drivers/pci/controller/pcie-brcmstb.c +59 -4
@@ -1333,6 +1333,52 @@ static int brcm_pcie_start_link(struct brcm_pcie *pcie)return 0 ; } +static int brcm_pcie_enable_external_msix (struct brcm_pcie *pcie, +struct device_node *msi_np) +{ +struct inbound_win inbound_wins[PCIE_BRCM_MAX_INBOUND_WINS ]; +u64 msi_pci_addr, msi_phys_addr; +struct resource r; +int mip_bar, ret; +u32 val, reg; + + ret =of_property_read_reg (msi_np,1 , &msi_pci_addr,NULL ); +if (ret) +return ret; + + ret =of_address_to_resource (msi_np,0 , &r); +if (ret) +return ret; + + msi_phys_addr = r.start; + +/* Find free inbound window for MIP access */ + mip_bar =brcm_pcie_get_inbound_wins (pcie, inbound_wins); +if (mip_bar <0 ) +return mip_bar; + + mip_bar +=1 ; + reg =brcm_bar_reg_offset (mip_bar); + + val =lower_32_bits (msi_pci_addr); + val |=brcm_pcie_encode_ibar_size (SZ_4K ); +writel (val, pcie->base + reg); + + val =upper_32_bits (msi_pci_addr); +writel (val, pcie->base + reg +4 ); + + reg =brcm_ubus_reg_offset (mip_bar); + + val =lower_32_bits (msi_phys_addr); + val |=PCIE_MISC_UBUS_BAR1_CONFIG_REMAP_ACCESS_EN_MASK ; +writel (val, pcie->base + reg); + + val =upper_32_bits (msi_phys_addr); +writel (val, pcie->base + reg +4 ); + +return 0 ; +} +static const char *const supplies[] = {"vpcie3v3" ,"vpcie3v3aux" ,
@@ -1898,11 +1944,20 @@ static int brcm_pcie_probe(struct platform_device *pdev) goto fail; } - msi_np =of_parse_phandle (pcie->np,"msi-parent" ,0 ); -if (pci_msi_enabled () && msi_np == pcie->np) { - ret =brcm_pcie_enable_msi (pcie); +if (pci_msi_enabled ()) { + msi_np =of_parse_phandle (pcie->np,"msi-parent" ,0 ); +const char *str; + +if (msi_np == pcie->np) { + str ="internal MSI" ; + ret =brcm_pcie_enable_msi (pcie); + }else { + str ="external MSI-X" ; + ret =brcm_pcie_enable_external_msix (pcie, msi_np); + } +if (ret) { -dev_err (pcie->dev,"probe of internal MSI failed" ); +dev_err (pcie->dev,"enable of %s failed\n" , str); goto fail; } }
Signature · 1 line
2.35.3
PATCH v2 7/11 PCI: brcmstb: Avoid turn off of bridge reset
In reply to Stanimir VarbanovOn brcm_pcie_turn_off avoid shutdown of bridge reset.
--- drivers/pci/controller/pcie-brcmstb.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/pci/controller/pcie-brcmstb.c +12 -2
@@ -234,10 +234,17 @@ struct inbound_win {u64 cpu_addr; }; +/* +* Shutting down this bridge on pcie1 means accesses to rescal block +* will hang the chip if another RC wants to assert/deassert rescal. +*/ +#define CFG_QUIRK_AVOID_BRIDGE_SHUTDOWN BIT(0) +struct pcie_cfg_data {const int *offsets;const enum pcie_soc_base soc_base;const bool has_phy; +const u32 quirks;u8 num_inbound_wins;int (*perst_set)(struct brcm_pcie *pcie,u32 val);int (*bridge_sw_init_set)(struct brcm_pcie *pcie,u32 val);
@@ -290,6 +297,7 @@ struct brcm_pcie {struct subdev_regulators *sr;bool ep_wakeup_capable;bool has_phy; +u32 quirks;u8 num_inbound_wins; };
@@ -1549,8 +1557,9 @@ static int brcm_pcie_turn_off(struct brcm_pcie *pcie)u32p_replace_bits (&tmp,1 ,PCIE_MISC_HARD_PCIE_HARD_DEBUG_SERDES_IDDQ_MASK );writel (tmp, base +HARD_DEBUG (pcie)); -/* Shutdown PCIe bridge */ - ret = pcie->bridge_sw_init_set (pcie,1 ); +if (!(pcie->quirks &CFG_QUIRK_AVOID_BRIDGE_SHUTDOWN )) +/* Shutdown PCIe bridge */ + ret = pcie->bridge_sw_init_set (pcie,1 );return ret; }
@@ -1864,6 +1873,7 @@ static int brcm_pcie_probe(struct platform_device *pdev) pcie->perst_set = data->perst_set; pcie->bridge_sw_init_set = data->bridge_sw_init_set; pcie->has_phy = data->has_phy; + pcie->quirks = data->quirks; pcie->num_inbound_wins = data->num_inbound_wins; pcie->base =devm_platform_ioremap_resource (pdev,0 );
Signature · 1 line
2.35.3
Florian Fainelli
maintainerRe: [PATCH v2 -next 07/11] PCI: brcmstb: Avoid turn off of bridge reset
Quoted 12 lines · Stanimir Varbanov
On
brcm_pcie_turn_offavoid shutdown of bridge reset.Signed-off-by Stanimir Varbanov <[email protected]>--- drivers/pci/controller/pcie-brcmstb.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)drivers/pci/controller/pcie-brcmstb.c +0
-0
drivers/pci/controller/pcie-brcmstb.c struct inbound_win { · line 240
Quoted 7 lines
drivers/pci/controller/pcie-brcmstb.c +4
-0@@ -234,10 +234,17 @@ struct inbound_win {u64 cpu_addr; }; +/* +* Shutting down this bridge on pcie1 means accesses to rescal block +* will hang the chip if another RC wants to assert/deassert rescal. +*/
Maybe a slightly more detailed comment saying that the RESCAL block is tied to PCIe controller #1, regardless of the number of controllers, and turning off PCIe controller #1 prevents access to the RESCAL register blocks, therefore not other controller can access this register space, and depending upon the bus fabric we may get a timeout (UBUS/GISB), or a hang (AXI).
Thanks!
Signature · 1 line
Florian
Re: [PATCH v2 -next 07/11] PCI: brcmstb: Avoid turn off of bridge reset
Quoted 19 lines · Florian Fainelli
Quoted 18 lines · Stanimir Varbanov
On
brcm_pcie_turn_offavoid shutdown of bridge reset.Signed-off-by Stanimir Varbanov <[email protected]>---
drivers/pci/controller/pcie-brcmstb.c| 14 ++++++++++++--1 file changed, 12 insertions(+), 2 deletions(-)drivers/pci/controller/pcie-brcmstb.c +0
-0@@ -234,10 +234,17 @@ struct inbound_win { u64 cpu_addr; };+/*
+ * Shutting down this bridge on pcie1 means accesses to rescal block
+ * will hang the chip if another RC wants to assert/deassert rescal.
Quoted 8 lines
Quoted 1 line
+ */
Maybe a slightly more detailed comment saying that the RESCAL block is tied to PCIe controller #1, regardless of the number of controllers, and turning off PCIe controller #1 prevents access to the RESCAL register blocks, therefore not other controller can access this register space, and depending upon the bus fabric we may get a timeout (UBUS/GISB), or a hang (AXI).
Ack. Thank you!
regards,
~Stan
PATCH v2 8/11 PCI: brcmstb: Add bcm2712 support
In reply to Stanimir VarbanovAdd bare minimum amount of changes in order to support PCIe RC hardware IP found in RPi5.
--- drivers/pci/controller/pcie-brcmstb.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/pci/controller/pcie-brcmstb.c +10 -0
@@ -1769,6 +1769,15 @@ static const struct pcie_cfg_data bcm2711_cfg = { .num_inbound_wins = 3, }; +static const struct pcie_cfg_data bcm2712_cfg = { + .offsets = pcie_offsets_bcm7712, + .soc_base =BCM7712 , + .perst_set = brcm_pcie_perst_set_7278, + .bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_generic, + .quirks =CFG_QUIRK_AVOID_BRIDGE_SHUTDOWN , + .num_inbound_wins =10 , +}; +static const struct pcie_cfg_data bcm4908_cfg = { .offsets = pcie_offsets, .soc_base =BCM4908 ,
@@ -1820,6 +1829,7 @@ static const struct pcie_cfg_data bcm7712_cfg = {static const struct of_device_id brcm_pcie_match[] = { { .compatible ="brcm,bcm2711-pcie" , .data = &bcm2711_cfg }, + { .compatible ="brcm,bcm2712-pcie" , .data = &bcm2712_cfg }, { .compatible ="brcm,bcm4908-pcie" , .data = &bcm4908_cfg }, { .compatible ="brcm,bcm7211-pcie" , .data = &generic_cfg }, { .compatible ="brcm,bcm7216-pcie" , .data = &bcm7216_cfg },
Signature · 1 line
2.35.3
Re: [PATCH v2 -next 08/11] PCI: brcmstb: Add bcm2712 support
Quoted 4 lines · Stanimir Varbanov
Add bare minimum amount of changes in order to support PCIe RC hardware IP found in RPi5.
Signed-off-by Stanimir Varbanov <[email protected]>
Signature · 1 line
Florian
PATCH v2 9/11 PCI: brcmstb: Reuse config structure
In reply to Stanimir VarbanovInstead of copying fields from pcie_cfg_data structure to brcm_pcie reference it directly.
--- drivers/pci/controller/pcie-brcmstb.c | 76 ++++++++++++--------------- 1 file changed, 33 insertions(+), 43 deletions(-)
drivers/pci/controller/pcie-brcmstb.c +33 -43
@@ -191,11 +191,11 @@#define SSC_STATUS_PLL_LOCK_MASK 0x800#define PCIE_BRCM_MAX_MEMC 3 -#define IDX_ADDR (pcie) ((pcie)->reg_offsets[EXT_CFG_INDEX]) -#define DATA_ADDR (pcie) ((pcie)->reg_offsets[EXT_CFG_DATA]) -#define PCIE_RGR1_SW_INIT_1 (pcie) ((pcie)->reg_offsets[RGR1_SW_INIT_1]) -#define HARD_DEBUG (pcie) ((pcie)->reg_offsets[PCIE_HARD_DEBUG]) -#define INTR2_CPU_BASE (pcie) ((pcie)->reg_offsets[PCIE_INTR2_CPU_BASE]) +#define IDX_ADDR (pcie) ((pcie)->cfg->offsets[EXT_CFG_INDEX]) +#define DATA_ADDR (pcie) ((pcie)->cfg->offsets[EXT_CFG_DATA]) +#define PCIE_RGR1_SW_INIT_1 (pcie) ((pcie)->cfg->offsets[RGR1_SW_INIT_1]) +#define HARD_DEBUG (pcie) ((pcie)->cfg->offsets[PCIE_HARD_DEBUG]) +#define INTR2_CPU_BASE (pcie) ((pcie)->cfg->offsets[PCIE_INTR2_CPU_BASE])/* Rescal registers */ #define PCIE_DVT_PMU_PCIE_PHY_CTRL 0xc700
@@ -283,8 +283,6 @@ struct brcm_pcie {int gen;u64 msi_target_addr;struct brcm_msi *msi; -const int *reg_offsets; -enum pcie_soc_base soc_base;struct reset_control *rescal;struct reset_control *perst_reset;struct reset_control *bridge_reset;
@@ -292,18 +290,14 @@ struct brcm_pcie {int num_memc;u64 memc_size[PCIE_BRCM_MAX_MEMC ];u32 hw_rev; -int (*perst_set)(struct brcm_pcie *pcie,u32 val); -int (*bridge_sw_init_set)(struct brcm_pcie *pcie,u32 val);struct subdev_regulators *sr;bool ep_wakeup_capable; -bool has_phy; -u32 quirks; -u8 num_inbound_wins; +const struct pcie_cfg_data *cfg; };static inline bool is_bmips (const struct brcm_pcie *pcie) { -return pcie->soc_base ==BCM7435 || pcie->soc_base ==BCM7425 ; +return pcie->cfg->soc_base ==BCM7435 || pcie->cfg->soc_base ==BCM7425 ; }/*
@@ -863,7 +857,7 @@ static int brcm_pcie_get_inbound_wins(struct brcm_pcie *pcie,* security considerations, and is not implemented in our modern * SoCs. */ -if (pcie->soc_base !=BCM7712 ) +if (pcie->cfg->soc_base !=BCM7712 )add_inbound_win (b++, &n,0 ,0 ,0 );resource_list_for_each_entry (entry, &bridge->dma_ranges) {
@@ -880,10 +874,10 @@ static int brcm_pcie_get_inbound_wins(struct brcm_pcie *pcie,* That being said, each BARs size must still be a power of * two. */ -if (pcie->soc_base ==BCM7712 ) +if (pcie->cfg->soc_base ==BCM7712 )add_inbound_win (b++, &n, size, cpu_start, pcie_start); -if (n > pcie->num_inbound_wins) +if (n > pcie->cfg->num_inbound_wins)break ; }
@@ -897,7 +891,7 @@ static int brcm_pcie_get_inbound_wins(struct brcm_pcie *pcie,* that enables multiple memory controllers. As such, it can return * now w/o doing special configuration. */ -if (pcie->soc_base ==BCM7712 ) +if (pcie->cfg->soc_base ==BCM7712 )return n; ret = of_property_read_variable_u64_array(pcie->np, "brcm,scb-sizes", pcie->memc_size, 1,
@@ -1020,7 +1014,7 @@ static void set_inbound_win_registers(struct brcm_pcie *pcie,* 7712: * All of their BARs need to be set. */ -if (pcie->soc_base ==BCM7712 ) { +if (pcie->cfg->soc_base ==BCM7712 ) {/* BUS remap register settings */ reg_offset =brcm_ubus_reg_offset (i); tmp =lower_32_bits (cpu_addr) & ~0xfff ;
@@ -1043,15 +1037,15 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie)int memc, ret;/* Reset the bridge */ - ret = pcie->bridge_sw_init_set (pcie,1 ); + ret = pcie->cfg->bridge_sw_init_set (pcie,1 );if (ret)return ret;/* Ensure that PERST# is asserted; some bootloaders may deassert it. */ -if (pcie->soc_base ==BCM2711 ) { - ret = pcie->perst_set (pcie,1 ); +if (pcie->cfg->soc_base ==BCM2711 ) { + ret = pcie->cfg->perst_set (pcie,1 );if (ret) { - pcie->bridge_sw_init_set (pcie,0 ); + pcie->cfg->bridge_sw_init_set (pcie,0 );return ret; } }
@@ -1059,7 +1053,7 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie)usleep_range (100 ,200 );/* Take the bridge out of reset */ - ret = pcie->bridge_sw_init_set (pcie,0 ); + ret = pcie->cfg->bridge_sw_init_set (pcie,0 );if (ret)return ret;
@@ -1079,9 +1073,9 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie)*/ if (is_bmips (pcie)) burst =0x1 ;/* 256 bytes */ -else if (pcie->soc_base ==BCM2711 ) +else if (pcie->cfg->soc_base ==BCM2711 ) burst =0x0 ;/* 128 bytes */ -else if (pcie->soc_base ==BCM7278 ) +else if (pcie->cfg->soc_base ==BCM7278 ) burst =0x3 ;/* 512 bytes */ else burst =0x2 ;/* 512 bytes */
@@ -1206,7 +1200,7 @@ static void brcm_extend_rbus_timeout(struct brcm_pcie *pcie)u32 timeout_us =4000000 ;/* 4 seconds, our setting for L1SS */ /* 7712 does not have this (RGR1) timer */ -if (pcie->soc_base ==BCM7712 ) +if (pcie->cfg->soc_base ==BCM7712 )return ;/* Each unit in timeout register is 1/216,000,000 seconds */
@@ -1284,7 +1278,7 @@ static int brcm_pcie_start_link(struct brcm_pcie *pcie)int ret, i;/* Unassert the fundamental reset */ - ret = pcie->perst_set (pcie,0 ); + ret = pcie->cfg->perst_set (pcie,0 );if (ret)return ret;
@@ -1527,12 +1521,12 @@ static int brcm_phy_cntl(struct brcm_pcie *pcie, const int start)static inline int brcm_phy_start (struct brcm_pcie *pcie) { -return pcie->has_phy ?brcm_phy_cntl (pcie,1 ) :0 ; +return pcie->cfg->has_phy ?brcm_phy_cntl (pcie,1 ) :0 ; }static inline int brcm_phy_stop (struct brcm_pcie *pcie) { -return pcie->has_phy ?brcm_phy_cntl (pcie,0 ) :0 ; +return pcie->cfg->has_phy ?brcm_phy_cntl (pcie,0 ) :0 ; }static int brcm_pcie_turn_off (struct brcm_pcie *pcie)
@@ -1543,7 +1537,7 @@ static int brcm_pcie_turn_off(struct brcm_pcie *pcie)if (brcm_pcie_link_up (pcie))brcm_pcie_enter_l23 (pcie);/* Assert fundamental reset */ - ret = pcie->perst_set (pcie,1 ); + ret = pcie->cfg->perst_set (pcie,1 );if (ret)return ret;
@@ -1557,9 +1551,9 @@ static int brcm_pcie_turn_off(struct brcm_pcie *pcie)u32p_replace_bits (&tmp,1 ,PCIE_MISC_HARD_PCIE_HARD_DEBUG_SERDES_IDDQ_MASK );writel (tmp, base +HARD_DEBUG (pcie)); -if (!(pcie->quirks &CFG_QUIRK_AVOID_BRIDGE_SHUTDOWN )) +if (!(pcie->cfg->quirks &CFG_QUIRK_AVOID_BRIDGE_SHUTDOWN ))/* Shutdown PCIe bridge */ - ret = pcie->bridge_sw_init_set (pcie,1 ); + ret = pcie->cfg->bridge_sw_init_set (pcie,1 );return ret; }
@@ -1647,7 +1641,7 @@ static int brcm_pcie_resume_noirq(struct device *dev) goto err_reset;/* Take bridge out of reset so we can access the SERDES reg */ - pcie->bridge_sw_init_set (pcie,0 ); + pcie->cfg->bridge_sw_init_set (pcie,0 );/* SERDES_IDDQ = 0 */ tmp =readl (base +HARD_DEBUG (pcie));
@@ -1878,13 +1872,7 @@ static int brcm_pcie_probe(struct platform_device *pdev) pcie =pci_host_bridge_priv (bridge); pcie->dev = &pdev->dev; pcie->np = np; - pcie->reg_offsets = data->offsets; - pcie->soc_base = data->soc_base; - pcie->perst_set = data->perst_set; - pcie->bridge_sw_init_set = data->bridge_sw_init_set; - pcie->has_phy = data->has_phy; - pcie->quirks = data->quirks; - pcie->num_inbound_wins = data->num_inbound_wins; + pcie->cfg = data; pcie->base =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (pcie->base))
@@ -1919,7 +1907,7 @@ static int brcm_pcie_probe(struct platform_device *pdev)if (ret)return dev_err_probe (&pdev->dev, ret,"could not enable clock\n" ); - pcie->bridge_sw_init_set (pcie,0 ); + pcie->cfg->bridge_sw_init_set (pcie,0 );if (pcie->swinit_reset) { ret =reset_control_assert (pcie->swinit_reset);
@@ -1958,7 +1946,8 @@ static int brcm_pcie_probe(struct platform_device *pdev) goto fail; pcie->hw_rev =readl (pcie->base +PCIE_MISC_REVISION ); -if (pcie->soc_base ==BCM4908 && pcie->hw_rev >=BRCM_PCIE_HW_REV_3_20 ) { +if (pcie->cfg->soc_base ==BCM4908 && + pcie->hw_rev >=BRCM_PCIE_HW_REV_3_20 ) {dev_err (pcie->dev,"hardware revision with unsupported PERST# setup\n" ); ret = -ENODEV ; goto fail;
@@ -1982,7 +1971,8 @@ static int brcm_pcie_probe(struct platform_device *pdev) } } - bridge->ops = pcie->soc_base ==BCM7425 ? &brcm7425_pcie_ops : &brcm_pcie_ops; + bridge->ops = pcie->cfg->soc_base ==BCM7425 ? + &brcm7425_pcie_ops : &brcm_pcie_ops; bridge->sysdata = pcie;platform_set_drvdata (pdev, pcie);
Signature · 1 line
2.35.3
Re: [PATCH v2 -next 09/11] PCI: brcmstb: Reuse config structure
Quoted 4 lines · Stanimir Varbanov
Instead of copying fields from
pcie_cfg_datastructure tobrcm_pciereference it directly.Signed-off-by Stanimir Varbanov <[email protected]>
Signature · 1 line
Florian
PATCH v2 10/11 arm64: dts: broadcom: bcm2712: Add PCIe DT nodes
In reply to Stanimir VarbanovAdd PCIe devicetree nodes, plus needed reset and mip MSI-X controllers.
--- arch/arm64/boot/dts/broadcom/bcm2712.dtsi | 166 ++++++++++++++++++++++ 1 file changed, 166 insertions(+)
arch/arm64/boot/dts/broadcom/bcm2712.dtsi +166 -0
@@ -192,6 +192,12 @@ soc: soc@107c000000 { #address-cells = <1>; #size-cells = <1>; + pcie_rescal: reset-controller@119500 { + compatible = "brcm,bcm7216-pcie-sata-rescal"; + reg = <0x00119500 0x10>; + #reset-cells = <0>; + }; + sdio1: mmc@fff000 { compatible = "brcm,bcm2712-sdhci", "brcm,sdhci-brcmstb";
@@ -204,6 +210,12 @@ sdio1: mmc@fff000 { mmc-ddr-3_3v; }; + bcm_reset: reset-controller@1504318 { + compatible = "brcm,brcmstb-reset"; + reg = <0x01504318 0x30>; + #reset-cells = <1>; + }; + system_timer: timer@7c003000 { compatible = "brcm,bcm2835-system-timer"; reg = <0x7c003000 0x1000>;
@@ -267,6 +279,160 @@ gicv2: interrupt-controller@7fff9000 { }; }; + axi@1000000000 { + compatible = "simple-bus"; + #address-cells = <2>; + #size-cells = <2>; + + ranges = <0x00 0x00000000 0x10 0x00000000 0x01 0x00000000>, + <0x14 0x00000000 0x14 0x00000000 0x04 0x00000000>, + <0x18 0x00000000 0x18 0x00000000 0x04 0x00000000>, + <0x1c 0x00000000 0x1c 0x00000000 0x04 0x00000000>; + + dma-ranges = <0x00 0x00000000 0x00 0x00000000 0x10 0x00000000>, + <0x14 0x00000000 0x14 0x00000000 0x04 0x00000000>, + <0x18 0x00000000 0x18 0x00000000 0x04 0x00000000>, + <0x1c 0x00000000 0x1c 0x00000000 0x04 0x00000000>; + + pcie0: pcie@100000 { + compatible = "brcm,bcm2712-pcie"; + reg = <0x00 0x00100000 0x00 0x9310>; + device_type = "pci"; + linux,pci-domain = <0>; + max-link-speed = <2>; + bus-range = <0x00 0xff>; + num-lanes = <1>; + #address-cells = <3>; + #interrupt-cells = <1>; + #size-cells = <2>; + interrupt-parent = <&gicv2>; + interrupts = <GIC_SPI 213 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 214 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "pcie", "msi"; + interrupt-map-mask = <0x0 0x0 0x0 0x7>; + interrupt-map = <0 0 0 1 &gicv2 GIC_SPI 209 IRQ_TYPE_LEVEL_HIGH>, + <0 0 0 2 &gicv2 GIC_SPI 210 IRQ_TYPE_LEVEL_HIGH>, + <0 0 0 3 &gicv2 GIC_SPI 211 IRQ_TYPE_LEVEL_HIGH>, + <0 0 0 4 &gicv2 GIC_SPI 212 IRQ_TYPE_LEVEL_HIGH>; + resets = <&bcm_reset 42>, <&pcie_rescal>; + reset-names = "bridge", "rescal"; + msi-controller; + msi-parent = <&pcie0>; + + ranges = <0x02000000 0x00 0x00000000 + 0x17 0x00000000 + 0x00 0xfffffffc>, + <0x43000000 0x04 0x00000000 + 0x14 0x00000000 + 0x3 0x00000000>; + + dma-ranges = <0x43000000 0x10 0x00000000 + 0x00 0x00000000 + 0x10 0x00000000>; + + status = "disabled"; + }; + + pcie1: pcie@110000 { + compatible = "brcm,bcm2712-pcie"; + reg = <0x00 0x00110000 0x00 0x9310>; + device_type = "pci"; + linux,pci-domain = <1>; + max-link-speed = <2>; + bus-range = <0x00 0xff>; + num-lanes = <1>; + #address-cells = <3>; + #interrupt-cells = <1>; + #size-cells = <2>; + interrupt-parent = <&gicv2>; + interrupts = <GIC_SPI 223 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 224 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "pcie", "msi"; + interrupt-map-mask = <0x0 0x0 0x0 0x7>; + interrupt-map = <0 0 0 1 &gicv2 GIC_SPI 219 IRQ_TYPE_LEVEL_HIGH>, + <0 0 0 2 &gicv2 GIC_SPI 220 IRQ_TYPE_LEVEL_HIGH>, + <0 0 0 3 &gicv2 GIC_SPI 221 IRQ_TYPE_LEVEL_HIGH>, + <0 0 0 4 &gicv2 GIC_SPI 222 IRQ_TYPE_LEVEL_HIGH>; + resets = <&bcm_reset 43>, <&pcie_rescal>; + reset-names = "bridge", "rescal"; + msi-parent = <&mip1>; + + ranges = <0x02000000 0x00 0x00000000 + 0x1b 0x00000000 + 0x00 0xfffffffc>, + <0x43000000 0x04 0x00000000 + 0x18 0x00000000 + 0x03 0x00000000>; + + dma-ranges = <0x03000000 0x10 0x00000000 + 0x00 0x00000000 + 0x10 0x00000000>; + + status = "disabled"; + }; + + pcie2: pcie@120000 { + compatible = "brcm,bcm2712-pcie"; + reg = <0x00 0x00120000 0x00 0x9310>; + device_type = "pci"; + linux,pci-domain = <2>; + max-link-speed = <2>; + bus-range = <0x00 0xff>; + num-lanes = <4>; + #address-cells = <3>; + #interrupt-cells = <1>; + #size-cells = <2>; + interrupt-parent = <&gicv2>; + interrupts = <GIC_SPI 233 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 234 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "pcie", "msi"; + interrupt-map-mask = <0x0 0x0 0x0 0x7>; + interrupt-map = <0 0 0 1 &gicv2 GIC_SPI 229 IRQ_TYPE_LEVEL_HIGH>, + <0 0 0 2 &gicv2 GIC_SPI 230 IRQ_TYPE_LEVEL_HIGH>, + <0 0 0 3 &gicv2 GIC_SPI 231 IRQ_TYPE_LEVEL_HIGH>, + <0 0 0 4 &gicv2 GIC_SPI 232 IRQ_TYPE_LEVEL_HIGH>; + resets = <&bcm_reset 44>, <&pcie_rescal>; + reset-names = "bridge", "rescal"; + msi-parent = <&mip0>; + + ranges = <0x02000000 0x00 0x00000000 + 0x1f 0x00000000 + 0x00 0xfffffffc>, + <0x43000000 0x04 0x00000000 + 0x1c 0x00000000 + 0x03 0x00000000>; + + dma-ranges = <0x02000000 0x00 0x00000000 + 0x1f 0x00000000 + 0x00 0x00400000>, + <0x43000000 0x10 0x00000000 + 0x00 0x00000000 + 0x10 0x00000000>; + + status = "disabled"; + }; + + mip0: msi-controller@130000 { + compatible = "brcm,bcm2712-mip"; + reg = <0x00 0x00130000 0x00 0xc0>, + <0xff 0xfffff000 0x00 0x1000>; + msi-controller; + interrupt-controller; + #interrupt-cells = <2>; + msi-ranges = <&gicv2 GIC_SPI 128 IRQ_TYPE_EDGE_RISING 64>; + }; + + mip1: msi-controller@131000 { + compatible = "brcm,bcm2712-mip"; + reg = <0x00 0x00131000 0x00 0xc0>, + <0xff 0xffffe000 0x00 0x1000>; + msi-controller; + interrupt-controller; + #interrupt-cells = <2>; + msi-ranges = <&gicv2 GIC_SPI 255 IRQ_TYPE_EDGE_RISING 8>; + }; + }; + timer { compatible = "arm,armv8-timer"; interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) |
Signature · 1 line
2.35.3
Florian Fainelli
maintainerRe: [PATCH v2 -next 10/11] arm64: dts: broadcom: bcm2712: Add PCIe DT nodes
Quoted 77 lines · Stanimir Varbanov
Add PCIe devicetree nodes, plus needed reset and mip MSI-X controllers.
Signed-off-by Stanimir Varbanov <[email protected]>--- arch/arm64/boot/dts/broadcom/bcm2712.dtsi | 166 ++++++++++++++++++++++ 1 file changed, 166 insertions(+)arch/arm64/boot/dts/broadcom/bcm2712.dtsi +47
-0@@ -192,6 +192,12 @@ soc: soc@107c000000 { #address-cells = <1>; #size-cells = <1>; + pcie_rescal: reset-controller@119500 { + compatible = "brcm,bcm7216-pcie-sata-rescal"; + reg = <0x00119500 0x10>; + #reset-cells = <0>; + }; + sdio1: mmc@fff000 { compatible = "brcm,bcm2712-sdhci", "brcm,sdhci-brcmstb";@@ -204,6 +210,12 @@ sdio1: mmc@fff000 { mmc-ddr-3_3v; }; + bcm_reset: reset-controller@1504318 { + compatible = "brcm,brcmstb-reset";> + reg = <0x01504318 0x30>; + #reset-cells = <1>; + }; + system_timer: timer@7c003000 { compatible = "brcm,bcm2835-system-timer"; reg = <0x7c003000 0x1000>;@@ -267,6 +279,160 @@ gicv2: interrupt-controller@7fff9000 { }; }; + axi@1000000000 { + compatible = "simple-bus"; + #address-cells = <2>; + #size-cells = <2>; + + ranges = <0x00 0x00000000 0x10 0x00000000 0x01 0x00000000>, + <0x14 0x00000000 0x14 0x00000000 0x04 0x00000000>, + <0x18 0x00000000 0x18 0x00000000 0x04 0x00000000>, + <0x1c 0x00000000 0x1c 0x00000000 0x04 0x00000000>; + + dma-ranges = <0x00 0x00000000 0x00 0x00000000 0x10 0x00000000>, + <0x14 0x00000000 0x14 0x00000000 0x04 0x00000000>, + <0x18 0x00000000 0x18 0x00000000 0x04 0x00000000>, + <0x1c 0x00000000 0x1c 0x00000000 0x04 0x00000000>; + + pcie0: pcie@100000 { + compatible = "brcm,bcm2712-pcie"; + reg = <0x00 0x00100000 0x00 0x9310>; + device_type = "pci"; + linux,pci-domain = <0>; + max-link-speed = <2>; + bus-range = <0x00 0xff>; + num-lanes = <1>; + #address-cells = <3>; + #interrupt-cells = <1>; + #size-cells = <2>; + interrupt-parent = <&gicv2>; + interrupts = <GIC_SPI 213 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 214 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "pcie", "msi"; + interrupt-map-mask = <0x0 0x0 0x0 0x7>; + interrupt-map = <0 0 0 1 &gicv2 GIC_SPI 209 IRQ_TYPE_LEVEL_HIGH>, + <0 0 0 2 &gicv2 GIC_SPI 210 IRQ_TYPE_LEVEL_HIGH>, + <0 0 0 3 &gicv2 GIC_SPI 211 IRQ_TYPE_LEVEL_HIGH>, + <0 0 0 4 &gicv2 GIC_SPI 212 IRQ_TYPE_LEVEL_HIGH>; + resets = <&bcm_reset 42>, <&pcie_rescal>;
arch/arm64/boot/dts/broadcom/bcm2712.dtsi gicv2: interrupt-controller@7fff9000 { · line 327
Quoted 10 lines
arch/arm64/boot/dts/broadcom/bcm2712.dtsi +10
-0+ reset-names = "bridge", "rescal"; + msi-controller; + msi-parent = <&pcie0>; + + ranges = <0x02000000 0x00 0x00000000 + 0x17 0x00000000 + 0x00 0xfffffffc>, + <0x43000000 0x04 0x00000000 + 0x14 0x00000000 + 0x3 0x00000000>;
Maybe a comment would help in figuring out what these ranges describe, and we could probably do a single line cell:
arch/arm64/boot/dts/broadcom/bcm2712.dtsi gicv2: interrupt-controller@7fff9000 { · line 329
Quoted 2 lines
arch/arm64/boot/dts/broadcom/bcm2712.dtsi +2
-0+ + dma-ranges = <0x43000000 0x10 0x00000000
Likewise
arch/arm64/boot/dts/broadcom/bcm2712.dtsi gicv2: interrupt-controller@7fff9000 { · line 333
Quoted 4 lines
arch/arm64/boot/dts/broadcom/bcm2712.dtsi +4
-0+ 0x00 0x00000000 + 0x10 0x00000000>; + + status = "disabled";
Other than that, this LGTM, assume the dt-bindings maintainer are also OK with that.
Signature · 1 line
Florian
PATCH v2 11/11 arm64: dts: broadcom: bcm2712-rpi-5-b: Enable PCIe DT nodes
In reply to Stanimir VarbanovEnable pcie1 and pcie2 DT nodes. Pcie1 is used for the extension connector and pcie2 is used for RP1 south-bridge.
--- arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts +8 -0
@@ -62,3 +62,11 @@ &sdio1 { sd-uhs-ddr50; sd-uhs-sdr104; }; + +&pcie1 { + status = "okay"; +}; + +&pcie2 { + status = "okay"; +};
Signature · 1 line
2.35.3
Rob Herring (Arm)
maintainerQuoted 53 lines · Stanimir Varbanov
Hello,
Here is a v2 of adding PCIe support for bcm2712 (RPi5), the fisrt version can be found at [1].
v2 is based on linux-next plus latest changes in pcie-brcmstb driver [2]. The changes recently made by Jim leaded to a simplified patchset for bcm2712 enablement coparing with previous version of this series.
Noticeable changes are:
- Use of msi-range property in the MIP MSI-X controller and DT which make possible to avoid few private DT properties. The other noticeable change is moving of msi-pci-addr private property to a second 'reg' region. I'll appreciate comments on this.
- Now the PCIe DT nodes are on separate axi{} simple-bus because adding it on soc{} adds too much churn in the node (Florian).
- Added 'quirks' field in
pcie_cfg_datato work around an issue (hw bug?) withbridge_reseton bcm2712 SoC.regards,
~Stan[1] https://patchwork.kernel.org/project/linux-pci/cover/[email protected]/
[2] https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git/log/?h=controller/brcmstbStanimir Varbanov (11):
dt-bindings: interrupt-controller: Add bcm2712 MSI-X DT bindings
dt-bindings: PCI: brcmstb: Update bindings for PCIe on bcm2712
irqchip: mip: Add Broadcom bcm2712 MSI-X interrupt controller
PCI: brcmstb: Expand inbound size calculation helper
PCI: brcmstb: Restore CRS in RootCtl afterprstn_n
PCI: brcmstb: Enable external MSI-X if available
PCI: brcmstb: Avoid turn off of bridge reset
PCI: brcmstb: Add bcm2712 support
PCI: brcmstb: Reuse config structure
arm64: dts: broadcom: bcm2712: Add PCIe DT nodes
arm64: dts: broadcom: bcm2712-rpi-5-b: Enable PCIe DT nodes.../brcm,bcm2712-msix.yaml | 69 ++++ .../bindings/pci/brcm,stb-pcie.yaml | 5 +- .../boot/dts/broadcom/bcm2712-rpi-5-b.dts | 8 + arch/arm64/boot/dts/broadcom/bcm2712.dtsi | 166 ++++++++++ drivers/irqchip/Kconfig | 12 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-bcm2712-mip.c | 310 ++++++++++++++++++ drivers/pci/controller/pcie-brcmstb.c | 172 +++++++--- 8 files changed, 694 insertions(+), 49 deletions(-) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/brcm,bcm2712-msix.yaml create mode 100644 drivers/irqchip/irq-bcm2712-mip.c
Quoted 5 lines
--
2.35.3
My bot found new DTB warnings on the .dts files added or changed in this series.
Some warnings may be from an existing SoC .dtsi. Or perhaps the warnings are fixed by another series. Ultimately, it is up to the platform maintainer whether these warnings are acceptable or not. No need to reply unless the platform maintainer has comments.
If you already ran DT checks and didn't see these error(s), then make sure dt-schema is up to date:
pip3 install dtschema --upgrade
New warnings running 'make CHECK_DTBS=y broadcom/bcm2712-rpi-5-b.dtb' for [email protected]:
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: pcie@100000: resets: [[12, 42], [13]] is too short
from schema $id: http://devicetree.org/schemas/pci/brcm,stb-pcie.yaml#arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: pcie@100000: reset-names:0: 'rescal' was expected
from schema $id: http://devicetree.org/schemas/pci/brcm,stb-pcie.yaml#arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: pcie@100000: reset-names:1: 'bridge' was expected
from schema $id: http://devicetree.org/schemas/pci/brcm,stb-pcie.yaml#arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: pcie@100000: reset-names: ['bridge', 'rescal'] is too short
from schema $id: http://devicetree.org/schemas/pci/brcm,stb-pcie.yaml#arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: pcie@110000: 'msi-controller' is a required property
from schema $id: http://devicetree.org/schemas/pci/brcm,stb-pcie.yaml#arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: pcie@110000: resets: [[12, 43], [13]] is too short
from schema $id: http://devicetree.org/schemas/pci/brcm,stb-pcie.yaml#arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: pcie@110000: reset-names:0: 'rescal' was expected
from schema $id: http://devicetree.org/schemas/pci/brcm,stb-pcie.yaml#arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: pcie@110000: reset-names:1: 'bridge' was expected
from schema $id: http://devicetree.org/schemas/pci/brcm,stb-pcie.yaml#arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: pcie@110000: reset-names: ['bridge', 'rescal'] is too short
from schema $id: http://devicetree.org/schemas/pci/brcm,stb-pcie.yaml#arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: pcie@120000: 'msi-controller' is a required property
from schema $id: http://devicetree.org/schemas/pci/brcm,stb-pcie.yaml#arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: pcie@120000: resets: [[12, 44], [13]] is too short
from schema $id: http://devicetree.org/schemas/pci/brcm,stb-pcie.yaml#arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: pcie@120000: reset-names:0: 'rescal' was expected
from schema $id: http://devicetree.org/schemas/pci/brcm,stb-pcie.yaml#arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: pcie@120000: reset-names:1: 'bridge' was expected
from schema $id: http://devicetree.org/schemas/pci/brcm,stb-pcie.yaml#arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: pcie@120000: reset-names: ['bridge', 'rescal'] is too short
from schema $id: http://devicetree.org/schemas/pci/brcm,stb-pcie.yaml#