diff options
Diffstat (limited to 'drivers/pci/controller/pci-aardvark.c')
| -rw-r--r-- | drivers/pci/controller/pci-aardvark.c | 38 | 
1 files changed, 16 insertions, 22 deletions
| diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 90ff291c24f0..1559f79e63b6 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -195,7 +195,6 @@ struct advk_pcie {  	DECLARE_BITMAP(msi_used, MSI_IRQ_NUM);  	struct mutex msi_used_lock;  	u16 msi_msg; -	int root_bus_nr;  	int link_gen;  	struct pci_bridge_emul bridge;  	struct gpio_desc *reset_gpio; @@ -641,7 +640,14 @@ static void advk_sw_pci_bridge_init(struct advk_pcie *pcie)  static bool advk_pcie_valid_device(struct advk_pcie *pcie, struct pci_bus *bus,  				  int devfn)  { -	if ((bus->number == pcie->root_bus_nr) && PCI_SLOT(devfn) != 0) +	if (pci_is_root_bus(bus) && PCI_SLOT(devfn) != 0) +		return false; + +	/* +	 * If the link goes down after we check for link-up, nothing bad +	 * happens but the config access times out. +	 */ +	if (!pci_is_root_bus(bus) && !advk_pcie_link_up(pcie))  		return false;  	return true; @@ -659,7 +665,7 @@ static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn,  		return PCIBIOS_DEVICE_NOT_FOUND;  	} -	if (bus->number == pcie->root_bus_nr) +	if (pci_is_root_bus(bus))  		return pci_bridge_emul_conf_read(&pcie->bridge, where,  						 size, val); @@ -670,7 +676,7 @@ static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn,  	/* Program the control register */  	reg = advk_readl(pcie, PIO_CTRL);  	reg &= ~PIO_CTRL_TYPE_MASK; -	if (bus->primary ==  pcie->root_bus_nr) +	if (pci_is_root_bus(bus->parent))  		reg |= PCIE_CONFIG_RD_TYPE0;  	else  		reg |= PCIE_CONFIG_RD_TYPE1; @@ -688,8 +694,10 @@ static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn,  	advk_writel(pcie, 1, PIO_START);  	ret = advk_pcie_wait_pio(pcie); -	if (ret < 0) +	if (ret < 0) { +		*val = 0xffffffff;  		return PCIBIOS_SET_FAILED; +	}  	advk_pcie_check_pio_status(pcie); @@ -715,7 +723,7 @@ static int advk_pcie_wr_conf(struct pci_bus *bus, u32 devfn,  	if (!advk_pcie_valid_device(pcie, bus, devfn))  		return PCIBIOS_DEVICE_NOT_FOUND; -	if (bus->number == pcie->root_bus_nr) +	if (pci_is_root_bus(bus))  		return pci_bridge_emul_conf_write(&pcie->bridge, where,  						  size, val); @@ -729,7 +737,7 @@ static int advk_pcie_wr_conf(struct pci_bus *bus, u32 devfn,  	/* Program the control register */  	reg = advk_readl(pcie, PIO_CTRL);  	reg &= ~PIO_CTRL_TYPE_MASK; -	if (bus->primary == pcie->root_bus_nr) +	if (pci_is_root_bus(bus->parent))  		reg |= PCIE_CONFIG_WR_TYPE0;  	else  		reg |= PCIE_CONFIG_WR_TYPE1; @@ -1105,7 +1113,6 @@ static int advk_pcie_probe(struct platform_device *pdev)  {  	struct device *dev = &pdev->dev;  	struct advk_pcie *pcie; -	struct resource *res, *bus;  	struct pci_host_bridge *bridge;  	int ret, irq; @@ -1116,8 +1123,7 @@ static int advk_pcie_probe(struct platform_device *pdev)  	pcie = pci_host_bridge_priv(bridge);  	pcie->pdev = pdev; -	res = platform_get_resource(pdev, IORESOURCE_MEM, 0); -	pcie->base = devm_ioremap_resource(dev, res); +	pcie->base = devm_platform_ioremap_resource(pdev, 0);  	if (IS_ERR(pcie->base))  		return PTR_ERR(pcie->base); @@ -1133,14 +1139,6 @@ static int advk_pcie_probe(struct platform_device *pdev)  		return ret;  	} -	ret = pci_parse_request_of_pci_ranges(dev, &bridge->windows, -					      &bridge->dma_ranges, &bus); -	if (ret) { -		dev_err(dev, "Failed to parse resources\n"); -		return ret; -	} -	pcie->root_bus_nr = bus->start; -  	pcie->reset_gpio = devm_gpiod_get_from_of_node(dev, dev->of_node,  						       "reset-gpios", 0,  						       GPIOD_OUT_LOW, @@ -1184,12 +1182,8 @@ static int advk_pcie_probe(struct platform_device *pdev)  		return ret;  	} -	bridge->dev.parent = dev;  	bridge->sysdata = pcie; -	bridge->busnr = 0;  	bridge->ops = &advk_pcie_ops; -	bridge->map_irq = of_irq_parse_and_map_pci; -	bridge->swizzle_irq = pci_common_swizzle;  	ret = pci_host_probe(bridge);  	if (ret < 0) { |