From patchwork Fri Oct 24 02:30:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Zhu X-Patchwork-Id: 5144011 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 A66B1C11AC for ; Fri, 24 Oct 2014 03:01:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C2F5E2026C for ; Fri, 24 Oct 2014 03:01:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9132420204 for ; Fri, 24 Oct 2014 03:01:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752190AbaJXDBN (ORCPT ); Thu, 23 Oct 2014 23:01:13 -0400 Received: from mail-by2on0142.outbound.protection.outlook.com ([207.46.100.142]:14256 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751507AbaJXDBM (ORCPT ); Thu, 23 Oct 2014 23:01:12 -0400 Received: from BY2PR03CA058.namprd03.prod.outlook.com (10.141.249.31) by BY1PR0301MB0854.namprd03.prod.outlook.com (25.160.193.148) with Microsoft SMTP Server (TLS) id 15.0.1054.13; Fri, 24 Oct 2014 03:01:10 +0000 Received: from BL2FFO11FD039.protection.gbl (2a01:111:f400:7c09::115) by BY2PR03CA058.outlook.office365.com (2a01:111:e400:2c5d::31) with Microsoft SMTP Server (TLS) id 15.1.6.9 via Frontend Transport; Fri, 24 Oct 2014 03:01:09 +0000 Received: from tx30smr01.am.freescale.net (192.88.168.50) by BL2FFO11FD039.mail.protection.outlook.com (10.173.161.135) with Microsoft SMTP Server (TLS) id 15.0.1049.20 via Frontend Transport; Fri, 24 Oct 2014 03:01:09 +0000 Received: from shlinux1.ap.freescale.net (shlinux1.ap.freescale.net [10.192.225.216]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id s9O312HQ005907; Thu, 23 Oct 2014 20:01:04 -0700 Received: by shlinux1.ap.freescale.net (Postfix, from userid 1003) id 868B24D6002; Fri, 24 Oct 2014 10:30:53 +0800 (CST) From: Richard Zhu To: CC: , , , , , Richard Zhu , Richard Zhu Subject: [PATCH V1] PCI: imx6: Wait the clocks to stabilize after ref_en Date: Fri, 24 Oct 2014 10:30:52 +0800 Message-ID: <1414117852-31657-2-git-send-email-richard.zhu@freescale.com> X-Mailer: git-send-email 1.7.8 In-Reply-To: <1414117852-31657-1-git-send-email-richard.zhu@freescale.com> References: <1414117852-31657-1-git-send-email-richard.zhu@freescale.com> X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:CAL; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(428002)(199003)(189002)(19580405001)(46386002)(85306004)(85852003)(80022003)(33646002)(92726001)(4396001)(92566001)(50226001)(77156001)(48376002)(44976005)(68736004)(26826002)(87936001)(102836001)(84676001)(45336002)(101416001)(52956003)(6806004)(42186005)(19580395003)(89996001)(88136002)(76482002)(77096002)(21056001)(105586002)(104166001)(103686003)(62966002)(106466001)(2351001)(110136001)(95666004)(76176999)(107046002)(87286001)(120916001)(36756003)(47776003)(50466002)(20776003)(229853001)(93916002)(50986999)(31966008)(46102003)(99396003)(64706001)(97736003)(16796002)(90966001); DIR:OUT; SFP:1102; SCL:1; SRVR:BY1PR0301MB0854; H:tx30smr01.am.freescale.net; FPR:; MLV:ovrnspm; PTR:InfoDomainNonexistent; A:0; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:BY1PR0301MB0854; X-Forefront-PRVS: 0374433C81 Received-SPF: None (protection.outlook.com: shlinux1.ap.freescale.net does not designate permitted sender hosts) Authentication-Results: spf=none (sender IP is 192.88.168.50) smtp.mailfrom=r65037@shlinux1.ap.freescale.net; X-OriginatorOrg: freescale.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=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 From: Richard Zhu For boards without a reset GPIO we skip the delay between enabling the pcie_ref_clk and touching the RC registers for configuration. This hangs the system if there isn't a proper delay to ensure the clocks are settled in the DW PCIe core. Also iMX6Q always needs an additional 10us delay to make sure the reset is propagated through the core, as we don't have an explicitly controlled reset input on this SoC. Signed-off-by: Richard Zhu Tested-by: Tim Harvey Tested-by: Fabio Estevam Tested-by: Fabio Estevam --- drivers/pci/host/pci-imx6.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/pci/host/pci-imx6.c b/drivers/pci/host/pci-imx6.c index 233fe8a..eac96fb 100644 --- a/drivers/pci/host/pci-imx6.c +++ b/drivers/pci/host/pci-imx6.c @@ -275,15 +275,22 @@ static int imx6_pcie_deassert_core_reset(struct pcie_port *pp) goto err_pcie; } - /* allow the clocks to stabilize */ - usleep_range(200, 500); - /* power up core phy and enable ref clock */ regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1, IMX6Q_GPR1_PCIE_TEST_PD, 0 << 18); + /* + * the async reset input need ref clock to sync internally, + * when the ref clock comes after reset, internal synced + * reset time is too short , cannot meet the requirement. + * add one ~10us delay here. + */ + udelay(10); regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1, IMX6Q_GPR1_PCIE_REF_CLK_EN, 1 << 16); + /* 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(imx6_pcie->reset_gpio, 0);