From d1fcbc345b82cd86e6c288b984ce2da0004eaf1d Mon Sep 17 00:00:00 2001 From: Richard Zhu Date: Thu, 28 Nov 2019 16:44:07 +0800 Subject: LF-128 PCI: imx: turn off the clocks and regulators when link is down To save power consumption, disable pcie clocks and regulators when pcie link is down. Signed-off-by: Richard Zhu Reviewed-by: Fugang Duan --- drivers/pci/controller/dwc/pci-imx6.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index 54ec58135784..f43bfd6090ce 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -1472,6 +1472,14 @@ err_reset_phy: dw_pcie_readl_dbi(pci, PCIE_PORT_DEBUG0), dw_pcie_readl_dbi(pci, PCIE_PORT_DEBUG1)); imx6_pcie_reset_phy(imx6_pcie); + if (!IS_ENABLED(CONFIG_PCI_IMX6_COMPLIANCE_TEST)) { + imx6_pcie_clk_disable(imx6_pcie); + if (imx6_pcie->vpcie != NULL) + regulator_disable(imx6_pcie->vpcie); + if (imx6_pcie->epdev_on != NULL) + regulator_disable(imx6_pcie->epdev_on); + } + return ret; } @@ -1504,7 +1512,8 @@ static int imx6_pcie_host_init(struct pcie_port *pp) if (!IS_ENABLED(CONFIG_EP_MODE_IN_EP_RC_SYS)) { dw_pcie_setup_rc(pp); pci_imx_set_msi_en(pp); - imx6_pcie_establish_link(imx6_pcie); + if (imx6_pcie_establish_link(imx6_pcie)) + return -ENODEV; if (IS_ENABLED(CONFIG_PCI_MSI)) dw_pcie_msi_init(pp); -- cgit v1.2.3