From patchwork Mon Oct 1 19:53:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonard Crestez X-Patchwork-Id: 10622709 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-2.web.codeaurora.org (Postfix) with ESMTP id 58D016CB for ; Mon, 1 Oct 2018 19:54:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 43E0528449 for ; Mon, 1 Oct 2018 19:54:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 377EE28470; Mon, 1 Oct 2018 19:54:32 +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 ADB8328449 for ; Mon, 1 Oct 2018 19:54:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726665AbeJBCdq (ORCPT ); Mon, 1 Oct 2018 22:33:46 -0400 Received: from mail-eopbgr80058.outbound.protection.outlook.com ([40.107.8.58]:27854 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726616AbeJBCdp (ORCPT ); Mon, 1 Oct 2018 22:33:45 -0400 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=LE02T3NF0OMwiCd3gGCJzQo6so1FKO2ay4f+uK6vp90=; b=HYKCGtAmwW93lyQFz3aR2jxTbQKxMWjuEYPZlszoHwebAd+9gp2wZiFbye5muut1ZTfMRME/8nebYFl35hM3gTrDpsNgTTM5QiHv1uFBsHTeVY/+eKfabfOFtiur7rqFsYYxl2Zv/osmYuRbHxD1tjhCP+1ePXl9idYNtqdJV8Y= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=leonard.crestez@nxp.com; Received: from localhost.localdomain (95.76.156.53) by AM6PR04MB4293.eurprd04.prod.outlook.com (2603:10a6:209:4f::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1185.22; Mon, 1 Oct 2018 19:54:12 +0000 From: Leonard Crestez To: Lucas Stach , Philipp Zabel , Richard Zhu , Lorenzo Pieralisi Cc: Andrey Smirnov , Gustavo Pimentel , Jingoo Han , Bjorn Helgaas , Shawn Guo , Fabio Estevam , linux-imx@nxp.com, kernel@pengutronix.de, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] PCI: imx: Add PME_Turn_Off support Date: Mon, 1 Oct 2018 22:53:48 +0300 Message-Id: <1cf53d188657bba7df06ad417eb2a65160238196.1538423063.git.leonard.crestez@nxp.com> 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: VI1P194CA0013.EURP194.PROD.OUTLOOK.COM (2603:10a6:800:be::23) To AM6PR04MB4293.eurprd04.prod.outlook.com (2603:10a6:209:4f::31) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 385222db-8617-4c5c-67de-08d627d7a943 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989299)(4534165)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:AM6PR04MB4293; X-Microsoft-Exchange-Diagnostics: 1;AM6PR04MB4293;3:kMwniy2bcErImPN5gz2iQMQoMgSxex9vdvZcIbbV0/co9cGyaeJMvg68mV3Yy3iJ6KbSnw6JcjC5vQPcMA/3P9Zd657EzECM939zjMov3g4isHSQ3coQjxYrXk/6Z58iTOpIIpb0IjJG7hwcfafzC45oEu8nF9X1l476mRJr/N0j4iXR1tt2NkxLb1WpTSngJJNzzm3mngJrRHGMIzMm+xImWUoe46IZutpTb9EoCTBbybPHBslWtVNXjKrJ1HxI;25:qFB/tQoEkDdrZ4yyoSfDp1vaFXmnnSdDMUmgAt5/AchE6y6kriPm/1X75ljFe6sc3HJ0nm9194N8HhvgqPy5XAncP6JSrZhZCUzHiok3kz9zY4WmIV/GRIUS2i2IKLSARXhV3u8zOHLrajRltYZ6U5D0EnArh4jgJyKfJtA+e4u7XcZyCwtvU/BxMmrUor+K9vYoamPRA5Hd3SsS3xQmlGAZktVdW+fQJ94QcFsAm1b1Xqpnxs03vdsnzN1+8/kZ5sI8kuYEKt0He1YlmJLyB7e1JltSalhf0kuubzwF+sxQfhPowKabnWTQCUsuJ+d4D2lZSTIxRm8jw5rlk22anA==;31:yNwHAxHrxs/VS/ZSjttTivxhFl7nf22tg1gOTzPAOkVPcqUDeg5sOMDci0ZjhWm3gF8joG5AGne+BoiANuw4UQ5mPh/OXCW2kXNY7aI62jL27SVkMQZF+aXuND6aiMs2ID7SCU+YtS79XR7Vu5APC1n/RrGAn24lF+2ithtsdcGPfMfR1NoDPpxbfnIfiQIDL556kAFAgw6IuqwcoC8iAaWKcOfH23qme6U8nYuckP4= X-MS-TrafficTypeDiagnostic: AM6PR04MB4293: X-Microsoft-Exchange-Diagnostics: 1;AM6PR04MB4293;20:gkTBm1PycUGQNAZE6B6g4OQjr+KO8B3JKUzJ/It1K2leqnJy5VfZwDmjfmr73BBXzics9RK/GI3b1nJzqlSNdmfhklswKeucvenS4nxTGUq3Bup0I2mbcaDDJ9qRQbLlBIxhOvNvvWP5UJUwhpOGoege9BvHYZHe7YYC9QMYXWghd0iViDDJutNqPkWgdSFLzp3onw+6pbLTXWUDFhvjUrrslTs9427EUi6c2VhzyeeKvpp5UXB4MRcdfQK9hDeGw/oLEBmKMvyNWkSwwlnt1Ss7prcDKwAKf6jk1CWpC/rzRyYUOQ8hIMZbVlAF7uuEZ+284v6UtYBaraNMVraeFaF4qUZ7voYz0LK0qEQydSrX0eHauemmUEb0jWvdrQU44y9LH/lMhtkRIKp9ezN1JZmnkiL5HnPubBwDxlfJBVU4Dkiqxq7JQRmBDazSlpvNU8fAWHozAWxqn337rPPf4ZBDBA7S5xZo67tCN4qJT60nyegp16xTG7t/hkshAXhK;4:JcofM1w2zG+a+ruez0XErVIRFidEIWRjREfatCZDSboOXW1TWXEuOKiFe/s1q4N5iCwsUhRB08BWYkskAlCzX/3IBtzduG3+L7ASDWr4Jm6W8Nzj5qYGsTeRmSSBVhdo83BBZSdsylNGBFRxDhxVKgg4wPZgHWYe4weB6/T4xSSvLZCMHm4G0NMcmcLcbO2y09vJBBzPW6s+l1zbDvLXfpmQYv1xEDxXd6K+ZCP5Q3VtOxrIx8tPXum47nMn0KigH+3UFip00bZqqJOEvK4Kyc/8kWLfgRli9pFhy3M/RIUPoYkZeNhp1f3cY4xohJ8C 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)(10201501046)(3231355)(944501410)(52105095)(3002001)(93006095)(93001095)(6055026)(149066)(150057)(6041310)(20161123558120)(20161123560045)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051);SRVR:AM6PR04MB4293;BCL:0;PCL:0;RULEID:;SRVR:AM6PR04MB4293; X-Forefront-PRVS: 0812095267 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6069001)(39860400002)(366004)(346002)(396003)(136003)(376002)(189003)(199004)(6486002)(7416002)(110136005)(54906003)(118296001)(6116002)(53936002)(6506007)(386003)(3846002)(11346002)(478600001)(105586002)(16586007)(7736002)(50466002)(6512007)(66066001)(47776003)(25786009)(956004)(486006)(305945005)(476003)(48376002)(26005)(2616005)(51416003)(52116002)(106356001)(6666003)(2906002)(39060400002)(97736004)(16526019)(186003)(14444005)(76176011)(446003)(44832011)(86362001)(5660300001)(50226002)(68736007)(69590400006)(8936002)(81166006)(81156014)(36756003)(8676002)(4326008)(316002);DIR:OUT;SFP:1101;SCL:1;SRVR:AM6PR04MB4293;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: 1;AM6PR04MB4293;23:Xth8zTxM+7cihlgt7cNZhiqR9uXoQkBpuYdPcO6knMVMPep9Mnc9+QussgVgVc5TWG+vHQAvsJGBx/yt+F0G2U2nvAK29tOebrtg+wruvYp4QGmTDfr8CNfcjyORup26pXZf2bfZCUkxQ++255W4mdYS7K0Xvw5Kdj8Hx5ukf39ss1/w7OWsj/VJYGg6+nB8vJBmO1w/LkHdiO5iVwKDtv92I1b4DMW3F9gVZAGn7qYJZkRTSSTO9V0yKBG4vEgbB0RhAWOrOjQhNqRq0oZtSYvFm5YYLnSILPQuntBjS/A5WD5MlnZAbQufHoZsXYnV6mXpYroKnbQ+QC2HO2cLOeC2S+Zc4eIFXi7NWEscGqodAEg5EcVfRX8RnRy1UNsrALtZxVOlgumr75pFkrnyk9azeNAe2jAl0wsImefW2D2EQej50iwogTjg6fgUmE88Z1s5W9daHMUaQ91OpO7OOs/MDjvf8Qj36gAmvLICqCXd2xY9j4PK3Wb9Io5gPpQFWGnn3t1wA+FEUCry0L+qbplEmT7HX28sBxQgefZC9qOXyJ1aPLziazQLO5AFME5wNyT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-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Oct 2018 19:54:12.1816 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 385222db-8617-4c5c-67de-08d627d7a943 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB4293 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 When the root complex suspends it must send a PME_Turn_Off TLP. Implement this by asserting the "turnoff" reset. On imx7d this is functionality is part of the SRC and exposed through the linux reset-controller subsystem. On imx6 equivalent bits are in the IOMUXC GPR area which the imx6-pcie driver accesses directly. This is only for imx7d right now but it's deliberately implemented as an optional reset, ignoring the chip variant: * Older dtbs won't have this reset so it will be ignored. * Future chips might also expose this as a reset controller. For example imx8m (not yet supported) has the exact same PCIE_CTRL_APPS_TURNOFF bit in the same location. Signed-off-by: Leonard Crestez --- drivers/pci/controller/dwc/pci-imx6.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index 6ba16fd1373c..13cb1a200442 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -50,10 +50,11 @@ struct imx6_pcie { struct clk *pcie_inbound_axi; struct clk *pcie; struct regmap *iomuxc_gpr; struct reset_control *pciephy_reset; struct reset_control *apps_reset; + struct reset_control *turnoff_reset; enum imx6_pcie_variants variant; u32 tx_deemph_gen1; u32 tx_deemph_gen2_3p5db; u32 tx_deemph_gen2_6db; u32 tx_swing_full; @@ -812,10 +813,16 @@ static void imx6_pcie_ltssm_disable(struct device *dev) default: dev_err(dev, "ltssm_disable not supported\n"); } } +static void imx6_pcie_pm_turnoff(struct imx6_pcie *imx6_pcie) +{ + reset_control_assert(imx6_pcie->turnoff_reset); + reset_control_deassert(imx6_pcie->turnoff_reset); +} + 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); @@ -832,10 +839,11 @@ 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_pm_turnoff(imx6_pcie); imx6_pcie_clk_disable(imx6_pcie); imx6_pcie_ltssm_disable(dev); return 0; } @@ -959,10 +967,17 @@ static int imx6_pcie_probe(struct platform_device *pdev) break; default: break; } + /* Grab turnoff reset */ + imx6_pcie->turnoff_reset = devm_reset_control_get_optional_exclusive(dev, "turnoff"); + if (IS_ERR(imx6_pcie->turnoff_reset)) { + dev_err(dev, "Failed to get TURNOFF reset control\n"); + return PTR_ERR(imx6_pcie->turnoff_reset); + } + /* Grab GPR config register range */ imx6_pcie->iomuxc_gpr = syscon_regmap_lookup_by_compatible("fsl,imx6q-iomuxc-gpr"); if (IS_ERR(imx6_pcie->iomuxc_gpr)) { dev_err(dev, "unable to find iomuxc registers\n");