From patchwork Fri Dec 19 08:10:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Cross X-Patchwork-Id: 5517961 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6B011BEEA8 for ; Fri, 19 Dec 2014 08:18:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A10492013D for ; Fri, 19 Dec 2014 08:18:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AA77F20142 for ; Fri, 19 Dec 2014 08:18:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752284AbaLSISm (ORCPT ); Fri, 19 Dec 2014 03:18:42 -0500 Received: from mail1.g1.pair.com ([66.39.3.162]:43903 "EHLO mail1.g1.pair.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752281AbaLSISj (ORCPT ); Fri, 19 Dec 2014 03:18:39 -0500 X-Greylist: delayed 478 seconds by postgrey-1.27 at vger.kernel.org; Fri, 19 Dec 2014 03:18:39 EST Received: from localhost.localdomain (unknown [210.23.18.169]) by mail1.g1.pair.com (Postfix) with ESMTPSA id 247AF3C4C6; Fri, 19 Dec 2014 03:10:39 -0500 (EST) From: Sean Cross To: Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , Lucas Stach , Shawn Guo , Bjorn Helgaas , devicetree@vger.kernel.org, Richard Zhu , Grant Likely , linux-pci@vger.kernel.org Cc: bunnie@kosagi.com, Sean Cross Subject: [PATCH 1/2] PCI: imx6: Add power-supply support Date: Fri, 19 Dec 2014 16:10:16 +0800 Message-Id: <1418976617-833-2-git-send-email-xobs@kosagi.com> X-Mailer: git-send-email 2.1.3 In-Reply-To: <1418976617-833-1-git-send-email-xobs@kosagi.com> References: <1418976617-833-1-git-send-email-xobs@kosagi.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- .../devicetree/bindings/pci/fsl,imx6q-pcie.txt | 3 +++ drivers/pci/host/pci-imx6.c | 20 +++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt b/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt index 6fbba53..fe912bd 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: +- power-supply: A regulator that controls power to the port + Example: pcie@0x01000000 { diff --git a/drivers/pci/host/pci-imx6.c b/drivers/pci/host/pci-imx6.c index 69202d1..9c2140e 100644 --- a/drivers/pci/host/pci-imx6.c +++ b/drivers/pci/host/pci-imx6.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -39,6 +40,7 @@ struct imx6_pcie { struct pcie_port pp; struct regmap *iomuxc_gpr; void __iomem *mem_base; + struct regulator *power_reg; }; /* PCIe Root Complex registers (memory-mapped) */ @@ -588,6 +590,19 @@ static int __init imx6_pcie_probe(struct platform_device *pdev) } } + /* Fetch power supply */ + imx6_pcie->power_reg = devm_regulator_get(&pdev->dev, "power"); + if (IS_ERR(imx6_pcie->power_reg)) + imx6_pcie->power_reg = 0; + + if (imx6_pcie->power_reg) { + ret = regulator_enable(imx6_pcie->power_reg); + if (ret) { + dev_err(&pdev->dev, "Unable to enable power regulator"); + return ret; + } + } + /* Fetch clocks */ imx6_pcie->pcie_phy = devm_clk_get(&pdev->dev, "pcie_phy"); if (IS_ERR(imx6_pcie->pcie_phy)) { @@ -619,8 +634,11 @@ static int __init imx6_pcie_probe(struct platform_device *pdev) } ret = imx6_add_pcie_port(pp, pdev); - if (ret < 0) + if (ret < 0) { + if (imx6_pcie->power_reg) + regulator_disable(imx6_pcie->power_reg); return ret; + } platform_set_drvdata(pdev, imx6_pcie); return 0;