mirror of
https://github.com/torvalds/linux.git
synced 2024-12-06 11:01:43 +00:00
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/20221113191301.5526-19-Sergey.Semin@baikalelectronics.ru Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru> Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org> Reviewed-by: Rob Herring <robh@kernel.org> Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
This commit is contained in:
parent
ef8c58877f
commit
9f67ecdd95
@ -628,26 +628,21 @@ static void dw_pcie_link_set_max_speed(struct dw_pcie *pci, u32 link_gen)
|
||||
|
||||
}
|
||||
|
||||
static bool dw_pcie_iatu_unroll_enabled(struct dw_pcie *pci)
|
||||
{
|
||||
u32 val;
|
||||
|
||||
val = dw_pcie_readl_dbi(pci, PCIE_ATU_VIEWPORT);
|
||||
if (val == 0xffffffff)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void dw_pcie_iatu_detect_regions(struct dw_pcie *pci)
|
||||
void dw_pcie_iatu_detect(struct dw_pcie *pci)
|
||||
{
|
||||
int max_region, ob, ib;
|
||||
u32 val, min, dir;
|
||||
u64 max;
|
||||
|
||||
if (dw_pcie_cap_is(pci, IATU_UNROLL)) {
|
||||
val = dw_pcie_readl_dbi(pci, PCIE_ATU_VIEWPORT);
|
||||
if (val == 0xFFFFFFFF) {
|
||||
dw_pcie_cap_set(pci, IATU_UNROLL);
|
||||
|
||||
max_region = min((int)pci->atu_size / 512, 256);
|
||||
} else {
|
||||
pci->atu_base = pci->dbi_base + PCIE_ATU_VIEWPORT_BASE;
|
||||
pci->atu_size = PCIE_ATU_VIEWPORT_SIZE;
|
||||
|
||||
dw_pcie_writel_dbi(pci, PCIE_ATU_VIEWPORT, 0xFF);
|
||||
max_region = dw_pcie_readl_dbi(pci, PCIE_ATU_VIEWPORT) + 1;
|
||||
}
|
||||
@ -689,23 +684,9 @@ static void dw_pcie_iatu_detect_regions(struct dw_pcie *pci)
|
||||
pci->num_ib_windows = ib;
|
||||
pci->region_align = 1 << fls(min);
|
||||
pci->region_limit = (max << 32) | (SZ_4G - 1);
|
||||
}
|
||||
|
||||
void dw_pcie_iatu_detect(struct dw_pcie *pci)
|
||||
{
|
||||
if (dw_pcie_iatu_unroll_enabled(pci)) {
|
||||
dw_pcie_cap_set(pci, IATU_UNROLL);
|
||||
} else {
|
||||
pci->atu_base = pci->dbi_base + PCIE_ATU_VIEWPORT_BASE;
|
||||
pci->atu_size = PCIE_ATU_VIEWPORT_SIZE;
|
||||
}
|
||||
|
||||
dw_pcie_iatu_detect_regions(pci);
|
||||
|
||||
dev_info(pci->dev, "iATU unroll: %s\n", dw_pcie_cap_is(pci, IATU_UNROLL) ?
|
||||
"enabled" : "disabled");
|
||||
|
||||
dev_info(pci->dev, "iATU regions: %u ob, %u ib, align %uK, limit %lluG\n",
|
||||
dev_info(pci->dev, "iATU: unroll %s, %u ob, %u ib, align %uK, limit %lluG\n",
|
||||
dw_pcie_cap_is(pci, IATU_UNROLL) ? "T" : "F",
|
||||
pci->num_ob_windows, pci->num_ib_windows,
|
||||
pci->region_align / SZ_1K, (pci->region_limit + 1) / SZ_1G);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user