From patchwork Wed Dec 6 15:58:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 751323 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="rT0lRgEC" Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2068.outbound.protection.outlook.com [40.107.21.68]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91DEDDC; Wed, 6 Dec 2023 07:59:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dyCd5O3wAjdULY9wTEVcbw9Y+LWr6Lgyfc6bOV+vjE5tHe2PBf3YxFJGvYEXu89BDi8dY58zvtQVkjMkeTAC08EnTWeWr71YhZuJcw+PkrfkT/OidfaDsKBjehOzLmh4+j90ZBNR02qzNELcz39aktWzhUZ7HZ7N9BuflWcltlQdcK7FQd8rIcgEZdmW3TbXAcfWLEHLxyi1kt190IOKlmr+2lKyoWWZF3zMsp/ZSlH5Ra8vwQz6pF5kSB/gHCNjyXoHOOuHbzQn4cqxfN2Kl+k+E52tb2gEUKi60OluGcfQ9fi1D1aFbpp85x7vfcaClbWk3WwY+st23alLwqZ8ZA== 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=Yl+P2vynjICwTZ9VPekPVgFlODQdtDC6Cz80GXK7NrI=; b=ajlNU/Y1Oh+C+6Iz/vPCo8NMdFwyqrcwMUR1N1GOl7iZMK503h6xP7JzRJW4jD+XT2PC89kJ8PPGCEuIX2k2uACb+x9Z1Iq7bqWY83dulwyDv2IqZLhPxS7P1x2MwSz2G/81AV8j83N8qb31WwodNRmix1jqRF3F+7ooI9STT//nb6fZubYNYQqKuiWE2HSU4PpaCLgC9ApCf9pT6O26ngGGDRJ2eJB/Apuz92OmVStY0MB34Gp6+ABf0NXcPRIYg4EG/mLq74fA/Jzwy6cPfURzHlWkKzHyHym4HdZ4mBaJUHWfd+8mthg+PQXCK2ztRVxua2UxQkCdcyOgXozv1A== 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=Yl+P2vynjICwTZ9VPekPVgFlODQdtDC6Cz80GXK7NrI=; b=rT0lRgECIveSrMlwvarTlPBqZq4NaKV2rpIpDZxYBbpozLPuQ26eQLULxhZ3DwzfDyJkI9IQtZed+7tfe/K/LgGzCdLVH+3AuD8zJ2pEpyfnKVmPlU+9K/29eEf/L7Nspyq4pVHAsax1wRozCdc/DbqabBF4ARiLiSEKG9WZvJ4= 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:28 +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:28 +0000 From: Frank Li To: imx@lists.linux.dev, Richard Zhu , Lucas Stach , Bjorn Helgaas , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , 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 1/9] PCI: imx6: Simplify clock handling by using HAS_CLK_* bitmask Date: Wed, 6 Dec 2023 10:58:55 -0500 Message-Id: <20231206155903.566194-2-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: 31f28c69-4ed3-4096-cf69-08dbf67453b1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5jvDl1lFCWjXTPrxauBg+xJJlQoyv06ke6PSieJZBnLFs/lKp6RUa+O/nnbwQaPPOUNqkX9+ND5+U/ErqWKT6YKX0rzExU2TVuDwmnZF1xjS7s+NuFPOOyf8Be7M3JlIZIqWliBwc+ihy9mGdt+pQUfRWl9CL8PpWDhbzfIr1VOBpZflRfwSdri6l4Rjq2SJFHclllT3jjaApUnZig4hedQ8ToQ4MSNj9Yk3P+KFA2xc8Dh3sEtLZfSKFn55EcYYtn6qY4i4nUwwxQXa3eHoUbjWeanpXT2Ks3OvQ0QAEdqpn4Se0ve8VU1HjOG1K71hRvRu+egsZ79PHUPMwre+Yfwpg5YlshUwuuQrs+F/4fNaFiYdjX4dhmBr3qUtwMe6jYc9pYXjcA+rdeitFrkHo+1EpGifwTNvHHKrLWQ3Jyz8BTb8HT+faRUIALJ7xb6fMmEfaHRYjhfb36L0Ws/gfv0qextneQxGrL11kvDP4BfkFioBJaEc0BUi/YiBjBrhmxfaDmRToN+dUj7TM+2DY45DC9j/5ZU7NIFIp6AsV4Ub5iNZMVe5YS/L0mSRLtc/N/Ac1mxSwHLAd7Z4AZMtB1H0XmxcJDpunmUe0v6XTw8Sqew8RMM/H5ej++/elplrThXlmnpdxRhReo8hitsUmQ== 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: MjIcGtm9sAfA9XPV4/4Mk8+zIueYM5GlkeBtEdv+A+FULFVuobFYbiF1c0j6L9EgP/NKE5tdgyiPIX9SxTPtfNZ/o1AcdOmAWYdCRM8xHc5h2YxjvoPvPuCgkmRnfwjlL+Mnw9altLCO0hKVkt5j+OurNmTE/J1oq0HcRz7DVw0XBnNHeY+iTI7W53tURCk/fOfaqb9WJy5KSqGB0DCy71KpO3IVZH5tHWxpkag0phR9ePdyu2nD9ApnJ8V2kHjqTDstrK4oigDIdE34j4iVflVflLrUjbhRgC57IP4vFn26AAZmPwbFjC2YSJG9+sxfo0IrGHHUWVnLfLr9C1EfRQj89/LwfDL71qZGI5QIfoQ0f5wepdl9qjQxbEiqpKL/Yx0UcljYY5gzaiy61RXXYox1wBwMB7x6/vPrv+xW5mXWL5Vw4IRd6HdQvUWGc9E4iS/WRJ41yIUsGYKfFFOX1SjnzhqAGB4H67RbtpoZgyURVAZGgqc8kMghNaNV0dMXGRMzX8CvTAbGEOfrrr5tf2pqcYg27UxHnIAE7DEFcdeXepRmN7+dDc/9arrPsaf8Vzv/Jkjqq+ztMAb0059D4q3zqef+wPOC09he5UX/Yq5l+nEsCnFHIOa4l+3gd2sBOnYJQ8uV8TqzQGJ/ZHeTnirUA+VA3KKMVz2lIYMDfiU0x/kBOS3LZxAbYf/KwOcjYsB/ycYlKKNMffZcu5IESc5NqizUSJhbFVwX1jbl5m7CTybQvAi1NJrplD+7zphbGGd3R9NvXEmCEykdGsoLH/x0CTjNdlpTl6Tx9VTCEVTQdPpo9axELGANAolmrCtxfKI02AB9q1mxW9aZbaExPeuUf/ZXotzNUo0i95+IjCCLirINQHlMyjozQ46LqiDE2bvJ65dYf1ErG7PsuU3xLw6wR/stfdet7hi/QecUswKenSrx8LATXPRB0AOVuOSvY8wzJY8fyz20nOrulFW08cAO9G1xXsR33EszWNAJeLXZd0GvOh8pGc1Wfa/M0EDsUfIpHLXQ8b6gZxMw46bkDhPyM7DAX51u7Ww7diXlTvOJGqhMJKatzAu5KEdXlSmr79gqpNzF9hA3vmZt9OS3V1pUh62CCIEvBzGoruo16RjPbIgMxfmPJM+8lcObJAFVNvy1Yl28oTHxRrL2RFcYWjxZvZ4LGPLUIJNjdjpLvtDevM4r3JxDGBNASDqgnOi6DmMvzYtbv0dvxGDmpsxhUbyUDtT5bPVS32jlItocKCbaGN1I7o5ORdRNH2CndqKw5lwgqsKAMySSEDigQe/PUkTwVpOp1igqbph8p6wuWoTf7zufhRfZhmJ5VuzG4DyyU5XYPLYLId69Q1yV8TNTvzgiCey9t11axp4bYuyLazBSqM6+onHdvTnH4hutp5oR2tbfQHr5QjF1pjgTGH+vykcWoIJJBQe21GCafumMGY48OqnxD+1SzC1Jmic/n2A5wRMH9ZxyOjhHpKqHO6jg1uI8pETJEoOYZ9Xn3nopZiypUkI3eEbYD/QiisQuJEymomfqCWVgjzwPQncjqtTWr/ry3tq0OOqQ12Xhy+4M+kE= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 31f28c69-4ed3-4096-cf69-08dbf67453b1 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:28.5782 (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: kcXWS8+cUIPFvR1r0KRUoQPi6risbl9K8/N6VMuihjSvc49udP9HXPWfU76qvlI4wr26SDY4VkFwq4uKPydXHA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8123 Refactors the clock handling logic in the imx6 PCI driver by adding HAS_CLK_* bitmask define for drvdata::flags . Simplifies the code and makes it more maintainable, as future additions of SOC support will only require straightforward changes. The drvdata::flags and a bitmask ensures a cleaner and more scalable switch-case structure for handling clocks. Signed-off-by: Frank Li --- drivers/pci/controller/dwc/pci-imx6.c | 84 +++++++++++++-------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index 74703362aeec..8a9b527934f8 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -60,6 +60,10 @@ enum imx6_pcie_variants { #define IMX6_PCIE_FLAG_IMX6_PHY BIT(0) #define IMX6_PCIE_FLAG_IMX6_SPEED_CHANGE BIT(1) #define IMX6_PCIE_FLAG_SUPPORTS_SUSPEND BIT(2) +#define IMX6_PCIE_FLAG_HAS_CLK_INBOUND_AXI BIT(3) +#define IMX6_PCIE_FLAG_HAS_CLK_AUX BIT(4) + +#define imx6_check_flag(pci, val) (pci->drvdata->flags & val) struct imx6_pcie_drvdata { enum imx6_pcie_variants variant; @@ -550,19 +554,23 @@ static int imx6_pcie_attach_pd(struct device *dev) static int imx6_pcie_enable_ref_clk(struct imx6_pcie *imx6_pcie) { - struct dw_pcie *pci = imx6_pcie->pci; - struct device *dev = pci->dev; unsigned int offset; int ret = 0; - switch (imx6_pcie->drvdata->variant) { - case IMX6SX: + if (imx6_check_flag(imx6_pcie, IMX6_PCIE_FLAG_HAS_CLK_INBOUND_AXI)) { ret = clk_prepare_enable(imx6_pcie->pcie_inbound_axi); - if (ret) { - dev_err(dev, "unable to enable pcie_axi clock\n"); - break; - } + if (ret) + return ret; + } + if (imx6_check_flag(imx6_pcie, IMX6_PCIE_FLAG_HAS_CLK_AUX)) { + ret = clk_prepare_enable(imx6_pcie->pcie_aux); + if (ret) + return ret; + } + + switch (imx6_pcie->drvdata->variant) { + case IMX6SX: regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, IMX6SX_GPR12_PCIE_TEST_POWERDOWN, 0); break; @@ -589,12 +597,6 @@ static int imx6_pcie_enable_ref_clk(struct imx6_pcie *imx6_pcie) case IMX8MQ_EP: case IMX8MP: case IMX8MP_EP: - ret = clk_prepare_enable(imx6_pcie->pcie_aux); - if (ret) { - dev_err(dev, "unable to enable pcie_aux clock\n"); - break; - } - offset = imx6_pcie_grp_offset(imx6_pcie); /* * Set the over ride low and enabled @@ -614,10 +616,13 @@ static int imx6_pcie_enable_ref_clk(struct imx6_pcie *imx6_pcie) static void imx6_pcie_disable_ref_clk(struct imx6_pcie *imx6_pcie) { - switch (imx6_pcie->drvdata->variant) { - case IMX6SX: + if (imx6_check_flag(imx6_pcie, IMX6_PCIE_FLAG_HAS_CLK_INBOUND_AXI)) clk_disable_unprepare(imx6_pcie->pcie_inbound_axi); - break; + + if (imx6_check_flag(imx6_pcie, IMX6_PCIE_FLAG_HAS_CLK_AUX)) + clk_disable_unprepare(imx6_pcie->pcie_aux); + + switch (imx6_pcie->drvdata->variant) { case IMX6QP: case IMX6Q: regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1, @@ -631,14 +636,6 @@ static void imx6_pcie_disable_ref_clk(struct imx6_pcie *imx6_pcie) IMX7D_GPR12_PCIE_PHY_REFCLK_SEL, IMX7D_GPR12_PCIE_PHY_REFCLK_SEL); break; - case IMX8MM: - case IMX8MM_EP: - case IMX8MQ: - case IMX8MQ_EP: - case IMX8MP: - case IMX8MP_EP: - clk_disable_unprepare(imx6_pcie->pcie_aux); - break; default: break; } @@ -1316,21 +1313,21 @@ static int imx6_pcie_probe(struct platform_device *pdev) return dev_err_probe(dev, PTR_ERR(imx6_pcie->pcie), "pcie clock source missing or invalid\n"); - switch (imx6_pcie->drvdata->variant) { - case IMX6SX: - imx6_pcie->pcie_inbound_axi = devm_clk_get(dev, - "pcie_inbound_axi"); + if (imx6_check_flag(imx6_pcie, IMX6_PCIE_FLAG_HAS_CLK_INBOUND_AXI)) { + imx6_pcie->pcie_inbound_axi = devm_clk_get(dev, "pcie_inbound_axi"); if (IS_ERR(imx6_pcie->pcie_inbound_axi)) - return dev_err_probe(dev, PTR_ERR(imx6_pcie->pcie_inbound_axi), - "pcie_inbound_axi clock missing or invalid\n"); - break; - case IMX8MQ: - case IMX8MQ_EP: + dev_err_probe(dev, PTR_ERR(imx6_pcie->pcie_inbound_axi), + "pcie_inbound_axi clock missing or invalid\n"); + } + + if (imx6_check_flag(imx6_pcie, IMX6_PCIE_FLAG_HAS_CLK_AUX)) { imx6_pcie->pcie_aux = devm_clk_get(dev, "pcie_aux"); if (IS_ERR(imx6_pcie->pcie_aux)) return dev_err_probe(dev, PTR_ERR(imx6_pcie->pcie_aux), "pcie_aux clock source missing or invalid\n"); - fallthrough; + } + + switch (imx6_pcie->drvdata->variant) { case IMX7D: if (dbi_base->start == IMX8MQ_PCIE2_BASE_ADDR) imx6_pcie->controller_id = 1; @@ -1353,10 +1350,6 @@ static int imx6_pcie_probe(struct platform_device *pdev) case IMX8MM_EP: case IMX8MP: case IMX8MP_EP: - imx6_pcie->pcie_aux = devm_clk_get(dev, "pcie_aux"); - if (IS_ERR(imx6_pcie->pcie_aux)) - return dev_err_probe(dev, PTR_ERR(imx6_pcie->pcie_aux), - "pcie_aux clock source missing or invalid\n"); imx6_pcie->apps_reset = devm_reset_control_get_exclusive(dev, "apps"); if (IS_ERR(imx6_pcie->apps_reset)) @@ -1482,7 +1475,8 @@ static const struct imx6_pcie_drvdata drvdata[] = { .variant = IMX6SX, .flags = IMX6_PCIE_FLAG_IMX6_PHY | IMX6_PCIE_FLAG_IMX6_SPEED_CHANGE | - IMX6_PCIE_FLAG_SUPPORTS_SUSPEND, + IMX6_PCIE_FLAG_SUPPORTS_SUSPEND | + IMX6_PCIE_FLAG_HAS_CLK_INBOUND_AXI, .gpr = "fsl,imx6q-iomuxc-gpr", }, [IMX6QP] = { @@ -1500,30 +1494,36 @@ static const struct imx6_pcie_drvdata drvdata[] = { }, [IMX8MQ] = { .variant = IMX8MQ, + .flags = IMX6_PCIE_FLAG_HAS_CLK_AUX, .gpr = "fsl,imx8mq-iomuxc-gpr", }, [IMX8MM] = { .variant = IMX8MM, - .flags = IMX6_PCIE_FLAG_SUPPORTS_SUSPEND, + .flags = IMX6_PCIE_FLAG_SUPPORTS_SUSPEND | + IMX6_PCIE_FLAG_HAS_CLK_AUX, .gpr = "fsl,imx8mm-iomuxc-gpr", }, [IMX8MP] = { .variant = IMX8MP, - .flags = IMX6_PCIE_FLAG_SUPPORTS_SUSPEND, + .flags = IMX6_PCIE_FLAG_SUPPORTS_SUSPEND | + IMX6_PCIE_FLAG_HAS_CLK_AUX, .gpr = "fsl,imx8mp-iomuxc-gpr", }, [IMX8MQ_EP] = { .variant = IMX8MQ_EP, + .flags = IMX6_PCIE_FLAG_HAS_CLK_AUX, .mode = DW_PCIE_EP_TYPE, .gpr = "fsl,imx8mq-iomuxc-gpr", }, [IMX8MM_EP] = { .variant = IMX8MM_EP, + .flags = IMX6_PCIE_FLAG_HAS_CLK_AUX, .mode = DW_PCIE_EP_TYPE, .gpr = "fsl,imx8mm-iomuxc-gpr", }, [IMX8MP_EP] = { .variant = IMX8MP_EP, + .flags = IMX6_PCIE_FLAG_HAS_CLK_AUX, .mode = DW_PCIE_EP_TYPE, .gpr = "fsl,imx8mp-iomuxc-gpr", }, From patchwork Wed Dec 6 15:58:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 751322 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="j5JbaDz0" Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2047.outbound.protection.outlook.com [40.107.21.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F4151112; Wed, 6 Dec 2023 07:59:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LoOCiGfM5zDpLcfBQAfSFttnjcFbatrAP7yEsJvXlUrFxUXBOSAcg1YmNqrsIlUaC8g8rFmcvbx9Bp4H+5hVJ7QpUbJ9aKQKanqb4lJEwwrhoISn3Cy8HuLiEPykYdpq+weyEFEv3rTVR9NlCWtRLnZBj8BtSXrmCAGUUaqRSQ2lEhjmjC7FEmM5zXJanyG9lwhw5H6qtU3Q3u8zs8U0ojoE81ig3Bre/gRQpyaBnDr83TClvcJ1HTzPSAMGeB4dHpNd2bfpPox38RjO8ZEen+XhzjNvu4ILnw5/QRF6gF49M4hD1VbVBwsmT2jDoJaU+h1XplkkmEIZWI0dyojw2Q== 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=nLFrgFMTx88zjL0CQUkclXOg54v0L16aSWM4qx0DJl0=; b=EIkAi0E3J38W/r+U3QzGSgJEwBqbtMcpZaf8wq33iudUCrlP1q7lLXtYSCdvZV3xE7NnWMv69zEAb7rptayW9aeBnaGU/l8Us8BJ5tJmJYDUrVe6O23vDakiimz/b28N70KOpSXPYMZBjlkNmWuELR7m5ZcUFOogzoblcPiwmns/QhSZvF9/MnujR2dXGtgXZ7AfyH81D0UfUPC7FCrNi4UI27eYA2d9sMD845LcAVYDYYP3VFPQOZ+DpF5JKJVAjefNirdt8T11Lm8xW2gl/0k7EERINuaAIkqlwkN1QF4ICfq5o7cmc8Co/mRsPkTYYkJIoKu5yfkFWycES5tR8g== 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=nLFrgFMTx88zjL0CQUkclXOg54v0L16aSWM4qx0DJl0=; b=j5JbaDz0tGEXPdUuGtjJdMLh/QPivwNcDu0cUFZT9UFsYd/DzU9yAPA64R85+DhNUUXhZUfUQHs/7c0GXTxAuj0zd4anKiQimMjzPv6I4+fc5IenHa/qvtFJJUogRU7lhgyJVecZ2YXs2FR1LK19WdsV763xaKjDSi+pq2UdRKE= 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:38 +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:38 +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 , Philipp Zabel , 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 3/9] PCI: imx6: Simplify reset handling by using by using *_FLAG_HAS_*_RESET Date: Wed, 6 Dec 2023 10:58:57 -0500 Message-Id: <20231206155903.566194-4-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: 317e8671-5f9f-463b-ffbb-08dbf6745977 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DhJg7MSulhAwIJmyODrqaq3BcBqkv3KM3SoFuCLdC7FNXu7Ld0kzaJguiwaJYAqNIKk02OvWFVC8nY2oFwHsSO/1MsLrPDrR89OApesv/gOvC9eRXolsn0uN4p+vPzSAqrJ3DApU7TX6NBrfLzzU4rivhWdGarkTLTJuN8b1meA0EHGZs8HX7xpuNScIA20PYbYsF++mIKFHDK7hX52k49Xa2uZ1w3mOhhSnl/Eb+4zkAKiwkwiEGOm3/p+Z2Szdi6wIgZKa4k0Ot42NaLS94lBVKnkFAAr9fuhtGDY7vLJdIhLO4PfQ+4v4OVTrNhprjkVB4cSfCCgHpEXje7OjYtWnsviz5ZxS92At8pGnRaT95Dpn5tMOQh2yrrJYOvwQVQYQ6tBawRS8TnEAAVcYm1kR7+Dw1fHp++shTCsO2o1iXhdFHc4ebJB1QpIeJXS+Y6z1GKTa7s+Laz/AvfNBbgDjA85KYy4dBXjuAFEFx11tsg0mRpfoEG8cSXP+rT8aZznlkaC1ZHzBgNk2b3/4RrnqYx7CIt8wdsg+QcEjGYaA6JFq7DXF0p04QhFPVY/p4JqaCa4NLWc084yypkXexGtc1g4XsQIE486x835jJTSIuOH9XFVtpk7LutCTpckFgoBYG09I67Qqma/pNgkR3A== 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: QLBYNiMRniwrf2M2DG+NJrBTizBv+XxJ83zUfvWj9G6N8tslVAknPsDNGwoEqu9ml2jUXoH1BMf5Vow97Ok6ylWEYi5qPCMAbRoNuzuMFJIB8NJfOzL5oLFUdEu6vcZ5ZMeYPG0C+edLOkbKpp2wTvAlG5oNBkH+G4vFSKT647Iz9DFbB/yPBUQ627wHM8qlyRNxdsO9BAn4Xbrrs69eLwXS4J588sjgzhS9yrA96Y9PuK0lP8iOVChk1bpaTguxl5xzBh/c4j1CSl4e2EIbBNo7jDNMXTt63iGEqqBBfUzlTrPoL7Y68MKitB/xg4DSw+l/dk/nBWWLHhMHJxxDtjWLfIC5aFwUeW9nq72y31MUwnCoPiXDiLSRoD7xtWN0UHXTmy009Qu/y/lcE5mwzABcCLjdCyPd0cXFvkDBJA6MNAmaKpHXgW1pZgYm11KcBptFwGwTzsr4hJKNb7kNi9kXJftyApbYrROLY3Z6grSxPAQmFUt9uPq2UGB15qQECPZJufApT/1jpEyQpdrXwhHUI/YxtSskn8uu2vAXEbppKlzlJC8phK1zNqIsQQ8jojh63UK2vHc/JLVfCvY/MfnJxQQdlWT1dSSJoBmdw2rYJRBHbQEdOk2djbXRmQ59bScHCJ85ufpPyPfvgbJIYJB3D+gYxzaBrW03VSkn8jwS8UKz1Gigt9TspORsTBivLkNOQfjW8kjFnNhG412SbYHnOAtk5G21Ey99g5w1BBumyzpZNmdGKSziSyjTF00zAfVUoGauAapx+FoNNEOEBv4Q33Oq7cmN4cqM4FzKmXv1wsM1Fy+iA4dZHz671RroPtB7ZpWAMNaToQc6N7jj9es8tElzpOw3bWZHsqFphBrPfw1SWFwrGjKq8AZ9BwN5r3t6qYqhUJeZUillmUAL1wxwaRsGhDigjjAibsPhxeAkKstZ+HPy5w5KOfs+wO0Z0rxXN/hBYkeUpjG2jGS7Q9nAaMb3FqpK+gBAkQtCvVRgo+AxhHginzf7BQNNDjLxaIvWhUFSQwjlcgAkJBNQnLsxHT0nh+1sfy+Yvowu9LQS6GA0fN5ioGcdgt76Uo6yTKNYouOEZA90hEo4w8koN8jEBkLyLnnCK8bc6BjwgM10zGVMU9JlQzAT8L84Zau9HPn24X8/rDAljSshQqbpRkfkgtFD1+sTTWf8RRBIThCsgNuUeidPxeZqEGo936hsp18ZfhjIhxOx3rCcQBkojCuFqnTwkgnJG1JgvU0JKsyl+Vh4OCdb0W7DoQw50CO/TZYKx9hbxYNcvzANYXYsAJV6YyQZAb1nNtxibsl8xi1rXXhfrY7REguA6gq8tuARpOZVXYojEPOlZoiEong3LNz751hWrFYcXQgYIjk4l/Lg2z26SApse7TzRQSmbWW+s+RWTfUBBi4LbNCc1vT5PqBMC05eVD+0QWOxDarMvubKas3QFlC5gBSoBz89YGgd/5I+JJCUKk7f2pZRA/A8Br82fbOecJLkCZTFPLabZ+4sSUtaxWauBf25AUoghtlst+M66FZBjSwqTE7jtfkZ3V/GVg3wLzWRazgpRLg+MsQ= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 317e8671-5f9f-463b-ffbb-08dbf6745977 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:38.2579 (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: LzgIQoBLCGaoN008vJxYV7NXGYgkSRTjQ5vQRWkCabivXEc0DVA/duoEzXBql45fJ6gKq9DFkJ8FB5lUeN7cEg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8123 Refactors the reset handling logic in the imx6 PCI driver by adding IMX6_PCIE_FLAG_HAS_*_RESET bitmask define for drvdata::flags. The drvdata::flags and a bitmask ensures a cleaner and more scalable switch-case structure for handling reset. Signed-off-by: Frank Li --- drivers/pci/controller/dwc/pci-imx6.c | 115 +++++++++++--------------- 1 file changed, 47 insertions(+), 68 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index bcf52aa86462..62d77fabd82a 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -63,6 +63,8 @@ enum imx6_pcie_variants { #define IMX6_PCIE_FLAG_HAS_CLK_INBOUND_AXI BIT(3) #define IMX6_PCIE_FLAG_HAS_CLK_AUX BIT(4) #define IMX6_PCIE_FLAG_HAS_PHY BIT(5) +#define IMX6_PCIE_FLAG_HAS_APP_RESET BIT(6) +#define IMX6_PCIE_FLAG_HAS_PHY_RESET BIT(7) #define imx6_check_flag(pci, val) (pci->drvdata->flags & val) @@ -696,18 +698,13 @@ static void imx6_pcie_clk_disable(struct imx6_pcie *imx6_pcie) static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie) { - switch (imx6_pcie->drvdata->variant) { - case IMX7D: - case IMX8MQ: - case IMX8MQ_EP: + if (imx6_check_flag(imx6_pcie, IMX6_PCIE_FLAG_HAS_PHY_RESET)) reset_control_assert(imx6_pcie->pciephy_reset); - fallthrough; - case IMX8MM: - case IMX8MM_EP: - case IMX8MP: - case IMX8MP_EP: + + if (imx6_check_flag(imx6_pcie, IMX6_PCIE_FLAG_HAS_APP_RESET)) reset_control_assert(imx6_pcie->apps_reset); - break; + + switch (imx6_pcie->drvdata->variant) { case IMX6SX: regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, IMX6SX_GPR12_PCIE_TEST_POWERDOWN, @@ -728,6 +725,8 @@ static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie) regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1, IMX6Q_GPR1_PCIE_REF_CLK_EN, 0 << 16); break; + default: + break; } /* Some boards don't have PCIe reset GPIO. */ @@ -741,14 +740,11 @@ static int imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie) struct dw_pcie *pci = imx6_pcie->pci; struct device *dev = pci->dev; - switch (imx6_pcie->drvdata->variant) { - case IMX8MQ: - case IMX8MQ_EP: - reset_control_deassert(imx6_pcie->pciephy_reset); - break; - case IMX7D: + if (imx6_check_flag(imx6_pcie, IMX6_PCIE_FLAG_HAS_PHY_RESET)) reset_control_deassert(imx6_pcie->pciephy_reset); + switch (imx6_pcie->drvdata->variant) { + case IMX7D: /* Workaround for ERR010728, failure of PCI-e PLL VCO to * oscillate, especially when cold. This turns off "Duty-cycle * Corrector" and other mysterious undocumented things. @@ -780,11 +776,7 @@ static int imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie) usleep_range(200, 500); break; - case IMX6Q: /* Nothing to do */ - case IMX8MM: - case IMX8MM_EP: - case IMX8MP: - case IMX8MP_EP: + default: break; } @@ -831,16 +823,12 @@ static void imx6_pcie_ltssm_enable(struct device *dev) IMX6Q_GPR12_PCIE_CTL_2, IMX6Q_GPR12_PCIE_CTL_2); break; - case IMX7D: - case IMX8MQ: - case IMX8MQ_EP: - case IMX8MM: - case IMX8MM_EP: - case IMX8MP: - case IMX8MP_EP: - reset_control_deassert(imx6_pcie->apps_reset); + default: break; } + + if (imx6_check_flag(imx6_pcie, IMX6_PCIE_FLAG_HAS_APP_RESET)) + reset_control_deassert(imx6_pcie->apps_reset); } static void imx6_pcie_ltssm_disable(struct device *dev) @@ -854,16 +842,12 @@ static void imx6_pcie_ltssm_disable(struct device *dev) regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, IMX6Q_GPR12_PCIE_CTL_2, 0); break; - case IMX7D: - case IMX8MQ: - case IMX8MQ_EP: - case IMX8MM: - case IMX8MM_EP: - case IMX8MP: - case IMX8MP_EP: - reset_control_assert(imx6_pcie->apps_reset); + default: break; } + + if (imx6_check_flag(imx6_pcie, IMX6_PCIE_FLAG_HAS_APP_RESET)) + reset_control_assert(imx6_pcie->apps_reset); } static int imx6_pcie_start_link(struct dw_pcie *pci) @@ -1335,36 +1319,24 @@ static int imx6_pcie_probe(struct platform_device *pdev) "failed to get pcie phy\n"); } - switch (imx6_pcie->drvdata->variant) { - case IMX7D: - if (dbi_base->start == IMX8MQ_PCIE2_BASE_ADDR) - imx6_pcie->controller_id = 1; - - imx6_pcie->pciephy_reset = devm_reset_control_get_exclusive(dev, - "pciephy"); - if (IS_ERR(imx6_pcie->pciephy_reset)) { - dev_err(dev, "Failed to get PCIEPHY reset control\n"); - return PTR_ERR(imx6_pcie->pciephy_reset); - } - - imx6_pcie->apps_reset = devm_reset_control_get_exclusive(dev, - "apps"); - if (IS_ERR(imx6_pcie->apps_reset)) { - dev_err(dev, "Failed to get PCIE APPS reset control\n"); - return PTR_ERR(imx6_pcie->apps_reset); - } - break; - case IMX8MM: - case IMX8MM_EP: - case IMX8MP: - case IMX8MP_EP: - imx6_pcie->apps_reset = devm_reset_control_get_exclusive(dev, - "apps"); + if (imx6_check_flag(imx6_pcie, IMX6_PCIE_FLAG_HAS_APP_RESET)) { + imx6_pcie->apps_reset = devm_reset_control_get_exclusive(dev, "apps"); if (IS_ERR(imx6_pcie->apps_reset)) return dev_err_probe(dev, PTR_ERR(imx6_pcie->apps_reset), "failed to get pcie apps reset control\n"); + } - break; + if (imx6_check_flag(imx6_pcie, IMX6_PCIE_FLAG_HAS_PHY_RESET)) { + imx6_pcie->pciephy_reset = devm_reset_control_get_exclusive(dev, "pciephy"); + if (IS_ERR(imx6_pcie->pciephy_reset)) + return dev_err_probe(dev, PTR_ERR(imx6_pcie->pciephy_reset), + "Failed to get PCIEPHY reset control\n"); + } + + switch (imx6_pcie->drvdata->variant) { + case IMX7D: + if (dbi_base->start == IMX8MQ_PCIE2_BASE_ADDR) + imx6_pcie->controller_id = 1; default: break; } @@ -1492,32 +1464,39 @@ static const struct imx6_pcie_drvdata drvdata[] = { }, [IMX7D] = { .variant = IMX7D, - .flags = IMX6_PCIE_FLAG_SUPPORTS_SUSPEND, + .flags = IMX6_PCIE_FLAG_SUPPORTS_SUSPEND | + IMX6_PCIE_FLAG_HAS_APP_RESET | + IMX6_PCIE_FLAG_HAS_PHY_RESET, .gpr = "fsl,imx7d-iomuxc-gpr", }, [IMX8MQ] = { .variant = IMX8MQ, - .flags = IMX6_PCIE_FLAG_HAS_CLK_AUX, + .flags = IMX6_PCIE_FLAG_HAS_CLK_AUX | + IMX6_PCIE_FLAG_HAS_APP_RESET | + IMX6_PCIE_FLAG_HAS_PHY_RESET, .gpr = "fsl,imx8mq-iomuxc-gpr", }, [IMX8MM] = { .variant = IMX8MM, .flags = IMX6_PCIE_FLAG_SUPPORTS_SUSPEND | IMX6_PCIE_FLAG_HAS_CLK_AUX | - IMX6_PCIE_FLAG_HAS_PHY, + IMX6_PCIE_FLAG_HAS_PHY | + IMX6_PCIE_FLAG_HAS_APP_RESET, .gpr = "fsl,imx8mm-iomuxc-gpr", }, [IMX8MP] = { .variant = IMX8MP, .flags = IMX6_PCIE_FLAG_SUPPORTS_SUSPEND | IMX6_PCIE_FLAG_HAS_CLK_AUX | - IMX6_PCIE_FLAG_HAS_PHY, + IMX6_PCIE_FLAG_HAS_PHY | + IMX6_PCIE_FLAG_HAS_APP_RESET, .gpr = "fsl,imx8mp-iomuxc-gpr", }, [IMX8MQ_EP] = { .variant = IMX8MQ_EP, .flags = IMX6_PCIE_FLAG_HAS_CLK_AUX | - IMX6_PCIE_FLAG_HAS_PHY, + IMX6_PCIE_FLAG_HAS_PHY | + IMX6_PCIE_FLAG_HAS_PHY_RESET, .mode = DW_PCIE_EP_TYPE, .gpr = "fsl,imx8mq-iomuxc-gpr", }, 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/pzeaA63qmiVHX7yNxp4DY6DSa22VixwpFP89AYjQsvsohgfgb3N5vgDfGeZZV3qMzLG87UHWSMwqyBW10zjonwyzACaaK1d5d8bJxzfn2ZcXyN6meiiswn3vRKhmuCCvpyeL/jj3qzSNNv711eZkCcm075+BntbeLW0H1VShi78fmVa8S94ERYSelXoEd8IusUV7I/2p9mUX4omuIHkIGuSLtnqmHgS35BKZLOmEG6LhlSckni9HUxpMtYZ5+z2fewiSHbYGuMUWQmciNHM2ENN1gkH+nDYVB2bP5RbtyEW/nnc8Fl8yhrnMW9wqtIN6XXXrsDeLTEQzBipWado2I7pkxmvckrm0Hmb+tm6wQsJfbFIk8YkBdciC1zUvs4+ZBr3HZQNTGbLtyi9wWPHgSZ8LAIn67zHG4v7DDFav+B756EPT4dclttWJUhNapKyPe4pyf7Mxk17LIgEVQpfzJ4Sx8ikap2nY4HYfY769Fh/i/1sFrAQeKMLTR5FKLkAlTjPK5yh0MtcBx6W1ZJb8k8140fjd1k9a3itJ0aYi+Lv7o8WmLiXyZKiZY1XKyd2mXiJ/fWEpdrBLlkS+WAW22fXX8qz+CK2dLftHBGV1KnHF3ly20RV6jw0nh2GJhuuew4Fs7UTZgAK+ogOeFBjOQ2quofzsCc68UM6JBCqf06EsTcrshQR1tc+jIR9KrZZwi8E7lyR2hXW46Uq81qBXECnHZ6UECqdOYehh0C9igvCwIIlT48AiWAAWdbyGdC0s9Iepg5BGKK3P3syzSo+npyS59eQXO2xsQd5oiA3b9B0k66mwg0j2aeG7JcyHvJoIqvcBnEadJ633YUKqcYVJnNMhkPSDNCkpYpjIhgB7wW+XtME8QSioXqgrA1VwZKyG6H5VUuJ+OCGmvnBrLIt8l3hifcyjsIQB20vfKbgpg65OWn4KJCBpLbsg7BfgkbG8io6O9XFGll03wG6l7LXPnh2T97add1zAEscgavahyf2FNI8Xe7ZDe5HfTgbaPG0l56qoDv1dkvHqgkhPz2jWuS0c3o87qV1fOB2TplBBdpJ9Q/sj0Xckk/apA901q74C/4J1XlAW+2tVfgZpW8PtolHJtl/o3xi7aQVbc2vzv1meHKg7xQ+Aj2vxgZ0UmCl0vW15xVL3RK56Rmij9TEkqKzM8Als5MFCSMzhUQlPnUIpPAFM8XYKERnk8BNU+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, From patchwork Wed Dec 6 15:59:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 751320 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="gt9xtppj" Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2066.outbound.protection.outlook.com [40.107.21.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3FE4D46; Wed, 6 Dec 2023 08:00:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LswJC8B72gjTapvaXk7f3Zwkvpj692K7JYvPw/rlzIGKDxRunmmoL+1/vX7r6zWlwpkI6SeL0w9OjOh7R66WgCuEP4bFcLRNzl9msbnhizf0gaQk8hzsQpQu2qix4N9o/hX++RQbJ8/RnNIz2b6Rn4VZ9/1r84cWyVi77gVvHOaUK0bFfrDPwyjbCjUPzJ43pOS9yq7+E3JPR0ZWXn1CPpT49Ia1U90K02oQF8mUatKTOxgfPMyY9j0CdUWYfyA+p3cme66oeq9Pa3zx74wAsaTu1+TbhXYF+NkFmi1260BOosurE8+KWOI3jZNVu+7Le9U439m3k2vxy6MqU83Q1w== 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=7Qpi9xQf8IYz44173pK3sVs/JxLMLTOTW2WmtSsdfdc=; b=Po4ZIWOld16NxMOgb3v/3xxO+Z4JeWwj3vxH7Zb2f6cYP6BekkF2IlhC3mATCGd6tV82d6EFeTNVuENbxhejZzhOKT51jS3hMrH6OXDCMKjSg4s3GXgKBxcvvGP1oUsP0mNGzUHhHd51+RqmPXnkIU3P4tGDtklL6t8iXC0A8J9T87bMAKgk3HAYeFSoLtI+hGXUjhRDb3x/5fKvYjy3Bi86kski80NfkaISlus9jZKduj/Al4ises4SZdePh9dfYEUx4aRC0nVGhTmYzmyWPh75jbuO23LQuDO+VdVbuRvZPcytgq41Qrdi/KfoWeZSCR8+1hZV9hYq4vZ1bRg/uA== 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=7Qpi9xQf8IYz44173pK3sVs/JxLMLTOTW2WmtSsdfdc=; b=gt9xtppjhIlyrjr8UnyO3sQ4OOMGKknyq+3v8BNndiJVRhoDJ/Gy+pf7rmO+DbQrGslQ3y3CucM4KqafMwx2p/RuM+TK9Y4kD/pAUx/zq377Ez5JgT1k2JjpsxbVN2IyUpZyjaC0DdYigFnEPl56T9n4aMvQzXRx3c/fbiCpeMM= 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:57 +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:57 +0000 From: Frank Li To: imx@lists.linux.dev, Richard Zhu , Lucas Stach , Bjorn Helgaas , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , 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 7/9] PCI: imx6: Simplify switch-case logic by involve init_phy callback Date: Wed, 6 Dec 2023 10:59:01 -0500 Message-Id: <20231206155903.566194-8-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: 59c01656-5227-40e1-8a1e-08dbf67464cd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cpKIs/IKQiKOp7+7Bd/04U1X9C3uwM4+Evpdeuy0cgFUF0nQ8gxV+6MhRZIsunSclcF7R9GIvepnlcZfF0gr8uuFqUk5UjREerLsH/yCjCgzLA07O1ix8YphBwiQ3iMcS8oPTxiIz8IbbZjHsTaUx+x3WeFVm9278Xq42evrA7ull8rHfrxf+hzkTw9283nKQkNxUGtcwsL4lUUSj2XkpTeBPDGgJrtzLzIFf9QsRFBcSD9USQWVkjBK/WbcMKCbfb9pIWRZJ3VAcF4u9QfhXUf/SrltQZ+yxXjUtW1N2MwXP+EaU38hAcwevJ8HRziOuRYZ6zerQAF98NUj7/YDuIIci4hx48BDn4n1GNz69WmCtbZgoMokI89AXey70ZicDVqLlOt7yiVYa1w/UTT0gl5ui0b8KmKkyT+zlefZGs2tuzGm9mGBXsjrE2tJrVTafDne415sj9OBC3pK1sBf10q5pAHaR1c+zq6XPqEPmJHs1O/+FGqwy6+Qdypd1iaYrnW1vUgkzbbnRiyr1AmvxgjuejlULe7l695pHuUd+QWTpW/IRvOudIOUl1qA6aP1Lxj9txmPx/lh8EhTQXECpxSBMBW7+g+Ef/cAvUfb7DxNrv83HsXx/rrIKWTq3tLKWrzNLiaoZ+m9bGBpIohiR7LGerFJjhXoo+l678bDBfc/ZCW7Icwf/Tdzn1AcSAgY 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)(230273577357003)(230173577357003)(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: 0K5aVJtEhnlEATtR7EGbHaUk44S815CGyx/PfrLaLV5jUrXkUALwU9niiKHB2y2Xy6UNVMTu1FkRSKA5zdPw6vfcanrLjlJIcSH65rYLlN5WFit2cUVAwk4fe1NJRQlNt3w0EkgrzR719zjU1Uh+4CtUCEB/LCmBd+CvPLdUSNNhcu3/5lUXWKHKs0kFc9SD5VqGqs5D1/bt/agdXoR5vNHKLEB8yzdPiarYBJkUReHyUINIT4ZRm3ecJDbL7MaLrang/P1CnU2IrykN2ODjQ2lX1oNN6R1EWZ5nh0SyKYeOYUgF9pA/T+wKEgBI7PCEzxOhtnDcyzD7yblFNIjiUi3mpMSoDjo7cd2/csSEotN1FhrM/T70kzNWJdbw1bMAG3XZLw3+YCVP9zjWV3w7EFTNBysMBhIzhnFmlOuO4G9QjbHek4yxJIB/p89t23LQQ9WRNMLCLmBT0bS8JaME/PigSsqEM0iq0pIUNJHVfgOyqqUMujhae+AnHYvokS8OSTeDNP/W+voYDBCwJQVLS2eB7/z1/EAe71RZETCM8luMTjoKqcOjRpzUt0941lDV92tQiy6pHHtvJx1RaxNcFLahU46P1Smd7DACYT5WLoPTaEr4FiH4Vvc69WsFEONxG2leotXQI9UYy7iSNJNN2O6qFZX1grfYlOmc4P2UBJgqEmBR0MWceatmRgQE+1w+JZGIsIkojHITQ1Goan1DwQkfTmvDa5DrJuNSVwLuNq5GzTFUAGkooDG01wFqyfOEb11deEpf00c79Q/YxcQMAMGTd9jN8uigDAxwMZZkWrrZwbomg5fPMGsXPIl9Gr/IjjEMjCfjrZXkCwJYwzwI0pGk8+oVGFaZrxBQOCauPN/CoUDfunUXMhzPw81YxVBsC/fTXe4RCZGlc6nU5eDA/47NqTd7NH8e+qjrs8SSmpF/d2/eeEXt6K9O6GvRVcjWpWjU04pEGsNZD6lf080uaOpw2xLkMpFAAH+KNyxt4KQkokS7qlg0SrkH2pPWsQwWNGMAYr9KkLXjjIE88P/zGAYLGnPUO+1CyVKGDH/NMgtyW2wgPbmePun2D20PIjLcPk1OZlNw6LjpJqhO0mOy6EKQi2v9w5sAtFb1BK6lC4zql1DCvgDdrPgn5QZUGgezwF8hk9VHOWfHxfqdkBMgrlRGooJ9h5DF8BduEqpm/tAQAXPRzGviRPB4f71/GxXaNcEqkYPUuq1ScVC///boRad34KrgVL7A8EZajf+1GCBxwuBdC91Jue/DOvRfEI3sh5kywwrvPutiNTc0kMecVf4klJiK1/Xp3al9dbrM7Z9fCtHSpQ5xfjnmM/CDH5yV6i16E6aUcqxidtNMCK4gUdS476x/haYZJSwIhGfH1P5vDcITIKh69JzkQSCJVvNy59TBPEQrwXw1pSLnFb5RhKkCTHcvdFQzPxaYsE3js5hz90YSSuDn3wCH07kpABlULxarD64ydiiGG4OmmioRn3lyBrRDvtF5pjBm7K1FZEAcCIl+23qrLOlvtzUj+MO824xBEnHF9sSrBOyOnFl81I42U0ythXqJpUCbrxH+OHA= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 59c01656-5227-40e1-8a1e-08dbf67464cd 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:57.2416 (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: wmKN1jVlF/6JnDIGr/T6ZoIbiUb8nQ6aQcXm9oMABz9S2BgZIN96uyr6fVXAcV+JNbS3Iy2SGdsANxHB0AMNjA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8123 Add drvdata::init_phy() callback function, so difference SOC choose difference callback function to simple switch-case logic. Signed-off-by: Frank Li --- drivers/pci/controller/dwc/pci-imx6.c | 135 ++++++++++++++------------ 1 file changed, 71 insertions(+), 64 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index a2a3496fe8a0..990b91534ea9 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -70,6 +70,9 @@ enum imx6_pcie_variants { #define imx6_check_flag(pci, val) (pci->drvdata->flags & val) #define IMX6_PCIE_MAX_INSTANCES 2 + +struct imx6_pcie; + struct imx6_pcie_drvdata { enum imx6_pcie_variants variant; enum dw_pcie_device_mode mode; @@ -80,6 +83,7 @@ struct imx6_pcie_drvdata { const u32 ltssm_mask; const u32 mode_off[IMX6_PCIE_MAX_INSTANCES]; const u32 mode_mask[IMX6_PCIE_MAX_INSTANCES]; + int (*init_phy)(struct imx6_pcie *pcie); }; struct imx6_pcie { @@ -326,76 +330,69 @@ static int pcie_phy_write(struct imx6_pcie *imx6_pcie, int addr, u16 data) return 0; } -static void imx6_pcie_init_phy(struct imx6_pcie *imx6_pcie) +static int imx8mq_pcie_init_phy(struct imx6_pcie *imx6_pcie) { - switch (imx6_pcie->drvdata->variant) { - case IMX8MM: - case IMX8MM_EP: - case IMX8MP: - case IMX8MP_EP: - /* - * The PHY initialization had been done in the PHY - * driver, break here directly. - */ - break; - case IMX8MQ: - case IMX8MQ_EP: - /* - * TODO: Currently this code assumes external - * oscillator is being used - */ + /* + * TODO: Currently this code assumes external + * oscillator is being used + */ + regmap_update_bits(imx6_pcie->iomuxc_gpr, + imx6_pcie_grp_offset(imx6_pcie), + IMX8MQ_GPR_PCIE_REF_USE_PAD, + IMX8MQ_GPR_PCIE_REF_USE_PAD); + /* + * Regarding the datasheet, the PCIE_VPH is suggested + * to be 1.8V. If the PCIE_VPH is supplied by 3.3V, the + * VREG_BYPASS should be cleared to zero. + */ + if (imx6_pcie->vph && regulator_get_voltage(imx6_pcie->vph) > 3000000) regmap_update_bits(imx6_pcie->iomuxc_gpr, imx6_pcie_grp_offset(imx6_pcie), - IMX8MQ_GPR_PCIE_REF_USE_PAD, - IMX8MQ_GPR_PCIE_REF_USE_PAD); - /* - * Regarding the datasheet, the PCIE_VPH is suggested - * to be 1.8V. If the PCIE_VPH is supplied by 3.3V, the - * VREG_BYPASS should be cleared to zero. - */ - if (imx6_pcie->vph && - regulator_get_voltage(imx6_pcie->vph) > 3000000) - regmap_update_bits(imx6_pcie->iomuxc_gpr, - imx6_pcie_grp_offset(imx6_pcie), - IMX8MQ_GPR_PCIE_VREG_BYPASS, - 0); - break; - case IMX7D: - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, + IMX8MQ_GPR_PCIE_VREG_BYPASS, + 0); + + return 0; +} + +static int imx7d_pcie_init_phy(struct imx6_pcie *imx6_pcie) +{ + return regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, IMX7D_GPR12_PCIE_PHY_REFCLK_SEL, 0); - break; - case IMX6SX: - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, - IMX6SX_GPR12_PCIE_RX_EQ_MASK, - IMX6SX_GPR12_PCIE_RX_EQ_2); - fallthrough; - default: - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, +} + +static int imx6_pcie_init_phy(struct imx6_pcie *imx6_pcie) +{ + regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, IMX6Q_GPR12_PCIE_CTL_2, 0 << 10); - /* configure constant input signal to the pcie ctrl and phy */ - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, - IMX6Q_GPR12_LOS_LEVEL, 9 << 4); - - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR8, - IMX6Q_GPR8_TX_DEEMPH_GEN1, - imx6_pcie->tx_deemph_gen1 << 0); - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR8, - IMX6Q_GPR8_TX_DEEMPH_GEN2_3P5DB, - imx6_pcie->tx_deemph_gen2_3p5db << 6); - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR8, - IMX6Q_GPR8_TX_DEEMPH_GEN2_6DB, - imx6_pcie->tx_deemph_gen2_6db << 12); - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR8, - IMX6Q_GPR8_TX_SWING_FULL, - imx6_pcie->tx_swing_full << 18); - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR8, - IMX6Q_GPR8_TX_SWING_LOW, - imx6_pcie->tx_swing_low << 25); - break; - } + /* configure constant input signal to the pcie ctrl and phy */ + regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, + IMX6Q_GPR12_LOS_LEVEL, 9 << 4); + + regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR8, + IMX6Q_GPR8_TX_DEEMPH_GEN1, + imx6_pcie->tx_deemph_gen1 << 0); + regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR8, + IMX6Q_GPR8_TX_DEEMPH_GEN2_3P5DB, + imx6_pcie->tx_deemph_gen2_3p5db << 6); + regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR8, + IMX6Q_GPR8_TX_DEEMPH_GEN2_6DB, + imx6_pcie->tx_deemph_gen2_6db << 12); + regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR8, + IMX6Q_GPR8_TX_SWING_FULL, + imx6_pcie->tx_swing_full << 18); + regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR8, + IMX6Q_GPR8_TX_SWING_LOW, + imx6_pcie->tx_swing_low << 25); + return 0; +} - imx6_pcie_configure_type(imx6_pcie); +static int imx6sx_pcie_init_phy(struct imx6_pcie *imx6_pcie) +{ + regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, + IMX6SX_GPR12_PCIE_RX_EQ_MASK, IMX6SX_GPR12_PCIE_RX_EQ_2); + + return imx6_pcie_init_phy(imx6_pcie); } static void imx7d_pcie_wait_for_phy_pll_lock(struct imx6_pcie *imx6_pcie) @@ -945,7 +942,11 @@ static int imx6_pcie_host_init(struct dw_pcie_rp *pp) } imx6_pcie_assert_core_reset(imx6_pcie); - imx6_pcie_init_phy(imx6_pcie); + + if (imx6_pcie->drvdata->init_phy) + imx6_pcie->drvdata->init_phy(imx6_pcie); + + imx6_pcie_configure_type(imx6_pcie); ret = imx6_pcie_clk_enable(imx6_pcie); if (ret) { @@ -1440,6 +1441,7 @@ static const struct imx6_pcie_drvdata drvdata[] = { .ltssm_mask = IMX6Q_GPR12_PCIE_CTL_2, .mode_off[0] = IOMUXC_GPR12, .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, + .init_phy = imx6_pcie_init_phy, }, [IMX6SX] = { .variant = IMX6SX, @@ -1452,6 +1454,7 @@ static const struct imx6_pcie_drvdata drvdata[] = { .ltssm_mask = IMX6Q_GPR12_PCIE_CTL_2, .mode_off[0] = IOMUXC_GPR12, .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, + .init_phy = imx6sx_pcie_init_phy, }, [IMX6QP] = { .variant = IMX6QP, @@ -1464,6 +1467,7 @@ static const struct imx6_pcie_drvdata drvdata[] = { .ltssm_mask = IMX6Q_GPR12_PCIE_CTL_2, .mode_off[0] = IOMUXC_GPR12, .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, + .init_phy = imx6_pcie_init_phy, }, [IMX7D] = { .variant = IMX7D, @@ -1473,6 +1477,7 @@ static const struct imx6_pcie_drvdata drvdata[] = { .gpr = "fsl,imx7d-iomuxc-gpr", .mode_off[0] = IOMUXC_GPR12, .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, + .init_phy = imx7d_pcie_init_phy, }, [IMX8MQ] = { .variant = IMX8MQ, @@ -1484,6 +1489,7 @@ static const struct imx6_pcie_drvdata drvdata[] = { .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, .mode_off[1] = IOMUXC_GPR12, .mode_mask[1] = IMX8MQ_GPR12_PCIE2_CTRL_DEVICE_TYPE, + .init_phy = imx8mq_pcie_init_phy, }, [IMX8MM] = { .variant = IMX8MM, @@ -1516,6 +1522,7 @@ static const struct imx6_pcie_drvdata drvdata[] = { .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, .mode_off[1] = IOMUXC_GPR12, .mode_mask[1] = IMX8MQ_GPR12_PCIE2_CTRL_DEVICE_TYPE, + .init_phy = imx8mq_pcie_init_phy, }, [IMX8MM_EP] = { .variant = IMX8MM_EP, From patchwork Wed Dec 6 15:59:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 751319 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="Gegk0YPq" Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2065.outbound.protection.outlook.com [40.107.21.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C4D3D59; Wed, 6 Dec 2023 08:00:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Xri7HlEhnvNb/2CywYC64V0IvubE2f82MILHR/pGSNsYIjXc0yUEGR6bTHvto3EN1LW0njARS7bCPd9anknqjNB+HEiwV3FiB2YIsmpQ95wf8sj581JqYXIXTpKOmTN75i/NSNO95Rjgw1nd/jQY7kLQl/c008fKaIK5GfzyPDhFtxoYNHwyeAThAiob2qG9vAyM86WpHnXiZBLOTvMq62wLj9UvTwpWB+LTGLCX9091CsYRDHuh3FuJGMjo5R0w7ZmLSDpUO/FewsMOknkZfulL5VMObZBZeSJAnMjRIeR+c2BzRbArR/9xR1W1McpwzIhm4C9iXmwIYW/8hrVvmA== 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=EyP010kXK2Q48Jra5YCr2LdwY148bnkQ5ya58KRUb0Y=; b=f4qA0EL5S5YlPcct5COjFETqhXFS3RKnY6k+CkS2dQidKrCW7jSUNR2Hp7A6A7iaEhdc6IOuI7yQQTUa28CgLJGGwDvqve43vnfVOnn2P3yKUb1JkyPNqfvK+LwlcoOYiCRZMxvSXkstALV5WSP7bB92/F4dmJ2gu1bhS64QO3HZJ/Ai8DYyqoGOVDk68yplXTQ8xsoLRRTrdsriDmjPnnVsCXJu9ft32FJdhWa9905+tF9+3g7PNADkIKcYR3xev/fAh7jREC4WdPvXTbWszNJPPgnrvOktABl/CHnXOppjOwfl2vntxGJiTlzaV23zA/2+76m/hUPn2vtpaMwn/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=EyP010kXK2Q48Jra5YCr2LdwY148bnkQ5ya58KRUb0Y=; b=Gegk0YPqfmgXTCKfwplI7+2SYU0Unc5BWfiPILhIRbJg275Kre7ZRpDTQ2LF0RdAqHnEnqdW6e/SPbquSsPjsrCPqoPLcbOZhZc/3ohtDCREExccasNMN4G/TjTbsFNJFLT60ovP43cdBvVDvkIhW3deHz+sK8Tr9beym8G3vM0= 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 16:00:06 +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 16:00:06 +0000 From: Frank Li To: imx@lists.linux.dev, Richard Zhu , Lucas Stach , Bjorn Helgaas , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , 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 9/9] PCI: imx6: Add iMX95 PCIe support Date: Wed, 6 Dec 2023 10:59:03 -0500 Message-Id: <20231206155903.566194-10-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: 58d81113-a9ea-4f1c-f763-08dbf6746a6f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: maR7HrBCtYefQTTTSN6XT+pENMQ39kHFCoUYqyt0UW5JzzzNdNJjCEdbsD4Qasbp7InCISGuvTg6Za998tM08LuTva5n3Xn9eapZes8y8hWF/nB8DuS/PU3PWAu2Ti6Qmx5a7wpgcvX0bSdt4LTA7LBAAjlboSfeQ4Lf8u1L+S80Iic879fp0XzLSvmUiLx8NEw5kmaUvUiN72InbKbTJ6sm/Ndfj+taN+43IlVvNW5faTd8AjMRXcEZyfJVbNmmakpYUtlyzPglQnFhJs8Vaa2TMm695cF2wtMCE3w3TZeKkrSz5D2AiG4zyOUG4qd6ZRfmwMtBqbAAD4eUSl0woxZOW5TYpwIqxfdz3Jh4kvXYTQJlW1Zjz9oS6uk1aAFQWhW5m4Mibos6QJ6S5C+Cvs2Jh69lQopLk7xW7ctXruBkopLX1sH63iXa1TwwIoZdrn6H/20YZTemPpn/OMVABXs9IMzPStUpa6UyI5EB20rm2lCacDWkPGQ0osmg8g/tlQnLKT9qOv4QLmt4g2dVft2M4i1LRMpAJK9lvD7UUQjX86Lgm3XDuU9dXl+FEXpBxef5oXltYjbKe8y/dFaIJho84OySmCHgosMDDLisVCZ3behlzZgX+vNjWpV12T35 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: Tm2ddBB9sfWgmEaLHgZ/VoY3wDEEBhTeUK9edbw/vu8cRp1NHTiVC4GdQz5hjZ09ijNiylO2N8jU2quNydTMHEbHAiXs7v+T4eYGXnGm1MPDQpidxKCKrGIiFdljjUHc6LJb/zMGcHB8I6pQUDoMQZsaPtHIsg2zf3RDMk4ibxa3i/oho8MaEMnJBMiDUL+ofZHcePnqRcHa01whyhFjB2qztAGx7E+435RAIQG9dITX8q8so2EYbBBEdbkJhJxfnK2fGGbmT5DWJ26unm0i3zFjMwEJFSKaHa1OmM5vsZJUGwY1jJnAWFgkKttQLKTD6sqoI0ITO9q7jCWkOIvNeY1EGyBmK4GaYmYmnXFcVZtjw313pKhCH7k9PbI7W0W/kBDMJElolx4rQlkH4PFrKFzrTu08EkieiXWkTlNbBk455W9l337YM+cEtFWhHx6Mwx3mmicoB5UoUj9xClVYj4mvjsLmyAbf8i9SVfl77BVqXUQTBJ639x05LKrZ4E8XlbG7socPBK5hjmdpJyQbNMjW0L3+IZ/ZmDXMxy3+2AaoBni9tMJ3mKMChOl8Sfnt5RQ3Qra4NUJ9BgOwElclV4Sjx4N6kWjbKYqIl1Y7nQVAcbmTthptqwtSZAorgZSa+SClaylA3aWp97diQqoR8MY5ugUYRyouIFuaCbiz0ZyUPFjCN0DSVkPRN1qNKi+MkGkQAFnC8MqB6HRERBxRInOxxXzVC1fbKmsGYkvrOsHpcZHehK6aF7F2n6o6zbc1mv7LeRZvScyshAJnVS6hnJAG5BX4zBhEdxsujYckRzI0MpcpVSZ0+bCUk6qa9sXlW8xilU0t0t4jaRthtjZOnlRmsheBkZK8py55sfXNgmWHg8EU8SeDeaO0ub5JedupRCXMIBwzVLZDPfKS5cGZWmXYHC/CMfdspeaxVq9yN32PCdYjg2t58muPqBgoYaFsc3uWonMpL+v/SGFBiNtm8TGdwBwqeVItW27fXiZr9NGxVZZ40Axh2sUSNHEG+seha+eVjZDDZjzJQd8vkcNPZUC/RaK9l2ECEvsO1MobA4ZG2rXXdVL7fx7VTedeiZIq/VNYzK07gkhMvzcYSd8gYh3Qjnw2ePGV8vhmmmyXUYH2p94IEhhNC18Pas3yKFFM1a+UFgN8siuO8QYroTZSAd1cAfa4bZ1GvJn4rqnTDrXxJCsGDgfnd7KLohmbgY2yDWPrK8V6NcshOw3653bOM2Gx4UcO95/lFs5v3XmL+fyFBQnxAvxnKPt2BRgfR9bzqCleTjNxo7hiaVLKgaOV3qC+W4qCKk5aUk+G2n4Vk0iIIkUMC9VRTHorEQMZlsYpszKcG5XqJ+SOfEPCwbpW1pBxH+/EGj1+Y9K6o1JgwcpgOf7YoAa0f0WoHALVwMfgghTpylkkOrrQB2MIUrbiP/fFFfZxeQQ1h3mcjhqcwStso7aUHdf7fXivWudLYUfoOkNqHlCC511pvfNTpVxky9avikvS+38tqn2v7pjO7kogY5LANVY70WP6MQd+3MntgpxoRiSTyk9aRNIyz0e7W0sk6oFbjrwFB+NQh7uqcSk= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 58d81113-a9ea-4f1c-f763-08dbf6746a6f X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 16:00:06.7073 (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: SUqbyAFkMKc6oV5cg5br/mcZe1PmsgMyFkZ64L9KWR2bwWlmdH3/B272TPxDFQNcSJ2uAJSj0fM7/SOGns7zbw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8123 Add iMX95 PCIe basic root complex function support. Signed-off-by: Frank Li --- drivers/pci/controller/dwc/pci-imx6.c | 85 +++++++++++++++++++++++++-- 1 file changed, 80 insertions(+), 5 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index 990b91534ea9..7e51aef97baa 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -43,6 +43,25 @@ #define IMX8MQ_GPR12_PCIE2_CTRL_DEVICE_TYPE GENMASK(11, 8) #define IMX8MQ_PCIE2_BASE_ADDR 0x33c00000 +#define IMX95_PCIE_PHY_GEN_CTRL 0x0 +#define IMX95_PCIE_REF_USE_PAD BIT(17) + +#define IMX95_PCIE_PHY_MPLLA_CTRL 0x10 +#define IMX95_PCIE_PHY_MPLL_STATE BIT(30) + +#define IMX95_PCIE_SS_RW_REG_0 0xf0 +#define IMX95_PCIE_REF_CLKEN BIT(23) +#define IMX95_PCIE_PHY_CR_PARA_SEL BIT(9) + +#define IMX95_PE0_GEN_CTRL_1 0x1050 +#define IMX95_PCIE_DEVICE_TYPE GENMASK(3, 0) + +#define IMX95_PE0_GEN_CTRL_3 0x1058 +#define IMX95_PCIE_LTSSM_EN BIT(0) + +#define IMX95_PE0_PM_STS 0x1064 +#define IMX95_PCIE_PM_LINKST_IN_L2 BIT(14) + #define to_imx6_pcie(x) dev_get_drvdata((x)->dev) enum imx6_pcie_variants { @@ -53,6 +72,7 @@ enum imx6_pcie_variants { IMX8MQ, IMX8MM, IMX8MP, + IMX95, IMX8MQ_EP, IMX8MM_EP, IMX8MP_EP, @@ -79,6 +99,7 @@ struct imx6_pcie_drvdata { u32 flags; int dbi_length; const char *gpr; + u32 pf_lut_offset; const u32 ltssm_off; const u32 ltssm_mask; const u32 mode_off[IMX6_PCIE_MAX_INSTANCES]; @@ -182,6 +203,24 @@ static unsigned int imx6_pcie_grp_offset(const struct imx6_pcie *imx6_pcie) return imx6_pcie->controller_id == 1 ? IOMUXC_GPR16 : IOMUXC_GPR14; } +static int imx95_pcie_init_phy(struct imx6_pcie *imx6_pcie) +{ + regmap_update_bits(imx6_pcie->iomuxc_gpr, + IMX95_PCIE_SS_RW_REG_0, + IMX95_PCIE_PHY_CR_PARA_SEL, + IMX95_PCIE_PHY_CR_PARA_SEL); + + regmap_update_bits(imx6_pcie->iomuxc_gpr, + IMX95_PCIE_PHY_GEN_CTRL, + IMX95_PCIE_REF_USE_PAD, 0); + regmap_update_bits(imx6_pcie->iomuxc_gpr, + IMX95_PCIE_SS_RW_REG_0, + IMX95_PCIE_REF_CLKEN, + IMX95_PCIE_REF_CLKEN); + + return 0; +} + static void imx6_pcie_configure_type(struct imx6_pcie *imx6_pcie) { const struct imx6_pcie_drvdata *drvdata = imx6_pcie->drvdata; @@ -589,6 +628,7 @@ static int imx6_pcie_enable_ref_clk(struct imx6_pcie *imx6_pcie) IMX6Q_GPR1_PCIE_REF_CLK_EN, 1 << 16); break; case IMX7D: + case IMX95: break; case IMX8MM: case IMX8MM_EP: @@ -735,11 +775,20 @@ static int imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie) { struct dw_pcie *pci = imx6_pcie->pci; struct device *dev = pci->dev; + u32 val; if (imx6_check_flag(imx6_pcie, IMX6_PCIE_FLAG_HAS_PHY_RESET)) reset_control_deassert(imx6_pcie->pciephy_reset); switch (imx6_pcie->drvdata->variant) { + case IMX95: + /* Polling the MPLL_STATE */ + if (regmap_read_poll_timeout(imx6_pcie->iomuxc_gpr, + IMX95_PCIE_PHY_MPLLA_CTRL, val, + val & IMX95_PCIE_PHY_MPLL_STATE, + 10, 10000)) + dev_err(dev, "PCIe PLL lock timeout\n"); + break; case IMX7D: /* Workaround for ERR010728, failure of PCI-e PLL VCO to * oscillate, especially when cold. This turns off "Duty-cycle @@ -1348,12 +1397,27 @@ static int imx6_pcie_probe(struct platform_device *pdev) return PTR_ERR(imx6_pcie->turnoff_reset); } + if (imx6_pcie->drvdata->gpr) { /* Grab GPR config register range */ - imx6_pcie->iomuxc_gpr = - syscon_regmap_lookup_by_compatible(imx6_pcie->drvdata->gpr); - if (IS_ERR(imx6_pcie->iomuxc_gpr)) { - dev_err(dev, "unable to find iomuxc registers\n"); - return PTR_ERR(imx6_pcie->iomuxc_gpr); + imx6_pcie->iomuxc_gpr = + syscon_regmap_lookup_by_compatible(imx6_pcie->drvdata->gpr); + if (IS_ERR(imx6_pcie->iomuxc_gpr)) + return dev_err_probe(dev, PTR_ERR(imx6_pcie->iomuxc_gpr), + "unable to find iomuxc registers\n"); + } + + if (imx6_pcie->drvdata->pf_lut_offset) { + void __iomem *off = pci->dbi_base + imx6_pcie->drvdata->pf_lut_offset; + static struct regmap_config regmap_config = { + .reg_bits = 32, + .val_bits = 32, + .reg_stride = 4, + }; + + imx6_pcie->iomuxc_gpr = devm_regmap_init_mmio(dev, off, ®map_config); + if (IS_ERR(imx6_pcie->iomuxc_gpr)) + return dev_err_probe(dev, PTR_ERR(imx6_pcie->iomuxc_gpr), + "unable to find iomuxc registers\n"); } /* Grab PCIe PHY Tx Settings */ @@ -1511,6 +1575,16 @@ static const struct imx6_pcie_drvdata drvdata[] = { .mode_off[0] = IOMUXC_GPR12, .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, }, + [IMX95] = { + .variant = IMX8MP, + .flags = IMX6_PCIE_FLAG_HAS_CLK_AUX, + .pf_lut_offset = 0x40000, + .ltssm_off = IMX95_PE0_GEN_CTRL_3, + .ltssm_mask = IMX95_PCIE_LTSSM_EN, + .mode_off[0] = IMX95_PE0_GEN_CTRL_1, + .mode_mask[0] = IMX95_PCIE_DEVICE_TYPE, + .init_phy = imx95_pcie_init_phy, + }, [IMX8MQ_EP] = { .variant = IMX8MQ_EP, .flags = IMX6_PCIE_FLAG_HAS_CLK_AUX | @@ -1551,6 +1625,7 @@ static const struct of_device_id imx6_pcie_of_match[] = { { .compatible = "fsl,imx8mq-pcie", .data = &drvdata[IMX8MQ], }, { .compatible = "fsl,imx8mm-pcie", .data = &drvdata[IMX8MM], }, { .compatible = "fsl,imx8mp-pcie", .data = &drvdata[IMX8MP], }, + { .compatible = "fsl,imx95-pcie", .data = &drvdata[IMX95], }, { .compatible = "fsl,imx8mq-pcie-ep", .data = &drvdata[IMX8MQ_EP], }, { .compatible = "fsl,imx8mm-pcie-ep", .data = &drvdata[IMX8MM_EP], }, { .compatible = "fsl,imx8mp-pcie-ep", .data = &drvdata[IMX8MP_EP], },