From patchwork Fri Aug 4 18:06:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13342158 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 DD357C001DF for ; Fri, 4 Aug 2023 18:08:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230193AbjHDSIb (ORCPT ); Fri, 4 Aug 2023 14:08:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230198AbjHDSI3 (ORCPT ); Fri, 4 Aug 2023 14:08:29 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2069.outbound.protection.outlook.com [40.107.21.69]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BF364C27; Fri, 4 Aug 2023 11:07:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VG2gdCol0fXv0tn6wr4gTaROqRhCMd6Q4z5RtalrXIt0GYd9yjxSNF8frzG+tAn9dFMHwOtVqi07VKyjAenAYL6OBVk2yDI6937AoXkOvrfSvwbthx0upkfgdF56Z8Are2CMWdhapugQg+sz78RioSvOby285bQEj15pkie4dTVJydmrdz/PnY75eVlQ4bG4ucB3NvXfFGRCSu8tV9IJ/bkBC0DZsNJmZXs8G5EAcfECXqi9FSt7E6oCQgvSXVhLryMbN1SJmCAVBJdzsyrECBl+5VWPz5gdBZTYD3f6oNwyHsc4qswB4oTeZsrT3bsp0QsYBRJNV2jM6YkVBCuaYA== 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=kD/znj39K7OopIjlMAM1QWmL7+eY1yePDeR4tqNfJ1s=; b=hBoJ5ORUSDn4jypmKxQtyrfK+L5EB71Pi4ml4sRdiZasTBVn+yVyTEXXqPJwDp1gxUs7lRopwf2WFYfZq5TcuA4mYmerKAEiKb2L9gt5JgavuXUTn2AVpUiSR+lqQpMo1qEKh5CtnHME9YBPTzP0sZOQzktvxDt5e35xmQDc74snTFV4kXVolXI7QcS6nJNQ0ClBVnbGs3Q4gDInELsaXx5bh7NMYN06kvb6PY1xX1kAw7V8a8Jp3ZF8JDFjZdMYjtrUO6ORFY4539geb6OW2ZJ1rocFZe9+yNk2vYe/dZ++AroRHMfYkLr/J7odKnHdYiPDMWfQTdOHCVZpNk+LMA== 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=kD/znj39K7OopIjlMAM1QWmL7+eY1yePDeR4tqNfJ1s=; b=VALB3c8+iSUwknqaEbP5H1a3wGG1iMVTKIjuxWylXl2Ca8vb+jsqiVV6pB8W+qVVphUEqqWKEKN/lI/KKs2pwJPQGfcDTt7D3vRod565Qtk0T1bjUOWemcPbZdme9wF2O+8xTRLbq0OJTPXBxzgPJARWDet0vbnNk+w6BBE5WMo= 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 DU0PR04MB9273.eurprd04.prod.outlook.com (2603:10a6:10:354::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.47; Fri, 4 Aug 2023 18:07:04 +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.6631.049; Fri, 4 Aug 2023 18:07:04 +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 v9 1/3] PCI: Add macro PCIE_PME_TO_L2_TIMEOUT_US Date: Fri, 4 Aug 2023 14:06:35 -0400 Message-Id: <20230804180637.462573-2-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230804180637.462573-1-Frank.Li@nxp.com> References: <20230804180637.462573-1-Frank.Li@nxp.com> X-ClientProxiedBy: BYAPR05CA0051.namprd05.prod.outlook.com (2603:10b6:a03:74::28) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|DU0PR04MB9273:EE_ X-MS-Office365-Filtering-Correlation-Id: a8088963-fb05-4277-1312-08db95159ba6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6GIsovQA5fAdccs8fZ1FsTqNgqcloE7mPDQr7Kh3Q6v+E6gA/6mnGfccqNVEQvdmhBB/1meScdkjd4yKj27bZe4Q/Y8GqhWtR68OJHfF8pJUXutENuN6RKJmWlenT1c+eao/2xk4B9MvFNxIm7Ke9GWTYZOFl7AQa5iaDNL+jLbvRzpjc5Hp1IqyIL3paKSv0rEGRzRElbFF0ZIhMvh+0LU1JZjCPU33eUhzsIrJzm8+XWtxtrKEUnC4s8VCTtagFq6Gr+Kf3airGsy766INlyUGvWzPiK2LJeV73eROT8oohHL7iu3UAyWMUMOtEerEWQH3DKMcSUTJr9kUeOHGkjnuWplGmFHQUL56IaD/sOL/FHJNRm57DVo2uoHvUaISS6UsSyUwP2GqtT0uq0iT4KKcdFNslZ/PLd9yVEiaoqqbwNUw9mgleYNd6FrdCl7FHCG0KpUPabpd2J2n4PVj1Gh+dR2myn5a8SF01Thd2eU1svG0w+kIgt9Aw0IlMlQeEpGxKGqI6vXMHOQdYNnR0niOgGLpFYuYFu4Axh9v+3ew30N7cLNHN6d3BX+yXLUr+BMxKB9BFRSyMcIE0FIhbt7lM/OzvBm58AxWJWx/McxG41rdlKYZB7wEVzXK04D+ 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)(39860400002)(136003)(346002)(366004)(376002)(396003)(451199021)(1800799003)(186006)(1076003)(2616005)(26005)(6506007)(8676002)(316002)(2906002)(66556008)(5660300002)(66946007)(66476007)(4326008)(6916009)(7416002)(41300700001)(8936002)(6486002)(6512007)(6666004)(4744005)(52116002)(478600001)(38100700002)(38350700002)(36756003)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mIgzLQI5ttdtju8JP9bwGS7ffCmKGV/qOnAeK9R0iirR8OxsdfgoR1Mwfk2vbu6HMh1o/ItI4/V888QfYCIxzOdy2NY3E3x1mmSkmxjpt1kVJbT7HRXv0E2D50oJQZPuUxkB1WmOTjsiDOILlzJuEsEEzfF6N6kE/G+n86An5qKVN1+D4GxLIiJWVXodC8syd2kyrG9xH7+ckSvLMjXotUQFoxHUkKANlqLycGrEYFdJJhsS8yTyffME85jBU9eXkcvaSMkLuGb5Mq9dyOt+0b1RQWUQTScrhw22PAQFFBGwme5TlPC5Q1CLcFxqmJcg6RoJiqMTRN28MGjegmOdIiEVD01jYzdKV6qgLRWqwAb/O1Wv12bMrwJwe3Djh/6kUw5SvptX+Zj2bQ0HFiLLfQdY/2/jc4rZSehbo8OWVX4UH+DKYp4sjn/6/vBiUIGGM3I0llgxBWQdqijBrgauwboX1uBD7OCXCheJ3Yn2HB1EX77PmYv+UWMWRESt5CkTRSptWrJIc9NxnCOPtEZ3bmcAOpBBWz/YFKiPJiESy8nwtDGN5ODVYUVtkxoSxreg+RBABPgP8IV6YmUQdxn9dVjMcx8jHINOZOpkdfr1r4arFtnVg/p9Grx4rop0/4srNF7kFwH4b9381JIuPO8f225bZ2B2h3C5x7BErodfzzOySGGGrOzv6S+PHcALhHmdGmBl98ftZT8dqOKNr8WbER84K7y2Z0rPwO57lb02/K5jyTdrr7muom2q+cdnuywDc5/llfTqC93VePaeMYRhKdRq6hfXaFgS48Wcg1uk75mWgPxIIzoSJxYz0UF5s0+W4os4jPRCEiTmRxTGTfTwRbtd3/iLlcCaDG/nXlxO75qpHsLlUUvEaTI0vfZvZMWmYSE+8dv5hdWhwB883Y1FsLKSDJvrMDYgq3MqcrfXIOT8SRJQm30nuQV8eef/xe6m7oPku9mtF0wtmZPTSGxFAKaRHNSKJvusAfnL8NU4zQ0gZJMPRe0jgshjzIF+XpqFnF1QGDR9j+xHy+OnKk9HXC91FIYyoqA0WUoNHZsuu64zTzNbhe/AVs7rqK0YroI35QdmKt/2U27IbCapNn2gcxwxuog5orNsbeGClXwBdExUSm/dKv9O+OfzShAx25x/4yjlpnmHZN5+K2xruRmt/G0UtEj/eaZZRkcuRNFzt5P4tocCfP/dIHxlFKbSNQEgosg2uCKznGL5pcS3ZR+ZExkb7sUEmCPkLBfw/ECyOLfvhxS4i3WdzHKSHcncFMPXvC7a2BmvKToUFCbeBE0nRCAb6LiuAHBn5aqC7+my4DYym9HctIxniSLmoa4wIOCRBiEDLBnk9srJvfGTb0uHV/luacK6kc1HmdWBef6MQ5xCtqhBeIGhEQXEvCns1QbDpWOTaDGCyceNZFf7YR8kwUOUlWfSdBIfjlmuzVZqtRARj0+7r2axmM+od4dlVWpGPPk6WRRXmBvXY0dVc2LVSORsrrZP9+uKQ4Qjno8zHsqH2TH0IR2xXvRqyM2CV0hS2e/a7EEKif/sXOSQjhNybaWvh8eC2KKOfno9H7tx1VI= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a8088963-fb05-4277-1312-08db95159ba6 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2023 18:07:04.4993 (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: 8E7JEwL8Mu6G6zHW76lWFJLuXO+bpafDi0gbC/jvkcEp3jJ1SdoARyqiLYzU7mx7KunyuswRtI/ZfQ4xk0drIw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9273 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Introduces the PCIE_PME_TO_L2_TIMEOUT_US macro to facilitate checking the PME (Power Management Event) timeout in the PCI subsystem. Signed-off-by: Frank Li Acked-by: Manivannan Sadhasivam --- 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 Fri Aug 4 18:06: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: 13342159 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 9336AC001DE for ; Fri, 4 Aug 2023 18:08:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230198AbjHDSIe (ORCPT ); Fri, 4 Aug 2023 14:08:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230247AbjHDSId (ORCPT ); Fri, 4 Aug 2023 14:08:33 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2061.outbound.protection.outlook.com [40.107.21.61]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CB7F4C02; Fri, 4 Aug 2023 11:08:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ihtf9gGWX9GkknXmZnOahEjig+vuLPj2hzi0N2HI2uwre+HfBfBgDcV9Zzz/fucHrKax0FT3JCLq35JxFcaw5rC9N5hBXYgKSnS4yQPP/vL/lcgWGVWQyj3kW8doZ6pz9iAeAgRokMBuy78R801zIK3pSPlvrNi1plQF+RcrCF+nRbs+s0y9mfChJEk3QLFq3hJy8PGTZxRrd/mRCECwOoHbBcVEclCVkIu+vLW8cfUWFlbsXip1PdPzg7ZzwQoibfMpvy6pRV8SqaUkiDDTBP2rqamSUbyBRED1o0ZqbDci99iJ/a7RsFbCZNgf0WaPY6D7SZF7zvqJvI50+X80zA== 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=1dBaOM5+RcrzhFBzLx4+olAPOEAPw/dd4GZG04J6QFQ=; b=NgAiWAZdZXFjlc9MSu+I64pi9wCT3VjuF65MjPHJpUl8rb13uVumBqTBh532qFD5j/Jh5adGmoYx2m/YhEnJE6PwYTgWvnF74mO1YO6Gz/Q2TElUl098jGXUyDw+NafWobFXkWCWD3sWpJjdZhOM+7wqpxeveChKl0zIx/akCcEndoDAJ/KKZ56Rff0cwWWE+zXzhSXCTQAZdQ5P1mAkrsoWGo4Cz2cGuQdiek2ni3mjMZvaXl8MNoEGnHnwzW66DvWy9Wo9vUcCIXM9bLoAcYDFQOnkezPtRiRlWr6PNdcMrmHxp9KD2Qp9H8+JJiH6p75t1ZN0WyvlDk03sJPn/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=1dBaOM5+RcrzhFBzLx4+olAPOEAPw/dd4GZG04J6QFQ=; b=ZIrq5JtQh0meOBa0QKg68Hngz5h8E2dlWalc530Hp+FfIzLSI461SyfRFaqGLQBursVFgYSshYTIoo1QkMt8/0ikWgbT1hU7XDx39j73FHUXO7AO1Liq8bLXnJX0Quo4SfgSZq7sKUS7zVZq4maKjdAC/NxmE2LS2AFTReM9K0Q= 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 DU0PR04MB9273.eurprd04.prod.outlook.com (2603:10a6:10:354::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.47; Fri, 4 Aug 2023 18:07:09 +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.6631.049; Fri, 4 Aug 2023 18:07:09 +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 v9 2/3] PCI: dwc: Implement general suspend/resume functionality for L2/L3 transitions Date: Fri, 4 Aug 2023 14:06:36 -0400 Message-Id: <20230804180637.462573-3-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230804180637.462573-1-Frank.Li@nxp.com> References: <20230804180637.462573-1-Frank.Li@nxp.com> X-ClientProxiedBy: BYAPR05CA0051.namprd05.prod.outlook.com (2603:10b6:a03:74::28) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|DU0PR04MB9273:EE_ X-MS-Office365-Filtering-Correlation-Id: c34127c1-0ef9-42aa-df3b-08db95159ecb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KmO/DeTlz3+nqIML7ww0aVkep/0YNxP08aFqENoY3vGcKXvFrqZh+mbSEGPinHrYD5cEV7qZ+7ZqvQZn+Vx4QETFUxvIBs3ICHdJmmwbGQ/us71WjF61bOyXCNB8beN3Yid5v4h8y+HrbyjDbn839OFfQ58Uy7URe/PM3743EelakTv4FWDTTjWXZEg1Bt/lIvgls041QUm+iYpQJuyQG9l01/uPgEkkCz+/dul23CPuKgMrTdLujG3wHXcGQXGjaKStv/w1YOslmFrslHNNuAG1BTXg80RQVHq7rIIyHbjnco6FWBpDyM5VO6OcZiH1kGGuPbyCoiemft/9niNmRcnbpHtWH2VUmRsQbFhSaMWiEdgKH//jDEureyxOGg6+bKnc0vCr1RmAIkpj4GcoJS2pSPyVpELxW5ZDaHLatLRBbzO0InFXSuqOi4NVo3XgTNtz1f+qqOr8yUr0APZ5ta3qVRQjqGmTLiVY23zd2HCzaJwitGs5ZJ9quiqyvIT8mxHlpMOQQ20Kxk0CxqoDdsfXKe+BiUEt4bxoxbMwfOHKTd5gNbHhdUuVfv3IGeiO9FrZQ65zkdcLGDBWwb6sDy3BRoHWcZLLa/UvPBgBJ1XWaTn7oaRFcL17iB0J/t8W 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)(39860400002)(136003)(346002)(366004)(376002)(396003)(451199021)(1800799003)(186006)(83380400001)(1076003)(2616005)(26005)(6506007)(8676002)(316002)(2906002)(66556008)(5660300002)(66946007)(66476007)(4326008)(6916009)(7416002)(41300700001)(8936002)(6486002)(15650500001)(6512007)(6666004)(52116002)(478600001)(38100700002)(38350700002)(36756003)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NDWn0Lvu1urRnuk8asOcP6r1RimE91pcxYGAgKdsl+7XTftB7B3tDIp+xXvgfrDKtugUbTHEmgGZG6IEngePaXb2yACMxtrdCPaYmakKGiLGacCMDXeKzS9GyZMoX181RUlDYhPA1BMIa5ozbG8cd8duAcGZH3jrlGxspQqV0YjbwjDdwntKvpXedNJvONEkTsd/EM1DATUEvurdVhTBPQuMed2P7y0s3HmestUYMFFamkr4celZPnsEj3WzMPzXa2B5pea/8MXEfQRFbVeo9DbRxS/Dsz4/a5UMpE9MW9xCrl9i8b5BRzMymsRtEJZXLMc59iHqcz91hd7IK234Vaex93H4PSVgRv0oS+2zTWGcLcS71+8JkBME7QIuNAWrtdGxKsJr1oMALjFp1iSIllKSVMlMe0TvXxq/kd/hbTUf6USa/2w4s5nYMSoWw/8EyR0tM+kw2Fw0WNfy+Jqu18hNMkYQuID17Rp84xJnEdjcWqJv1AneVoeXNrzL294JgUutV0Nabyto9hFNB6qNlafpgG4mvBEMiCvhSR000xGTQZqVEHxWm2x2us5G7IpLe4Gdf5v4li+Hrbbcs8V0YccGnQjUGFPkKhRgF8WiBwzsuWbj4KimLpDzIIytUFduqzvwWkSPSqJLWWFmN7slNXknqte1393gCIYOrXJeNg7YAu5n+as9vspD8T9LPwrJ020xi9pxiK7Y1TjH8jcGqDYAd6R/Qu2wrZB1UKG+OTAZqCDwp4tr1c3HjpleKFGGtywExFzhq5uBmErW3dxa4WDqdBVm5PgUKfSR3DITA4jKML2n7CvjXYWIt4kwtxZlyeFMfljWsRtHhHbs9XbCQvRbpeySR+C7L2n8metDpK8S4AoHVFgbG99aJj3LRHpUaMRUHsC7sgET0GOsEnxmbMGzmxqDdEJ0TC9nP/JuXUHydHpBG2eIq3BWhxL8sMsiwm+MZ+sASNtlGrn1uYsrfUk97q/siOgRmBLx2UDjkTH1KQUmK9n97d9QScTv/pRo/WM3D4bbEao0ZVAtVED1+C0ALrFsqAEZoNR+DNc23boVTaAw0CckKLqPLpVWL0PYN4ItFHhz/sB7+hOWBbGXvFOJQPibWORo8P8RNo64iPj/tP1726lAMdsTG07WtAu6VoHgrmDEm/UclLwuABQmuyzZtRWZ4UvxA8zG20vYi61W9tg9hgR/wFw/v5xTMFFy8sw43XYSv81xWCtR1VYumPDAr4/znqiejsSVupxS+ueDAp1xBufdK7ve0kaaHW35a5aDfzsOLth9qRxtyy3abgogJA83bZeuiqoEmpxxMR4jYYMEb5x1y4gTa+bA0YHi0MYZerm26ukqJhaLef2nrOHxTmacVN83iEbOuLUMxbQDdJVtOfPqS5Uekz3L49kPfdyE6sAwjpuHmvtjkaDS1WXJl/iVZgkyrLpzU+zUfPpPzs97MjraVE+dyG+Jx72lp8G47gx3McFH61C6Eqcy6JUiaK9RNXGViG9Gl4nQxwRJSrLIfrc35NLbH3yCIBsGij445qHvZQ29fBWnbGJN6JaubnH/fLgF+XLaSFrTDO4= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c34127c1-0ef9-42aa-df3b-08db95159ecb X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2023 18:07:09.5903 (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: YSA5VTZnWTRSGFan4cWXZf2bmsbIEDk3dYf1zm1AIZD7Z+kP6sv9dPJLNWDp90So+IINLks89gX1s2gBNOMQAw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9273 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 and .exit_from_l2 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. Issue exit from L2 command. 2. Reinitialize PCI host. 3. Wait for link to become active. Signed-off-by: Frank Li Acked-by: Manivannan Sadhasivam --- .../pci/controller/dwc/pcie-designware-host.c | 76 +++++++++++++++++++ drivers/pci/controller/dwc/pcie-designware.h | 28 +++++++ 2 files changed, 104 insertions(+) diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c index 9952057c8819c..7d87ed61e2bf9 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; @@ -807,3 +809,77 @@ 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->exit_from_l2) + return 0; + + pci->pp.ops->exit_from_l2(&pci->pp); + + if (pci->pp.ops->host_init) { + ret = pci->pp.ops->host_init(&pci->pp); + if (ret) { + dev_err(pci->dev, "Host init failed! ret = %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 79713ce075cc1..cbba3ed19b3c0 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 { + DW_PCIE_LTSSM_UNKNOWN = 0xFFFFFFFF, + /* 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, +}; + 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); + void (*exit_from_l2)(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) @@ -430,6 +443,9 @@ void dw_pcie_iatu_detect(struct dw_pcie *pci); int dw_pcie_edma_detect(struct dw_pcie *pci); void dw_pcie_edma_remove(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); @@ -501,6 +517,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 Fri Aug 4 18:06:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13342160 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 99117C04A6A for ; Fri, 4 Aug 2023 18:08:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230294AbjHDSIz (ORCPT ); Fri, 4 Aug 2023 14:08:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230354AbjHDSIs (ORCPT ); Fri, 4 Aug 2023 14:08:48 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2069.outbound.protection.outlook.com [40.107.21.69]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A7075251; Fri, 4 Aug 2023 11:08:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y7NCH22QXVipLfI0mTIezycBZvLaKEAmv6mS7cPcdEbOmCAvmvPjewmoZE7MRCd9o7/K+t5C8k/Cxhn0p6coBMU7fdjMq25lCE1ikNpxLL3jzfYsnyV89X4NLcFqIkp5lI3GDzokGJXt16gj23bmdIYIo9Huuez46/Kh7UFwjU3s/36W/gzJErWcZyyOJEyARBg/InpesT/3tYmKkeakdvG9w9z4UmUgX1T4XCDVY+PXnIXSuWKSNhgl6Ug0rvH9d0YFSOYhj94u4cjh29ps6PWdLqIQcj69dGJCN8u48qgvtM9lWp+h6YtqIgAB7TrAmPUWBaeWbF282gSS32cb9w== 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=pTI1FDwVFHEIcMxT/Kb94jED7qZSnUIDLYRWLWFvxec=; b=Q5VCdIvoWF+2S2FqGiLh5HZjg+47HSW/6Jiw3+cFpEwTdd8oGEZMf7APIn4cX4bo5W1t++Fiw1lejh0g3BnFsDkIwt8r6xeO0jfFToISb12tZ/d8AhEujKvWic/IJ4qMAFbq5R2dHy9yMIShlv7ulV02orLmGzh1Y7ETW4sTcGDYHteoyesNMMmZHzut6puksKOPnueC7R4G/U4/8BEsBH+zmPyl1Gl/saZqRKFh+IPO+GrSumwuKQsYUlOmOsOWGtoYTEoMrWm1b+F19kCPD7U7DvzTZi4ojh9FMqE0mj35htTVI4ERtSRNeNmGD0SvJ/4d/iM1cn58BnWM7wG9ng== 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=pTI1FDwVFHEIcMxT/Kb94jED7qZSnUIDLYRWLWFvxec=; b=dkGl1KMogibzScma41MSAUTfaab3Iot1V/b3hAOl2og8VHfquJyKh6tbYqp0s4gqc25GCDt0rZtaZC0Sde7KnlcNDishM9hCvfL4Vshmm27xvHQaifChPrEl4kCMgkV74ppCJuqo7RzV7UST1ZXbLsjnnVIqCWkMpCgQhQL4osY= 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 DU0PR04MB9273.eurprd04.prod.outlook.com (2603:10a6:10:354::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.47; Fri, 4 Aug 2023 18:07:14 +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.6631.049; Fri, 4 Aug 2023 18:07:14 +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 v9 3/3] PCI: layerscape: Add power management support for ls1028a Date: Fri, 4 Aug 2023 14:06:37 -0400 Message-Id: <20230804180637.462573-4-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230804180637.462573-1-Frank.Li@nxp.com> References: <20230804180637.462573-1-Frank.Li@nxp.com> X-ClientProxiedBy: BYAPR05CA0051.namprd05.prod.outlook.com (2603:10b6:a03:74::28) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|DU0PR04MB9273:EE_ X-MS-Office365-Filtering-Correlation-Id: 9e20147d-0c39-4284-0fc2-08db9515a1d5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nPmsOc9bvtRyPNmJEqPbsUDWySaugSMOdH67TYgZDpXR559qPPOpk+Tumx/aES2rqF0a5JDHePwpcwpl4/TO8tBjHObqOL5L7AvX9no+m5zzSoZO03JXRkmgeY7G2CTP8NAzEroE5Duu+aCxLC89Yb74uxX3zmeG7rGGv406tx9XQMuD1fyTJNHODTmFMULs8Um7m3r7CJ0kETCFlvnGs8lLIyv95rOjGBZNoVv7Ich250c6qmltWZkpNoek9616nhYcek5/VENbrOA/jvQGJcwvmi8Bh/fZPCA1U+YotEiQAd/bJxfRIPIfVgTJFxSz4v7QK/ySeDmrH5U7LCM5baV12sPPr7wmYCKpa/hZA85/gdTJsS71lP947CTzFNqQL+xUM4emxpHYGO2TF7PjmmSw/pOBOfYFd3qAtwH/AMPxkX1g4Ou3Vq/uJHuvcRqvnYUtfPZoC+mvBh+aXd5UZPttOcZjw1vzwUJNyGF0Q8Ohj7aOaGfBdOz8BN0DhJJzQ+eJEQxIlgE/Ejbu9ECmg36gSZpuSXDc8kbpBFqft/VcFgkYIChtr15e5ZpjRnS5vrhlnUwYoRM4Uo6N0rp3tCtQp3NEuY4ZOzzzsPb0MPTQnnAyxT9UhSgwkR6XRS5X 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)(39860400002)(136003)(346002)(366004)(376002)(396003)(451199021)(1800799003)(186006)(83380400001)(1076003)(2616005)(26005)(6506007)(8676002)(316002)(2906002)(66556008)(5660300002)(66946007)(66476007)(4326008)(6916009)(7416002)(41300700001)(8936002)(6486002)(6512007)(6666004)(52116002)(478600001)(38100700002)(38350700002)(36756003)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZdbM4yhrizV5oOS/XHkMOtVeqDKiKi2opvcHMHjJRjh2j1meYG9fbkpIOn/v10JvW5eNpDEBhTZPQwUy02sgD2Pg6q6lO2SChG4VvB/Ttl2Ge92HE4kEBUwexflbGrWrtjGqYCopvFgESdPvmZMhf4eDAWalBzDlHw9mC5FmQlThGZhxqJ0w4HEopxQmMD2s4BVdtS2LmS9F+fkwENkt34E5Og337WUvWUuw1rw9b9dBd5fO67wLpN3uCzu53sHenzf6xJTos+WYwIaS3p8dJ9Lj8dfH151fzMVwZ5P3BH3aL2gnwdWWeIktxej5k1hD6KlZt7lDcNtXl5I6/nKqCW8qNHWVtRmR/YtRRQdNiwH2RA9s/IidYQvkf2ag9Oyl44HFUsc1a7s8xt8sShN2R147keGeTTlEq2EqdD3GqHHLMiY18rRRsLCVru9tvQcmcjKkI8UYW9O7oyTWpjqf47ZdnsZkRV1pZPShUkIaSz3RRAgNi8fyYUNgIqfEA+ofGz/j/PDYYuKhgb0NcNGjOLdMjBIJ1jX+fumU3ousX9SOMGCAX6J45MSBGloEKb9syfWy0sDyYv2Da4JYF2ra+HOscgx/q2xSyau32BCD8AkqoMMKFqgRsE8I7Z0J6V1g0j52qD0tdLn2fE2UChWxXhSUPM6fmN1mWrmvTEKPABxiJBcpSmtmcpPJHbKzWKp9K3LMcBvN23bNbcuo9Y5jfich8+yLiUdVt5bCy22HR49xWepPJrqh62bAbNU0AWKV/a7sjnrqgftA2rUbIXrj6F3Rn5BsLGvFczk5YNvYNd/7FjlFqwB/x6nwhEUIN21xVliUeNl7SLpnpGonubYLxcLRxLrkHUb/YXevFsGgs9a0HBqQhY4n+AlIpEjZ0i30M+0Ijw6LMU9nrMsUg2t6cjSD6s1YLjkfs0nJL36sSCsGhziNxfbkJY/tspUVUjmgrAmV2tWlgX5pnPick2uCu31yZYWe9HFyG3SGn1gBNeHdScHCvPi1surkOUFS1ILVxRzZwEmAnZfCbm6SxXM9zc00nBElecISXecu7ikuVMhbD9hTGR4uvFbTf0WJIYeJLGwKYa9l3/4s7iFb29zuz/TQljG1WetwcXkGz7jyWKNFypSfcqa/VkvFMKtSHoTRmDpsW1r7Vht7SjbJAoXvcH/WimB/vaqedY85mT/K1MNP6LOyMK308w0m1WxzhKqWQRzWqNn41WBcQppwlk0geYoUduVtuAxmvm4gwaC0fMvzaQ7vootD9iz5qeMSnXWosfzvzjDWVc1lSvm+mc1kDhxVFzXquoIe732Iray5pOvTCwr1qSadxi8Hbmocn9Uxm8RbG6o5LkoiY2Yu0j4By7pVR3kucSrHs4NS6lXzuCE39PyE2YIfR7b/3u4G4FqH0ExBYE57NK15URUfUCCpZcbACK1Wx9llIPrGwxJC50NhAtt+zjgmXM5CQcL+75w785gmC9C1TiG3qkcR1kkQXvA6rSVY7v8Q9uXdwySytrOpOC7O9aQKPiIVTQbwdVUxQNcj6602z40N2L/cTjEGoSfbAhMHWRwOAa9SaiFytsM= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9e20147d-0c39-4284-0fc2-08db9515a1d5 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2023 18:07:14.6476 (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: I2gl8C306F+rRNPObnGeQjiPoFtT29eE0pZXC/1YB2ASnm6XQgrshRF1K4kB5FaMKEkfqy7YyyMLTHpVd66UvA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9273 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. Signed-off-by: Hou Zhiqiang Signed-off-by: Frank Li Acked-by: Manivannan Sadhasivam --- 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);