From patchwork Mon Jan 8 23:21:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13514153 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2047.outbound.protection.outlook.com [40.107.8.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E42BE5732B; Mon, 8 Jan 2024 23:22:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="oqIIBBsD" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ltnhsRaY2dnTi/y2abv69gjpdzVpoDIDsZm/2uK7L4TgBA6urg3kC8ul6P8/QCG3p18ctcN2M9IfhM0zIu3r+6Ty2FIMkmqP3IEbtJdx8s8tQ7nLXeWMBtn3CTmhelFT0tuXZvpC4pbYkyCF1EsKUKfFqVF+v6lSo5cGeB/WmXFoWtZiTNTd6Rv7m71NN0Hf0FI3ahscyBRInMw2oRIXSpJD/1IVSl+yptFDZMJStPmeinD8EtPs8CaefSBo+2IRN3SP0ZcgwwBQXNr0ARKSThf+cg5182DVAxndtujrdoQ1xCBD/a3pvMnHuuwX5sdgQuc95BlwuYOllKxF45qYSw== 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=CsvNnu8SlEkTdDeClAfZIHbuLoehsz9bDSDrPJk5scU=; b=A/TgQb8CmuJR3jsOg7QwKEwkDgDQo1hJewVoPtq8i/a3HSw2TRDRI61kGbnFoJsul8PbwEdNKt+rlRgRsyprsPsn4H47U/Xt/mvJM9HUuXSgXXrjbbpeKJPVaK+tRX7E9M824LnC8qvuotOk1e8F6hYCjx6BDXaf2Gdj2MbLAwIv5QFey2xztpPvUBOXiY9r36jDPi2t1ZZzkSG3bfJPFZ37zeApQ876WNzze5XPB0350wVDaRFQ1FnRMvzQCkTrMsk4sO2y6/hbiLnR/PVVPU2vHL074vNKVndLmUF1OiFJJ6bD9766z3JoFqgeevA25lCgYymHlLLszdc0eK07Fg== 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=CsvNnu8SlEkTdDeClAfZIHbuLoehsz9bDSDrPJk5scU=; b=oqIIBBsDSYiPc2jwzA8h3ZwqeOFsHov/EnG5wuSb+mpdmJIPcm9VJ2cuZOI3p8Klu8tUpCJs3hmxievF0NF0IM5Z2tOwPSPkqc9r/41oMOglyBH+ICc+IT9nLhL+pZfgwuLIormMKXLa0yK1e6h6VyzIFsnYD342Q7U3Tpd+Fjo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB7511.eurprd04.prod.outlook.com (2603:10a6:20b:23f::5) by AS4PR04MB9338.eurprd04.prod.outlook.com (2603:10a6:20b:4e6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.21; Mon, 8 Jan 2024 23:22:39 +0000 Received: from AS8PR04MB7511.eurprd04.prod.outlook.com ([fe80::8ee3:bac5:a2da:d469]) by AS8PR04MB7511.eurprd04.prod.outlook.com ([fe80::8ee3:bac5:a2da:d469%4]) with mapi id 15.20.7159.020; Mon, 8 Jan 2024 23:22:39 +0000 From: Frank Li To: krzysztof.kozlowski@linaro.org Cc: Frank.Li@nxp.com, bhelgaas@google.com, conor+dt@kernel.org, devicetree@vger.kernel.org, festevam@gmail.com, helgaas@kernel.org, hongxing.zhu@nxp.com, imx@lists.linux.dev, kernel@pengutronix.de, krzysztof.kozlowski+dt@linaro.org, kw@linux.com, l.stach@pengutronix.de, linux-arm-kernel@lists.infradead.org, linux-imx@nxp.com, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, lpieralisi@kernel.org, manivannan.sadhasivam@linaro.org, robh@kernel.org, s.hauer@pengutronix.de, shawnguo@kernel.org Subject: [PATCH v8 06/16] PCI: imx6: Simplify ltssm_enable() by using ltssm_off and ltssm_mask Date: Mon, 8 Jan 2024 18:21:35 -0500 Message-Id: <20240108232145.2116455-7-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240108232145.2116455-1-Frank.Li@nxp.com> References: <20240108232145.2116455-1-Frank.Li@nxp.com> X-ClientProxiedBy: BYAPR02CA0063.namprd02.prod.outlook.com (2603:10b6:a03:54::40) To AS8PR04MB7511.eurprd04.prod.outlook.com (2603:10a6:20b:23f::5) Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB7511:EE_|AS4PR04MB9338:EE_ X-MS-Office365-Filtering-Correlation-Id: 11a4b0db-a1d9-4905-515e-08dc10a0b48b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8yIvxKu+dGd0lJ+C80MYCakjw9kPZNYk8jBmINOhtBTu+bYz32Hstg3YIeUgnodZ9D6O8Na+knszqRtODUERBXFb8eZN6azHOOMLdLl5NWFU0jxwah1FODoZpUK7NCwFMIqZsRS9UBRn9F8cfUtkLlFfkMjKRgfibDAhS/DHrVsvqcm0APggYFzGtqJDzhTM15knKIiSY6AAZstppSabqqJ81u2Bgi5eQ35EEN+6eYsR6rVC+8/2xD+LVHijo2jHlh0H+udmMnPnYt1+m7jUiuALbBSQ4kUkMMbOWD+hICZygFAIm9To7fJTwxn9QSxrWg0I0XZhfscMsksAmU9hpz36YiJT5I8lQLH3gQXyfExHxkkCE0wJefm85sWcyGzMHbp/70JAuJD4vpYQRUFJaDeSRZbQZvL6x/7TNnjNloTYUg3sHn+i6vi5hV00PI8wnKKACLHtKkJfPv9EaKNCxe5rwqdcUlxN+Zg3MNHSPYNUKVEEYRIWQic9UcYdhdqPOWc3H0pdH3FKgfs36VI0T1VabxJeGZf/lSjRCDBuXSGJAJaTP2v4SVm5/J2aSzxfO2I85+Y75fuyxST1KtE6l2iroUQuMQk3NoeU1sZd9UsV+GKwm2XGRxwpQxeAuw7h X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR04MB7511.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(39860400002)(376002)(346002)(396003)(366004)(230922051799003)(64100799003)(186009)(451199024)(1800799012)(52116002)(6506007)(2616005)(1076003)(6666004)(6512007)(478600001)(26005)(6486002)(38100700002)(86362001)(38350700005)(36756003)(41300700001)(83380400001)(7416002)(66556008)(2906002)(316002)(66476007)(6916009)(4326008)(5660300002)(8676002)(8936002)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mTycPkRSzcD2EW8h9Eku25Bbid34XHuowzGQ1wRAD1hAWiHq831BnUP/KsmjwtaKMVk3DUVSZKlBODvFqK0NdF+Rug8z7zHcusW77aAkQjHG/KBSWS84aXY7WL01IobtDTXHzHKLD6L2ZDXQ7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57PTWwdjLH7X5Hnkw/U/9Rrvon9PyROiMCbn8BrxXNOO5J1ZJVa/zVZ4ev17kZ65pNbPJa6DP8MRHhtw4s0B7UOnc2sk9uZKXkpx3dTAi59gKnsNHLu83QxKVmKUiNsFH3SE2mcS2HQkHG8aqL7r0zqAeTtp1/v0Fb5XTJMpbfotHEwmSU+E9chl8coz6qDM/bBBfHvnnFdn3gLowdSilUA8Ij4su8U8BcQdDwJ/3dbvwUSolKC5VBRiPAPghsAmY5Efg4FC7b2yY0gV4Mj/j4NTl+EXn+Or5a1ZapuM7dr3b7E01FQOKxY+z47ptJW9giMVrpq5u8cFkWRt2Q1eBXfg0lWZdqoL3ftjgGDRrX4p2JFgYY/S X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 11a4b0db-a1d9-4905-515e-08dc10a0b48b X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB7511.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2024 23:22:39.1423 (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: brh+GJl0Hp1MJgcL+3IWGdmxuXuwWYmBhoIEHYCK9/zjPIGnJKP/AE/s/By3C5jf4EtKqRe+zAe9SNt5yvbMuQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR04MB9338 Add drvdata::ltssm_off and drvdata::ltssm_mask to simple imx6_pcie_ltssm_enable(disable)() logic. Reviewed-by: Manivannan Sadhasivam Signed-off-by: Frank Li --- Notes: Change from v7 to v8 - Add Manivannan Sadhasivam's review tag Change from v1 to v7 - none 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 06aa40a185283..818e73157e724 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -76,6 +76,8 @@ struct imx6_pcie_drvdata { const char *gpr; const char * const *clk_names; const u32 clks_cnt; + const u32 ltssm_off; + const u32 ltssm_mask; }; struct imx6_pcie { @@ -775,18 +777,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); reset_control_deassert(imx6_pcie->apps_reset); } @@ -794,17 +789,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); reset_control_assert(imx6_pcie->apps_reset); } @@ -1398,6 +1387,8 @@ static const struct imx6_pcie_drvdata drvdata[] = { .gpr = "fsl,imx6q-iomuxc-gpr", .clk_names = imx6_3clks_bus_pcie_phy, .clks_cnt = ARRAY_SIZE(imx6_3clks_bus_pcie_phy), + .ltssm_off = IOMUXC_GPR12, + .ltssm_mask = IMX6Q_GPR12_PCIE_CTL_2, }, [IMX6SX] = { .variant = IMX6SX, @@ -1407,6 +1398,8 @@ static const struct imx6_pcie_drvdata drvdata[] = { .gpr = "fsl,imx6q-iomuxc-gpr", .clk_names = imx6_4clks_bus_pcie_phy_axi, .clks_cnt = ARRAY_SIZE(imx6_4clks_bus_pcie_phy_axi), + .ltssm_off = IOMUXC_GPR12, + .ltssm_mask = IMX6Q_GPR12_PCIE_CTL_2, }, [IMX6QP] = { .variant = IMX6QP, @@ -1417,6 +1410,8 @@ static const struct imx6_pcie_drvdata drvdata[] = { .gpr = "fsl,imx6q-iomuxc-gpr", .clk_names = imx6_3clks_bus_pcie_phy, .clks_cnt = ARRAY_SIZE(imx6_3clks_bus_pcie_phy), + .ltssm_off = IOMUXC_GPR12, + .ltssm_mask = IMX6Q_GPR12_PCIE_CTL_2, }, [IMX7D] = { .variant = IMX7D,