From patchwork Mon Aug 7 14:18:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 711299 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 4A9D6C00528 for ; Mon, 7 Aug 2023 14:19:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232370AbjHGOTE (ORCPT ); Mon, 7 Aug 2023 10:19:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232715AbjHGOTD (ORCPT ); Mon, 7 Aug 2023 10:19:03 -0400 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2061.outbound.protection.outlook.com [40.107.6.61]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43AED10CF; Mon, 7 Aug 2023 07:19:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FbgR9ldgYj08IEGldO3+xArGuNSthVul/TPg1zPXC65KOHnofsQ20ENpqYrnq3WtZz2uVq3OUQt/o13oTMCwMl6tdqFL+JNUDfw+yawDBenT9CQFDbXxX1auxcHqVqyXFXHzUV7cl/Ac1H0pzAeCZHdfMkBi2ah9Fu5tuOx98m5cjWTfOhuJpvX0GQ544oe5+LFp8YuIK3WtI/Owaz0z1fWDzUO30Hh7mEEZpAWeNeO6NEMEG9E2NA+cos3cWTB3Yq8go/cGpqD4+OVYGRgaMmVlkZl4ZGWNF1M8wPw+JAr8FJ+PdCZ02PWtoOLJBA5o1zCoJgS9IKlEbvP+V2Ulnw== 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=gg8pCLl3igVprQvIWQjw0e8jShWYT8XKIh/FinGiE3nPYMdeVEh7EeI84xqIV4AbmpqcoxsZ8SJmkrKkJfNHkMAPMj+88ozUL+bz4BE1ktJbcha97oPxoZi0WzpHiaXvdvUExa1zssAB1R+iLCrpyg0XcxHAfU3dMF6/773axrTyZTi9TyJkrEpCkUrhVPk0NS+r1yx8H0+U7mxMkGU15ykyMl4Ukr0LUczChr03nL53vNbfAWeVBAw1Pq80Lw1Nk6T+dRHtx6m4VmQxgfNXk/t2bsG/xaxxGjjtEulITo3kXgaPhcEVpVqtQ0GpgH/fo9Sr8c96yw0t9GYdvAXuNA== 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=nu7XeUbKuOEbuiA6xkc6vxWVp3A2W3OSylhoAMVis9X487kFqryvMWsYKcldvhyM6qUkZTk77k70Yt1gid438PGcq06lEU6lvNLSH2y6PXSff0Tg8dOGyk9Jrl+jJiPOIJDzCxOaFRwYpVjb7f9x8xrCcCkp6YP5m01AJ3TIHWA= 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 AS5PR04MB9798.eurprd04.prod.outlook.com (2603:10a6:20b:654::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.25; Mon, 7 Aug 2023 14:18:59 +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 14:18:59 +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 1/3] PCI: Add macro PCIE_PME_TO_L2_TIMEOUT_US Date: Mon, 7 Aug 2023 10:18:31 -0400 Message-Id: <20230807141833.564479-2-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807141833.564479-1-Frank.Li@nxp.com> References: <20230807141833.564479-1-Frank.Li@nxp.com> X-ClientProxiedBy: BYAPR02CA0057.namprd02.prod.outlook.com (2603:10b6:a03:54::34) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|AS5PR04MB9798:EE_ X-MS-Office365-Filtering-Correlation-Id: 6d5b36bf-815a-498b-d3b7-08db97513e22 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: frmvgWTf0114w5DjahHnhx9NFxjI5BLzsVv36bX1bmch+QPGRb6UT+U5GyEcR8tRQZ5qV6nFqPeyhkmZb5R41Qxa54sczlYl85hACOvC4EgPsGo/Lf5cZFgJP1nY6sCNhZelBRfkCdEnYqDHpzl1eAlnxznhhg46yfjOP7tsJ1yd0RIt2x2DwKZTKnTJLhZTqAkF8S6mYqS7qdxL8YTqwSqYLygzPjTRosudty6fSJ45hO9L7TbP07k/G1UhgCCiscRdamuMyc1nf4+vquLFwE6imRNt3n2gxlsm/q+xgd0e1b75OOb87UOvruyZ52HJWdjtXpDV8e9nuir1bJo7MFuBfyrVSqucYt5xtkhMHllYpM5vcZ/yHyV4vdk2cthj5hmz5U/Et6Mju50aZ7eUKGPuLt1N/XJrewrpHU5lev3DcJO8dwnKcoAgUYPtOe75knl0cejOCKF51PFkUSQ0XpAvSn+aMuvo4lZdlnSd7pDojF4WO8Kv2Lw/JuE1bduxCMPmb0E/6jl/942wMEon9GqNzrtZKCG964oufSzlewcb694TKJ6YK/IhDUs4ekTvy9vw0TDOL8erc709i41noYHF7tRv26evPsdo1UzeGiX+Tg7C9gz9mtmhlo9DmVPb 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)(346002)(396003)(136003)(39860400002)(366004)(376002)(451199021)(1800799003)(186006)(6512007)(26005)(6506007)(1076003)(36756003)(38350700002)(38100700002)(5660300002)(7416002)(86362001)(4744005)(4326008)(2906002)(6916009)(66556008)(66476007)(41300700001)(66946007)(8676002)(316002)(8936002)(6666004)(52116002)(478600001)(2616005)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3jQGPx0/Scx5vdA5wjgOjXA/ws/QUE2FF2h7u7iGx0uzFIH7MEeMDqfW1cFZxfGGRC4PhkyQD0iUM8LRIJ5gDSZnXI+fFcZZJPg3D+QUCptw1+ZhLwo9h4qLluJkxgc8UcMQaMxwhNRjquPE1Zu1BopPc0tgHYSD//y8U1oz3t+XAASyszR5+9d2RMLEG++uxj0QPcQ2vyRtvGzYvctyGAw1F3+oJWQOf7i92siToosgUwBjcv1TqG0EziAidd1hMg7bJBM/QQsAmZFsTiqyODJ6WEiWURPvP3tNRuqxQKig8J17aSfTr+99S6CPtxjaDTBcxkeKg2KT5RwrUgb1hHhAMJu1r5xFMizb772avQGLjwEDgJG4NXzRIUc0ebQ53LslW9JKToVXjdhrVZdn8x8B2ttQmL1Qhd7VtYIOIhBHIhTEjS7d69z3RC0CMuJrr/kPudUGTwq1vXMGxK6Y4TFIcYA4HM2ZqZQL+lXjZMuPn4tOuFyel+xb/rF3FZZe36jPWAwqN5ymizQwb/i2BT5AfNdkC+VKdwPN599gmekQb1jYLFV9EUXwknD1XX87i+JaYa3xakix57ds89iwpP3okvuB9Gny53LSZeCZAadNFhkZN2Vn0C8PxtDZMRBzDmX8kTDK0U1+zfQUBo1FLtgvJEQag8saUE3TWI+KHjCrXVrGsDQ9TS0ymuhqoZydpKZRAFCVKsFQWo52PAogPIE/xHNfWx9YVA+swQMEVUpfyAOYGaaWl61ggW6v+awPiRkFKbHHWRdhBg6xtYr9PyN/4mw8h9iY3WH6D3NO+DdUndpU+9K/xrNpp7YjgSrDe7RZgF7Les89e6SJ9ap62xPFtWqY2Ru4QBLh5QcPVVwSwyTNyLSiDMQuuCAr5KQWvvC8n8Hmhm2A2Zn86udrSVFBaAhYAnhmPUSfehMKOU7BYVqRo5zERQPO2M+Yvx+t+qJ76gVOV/xoE1x2vMzKnrmhhOeoXrit8DpLfRZrQcOOsY5SOXGVfwLsmG1+mKLG3rayHb2goUOfT0VU7tzjxeWd3Mmu+DsJFt0LBV7ITFDxkXc08NLG/FedlUj2sZ+3aHjBUbydum59P9kOkhb6looCGCRUk6u//Ymtj+050pD1636PJjVkfnuGoWLmi0o4EfLXABpSeJqHgl4TDhSQCAHVYTUhLCLDxPiODUf2ewiVmAXS8917q8ku1TI93VzIArbSP53HS+BDHSJ2ekJvG3ArJ2N6lRc6gfIlkES1uRFbllXy1gs+zrKPMyHkOy04kG4BpJWp31BtNgOGa8aBgNjJNTRGcrmx8B6Fv0Ol8/BomDuDDgWjH5bY3dbtAO0o0uE9wuE9hmcgAZHb9RvtRebUlcE4NnTSQA3yiX7UywSP4WaCQQyLoe02x7FLp6BkUqNszIGT/SxYczR31QoIg4vlDU3B5x9D4pv9l3U3f30xo85WB3gVUuNLbhGQEng1ssGJvJN9Syxb9BIrE0kraAYtpx8UWOGY4fO1ZkqKHpE2C7cUbs5SPmmmJiyRpuOUFayVtyYEwJKVv51e8LvETqpAG13caMtmkHNuAMajTEk= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6d5b36bf-815a-498b-d3b7-08db97513e22 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2023 14:18:59.7218 (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: I3MtXG52eyKwS3QhmKoP+FUwH05SqeAjIjzLbekIorgv0s3p0M9yB1/01oswlJbD9GXVKxe2qm9yU2NwO52jvw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS5PR04MB9798 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 14:18:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 711298 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 1C325C04A6A for ; Mon, 7 Aug 2023 14:19:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233522AbjHGOTT (ORCPT ); Mon, 7 Aug 2023 10:19:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233189AbjHGOTO (ORCPT ); Mon, 7 Aug 2023 10:19:14 -0400 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2060.outbound.protection.outlook.com [40.107.6.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C49A172A; Mon, 7 Aug 2023 07:19:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GkIO3adiHqWwZim3D4cNcUxtlrcvPA6/AzCbpIUgb5VydLlkK/RvoiSS9f7iP0pVyOceJDb6B1zAtFRjILkIxPJgq58xaT2kK0JWQMmaqpQKgO9Pl4OxJ+ixWWCgZMFPwxJ/kknBZDk+Hp7op8eBMWDt9xDCxgREcvR47eY61smj1KKx++UeyMSobXDl19U1aQxm1z6TPBGO99Dt3xBJIER3NtH57mCXnSfbgoSMVnIu9Gpqcv/Yu1rMeqMZ6NCJAnSehMDHGUsshsPaPFdm6fmP2WLb9RjG8hmxAe7i8tJzHez6QA4m9EWYVJA3ke46OdQZbCWB/ExrTDaiyFuzGw== 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=XjD5P08SrTI/1IRmEjINIeuvl2z7CtC1yVYxXuDNJOr5Qa51i1wJPkD5Aee9aExZlgq3ORwc4yigBbRC+fFb4S2j7X8Lu/0Cbfw+RhvjUaVrUvDM+Z4+okEc5Tv217RHmfxCgiEEldUP/nHUdNgWZrrVtQqqqAoxxlotpp/w2gQEIvLarmprRKEqrjKg77DYImcSLlqrkVEsHnQkB/F2Fz1nYOyAKmW8238iIuk0xJiIGqZMCx5ruGUXqp9ygIqeJM/AiYHGhsCDSU8DsIcYkl33Vm89XGyvHPKRxe8H1NSLqCIipjj3crznRxUcQtfsWOMP2UC0k33Wr3v6PmQP/Q== 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=n/ca41OH7iYGhXcRE+mqGcxsB2xgbU+yNV9W09Z30Bcq9cd1f38NvfL1ppjVUpJK8vtoiOrThSj3JCiLUc5kHXyc0EBoPghlD9bN1JrZypNISn53QbdcDueA2yhE5jRPiViVqzZDHIZgNrxrOgL7Tc/tND/PFXUy7KpwWXRIwUc= 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 AS5PR04MB9798.eurprd04.prod.outlook.com (2603:10a6:20b:654::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.25; Mon, 7 Aug 2023 14:19: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.6652.026; Mon, 7 Aug 2023 14:19: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 v10 3/3] PCI: layerscape: Add power management support for ls1028a Date: Mon, 7 Aug 2023 10:18:33 -0400 Message-Id: <20230807141833.564479-4-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807141833.564479-1-Frank.Li@nxp.com> References: <20230807141833.564479-1-Frank.Li@nxp.com> X-ClientProxiedBy: BYAPR02CA0057.namprd02.prod.outlook.com (2603:10b6:a03:54::34) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|AS5PR04MB9798:EE_ X-MS-Office365-Filtering-Correlation-Id: bde52dd6-7061-46bb-4714-08db97514448 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: izSon6rldi0ZhVZzc/3WSFFvY4ewGHHxflSmwobfrIMZNLg+bbXBqnNhEkjOexGre/M58i8+j5huwvwrl+uoVyyKRan2VnCq6rUAf1L0MVz9Us9qsfGzGApuVw8MKHxWTPUBxc0s/q0Q/4BB5HPstHwuw0gwuU0VUUNoaOQCiGjyAHicntt71Mtf/V7UBcn023fyjG6Qtdcsp/RMsaKhF3qlq6z+PR2IPSFSY6qn/Lg2Eys9Hyvtu9l6xVApfatloxxjNi8ZGc5ZDyLMxfzrcQJLxf4UkpAJZnbaPVA+fceqUlrQa9ERpvv4Usa+bBj4w49eRI8wEiJo8UJCaBPJcb6VsGWqw8jh7juNFHgKNRzMrVY6FqgT9BOD0J/hweYCGYVpNPzyAhHvIAmX1I94ewnwyRfjl18E+pi/gIGQEHoNsAYC+/WlJ2ZCeKeDu+cNFVauYODu8dS5DeAnwWhNgYdSwV/qKCXeCGwZSAF2l5v2bV8d/ct5Eu61WyYIT32Jv6HW6fUhXqcuQETs1wYcZpsAoa6cMZp14AAyBb1prp4Tkh9ja+arkmBbGQ39XuDdNQtOduM66iUCzr7cTgELtAGa3uD+oTn4MBy14Pqi3QRuTQMfJB1l/Hxxk5FEM8DJ 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)(346002)(396003)(136003)(39860400002)(366004)(376002)(451199021)(1800799003)(186006)(6512007)(26005)(6506007)(1076003)(36756003)(38350700002)(38100700002)(5660300002)(7416002)(86362001)(4326008)(2906002)(6916009)(66556008)(66476007)(41300700001)(66946007)(8676002)(316002)(8936002)(6666004)(52116002)(478600001)(2616005)(6486002)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VEjXSkziGkEi+1Mpw8hag4Zj+sW+wxTJLI9xR0cuwNIg3Pv6BkwyOtg0zbvVIvJ6UC7KMgeGxlCvq8vGVz+jf1WX0kTNKRAzSgK+FgYi+TUUUmRNaEWxyIu/STAPHC7+svZ4rHDttm28aedquiKtEUz77CEw/pv45uh9zCltpHUK8NXMvlwvKmkQVfmjvT0EvmQ75Wdj9NkCdXomnqJFct4t1PyUQpMPkNKYeHB2Q5TY3g5pjkWhj43tloSIbH3hBii9F3yfQP1+Fy1Diu1c6ximtq53EI+cXXleyNaEW+GMSiwDAI3Cvqn+LgaT9QNdGAaR+FvT0QQlTyJGkQQelJVtYSXQqW4wN7CrEM9WVVLAvAv3caPYJyU0lOnx5PCHl/0gAAXjPThGfFz+/Lie56fE9PvFnOxX5qyZ8IBqRxdEWOMsoaud9498VpZAVmE5aMnFXxeV612G/6ZfVo7S4PgYNnZfjOMyrn54Wtlik9bKVAr7c7yeH+fCwupi5vB+m1mMcFOuT8kDcoVZHrFHVUOBjNBYcJW1MXuLlTMYhwyNdWDxR4xO+hG1bDe/t6Dq9ODBPARpAyCwqfu6kSBbZSiV5XpoUdPFUKJNcRPMPZ5B/pYxkVAWN/7XYc6b6U/29gd8CMEEJyFNdvCRVyqC7yXaiMJXkFNlMwmwgoalJmr29coV0VBbizA2mmarotxPa1IKlc3TQDyJlq+ndUUdPIOJKB0d4GLyQt/wogOgQ+38fpUm0u4zdY08ddJcY4hjxejp7a8MTCRghelW4n7IYAZJ7JEOh9rnvczkulW4WpTk0h0kawJv97tpoKQYhU35K8AidMqFkGIUR3KHkCnFHXErUCID339Fp1wr1v75tj5T1nv7zidAuVQygwmlrLffXEyrTz1tBZWRIjarXXsDBaMP1V2NDDzZbq3ZwfQA4sZAXyrdi4i7S7YMp4wphyjEOYlmlsw5r9yK8IUrzRsaffNST2UfWkLMiJ+/CnCWWGIio1aYUQR0DzL4rBkorSkrdas90sXBfpT9urjMnXsNaAcddU7ZYogumNPJIbsHtW/NpAwzJSt75PZVi3H2jBAsjAMX5nJ4jN+J7keirpFxvLZpRxVbXhMNvdQUNTpDPAaRgKI/rRIkycThDW7PzMIUf1AE4jYkL/q50QAR9CS7ZNU/nhdFvF2/seTwd1GmwtXo6eT8jjYk7+xifs8Hx5HvKJ56hNV5IypnM0xDAE2sTf+k8nAFeIH7hoFY14ycnUsWf6qeQqT6cvso0LPxuO5mwSVG2jsB+v2blrvWvPG8K/4sAmsRZErSJpRA/ECYltx1ZygbK8ALDT0h+eB6KjL/Zpj2NVQXEp4VhvVbAh9H6UPlW9CZ8xL9Vyg0G/9Y6TuEGRN4cq1cObuKYY0ys8bSMSUBm57r0SP+/B060R37DFptgQmOOvulkaZzvU8B6c7m6WJCmQTKxZS0EW4TDWA0wNRg0EDCll29HZNgkyi18fA7gPj+kYETxHzyMNekZEMveX5Ny6SpLL1ge22hlzC3Hn+jtP/mxwv4x4H4jRoYOh09XzsSNqbNRdj+k6hYp0g= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: bde52dd6-7061-46bb-4714-08db97514448 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2023 14:19:09.8310 (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: b/IJw+PtKGz9bLGb19uhz4GGSoAvl/l7UjIFwfopNa2nOYcWTuZJ+XWijqr7rJD/h2+ANOorl1p/hO7RPKRnVA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS5PR04MB9798 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);