linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Richard Zhu <hongxing.zhu@nxp.com>
To: l.stach@pengutronix.de, bhelgaas@google.com, shawnguo@kernel.org,
	festevam@gmail.com
Cc: linux-pci@vger.kernel.org, linux-imx@nxp.com,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, kernel@pengutronix.de,
	Richard Zhu <hongxing.zhu@nxp.com>
Subject: [PATCH 2/2] PCI: imx: add another regulator for imx pcie
Date: Tue, 21 Jul 2020 15:44:30 +0800	[thread overview]
Message-ID: <1595317470-9394-2-git-send-email-hongxing.zhu@nxp.com> (raw)
In-Reply-To: <1595317470-9394-1-git-send-email-hongxing.zhu@nxp.com>

One more regulator is required to turn on the external oscillator
populated on the iMX6QP SABRESD board.
Add another regulator to enable PCIe on iMX6QP SABRESD board.

Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
---
 drivers/pci/controller/dwc/pci-imx6.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c
index 8f08ae53f53e..9e1563601835 100644
--- a/drivers/pci/controller/dwc/pci-imx6.c
+++ b/drivers/pci/controller/dwc/pci-imx6.c
@@ -81,6 +81,7 @@ struct imx6_pcie {
 	u32			tx_swing_low;
 	int			link_gen;
 	struct regulator	*vpcie;
+	struct regulator	*vepdev;
 	void __iomem		*phy_base;
 
 	/* power domain for pcie */
@@ -507,6 +508,14 @@ static void imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie)
 			return;
 		}
 	}
+	if (imx6_pcie->vepdev && !regulator_is_enabled(imx6_pcie->vepdev)) {
+		ret = regulator_enable(imx6_pcie->vepdev);
+		if (ret) {
+			dev_err(dev, "failed to enable vepdev regulator: %d\n",
+				ret);
+			goto err_pcie_vepdev;
+		}
+	}
 
 	ret = clk_prepare_enable(imx6_pcie->pcie_phy);
 	if (ret) {
@@ -595,6 +604,13 @@ static void imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie)
 err_pcie_bus:
 	clk_disable_unprepare(imx6_pcie->pcie_phy);
 err_pcie_phy:
+	if (imx6_pcie->vepdev && regulator_is_enabled(imx6_pcie->vepdev) > 0) {
+		ret = regulator_disable(imx6_pcie->vepdev);
+		if (ret)
+			dev_err(dev, "failed to disable vepdev regulator: %d\n",
+				ret);
+	}
+err_pcie_vepdev:
 	if (imx6_pcie->vpcie && regulator_is_enabled(imx6_pcie->vpcie) > 0) {
 		ret = regulator_disable(imx6_pcie->vpcie);
 		if (ret)
@@ -1178,6 +1194,12 @@ static int imx6_pcie_probe(struct platform_device *pdev)
 			return PTR_ERR(imx6_pcie->vpcie);
 		imx6_pcie->vpcie = NULL;
 	}
+	imx6_pcie->vepdev = devm_regulator_get_optional(&pdev->dev, "vepdev");
+	if (IS_ERR(imx6_pcie->vepdev)) {
+		if (PTR_ERR(imx6_pcie->vepdev) != -ENODEV)
+			return PTR_ERR(imx6_pcie->vepdev);
+		imx6_pcie->vepdev = NULL;
+	}
 
 	platform_set_drvdata(pdev, imx6_pcie);
 
-- 
2.17.1


  reply	other threads:[~2020-07-21  7:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-21  7:44 [PATCH 1/2] ARM: dts: imx6qp-sabresd: enable pcie Richard Zhu
2020-07-21  7:44 ` Richard Zhu [this message]
2020-07-21  8:16 ` Lucas Stach
2020-07-22  1:13   ` [EXT] " Richard Zhu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1595317470-9394-2-git-send-email-hongxing.zhu@nxp.com \
    --to=hongxing.zhu@nxp.com \
    --cc=bhelgaas@google.com \
    --cc=festevam@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=l.stach@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=shawnguo@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).