From patchwork Wed Jul 18 19:44:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trent Piepho X-Patchwork-Id: 10533139 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A77F0602CA for ; Wed, 18 Jul 2018 19:45:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9859529CD0 for ; Wed, 18 Jul 2018 19:45:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C29429CD6; Wed, 18 Jul 2018 19:45:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02B2929CD0 for ; Wed, 18 Jul 2018 19:45:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729267AbeGRUYw (ORCPT ); Wed, 18 Jul 2018 16:24:52 -0400 Received: from mail-eopbgr730125.outbound.protection.outlook.com ([40.107.73.125]:52201 "EHLO NAM05-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727009AbeGRUYw (ORCPT ); Wed, 18 Jul 2018 16:24:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=impinj.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dlTqsD5uBn+8c+wxb9kLR5CA1a2JNt5HcZbVUtXsb1s=; b=QI1sqKMWd0E72l39CQjq4LsVV0Al89lm1APsFBWFLRH/TCIRodq7BeZ5KH8v/audhiGIjb16eWBrbg1UBs0JVKKG2o6W1Ysl56aJfEVYQgcDaxq4XUEAytVmIGhlGhxsUr9SZuecXtHtlArn2Fa4nqIdSfOdQbeXHyVG/X+GZlQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=tpiepho@impinj.com; Received: from impinj.com (216.207.205.253) by MWHPR0601MB3708.namprd06.prod.outlook.com (2603:10b6:301:7c::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.952.18; Wed, 18 Jul 2018 19:44:51 +0000 From: Trent Piepho To: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Trent Piepho , Shawn Guo , Sascha Hauer , Fabio Estevam , Richard Zhu , Lucas Stach Subject: [PATCH 2/2] PCI: imx: Add workaround for e10728, IMX7d PCIe PLL failure Date: Wed, 18 Jul 2018 12:44:24 -0700 Message-Id: <20180718194424.8844-3-tpiepho@impinj.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180718194424.8844-1-tpiepho@impinj.com> References: <20180718194424.8844-1-tpiepho@impinj.com> MIME-Version: 1.0 X-Originating-IP: [216.207.205.253] X-ClientProxiedBy: MWHPR14CA0014.namprd14.prod.outlook.com (2603:10b6:300:ae::24) To MWHPR0601MB3708.namprd06.prod.outlook.com (2603:10b6:301:7c::38) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 48047a80-a6c1-4851-c080-08d5ece6ed69 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600067)(711020)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:MWHPR0601MB3708; X-Microsoft-Exchange-Diagnostics: 1; MWHPR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ay+Ok5Dq7LF+8XDHySa5QUZPSPr2pVibYHf5tfkcgaW5MHQSxnBwz0WqCaihtMWKgCp0ZreplSBcmjLi9iq0Je3M8bddXkrM2Jk43cSDNwu08VQTmkjn0IVf4bBm1Llg7iGd5D0gpHIXJw1ZrUTS04sBnChAuy1pmkrdMtkDwJiv3M70JpOo2gq+BQ+FK1FpEqWfTSlktjjHvkI7NWOHIYvIZzxDaz7v53E+XZkIuZTKnX/mBeNuIfPZVswLONbi4Bp6wNd1MX35nbf6YcAn49K60RPXsKiwjh65eNybQfhPtsa2hJ2Gd2CbOn3ZBuQ40qBjbFJSIpBk90z/6yflf0gVhqo++R; 4:5ScenAAUKLkPHGiipRrXBaUebDKBJPjXdVaZHbxfqTfstmNqSW5VioH8lHQnlewN7V125jQWr1uBhbGmWrwxJsyGX+Ol6zgFyeNBOU06ZQgTg9RtN6T1EA2NnQoOSHxy/+svrTdgnFHGn8BE1uBtuV+lig7x8xSFR1p3WTpZzpPbCjFNZ/PKrGNP4JLTBya2DS/duAlelfWig6vr/V7pESoLp3Vq8K80AOpzQ0esJrtPO+MfyNWk+tTDE1TzeLemGkNkDqn3m0ZURl+iekmsM6djQazlVI38J2n1JOM9bkdjU3uYL3BTlEo2k0jrKT3a X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231311)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(149027)(150027)(6041310)(20161123560045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123558120)(6072148)(201708071742011)(7699016); SRVR:MWHPR0601MB3708; BCL:0; PCL:0; RULEID:; SRVR:MWHPR0601MB3708; X-Forefront-PRVS: 0737B96801 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(39840400004)(366004)(396003)(136003)(346002)(376002)(189003)(199004)(81156014)(25786009)(386003)(81166006)(16526019)(52116002)(76176011)(2906002)(7736002)(305945005)(316002)(106356001)(51416003)(7696005)(4326008)(26005)(53936002)(8936002)(186003)(54906003)(8676002)(48376002)(50466002)(16586007)(105586002)(66066001)(21086003)(1076002)(14444005)(5660300001)(3846002)(486006)(11346002)(476003)(97736004)(69596002)(68736007)(2616005)(478600001)(55016002)(956004)(86362001)(36756003)(6666003)(6116002)(50226002)(47776003)(446003); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR0601MB3708; H:impinj.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: impinj.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR0601MB3708; 23:B39++mrlIh7eAu/ihDM6UR6Qme/DqvC+teNc6yh?= =?us-ascii?Q?7Xc5mfXXZTXTPH9CU0bg9PS8AAWZ7B0BFwI2U5Y9XTHRUfuba9xCCkuVfmSY?= =?us-ascii?Q?HRy4GK3I3LMTTWfrKUa+v/nnzEljBeH4TkuZyyZE43Jv19itJclZ2Fw85soa?= =?us-ascii?Q?bsK9h6Xd4hMAT1nY9GRcvf5oGNhANwcer99C3epSC1kfRJAeg0b6qi1q/lhz?= =?us-ascii?Q?v6VdrfI2CUhmPrvLm9RhgrLB1R8xD6zYPLLPWKNZW1S2V4L68vQaC3C3XZwQ?= =?us-ascii?Q?SVoZ4SW7Yyh0sGtL9BqE6guomAWqVhZIyWRiskRIxK5yAc5nmFo2wgYeTwk/?= =?us-ascii?Q?AlT4OihRNZg86paNfzoyD4IAmdBMlGZpbO2TVFArhcJrm63q3hydjX2YXcDf?= =?us-ascii?Q?EjQbVuRhCVxhnKwjGz0bG/U+dZdrcO0VFvQ77q8CgOAVZVVAgf/hrMU73Yqw?= =?us-ascii?Q?SNgeSoBBrnOZo0r9zn/+jaBUvFUkq4AN0dO/Uoy/0bP7luqb1gTwc54gp2ZI?= =?us-ascii?Q?aEliRK5sKc8DAavCT7l5lxruWwyEWfo/pUvtCOzHF+0OF1RgEoCK7GhC6LS9?= =?us-ascii?Q?swv5Wdqpy2uks3nTRuYtsGOu3MipxVoMyKDTOMY7S7bY879zHUbbSmTNZ0mI?= =?us-ascii?Q?p61jQAw955Yt+1xuCOS6h1Mx75cPRUNvk42H0CkofnJtAdYhpVodCBT+B9P1?= =?us-ascii?Q?4of7bOInmG0SC5NPuhkC73B17/PKHrOWr8qdza07mrsKcV9y2R7uACkzReeG?= =?us-ascii?Q?Bnn0DEgYxGF6J5egh65QKLR0Xnr/BPL/K3o0uI7M4VRYAb52XGOh8c1RGLQ0?= =?us-ascii?Q?SM+6V7WQ290f5IUWlqP2r/7UhIcxezSCAfT8sTmneCVt+2lrL9v6RXJsBjv2?= =?us-ascii?Q?csnvcDw01M7bK8b8qo+pd34me9LPGB357xAhFZHff+vbitrtmxuVLj2OkX5v?= =?us-ascii?Q?lBYvvDZ4dp61+39dsgw3HB8Y68QBZFbTNmNxaFOCmKH6oweJEeo/59FzW4Wj?= =?us-ascii?Q?Fj7UH35oqLFKCHbnTwiDb2w2eLIZYootG3bVcDLi1G6TTRE5w3X+ueZK/ATX?= =?us-ascii?Q?E7d298Fs/8NeSCSNYl5PhhX8kVGMYwu/eNVzdkGaRNyrPrDxhic0lUSveeif?= =?us-ascii?Q?43DlkGImpRcQzwMKDPtKOXh3ycu7aGu1RiQCJQa8v7X6gqcPSBN5g6+whEVw?= =?us-ascii?Q?7meturKrHV31/PXmeCNYKrIf1MEn+/e/joyaWQynfRMpW+bIrrxfR6sQBPw?= =?us-ascii?Q?=3D=3D?= X-Microsoft-Antispam-Message-Info: y/3433RezjCnv0sqH1b1501G7BZ7VY0nNgSGKuGSs1T3sO2RIUeN+6Pp6vryWX62rtprz63XqV83BG8tkYwF66KooSTEpqNB6/HZFfS/sIgWKUwF1JMjdUCzITmP1BsW9Md1CBHQTtm895kiP2Wg7tAmUHauYYPt1ervAASCQnO7B8LHgOyW4K4d4x1duCmQn45+4L32HV0QcyGTKN5D7YhfLJ74i7KNqW7nkIIvuW5D6qrhYhOdK5fFiRq5VBI5o2XdJrmMdBYW4g1N/oZbh/+Sl9eah33yaKZRZYI59tYYqMYTpDefws0EpwvkV9abpVpoUALW6M0N1X2PJTuxfzgSqYXuAD6ZNrw1UHCrS8g= X-Microsoft-Exchange-Diagnostics: 1; MWHPR0601MB3708; 6:PuqWgz4j5mGGT2HVtwh2c93IBNAG/B134FPSYkLJSkWMvExi1abZ4yrCiWY199hgVio7LJnZX18bHKL7yPN1OOSD9QKYqXUGjkAj6ySkR8218HJL2SVXanSK/btmIemopFcYBnIJTrQzInC0jq0dX7xF8M1coEB9dzUUvkBmsqpVbpFD+u3le2avhIPW+PoGgrJPmZhrfEc84W15D4sG2TwGFZW5hlM+pWxXQ5AsfJLWhBdX+GOzze8pXTmy5MaFOpmv61vIYqflEtVvPlxXyO13L/hlC6Xh1cJWxGe+QZFNp0zw1P2Q+sjHbNcCsYs1JMvYzrzZBygpm9e9a1YUhabvCVsrq46h6q5Q8Kr/H70Ilw4liSp5SZNwZrPlMVbH+Moi+cs561dHspaMnsE8M97Qesy46SiLnHB0YIxq4hezTAIT1B99+OfPt+lHDkMx7dIx+CbGAdP4sUOlT9Rwew==; 5:OBwfssyavrCIJ8NYsN5KRm3bwwCOSpPfFYaMSUueRy3ZM7EX56vmCp0UMrNxrmquoDpKDdsQbo7j9x9JE5HT65bl95LUaBhNXwIJ8mo3PjfbNe4PbRZ5j5obv1zvGlkQkWHtmvBVdvroxz0fVdnijSEIavm2MZ+WJq0HPlvDiD8=; 24:qNPSXTl1lxr0yZ7fanD6S37kDzY+Kn7ez6z/eIw2YKOcYWvaDVJgic3ZoUmxPwkzyVLlpHFvCO6BRizwrqZr3pBKlrmOJypXgE6OV687TeE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MWHPR0601MB3708; 7:8gELQPVJhR3gfF+hZ1tzfK3OTEEnUFOFpMSHB32nWVaX1gwliqtn1ObU0N7TCYqFze0lRkm43PDAhPEaXS3kZijeFi1LDjWJwKpHsvwvajhJRzWbnsTaSS2K0jpm+7b8oh1OlpLOVShuTdhnGfycolZV8B5TVKjG8XrexmXi7jA/yYmMhybM6vQzA6PTuGR7+0u0FH+TWJEzPyxtymbgsfNOLrVF12lK6ixomBSZiUMlBqOwKUc7mrxI+XdMcU5+ X-OriginatorOrg: impinj.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jul 2018 19:44:51.1796 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 48047a80-a6c1-4851-c080-08d5ece6ed69 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 6de70f0f-7357-4529-a415-d8cbb7e93e5e X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR0601MB3708 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This implements the workound described in the NXP IMX7d erratum e10728. Initial VCO oscillation may fail under corner conditions such as cold temperature. It causes PCIe PLL to fail to lock in the initialization phase, which results in the PCIe link failing to come up. The workaround is to disable Duty-cycle Corrector (DCC) calibration after G_RST. To do this it is necessary to gain access to the undocumented and currently unused PCIe PHY register bank. A new device tree node of type "fsl,imx-pcie-phy" is created for the PHY block and the existing PCIe device uses a phandle named "fsl,pcie-phy" to point to it. Cc: Shawn Guo Cc: Sascha Hauer Cc: Fabio Estevam Cc: Richard Zhu Cc: Lucas Stach Signed-off-by: Trent Piepho --- drivers/pci/dwc/pci-imx6.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/drivers/pci/dwc/pci-imx6.c b/drivers/pci/dwc/pci-imx6.c index dcf389b62944..32429afc9380 100644 --- a/drivers/pci/dwc/pci-imx6.c +++ b/drivers/pci/dwc/pci-imx6.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -58,6 +59,7 @@ struct imx6_pcie { u32 tx_swing_low; int link_gen; struct regulator *vpcie; + void __iomem *phy_base; }; /* Parameters for the waiting for PCIe PHY PLL to lock on i.MX7 */ @@ -98,6 +100,23 @@ struct imx6_pcie { #define PCIE_PHY_RX_ASIC_OUT 0x100D #define PCIE_PHY_RX_ASIC_OUT_VALID (1 << 0) +/* iMX7 PCIe PHY registers */ +#define PCIE_PHY_CMN_REG4 0x14 +/* These are probably the bits that *aren't* DCC_FB_EN */ +#define PCIE_PHY_CMN_REG4_DCC_FB_EN 0x29 + +#define PCIE_PHY_CMN_REG15 0x54 +#define PCIE_PHY_CMN_REG15_DLY_4 BIT(2) +#define PCIE_PHY_CMN_REG15_PLL_PD BIT(5) +#define PCIE_PHY_CMN_REG15_OVRD_PLL_PD BIT(7) + +#define PCIE_PHY_CMN_REG24 0x90 +#define PCIE_PHY_CMN_REG24_RX_EQ BIT(6) +#define PCIE_PHY_CMN_REG24_RX_EQ_SEL BIT(3) + +#define PCIE_PHY_CMN_REG26 0x98 +#define PCIE_PHY_CMN_REG26_ATT_MODE 0xBC + #define PHY_RX_OVRD_IN_LO 0x1005 #define PHY_RX_OVRD_IN_LO_RX_DATA_EN (1 << 5) #define PHY_RX_OVRD_IN_LO_RX_PLL_EN (1 << 3) @@ -431,6 +450,26 @@ static void imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie) switch (imx6_pcie->variant) { case IMX7D: reset_control_deassert(imx6_pcie->pciephy_reset); + + /* Workaround for ERR010728, failure of PCI-e PLL VCO to + * oscillate, especially when cold. This turns off "Duty-cycle + * Corrector" and other mysterious undocumented things. + */ + if (likely(imx6_pcie->phy_base)) { + /* De-assert DCC_FB_EN */ + writel(PCIE_PHY_CMN_REG4_DCC_FB_EN, + imx6_pcie->phy_base + PCIE_PHY_CMN_REG4); + /* Assert RX_EQS and RX_EQS_SEL */ + writel(PCIE_PHY_CMN_REG24_RX_EQ_SEL + | PCIE_PHY_CMN_REG24_RX_EQ, + imx6_pcie->phy_base + PCIE_PHY_CMN_REG24); + /* Assert ATT_MODE */ + writel(PCIE_PHY_CMN_REG26_ATT_MODE, + imx6_pcie->phy_base + PCIE_PHY_CMN_REG26); + } else { + dev_err(dev, "PHY base address not set\n"); + } + imx7d_pcie_wait_for_phy_pll_lock(imx6_pcie); break; case IMX6SX: @@ -698,6 +737,7 @@ static int imx6_pcie_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct dw_pcie *pci; struct imx6_pcie *imx6_pcie; + struct device_node *np; struct resource *dbi_base; struct device_node *node = dev->of_node; int ret; @@ -717,6 +757,25 @@ static int imx6_pcie_probe(struct platform_device *pdev) imx6_pcie->variant = (enum imx6_pcie_variants)of_device_get_match_data(dev); + /* Find the PHY if one is defined, only imx7d uses it */ + np = of_parse_phandle(node, "fsl,pcie-phy", 0); + if (np) { + struct resource res; + + ret = of_address_to_resource(np, 0, &res); + if (ret) { + dev_err(dev, "Unable to map PCIe PHY\n"); + return ret; + } + imx6_pcie->phy_base = devm_ioremap_resource(dev, &res); + if (IS_ERR(imx6_pcie->phy_base)) { + dev_err(dev, "Unable to map PCIe PHY\n"); + return PTR_ERR(imx6_pcie->phy_base); + } + } else { + imx6_pcie->phy_base = NULL; + } + dbi_base = platform_get_resource(pdev, IORESOURCE_MEM, 0); pci->dbi_base = devm_ioremap_resource(dev, dbi_base); if (IS_ERR(pci->dbi_base))