|
@@ -238,7 +238,7 @@ static int cdns_pcie_ep_get_msi(struct pci_epc *epc, u8 fn)
|
|
struct cdns_pcie_ep *ep = epc_get_drvdata(epc);
|
|
struct cdns_pcie_ep *ep = epc_get_drvdata(epc);
|
|
struct cdns_pcie *pcie = &ep->pcie;
|
|
struct cdns_pcie *pcie = &ep->pcie;
|
|
u32 cap = CDNS_PCIE_EP_FUNC_MSI_CAP_OFFSET;
|
|
u32 cap = CDNS_PCIE_EP_FUNC_MSI_CAP_OFFSET;
|
|
- u16 flags, mmc, mme;
|
|
|
|
|
|
+ u16 flags, mme;
|
|
|
|
|
|
/* Validate that the MSI feature is actually enabled. */
|
|
/* Validate that the MSI feature is actually enabled. */
|
|
flags = cdns_pcie_ep_fn_readw(pcie, fn, cap + PCI_MSI_FLAGS);
|
|
flags = cdns_pcie_ep_fn_readw(pcie, fn, cap + PCI_MSI_FLAGS);
|
|
@@ -249,7 +249,6 @@ static int cdns_pcie_ep_get_msi(struct pci_epc *epc, u8 fn)
|
|
* Get the Multiple Message Enable bitfield from the Message Control
|
|
* Get the Multiple Message Enable bitfield from the Message Control
|
|
* register.
|
|
* register.
|
|
*/
|
|
*/
|
|
- mmc = (flags & PCI_MSI_FLAGS_QMASK) >> 1;
|
|
|
|
mme = (flags & PCI_MSI_FLAGS_QSIZE) >> 4;
|
|
mme = (flags & PCI_MSI_FLAGS_QSIZE) >> 4;
|
|
|
|
|
|
return mme;
|
|
return mme;
|
|
@@ -439,6 +438,7 @@ static int cdns_pcie_ep_probe(struct platform_device *pdev)
|
|
struct pci_epc *epc;
|
|
struct pci_epc *epc;
|
|
struct resource *res;
|
|
struct resource *res;
|
|
int ret;
|
|
int ret;
|
|
|
|
+ int phy_count;
|
|
|
|
|
|
ep = devm_kzalloc(dev, sizeof(*ep), GFP_KERNEL);
|
|
ep = devm_kzalloc(dev, sizeof(*ep), GFP_KERNEL);
|
|
if (!ep)
|
|
if (!ep)
|
|
@@ -473,6 +473,12 @@ static int cdns_pcie_ep_probe(struct platform_device *pdev)
|
|
if (!ep->ob_addr)
|
|
if (!ep->ob_addr)
|
|
return -ENOMEM;
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
+ ret = cdns_pcie_init_phy(dev, pcie);
|
|
|
|
+ if (ret) {
|
|
|
|
+ dev_err(dev, "failed to init phy\n");
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
|
|
+ platform_set_drvdata(pdev, pcie);
|
|
pm_runtime_enable(dev);
|
|
pm_runtime_enable(dev);
|
|
ret = pm_runtime_get_sync(dev);
|
|
ret = pm_runtime_get_sync(dev);
|
|
if (ret < 0) {
|
|
if (ret < 0) {
|
|
@@ -521,6 +527,10 @@ static int cdns_pcie_ep_probe(struct platform_device *pdev)
|
|
|
|
|
|
err_get_sync:
|
|
err_get_sync:
|
|
pm_runtime_disable(dev);
|
|
pm_runtime_disable(dev);
|
|
|
|
+ cdns_pcie_disable_phy(pcie);
|
|
|
|
+ phy_count = pcie->phy_count;
|
|
|
|
+ while (phy_count--)
|
|
|
|
+ device_link_del(pcie->link[phy_count]);
|
|
|
|
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
@@ -528,6 +538,7 @@ static int cdns_pcie_ep_probe(struct platform_device *pdev)
|
|
static void cdns_pcie_ep_shutdown(struct platform_device *pdev)
|
|
static void cdns_pcie_ep_shutdown(struct platform_device *pdev)
|
|
{
|
|
{
|
|
struct device *dev = &pdev->dev;
|
|
struct device *dev = &pdev->dev;
|
|
|
|
+ struct cdns_pcie *pcie = dev_get_drvdata(dev);
|
|
int ret;
|
|
int ret;
|
|
|
|
|
|
ret = pm_runtime_put_sync(dev);
|
|
ret = pm_runtime_put_sync(dev);
|
|
@@ -536,13 +547,14 @@ static void cdns_pcie_ep_shutdown(struct platform_device *pdev)
|
|
|
|
|
|
pm_runtime_disable(dev);
|
|
pm_runtime_disable(dev);
|
|
|
|
|
|
- /* The PCIe controller can't be disabled. */
|
|
|
|
|
|
+ cdns_pcie_disable_phy(pcie);
|
|
}
|
|
}
|
|
|
|
|
|
static struct platform_driver cdns_pcie_ep_driver = {
|
|
static struct platform_driver cdns_pcie_ep_driver = {
|
|
.driver = {
|
|
.driver = {
|
|
.name = "cdns-pcie-ep",
|
|
.name = "cdns-pcie-ep",
|
|
.of_match_table = cdns_pcie_ep_of_match,
|
|
.of_match_table = cdns_pcie_ep_of_match,
|
|
|
|
+ .pm = &cdns_pcie_pm_ops,
|
|
},
|
|
},
|
|
.probe = cdns_pcie_ep_probe,
|
|
.probe = cdns_pcie_ep_probe,
|
|
.shutdown = cdns_pcie_ep_shutdown,
|
|
.shutdown = cdns_pcie_ep_shutdown,
|