From patchwork Tue Jul 24 16:14:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonard Crestez X-Patchwork-Id: 10542407 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 823A017FD for ; Tue, 24 Jul 2018 16:16:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E1B228CF0 for ; Tue, 24 Jul 2018 16:16:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6100B28DEE; Tue, 24 Jul 2018 16:16:06 +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=-2.9 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E569528CF0 for ; Tue, 24 Jul 2018 16:16:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/Yxbo1KFgHx8lP0olBC7wnU6pAU42gw70W6XFs9+uSU=; b=c6qTom7ccd3fXQ P/ZyIyD8JmQ69xr5zD33xlYBS4hxDsVg6vFNO+QlVG13nglzlgM+/8cVsLfXnRQ4plwpSJ1DoZ3wz QfiWuxGThrWsBodhtRxQz6T8j6rhzdFJcbtzYomzBSQs97a+Ypi0ATS6ql8lOQ4Catih+XOl0fBIV jKzKc3uVdu+lr8pAPvCjYl7eWBhVLThH00dPj8vZpNECvIMI8Ryh0rrDfmnTGKzgbNMskB7kmlmXC eXhk0GCzrRsE0rOgm0U8O4Inufii5t4FWPoD94w68fQLKO15TB7r3x2TUHjccVAAlcOPtUoN08gZx +MQMv4ApR9jh00eRyyqA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fhzyg-0003xG-UL; Tue, 24 Jul 2018 16:15:58 +0000 Received: from mail-eopbgr80085.outbound.protection.outlook.com ([40.107.8.85] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fhzyJ-0002HO-RR for linux-arm-kernel@lists.infradead.org; Tue, 24 Jul 2018 16:15:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ND4YWGkHWotnvSOJ36ySVVbPGq7f7PkYyTJaPsqrfDU=; b=J/+P54Q6YzccAKVWR/gwk7cgGSSr4sc7ZdhyOU21zpcWtFpwwMSKFJ4RpSxX0eVWFyOmgTHDutxjw/BGL403VqtorwwysmW68HMDH3eEmvrhvzwOKpcVsY7CwctBidyJWnrTEtGcuwi6tjvllp7OY4FxAbfBX2XV7LlCqMRsdbU= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=leonard.crestez@nxp.com; Received: from localhost.localdomain (95.76.156.53) by AM0PR04MB4290.eurprd04.prod.outlook.com (2603:10a6:208:67::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.973.21; Tue, 24 Jul 2018 16:15:13 +0000 From: Leonard Crestez To: Lucas Stach , Andrey Smirnov , Richard Zhu , Shawn Guo Subject: [PATCH v3 2/2] PCI: imx: Initial imx7d pm support Date: Tue, 24 Jul 2018 19:14:20 +0300 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [95.76.156.53] X-ClientProxiedBy: AM3PR05CA0137.eurprd05.prod.outlook.com (2603:10a6:207:3::15) To AM0PR04MB4290.eurprd04.prod.outlook.com (2603:10a6:208:67::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d6f0d4d7-a093-45ed-6078-08d5f180a391 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600073)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM0PR04MB4290; X-Microsoft-Exchange-Diagnostics: 1; AM0PR04MB4290; 3:7LmRvPp+IbC+flaOiLySQJAD5xSSC4PsSllTvwK4aFsx3Gp+lYZsHznPn2EgMPFhVrLhMYXxn3QQCptlEm/iZoDVg1DOTZ0DUP99PzneTC3Qz8HITCtLwosgT1O058gCTWUEVDtJTA6wDO6kmoLIgcgYefib3YlMj5gcuhXXHnjtyZ5HPI3EPAj3lFHkq/TOzateK0+DvVy1E1BgaVw73j3KpNdBqsEAz+Ok0fgus4PlThGdRYa9rYqCxCyn3cLr; 25:ifVi7l5yVDqMeSb5p0kKDIsuhxiDncO3VjAfYMXfPBalKSQul++2mQNR/D5KL2P+nTfARg/+b6KYnYNj0LZFNBQi5fQH64BBEi6gjZyVVZU/LmQh4Mx6cf+Zak/y38AdgsEAsxYIcVx5vRSSYA7XyBngfglpRuAC5d7N1oDrbGFYyVdbFgvaIYRBxIzb61gMKO9ub8x/5Vdmnzw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FcbSwlHiw60AqIrdSYz1K/m9ksoxZDdjL+3PaTQ9EKGRMV0rU0Be/jl5RbyyvYgODj15y43CGY0tGY8YBDWkvADtkdcw8JroKaGASgaFXTFNfiM6tOMTTQq3c+Z6r1yhva2n/VlDNAqU4wGMe/+CHnIgYrH8UGOovO5DE7G6u70x5tMJebIQkFKRlHSrmo 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)(8121501046)(5005006)(3231311)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123562045)(20161123564045)(6072148)(201708071742011)(7699016); SRVR:AM0PR04MB4290; BCL:0; PCL:0; RULEID:; SRVR:AM0PR04MB4290; X-Forefront-PRVS: 0743E8D0A6 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(396003)(376002)(366004)(39860400002)(346002)(136003)(189003)(199004)(446003)(44832011)(86362001)(11346002)(54906003)(81156014)(50226002)(47776003)(97736004)(81166006)(2906002)(110136005)(8676002)(14444005)(316002)(16586007)(4326008)(16526019)(8936002)(25786009)(305945005)(486006)(66066001)(39060400002)(2616005)(186003)(6506007)(386003)(6116002)(3846002)(7416002)(118296001)(68736007)(53936002)(76176011)(476003)(7736002)(26005)(52116002)(6512007)(51416003)(106356001)(36756003)(5660300001)(6666003)(105586002)(50466002)(956004)(6486002)(478600001)(48376002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR04MB4290; H:localhost.localdomain; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM0PR04MB4290; 23:FjIlKAYxt3n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lX019oXDh8n/LHVPP9xtbv5YGsxAICUKCJJOfVaRSgN+PXKSaCgJg==; 5:uIzElYlSfAZlxxeOT+gRPuJF9FoqMkTZQ06E5n2C2rwjr+OOQ5NBwJyLIgX6O7nZUXSgy5Vp48r4QFRWBYCXSkakHnPNfmsTzDRcBuxB8CJLKDzziETfzIFjU98G58X1rE07c6Ig5y+nEDZoj/noQeOKrdSwtndatcO9Q5AsDQE=; 7:1xzoGDSaZAKj7qMm6rvs6GEGNipsF6ol0uox6tVu1jwgS9FUkME7NTA4ySTH8EFZnX/Fbs+4tNtfWysNoP2ozDbAceYyRd0c8cbcJ2/sez+fe0FipzzmZ3jw6yV2GtkSbZ8apb9VUcDzw8tannxm5dqYOA4+bTt/9GIYmkuwDG2mhMRM28eXY9PJlsHUiKxbAZF+TG5N+SOygS8vb0tYES0GNotl+yqZ+w7SQkvKa5HDgFb+NBNOvAuynhCiFJ/W SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2018 16:15:13.6208 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d6f0d4d7-a093-45ed-6078-08d5f180a391 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4290 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180724_091536_359052_EF005691 X-CRM114-Status: GOOD ( 16.96 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dong Aisheng , Joao Pinto , kernel@pengutronix.de, Anson Huang , Jingoo Han , linux-kernel@vger.kernel.org, Fabio Estevam , Lorenzo Pieralisi , linux-imx@nxp.com, Philipp Zabel , linux-pci@vger.kernel.org, Bjorn Helgaas , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On imx7d the pcie-phy power domain is turned off in suspend and this can make the system hang after resume when attempting any read from PCI. Fix this by adding minimal suspend/resume code from the nxp internal tree. This will prepare for powering down on suspend and reset the block on resume. Code is only for imx7d but a very similar sequence can be used for other socs. The original author is mostly Richard Zhu , this patch adjusts the code to the upstream imx7d implemention using reset controls and power domains. Signed-off-by: Leonard Crestez Reviewed-by: Lucas Stach --- drivers/pci/controller/dwc/pci-imx6.c | 97 +++++++++++++++++++++++++-- 1 file changed, 92 insertions(+), 5 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index 4a9a673b4777..65b6d1015723 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -540,10 +540,28 @@ static int imx6_pcie_wait_for_speed_change(struct imx6_pcie *imx6_pcie) dev_err(dev, "Speed change timeout\n"); return -EINVAL; } +static void imx6_pcie_ltssm_enable(struct device *dev) +{ + struct imx6_pcie *imx6_pcie = dev_get_drvdata(dev); + + switch (imx6_pcie->variant) { + case IMX6Q: + case IMX6SX: + case IMX6QP: + regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, + IMX6Q_GPR12_PCIE_CTL_2, + IMX6Q_GPR12_PCIE_CTL_2); + break; + case IMX7D: + reset_control_deassert(imx6_pcie->apps_reset); + break; + } +} + static int imx6_pcie_establish_link(struct imx6_pcie *imx6_pcie) { struct dw_pcie *pci = imx6_pcie->pci; struct device *dev = pci->dev; u32 tmp; @@ -558,15 +576,11 @@ static int imx6_pcie_establish_link(struct imx6_pcie *imx6_pcie) tmp &= ~PCIE_RC_LCR_MAX_LINK_SPEEDS_MASK; tmp |= PCIE_RC_LCR_MAX_LINK_SPEEDS_GEN1; dw_pcie_writel_dbi(pci, PCIE_RC_LCR, tmp); /* Start LTSSM. */ - if (imx6_pcie->variant == IMX7D) - reset_control_deassert(imx6_pcie->apps_reset); - else - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, - IMX6Q_GPR12_PCIE_CTL_2, 1 << 10); + imx6_pcie_ltssm_enable(dev); ret = imx6_pcie_wait_for_link(imx6_pcie); if (ret) goto err_reset_phy; @@ -680,10 +694,82 @@ static int imx6_add_pcie_port(struct imx6_pcie *imx6_pcie, static const struct dw_pcie_ops dw_pcie_ops = { .link_up = imx6_pcie_link_up, }; +#ifdef CONFIG_PM_SLEEP +static void imx6_pcie_ltssm_disable(struct device *dev) +{ + struct imx6_pcie *imx6_pcie = dev_get_drvdata(dev); + + switch (imx6_pcie->variant) { + case IMX6SX: + case IMX6QP: + regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, + IMX6Q_GPR12_PCIE_CTL_2, 0); + break; + case IMX7D: + reset_control_assert(imx6_pcie->apps_reset); + break; + default: + dev_err(dev, "ltssm_disable not supported\n"); + } +} + +static void imx6_pcie_clk_disable(struct imx6_pcie *imx6_pcie) +{ + clk_disable_unprepare(imx6_pcie->pcie); + clk_disable_unprepare(imx6_pcie->pcie_phy); + clk_disable_unprepare(imx6_pcie->pcie_bus); + + if (imx6_pcie->variant == IMX7D) { + regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, + IMX7D_GPR12_PCIE_PHY_REFCLK_SEL, + IMX7D_GPR12_PCIE_PHY_REFCLK_SEL); + } +} + +static int imx6_pcie_suspend_noirq(struct device *dev) +{ + struct imx6_pcie *imx6_pcie = dev_get_drvdata(dev); + + if (imx6_pcie->variant != IMX7D) + return 0; + + imx6_pcie_clk_disable(imx6_pcie); + imx6_pcie_ltssm_disable(dev); + + return 0; +} + +static int imx6_pcie_resume_noirq(struct device *dev) +{ + int ret; + struct imx6_pcie *imx6_pcie = dev_get_drvdata(dev); + struct pcie_port *pp = &imx6_pcie->pci->pp; + + if (imx6_pcie->variant != IMX7D) + return 0; + + imx6_pcie_assert_core_reset(imx6_pcie); + imx6_pcie_init_phy(imx6_pcie); + imx6_pcie_deassert_core_reset(imx6_pcie); + dw_pcie_setup_rc(pp); + + ret = imx6_pcie_establish_link(imx6_pcie); + if (ret < 0) + dev_info(dev, "pcie link is down after resume.\n"); + + return 0; +} +#endif + +static const struct dev_pm_ops imx6_pcie_pm_ops = { + SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(imx6_pcie_suspend_noirq, + imx6_pcie_resume_noirq) +}; + static int imx6_pcie_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct dw_pcie *pci; struct imx6_pcie *imx6_pcie; @@ -846,10 +932,11 @@ static const struct of_device_id imx6_pcie_of_match[] = { static struct platform_driver imx6_pcie_driver = { .driver = { .name = "imx6q-pcie", .of_match_table = imx6_pcie_of_match, .suppress_bind_attrs = true, + .pm = &imx6_pcie_pm_ops, }, .probe = imx6_pcie_probe, .shutdown = imx6_pcie_shutdown, };