From patchwork Mon Aug 7 16:52:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 711285 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 60C8BC00528 for ; Mon, 7 Aug 2023 16:53:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231899AbjHGQxK (ORCPT ); Mon, 7 Aug 2023 12:53:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230389AbjHGQxJ (ORCPT ); Mon, 7 Aug 2023 12:53:09 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2072.outbound.protection.outlook.com [40.107.7.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47261A6; Mon, 7 Aug 2023 09:53:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mOLHl6IW1pZ7w6BevtM/P3dMTxHjnV095m3KKGMLxakVGTf/XH1WHmM3EMgIeLmy4bGJmgjM13K0GJ6ymld24XSp5gwIN3eKuMwDpJORjZbWylGmFysfTwOCN23KYRJ7MeJ9BtC/TSwuqqKqyHyn6X9Kw3lXXqmvWI+JCc6smX00l+O/Vmhxc7yugJ2RosTBP+Ylg8JjRDB2RjYOzoCDVMuYMTJeza94uIAk26+dxGcSeQKgiIxXbnP6mqlRBolacb70jOBjVjxH+87E5X9y7qapOnRcd0cmbyEbcPS2jt7j78PwMXhKUgzdXL/9lX4rJFO7SGruKFR+iMJug/2EqA== 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=kjyxhbW06JhrkrTCJL7QM3CGDyh+FD/nRHJUcFll8aA=; b=d+k5Nv1aFghoIHVktSSkd9Eh1z5PWS3FsWZJTrB5fLs7t0AOOGggKGhVR0SUT3xpoGiytLvFl2JfuG7Nb9gzYgUUCAjqwnwhphAP8Ee+qVQOX6X2FZdja0na4Buzp1d7bV5hOP4jNGtwaDylGSdgMa/Gwj5LfhQoGoxW7e0hJ0lDwnrLu5mfoCrO1PI4YpAhTTE3ao+sX/LeH/NnvPUYjBIpgAgNoErxKZB7wNsvwLltkQJ6dbWez5Qfj+gQrSFC3yzNqITGGyp7COiIm8jaEv5s7K1AnL1FwZYej8GyB9EQSgPnmb/S+IX81jurxFlgwjEkpLB/VBpSaDtxGsOmHw== 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=kjyxhbW06JhrkrTCJL7QM3CGDyh+FD/nRHJUcFll8aA=; b=KscFYe5xeTmr2CHLHVZ6075dR9UuknXiCLco72RcbMvfMO1tuA7Lu6sqtHL4k1vfmgcsde8zh49EsS5EYMumagu2jk9yRJD3fUbd0T1aeEXMwvBnSB7Ig8ndLOiYERxObYLHa4DEsBGmJPGJYgpgc4ubS1ASp57A0QceQhV28Vs= 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 DBAPR04MB7318.eurprd04.prod.outlook.com (2603:10a6:10:1ab::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.26; Mon, 7 Aug 2023 16:53:05 +0000 Received: from AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::d0d5:3604:98da:20b1]) by AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::d0d5:3604:98da:20b1%7]) with mapi id 15.20.6652.026; Mon, 7 Aug 2023 16:53:05 +0000 From: Frank Li To: helgaas@kernel.org Cc: Frank.li@nxp.com, bhelgaas@google.com, devicetree@vger.kernel.org, gustavo.pimentel@synopsys.com, 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 v10 resent 1/3] PCI: Add macro PCIE_PME_TO_L2_TIMEOUT_US Date: Mon, 7 Aug 2023 12:52:36 -0400 Message-Id: <20230807165238.569297-2-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807165238.569297-1-Frank.Li@nxp.com> References: <20230807165238.569297-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR05CA0093.namprd05.prod.outlook.com (2603:10b6:a03:334::8) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|DBAPR04MB7318:EE_ X-MS-Office365-Filtering-Correlation-Id: 2d55efd5-9710-433c-3383-08db9766c528 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jbiVzTsGrBXWeGxV17qDRtvsFvnybDeb5bU9PKGN9R8QIpktJhQPxPIdxXghJo04bOQKz7ZYEFfsrHghKg1JIXtueoRbeGf7VpayOSihgk9GfjYJ51ruHw4TQvgfXOzeJ8q0ox7iuCaC8MhqhJ8CgVQyn3VT79OAwmFosvRNWu8dpAHVDW4VmBpS5i3vcdK2aBenwKw9qh16n5TDBmWnUGTdgSQZYyW1uWgyTC3QsC9Xl+Y6QUTzBMPijIOZk7Ad6sHThR0wxcT7QKUiWzs1icQ1K5EUwoZClQ8hkSk83JYv9GvPt/iMAd3Zaf1FmBu1D+4PdT/VBM5WTJ6k0nx4C9xKIZ6GFZ5+CN3ioZnp4r3kwmzraGKchtcFFMDXGi1XC4LSnuk1duESDw4RFkhSW90cCMJYZO0BJVjRT12Sw9CgFHfynCglFIlnG61nEk1EMI1vLrnlcGcoakTxh8aqsbW3Gum3Q13gw8i84BwenuXDQxAhbklD4UfjQOAubxnH6VEaYhfUePdW8BB50HOj67Dx14LxpcW7fRUGFRSDqHJ3f59cZC/mumShLW8dkUNnXkAdKKNhqpIDjtw1ATPihSRsVXpnu31WKbmdYAfzsasRAvNWQVM42nZ1fo1zq+CH 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:(13230028)(4636009)(396003)(366004)(376002)(136003)(346002)(39860400002)(451199021)(186006)(1800799003)(2616005)(36756003)(6512007)(4326008)(316002)(6916009)(86362001)(478600001)(38350700002)(38100700002)(52116002)(6666004)(66946007)(6486002)(66556008)(66476007)(6506007)(41300700001)(1076003)(26005)(8676002)(8936002)(4744005)(2906002)(7416002)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lxdE+7iBNCXY6W6a1Z1DrfMMI52XCAtkgbxCjB1cZnaIQop4IUuW3LkCl1348K+rMONcA4lNKYYwTBSNtgXPwgyd84WpfasYzFhCEB9mcu8k7VmhcIuUFPjP6ZzJ6F2k3w0T6EOlOvd+ZbfzKBJM6KtKptuDpF3OP9He0bKhVj7zZ2ujSCYNR5NVdBs5hyRNacEVvQ5XzxCeFXAVnBM//7tFKV7d7GWhB1RzydGlj2NOYjTVpVl7J2I2q7Ui2SZmJj/4EYJMsdlcJVDDe0DGQghm/ZWU8sKdppqhhz05dKetGlEPUMaIkfMHRAfgc5FZKPOuk5Lp8U35Yg39kZquxf2o+ioNtwPMQlqDK32YNRmkr4SJM6JvQuEqtH0thXeDrIKPiHNxpK4CG/g93+gCgBBVgsQXEOzfzMdRQZeEw8RghnmqOFQ5Kl4idQoa4Qw9hKXWJfeBPBb8wINQiPigpXkzjnuFo9gwhoZN/4yRWHpgum7nwNmivnpiHyaDg1H9Z5O78LR1Ev5sY13HMAHJ3Tyah+bprXGgf96/CK05yhAKUjJeAQXkJuMllYP+Dd+3umbolaxd8mrhTqjMRMAfs9XLCZo/Zss736zt0cUq6DQfLj+1wyBj6EC+28D93QPsr0oWEj7RjBlRe0jKuPwpMPKFhwCzCAn55NrZEjKvDTct7u2r3z8XjvJt4YRAF/lrsVAQTCUzwwSezzMwIm6/35UpfrGwAWGSJ0wmvPijAbcnfgZBC8fGQ4TqVtcrohk88riDdG9HI6epvrM5+9seD8x0ValhMA+Ajy/RZOD1rBQ6+RXAwy4CuH8AmFmJDH3S1pFcbKgtgVD0ki+h9yjjJ2F30B5/Q8TM1wx5c1sc7qX+y39BCqfSwzjAr919/3Ru7/B0LKMfnz5BlHy9HhL3+2buMqfKye1OessiF3FV7IR2W0tEXFkFmtKJdOdZXq/zM1JOaUAp1tjz/Xmav+TIg22HKCRgEy/UIRjgO3BnefGH4bq2VhwfzcgPIuAdmXnNbMi97V1F5C3yTt3HITti45FVL/rSoMbnwrm9gfFj+R+vuC0BddS6MM7CBlSBmwQd0Ng4RIs0+8BJzexG+OUbuCP0r/NAiER7Qi5XiILaA26mNgsAWaHJOVk4TPbWgWo7EKsk1UlMzUy78IFuPKJrLcJaejKSVSVwTJQ/xVtihn+QSF3Kdh2smOPiO5fKpbgqRF83FJAkO8Ll1ps8qvXVWECXEQ80NJcTvLQu8c/gY1z/HUIvlWJbEKoYToLasjnv0drwEE53KVwWXQ5tyQfyDRG2ubCijfNNuX5IW/TynRTsVaUS92YpUL2MwQy26tLyTzxv/9dMM7CFIuWtXBiXHesBM3I21teS/9DcOUV4bgWHRj92pEAX9/3BgcSZy+dXbpmiIOQXQ9UN9YY4ZhkS75oHZrpbUjSh3tm8eW3O0US5NjmsAzuDzEZ/SqcGWv+8pndXA79YhPiGl8SaaAlPGbnshc56CT64Wpx8aWoImQj4iM+jjv+ze7e9pDyJ2w9/28iqOkhrZz87n0nUPKeRxT68+nt0fepOlHN+U7zyeCKR3kdvX10vZ9pHfDbRekp8 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2d55efd5-9710-433c-3383-08db9766c528 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2023 16:53:05.6846 (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: DKgL6SAOmvu4MPjKGmV0uP5im3fNEIK00h0Kkb60TfVMNcvoC5HRofASkbCh+FXq9xnYWjTLTBzKJOsfzRbyFA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7318 Precedence: bulk List-ID: X-Mailing-List: devicetree@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 a4c3974340576..da8156663c825 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 7 16:52:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 711284 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 09CE7C00528 for ; Mon, 7 Aug 2023 16:53:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231553AbjHGQxl (ORCPT ); Mon, 7 Aug 2023 12:53:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230142AbjHGQxk (ORCPT ); Mon, 7 Aug 2023 12:53:40 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2053.outbound.protection.outlook.com [40.107.7.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B30710DC; Mon, 7 Aug 2023 09:53:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KF/mu/qe8zrO8dYJab6q6yLaqeM/8JdD5LYoB4pPEqPvFRK0p1PPpPD0Ai8U9GZceKf2lugURobD4qwVT+ix2mdZ3BbRpMLSsMvdLGK9rwbJS9eXNAWUqPgtASxv2YaED9lBVH0JLl6YgRTxVGNB7VpsQnzb7ZGA1Kw2tq0qNR+nfTfHKU1zQPjgJ/vBuP6pgXhqxtxPrTFodrBTnfgw9e3AwGEhT6wdqY7MoPZ1mXsfOSzcNAO8iS2MhyS9Rl/58AkoX89k/q9y42m8Uz5LJDOwjJ0Djodc2TvtRyQQ4DJ5fpTdcww/q3Y9KQtLtEa1PDc8ncYXJoTK93/TuAemww== 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=cemv0o+A4B4UVs6IecKdz+P02Zgm4E8Y/XAvJfrdSkY=; b=BXOzEDC/X08AtGjjGZFDFisD63PanY6o30BlzitttXGt16L2KfbLRO//iCBbxzeHXqLT87wzHj+N0+8CMlU2uM7UDohROUB/09dZMpE21PfmTpilecvqlX6nx2i4jZ2suWd0xSPWhsacktm/TPP+XZ6nk+CeNDXLvyLULe7Hc3Jf8kGHaZk33KZv2kXt2bcjL6xGX4Gv3qn/TttZUwUCQ4AvBk8FIUtX4iq+YAbA+TKDOEi3EX/3Flt1nP8QzcxVQHP/HEONGRMwJxKkjbrXAHkAgpCQCUPIciVoKodfHm5BY+kbTva8dXfu0/cQPnqcYwrKNtbldr43UXbx+NfN+w== 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=cemv0o+A4B4UVs6IecKdz+P02Zgm4E8Y/XAvJfrdSkY=; b=Hffa5q+iHh2OWWWflBehs03zPcgBO+Iwd0etP8/6QaIGdh2ULLDS5L2USWOW9KjIZklVJrjvhOySv2eljvtCzWeR0btT6oiKtSyMBn6xWma2ZCpS3ZOediarm2Sc7j/sFotL6Z7Y2uOWvmMgQNatUwA9FNb8U8IbbDQCE5UYmcY= 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 DBAPR04MB7318.eurprd04.prod.outlook.com (2603:10a6:10:1ab::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.26; Mon, 7 Aug 2023 16:53:20 +0000 Received: from AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::d0d5:3604:98da:20b1]) by AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::d0d5:3604:98da:20b1%7]) with mapi id 15.20.6652.026; Mon, 7 Aug 2023 16:53:20 +0000 From: Frank Li To: helgaas@kernel.org Cc: Frank.li@nxp.com, bhelgaas@google.com, devicetree@vger.kernel.org, gustavo.pimentel@synopsys.com, 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 v10 resent 3/3] PCI: layerscape: Add power management support for ls1028a Date: Mon, 7 Aug 2023 12:52:38 -0400 Message-Id: <20230807165238.569297-4-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807165238.569297-1-Frank.Li@nxp.com> References: <20230807165238.569297-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR05CA0093.namprd05.prod.outlook.com (2603:10b6:a03:334::8) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|DBAPR04MB7318:EE_ X-MS-Office365-Filtering-Correlation-Id: 04b26cf6-2fb2-42bf-406b-08db9766cb89 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Mt32X455/BmZ20SL5kXiUrgvVLt4uL77e1CpCgvQ9ibkcbGEDx+GRCguMmQBFqsN8SwBVeTaUPaAY7NTeIJ+6qTi45lc+UwdM3286dXX2W+x1T1Pp5/mjTsU0hd0i8M4eVj6cCeCrW6XkFg12dKnMVPCRsJrgzOpFFA8GU9sJ5g+vWZEJEJPjpEpuvI/vh39lVETtXdwUCVpM6I7z9mPSMYHe2fRPLkNbGfqAliio8gUXlPK7j3UAkVRXxBgeOEEBkfWI5hRfNanTdCCOz57dv570p584TVkU27jDlEwKjq2mhnpQEVDln0IRoMlNEne8psbinV1YCXKv6erHWaSfRiP1BOmb8kYl2J2suIl4KE5cnA6gP0dB28iBk5M255Z/BPF3WR+VDuCzHOoCg3ev1QMMT6Z+MRzcPdCz+PSy51xYxd7WGTVxuiLJXZFZLrvBHA3kXSGk8AhZVv45BoFjhbnyX1n0zeKiNRPL0mfwSgYTV7Ixudg3bfXqSuSiXjjlXp4hnO09CgM7llrZtyU0hs5zqhazugajDnYdf98jumSo6YXd2SmoLTO4aYfMguHFcMR6H4sN0U/IROK2lnau9cOcOoJbG+UrGxKTU5Twn914C4qptvmC65vxKpv+jUC 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:(13230028)(4636009)(396003)(366004)(376002)(136003)(346002)(39860400002)(451199021)(186006)(1800799003)(2616005)(36756003)(6512007)(4326008)(316002)(6916009)(86362001)(478600001)(38350700002)(38100700002)(52116002)(6666004)(66946007)(6486002)(66556008)(66476007)(6506007)(41300700001)(1076003)(26005)(8676002)(8936002)(2906002)(83380400001)(7416002)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1xb4FY5j72g4E1UMCfJhzo9mi65o4RFzZoHyhfE7xa/toNLVfb4f+7zJdQo6S/WonHOOb38J1wq8Vctyw8lNn5pSN/FCY/FWMlvlYx77bY1pjeLs1nclW66f3aBS/QgqhPgyAJHTe1nIC2bSTXbXmCGYFwgGXW/GT6TD0Im1YkgRvVwf0+d2oO0Fqjwx0OrS3QG9sVaXKHKTRUes1EyHiDtkcSJ+tQiFT2z7k8cK80oNr5BQ0/ltlvazgFflvGOPeQ92RWVQYHjQuh+En6wxEAz3ky9s9g+0XCzryWiqyYjkxr1QkoFSsov5t+Q0kH5WjWWYAYEZzOHl8XjU05Sxg+ELEWx7lRCpTAKJ/efuMF3JS2spKc25hi2HthwVjLYuytBAeWA3dTlfqxzLWyCsnOGU+aKzebjwG6yJXdM+/vrAmuTwBY6IADrFETQ49hb/cuuewhsfmo8FVbQfWaSO1YIlG6cxIWe7eyz4HITHtHEGmHu66n3lDV+A0aLIz254NxK4YuuEsMQK+fLDnw1AJR9X3U+KrhRP41Jd0mJTB32JoZdr8+VeFQ1eFMDk672EdrjMQxRXgm4Uke3wgEVd8WSu4xFIZtIz5pUMvSlIDPUUS3hzUW4zw5/j0rpk7ysFSvCfmP0/Ve/RhqGs6M4B4C6bKGJyQeZ5e69zmqncNQ4R3SCTONS+DoGvQ2JJ5o4qqsnK+dr63NNSuLmP+rGdjw0C9+vhfDAIsvHnJhrd1D7E7us/0e9zrSXvrGtxMJUc4J1IOQpl79pIBZA2mW/56lcJphabdMuecjFP+hWApB6ikPKoym9DJCVhIvw5q2vY6CXrvUZyv/OGptNYGgBeUZHEECbroVPBxO4gqZhn1j3ADeTkfYsXuapiQuveURFNutup357LIUJgnoq0txNVF0QpHX04sB4OPXusRt6XAqd+fe2eXBBmmqok+0tcx0ZXel9RlRv+EclEB+6b7SzWLPYKn9wtSJ1s9YegbeRKcWGRMFL1OgN3NXQ2S7jdWSrIFzYoaEbFg7sQAHH6hGPKCCh5u9J35oDEqRoOvqKxaY9ypFFxs6mG/doOhcQImRIqbhVe0E/TMDQlv092P8SUgp5mIjpJPv9+B+JSjO08PlU0tAaSBG5LHb9pnvNBE/YKMTcL532OjdzQq4esLb75lHODkdW26ULif5HfaQ/SU4PjF3kwmMJGzlesU5ak7wb92U8vqvsV3Xk1N0vhlLZvaDzRmLzY9mF5UKiRvfZF1c00qUd3OkeWwNIdrf46Vn0YChD944Icc+sssmSeMgX/rVC7vF4Eg9Cl+M8NPjppkPEElu3jJrezADKSlO3sQGDeQ7SAZI3249BHCCYodQzHdN6qtDNmkmX4krkRfh1qbJ7OVGWokkWWCaRCpYZzcFdwBEYn+TAS9kx6P6PZApG6FO0pOHAqdeg8hljM10SSSpLdIxVH774nQ35ZdOhPC14OHpD0GQYPm84ceeG2d2wRBGd7FW9YQyegtFlVvsks1fTqvCPPhuIIdv3Gyh5/Y8/QwUoUSZPdutqKBIUh0amdqYqV+vplvDHWbk9e6nCJlykatGhm/tQ4bCxz/PAaEwFT X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 04b26cf6-2fb2-42bf-406b-08db9766cb89 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2023 16:53:16.2129 (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: +nB5tuuYPGj40ADKuOYngV2xeRLskmvVDXWsmvPRL9kqFduJK5mOeg8fJnoLGVRupyRj5vzL6FbF/L8zPUsTxw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7318 Precedence: bulk List-ID: X-Mailing-List: devicetree@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 | 130 ++++++++++++++++++-- 1 file changed, 121 insertions(+), 9 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-layerscape.c b/drivers/pci/controller/dwc/pci-layerscape.c index ed5fb492fe084..7586aece769b2 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,60 @@ 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, "poll turn off message 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; + + 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), + PCIE_PME_TO_L2_TIMEOUT_US/10, + PCIE_PME_TO_L2_TIMEOUT_US); + if (ret) + dev_err(pcie->pci->dev, "poll exit L2 state 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 +162,28 @@ 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, + .exit_from_l2 = ls_pcie_exit_from_l2, +}; + +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 +202,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 +214,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 +226,37 @@ 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; + + 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);