From patchwork Mon Aug 21 18:48:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13359750 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 512F9EE49AF for ; Mon, 21 Aug 2023 18:53:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229503AbjHUSxO (ORCPT ); Mon, 21 Aug 2023 14:53:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229483AbjHUSxL (ORCPT ); Mon, 21 Aug 2023 14:53:11 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2053.outbound.protection.outlook.com [40.107.22.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F03EA6972F; Mon, 21 Aug 2023 11:53:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NkAyrWjLbjvC+EOpxCzhLAyGhoUybmCVfxHvP7D5sFzCb6DJEdsflPo1dm3pMmuTqPdx9gN7erOuX9IgTtAE5hZr0D4LnrAp7b6wqLqpX0V7nT5gr4+Q6V0SAsEZzIv5kmKf2YDmatddjG1OcbmuyHoxu8a947WX4NLfuR5LnjIMDgPyHX6xX3CRfVprbdYvaYz1DQrNNQBVQDio/1Klv0L7yqTiOgWpfZodP3qA7x2ckk1slbUV2C6/E4ByM2Q/YA5uyGHKfgdgR4OYVPDY9QDqYmfJp68T+Jhs2YUCGRoXdmYELBb9WhMglNVB9Fi9OMcl1+YUpk3/c2yr8FgbdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7TNgc5ao9HIIj+lcJX6KzGjS/yWAIN/MaPR23drMKgQ=; b=apQwoZrsiQwrtUAMskTYN31xjjL1mGqFe3TURXQpX24k7IDxM58hKDfZjboZbhQowrTrI6WChDGSQMUDP1VckJoFa0xtQoQdvpf0pw3zjxPy48t5T4rgVfugq669blg1sthkkrAm3bY5hfpm1oZezM961/qdGZsLPT7tD4xamZ1MGy5jKKZKeSgNdyX5jWadaxUEQjDPFnNSMuOS1Tqoi3rVvV9kdYBcE7Wg32OtPRnzX2wNhFi0qMRQdD3zZwwZjccFQH9fLvWbPpAoB6bRItp6urukZt5GexGR0xKMaC3Y03djU+4EznXDjXWca9+ZC/vvFcPlEuwDFHjZcgMdSA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7TNgc5ao9HIIj+lcJX6KzGjS/yWAIN/MaPR23drMKgQ=; b=c0Eolldy2eeYFcIVwyu9l1cc9vkZEjAkhGgcnH6yBOvem+UGGlzdFMt9BOJREPIAUYIQQqhh14K72RbclahjNIyUNN4hN/S9R3m/VO6G3AbQe/Un6/h8JpLFtOx2BGWCw76K/raCsGAd/PnrsJAUAHW55Ksee6LSZZsCgM8zC+g= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) by PA4PR04MB9566.eurprd04.prod.outlook.com (2603:10a6:102:26c::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.20; Mon, 21 Aug 2023 18:48:40 +0000 Received: from AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::a680:2943:82d1:6aa8]) by AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::a680:2943:82d1:6aa8%3]) with mapi id 15.20.6699.022; Mon, 21 Aug 2023 18:48:40 +0000 From: Frank Li To: frank.li@nxp.com Cc: bhelgaas@google.com, devicetree@vger.kernel.org, gustavo.pimentel@synopsys.com, helgaas@kernel.org, imx@lists.linux.dev, kw@linux.com, leoyang.li@nxp.com, linux-arm-kernel@lists.infradead.org, linux-imx@nxp.com, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, lorenzo.pieralisi@arm.com, lpieralisi@kernel.org, mani@kernel.org, manivannan.sadhasivam@linaro.org, minghuan.lian@nxp.com, mingkai.hu@nxp.com, robh+dt@kernel.org, roy.zang@nxp.com, shawnguo@kernel.org, zhiqiang.hou@nxp.com Subject: [PATCH v12 1/3] PCI: Add macro PCIE_PME_TO_L2_TIMEOUT_US Date: Mon, 21 Aug 2023 14:48:13 -0400 Message-Id: <20230821184815.2167131-2-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230821184815.2167131-1-Frank.Li@nxp.com> References: <20230821184815.2167131-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR05CA0022.namprd05.prod.outlook.com (2603:10b6:a03:33b::27) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|PA4PR04MB9566:EE_ X-MS-Office365-Filtering-Correlation-Id: bc7f1b63-a032-4261-9d23-08dba2773c6a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wjuLi8NoeFIvxEHsNaXWrpuRqBF7s6/MNJgscPWc7o/+zPEr943kUoCT7YytEbMhKN2aKpOsHYiPy7vH7WUFrCFTzbuUIljh2vG1WreqOBuPt4DTxcfZ1ESNSqxc2+8D6rcCO5xVKf6Az+pQVejZr3kfKrevB8zbYMHi9CT7lvF5crAG/NDeeZlLCKqFyQM2BpdocWTQpUPCo7DOgYjaWopO0m7AUi132Ae72CGUPel5nrKSHt+0cp6u/5Bl7iDDJOHsjtrY228GEivBU5hW+13TflSixGIvg9ldCLOEK4ldRgaRkE33wweuuPbvRoBLg96Zkm5Vn+B5/roE8SpYV9vrlq7AruA6fkdpAfV4n5wJtO0jMgs3rbbCHlssxpv4NpLgYJe9fl529QzfI8YM+L6I+fHOg1wMA71TBguY9/KBcwvq59+iHferF05W4K/PpG8nXmBr+0Hda+elrl5b0zmx7im7bz/auoheNS3aNUwK/9z8FjjtpuM3kILfw0RIY+e0gEcNw8gmjElmlHEmV0NL0Uo8PA42Tw08ocHUC7ebfSxEtIPlAz/I+mm1PSBjhPIkXjldpFUu+5c3FROjiqRZfAmFco3XFeeTs0jGZkL5RujOxrAcbiS5xRW4w6xH X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR04MB4838.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(39860400002)(376002)(396003)(366004)(346002)(186009)(1800799009)(451199024)(86362001)(36756003)(478600001)(66946007)(66556008)(37006003)(66476007)(34206002)(316002)(41300700001)(38100700002)(38350700002)(6486002)(26005)(6666004)(6512007)(52116002)(1076003)(8676002)(2906002)(5660300002)(7416002)(6506007)(4744005)(4326008)(2616005)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: i+5IkvLxi3o87fU1o6TCdNGe7+RHNya6n3+4FJib2PGizJ+atbYVprSnwXBtIWKPeIsck3ehNy66CI3MkzK9I/TZsmn7KrLfuTDpIIYBEMKDLkZu3oXUiamoYM0bMerefoikwnapJlm/Ul+uTxqbs13Il/NJF4W1RKxgfyfDpHrVELBnRIf0pgZv988EPqNWMNRL2aNJAag58LgmXFO6czLOu5VoGJymZTX6ML5A/KyjzUsD7TtXgBXSWI1jTV9eLUxYbtV9cKdSb+WRgksb0kOX8BYm40XJs2ZmIHg+1hdiGGzsdDrpCGESjrVgZNRD10Fec9XAwR/pLtVLeSqPzB9QdS5rNSLGW9iuMDjlqQdtsaUgVIC1vKEGVago8+Fww0wbRnFObapumejQ30BgGMi/9KdXTFbNjvM3C3uaopG31Mr13IN5rqGSzP6f0ax7IbV7Ryfe8tLR7pqZtnTCy7E3itA6N8BZS8YOGsfD110YXdV4r2ZeCrLPVzUUsHQpCsy2GBZKBnmH4QnSKD5tE1yQM+220FOwxZ/hpf+qnaP8qB4LsHf8JQrXkzRF+avWmcfcqPKU611BDNYQUmw42LOzYjmuvEaaeLCdoPrscGvjiU1j/5czzl21fsbPmasOExcd0HCptyOsYU30HQn0SqKuUleVscwt34byiPGWzt/NxE4abQV40dJ/5U1onfsm1jm9KOkVYphRndt/j2eG7tExFZC/xQI32QwmG21xjgbSXC+t55HKZKWUZswXp32ruCkI+6CTrffxkdBXEj7iXBLQFgl8YqA4uCd07Oik44sQ5gBkWRxgxAzbHUwONf8Dll1gwUSP1sKpQUcHNt4XDk/kqHF3W4HIUyVupaaX1UtdVAPzIjSfUWR1xX2ySLVJ84ym5WAa4G8G8guwg/5XWO265tlwWrGnDeQYUSGOShCW2/MbHnLY87Opu4a5A/CZHImlbZE1IZpVPEve+E23+KSoDs3kWJBHqSk3trwXs1vWeN+J0Uc092ST4dBoYaeI/2Atfw+CF/lgyKqjRdyXlIrFtrS/Hg2Ld0xBjuHHyaIiDQgvIcAw8Iq3ZRaDSXBgge98GaqVIuCIlTXknDrSVdLTI6tGgNKTsLELOPQYqk+lPv1aXbGd8L+gbmEdklfsjOUR/QfPIgtKj5KEg24RsGhKYHKdg61WePZpMomqf2+mT22NslQU22N8aWHMKdQqhXDKhGiorvIcEBLe5MAM6wLzhrh4P2O3abc1Esqnm9Yi2c2a+JdElS7wvR5mgK+2IwvYOP3qIpOlqISlXLMSMzC1u8Ltl/dT2RbZRl6DbuTg7YZyvBRWzqTmTIfM8N9ZZ3410VYEMFeGRi0qacm0CzUsXxr/M1tj1BmFSY2P8s+S9nHAm2k9HmYL1MsxES3W+wWszcaba1r727Ee4eed/zh/1fUzwk+HzgyQul8Wnatdx/ux42JCNyrNCObhRYsozTIimGJfu5T1VUX3HOL+5+WYlFd17bkg0fb4dP2HfAuxgBzl+55wM+Or4cSSrdhWHIqYIcM2UngVHoEFHp2rSZOWovCcdQYIZm+Sicydc648bk0kB25j8Wm36/WSi4vO X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: bc7f1b63-a032-4261-9d23-08dba2773c6a X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2023 18:48:40.4820 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: PBHBw9kfx5FkX9mBj6/ix+BsiAcDoOs5K6YDQ8gfzLkTmhrjDZw/quKVoxZjXNKkE4DBh+wxExA/W8lFtZU4Wg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB9566 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Introduce the PCIE_PME_TO_L2_TIMEOUT_US macro to facilitate checking the L2 ready timeout in the PCI subsystem. Acked-by: Manivannan Sadhasivam Signed-off-by: Frank Li --- drivers/pci/pci.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index a4c397434057..da8156663c82 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -13,6 +13,12 @@ #define PCIE_LINK_RETRAIN_TIMEOUT_MS 1000 +/* + * PCIe r6.0, sec 5.3.3.2.1 + * Recommends 1ms to 10ms timeout to check L2 ready. + */ +#define PCIE_PME_TO_L2_TIMEOUT_US 10000 + extern const unsigned char pcie_link_speed[]; extern bool pci_early_dump; From patchwork Mon Aug 21 18:48:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13359751 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7D86EE49A8 for ; Mon, 21 Aug 2023 18:53:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229437AbjHUSxO (ORCPT ); Mon, 21 Aug 2023 14:53:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229484AbjHUSxN (ORCPT ); Mon, 21 Aug 2023 14:53:13 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2053.outbound.protection.outlook.com [40.107.22.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82D176A24C; Mon, 21 Aug 2023 11:53:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O9ae8hjFC9sL8BwJh3d6z54P1AUUU2XruIdtkAZzEotFLpqYJmHGbydM6HPahUhnKAPWyV1kyhvtLK39NctUSJbnJzrSWfB3OgQ5HEanb04OfBjds5akFBwR5r02vfhGggX6aU8PPvISd+tlwMDnk6ri7mpIPczzPFRZ+fNwhrtB1TFXysJm5EoPCglDY94JdPE7JVKpSYJQ8kph2DV750Mjv2x7gTzEcbk0KTzKoORuw0Ugqa7/27E9Mwoc4RgDSkv/c6433OJHSoj7ulhoUHM0xdC3EuLaInJ8Lf1LrFxYGPZcBmqTawJ41m3uJCS00IgM9g3JVW4spQTRtvejGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=OHMaH/4kxsdx1QZ/NpZYByEUDHKdk1r646t1LOIrrS0=; b=b8YSEeN+sOY4CAQb+8+5SlRkRioh1YMatfADLknXjMUAjDmzLDE6rOOFLeJKoTPmmogpAhPr+MmarZxdbhp3YYGK4oyi1MH3KQ7K9x1FMx8CF4UwowudByiGtkGnNtYYNVa1t0uHkQXL07uIY9w8E8ptmzH0VUrizrvX2p2rg92XlTKUST//2/uuUB4lTlbJgDjM1MdEGMt3mHLUt/s48F1JKx4rWp8xANkmqbmdSxWcvHFR0Qjo2wQUy5Vekerq8IPbcroIrlFTBsAPNqPzkhbBNFhxheAwiZAAE0L94orfhhTvTCKLGWRDsiryPkjL9Lhi9Tq3/wJgkm0enCYKJw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OHMaH/4kxsdx1QZ/NpZYByEUDHKdk1r646t1LOIrrS0=; b=RNpaflWYPRjiOIu4cz6/EyemLkQM40408DsqlHRiYbIVawUhf70WC3BDmb+3KzRVqxQUE0LMjU5tVHPy1GmvaR6ELmwMshYA49udYovKXLb3OVFNEUs5vBdr4AmR0w6AXP35IxsmJX0Rw/2dGuasLDE+6mZG0Z+SiICwyl0b6Cg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) by PA4PR04MB9566.eurprd04.prod.outlook.com (2603:10a6:102:26c::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.20; Mon, 21 Aug 2023 18:48:45 +0000 Received: from AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::a680:2943:82d1:6aa8]) by AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::a680:2943:82d1:6aa8%3]) with mapi id 15.20.6699.022; Mon, 21 Aug 2023 18:48:45 +0000 From: Frank Li To: frank.li@nxp.com Cc: bhelgaas@google.com, devicetree@vger.kernel.org, gustavo.pimentel@synopsys.com, helgaas@kernel.org, imx@lists.linux.dev, kw@linux.com, leoyang.li@nxp.com, linux-arm-kernel@lists.infradead.org, linux-imx@nxp.com, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, lorenzo.pieralisi@arm.com, lpieralisi@kernel.org, mani@kernel.org, manivannan.sadhasivam@linaro.org, minghuan.lian@nxp.com, mingkai.hu@nxp.com, robh+dt@kernel.org, roy.zang@nxp.com, shawnguo@kernel.org, zhiqiang.hou@nxp.com Subject: [PATCH v12 2/3] PCI: dwc: Implement general suspend/resume functionality for L2/L3 transitions Date: Mon, 21 Aug 2023 14:48:14 -0400 Message-Id: <20230821184815.2167131-3-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230821184815.2167131-1-Frank.Li@nxp.com> References: <20230821184815.2167131-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR05CA0022.namprd05.prod.outlook.com (2603:10b6:a03:33b::27) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|PA4PR04MB9566:EE_ X-MS-Office365-Filtering-Correlation-Id: e6a28ce1-2525-4939-a2fb-08dba2773faa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zteWQFNeeWZTKCyvDvcL6Obg5nN1+reMlEwsnHmiZuDQR72K+I4VN4vkXLPvPPBs838WIZRsuh3ukoaLfC7+JfWeJDPaSey3zbI6wRnPSFIJlmxlrKd3BykY1Oz96dNTwiLMKxoipapQ7uLPTPmuMxGFGsheW994H7nHYkIZO9qvBvDLwVGKL2aZ9UtH9qldGgdyFdR20RExaxuKm7HyZdpWi3u7ifFTMOotyMMxcqFFcYMH+m0fXefWUc7nGTRpQEu/ioitFkXwqR+GXGNX3KtTF/eScBaep43I6fGA181AUa8a+uMgwwOnct9Qah1aYuA5hHqcINRgd9XxV+ws+K9qmuhxiQtZO/LROSCiD/rqG119TnqysThfgKt9CIvFL5/Cm+oS1HnhDYfIMF+wPRRd80UckWZBxPQjOcQp2iffStWhU6m+o/xKlLmgckU9iWR590JzmxU3QYHHt0u6NYDDDXaiBPUF8mtJUHPmKB6d3+/vLrUkZt3C3PuZM5rXKzTD3Wk1C66LPopTtqhcP/w/KTz+VkawdfFSHoa8p2byYyFerpeU4lhJhMRIeZIsUMANor9xupv94ecZl5cAUL7zi7Zv2UwjiuPEP8tPLqvrz7KbJiqeuBt+cc8dJagl X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR04MB4838.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(39860400002)(376002)(396003)(366004)(346002)(186009)(1800799009)(451199024)(86362001)(36756003)(478600001)(66946007)(66556008)(37006003)(66476007)(34206002)(316002)(41300700001)(38100700002)(38350700002)(6486002)(26005)(15650500001)(6666004)(6512007)(52116002)(1076003)(8676002)(2906002)(5660300002)(7416002)(6506007)(4326008)(2616005)(8936002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GmJagrndznNRs+PQbEEw8suJeM6wwNhEZ0Ka2ITW6a+TMAF7t1cXlyHUEVbf+VClW05QBFPZZrngt8rZ8RT5rG/2yyU05jlgy7wkPvNE1oehyzvyKiTgoPwvY0wP/XYAYCaNvcQr1f8efK/2yvgKkjIS5685o0jBnvmxYt7CGshvl5PXEP/BbUOn/v8+bIjYb5YeeTxAYT3eAjpcsNOcWiw1jrgDCXg4c8vLSgdC9LbY9lCY1HyJvfQrhwo8H5PlFZzDae/0tKmC6ARgAEr1woqe4Z9Xcigla42sn4Fg0PDLkSKjypmlTL4gmMo+mfDdzF6L6VDBSN7Nj8o1mt9v1u6SuUqsYhwHt6uHn2PrYDTLjQodJFP8elgs8J0w6E1lThRQUQSV98EeuOsbr25eJOsPaF4wQhFOPkdV5FOgQHjoE0vAn5vrBlcArqOlPOZS9lCalUaItYou6wkhgadNEGFrVzfIEwHoQb8/ejgCsfuB8P7D+VCQgJ6doCeBQt+16X+2xqsimhYQQhIQS4cl9qhcV+jshVwX7/65DekN7pUD0wUH4C0in0jqezuMJHCsVH7IASYMHzvic7QaiJHhsKW00kPeQrqn0rU2EU1c6bIbfL9P/v0VbVSu+AROHz9JKz58UPv7rYmPZ6Uxfj+HPYmID/Vw2ChWCblAVOLtmS2cA43S8imSS2LBfUK2sfJaJhkw0Hg3lFasmozdg1jwV1tcOH0wpyhPCwWD/bmZXyzelcF2EHRi+2YMfl0F3pGpgYm5iqJg/Nva1Xrp+V9ISsQuBqTNkz2o+FhNvLE3B6TBoUZLCvS/RI+tGYvv5vllYgcg+kAnaqnTNrvGtvgJ8jDWAkGQ7D4ZAsGCoVl9LXcneXdNZTeeczX0MrQysvM7lqbG7iSgVnThkR2gTPuxN4FyM3KUCagqrI7lWimRTabXBrdWHcCsU/LX9Ku1JMb4DhGMn91TSjLf+Zgidzpqfny/noJXH7scFdtqtr/IBEFdqjudlJ46KLlhe2z7RxBc+L1pTlGFN/XjJOE0lsCSboIgc9LRzVpI8DDFPtNFvp06Bjq61wXWLO9V57fvxj8rZtC0PUsP1wU7jGi6ILRE30S3LyeO8oHCy+OZFtjE1Jm4gWP3oXSikDpprlpCEVsUinJBNZItzC57AGLS2e4V5p1I8PXoX6RlSAtL4jGdlQNmUfNFBm5qmF5CF3L8/FQY44cGDjGGfz12zp7C7keZSyGcYThYbLSQdaSVMmnE+1s6i9roztEWv+1y7kLIw7Pxo5ZBN7pP1G5DZhLTyAFiteNJ7OJ/HcqxkjDaFQ1Mi/y+Ypq9F3lBGGJMd+/CKuKNsrUkQfEmgtHJr4/hHuB9X5hxqLOfjBfHyJfXsW/cwrdSnrJ/qPvDPuJcy19sCnNLLOpfJsfp/wJuSUkIjbaGeaWCRtJE1/CYMBeD9uuIjw4i+rupGGa2ZrxE6a15spN6ti+wJ9U8ddEFuZeWTLpR0lxESRGlycTBO8W75eyEu+5C93kaRi75mBANVSDJ2CnP7rSeSFjk2VAAtYePCX0Tf6eGXhwJsaPk3Z/gOmgL/aJkgYBDw38+BAakzAwrDXpR X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e6a28ce1-2525-4939-a2fb-08dba2773faa X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2023 18:48:45.7879 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: yU80pfIV5BXRR7NApUHX/Lror3PMSwON0X6WB80QYpU/Wqhzc12PvN9q0q4aMYdekMKR2XNmeVfPvQqiS8D7XA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB9566 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Introduce helper function dw_pcie_get_ltssm() to retrieve SMLH_LTSS_STATE. Add callback .pme_turn_off for platform specific PME handling. Add common dw_pcie_suspend(resume)_noirq() API to avoid duplicated code in dwc pci host controller platform driver. Typical L2 entry workflow/dw_pcie_suspend_noirq() 1. Transmit PME turn off signal to PCI devices and wait for PME_To_Ack. 2. Await link entering L2_IDLE state. Typical L2 exit workflow/dw_pcie_resume_noirq() 1. Reinitialize PCI host. 2. Wait for link to become active. Acked-by: Manivannan Sadhasivam Signed-off-by: Frank Li --- .../pci/controller/dwc/pcie-designware-host.c | 71 +++++++++++++++++++ drivers/pci/controller/dwc/pcie-designware.h | 28 ++++++++ 2 files changed, 99 insertions(+) diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c index cf61733bf78d..5c8cbc3afae4 100644 --- a/drivers/pci/controller/dwc/pcie-designware-host.c +++ b/drivers/pci/controller/dwc/pcie-designware-host.c @@ -8,6 +8,7 @@ * Author: Jingoo Han */ +#include #include #include #include @@ -16,6 +17,7 @@ #include #include +#include "../../pci.h" #include "pcie-designware.h" static struct pci_ops dw_pcie_ops; @@ -812,3 +814,72 @@ int dw_pcie_setup_rc(struct dw_pcie_rp *pp) return 0; } EXPORT_SYMBOL_GPL(dw_pcie_setup_rc); + +int dw_pcie_suspend_noirq(struct dw_pcie *pci) +{ + u8 offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP); + u32 val; + int ret; + + /* + * If L1SS is supported, then do not put the link into L2 as some + * devices such as NVMe expect low resume latency. + */ + if (dw_pcie_readw_dbi(pci, offset + PCI_EXP_LNKCTL) & PCI_EXP_LNKCTL_ASPM_L1) + return 0; + + if (dw_pcie_get_ltssm(pci) <= DW_PCIE_LTSSM_DETECT_ACT) + return 0; + + if (!pci->pp.ops->pme_turn_off) + return 0; + + pci->pp.ops->pme_turn_off(&pci->pp); + + ret = read_poll_timeout(dw_pcie_get_ltssm, val, val == DW_PCIE_LTSSM_L2_IDLE, + PCIE_PME_TO_L2_TIMEOUT_US/10, + PCIE_PME_TO_L2_TIMEOUT_US, false, pci); + if (ret) { + dev_err(pci->dev, "Timeout waiting for L2 entry! LTSSM: 0x%x\n", val); + return ret; + } + + if (pci->pp.ops->host_deinit) + pci->pp.ops->host_deinit(&pci->pp); + + pci->suspended = true; + + return ret; +} +EXPORT_SYMBOL_GPL(dw_pcie_suspend_noirq); + +int dw_pcie_resume_noirq(struct dw_pcie *pci) +{ + int ret; + + if (!pci->suspended) + return 0; + + pci->suspended = false; + + if (pci->pp.ops->host_init) { + ret = pci->pp.ops->host_init(&pci->pp); + if (ret) { + dev_err(pci->dev, "Host init failed: %d\n", ret); + return ret; + } + } + + dw_pcie_setup_rc(&pci->pp); + + ret = dw_pcie_start_link(pci); + if (ret) + return ret; + + ret = dw_pcie_wait_for_link(pci); + if (ret) + return ret; + + return ret; +} +EXPORT_SYMBOL_GPL(dw_pcie_resume_noirq); diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h index 615660640801..91d13f9b21b1 100644 --- a/drivers/pci/controller/dwc/pcie-designware.h +++ b/drivers/pci/controller/dwc/pcie-designware.h @@ -288,10 +288,21 @@ enum dw_pcie_core_rst { DW_PCIE_NUM_CORE_RSTS }; +enum dw_pcie_ltssm { + /* Need to align with PCIE_PORT_DEBUG0 bits 0:5 */ + DW_PCIE_LTSSM_DETECT_QUIET = 0x0, + DW_PCIE_LTSSM_DETECT_ACT = 0x1, + DW_PCIE_LTSSM_L0 = 0x11, + DW_PCIE_LTSSM_L2_IDLE = 0x15, + + DW_PCIE_LTSSM_UNKNOWN = 0xFFFFFFFF, +}; + struct dw_pcie_host_ops { int (*host_init)(struct dw_pcie_rp *pp); void (*host_deinit)(struct dw_pcie_rp *pp); int (*msi_host_init)(struct dw_pcie_rp *pp); + void (*pme_turn_off)(struct dw_pcie_rp *pp); }; struct dw_pcie_rp { @@ -364,6 +375,7 @@ struct dw_pcie_ops { void (*write_dbi2)(struct dw_pcie *pcie, void __iomem *base, u32 reg, size_t size, u32 val); int (*link_up)(struct dw_pcie *pcie); + enum dw_pcie_ltssm (*get_ltssm)(struct dw_pcie *pcie); int (*start_link)(struct dw_pcie *pcie); void (*stop_link)(struct dw_pcie *pcie); }; @@ -393,6 +405,7 @@ struct dw_pcie { struct reset_control_bulk_data app_rsts[DW_PCIE_NUM_APP_RSTS]; struct reset_control_bulk_data core_rsts[DW_PCIE_NUM_CORE_RSTS]; struct gpio_desc *pe_rst; + bool suspended; }; #define to_dw_pcie_from_pp(port) container_of((port), struct dw_pcie, pp) @@ -431,6 +444,9 @@ int dw_pcie_edma_detect(struct dw_pcie *pci); void dw_pcie_edma_remove(struct dw_pcie *pci); void dw_pcie_print_link_status(struct dw_pcie *pci); +int dw_pcie_suspend_noirq(struct dw_pcie *pci); +int dw_pcie_resume_noirq(struct dw_pcie *pci); + static inline void dw_pcie_writel_dbi(struct dw_pcie *pci, u32 reg, u32 val) { dw_pcie_write_dbi(pci, reg, 0x4, val); @@ -502,6 +518,18 @@ static inline void dw_pcie_stop_link(struct dw_pcie *pci) pci->ops->stop_link(pci); } +static inline enum dw_pcie_ltssm dw_pcie_get_ltssm(struct dw_pcie *pci) +{ + u32 val; + + if (pci->ops && pci->ops->get_ltssm) + return pci->ops->get_ltssm(pci); + + val = dw_pcie_readl_dbi(pci, PCIE_PORT_DEBUG0); + + return (enum dw_pcie_ltssm)FIELD_GET(PORT_LOGIC_LTSSM_STATE_MASK, val); +} + #ifdef CONFIG_PCIE_DW_HOST irqreturn_t dw_handle_msi_irq(struct dw_pcie_rp *pp); int dw_pcie_setup_rc(struct dw_pcie_rp *pp); From patchwork Mon Aug 21 18:48:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13359748 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B00CEE49A6 for ; Mon, 21 Aug 2023 18:53:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229445AbjHUSxI (ORCPT ); Mon, 21 Aug 2023 14:53:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229437AbjHUSxH (ORCPT ); Mon, 21 Aug 2023 14:53:07 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2053.outbound.protection.outlook.com [40.107.22.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C059F541BF; Mon, 21 Aug 2023 11:53:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j7Z/Eq53fbVVySZG0GrDkA3d8XYrSWRzXdgmAFck20CVlDaIDOxxucr9E4dv3x35cO/6h/MFEr6vSs9BoqcBUytUtO7A7WiMcO3XbybKH5iHG6Hup7MLZK5nqoefu4b32nXVYEEjBFZaSguhQvw1M06fcA0fV5Eb+cfX3yj4M390qklJUaUP+rIXeXmDBy2xBqalD6OdW6NchacET7x3ybQvtfthqwmy94/pbo/SQaiAJhbYvn8/2qyO6A4ACfklRvemXkN/4XGgF9Zkv2b/rYgibt5bAO/1r47Nm8ESww3Xx+XSz7v/tGV+pnG7B9979hcTVun/499dH+nlItkgZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Eh4j8R2AsEoSCwxNgCfAY9dclfLuEv1xBwyGi7KvZdw=; b=hk6NrlKIAU+kkGELtHhQ63tw9VWSkT1jATTdrXiwnehpljkI/nOYZGAWseNouIFiq5uqliyiMH++32gpQVth9smW8/Ujdhnf/dZsNQIzoMY//BmcWUI11dZnVJ5KpHS7y8kpATeJEA60GTRk70z1qqtIOxoJC/2tFDd3O6QChtrLnsio7xZtUMEwh0UI/vT/E1fpnkKcrn4YJyHwwKFcjIHTgfji4btOu6Xcp5+65HikTiP0H/OXueE84v7NcpgsB+7Z6HnZrAsPzggnrBdb9cvY/NeUKMLWS1rtTxYOJTs+uaU3U+NT6QltcN1vgnKyxkZVDyAn1Srt50gXfo+2/g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Eh4j8R2AsEoSCwxNgCfAY9dclfLuEv1xBwyGi7KvZdw=; b=B8RbyYIDYSERIN7QapAGI2UkzDrNxpg4P3B5s2SRpOdHCe2/3rqHrvcej/T4yBHnrim9EpHIRYFj6WIvigG4IULId7rh/zSkfuxSPKQklpOjkP3iWU6TikdCCqUq19aJrKiUGSVnm4LylTXw7H3XcA0tseyTQmzIwmAOUHP6v8o= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) by PA4PR04MB9566.eurprd04.prod.outlook.com (2603:10a6:102:26c::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.20; Mon, 21 Aug 2023 18:48:51 +0000 Received: from AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::a680:2943:82d1:6aa8]) by AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::a680:2943:82d1:6aa8%3]) with mapi id 15.20.6699.022; Mon, 21 Aug 2023 18:48:51 +0000 From: Frank Li To: frank.li@nxp.com Cc: bhelgaas@google.com, devicetree@vger.kernel.org, gustavo.pimentel@synopsys.com, helgaas@kernel.org, imx@lists.linux.dev, kw@linux.com, leoyang.li@nxp.com, linux-arm-kernel@lists.infradead.org, linux-imx@nxp.com, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, lorenzo.pieralisi@arm.com, lpieralisi@kernel.org, mani@kernel.org, manivannan.sadhasivam@linaro.org, minghuan.lian@nxp.com, mingkai.hu@nxp.com, robh+dt@kernel.org, roy.zang@nxp.com, shawnguo@kernel.org, zhiqiang.hou@nxp.com Subject: [PATCH v12 3/3] PCI: layerscape: Add power management support for ls1028a Date: Mon, 21 Aug 2023 14:48:15 -0400 Message-Id: <20230821184815.2167131-4-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230821184815.2167131-1-Frank.Li@nxp.com> References: <20230821184815.2167131-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR05CA0022.namprd05.prod.outlook.com (2603:10b6:a03:33b::27) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|PA4PR04MB9566:EE_ X-MS-Office365-Filtering-Correlation-Id: 69d98819-f2e2-44c2-4880-08dba27742c9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rVL2yQYMAhy9WT8IuIj6rLUTm9vR2koZSAOk3D+c6Y0b7JhSBXc6nen1LTipcnyQXyDE+WiaidywvRGvpcJz6bfSv9JqRmamjDQWr8vADY/EdxJaYiRWLp3eWI410ZZib3PJg54c3XTqlWiO/piRVIONPW19pV7XsonIfXNIZTDBOJRxkch3RTteruf0ifXSrTYLpW7m6YrfugZEwciTNJQNWJnkwG7NbZwOof1lOVJXPuFfJb/z08W0D1jyfjrtmwO1ENiLCUtF4oPfcrSDKm9vgmx49I3h1kQUBuISBA6RZYyGCCAC0WTIxe+e9jqCqR4K+vaKfPObi6bl+iBjXfEo7CiXgBeDyYXKDBoxOj2EyxmKr3zWo3ekT6ERsUq4DBx2d9vveO3pgXrO+IK1Sw0ms/ORJPtKx+ItXFC1NEDVu9BGY6zW9Z2keaKRCYeNvjOD+0kKuDvH3mcmFO9Y1AZ5EVNe4SZbRKtk8LzVlcj69WK+KJs/b1FGxXK19s26jz6oELWFW6SnTh8aAl60SebtWW+7EgaO1J3IxR0+g67NLGyGEwBEhLA8546850Lkm6WD8+Nd2WXz1HF5538ePn7bN7YE6nUnTd6Cced/Jn4RawfIu58gODequJbmqaG0 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR04MB4838.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(39860400002)(376002)(396003)(366004)(346002)(186009)(1800799009)(451199024)(86362001)(36756003)(478600001)(66946007)(66556008)(37006003)(66476007)(34206002)(316002)(41300700001)(38100700002)(38350700002)(6486002)(26005)(6666004)(6512007)(52116002)(1076003)(8676002)(2906002)(5660300002)(7416002)(6506007)(4326008)(2616005)(8936002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Qt8rD/7Foddj/EKSqKeKO8o4xWWrrI7TFvd/4RAVcSDuLtNuhpKiXiorfvIlSE1Kebs7581bV6E+5STw02hGAJFsHl/39LEE3nfU8hDNmW7DeEZYQlXLsIzQIqUAiVzn7FbFgSTIzJllEnOBIhXDvz8pzmZNpg/M36k2h8DBroBJ8gpXdSByL/f0ypQDciAY1AaM5HYoVEMyoZmLkWFZ7zH+Hx9Bt/3u3I3yGYYV40JXRdWYeHGm6Fjtq2GSippIWIp0uTtE3R/bLIwRdB1nS44mGY8TptUSF+uMMOjgD+YIBfOBtYnyOC7urbRr/iHmICa4q1ONno7/skpX39laffwTiXIhR2Uflj7e9q3Vm91f0lBUExp+dPWD1jpbE6kxGZlpPFJdFXYFIJTbV1Sorh80fNftCy46+kqVh78FpkL9tFrmGsVoWS2sSdVtKC5fmsGRbH0JkWnRwBKytyQ4moAxv6FRC+hbTilHQ0uFYzE2umGABV3vbtGqEbXeRwxGpFkfwGMdxaPNXRSs1fSR4BEPIN9ojbu90a0CoW+cB+gscZMGE2zhV3+FQspqpMifxvDLNVFL0FCFWQbswUB1+3x3+s0/Kzq8LAeOptJR14E2VwdWi9Z+IemxL9nmJ/aqbSbo6FJuyd5nTaESeeN8AOVwf2CZBFZW1ZvCrgc5wKt7eCRIf1HFocPFH8lOCPP+wNEsn59maFMqHiHp7PXcdiO0sKlYTq1eYlMl6YyXM/XnW7t18u+b2NvtsG7Gwk0tMwv6c0WhA7JnsafiDZUo9MN7FZ4hUaYwp+wKNRc2iSt1aH5D1/Sa7d8d6RysSVe/oJbDrYxyc78k91erb6VULMPOEKCvLSL8tNKnpbZN/rn6in87+fzyYG3xU4L5LRWd62eLDd/jg/V4+5A5iPgZZ6p3mMVQR1tkKiDl4lj4GTRpMXNfNtRKrupOqekOv+ZfSIesNmN71WVOcI5FREC63Ev514y6vQje0GsrLaX8qK3EXpXwpK837KRspQSJtEE9pLcmb9nLGt6rdEQ8k4zSNpbTteCrM6Ixey2tmu/FfAJ23x9IgpTdy4xda+c9XnFfzHaRNJxzTeadAcOw/rXzoLmDidbU2RNfwbEy2MeYLNZlUjW0ozIsNx7/98RVQHNQ2//9ZHR/zgMvFn8EyHNH3LL5sc3+eo6YxRMama6iKwrq3B33MkUVy//BZnh/1mnPFUGkV8ZFGag6b5XyyKihtaYTPX3GkgTTpa5DWh9yrlFI88NEe8qy1Cq6lS/QndrIBud5Oxs073U7GP97k/OWzttwTKE2b8wcOJPLGQ+MrLktXLUV5UAPmDRg+lbsluoOeD6UZwSpM6I/5HWI90z3W1sFL3FSr0+ZxfdYcY+i4+pL/7o/sXXYJrrakNL79T2MviUNnIoajFTX54EQQnVAzsc5DC9ZRMIJTwnvWTWayX0mm8+y7NfzOZsNr7EXjguDuFtd9YoI22rG4w+R2teLHQWtS98NCClYqc6M/+cIBPK3vvl2VKc0E1eREbPcUxzxeUSs0jXGZ12gGve170fnNDElJZX/KLydDM/HfCJm1sC+8N3TullhV4lSvIrY+eDn X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 69d98819-f2e2-44c2-4880-08dba27742c9 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2023 18:48:51.0282 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: C2FRSy9K/BJF3U7gHx7Mbc+k8VJFfk6O7d3IhuGVbNwxfsl6wU9VB1Tqqm4xC3DDj3wtqoLFwNH8X1qOhsbDGw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB9566 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Hou Zhiqiang Add PME_Turn_off/PME_TO_Ack handshake sequence for ls1028a platform. Call common dwc dw_pcie_suspend(resume)_noirq() function when system enter/exit suspend state. Acked-by: Manivannan Sadhasivam Signed-off-by: Hou Zhiqiang Signed-off-by: Frank Li --- drivers/pci/controller/dwc/pci-layerscape.c | 135 ++++++++++++++++++-- 1 file changed, 126 insertions(+), 9 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-layerscape.c b/drivers/pci/controller/dwc/pci-layerscape.c index ed5fb492fe08..97b8d3329df7 100644 --- a/drivers/pci/controller/dwc/pci-layerscape.c +++ b/drivers/pci/controller/dwc/pci-layerscape.c @@ -8,9 +8,11 @@ * Author: Minghuan Lian */ +#include #include #include #include +#include #include #include #include @@ -20,6 +22,7 @@ #include #include +#include "../../pci.h" #include "pcie-designware.h" /* PEX Internal Configuration Registers */ @@ -27,12 +30,26 @@ #define PCIE_ABSERR 0x8d0 /* Bridge Slave Error Response Register */ #define PCIE_ABSERR_SETTING 0x9401 /* Forward error of non-posted request */ +/* PF Message Command Register */ +#define LS_PCIE_PF_MCR 0x2c +#define PF_MCR_PTOMR BIT(0) +#define PF_MCR_EXL2S BIT(1) + #define PCIE_IATU_NUM 6 +struct ls_pcie_drvdata { + const u32 pf_off; + bool pm_support; +}; + struct ls_pcie { struct dw_pcie *pci; + const struct ls_pcie_drvdata *drvdata; + void __iomem *pf_base; + bool big_endian; }; +#define ls_pcie_pf_readl_addr(addr) ls_pcie_pf_readl(pcie, addr) #define to_ls_pcie(x) dev_get_drvdata((x)->dev) static bool ls_pcie_is_bridge(struct ls_pcie *pcie) @@ -73,6 +90,64 @@ static void ls_pcie_fix_error_response(struct ls_pcie *pcie) iowrite32(PCIE_ABSERR_SETTING, pci->dbi_base + PCIE_ABSERR); } +static u32 ls_pcie_pf_readl(struct ls_pcie *pcie, u32 off) +{ + if (pcie->big_endian) + return ioread32be(pcie->pf_base + off); + + return ioread32(pcie->pf_base + off); +} + +static void ls_pcie_pf_writel(struct ls_pcie *pcie, u32 off, u32 val) +{ + if (pcie->big_endian) + iowrite32be(val, pcie->pf_base + off); + else + iowrite32(val, pcie->pf_base + off); +} + +static void ls_pcie_send_turnoff_msg(struct dw_pcie_rp *pp) +{ + struct dw_pcie *pci = to_dw_pcie_from_pp(pp); + struct ls_pcie *pcie = to_ls_pcie(pci); + u32 val; + int ret; + + val = ls_pcie_pf_readl(pcie, LS_PCIE_PF_MCR); + val |= PF_MCR_PTOMR; + ls_pcie_pf_writel(pcie, LS_PCIE_PF_MCR, val); + + ret = readx_poll_timeout(ls_pcie_pf_readl_addr, LS_PCIE_PF_MCR, + val, !(val & PF_MCR_PTOMR), + PCIE_PME_TO_L2_TIMEOUT_US/10, + PCIE_PME_TO_L2_TIMEOUT_US); + if (ret) + dev_err(pcie->pci->dev, "PME_Turn_off timeout\n"); +} + +static void ls_pcie_exit_from_l2(struct dw_pcie_rp *pp) +{ + struct dw_pcie *pci = to_dw_pcie_from_pp(pp); + struct ls_pcie *pcie = to_ls_pcie(pci); + u32 val; + int ret; + + /* + * Set PF_MCR_EXL2S bit in LS_PCIE_PF_MCR register for the link + * to exit L2 state. + */ + val = ls_pcie_pf_readl(pcie, LS_PCIE_PF_MCR); + val |= PF_MCR_EXL2S; + ls_pcie_pf_writel(pcie, LS_PCIE_PF_MCR, val); + + ret = readx_poll_timeout(ls_pcie_pf_readl_addr, LS_PCIE_PF_MCR, + val, !(val & PF_MCR_EXL2S), + 1000, + 10000); + if (ret) + dev_err(pcie->pci->dev, "L2 exit timeout\n"); +} + static int ls_pcie_host_init(struct dw_pcie_rp *pp) { struct dw_pcie *pci = to_dw_pcie_from_pp(pp); @@ -91,18 +166,27 @@ static int ls_pcie_host_init(struct dw_pcie_rp *pp) static const struct dw_pcie_host_ops ls_pcie_host_ops = { .host_init = ls_pcie_host_init, + .pme_turn_off = ls_pcie_send_turnoff_msg, +}; + +static const struct ls_pcie_drvdata ls1021a_drvdata = { +}; + +static const struct ls_pcie_drvdata layerscape_drvdata = { + .pf_off = 0xc0000, + .pm_support = true, }; static const struct of_device_id ls_pcie_of_match[] = { - { .compatible = "fsl,ls1012a-pcie", }, - { .compatible = "fsl,ls1021a-pcie", }, - { .compatible = "fsl,ls1028a-pcie", }, - { .compatible = "fsl,ls1043a-pcie", }, - { .compatible = "fsl,ls1046a-pcie", }, - { .compatible = "fsl,ls2080a-pcie", }, - { .compatible = "fsl,ls2085a-pcie", }, - { .compatible = "fsl,ls2088a-pcie", }, - { .compatible = "fsl,ls1088a-pcie", }, + { .compatible = "fsl,ls1012a-pcie", .data = &layerscape_drvdata }, + { .compatible = "fsl,ls1021a-pcie", .data = &ls1021a_drvdata }, + { .compatible = "fsl,ls1028a-pcie", .data = &layerscape_drvdata }, + { .compatible = "fsl,ls1043a-pcie", .data = &ls1021a_drvdata }, + { .compatible = "fsl,ls1046a-pcie", .data = &layerscape_drvdata }, + { .compatible = "fsl,ls2080a-pcie", .data = &layerscape_drvdata }, + { .compatible = "fsl,ls2085a-pcie", .data = &layerscape_drvdata }, + { .compatible = "fsl,ls2088a-pcie", .data = &layerscape_drvdata }, + { .compatible = "fsl,ls1088a-pcie", .data = &layerscape_drvdata }, { }, }; @@ -121,6 +205,8 @@ static int ls_pcie_probe(struct platform_device *pdev) if (!pci) return -ENOMEM; + pcie->drvdata = of_device_get_match_data(dev); + pci->dev = dev; pci->pp.ops = &ls_pcie_host_ops; @@ -131,6 +217,10 @@ static int ls_pcie_probe(struct platform_device *pdev) if (IS_ERR(pci->dbi_base)) return PTR_ERR(pci->dbi_base); + pcie->big_endian = of_property_read_bool(dev->of_node, "big-endian"); + + pcie->pf_base = pci->dbi_base + pcie->drvdata->pf_off; + if (!ls_pcie_is_bridge(pcie)) return -ENODEV; @@ -139,12 +229,39 @@ static int ls_pcie_probe(struct platform_device *pdev) return dw_pcie_host_init(&pci->pp); } +static int ls_pcie_suspend_noirq(struct device *dev) +{ + struct ls_pcie *pcie = dev_get_drvdata(dev); + + if (!pcie->drvdata->pm_support) + return 0; + + return dw_pcie_suspend_noirq(pcie->pci); +} + +static int ls_pcie_resume_noirq(struct device *dev) +{ + struct ls_pcie *pcie = dev_get_drvdata(dev); + + if (!pcie->drvdata->pm_support) + return 0; + + ls_pcie_exit_from_l2(&pcie->pci->pp); + + return dw_pcie_resume_noirq(pcie->pci); +} + +static const struct dev_pm_ops ls_pcie_pm_ops = { + NOIRQ_SYSTEM_SLEEP_PM_OPS(ls_pcie_suspend_noirq, ls_pcie_resume_noirq) +}; + static struct platform_driver ls_pcie_driver = { .probe = ls_pcie_probe, .driver = { .name = "layerscape-pcie", .of_match_table = ls_pcie_of_match, .suppress_bind_attrs = true, + .pm = &ls_pcie_pm_ops, }, }; builtin_platform_driver(ls_pcie_driver);