MLK-13178-2 pci: imx6: add one regulator for ext osc
authorRichard Zhu <hongxing.zhu@nxp.com>
Fri, 11 Jan 2019 06:58:08 +0000 (12:28 +0530)
committerLeonard Crestez <leonard.crestez@nxp.com>
Wed, 17 Apr 2019 23:51:34 +0000 (02:51 +0300)
On imx6qp sabresd rev b board, there is a standalone
external oscilator, used to provided the clks for
imx6qp pcie.

Add one regulator into pcie node, let the ext osc work.

Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
rebase on v4.19
Signed-off-by: Vipul Kumar <vipul_kumar@mentor.com>
drivers/pci/controller/dwc/pci-imx6.c

index 03a1096..846e158 100644 (file)
@@ -74,6 +74,7 @@ struct imx6_pcie {
        struct regulator        *vpcie;
        struct regmap           *reg_src;
        struct regulator        *pcie_phy_regulator;
+       struct regulator        *pcie_bus_regulator;
 };
 
 /* Parameters for the waiting for PCIe PHY PLL to lock on i.MX7 */
@@ -543,6 +544,12 @@ static void imx6_pcie_init_phy(struct imx6_pcie *imx6_pcie)
                                   IMX6SX_GPR12_PCIE_RX_EQ_2);
        }
 
+       if (imx6_pcie->pcie_bus_regulator != NULL) {
+               ret = regulator_enable(imx6_pcie->pcie_bus_regulator);
+               if (ret)
+                       dev_err(imx6_pcie->pci->dev, "failed to enable pcie regulator.\n");
+       }
+
        if (imx6_pcie->variant != IMX7D) {
                regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12,
                                   IMX6Q_GPR12_PCIE_CTL_2, 0 << 10);
@@ -601,6 +608,8 @@ static int imx6_pcie_wait_for_link(struct imx6_pcie *imx6_pcie)
                release_bus_freq(BUS_FREQ_HIGH);
                if (imx6_pcie->pcie_phy_regulator != NULL)
                        regulator_disable(imx6_pcie->pcie_phy_regulator);
+               if (imx6_pcie->pcie_bus_regulator != NULL)
+                       regulator_disable(imx6_pcie->pcie_bus_regulator);
        }
 
        return -ETIMEDOUT;
@@ -1021,6 +1030,8 @@ static int pci_imx_suspend_noirq(struct device *dev)
                /* Power down PCIe PHY. */
                if (imx6_pcie->pcie_phy_regulator != NULL)
                        regulator_disable(imx6_pcie->pcie_phy_regulator);
+               if (imx6_pcie->pcie_bus_regulator != NULL)
+                       regulator_disable(imx6_pcie->pcie_bus_regulator);
                if (gpio_is_valid(imx6_pcie->power_on_gpio))
                        gpio_set_value_cansleep(imx6_pcie->power_on_gpio, 0);
        } else {
@@ -1213,6 +1224,11 @@ static int __init imx6_pcie_probe(struct platform_device *pdev)
                break;
        }
 
+       imx6_pcie->pcie_bus_regulator = devm_regulator_get(dev,
+                                                          "pcie-bus");
+       if (IS_ERR(imx6_pcie->pcie_bus_regulator))
+               imx6_pcie->pcie_bus_regulator = NULL;
+
        /* Grab GPR config register range */
        if (imx6_pcie->variant == IMX7D) {
                imx6_pcie->iomuxc_gpr =