From patchwork Wed Dec 6 15:58:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 751321 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="bT3BUJHL" Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2063.outbound.protection.outlook.com [40.107.21.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C835110C3; Wed, 6 Dec 2023 07:59:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j7AxGVTKVR0pjpfF/ZM4gTbUPdwlK9ZA0Twa1OjTRu3RWJXOjLtVWROiZ/ajtiUDDnrXTkmDxRTDUOE9VtS4JUlzmhAGDGg53faW5jE1QLzfxo2wO3lon648woHvFK9NFu80jkdIAmCwwbRqzrNvFveEJZwa8ZzW76f994+M5O5BJ50f90WlSOwCNn4JKo2Slk+QfmoW/JgPl+vt+EnKEnhr12Vg9EiKmBemuqin0GnWi391yZiXk+EyRQt7bvuADlWzZZ2G5ESw6kAfp/f7jBvmYsp50yWr6Q+oWYecIVtuQWRbWjf0py6aIRNi8H7Yh8XVhwLnVsbUCbxbvfmH1w== 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=UbSzpiXuG5FYP7fd5ONqzOID+nLthrOouWqAEacFA1s=; b=kN1vB5HEVas/IRfCId+yaKW0Y1RDZ1L7vovzvthWFObX9gnMl0FmCrLFgHLgXOaKxVkF6yU+LcPfi/T7ruQHrBfhVviSUPnbXOntAxdLhn+OeAHdGEasdUcp1c5eAUSSHv3fyd41TArWdS14n2uyd7p18vxcUYD+0soPU7KKtc44YhgdXPc5iPueGGMLOw0/iHFAPE0hPHz365YMX2iHdySZDhhARSQqt1aKsS1aXlr2dZIQtM/IySEnUIXrG6vepwxQzNW8PXB+k9WP54H+qoWq384UuH6dPjEOHd0sK81g6k6HvKeCN5BGhFt2ju/NCCuvm4akcm4t9hWWHHQFKg== 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=UbSzpiXuG5FYP7fd5ONqzOID+nLthrOouWqAEacFA1s=; b=bT3BUJHLMCHIO50S6mMWmijA350H+PEM5VmJnZBBD7X4st/m/i46cDt2xBNNWXr7ttYm7MqYfrYLRiuKn38LlOfs8rYxOjEZgTLtvi5nI3yYni4ZqwQL5iE2Ocv0+TQRQPVQCIM+vfE0I3JMrOO7uz3N//3kliq81SWV/2mKt44= 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 DB9PR04MB8123.eurprd04.prod.outlook.com (2603:10a6:10:243::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.24; Wed, 6 Dec 2023 15:59:47 +0000 Received: from AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::95f5:5118:258f:ee40]) by AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::95f5:5118:258f:ee40%6]) with mapi id 15.20.7068.022; Wed, 6 Dec 2023 15:59:47 +0000 From: Frank Li To: imx@lists.linux.dev, Richard Zhu , Lucas Stach , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Bjorn Helgaas , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , linux-pci@vger.kernel.org (open list:PCI DRIVER FOR IMX6), linux-arm-kernel@lists.infradead.org (moderated list:PCI DRIVER FOR IMX6), devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 5/9] PCI: imx6: Simplify ltssm_enable() by using ltssm_off and ltssm_mask Date: Wed, 6 Dec 2023 10:58:59 -0500 Message-Id: <20231206155903.566194-6-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231206155903.566194-1-Frank.Li@nxp.com> References: <20231206155903.566194-1-Frank.Li@nxp.com> X-ClientProxiedBy: BYAPR21CA0015.namprd21.prod.outlook.com (2603:10b6:a03:114::25) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|DB9PR04MB8123:EE_ X-MS-Office365-Filtering-Correlation-Id: 63313520-f9f3-4fa1-5872-08dbf6745f26 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YefGQEIwXTJw5uN17HNXaazK2cAC3fhNcbBZV65GLMRH83k7FUiAUzA7zn9FIxZPMy6u+AUSGVeqytE46PQVhlojIUBbcxntZqP4APp4coukaAEYRw11RLjzscV5UaqW3i3XJDNAw43+TMIieMsGYsnIfB1x3LlW3WUDNaJTdQgOuyuP4l2U5Gavg7oIRGTdP1DhnJSl+QVuYGE87Z1h15/6QpWlEIIQgkHIwZSaoZy9pP6QznJ8NDiRwvLtGSCn41JX/vRZ3CoCj0E/Cs7faRrqIhKDraAieeiFCxrtYHi++FY2BbZVKId0I0ffXH6vJJoaa5ZHvZFubAnlxck+z4qGn1sgsTPLpdbRho3Of4OAeaAotWJbysrofsK3JRZY0nZGhwPGQ36sOyfhFyfqOjTZ3dLD9SW90gOb4DsTPoK5Y8km9TlqcVugOJa7dC5p44L/cAtY59Yu4eDtWW5ZGNiDbqpC6UhUYicPTnu4cjeovn3FhTMqi8IbU0hDP+IL+NzN4BeIoup2Bo5S+BhTCpjr4VAhUkvoQdPw6EOXswWIDg7S2jm4dLWvRo7cEyPGC6bOs1SXTXC14Lg2B6DxlNtMgtAy5+dBUbw+W8EgUs8sRMr3jzSkbPkg+nVBEVXlz2f/NQvyPxdTFEfYiV3OaA== 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)(39860400002)(376002)(136003)(396003)(346002)(366004)(230922051799003)(1800799012)(451199024)(186009)(64100799003)(1076003)(41300700001)(83380400001)(36756003)(6666004)(52116002)(6506007)(2616005)(26005)(6512007)(478600001)(921008)(38350700005)(6486002)(7416002)(316002)(66946007)(66556008)(66476007)(86362001)(38100700002)(110136005)(2906002)(8936002)(8676002)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GqeT8WLElbOiIwjb1MnOUkWcG4C8jFBcGQYNAYKvuX3c8uXu1tmq9GokB/xSAn9n0hwS+AZ+PocolGAM0XJe/hVHw1uCUbJfIEJeHJRMExmB9Hydl35x+vD0yYMaZJIG54G/Rmt6MCj/a+sEYujyHRcqqd4PbcgcJRnm/I6Tj1Sgy9o7TylgLmw/pzeaA63qmiVHX7yNxp4DY6DSa22VixwpFP89AYjQsvsohgfgb3N5vgDfGeZZV3qMzLG87UHWSMwqyBW10zjonwyzACaaK1d5d8bJ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CSMzhUQlPnUIpPAFM8XYKERnk8BNU+3iKvIUOTAHsySaFnKb1omCMZxVScg7L/wEiZ2yKRXISYwTrXha/UVwOPhgbxzs+WGcQPbStBoWJbgvPmZVHfM7TYEN+EQcFu0xf1KDSVhWhx7S78DgDM5u41MLilv2/zpgzb2JxEu+9lyhEe4gxC3VJDg5Wx4AqskYzhiL3TEBMcyuEywUWcLU= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 63313520-f9f3-4fa1-5872-08dbf6745f26 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 15:59:47.7685 (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: pL1d+c79vm7OIjg9LDLbpAaKlQD4QGHCqy3FM9Ey5MPccsULE1Jz3PjvwwK0Yil4qcI0xZZn/nCj/y4TyY13ew== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8123 Add drvdata::ltssm_off and drvdata::ltssm_mask to simple imx6_pcie_ltssm_enable(disable)() logic. Signed-off-by: Frank Li --- drivers/pci/controller/dwc/pci-imx6.c | 37 ++++++++++++--------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index 239ef439ba70..334e714a7e96 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -75,6 +75,8 @@ struct imx6_pcie_drvdata { u32 flags; int dbi_length; const char *gpr; + const u32 ltssm_off; + const u32 ltssm_mask; }; struct imx6_pcie { @@ -815,18 +817,11 @@ static int imx6_pcie_wait_for_speed_change(struct imx6_pcie *imx6_pcie) static void imx6_pcie_ltssm_enable(struct device *dev) { struct imx6_pcie *imx6_pcie = dev_get_drvdata(dev); + const struct imx6_pcie_drvdata *drvdata = imx6_pcie->drvdata; - switch (imx6_pcie->drvdata->variant) { - case IMX6Q: - case IMX6SX: - case IMX6QP: - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, - IMX6Q_GPR12_PCIE_CTL_2, - IMX6Q_GPR12_PCIE_CTL_2); - break; - default: - break; - } + if (drvdata->ltssm_mask) + regmap_update_bits(imx6_pcie->iomuxc_gpr, drvdata->ltssm_off, drvdata->ltssm_mask, + drvdata->ltssm_mask); if (imx6_check_flag(imx6_pcie, IMX6_PCIE_FLAG_HAS_APP_RESET)) reset_control_deassert(imx6_pcie->apps_reset); @@ -835,17 +830,11 @@ static void imx6_pcie_ltssm_enable(struct device *dev) static void imx6_pcie_ltssm_disable(struct device *dev) { struct imx6_pcie *imx6_pcie = dev_get_drvdata(dev); + const struct imx6_pcie_drvdata *drvdata = imx6_pcie->drvdata; - switch (imx6_pcie->drvdata->variant) { - case IMX6Q: - case IMX6SX: - case IMX6QP: - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, - IMX6Q_GPR12_PCIE_CTL_2, 0); - break; - default: - break; - } + if (drvdata->ltssm_mask) + regmap_update_bits(imx6_pcie->iomuxc_gpr, drvdata->ltssm_off, + drvdata->ltssm_mask, 0); if (imx6_check_flag(imx6_pcie, IMX6_PCIE_FLAG_HAS_APP_RESET)) reset_control_assert(imx6_pcie->apps_reset); @@ -1451,6 +1440,8 @@ static const struct imx6_pcie_drvdata drvdata[] = { IMX6_PCIE_FLAG_IMX6_SPEED_CHANGE, .dbi_length = 0x200, .gpr = "fsl,imx6q-iomuxc-gpr", + .ltssm_off = IOMUXC_GPR12, + .ltssm_mask = IMX6Q_GPR12_PCIE_CTL_2, }, [IMX6SX] = { .variant = IMX6SX, @@ -1459,6 +1450,8 @@ static const struct imx6_pcie_drvdata drvdata[] = { IMX6_PCIE_FLAG_SUPPORTS_SUSPEND | IMX6_PCIE_FLAG_HAS_CLK_INBOUND_AXI, .gpr = "fsl,imx6q-iomuxc-gpr", + .ltssm_off = IOMUXC_GPR12, + .ltssm_mask = IMX6Q_GPR12_PCIE_CTL_2, }, [IMX6QP] = { .variant = IMX6QP, @@ -1467,6 +1460,8 @@ static const struct imx6_pcie_drvdata drvdata[] = { IMX6_PCIE_FLAG_SUPPORTS_SUSPEND, .dbi_length = 0x200, .gpr = "fsl,imx6q-iomuxc-gpr", + .ltssm_off = IOMUXC_GPR12, + .ltssm_mask = IMX6Q_GPR12_PCIE_CTL_2, }, [IMX7D] = { .variant = IMX7D,