From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 98F7AC433EF for ; Fri, 11 Feb 2022 18:20:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Owner; bh=GSlVFf+W3afgKobykES36zs4FLXCJSwWBWpNqYJsJ9U=; b=moogFYAjyUPH4U 97EVfg0xah6nEKWKO60ya1tJTdauCq5uDZUuZOUkoDmxVKPjM8JsuX0IH7t1UG6qkSVwvY39meKG2 HJn7zv1HgpZ+uqF2cKI/PL37S2q5d5R/lnlJBEieZPeMtqhyq2/WHnHZhHk86EUFdUMUZR1qF+ZUW uXPRf3XhAASRSdc0+LapKyQP4QiLrlsNnM7tExmboISr3wcfAL+CV+shfOHzpNQq+/f6JuagGn6ev 8pcOuQ15KsNL1sGi7754Hq/sOycw8DqugohnDdoozE4iwcU+5qW1BG3Dsxr2mi6wZ8QaTAWftSAHM hQAL5gVba7lJ1Hti5KOg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIaVe-008OtQ-5E; Fri, 11 Feb 2022 18:19:06 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIaV1-008OYf-P8 for linux-arm-kernel@lists.infradead.org; Fri, 11 Feb 2022 18:18:29 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5267661E14; Fri, 11 Feb 2022 18:18:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67397C340E9; Fri, 11 Feb 2022 18:18:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644603506; bh=7h6+U0QyJ2iRXwnHJiK2E1wPEmMwdOFIcD6R74xoEQ4=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=C2BZXgBPdObkIIflLjyGbFfeVCv3dIfm9cHpaT7khQcCsN6xrlGOXWaQw0lErTB+4 2+XcnlVV2brFtOy24bqr0kZf6Fs4fCLN1DGvhxPYKU+ZkbNlHWm7EN0I1qZunc7giR 8JtVBnN0lppNe5y3lfjPOg29LER5dQPZBWgbqrkcRGXPoo/E1M82jKSMLgCQH9d3Yx dmB/o8qqrQfViRg4cbGtvbELSutY0OS3ny3HiPPlZmQXt8izyfQ8VaUmnsDZpjDgb7 JYVuyqneEBOt54dQ+EshjNj9J2OWSkk6chyfAcC53QPPEcSwssuZaxFNQ7tZZ9mJYf zO066UhB6iePg== Date: Fri, 11 Feb 2022 12:18:24 -0600 From: Bjorn Helgaas To: Francesco Dolcini Cc: Richard Zhu , Lucas Stach , Lorenzo Pieralisi , Rob Herring , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Shawn Guo , Sascha Hauer , linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v1] PCI: imx6: Fix PERST# start-up sequence Message-ID: <20220211181824.GA718271@bhelgaas> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220211152550.286821-1-francesco.dolcini@toradex.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220211_101827_930474_2F8E36B7 X-CRM114-Status: GOOD ( 31.10 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Feb 11, 2022 at 04:25:50PM +0100, Francesco Dolcini wrote: > According to the PCI-E standard the PERST# signal (reset-gpio in s/PCI-E/PCIe/ everywhere, to match conventional usage. > fsl,imx6* compatible dts) should be kept asserted for at least 100 usec > before the PCI-E refclock is stable, should be kept asserted for at > least 100ms after the power rails are stable and the host should wait > at least 100 msec after it is de-asserted before accessing the > configuration space of any attached device. > > From PCI Express Card Electromechanical Specification Please include spec revision and section number. I think this would probably be "PCIe CEM r5.0, sec 2.9.2". > T-PVPERL: Power stable to PERST# inactive - 100 msec > T-PERST-CLK: REFCLK stable before PERST# inactive 100 usec. > > From PCI Express Base Specification: Similarly, "PCIe r6.0, sec xxx". I don't see the text below in r6.0, so I think it must have evolved a bit. Probably something in sec 6.6.1. > To allow components to perform internal initialization, system > software must wait for at least 100 ms from the end of a Conventional > Reset of one or more devices before it is permitted to issue > Configuration Requests to those devices > > Failure to do so could prevent PCI-E devices to be working correctly, > and this was experienced with real devices. > > Move reset assert to imx6_pcie_assert_core_reset(), this way we ensure > that PERST# is asserted before enabling any clock, move de-assert to the > end of imx6_pcie_deassert_core_reset() after the clock is enabled and > deemed stable and add a new delay of 100 msec just afterward. > > Fixes: bb38919ec56e ("PCI: imx6: Add support for i.MX6 PCIe controller") > Signed-off-by: Francesco Dolcini > --- > drivers/pci/controller/dwc/pci-imx6.c | 27 ++++++++++++++++++--------- > 1 file changed, 18 insertions(+), 9 deletions(-) > > diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c > index 7b200b66114a..392803544364 100644 > --- a/drivers/pci/controller/dwc/pci-imx6.c > +++ b/drivers/pci/controller/dwc/pci-imx6.c > @@ -408,6 +408,11 @@ static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie) > dev_err(dev, "failed to disable vpcie regulator: %d\n", > ret); > } > + > + /* Some boards don't have PCIe reset GPIO. */ > + if (gpio_is_valid(imx6_pcie->reset_gpio)) > + gpio_set_value_cansleep(imx6_pcie->reset_gpio, > + imx6_pcie->gpio_active_high); > } > > static unsigned int imx6_pcie_grp_offset(const struct imx6_pcie *imx6_pcie) > @@ -544,15 +549,6 @@ static void imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie) > /* allow the clocks to stabilize */ > usleep_range(200, 500); > > - /* Some boards don't have PCIe reset GPIO. */ > - if (gpio_is_valid(imx6_pcie->reset_gpio)) { > - gpio_set_value_cansleep(imx6_pcie->reset_gpio, > - imx6_pcie->gpio_active_high); > - msleep(100); > - gpio_set_value_cansleep(imx6_pcie->reset_gpio, > - !imx6_pcie->gpio_active_high); > - } > - > switch (imx6_pcie->drvdata->variant) { > case IMX8MQ: > reset_control_deassert(imx6_pcie->pciephy_reset); > @@ -599,6 +595,19 @@ static void imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie) > break; > } > > + /* Some boards don't have PCIe reset GPIO. */ > + if (gpio_is_valid(imx6_pcie->reset_gpio)) { > + msleep(100); > + gpio_set_value_cansleep(imx6_pcie->reset_gpio, > + !imx6_pcie->gpio_active_high); > + /* > + * PCI Express Base Specification: Mention spec rev & section here, too. Someday we'll consolidate these with #defines and identifying all the delays related to sec 6.6.1 (or whatever it is) will be important. > + * A delay of at least 100ms is required after PERST# is > + * de-asserted before issuing any Configuration Requests > + */ > + msleep(100); > + } > + > return; > > err_ref_clk: > -- > 2.25.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel