Skip to content

Commit cf417e6

Browse files
wensbjorn-helgaas
authored andcommitted
PCI: mediatek-gen3: Move controller setup steps before PERST# control
Setting up the translation windows and enabling MSI involve only the controller, not the link or any downstream device. These can be done before the device is enabled. Move these steps before the existing PERST# control and waiting for the link to come up. This provides a cleaner separation of controller vs device setup. This also allows the later commits that split out PERST# control and add device power control to have cleaner teardown. This change only moves code. No functional change is expected. Suggested-by: Bjorn Helgaas <helgaas@kernel.org> Signed-off-by: Chen-Yu Tsai <wenst@chromium.org> Signed-off-by: Manivannan Sadhasivam <mani@kernel.org> [bhelgaas: commit log] Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> Link: https://patch.msgid.link/20260324052002.4072430-4-wenst@chromium.org
1 parent eddbac0 commit cf417e6

1 file changed

Lines changed: 25 additions & 25 deletions

File tree

drivers/pci/controller/pcie-mediatek-gen3.c

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,31 @@ static int mtk_pcie_startup_port(struct mtk_gen3_pcie *pcie)
464464
val |= PCIE_DISABLE_DVFSRC_VLT_REQ;
465465
writel_relaxed(val, pcie->base + PCIE_MISC_CTRL_REG);
466466

467+
mtk_pcie_enable_msi(pcie);
468+
469+
/* Set PCIe translation windows */
470+
resource_list_for_each_entry(entry, &host->windows) {
471+
struct resource *res = entry->res;
472+
unsigned long type = resource_type(res);
473+
resource_size_t cpu_addr;
474+
resource_size_t pci_addr;
475+
resource_size_t size;
476+
477+
if (type == IORESOURCE_IO)
478+
cpu_addr = pci_pio_to_address(res->start);
479+
else if (type == IORESOURCE_MEM)
480+
cpu_addr = res->start;
481+
else
482+
continue;
483+
484+
pci_addr = res->start - entry->offset;
485+
size = resource_size(res);
486+
err = mtk_pcie_set_trans_table(pcie, cpu_addr, pci_addr, size,
487+
type, &table_index);
488+
if (err)
489+
return err;
490+
}
491+
467492
/*
468493
* Airoha EN7581 has a hw bug asserting/releasing PCIE_PE_RSTB signal
469494
* causing occasional PCIe link down. In order to overcome the issue,
@@ -510,31 +535,6 @@ static int mtk_pcie_startup_port(struct mtk_gen3_pcie *pcie)
510535
return err;
511536
}
512537

513-
mtk_pcie_enable_msi(pcie);
514-
515-
/* Set PCIe translation windows */
516-
resource_list_for_each_entry(entry, &host->windows) {
517-
struct resource *res = entry->res;
518-
unsigned long type = resource_type(res);
519-
resource_size_t cpu_addr;
520-
resource_size_t pci_addr;
521-
resource_size_t size;
522-
523-
if (type == IORESOURCE_IO)
524-
cpu_addr = pci_pio_to_address(res->start);
525-
else if (type == IORESOURCE_MEM)
526-
cpu_addr = res->start;
527-
else
528-
continue;
529-
530-
pci_addr = res->start - entry->offset;
531-
size = resource_size(res);
532-
err = mtk_pcie_set_trans_table(pcie, cpu_addr, pci_addr, size,
533-
type, &table_index);
534-
if (err)
535-
return err;
536-
}
537-
538538
return 0;
539539
}
540540

0 commit comments

Comments
 (0)