PCI: mediatek: Use pci_parse_request_of_pci_ranges()
Convert Mediatek host bridge to use the common pci_parse_request_of_pci_ranges(). Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Reviewed-by: Andrew Murray <andrew.murray@arm.com> Cc: Ryder Lee <ryder.lee@mediatek.com> Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Cc: Bjorn Helgaas <bhelgaas@google.com> Cc: Matthias Brugger <matthias.bgg@gmail.com> Cc: linux-mediatek@lists.infradead.org
This commit is contained in:
parent
7ef1c871da
commit
8a26f861b8
|
@ -216,7 +216,6 @@ struct mtk_pcie {
|
|||
void __iomem *base;
|
||||
struct clk *free_ck;
|
||||
|
||||
struct resource mem;
|
||||
struct list_head ports;
|
||||
const struct mtk_pcie_soc *soc;
|
||||
unsigned int busnr;
|
||||
|
@ -661,11 +660,19 @@ static int mtk_pcie_setup_irq(struct mtk_pcie_port *port,
|
|||
static int mtk_pcie_startup_port_v2(struct mtk_pcie_port *port)
|
||||
{
|
||||
struct mtk_pcie *pcie = port->pcie;
|
||||
struct resource *mem = &pcie->mem;
|
||||
struct pci_host_bridge *host = pci_host_bridge_from_priv(pcie);
|
||||
struct resource *mem = NULL;
|
||||
struct resource_entry *entry;
|
||||
const struct mtk_pcie_soc *soc = port->pcie->soc;
|
||||
u32 val;
|
||||
int err;
|
||||
|
||||
entry = resource_list_first_type(&host->windows, IORESOURCE_MEM);
|
||||
if (entry)
|
||||
mem = entry->res;
|
||||
if (!mem)
|
||||
return -EINVAL;
|
||||
|
||||
/* MT7622 platforms need to enable LTSSM and ASPM from PCIe subsys */
|
||||
if (pcie->base) {
|
||||
val = readl(pcie->base + PCIE_SYS_CFG_V2);
|
||||
|
@ -1023,39 +1030,15 @@ static int mtk_pcie_setup(struct mtk_pcie *pcie)
|
|||
struct mtk_pcie_port *port, *tmp;
|
||||
struct pci_host_bridge *host = pci_host_bridge_from_priv(pcie);
|
||||
struct list_head *windows = &host->windows;
|
||||
struct resource_entry *win, *tmp_win;
|
||||
resource_size_t io_base;
|
||||
struct resource *bus;
|
||||
int err;
|
||||
|
||||
err = devm_of_pci_get_host_bridge_resources(dev, 0, 0xff,
|
||||
windows, &io_base);
|
||||
err = pci_parse_request_of_pci_ranges(dev, windows,
|
||||
&bus);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = devm_request_pci_bus_resources(dev, windows);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
/* Get the I/O and memory ranges from DT */
|
||||
resource_list_for_each_entry_safe(win, tmp_win, windows) {
|
||||
switch (resource_type(win->res)) {
|
||||
case IORESOURCE_IO:
|
||||
err = devm_pci_remap_iospace(dev, win->res, io_base);
|
||||
if (err) {
|
||||
dev_warn(dev, "error %d: failed to map resource %pR\n",
|
||||
err, win->res);
|
||||
resource_list_destroy_entry(win);
|
||||
}
|
||||
break;
|
||||
case IORESOURCE_MEM:
|
||||
memcpy(&pcie->mem, win->res, sizeof(*win->res));
|
||||
pcie->mem.name = "non-prefetchable";
|
||||
break;
|
||||
case IORESOURCE_BUS:
|
||||
pcie->busnr = win->res->start;
|
||||
break;
|
||||
}
|
||||
}
|
||||
pcie->busnr = bus->start;
|
||||
|
||||
for_each_available_child_of_node(node, child) {
|
||||
int slot;
|
||||
|
|
Loading…
Reference in New Issue