Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752072AbdFPAtq (ORCPT ); Thu, 15 Jun 2017 20:49:46 -0400 Received: from mail-db5eur01on0087.outbound.protection.outlook.com ([104.47.2.87]:64032 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751673AbdFPAto (ORCPT ); Thu, 15 Jun 2017 20:49:44 -0400 From: Richard Zhu To: Bjorn Helgaas , Quentin Schulz CC: "l.stach@pengutronix.de" , "bhelgaas@google.com" , "robh+dt@kernel.org" , "mark.rutland@arm.com" , "thomas.petazzoni@free-electrons.com" , "devicetree@vger.kernel.org" , "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" Subject: RE: [PATCH] PCI: imx6: add regulator support Thread-Topic: [PATCH] PCI: imx6: add regulator support Thread-Index: AQHS4C5XmD5a2o7nkkOKIXZC8H7Jg6ImdfEAgAA893A= Date: Fri, 16 Jun 2017 00:49:40 +0000 Message-ID: References: <20170608080742.3910-1-quentin.schulz@free-electrons.com> <20170615210544.GE12735@bhelgaas-glaptop.roam.corp.google.com> In-Reply-To: <20170615210544.GE12735@bhelgaas-glaptop.roam.corp.google.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=nxp.com; x-originating-ip: [199.59.225.131] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;AM5PR0402MB2851;7:mD5bucIVOYvbBEBKrb3oCxC8t6TXkK9cOsZvXlGcVtFbEkCBmqSjgNKC+67+INqbachpS2E+XH79cLvPNgZoX88k5JtxJuq26SaBfpg3+evkvJTglXU/WGOMNnWUs1VWxXZSjhuvO8cJhgJcbdO9+q4IIPht4C9FpJdGnLGP49ENHgs25YKs0dq6m84QeuG5OBVGcU8V9sFXxAqhWflnsQUs1KxGZp5+hi8q7/XVz3GSwJAbogGNiXN2ZMz3GpdcaJdEojH4c/yeFMs/YGdfJ4Scc7kpDVip2xDLxnlf6bzaOW/YXtXy7fKztCa8nZer14niU5ACTDfRJJG2jPGBxw== x-ms-traffictypediagnostic: AM5PR0402MB2851: x-ms-office365-filtering-correlation-id: a96170da-bc83-4937-fa98-08d4b451925b x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(2017030254075)(48565401081)(201703131423075)(201703031133081);SRVR:AM5PR0402MB2851; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917)(9452136761055)(185117386973197)(258649278758335)(211936372134217)(58145275503218); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(100000703101)(100105400095)(10201501046)(6055026)(6041248)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123560025)(20161123562025)(20161123555025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:AM5PR0402MB2851;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:AM5PR0402MB2851; x-forefront-prvs: 0340850FCD x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(39400400002)(39410400002)(39850400002)(39840400002)(39860400002)(39450400003)(13464003)(24454002)(377454003)(76176999)(478600001)(966005)(6246003)(53936002)(86362001)(229853002)(81166006)(45080400002)(2900100001)(50986999)(54356999)(8936002)(5660300001)(5250100002)(54906002)(1720100001)(8676002)(2950100002)(189998001)(7696004)(55016002)(9686003)(66066001)(3280700002)(6506006)(102836003)(6306002)(99286003)(3660700001)(25786009)(14454004)(305945005)(33656002)(2906002)(4326008)(7736002)(6436002)(6116002)(53546009)(74316002)(38730400002)(3846002);DIR:OUT;SFP:1101;SCL:1;SRVR:AM5PR0402MB2851;H:AM5PR0402MB2850.eurprd04.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Jun 2017 00:49:40.5372 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0402MB2851 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id v5G0nqCL019744 Content-Length: 5376 Lines: 148 > -----Original Message----- > From: Bjorn Helgaas [mailto:helgaas@kernel.org] > Sent: Friday, June 16, 2017 5:06 AM > To: Quentin Schulz > Cc: Richard Zhu ; l.stach@pengutronix.de; > bhelgaas@google.com; robh+dt@kernel.org; mark.rutland@arm.com; > thomas.petazzoni@free-electrons.com; devicetree@vger.kernel.org; linux- > pci@vger.kernel.org; linux-kernel@vger.kernel.org; linux-arm- > kernel@lists.infradead.org > Subject: Re: [PATCH] PCI: imx6: add regulator support > > On Thu, Jun 08, 2017 at 10:07:42AM +0200, Quentin Schulz wrote: > > Some boards might require to control a regulator to power the PCIe port. > > > > This adds support for an optional regulator defined in Device Tree > > linked in the PCIe controller under `vpcie-supply`. If present, the > > regulator will be disabled and then enabled as part of the PCIe host > > initialization process and will be disabled when shutting down. > > > > Signed-off-by: Quentin Schulz > > Waiting for ack from Richard or Lucas. [Zhu hongxing] Sorry to replay late. This patch is okay for me. Thanks. Acked-by: Richard Zhu > > > --- > > .../devicetree/bindings/pci/fsl,imx6q-pcie.txt | 4 +++ > > drivers/pci/dwc/pci-imx6.c | 34 +++++++++++++++++++++- > > 2 files changed, 37 insertions(+), 1 deletion(-) > > > > diff --git a/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt > > b/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt > > index e3d5680875b1..cf92d3ba5a26 100644 > > --- a/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt > > +++ b/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt > > @@ -33,6 +33,10 @@ Optional properties: > > - reset-gpio-active-high: If present then the reset sequence using the > GPIO > > specified in the "reset-gpio" property is reversed (H=reset state, > > L=operation state). > > +- vpcie-supply: Should specify the regulator in charge of PCIe port power. > > + The regulator will be enabled when initializing the PCIe host and > > + disabled either as part of the init process or when shutting down > > +the > > + host. > > > > Additional required properties for imx6sx-pcie: > > - clock names: Must include the following additional entries: > > diff --git a/drivers/pci/dwc/pci-imx6.c b/drivers/pci/dwc/pci-imx6.c > > index 19a289b8cc94..f9b7500c9aff 100644 > > --- a/drivers/pci/dwc/pci-imx6.c > > +++ b/drivers/pci/dwc/pci-imx6.c > > @@ -24,6 +24,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > @@ -59,6 +60,7 @@ struct imx6_pcie { > > u32 tx_swing_full; > > u32 tx_swing_low; > > int link_gen; > > + struct regulator *vpcie; > > }; > > > > /* Parameters for the waiting for PCIe PHY PLL to lock on i.MX7 */ @@ > > -310,6 +312,13 @@ static void imx6_pcie_assert_core_reset(struct > imx6_pcie *imx6_pcie) > > IMX6Q_GPR1_PCIE_REF_CLK_EN, 0 << 16); > > break; > > } > > + > > + if (imx6_pcie->vpcie && regulator_is_enabled(imx6_pcie->vpcie) > 0) > { > > + int ret = regulator_disable(imx6_pcie->vpcie); > > + > > + if (ret) > > + pr_err("failed to disable vpcie regulator: %d\n", ret); > > + } > > } > > > > static int imx6_pcie_enable_ref_clk(struct imx6_pcie *imx6_pcie) @@ > > -376,10 +385,19 @@ static void imx6_pcie_deassert_core_reset(struct > imx6_pcie *imx6_pcie) > > struct device *dev = pci->dev; > > int ret; > > > > + if (imx6_pcie->vpcie && !regulator_is_enabled(imx6_pcie->vpcie)) { > > + ret = regulator_enable(imx6_pcie->vpcie); > > + if (ret) { > > + dev_err(dev, "failed to enable vpcie regulator: %d\n", > > + ret); > > + return; > > + } > > + } > > + > > ret = clk_prepare_enable(imx6_pcie->pcie_phy); > > if (ret) { > > dev_err(dev, "unable to enable pcie_phy clock\n"); > > - return; > > + goto err_pcie_phy; > > } > > > > ret = clk_prepare_enable(imx6_pcie->pcie_bus); > > @@ -439,6 +457,13 @@ static void imx6_pcie_deassert_core_reset(struct > imx6_pcie *imx6_pcie) > > clk_disable_unprepare(imx6_pcie->pcie_bus); > > err_pcie_bus: > > clk_disable_unprepare(imx6_pcie->pcie_phy); > > +err_pcie_phy: > > + if (imx6_pcie->vpcie && regulator_is_enabled(imx6_pcie->vpcie) > 0) > { > > + ret = regulator_disable(imx6_pcie->vpcie); > > + if (ret) > > + dev_err(dev, "failed to disable vpcie regulator: %d\n", > > + ret); > > + } > > } > > > > static void imx6_pcie_init_phy(struct imx6_pcie *imx6_pcie) @@ -802,6 > > +827,13 @@ static int imx6_pcie_probe(struct platform_device *pdev) > > if (ret) > > imx6_pcie->link_gen = 1; > > > > + imx6_pcie->vpcie = devm_regulator_get_optional(&pdev->dev, > "vpcie"); > > + if (IS_ERR(imx6_pcie->vpcie)) { > > + if (PTR_ERR(imx6_pcie->vpcie) == -EPROBE_DEFER) > > + return -EPROBE_DEFER; > > + imx6_pcie->vpcie = NULL; > > + } > > + > > platform_set_drvdata(pdev, imx6_pcie); > > > > ret = imx6_add_pcie_port(imx6_pcie, pdev); > > -- > > 2.11.0 > > > > > > _______________________________________________ > > linux-arm-kernel mailing list > > linux-arm-kernel@lists.infradead.org > > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel