Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI: cadence: Add Power Management ops for host and EP

These PM ops will enable/disable the optional PHYs if present. The
AXI link-down register in the host driver is now cleared in
cdns_pci_map_bus() since the link-down bit will be set if the PHY has
been disabled. It is not cleared when enabling the PHY, since the
link will not yet be up (e.g. when an EP controller is connected
back-to-back to the host controller and its PHY is still disabled).

Link: http://lkml.kernel.org/r/1529915453-4633-5-git-send-email-adouglas@cadence.com
Signed-off-by: Alan Douglas <adouglas@cadence.com>
[lorenzo.pieralisi@arm.com: updated commit log]
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>

authored by

Alan Douglas and committed by
Lorenzo Pieralisi
ee12c9ef 82dfbd27

+38
+1
drivers/pci/controller/pcie-cadence-ep.c
··· 555 555 .driver = { 556 556 .name = "cdns-pcie-ep", 557 557 .of_match_table = cdns_pcie_ep_of_match, 558 + .pm = &cdns_pcie_pm_ops, 558 559 }, 559 560 .probe = cdns_pcie_ep_probe, 560 561 .shutdown = cdns_pcie_ep_shutdown,
+3
drivers/pci/controller/pcie-cadence-host.c
··· 61 61 /* Check that the link is up */ 62 62 if (!(cdns_pcie_readl(pcie, CDNS_PCIE_LM_BASE) & 0x1)) 63 63 return NULL; 64 + /* Clear AXI link-down status */ 65 + cdns_pcie_writel(pcie, CDNS_PCIE_AT_LINKDOWN, 0x0); 64 66 65 67 /* Update Output registers for AXI region 0. */ 66 68 addr0 = CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_NBITS(12) | ··· 347 345 .driver = { 348 346 .name = "cdns-pcie-host", 349 347 .of_match_table = cdns_pcie_host_of_match, 348 + .pm = &cdns_pcie_pm_ops, 350 349 }, 351 350 .probe = cdns_pcie_host_probe, 352 351 };
+30
drivers/pci/controller/pcie-cadence.c
··· 217 217 218 218 return ret; 219 219 } 220 + 221 + #ifdef CONFIG_PM_SLEEP 222 + static int cdns_pcie_suspend_noirq(struct device *dev) 223 + { 224 + struct cdns_pcie *pcie = dev_get_drvdata(dev); 225 + 226 + cdns_pcie_disable_phy(pcie); 227 + 228 + return 0; 229 + } 230 + 231 + static int cdns_pcie_resume_noirq(struct device *dev) 232 + { 233 + struct cdns_pcie *pcie = dev_get_drvdata(dev); 234 + int ret; 235 + 236 + ret = cdns_pcie_enable_phy(pcie); 237 + if (ret) { 238 + dev_err(dev, "failed to enable phy\n"); 239 + return ret; 240 + } 241 + 242 + return 0; 243 + } 244 + #endif 245 + 246 + const struct dev_pm_ops cdns_pcie_pm_ops = { 247 + SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(cdns_pcie_suspend_noirq, 248 + cdns_pcie_resume_noirq) 249 + };
+4
drivers/pci/controller/pcie-cadence.h
··· 166 166 #define CDNS_PCIE_AT_IB_RP_BAR_ADDR1(bar) \ 167 167 (CDNS_PCIE_AT_BASE + 0x0804 + (bar) * 0x0008) 168 168 169 + /* AXI link down register */ 170 + #define CDNS_PCIE_AT_LINKDOWN (CDNS_PCIE_AT_BASE + 0x0824) 171 + 169 172 enum cdns_pcie_rp_bar { 170 173 RP_BAR0, 171 174 RP_BAR1, ··· 317 314 void cdns_pcie_disable_phy(struct cdns_pcie *pcie); 318 315 int cdns_pcie_enable_phy(struct cdns_pcie *pcie); 319 316 int cdns_pcie_init_phy(struct device *dev, struct cdns_pcie *pcie); 317 + extern const struct dev_pm_ops cdns_pcie_pm_ops; 320 318 321 319 #endif /* _PCIE_CADENCE_H */