PCI: intel-gw: Fix ATU base address setup and add optional DT 'atu' region

The ATU base address was set in intel_pcie_host_setup(), which is called
via pp->ops->init(). However, dw_pcie_get_resources() runs before this
callback and sets a default atu_base of 0x300000, which then gets
overwritten by the driver's value of 0xC0000.

But this ordering is broken because atu_base must be set before
dw_pcie_get_resources() runs, not after. So move the atu_base assignment
from intel_pcie_host_setup() to intel_pcie_probe() to fix the
initialization order.

The call stack is:

  intel_pcie_probe
    dw_pcie_host_init
      dw_pcie_host_get_resources
        dw_pcie_get_resources       <- sets atu_base = 0x300000
      pp->ops->init
        intel_pcie_rc_init
          intel_pcie_host_setup     <- was overwriting atu_base here

Additionally, add support for parsing the ATU region from the device tree.
If an 'atu' region is present in DT, the DWC core parses it via
dw_pcie_get_resources() and the driver does not set atu_base explicitly.
If 'atu' is absent, the driver falls back to the hardcoded offset (0xC0000
from DBI base) for backwards compatibility, with a warning to the user.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
[mani: commit log]
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20260417-pcie-intel-gw-v5-6-0a2b933fe04f@dev.tdt.de
This commit is contained in:
Florian Eckert 2026-04-17 10:35:50 +02:00 committed by Bjorn Helgaas
parent 1eedabe7c6
commit 19f90be49c

View File

@ -310,8 +310,6 @@ static int intel_pcie_host_setup(struct intel_pcie *pcie)
goto clk_err;
}
pci->atu_base = pci->dbi_base + 0xC0000;
ret = phy_init(pcie->phy);
if (ret)
goto phy_err;
@ -395,6 +393,7 @@ static int intel_pcie_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct intel_pcie *pcie;
struct dw_pcie_rp *pp;
struct resource *res;
struct dw_pcie *pci;
int ret;
@ -419,6 +418,32 @@ static int intel_pcie_probe(struct platform_device *pdev)
pci->ops = &intel_pcie_ops;
pp->ops = &intel_pcie_dw_ops;
/*
* If the 'atu' region is not available in the devicetree, use the
* default offset from DBI region for backwards compatibility. The
* 'atu' region should always be specified in the devicetree, as
* this is a hardware-specific address that should not be defined
* in the driver.
*/
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "atu");
if (!res) {
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dbi");
pci->dbi_base = devm_pci_remap_cfg_resource(pci->dev, res);
if (IS_ERR(pci->dbi_base))
return PTR_ERR(pci->dbi_base);
pci->dbi_phys_addr = res->start;
pci->atu_base = devm_ioremap(dev, res->start + 0xC0000, SZ_4K);
if (!pci->atu_base) {
dev_err(dev, "failed to remap ATU space\n");
return -ENOMEM;
}
pci->atu_size = SZ_4K;
pci->atu_phys_addr = res->start + 0xC0000;
dev_warn(dev, "ATU region not specified in DT. Using default offset\n");
}
ret = dw_pcie_host_init(pp);
if (ret) {
dev_err(dev, "Cannot initialize host\n");