From patchwork Tue May 29 19:39:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonard Crestez X-Patchwork-Id: 10436839 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 5D942602CC for ; Tue, 29 May 2018 19:41:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C9B5289EE for ; Tue, 29 May 2018 19:41:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 41184289C6; Tue, 29 May 2018 19:41:22 +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 AACAD289C6 for ; Tue, 29 May 2018 19:41:21 +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=JHR/L1my2lG7vD1tlOOTzVtAZm3ytOk2q3J6/CoVhgE=; b=k02AsApNYhfaou QmzxWkJQM6xS/7ih4zgyk9zZTGrhKzWRePZuesbb3zOLmi4GNHohTy4pZP+f84U+375tnbiC5XBAY a7RKI2saXcunBEDre5MXnJRMvGMxfvgO8fGJbzel0kS7CxZptvi+OCpQzRhwgt4e6exFYWR4baKAw eXjThtPsE41W1c6gf0SF5eFTq+XbqbOH+5kPh7oS34L2tEeYZuT/+0Vt0hxNa1hSaNGTEX8D5hzvj Jg23qK+2Ve2+u0TaCvRzjmxRwNnq74jKUgnYBmgdqBNk1qdHf60UIAiikAH2B+rSTp427Rtd41QEn B2mlWK3F3S13z6bIoETw==; 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 1fNkUV-0001eC-S5; Tue, 29 May 2018 19:41:07 +0000 Received: from mail-ve1eur01on0087.outbound.protection.outlook.com ([104.47.1.87] helo=EUR01-VE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fNkTH-0008Eu-AX for linux-arm-kernel@lists.infradead.org; Tue, 29 May 2018 19:39:59 +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=HEvYKzhWM/VTDvJyO1icBvlqqhxn/GcY/tM3hzc5luU=; b=oI8H4ZZaIvAVwD1M0hmJWmXbuTsQfUMk6D9QePJL3KYSxmZXWoDa5TiYY5hTeSBPKPFRPS3W+BjbgxU3CBANerScV0OqTJZmAV47UtnbxdRt7buC5J61tmoSPbz1BsJY9a7DfwcN0lMmdzKlJerCXFHp/0KOkam9GXZ7assNLMk= Received: from localhost.localdomain (95.76.156.53) by AM0PR04MB4289.eurprd04.prod.outlook.com (2603:10a6:208:67::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.820.11; Tue, 29 May 2018 19:39:34 +0000 From: Leonard Crestez To: Andrey Smirnov , Philipp Zabel , Lucas Stach , Richard Zhu , linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] PCI: imx: Initial imx7d pm support Date: Tue, 29 May 2018 22:39:17 +0300 Message-Id: X-Mailer: git-send-email 2.17.0 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [95.76.156.53] X-ClientProxiedBy: AM5PR0502CA0013.eurprd05.prod.outlook.com (2603:10a6:203:91::23) To AM0PR04MB4289.eurprd04.prod.outlook.com (2603:10a6:208:67::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:AM0PR04MB4289; X-Microsoft-Exchange-Diagnostics: 1; AM0PR04MB4289; 3:a+xDXzDj8A14zsQVAIo7GcqBWnOHJp6aG/CsiSRvQAkLgWpOvbnhOYkRLYkBNPdTisgGXpnD/Nm/tylh1WAg3zipw2HQTNGOziyNRvQ4eOT1pZ+kSMIQWMbs0xyBnFTC4ZyNt1wPXRGaMfmx2OfS7s0MUphNFgIt4ODfprqkIlBqzrVOr8lsupbrSx4RrYefjN4P+nrPxyEmaz2cLUebQX/UvjXAIlejzfmwJ/k8X2lXnnBwB5geGeUIaqzNC+Xj; 25:UT3mJussJXL8ImLoIdeSefYkN0RRM6opnnagwsdXlo7mtP8N1x0/hcCWIzI1vY8WEUSNKsnww6eTyWWoRYsTVlumKuYcZNp7cCfajnnPA07fQ6RJXfpMi4fR+SxXHjWD9D4xeDtZHFlCWXbduI9uk2Py+tFCvO6et5Ig739mHrRGRj6hm//Z/dgh4ntYHJfjoDZkJNlgKHTOGWT3MEfd0E+5pGmaLdDSPqKSkHdNMSkm5/LmqAYq1oJLDJfZ+sB5dqe7c/q02gJsn6LFPcph1w0HkXivxo07VaS/ZQUs3eY5zSZHecQO2vUpgJA6MwkSJy/5ppfoy+ujznB0cXk/1w==; 31:NMHdNgo0JSO8fMYyYvmTuioYX9zk4+cSzH74BitvSqlP1+n0jrBQ+yhE6EfnlGHY/dC7InRvTUWg+lg8oArjeweL6mjQM4ByWwlmysLmTxH5yvKw5GxdSaiQm4whjV5OM+v9yTTUkKaMOZ1q2WKraGr0vCOjrkTAvFRbOyp7NPvMgGBJlIgGu2UEAjaV2AmFQzUeUaryUze0sf5crkq7Mp2eQBbugVPczLfGW7loPP0= X-MS-TrafficTypeDiagnostic: AM0PR04MB4289: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=leonard.crestez@nxp.com; X-Microsoft-Exchange-Diagnostics: 1; AM0PR04MB4289; 20:sQtrk9fDYNUnaGY5+iTSnivDUMygEuGkJsv/Bn+3UW6uKO1wSen3eNvMNPvS5277BOD+hZfioNzyc4hHceElnB5MDAEThnqvLcI6ZmD2rAD0fgTIzfjKy7lTpZkwAjlZFLOB9Shuf40ptTfJ5+oc3pXA9J/FMc9KK2HfRwzhtfLklV/Ynw5NeN/lo8kGPObGTXB6YzW+iWbex89OYfzhrJYUqFWCiM75Rh9QYrkk+eBIFq6c86hV5teKvq0xu1i97a3Ze0dkvJaU2kd/6iuPt5TDFJkyUa2YwjMpHdxdkIviEReAUq4iXI5Oakbv3ofsFa7iAtUrNgh+jpbwgcZkE19kVJjnCB1ZUEqRn1/Zf9YN/8jrOZeZcE+CplkRSn8ghmTx/bB7kUBZdg38Xr2A061DtooJDeEgsc/GpYA4RYQz+2wb5K0RPCVp9wIWuWNdmeIVMYqwPx4mye0OP9kjNW51rPft4vGjVFvmV5co/c9wttiIXuKiHapvdQvpJj8D; 4:giVEFdn71F3IwMlR9EVTJGGFY7rTTpImVePMuDGkB0dejINhZngDCDczbAcxw407k2mD/eGwQrjoXH15SZkQ3JuswCQpKvSDzAjbP67VIknIifyiuqU9ykCQJx6O57G1X1p/xGwY4nwHlW6znN1wzHC2X91xfUDuQKeG6P/C492HmK9IwA1tXUWzMTwUgdw581TVVh/8oaNbkmGiB0jQhRlD0T6QJlYy80t8vsU9Hv/dnYqReFbCZLcA1/Cn7NODc61L9PjJIkJv7cA7HoJgbYzbLsJ+XpennPqmo/7stajp2Cb94Og3uDuD2T4JlYjw 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)(93006095)(93001095)(3002001)(10201501046)(3231254)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123558120)(20161123560045)(6072148)(201708071742011)(7699016); SRVR:AM0PR04MB4289; BCL:0; PCL:0; RULEID:; SRVR:AM0PR04MB4289; X-Forefront-PRVS: 0687389FB0 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(39380400002)(396003)(376002)(346002)(366004)(39860400002)(189003)(199004)(2906002)(3846002)(50466002)(16586007)(48376002)(59450400001)(8676002)(81156014)(105586002)(106356001)(50226002)(476003)(6116002)(86362001)(81166006)(118296001)(305945005)(7736002)(8936002)(44832011)(16526019)(186003)(66066001)(486006)(26005)(54906003)(76176011)(36756003)(110136005)(6506007)(386003)(52116002)(11346002)(47776003)(51416003)(446003)(316002)(4326008)(25786009)(6486002)(956004)(2616005)(6666003)(68736007)(53936002)(5660300001)(7416002)(39060400002)(6512007)(478600001)(97736004); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR04MB4289; 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; AM0PR04MB4289; 23:NMA5MtGSrISvgVXiTo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JyxrSdrqI8SSoHbVHcKIA+KvFFUAGze48IbIv16zhAVjH1OQGgfMoEng0uz43yWelmBsDsm85ze4DwwcEKHMTVM4R+n7zqt5+jAizDUBMSQw0a6ti9VLvvn6SqBu53Nftr1XTOONV2iGv/PkTQOHr/eNXDcSYea+/wfoW0KKUGqAHvWNdXdtpKLpiXXiIS0L55nrFD9f4XFw==; 5:NfBHyxIwpKB9wb5nL8LPpk/XVavLEZY92U83eOL8FbhKUwdBREJGNfubOo9964iVtWyxtRstVC1zfXF9eMPich12KMYM274WgwwH8C/RG+qtbat6s/G7qUlB/0HvMmeOZRhZ1dFUbvOFmhdQfJ1G4pIwPh1GznKIJB0ckAJp+BY=; 24:0HXY/rKfQiwRjxxkLJiogIrHIupGrtq5rDt8gzZwo9vJ9D3L3ZmFd+IRDdVlLmKV6U4LClKHFM4LZRzymzqxim1ikSvjC0QZJyLC0wNIec8= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM0PR04MB4289; 7:HwJ+aCDUUDPYeuRsLg5Tas/Mj++KJLBwFm+T3jW/Am/gwNp/MYgAlOT9w5NN7e+L67/ezKYqnHMNYTn/UUI8dVHW4DGhJiuYtAAA+VZO3XBuxNTvyWutIO/M5pMGdaHZftHqHdZD7GXrIbwkhKGBvmp+hKpUdA1LT0rn9o9ONvlpHk9u6s35hfF0cjeWb5Q78hkZO/gy1zJFEeSsEXAmZHREZbwh9EpYIcfES/GiqasBUEQCOTr70XpqkGD82rKA X-MS-Office365-Filtering-Correlation-Id: 553c5012-f858-4751-bf41-08d5c59be863 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2018 19:39:34.5362 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 553c5012-f858-4751-bf41-08d5c59be863 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4289 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180529_123951_399814_6F2EC59F X-CRM114-Status: GOOD ( 18.56 ) 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: Joao Pinto , Abel Vesa , Anson Huang , Jingoo Han , "Rafael J. Wysocki" , Lorenzo Pieralisi , Bjorn Helgaas 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 phy is turned off in suspend and must be reset on resume. Right now lspci -v fails after a suspend/resume cycle, fix this by adding minimal suspend/resume code from the nxp vendor tree. This is currently only enabled for imx7 but the same sequence can be applied to other imx pcie variants. Tested on imx7d-sabresd with an Intel 5622ANHMW wireless pcie adapter. 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 --- drivers/pci/dwc/pci-imx6.c | 94 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 89 insertions(+), 5 deletions(-) diff --git a/drivers/pci/dwc/pci-imx6.c b/drivers/pci/dwc/pci-imx6.c index 4818ef875f8a..ff6077eeb387 100644 --- a/drivers/pci/dwc/pci-imx6.c +++ b/drivers/pci/dwc/pci-imx6.c @@ -540,10 +540,27 @@ 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); + } +} + 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 +575,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; @@ -681,10 +694,80 @@ 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 int imx6_pcie_suspend_noirq(struct device *dev) +{ + struct imx6_pcie *imx6_pcie = dev_get_drvdata(dev); + + if (imx6_pcie->variant == IMX7D) { + /* Disable clks */ + clk_disable_unprepare(imx6_pcie->pcie); + clk_disable_unprepare(imx6_pcie->pcie_phy); + clk_disable_unprepare(imx6_pcie->pcie_bus); + /* turn off external osc input */ + regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, + IMX7D_GPR12_PCIE_PHY_REFCLK_SEL, + IMX7D_GPR12_PCIE_PHY_REFCLK_SEL); + } + + return 0; +} + +static void imx6_pcie_ltssm_disable(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, 0); + break; + case IMX7D: + reset_control_assert(imx6_pcie->apps_reset); + break; + } +} + +static int imx6_pcie_resume_noirq(struct device *dev) +{ + int ret = 0; + struct imx6_pcie *imx6_pcie = dev_get_drvdata(dev); + struct pcie_port *pp = &imx6_pcie->pci->pp; + + if (imx6_pcie->variant == IMX7D) { + imx6_pcie_ltssm_disable(dev); + + imx6_pcie_assert_core_reset(imx6_pcie); + imx6_pcie_init_phy(imx6_pcie); + imx6_pcie_deassert_core_reset(imx6_pcie); + + /* + * controller maybe turn off, re-configure again + */ + dw_pcie_setup_rc(pp); + + imx6_pcie_ltssm_enable(dev); + + ret = imx6_pcie_wait_for_link(imx6_pcie); + if (ret < 0) + pr_info("pcie link is down after resume.\n"); + } + + return 0; +} + +static const struct dev_pm_ops imx6_pcie_pm_ops = { + SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(imx6_pcie_suspend_noirq, + imx6_pcie_resume_noirq) +}; +#endif + static int imx6_pcie_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct dw_pcie *pci; struct imx6_pcie *imx6_pcie; @@ -847,10 +930,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, };