Skip to content

Commit 9f67ecd

Browse files
fancerLorenzo Pieralisi
authored andcommitted
PCI: dwc: Combine iATU detection procedures
Since the iATU CSR region is now retrieved in the DW PCIe resources getter there is no much benefits in the iATU detection procedures splitting up. Therefore let's join the iATU unroll/viewport detection procedure with the rest of the iATU parameters detection code. The resultant method will be as coherent as before, while the redundant functions will be eliminated thus producing more readable code. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Serge Semin <[email protected]> Signed-off-by: Lorenzo Pieralisi <[email protected]> Reviewed-by: Rob Herring <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]>
1 parent ef8c588 commit 9f67ecd

File tree

1 file changed

+10
-29
lines changed

1 file changed

+10
-29
lines changed

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

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -628,26 +628,21 @@ static void dw_pcie_link_set_max_speed(struct dw_pcie *pci, u32 link_gen)
628628

629629
}
630630

631-
static bool dw_pcie_iatu_unroll_enabled(struct dw_pcie *pci)
632-
{
633-
u32 val;
634-
635-
val = dw_pcie_readl_dbi(pci, PCIE_ATU_VIEWPORT);
636-
if (val == 0xffffffff)
637-
return true;
638-
639-
return false;
640-
}
641-
642-
static void dw_pcie_iatu_detect_regions(struct dw_pcie *pci)
631+
void dw_pcie_iatu_detect(struct dw_pcie *pci)
643632
{
644633
int max_region, ob, ib;
645634
u32 val, min, dir;
646635
u64 max;
647636

648-
if (dw_pcie_cap_is(pci, IATU_UNROLL)) {
637+
val = dw_pcie_readl_dbi(pci, PCIE_ATU_VIEWPORT);
638+
if (val == 0xFFFFFFFF) {
639+
dw_pcie_cap_set(pci, IATU_UNROLL);
640+
649641
max_region = min((int)pci->atu_size / 512, 256);
650642
} else {
643+
pci->atu_base = pci->dbi_base + PCIE_ATU_VIEWPORT_BASE;
644+
pci->atu_size = PCIE_ATU_VIEWPORT_SIZE;
645+
651646
dw_pcie_writel_dbi(pci, PCIE_ATU_VIEWPORT, 0xFF);
652647
max_region = dw_pcie_readl_dbi(pci, PCIE_ATU_VIEWPORT) + 1;
653648
}
@@ -689,23 +684,9 @@ static void dw_pcie_iatu_detect_regions(struct dw_pcie *pci)
689684
pci->num_ib_windows = ib;
690685
pci->region_align = 1 << fls(min);
691686
pci->region_limit = (max << 32) | (SZ_4G - 1);
692-
}
693-
694-
void dw_pcie_iatu_detect(struct dw_pcie *pci)
695-
{
696-
if (dw_pcie_iatu_unroll_enabled(pci)) {
697-
dw_pcie_cap_set(pci, IATU_UNROLL);
698-
} else {
699-
pci->atu_base = pci->dbi_base + PCIE_ATU_VIEWPORT_BASE;
700-
pci->atu_size = PCIE_ATU_VIEWPORT_SIZE;
701-
}
702-
703-
dw_pcie_iatu_detect_regions(pci);
704-
705-
dev_info(pci->dev, "iATU unroll: %s\n", dw_pcie_cap_is(pci, IATU_UNROLL) ?
706-
"enabled" : "disabled");
707687

708-
dev_info(pci->dev, "iATU regions: %u ob, %u ib, align %uK, limit %lluG\n",
688+
dev_info(pci->dev, "iATU: unroll %s, %u ob, %u ib, align %uK, limit %lluG\n",
689+
dw_pcie_cap_is(pci, IATU_UNROLL) ? "T" : "F",
709690
pci->num_ob_windows, pci->num_ib_windows,
710691
pci->region_align / SZ_1K, (pci->region_limit + 1) / SZ_1G);
711692
}

0 commit comments

Comments
 (0)