linux/drivers/pci/controller
Jim Quinlan 52ded9e4f0 PCI: brcmstb: Set additional internal memory DMA viewport sizes
The Raspberry Pi (RPI) is currently the only chip using this driver
(pcie-brcmstb.c).  There, only one memory controller is used, without an
extension region, and the SCB0 viewport size is set to the size of the
first and only dma-range region.  Other BrcmSTB SOCs have more complicated
memory configurations that require setting additional viewport sizes.

BrcmSTB PCIe controllers are intimately connected to the memory
controller(s) on the SOC.  The SOC may have one to three memory
controllers; they are indicated by the term SCBi.  Each controller has a
base region and an optional extension region.  In physical memory, the base
and extension regions of a controller are not adjacent, but in PCIe-space
they are.

There is a "viewport" for each memory controller that allows DMA from
endpoint devices.  Each viewport's size must be set to a power of two, and
that size must be equal to or larger than the amount of memory each
controller supports which is the sum of base region and its optional
extension.  Further, the 1-3 viewports are also adjacent in PCIe-space.

Unfortunately the viewport sizes cannot be ascertained from the
"dma-ranges" property so they have their own property, "brcm,scb-sizes".
This is because dma-range information does not indicate what memory
controller it is associated.  For example, consider the following case
where the size of one dma-range is 2GB and the second dma-range is 1GB:

    /* Case 1: SCB0 size set to 4GB */
    dma-range0: 2GB (from memc0-base)
    dma-range1: 1GB (from memc0-extension)

    /* Case 2: SCB0 size set to 2GB, SCB1 size set to 1GB */
    dma-range0: 2GB (from memc0-base)
    dma-range1: 1GB (from memc0-extension)

By just looking at the dma-ranges information, one cannot tell which
situation applies. That is why an additional property is needed.  Its
length indicates the number of memory controllers being used and each value
indicates the viewport size.

Note that the RPI DT does not have a "brcm,scb-sizes" property value,
as it is assumed that it only requires one memory controller and no
extension.  So the optional use of "brcm,scb-sizes" will be backwards
compatible.

One last layer of complexity exists: all of the viewports sizes must be
added and rounded up to a power of two to determine what the "BAR" size is.
Further, an offset must be given that indicates the base PCIe address of
this "BAR".  The use of the term BAR is typically associated with endpoint
devices, and the term is used here because the PCIe HW may be used as an RC
or an EP.  In the former case, all of the system memory appears in a single
"BAR" region in PCIe memory.  As it turns out, BrcmSTB PCIe HW is rarely
used in the EP role and its system of mapping memory is an artifact that
requires multiple dma-ranges regions.

Link: https://lore.kernel.org/r/20200911175232.19016-8-james.quinlan@broadcom.com
Signed-off-by: Jim Quinlan <james.quinlan@broadcom.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
2020-10-02 12:40:40 +01:00
..
cadence Merge branch 'pci/host-probe-refactor' 2020-08-05 18:24:21 -05:00
dwc Merge branch 'pci/irq-error' 2020-08-05 18:24:22 -05:00
mobiveil Merge branch 'pci/irq-error' 2020-08-05 18:24:22 -05:00
Kconfig PCI: brcmstb: PCIE_BRCMSTB depends on ARCH_BRCMSTB 2020-09-17 12:30:38 +01:00
Makefile PCI: xilinx-cpm: Add Versal CPM Root Port driver 2020-08-05 17:09:15 -05:00
pci-aardvark.c Merge branch 'pci/host-probe-refactor' 2020-08-05 18:24:21 -05:00
pci-ftpci100.c PCI: Set bridge map_irq and swizzle_irq to default functions 2020-08-04 16:36:30 +01:00
pci-host-common.c PCI: Set bridge map_irq and swizzle_irq to default functions 2020-08-04 16:36:30 +01:00
pci-host-generic.c PCI: host-generic: Eliminate pci_host_common_probe wrappers 2020-05-07 09:29:43 +01:00
pci-hyperv-intf.c PCI: hv: Add a Hyper-V PCI interface driver for software backchannel interface 2019-08-22 00:25:12 -07:00
pci-hyperv.c PCI: hv: Make some functions static 2020-07-28 11:22:17 +01:00
pci-loongson.c Merge branch 'pci/host-probe-refactor' 2020-08-05 18:24:21 -05:00
pci-mvebu.c Merge branch 'pci/host-probe-refactor' 2020-08-05 18:24:21 -05:00
pci-rcar-gen2.c PCI: Move DT resource setup into devm_pci_alloc_host_bridge() 2020-08-04 16:36:30 +01:00
pci-tegra.c Merge branch 'pci/irq-error' 2020-08-05 18:24:22 -05:00
pci-thunder-ecam.c PCI: host-generic: Eliminate pci_host_common_probe wrappers 2020-05-07 09:29:43 +01:00
pci-thunder-pem.c PCI: host-generic: Eliminate pci_host_common_probe wrappers 2020-05-07 09:29:43 +01:00
pci-v3-semi.c Merge branch 'pci/irq-error' 2020-08-05 18:24:22 -05:00
pci-versatile.c PCI: Set bridge map_irq and swizzle_irq to default functions 2020-08-04 16:36:30 +01:00
pci-xgene-msi.c PCI: Remove dev_err() when handing an error from platform_get_irq() 2020-08-03 09:26:03 -05:00
pci-xgene.c PCI: Set bridge map_irq and swizzle_irq to default functions 2020-08-04 16:36:30 +01:00
pcie-altera-msi.c Merge branch 'pci/irq-error' 2020-08-05 18:24:22 -05:00
pcie-altera.c Merge branch 'pci/irq-error' 2020-08-05 18:24:22 -05:00
pcie-brcmstb.c PCI: brcmstb: Set additional internal memory DMA viewport sizes 2020-10-02 12:40:40 +01:00
pcie-iproc-bcma.c
pcie-iproc-msi.c PCI: iproc-msi: Fix __iomem annotation in decode_msi_hwirq() 2019-10-17 11:01:24 +01:00
pcie-iproc-platform.c PCI: Set bridge map_irq and swizzle_irq to default functions 2020-08-04 16:36:30 +01:00
pcie-iproc.c PCI: Set bridge map_irq and swizzle_irq to default functions 2020-08-04 16:36:30 +01:00
pcie-iproc.h PCI: iproc: Use pci_host_probe() to register host 2020-07-10 11:50:23 +01:00
pcie-mediatek.c PCI: Set bridge map_irq and swizzle_irq to default functions 2020-08-04 16:36:30 +01:00
pcie-rcar-ep.c PCI: rcar: Add endpoint mode support 2020-05-22 12:35:32 +01:00
pcie-rcar-host.c Merge branch 'pci/host-probe-refactor' 2020-08-05 18:24:21 -05:00
pcie-rcar.c PCI: rcar: Fix calculating mask for PCIEPAMR register 2020-05-11 11:29:48 +01:00
pcie-rcar.h PCI: rcar: Add endpoint mode support 2020-05-22 12:35:32 +01:00
pcie-rockchip-ep.c PCI: Fix kerneldoc warnings 2020-08-05 18:23:14 -05:00
pcie-rockchip-host.c Merge branch 'pci/irq-error' 2020-08-05 18:24:22 -05:00
pcie-rockchip.c PCI: controller: Convert to devm_platform_ioremap_resource_byname() 2020-07-10 11:50:23 +01:00
pcie-rockchip.h PCI: rockchip: Use pci_is_root_bus() to check if bus is root bus 2020-07-23 11:20:50 +01:00
pcie-tango.c PCI: Remove dev_err() when handing an error from platform_get_irq() 2020-08-03 09:26:03 -05:00
pcie-xilinx-cpm.c Merge branch 'pci/host-probe-refactor' 2020-08-05 18:24:21 -05:00
pcie-xilinx-nwl.c Merge branch 'pci/irq-error' 2020-08-05 18:24:22 -05:00
pcie-xilinx.c PCI: Set bridge map_irq and swizzle_irq to default functions 2020-08-04 16:36:30 +01:00
vmd.c pci-v5.9-changes 2020-08-07 18:48:15 -07:00