Commit 9f352f0e authored by Jason Gunthorpe's avatar Jason Gunthorpe Committed by Jason Cooper

PCI: mvebu: Dynamically detect if the PEX link is up to enable hot plug

Otherwise hotplugging the PEX doesn't work at all since the driver
detects the link state at probe time. Simply replacing the two tests
of haslink with a register read is enough to fix it.

Tested on kirkwood with repeated plug/unplug of the link partner.
Signed-off-by: default avatarJason Gunthorpe <jgunthorpe@obsidianresearch.com>
Acked-by: default avatarThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Tested-by: default avatarThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: default avatarJason Cooper <jason@lakedaemon.net>
parent 96ae0b54
...@@ -120,7 +120,6 @@ struct mvebu_pcie_port { ...@@ -120,7 +120,6 @@ struct mvebu_pcie_port {
char *name; char *name;
void __iomem *base; void __iomem *base;
spinlock_t conf_lock; spinlock_t conf_lock;
int haslink;
u32 port; u32 port;
u32 lane; u32 lane;
int devfn; int devfn;
...@@ -560,7 +559,7 @@ static int mvebu_pcie_wr_conf(struct pci_bus *bus, u32 devfn, ...@@ -560,7 +559,7 @@ static int mvebu_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
if (bus->number == 0) if (bus->number == 0)
return mvebu_sw_pci_bridge_write(port, where, size, val); return mvebu_sw_pci_bridge_write(port, where, size, val);
if (!port->haslink) if (!mvebu_pcie_link_up(port))
return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_DEVICE_NOT_FOUND;
/* /*
...@@ -602,7 +601,7 @@ static int mvebu_pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where, ...@@ -602,7 +601,7 @@ static int mvebu_pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where,
if (bus->number == 0) if (bus->number == 0)
return mvebu_sw_pci_bridge_read(port, where, size, val); return mvebu_sw_pci_bridge_read(port, where, size, val);
if (!port->haslink) { if (!mvebu_pcie_link_up(port)) {
*val = 0xffffffff; *val = 0xffffffff;
return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_DEVICE_NOT_FOUND;
} }
...@@ -950,14 +949,12 @@ static int mvebu_pcie_probe(struct platform_device *pdev) ...@@ -950,14 +949,12 @@ static int mvebu_pcie_probe(struct platform_device *pdev)
mvebu_pcie_set_local_dev_nr(port, 1); mvebu_pcie_set_local_dev_nr(port, 1);
if (mvebu_pcie_link_up(port)) { port->clk = of_clk_get_by_name(child, NULL);
port->haslink = 1; if (IS_ERR(port->clk)) {
dev_info(&pdev->dev, "PCIe%d.%d: link up\n", dev_err(&pdev->dev, "PCIe%d.%d: cannot get clock\n",
port->port, port->lane); port->port, port->lane);
} else { iounmap(port->base);
port->haslink = 0; continue;
dev_info(&pdev->dev, "PCIe%d.%d: link down\n",
port->port, port->lane);
} }
port->dn = child; port->dn = child;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment