Skip to content

Commit f28b3c9

Browse files
nxpfranklibjorn-helgaas
authored andcommitted
PCI: dwc: ep: Use devicetree 'reg[addr_space]' to derive CPU -> ATU addr offset
Endpoint ┌───────────────────────────────────────────────┐ │ pcie-ep@5f010000 │ │ ┌────────────────┐│ │ │ Endpoint ││ │ │ PCIe ││ │ │ Controller ││ │ bus@5f000000 │ ┌────────► │ ┌──────────┐ │ │ ││dynamically │ │ │ Outbound Transfer │ ││allocated │┌─────┐ │ Bus ┼─────►│ ATU ───────┘ ││PCI Addr ││ │ │ Fabric │Bus │ ││ ││ CPU ├───►│ │Addr │ ││ ││ │CPU │ │0x8000_0000 ││ │└─────┘Addr└──────────┘ │ ││ │ 0x7000_0000 └────────────────┘│ └───────────────────────────────────────────────┘ bus@5f000000 { compatible = "simple-bus"; ranges = <0x80000000 0x0 0x70000000 0x10000000>; pcie-ep@5f010000 { reg = <0x80000000 0x10000000>; reg-names ="addr_space"; ... }; ... }; In the diagram above, CPU writes data to outbound window address 0x7000_0000, and the bus fabric maps it to 0x8000_0000. The ATU uses bus address 0x8000_0000 as input address and maps to some PCI address dynamically allocated by a PCI device driver on the host side. The pcie-ep@5f010000 'reg[addr_space]' is the parent bus address, which is the input of PCIe controller, including the ATU. Set parent_bus_offset, the offset from the CPU address to the PCIe controller input address using dw_pcie_init_parent_bus_offset(). The parent_bus_offset is not used yet, so no functional change intended. [bhelgaas: commit log] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Frank Li <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent d7ae671 commit f28b3c9

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

drivers/pci/controller/dwc/pcie-designware-ep.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,13 @@ static int dw_pcie_ep_get_resources(struct dw_pcie_ep *ep)
904904
ep->phys_base = res->start;
905905
ep->addr_size = resource_size(res);
906906

907+
/*
908+
* artpec6_pcie_cpu_addr_fixup() uses ep->phys_base, so call
909+
* dw_pcie_parent_bus_offset() after setting ep->phys_base.
910+
*/
911+
pci->parent_bus_offset = dw_pcie_parent_bus_offset(pci, "addr_space",
912+
ep->phys_base);
913+
907914
ret = of_property_read_u8(np, "max-functions", &epc->max_functions);
908915
if (ret < 0)
909916
epc->max_functions = 1;

0 commit comments

Comments
 (0)