Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions drivers/pci/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,6 @@ void __weak pcibios_bus_add_device(struct pci_dev *pdev) { }
void pci_bus_add_device(struct pci_dev *dev)
{
struct device_node *dn = dev->dev.of_node;
struct platform_device *pdev;

/*
* Can not put in pci_device_add yet because resources
Expand All @@ -357,24 +356,6 @@ void pci_bus_add_device(struct pci_dev *dev)
pci_proc_attach_device(dev);
pci_bridge_d3_update(dev);

/*
* If the PCI device is associated with a pwrctrl device with a
* power supply, create a device link between the PCI device and
* pwrctrl device. This ensures that pwrctrl drivers are probed
* before PCI client drivers.
*/
pdev = of_find_device_by_node(dn);
if (pdev) {
if (of_pci_supply_present(dn)) {
if (!device_link_add(&dev->dev, &pdev->dev,
DL_FLAG_AUTOREMOVE_CONSUMER)) {
pci_err(dev, "failed to add device link to power control device %s\n",
pdev->name);
}
}
put_device(&pdev->dev);
}

if (!dn || of_device_is_available(dn))
pci_dev_allow_binding(dev);

Expand Down
24 changes: 22 additions & 2 deletions drivers/pci/controller/dwc/pcie-qcom.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <linux/of_pci.h>
#include <linux/pci.h>
#include <linux/pci-ecam.h>
#include <linux/pci-pwrctrl.h>
#include <linux/pm_opp.h>
#include <linux/pm_runtime.h>
#include <linux/platform_device.h>
Expand Down Expand Up @@ -1328,10 +1329,18 @@ static int qcom_pcie_host_init(struct dw_pcie_rp *pp)
if (ret)
goto err_deinit;

ret = pci_pwrctrl_create_devices(pci->dev);
if (ret)
goto err_disable_phy;

ret = pci_pwrctrl_power_on_devices(pci->dev);
if (ret)
goto err_pwrctrl_destroy;

if (pcie->cfg->ops->post_init) {
ret = pcie->cfg->ops->post_init(pcie);
if (ret)
goto err_disable_phy;
goto err_pwrctrl_power_off;
}

qcom_ep_reset_deassert(pcie);
Expand All @@ -1346,6 +1355,11 @@ static int qcom_pcie_host_init(struct dw_pcie_rp *pp)

err_assert_reset:
qcom_ep_reset_assert(pcie);
err_pwrctrl_power_off:
pci_pwrctrl_power_off_devices(pci->dev);
err_pwrctrl_destroy:
if (ret != -EPROBE_DEFER)
pci_pwrctrl_destroy_devices(pci->dev);
err_disable_phy:
qcom_pcie_phy_power_off(pcie);
err_deinit:
Expand All @@ -1360,6 +1374,12 @@ static void qcom_pcie_host_deinit(struct dw_pcie_rp *pp)
struct qcom_pcie *pcie = to_qcom_pcie(pci);

qcom_ep_reset_assert(pcie);

/*
* No need to destroy pwrctrl devices as this function only gets called
* during system suspend as of now.
*/
pci_pwrctrl_power_off_devices(pci->dev);
qcom_pcie_phy_power_off(pcie);
pcie->cfg->ops->deinit(pcie);
}
Expand Down Expand Up @@ -1968,7 +1988,7 @@ static int qcom_pcie_probe(struct platform_device *pdev)

ret = dw_pcie_host_init(pp);
if (ret) {
dev_err(dev, "cannot initialize host\n");
dev_err_probe(dev, ret, "cannot initialize host\n");
goto err_phy_exit;
}

Expand Down
1 change: 1 addition & 0 deletions drivers/pci/of.c
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,7 @@ bool of_pci_supply_present(struct device_node *np)

return false;
}
EXPORT_SYMBOL_GPL(of_pci_supply_present);

#endif /* CONFIG_PCI */

Expand Down
59 changes: 0 additions & 59 deletions drivers/pci/probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -2533,56 +2533,6 @@ bool pci_bus_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *l,
}
EXPORT_SYMBOL(pci_bus_read_dev_vendor_id);

#if IS_ENABLED(CONFIG_PCI_PWRCTRL)
static struct platform_device *pci_pwrctrl_create_device(struct pci_bus *bus, int devfn)
{
struct pci_host_bridge *host = pci_find_host_bridge(bus);
struct platform_device *pdev;
struct device_node *np;

np = of_pci_find_child_device(dev_of_node(&bus->dev), devfn);
if (!np)
return NULL;

pdev = of_find_device_by_node(np);
if (pdev) {
put_device(&pdev->dev);
goto err_put_of_node;
}

/*
* First check whether the pwrctrl device really needs to be created or
* not. This is decided based on at least one of the power supplies
* being defined in the devicetree node of the device.
*/
if (!of_pci_supply_present(np)) {
pr_debug("PCI/pwrctrl: Skipping OF node: %s\n", np->name);
goto err_put_of_node;
}

/* Now create the pwrctrl device */
pdev = of_platform_device_create(np, NULL, &host->dev);
if (!pdev) {
pr_err("PCI/pwrctrl: Failed to create pwrctrl device for node: %s\n", np->name);
goto err_put_of_node;
}

of_node_put(np);

return pdev;

err_put_of_node:
of_node_put(np);

return NULL;
}
#else
static struct platform_device *pci_pwrctrl_create_device(struct pci_bus *bus, int devfn)
{
return NULL;
}
#endif

/*
* Read the config data for a PCI device, sanity-check it,
* and fill in the dev structure.
Expand All @@ -2592,15 +2542,6 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn)
struct pci_dev *dev;
u32 l;

/*
* Create pwrctrl device (if required) for the PCI device to handle the
* power state. If the pwrctrl device is created, then skip scanning
* further as the pwrctrl core will rescan the bus after powering on
* the device.
*/
if (pci_pwrctrl_create_device(bus, devfn))
return NULL;

if (!pci_bus_read_dev_vendor_id(bus, devfn, &l, 60*1000))
return NULL;

Expand Down
Loading