devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sean Cross <xobs@kosagi.com>
To: Rob Herring <robh+dt@kernel.org>, Pawel Moll <pawel.moll@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	Kumar Gala <galak@codeaurora.org>,
	Lucas Stach <l.stach@pengutronix.de>,
	Shawn Guo <shawn.guo@freescale.com>,
	Bjorn Helgaas <bhelgaas@google.com>,
	devicetree@vger.kernel.org, Richard Zhu <r65037@freescale.com>,
	Grant Likely <grant.likely@linaro.org>,
	linux-pci@vger.kernel.org
Cc: bunnie@kosagi.com, Sean Cross <xobs@kosagi.com>
Subject: [PATCH v2 3/4] PCI: imx6: Add power-supply support
Date: Mon, 22 Dec 2014 16:32:06 +0800	[thread overview]
Message-ID: <1419237127-21763-4-git-send-email-xobs@kosagi.com> (raw)
In-Reply-To: <1419237127-21763-1-git-send-email-xobs@kosagi.com>

Some PCIe ports gate power to the slot.  In order to prevent system lockup,
these boards must enable power to the slot before attempting communication
over the PCI bus.

Signed-off-by: Sean Cross <xobs@kosagi.com>
---
 .../devicetree/bindings/pci/fsl,imx6q-pcie.txt     |  3 +++
 drivers/pci/host/pci-imx6.c                        | 27 ++++++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt b/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt
index 6fbba53..a806b68 100644
--- a/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt
+++ b/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt
@@ -13,6 +13,9 @@ Required properties:
 - clock-names: Must include the following additional entries:
 	- "pcie_phy"
 
+Optional properties:
+- bus-supply: A regulator that controls power to the entire bus
+
 Example:
 
 	pcie@0x01000000 {
diff --git a/drivers/pci/host/pci-imx6.c b/drivers/pci/host/pci-imx6.c
index 69202d1..8e4f957 100644
--- a/drivers/pci/host/pci-imx6.c
+++ b/drivers/pci/host/pci-imx6.c
@@ -22,6 +22,7 @@
 #include <linux/pci.h>
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
+#include <linux/regulator/consumer.h>
 #include <linux/resource.h>
 #include <linux/signal.h>
 #include <linux/types.h>
@@ -39,6 +40,7 @@ struct imx6_pcie {
 	struct pcie_port	pp;
 	struct regmap		*iomuxc_gpr;
 	void __iomem		*mem_base;
+	struct regulator	*bus_supply;
 };
 
 /* PCIe Root Complex registers (memory-mapped) */
@@ -523,6 +525,7 @@ static struct pcie_host_ops imx6_pcie_host_ops = {
 static int __init imx6_add_pcie_port(struct pcie_port *pp,
 			struct platform_device *pdev)
 {
+	struct imx6_pcie *imx6_pcie = to_imx6_pcie(pp);
 	int ret;
 
 	if (IS_ENABLED(CONFIG_PCI_MSI)) {
@@ -544,9 +547,22 @@ static int __init imx6_add_pcie_port(struct pcie_port *pp,
 	pp->root_bus_nr = -1;
 	pp->ops = &imx6_pcie_host_ops;
 
+	if (imx6_pcie->bus_supply) {
+		ret = regulator_enable(imx6_pcie->bus_supply);
+		if (ret) {
+			dev_err(pp->dev,
+				"unable to enable bus supply: %d\n", ret);
+			return ret;
+		}
+	}
+
 	ret = dw_pcie_host_init(pp);
 	if (ret) {
 		dev_err(&pdev->dev, "failed to initialize host\n");
+
+		if (imx6_pcie->bus_supply)
+			regulator_disable(imx6_pcie->bus_supply);
+
 		return ret;
 	}
 
@@ -588,6 +604,17 @@ static int __init imx6_pcie_probe(struct platform_device *pdev)
 		}
 	}
 
+	/* Fetch bus supply */
+	imx6_pcie->bus_supply = devm_regulator_get_optional(&pdev->dev, "bus");
+	if (IS_ERR(imx6_pcie->bus_supply)) {
+		ret = PTR_ERR(imx6_pcie->bus_supply);
+		if (ret == -EPROBE_DEFER)
+			return ret;
+
+		dev_err(&pdev->dev, "unable to get bus-supply\n");
+		return ret;
+	}
+
 	/* Fetch clocks */
 	imx6_pcie->pcie_phy = devm_clk_get(&pdev->dev, "pcie_phy");
 	if (IS_ERR(imx6_pcie->pcie_phy)) {
-- 
2.1.3

  parent reply	other threads:[~2014-12-22  8:32 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-22  8:32 [PATCH v2 0/4] Add support for kosagi novena Sean Cross
2014-12-22  8:32 ` [PATCH v2 1/4] drm/panel: simple: Add Innolux N133HSE panel support Sean Cross
2014-12-22  8:32 ` [PATCH v2 2/4] devicetree: bindings: Add vendor prefix for Kosagi Sean Cross
2014-12-26 21:00   ` Rob Herring
2014-12-22  8:32 ` Sean Cross [this message]
2015-01-05  9:46   ` [PATCH v2 3/4] PCI: imx6: Add power-supply support Lucas Stach
2015-01-05 15:31   ` Arnd Bergmann
     [not found] ` <1419237127-21763-1-git-send-email-xobs-nXMMniAx+RbQT0dZR+AlfA@public.gmane.org>
2014-12-22  8:32   ` [PATCH v2 4/4] ARM: dts: imx6q: add Novena board Sean Cross
2015-01-19 10:04     ` Lucas Stach
2015-01-30  6:48       ` Sean Cross
2015-01-16  0:46   ` [PATCH v2 0/4] Add support for kosagi novena Bjorn Helgaas
2015-01-16 10:38     ` Sean Cross
     [not found]       ` <54B8EA1C.7070700-nXMMniAx+RbQT0dZR+AlfA@public.gmane.org>
2015-01-16 10:44         ` Lucas Stach

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=1419237127-21763-4-git-send-email-xobs@kosagi.com \
    --to=xobs@kosagi.com \
    --cc=bhelgaas@google.com \
    --cc=bunnie@kosagi.com \
    --cc=devicetree@vger.kernel.org \
    --cc=galak@codeaurora.org \
    --cc=grant.likely@linaro.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=l.stach@pengutronix.de \
    --cc=linux-pci@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=pawel.moll@arm.com \
    --cc=r65037@freescale.com \
    --cc=robh+dt@kernel.org \
    --cc=shawn.guo@freescale.com \
    /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).