From patchwork Thu Dec 7 19:34:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 751818 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="rANmVIP9" Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2067.outbound.protection.outlook.com [40.107.104.67]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 781A710EF; Thu, 7 Dec 2023 11:34:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vgozex5EmF8nrGBZqh8hRjS7IDgwzudBiORZNWYMXXu1lEoe8pvlsKMcsMk3EZLQqhytkp6JUAl6QI18C+fIY7CWpRTPsRQozfhaeNfPB2xM7AvAMTyYaI8ZWXhJ/Dd4VmQ6w3pUorYG8YXDNiyjTWm6XEjLR4t7xinExAqnf3txgBmTHXpP5GoO/aDIyn9zXXe4I3qFX2KUHyFYDReviMmn2vYiIvBHa1sldLYXByyIhqn86gIqMT1qcjs9zxWXyTTtOQE/Y+T1TlvKw33DyrAe5BaHMgHnoJLV5jnUzVe1CU9REBsqNZ/k6rIAmcU7IwKLwUDka3/GcMapsMSUvA== 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=DojZRXzpRZWfWnlDBAAcF49Bdzfvx2oxVLlW8/nmYCU=; b=lNMyZrdKrJtlpQs+pH4i9FCdJhDbduKsAugwNUEgxBbRzOvaIdHT4ZIg0s4EEQyAPTnRowhpVA8mKsyu2kjzZ77W+haIElAn1t8N2i4BH25Ty5Kz6Vxc5nCEzdM0mXEzl/s6LZMVxnEXaFwKVAXrooNBR5+giob+9bdSYZOc9mHvh7wbNIgMz14n84BdI16uZ2tk3fpH+UC446NnlSZ6/dk3a2tckK1G6qvjVSQOONfmz9UGNk18Cm6j8Lrw392Pt4ctEYYXfd0PgZVo9keXZtDonHuHTE1ZmBn/+tDwlxN7tS83+HIp/1NYiORiOt/hFGl/oG3j5xBltB3bJ5brww== 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=DojZRXzpRZWfWnlDBAAcF49Bdzfvx2oxVLlW8/nmYCU=; b=rANmVIP9H9py4GgL+8JuHyTwvd3jcMhNprNv8Iken9M4MRx3Gb/XR2YI9TPAOkU0vfC5M3Ucs8RKaVTW0a1/4AWd96bzrrmcK5KnmwsdQZEy90A4SQc/IFhWp5K4Oh/o8PBfkvCBPuSdZqD1GrsW02+pkcIEWp/jknc3ocPv7fI= 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 DU0PR04MB9635.eurprd04.prod.outlook.com (2603:10a6:10:31f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.27; Thu, 7 Dec 2023 19:34:55 +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.026; Thu, 7 Dec 2023 19:34:55 +0000 From: Frank Li To: helgaas@kernel.org, manivannan.sadhasivam@linaro.org Cc: Frank.li@nxp.com, bhelgaas@google.com, conor+dt@kernel.org, devicetree@vger.kernel.org, festevam@gmail.com, 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, robh@kernel.org, s.hauer@pengutronix.de, shawnguo@kernel.org Subject: [PATCH v2 1/9] PCI: imx6: Simplify clock handling by using HAS_CLK_* bitmask Date: Thu, 7 Dec 2023 14:34:22 -0500 Message-Id: <20231207193430.431994-2-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231207193430.431994-1-Frank.Li@nxp.com> References: <20231207193430.431994-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR03CA0348.namprd03.prod.outlook.com (2603:10b6:a03:39c::23) 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_|DU0PR04MB9635:EE_ X-MS-Office365-Filtering-Correlation-Id: a7555e79-986e-43bd-0a8c-08dbf75b975e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8BVnX6C6eM6NkWa/rUZLtnRd8QqceJMkeSfasMUSH0hjJv2zYI95kNSLT9KqMECYxszD8OY9azKpc41J/6aNtSmQuM2acbVT2Y8YYGW+CU0M0qRyVUc/3EDD869lCa6zSKHXySiOEZcrNcpwTFCZcvLbzZiEOYjM1cgJC0PgYgXj7K2FW3DiMlYU2INe2pC/jIpGEGJnHgrHgmfdhX/256jziszaWzfaaSBo9UXrbgWGWAvM7PmoT2JbnC0G2O1dxGKh0rkxozKuMvs4fXub1pseSRpUgEnSoNR9zgbKyHWdtMI9809IFpnTcJIvaT4HtwVtGgzSSjQoZbthrunXuyo3Tup5uWi9JqXLZPwEF+kK+eafhJYAeA4t6gBhGZd7g0ST5rFTg9W3Cw0/YWsz47JoDlnr6fakt3jSDbBSl1rRiRuegc7pzg1jrK1AHpxueACmkE0GTA0unlBMdY3XzqFKSY22SXQ4pe2bmHTVrScMCyvuaOU31MXZRtviZmrwA9CcLtmRYWCoZlOqkt1tyEpN6rrc/FaAEPqpMSNOd4LlEYamQNbPmyRLb/D0tzIWR0/5wrJkjBWHSBq79QsfQhuymj94GChQgdSP/kEdkoPMx18Hl8z+spuNvbgPaRit 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)(396003)(376002)(346002)(136003)(39860400002)(366004)(230922051799003)(186009)(64100799003)(451199024)(1800799012)(52116002)(6512007)(38100700002)(66556008)(66476007)(66946007)(316002)(6666004)(6486002)(1076003)(2616005)(26005)(6506007)(83380400001)(478600001)(8936002)(8676002)(4326008)(2906002)(7416002)(5660300002)(86362001)(41300700001)(36756003)(38350700005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9L/wq+bDUWsjJxUZ0ICG8dhLZoDBA9+h+Kcz2ZPSUMfrRC5ouj4RHPEUyEqnGYe9PYFnVHnO4nS+wdU+rqrEUMV2uXTUvtIE/orJmRkEMddzRrGD6nQNpLp3+1VaJ/dWqYssPzRP8D8InnjAIGRvJBhXmxbX9DAZwexa6l3L46ByBbUelN65jzhlPo6x0h4EC7pjbncoilVfDBrlsuCYZmNd9t3KLJ6DFv92ZDeIX6u8X9Gd+hIgwRB9GTgeZVVvFpcrwSdG3GcR2k68afeeUlnQj/2yMqwxnPkXFBGrPhz6zTP54Wite2yv+2YSBhJ2wQoIlXPT/MqNfBDdvHNlFRLbIpgghfscZe3/YU0wmFD7e+w/L88uhA54jRsKn2tbzz6x/ruPfWgJs7c14z11ryE4H+qWyOZrKZDm/GlijOqeWoycgVZHjk1uuten4wZE2YcNVzPj5ni2f0g3YOkDsPkwx3lo+otXYUabbe1p9AX4p3XXipcAqg/hmitiM2r6z6G+Sz5LqLwRaTWGmgOwBQD98YpR9SrbQ+Z7nbUX4i3HPjHJa9bgj+nGdauE6XEl6fuAGC5sXMA2SY0cD454HZmlwycZaRelasbTuyS++TW8mQp5J/68PdFgp/Yg/TaGgRLeRlswQsWty+oE8GXxf3Sowcl6l91UHSKDOejwan2Mc9bmM3Nl3IojIzWSNf8JKpmfGmxb5c+BNf5RaOy4rq1sz0l0AbujHWKYFtTMCbPCtBKizM+8SK6232c7gd+e2A+N4NpmJpoyqO+EN0mFP+Iuo1BqYYoXt9Xp+qhuUF+cNpL50xNr7y9+GQ2LGECHXY9vIlldYybc8rrCFfeIWDqMoOMKqi7VcLHsBsMe9KI9Rsh5bthFLJZeYgQ8UmIB+u5T6yawh+ZGEBzraxJHFYfiBW4ofAjoSOOXiO4pjL6c29CplKIxCa8XBpDOMeAD9P7JF8NE3CMGIWzAvoJXIWP4XyDW/tHy/VY6kwe9idfqdhsXlnTpItBFkD2S7DLsMwZsrio5blhMJHfqsOQK5WYmWz40eV6XbG2nfRrZ9NN3AxH/EzMJWlVgoMSw0lZZtUbW78It/l5rIVafddx9CvFMMCSSv3dXtBM//bcShmFLEixoTFfu8jEWxZ4PhqBkc8P9laiM4mZQVBglOiM8cTPqgqleZTAAhxFiuPtLojDHrBgVn+qlttgLkHVWygvCeue5GiTnoV5M20RwhZrsXzquLQevWizsO16jcAawnkJkzQqW7dFWVLHx3nMvbnhhxrnEir0EB4exVznbXEnpVW4q8M//70Kt0GCZW/t52jNBQkFzITpGH5KvBAa1lI2feQtswRzdOfnelmtfu3SdCBg+AviqzHphTvmHl4E9bwT1jTyy9XIF32U5lcI5Z2D6xplbFpvPqUVWJAhKCpCuRlJyApbrjAZRGbkkZ0sBEXvXqHBNK4iI8eXhx9Cqxr2OkhH3U8qwpzUImSdIsVnJXLSCDPOvzOpOgaxcmSygz9u2P3f23TEA7LBq2AWBx1kkzNdvl2+ohz/bfy9qU9ZW6ZozOgico7Z/YCrUpsUf8dM= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a7555e79-986e-43bd-0a8c-08dbf75b975e X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2023 19:34:55.8291 (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: I60skOHlFAz/6xk0PcXx1eixaze695IF22+r3zcIQDGJJ+EUTlYp20NMVHxSCUol0qx7G8voiuT5ZjS1IznkkA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9635 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 74703362aeec7..8a9b527934f80 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 Thu Dec 7 19:34:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 751221 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="S2HIdV7R" Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2067.outbound.protection.outlook.com [40.107.104.67]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A2AC10F7; Thu, 7 Dec 2023 11:35:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PFO2MVT3g3dFk5OeXH4aim6AwXS6NEDvmoB4Rin4BMyYLjKvQ6nSa2eMoX96TYL8+u8oCbbdifmO+/vilD3P5Akv1pNEnZf6sgi/zvjjBrImKx4BUjhW04VZayq7BuOgzjHqEpZWnPhLvMXgZXOQzVFVoG9Z03pkV1M6evzOvomrl6rRSsdL9C5iApN9tRVly+YOlK4TymCU9kdTtzmWMxIpf0LKKTuuvP//qVen3D0YT5KSjjaYvRH+11yssmFE4wF/2JPx9RjVdxwuf/t3Qz1Ca8bn30cSBNwfJxB+6+BrFW2bBWuxSLhI4AnB3cXFIeKGyvlruxc++9FoMpskEg== 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=/s0+Que1s5W2eoQy/OJla8scuKmDll1biQwYz1qYmkM=; b=BDvvko15TWtZzLSCk3QGZgZGZD1LBwV/Vtq4zzVY+nfGLLg9zQTeZaB490IifVXqAysc1dlYpz4Z2ra8BN6hwnwcLTkCHaTT7eRf7JlpqXkMLXvAOv8XEUkZ4nb4dGyXupMljBXS+SWvYbwq+WWfY0sS6pij40uQZ7uDn/RFwMOPqjXgRyz45cC9kAcLf3wWjLLY8b4iOS6s6CyrajP52BHAIDOsKkz40SoqFZSiKF91Io6IasYtjeTfaP69yha7VgYwjvzMpPNM65kBwyOWSmhKCxOK85N5VQguagv787/7OajJpddXiZZSxUFXfyJPL19f/8P12UKn6XNcDHujlg== 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=/s0+Que1s5W2eoQy/OJla8scuKmDll1biQwYz1qYmkM=; b=S2HIdV7RkAbQ5pXbUs6CoQr1x2l5ToxZZHuB8a5qLmkUPdeOSG6ntghv+RQYxsSR8rl9P1LjPDS1bgBjj3NSTHIKR2o7Tb50Lv2CJ9Z2u4v3oWLfIj7G/QYXLOE65h50ibw9bcnAu5uuGa4hRBaeGWFLZ/HqO/arJjQdfapLDX8= 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 DU0PR04MB9635.eurprd04.prod.outlook.com (2603:10a6:10:31f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.27; Thu, 7 Dec 2023 19:35:01 +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.026; Thu, 7 Dec 2023 19:35:00 +0000 From: Frank Li To: helgaas@kernel.org, manivannan.sadhasivam@linaro.org Cc: Frank.li@nxp.com, bhelgaas@google.com, conor+dt@kernel.org, devicetree@vger.kernel.org, festevam@gmail.com, 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, robh@kernel.org, s.hauer@pengutronix.de, shawnguo@kernel.org Subject: [PATCH v2 2/9] PCI: imx6: Simplify phy handling by using by using IMX6_PCIE_FLAG_HAS_PHY Date: Thu, 7 Dec 2023 14:34:23 -0500 Message-Id: <20231207193430.431994-3-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231207193430.431994-1-Frank.Li@nxp.com> References: <20231207193430.431994-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR03CA0348.namprd03.prod.outlook.com (2603:10b6:a03:39c::23) 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_|DU0PR04MB9635:EE_ X-MS-Office365-Filtering-Correlation-Id: cf369fd0-fd2c-4bb1-e5f2-08dbf75b9a64 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3CFN51fs1QTPlCXkaGlX3N47QxS5ssPSo8BitNey98SXN39E5QHRgw/Pl0+X/j+t/9U804qm7UJVrvRp3YAibdbMCBXX8louYt5NGRVd/gGtz8ZZCfH6fcVgcoultJ9Hq0Y/sphP2Felyh352dAIJmkJTJTNSCSO6KrLPQE51Vw2XQt9oYHT5siRoQb1GwNXxbnhm2k2kFXqTHzM95/28eBfeCAec95O33caK9YzEYaNxEHHrmuSuMkKm++1i3SY2B15KDjUfrLA4dG/KLi9jHBGU1HBNA7sgiVWYOLMeNkh/W6IEnBDcAL4rtbbUmRHCYMqET0LLlBIUeEhcm88Aph4h2wRVxCzPaTjjDcoi2rXWcVmeKs/M/JVoPFXfMSt1Dxe2CUQQ4eUKWWBj5v88Cww2GT1UIbjsxxJyNHGCbIvN6RhYJI0VuJbJJi7rCe8FIR3gd/wy2aMrJs70wRRqZH4qn1rFfqnZNTDXLoUHWJWtfYDjA4x+wGxk5xjmR/uRx3vIOLdQ3B/1cOIXGd3uMv6XZOVpw8Jm1cgpZhsD+/wRjNOXWF0ANoq2f5r5e9TfBggWFrC8w3KEIoEoXwQWaR+1LRZV4TJSJBxeBbhdpXE6Kk+cWJs8z8Q6Rw3knD0 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)(396003)(376002)(346002)(136003)(39860400002)(366004)(230922051799003)(186009)(64100799003)(451199024)(1800799012)(52116002)(6512007)(38100700002)(66556008)(66476007)(66946007)(316002)(6666004)(6486002)(1076003)(2616005)(26005)(6506007)(83380400001)(478600001)(8936002)(8676002)(4326008)(2906002)(7416002)(5660300002)(86362001)(41300700001)(36756003)(38350700005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BENfIbEIQT2HBENpfyLXzeZybDeS0csajGcNPFGczPK2Fh6SS+xTuwu4F4lWnn9dQcK6gZvZERG8+eF265vYB9BX/biXUrNHcLNqB2U3feMz2Sl2le5m4A4WIPOyYdSmtnWGf8UaGTC4E3xaSFXz2NOlaxXfLshTwt4LF1UQCAJhzTk2pQ2xx9jrglNotQ/BeHbUYBtqB4DxtkXIFuXsbyEBJKZhIktlwMFQCQCen+m9heYbO/sZlZUxO8O7VjwOaJsX/8vqGOYapRV2ncQUmTMtAc60ylPXxatDoqrOii1zjtkgtcsl71ms9DJJm1EdHwGsQhrltdb2fvUvMn1yGKgpvG/4oDXptRHCrAnRaxS6+DXT5V17+cpgjdLRl1LOZebo1GRl9Rp8XklQKTq5w9hxGSroZpfrLKUEIyrj/R8vsE7+Wi6neC6nsFkJ428HLCl1umhHCEEiUAcwNAmW5MbG1UdKtwjGioV50O2lLNoxHg1mGFRN7kCmHek24+vxj5l9lk8wf5wH8+bHX8LBcKMm3h3d3YWVrKxs8ZXJz2YS3u35//F2UwO0+tE/w2zAEeyG20d1y4XCLmqE/8wMWU/IWwoXin6Zt2kNVNGErwP/+ePdyuZzF03NSvhenLBErrQS0mNaXymSVMsOhBW2rOkH5TLG+n4s/eMH/bmrc3LwAKnsBnY3dBQ/Isn+fnUN2nBGEKmbfSAJaWAAgmGUNrtwwWO4/iyxlwu6tRkFVMDDf2ZPW9RMRu9r++641YHtULDugqH0KhF9yGfzXVjbkjwlJF3zf0Qnwfa51261qk6g70etykQ5rjAQMNb2JfDl24FsCMOyAFrpIxkbeoWUXwE6jK4NyXPCQFjr7UpTLWmpWc8e40ZGSoETW6lfdknPqgKi/8ZL4JNdcfLXTBZwiTmP9wyy03dmwdtdo1zIFJ8QuHd1jl/PHHXntPFWUO0lkUBqAecEFBDTa4L44oR5LX5AUZyfBZtjWmfBwVOlpV8/mNmeh+P2a33hror1GpZvSrJnSnzxi0vWnzcIE9AADECpJswsCYpy9x8S2UCwkiht7oYGRNLkRNHECeUaz3pyWgs+OrgNnkk+/Va9cDGpcxzTD57c1P639AXjLYnWgkCRQFmGzdFywHwTTuGK6iyY8Ag9AI57xdPRpk4gcR17XUmo/DYucU+rxZXedjAUbirtcz36Dz9oNfp2rbLqFz5Ub9slgESFdKYOieQDH+HR8zwluemn2S/3dr1phQaI+6K7ymi1qF7SmZqG79Pik9wVJ2sq77ph2RlGSUO9z0Eomf7OJBh8I/h0J8kR3SuFNwWJVYs7g9hlPAgeNRDw7/XuIdY1omqk8ymWjybEOZDCGb+BMJlLNHa/cJSzYQwJJset2f3upi0B4ScLYXIuhd9fRTpG8m4jXjKJINJottlWIA3RFd2WCN68DIP6/IsIfPRZttwmqO8dssd++gbl/d6+Z38JqKmjy+tOIWAQJkmJgmHXZgJo/3Ya4Y1tghjz35pWbUR3EluSnRIQ2pzh/N01PqmtAubFoSTrRNe5xskPOND6wkiDtaJ88EbrqZNi5zE= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: cf369fd0-fd2c-4bb1-e5f2-08dbf75b9a64 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2023 19:35:00.9620 (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: 4fGXmYEpTPoPH2KYq8r0PC7m2V9NUWkLT2cuSUFY5GjW+B0z7VhWHi1v9aW1ahfSfTfmGSo1KvikfcX7Z5hlnA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9635 Refactors the phy handling logic in the imx6 PCI driver by adding IMX6_PCIE_FLAG_HAS_PHY bitmask define for drvdata::flags. The drvdata::flags and a bitmask ensures a cleaner and more scalable switch-case structure for handling phy. Signed-off-by: Frank Li --- drivers/pci/controller/dwc/pci-imx6.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index 8a9b527934f80..bcf52aa86462e 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -62,6 +62,7 @@ enum imx6_pcie_variants { #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_PCIE_FLAG_HAS_PHY BIT(5) #define imx6_check_flag(pci, val) (pci->drvdata->flags & val) @@ -1327,6 +1328,13 @@ static int imx6_pcie_probe(struct platform_device *pdev) "pcie_aux clock source missing or invalid\n"); } + if (imx6_check_flag(imx6_pcie, IMX6_PCIE_FLAG_HAS_PHY)) { + imx6_pcie->phy = devm_phy_get(dev, "pcie-phy"); + if (IS_ERR(imx6_pcie->phy)) + return dev_err_probe(dev, PTR_ERR(imx6_pcie->phy), + "failed to get pcie phy\n"); + } + switch (imx6_pcie->drvdata->variant) { case IMX7D: if (dbi_base->start == IMX8MQ_PCIE2_BASE_ADDR) @@ -1356,11 +1364,6 @@ static int imx6_pcie_probe(struct platform_device *pdev) return dev_err_probe(dev, PTR_ERR(imx6_pcie->apps_reset), "failed to get pcie apps reset control\n"); - imx6_pcie->phy = devm_phy_get(dev, "pcie-phy"); - if (IS_ERR(imx6_pcie->phy)) - return dev_err_probe(dev, PTR_ERR(imx6_pcie->phy), - "failed to get pcie phy\n"); - break; default: break; @@ -1500,24 +1503,28 @@ static const struct imx6_pcie_drvdata drvdata[] = { [IMX8MM] = { .variant = IMX8MM, .flags = IMX6_PCIE_FLAG_SUPPORTS_SUSPEND | - IMX6_PCIE_FLAG_HAS_CLK_AUX, + IMX6_PCIE_FLAG_HAS_CLK_AUX | + IMX6_PCIE_FLAG_HAS_PHY, .gpr = "fsl,imx8mm-iomuxc-gpr", }, [IMX8MP] = { .variant = IMX8MP, .flags = IMX6_PCIE_FLAG_SUPPORTS_SUSPEND | - IMX6_PCIE_FLAG_HAS_CLK_AUX, + IMX6_PCIE_FLAG_HAS_CLK_AUX | + IMX6_PCIE_FLAG_HAS_PHY, .gpr = "fsl,imx8mp-iomuxc-gpr", }, [IMX8MQ_EP] = { .variant = IMX8MQ_EP, - .flags = IMX6_PCIE_FLAG_HAS_CLK_AUX, + .flags = IMX6_PCIE_FLAG_HAS_CLK_AUX | + IMX6_PCIE_FLAG_HAS_PHY, .mode = DW_PCIE_EP_TYPE, .gpr = "fsl,imx8mq-iomuxc-gpr", }, [IMX8MM_EP] = { .variant = IMX8MM_EP, - .flags = IMX6_PCIE_FLAG_HAS_CLK_AUX, + .flags = IMX6_PCIE_FLAG_HAS_CLK_AUX | + IMX6_PCIE_FLAG_HAS_PHY, .mode = DW_PCIE_EP_TYPE, .gpr = "fsl,imx8mm-iomuxc-gpr", }, From patchwork Thu Dec 7 19:34:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 751817 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="nx1uejXo" Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2071.outbound.protection.outlook.com [40.107.104.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C66A110F7; Thu, 7 Dec 2023 11:35:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R2LQ562mCGJuIwgquqxgqR4FdPTYnim1YPKdpt3Dflb7DBO7cPO0hgq5okUpWLwTN8WcsIRQq5pX54/KTQQX1UEGVaSh+AQaqE4UAKxchsQcR3VnmEWlp5f6Nk6bxZkCwFT717DOTnh+/Z5KzOQpvd6w8HpdXAsupziRVmH+cjPzYOjlqiCoyMa5xVjZ8dw+0hV+R+FrjmGAuIKJLWZYhEByzrsUK0sxP7ie8xlJZuyjblS4N61QSTxFTN+gZYLLC4nAWUZtA9lWIMyrXTw1Uhm8/7xgqMcQGwJHgOJ+P3RxXpP8IMdUoCJjeGTJsMDpaxqwkQXcGXOOYKbm3j/GLQ== 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=LzoJNgxx7XeWgJ9B1JpqNzJ9NuYU/ZTE4t87VxOogg0=; b=YD8JnXjZLCCaXEkeFWPoKaspnaTYy1pjuw1W2xx+XLYAz/0lzebaHYBbte3UU/p7Mw/p38y0y7AzKDdmq/QUOO1ojqZRTVMWSUFod9wcWIstfB4LEhDhW+YTSMPAZjwBkjdIrEseLZJF8FuhOQQyNnc0jrYO7cpf9FfFQqLEKBH67wArosYJQPUY1cgIii/OOAaqLTK1CWIU83ZKHNTU+4niqYMKVWffdO2hnb62ATG9L6UR2H3CG/+cg6LjzPfGXj0SVRS/2oMdQHu7UX7Qzmk5YSb7h2055cws2Titc4oFaFt03KH74HoUnCAgFlbyLnq6bbcloMCVfMv24SdwYA== 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=LzoJNgxx7XeWgJ9B1JpqNzJ9NuYU/ZTE4t87VxOogg0=; b=nx1uejXoFoL25O1ZwfrjkoTEEToo9wTKbBa8GdWupvsY29pqG1Ykm9PlXilqM1jIMHyjuvJHVpg1m6YawEf4nkSOO9nbBQ6sEVr8U9t7ZyD2Ham3b9/Ime3yQac3mRKE47AfflxLrpyIEOypcRLPoRe+Xdx5kO5CwhGqT+qX5Q8= 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 DU0PR04MB9635.eurprd04.prod.outlook.com (2603:10a6:10:31f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.27; Thu, 7 Dec 2023 19:35: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.026; Thu, 7 Dec 2023 19:35:06 +0000 From: Frank Li To: helgaas@kernel.org, manivannan.sadhasivam@linaro.org Cc: Frank.li@nxp.com, bhelgaas@google.com, conor+dt@kernel.org, devicetree@vger.kernel.org, festevam@gmail.com, 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, robh@kernel.org, s.hauer@pengutronix.de, shawnguo@kernel.org Subject: [PATCH v2 3/9] PCI: imx6: Simplify reset handling by using by using *_FLAG_HAS_*_RESET Date: Thu, 7 Dec 2023 14:34:24 -0500 Message-Id: <20231207193430.431994-4-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231207193430.431994-1-Frank.Li@nxp.com> References: <20231207193430.431994-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR03CA0348.namprd03.prod.outlook.com (2603:10b6:a03:39c::23) 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_|DU0PR04MB9635:EE_ X-MS-Office365-Filtering-Correlation-Id: 3b29a52a-781d-43b6-98bf-08dbf75b9d83 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ExuauAAVS1odlbALWtLN70UXRkX4OrbMinTkrwTPCEARFcmVw51ni9nhI5DAMyxUx0Rvm7jB3cuceyeKD6F97bnWLz0baTMfa/JKhYT98lI+V+eDBBP7n9O5BtQWwqTDChe5tiaZXtlDssVWaehjsaG6kjv28ntzxPGG+xK2Bla/xypu+6CgIEE8z7/ztDD0m5jCBXE7t6dZz6QfyMeXv4g8VgqDM/8WFTjcZxtJJJEOZPPRtfWdKZsw/Qzl+E94m/p2skZikXIZfjGvBNrRxF39mO6NcJfNedkGnz3rI3a2wwgIRi0eDOiYYjHPybXgC1SQVVgG5FE7HL1nrjMmtqnTdIw++pD0Hy2mcTg4Vq7kEH1ps+tOSmbsknGksNVqXgaRPzL4+z5GBDNrNUbqmDsIYh4yFsCJlXQBKDYf+r1pBCBtc62BzfLyGax6LRSDBO6SnksY6jtGH/gXAXIMeTFzUoxoEYw5fJik6Qiaj5Y8rzmtU39+65N3AygdrsDMZ3+Pg5ocRMRbkz1fCQYiHxIsNcNf9viN/C88/R4TsildTu3SskERLb7yz5ihchMGtkWKqUDfr6bjT8OGN+acSm8iagTD6dN8Xav+TdSx996+fORMx5GXgJ7ohQr8jWdG 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)(396003)(376002)(346002)(136003)(39860400002)(366004)(230922051799003)(186009)(64100799003)(451199024)(1800799012)(52116002)(6512007)(38100700002)(66556008)(66476007)(66946007)(316002)(6666004)(6486002)(1076003)(2616005)(26005)(6506007)(83380400001)(478600001)(8936002)(8676002)(4326008)(2906002)(7416002)(5660300002)(86362001)(41300700001)(36756003)(38350700005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: be+g8GiJo6EEzHZZCIcFZnkLzTyEu08U1net5fEqf8gtoHzJ+8M558FbpQG6uammXcNw+TWauM8MP7m9D0wgK0YTnruI7C75R/XBGPSWdlvikG794Y0WWVSJ6kRiohOJm+IFF2PAqA/aaFvptlSmfoIH0KMRtrv53xvzjrLQXCuqOKhbQdcyTezmv3SYV+Li9b6z1koHWuyIpeU7zQrYr1gN/gqeWsT1JMVoUbtxDZsvZCXm0n8vi8UiM6y0bzZlGJfPqfFdngBQhfTdONcC4IAegvbCSaQyDNpbySQ9KOUbxKPquAhtd1jg/W+eB6Q5kFHvbpgXYB3D5F5ffkN4Arc5O3iacXOMupVnHsSY8GThSlabe7BGwmSNDZ31jTufdwuXdEa9YRGZc9UZxtECQsEYtZAr8iOm79U981N4v67NykUVg/IreStZW2xzZxjwh7pV/f/hvQ8kpmhJ0gcBQF3TWK5hOu1+w/0dC3WAgjCdcmPqZxFoLM2VF+D2mkH5tebPs3k5QdtVU9nd08tQnvcSw5PaJ/RNExgmZSreRyb/qdqn1cQNmMyfSHmZUoUtg6b8DZHu0Hzv9rvHlNUSqMyJ6f3zK62RkdsBRJ0N0W8EltDo2+uprkt8TGHMkDUkraJGNNBjsJwwr8FZvyo3HxvV2xFr8xgwQWNwVKSJpCsDcSTkCFqtADg7nfNwt6i+A83M+Rjr8x+8EST0syqh+LuJUmHDBxL/Mqg01heMVY1Cz+xxxmcb6GJU1Old0Cg6iYELbrdD5Jl9/oQNLkgm1534g7azPBqADwuDhRSQXa/sVOoDAw32a/g/Ig/R6Jiv5IRzCyG5ZvuiGCx01iG1P4OL3FtdLhGC5/Hk97tLJxdYsWfeCf7zdIKOvdIJFHqBpWIYKw8wIctwXPaXT9O5iIWM8ySpeuwbaC4o6lSr52lmqNDAbGyr6b9+0+RYX67COOwMVQKR4GqKHZh2Bi+ZIWxK95OCE+XCRcmQJkq05EwNvJtfto0Q6VrtyY8S/vVw+ikpQF7NiUzHEBeTNTAdR4nl4xQHeb802Kh5V5RR6GRf2A8sGglTNPesXQI9GnEY1/cgWtZA1ITwFMBVNXSatx1knsF2ytsbEphR4WVQvKKrdD7EYhqzmcurNyfulyBSNMWzCN2758hV8/DOL78kSm7jUVlqmUrDbsRTpxGsnMjU3rnS+TCinVhF5i7xp1gJmoyYQuI45ivQO0aLUfyrdLj2Rk18PDFLvYyBcVNGGxSEanVyetLyYtmcCuRVPAajoEzcMKMVKZYRYYBr9rCS8VpCnl0TquHuOzEDkvCraEsYqk6M3m3RWlOVqCwF/hgxYIN6iRjIfQYxZmGf7RA+VPyubTZFU7+rVY8zZ5cmMtp3gKSUfCup5XfV99/jxAOGVdJHDM6xpFADBVmlmYeREVD9DvR4wSUMgEKeO329zrUwmueXlyOX2plB+vaJ4CwQOsBTHveJDy8GmdDAhFNv3Z/HHN2bdngzKNVXU4k6U9DTo06rGp3Qz1PsYllaF6+WADzr1bXykX8Ch4YGLEnYrHOre21JVHxy7o1KpZlzMnM= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3b29a52a-781d-43b6-98bf-08dbf75b9d83 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2023 19:35:06.2520 (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: /DLuLx4+/kN35e/KWRWvcTInKfHrcwkqsg8Xx9IDTdBF/GhTRpXaAzIvsd5ry4FvmJ8A06HkexOqqPKaQLkf2w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9635 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 --- Notes: Change from v1 to v2: - remove condition check before reset_control_(de)assert() because it is none ops if a NULL pointer pass down. - still keep condition check at probe to help identify dts file mismatch problem. drivers/pci/controller/dwc/pci-imx6.c | 111 ++++++++++---------------- 1 file changed, 42 insertions(+), 69 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index bcf52aa86462e..509d459bdc5a1 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,10 @@ static void imx6_pcie_clk_disable(struct imx6_pcie *imx6_pcie) static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie) { + reset_control_assert(imx6_pcie->pciephy_reset); + reset_control_assert(imx6_pcie->apps_reset); + switch (imx6_pcie->drvdata->variant) { - case IMX7D: - case IMX8MQ: - case IMX8MQ_EP: - reset_control_assert(imx6_pcie->pciephy_reset); - fallthrough; - case IMX8MM: - case IMX8MM_EP: - case IMX8MP: - case IMX8MP_EP: - reset_control_assert(imx6_pcie->apps_reset); - break; case IMX6SX: regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, IMX6SX_GPR12_PCIE_TEST_POWERDOWN, @@ -728,6 +722,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 +737,10 @@ static int imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie) struct dw_pcie *pci = imx6_pcie->pci; struct device *dev = pci->dev; + reset_control_deassert(imx6_pcie->pciephy_reset); + switch (imx6_pcie->drvdata->variant) { - case IMX8MQ: - case IMX8MQ_EP: - reset_control_deassert(imx6_pcie->pciephy_reset); - break; case IMX7D: - reset_control_deassert(imx6_pcie->pciephy_reset); - /* 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 +772,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 +819,11 @@ 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; } + + reset_control_deassert(imx6_pcie->apps_reset); } static void imx6_pcie_ltssm_disable(struct device *dev) @@ -854,16 +837,11 @@ 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; } + + reset_control_assert(imx6_pcie->apps_reset); } static int imx6_pcie_start_link(struct dw_pcie *pci) @@ -1335,36 +1313,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 +1458,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 Thu Dec 7 19:34:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 751220 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="hIZmxiON" Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2073.outbound.protection.outlook.com [40.107.104.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FCEC10EF; Thu, 7 Dec 2023 11:35:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c6OVz3C7Af4n+P9GQkg34AnCKTHOjDlGs7o8BzYlsg654Sy9dFUWZl+sTmkkYph4VI7+V8CtrGkGGIl/LV/ngWFdq34FTvZ/fWeWBRFRXkB8+f3OSewK+d7mOKgSKqeD6WMo3PtjsnflDGvTYzuHf2vlvehxbxCQ6gA58BKzXtSGd74AcjjTs3an/F6JQQFKMmkgpI0B1IIONZ1qrmQaDYEW7Mc1WdKLC0RcQlIYunO0iAQUuQat7VaWQVs0+kZWNVUZFQzGNplpwQePrtytN890vTcIOtr2up2gco5pMI2fK8Rm8xy9FiBZ9ckOE6+XxzAAOKinLtqjxHv2aAPblw== 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=PSuEpyyki/DfByE7OzgHPt5qCHhxy+0xcoGs2kkAca4=; b=G+VwYZVR1Nzb/oXyKJxIiSyixd+NOfuphZs/9Xh/NApnvf5qr8B3S3TNyrP81rBAj3Bx9WsqKPehvIqTKV59niqI9INibNoJLnAPtHn+rQZlG2RyQix908nJ+WV2MxJfUTs2Tu2aJD5/dAq9Mv277vlSdZuLiWf043ECgyjqiv9/oR9LgtjeC20+8/SOKjESougCxlBNMKz6YfzUwxVD4g05KWWKR30osuQm+pxE7SG9G7wvb7O6mn+JEatYpKKxQzQ46dCQRhBCl/e1jtQPWc4CqSg09MN0icOTA2yrP2sShtGfFosFc46Fc0ICP6b4sl/WPOf+OvGf/StYs5cmSw== 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=PSuEpyyki/DfByE7OzgHPt5qCHhxy+0xcoGs2kkAca4=; b=hIZmxiONyJeeneS436du8QaRY6W3Xt8GNZIoUPJPpV8vD3jz3l8sBptAj9MGYkaQr523+KxRaeYAv7Rd18ryaLLMkC+bbdKMub4XZlpt1cAaC/J16kfTyNTETOVZ08t5wMXNP1PNreu9d2JlV3F2vOnqzPAu4+nAWy9+sEppG2k= 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 DU0PR04MB9635.eurprd04.prod.outlook.com (2603:10a6:10:31f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.27; Thu, 7 Dec 2023 19:35:11 +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.026; Thu, 7 Dec 2023 19:35:11 +0000 From: Frank Li To: helgaas@kernel.org, manivannan.sadhasivam@linaro.org Cc: Frank.li@nxp.com, bhelgaas@google.com, conor+dt@kernel.org, devicetree@vger.kernel.org, festevam@gmail.com, 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, robh@kernel.org, s.hauer@pengutronix.de, shawnguo@kernel.org Subject: [PATCH v2 4/9] PCI: imx6: Using "linux,pci-domain" as slot ID Date: Thu, 7 Dec 2023 14:34:25 -0500 Message-Id: <20231207193430.431994-5-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231207193430.431994-1-Frank.Li@nxp.com> References: <20231207193430.431994-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR03CA0348.namprd03.prod.outlook.com (2603:10b6:a03:39c::23) 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_|DU0PR04MB9635:EE_ X-MS-Office365-Filtering-Correlation-Id: 64a12733-ad45-45de-8714-08dbf75ba09d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qUShCUzxsJJ97gh85RLCO/Js0gFilIZmBwMYrtPT9czeHqv0/DogzTUiljGj8OHBROqYZSMogIAzVRs0WUX0FVwONYQAhkSgRbZqa2POLZsJe2XGF7raoHCWLlkh7clwmKoBAH/avUfIz3JWQgInqo87a24hvaf55vl7JIpDQKnO3SDtVepIaOU2AALfHy8c+y3kaP2PnHJvqSwlFT/yZAA2Mr5fv4vkTSaJUPvKQ6ExXU1uBHj7TkCtnm821SMKWwKKIOoyHjXp/EzzEsbRYN0OpPcaNRR3X66CedqjEwLJTTYQyrq93mAfBpsl5Ce+FG59nN2PLJ5ahrTrRpMJe8Yp3IXo7d+wJOnnAvN8PyTfFKlonhG0eU0HVssHZsN+YHXcX1MFezzbMQrFzvM1Rbkk7KnmFBxoEjMDD1bS/LC0Tsr2a2oU89eOU9D0ywXHpzzmhFs0qvX++u0hCxCOVrT99CVppEuqNOsxnXwoZP9s1TPUE/t7vAYqYVNxHfvA439aRKfXuABlQssHCmyf46v3PpvA7z0NR556XpxZP9YL3Eab9Df8Z+E2sBX1KDuzdsS0uTQwh2iCHqE9/tHScDCnWiiTIZ45+wK3dBaBUKlbnZoNVYzosqVSz1eZ7h0r 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)(396003)(376002)(346002)(136003)(39860400002)(366004)(230922051799003)(186009)(64100799003)(451199024)(1800799012)(52116002)(6512007)(38100700002)(66556008)(66476007)(66946007)(316002)(6666004)(6486002)(1076003)(2616005)(26005)(6506007)(478600001)(8936002)(8676002)(4326008)(2906002)(7416002)(5660300002)(86362001)(41300700001)(36756003)(38350700005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RYEEm0cvGY7z+LeeZX/elhvAQ7mJvEOAiwIbTLtiPEsRZCXbv9rktnYw/n6FANjF12gLV1B3itwOqYmMNodP5t5ez8wl+cBmT4HbIeJhAfXpLKQtFeRi8/fIpbkY8+96vUbMF6R0gPVrh6odE8KhXGVomvY7DSXaoqYqW9ueoA7aJwX+CTQgp7kpJGa7iLMB6+63fAiW1UpBziG8BYn15Rg22f+ftYFRHw2Ia4rwjUeGhaALfUsvFmpteHzLbu31X8dlTLGB/zyfL1kQyNlrCdxKVL3BEz17PZH46aA2kq8G9ct5aKwZSb4ieMZLVwj0ZKaltcFZlHF40pivmWjLXaOycw7qJYZn9T7vAPcJe5n8TiI9xN3+nTXmcEgpgx5dXAHoj7dNCAVvRuxnraWCm+epda8Kh9IE9EOZiOFnsL32sj5Cx6dPcCO4YVmUB/5O1/mlxQ+Atrmns13fpyP6TKuDVJCZCSOwzncYlik+orxz96UUQO6zJKNr5RckkITyBb/N9g8GRz9f1KMGreX6cR39VdGhEzyJvlIvgQ/3+XGMnraeI+jdaPCzCRduIBpRiUVsoa1NuRLExqxEFQYtncCksk3uYGs2SAV315MFzDVndpnPqMATNhAYricLGJ3kdp2qyelxBfngqar2A5ZLnL45S1SBoO51Ig+ByW9J2aCFkAMFclzIhX1s8+aGSgMPpTqXLn67ki8hs/fBaKjbHUX8qgIsPd678cWvN0UHLZmx254IdwbarlzikS0rzfPC86vcboSRYlRsJE6JUFpJrETFA8B6FsqC/9scNjesPskCKH7leRyqkbSyGWt7fht1RoYV4BoxSac0zise79PTlRSpe+aUdmD2RFv3fNZuamtqmKIg1hwYV4o6/bvu1rMuDdNPLDn/8ntAF2KoVjklx+bAp/aJYGjplXfyh+gULyWdBIWQJv2g3jy5XjBmY3vMjzCbmukdxglD4GbFyzeCFQxFG3yZz4m6yx78mUlfSkhpI4BDponlcoK0UT2+B8ugHnnS3N6aMrlr2xK0r/jblLJY+5usZGVYKz7B9v9QSOzWUetQHz1MPPXzvpwBN6PquD4/JABRysRGHabGQIB/8fmmdkdEbuFLkQuONDwGSMgXRePqKrl0BxyWUff2wZPAQY9yvgZ/dRGk4MNxCcymKEhjSKV97dXVdw9VM6ospIQfUdNJAC3/SAySCUMmS2umZrZVeB5mUgGR1ZSiyrmPez+fINGNS1/FhRDQs2ZcOuin9szY9+DeHh9ZtP2bou8a6VbEcQQ1EbJXDJarNHsMUfkKo6qOuZ4ScYk9EoFfLeOhm421uy/MKpFA3pmqFhcNABdjvtB8G+sVcpM3bWysGSAE0ZFDxInWZwmfUEwtguR+baCbv6hgqUFd9yJUjgGMwOefdL0qOkvpWb5c6zn5/9Q8s9D0tepd58PcZttHGM9GSHdWWRkk4WkkpjSaSwTTIr/dBP9tSveOB8ooSbXsuzuez1kne33ybDZPU+vm6j8zfdJsB1SM4f5zPsDiWA19WsWvJG8ACxpKH+OTFBelavGDNeEnFtafpOV7nQcsBQo= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 64a12733-ad45-45de-8714-08dbf75ba09d X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2023 19:35:11.4626 (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: /YOmhfl8Sj7x/wLu7VSAD3hV3+3oZc6CKn0xRfNKnhJFnxNtrFgRnC/F9dX5Z1939sNUOE5XRL7vOQF2btdhLQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9635 Avoid use get slot id by compared with register physical address. If there are more than 2 slots, compared logic will become complex. Signed-off-by: Frank Li --- Notes: Change from v1 to v2 - fix of_get_pci_domain_nr return value check logic drivers/pci/controller/dwc/pci-imx6.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index 509d459bdc5a1..548034151ee1a 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -33,6 +33,7 @@ #include #include +#include "../../pci.h" #include "pcie-designware.h" #define IMX8MQ_GPR_PCIE_REF_USE_PAD BIT(9) @@ -1327,6 +1328,12 @@ static int imx6_pcie_probe(struct platform_device *pdev) "Failed to get PCIEPHY reset control\n"); } + /* Using linux,pci-domain as PCI slot id */ + imx6_pcie->controller_id = of_get_pci_domain_nr(node); + /* If there are not "linux,pci-domain" in dts file, means only 1 controller */ + if (imx6_pcie->controller_id < 0) + imx6_pcie->controller_id = 0; + switch (imx6_pcie->drvdata->variant) { case IMX7D: if (dbi_base->start == IMX8MQ_PCIE2_BASE_ADDR) From patchwork Thu Dec 7 19:34:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 751816 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="sb2tVrUT" Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2057.outbound.protection.outlook.com [40.107.104.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB5841708; Thu, 7 Dec 2023 11:35:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QRQ0brQVFuS/GcEa+SVzDj5az/NQehAwqVtQZUjH9g1oKfCZbNeAfIiGcOQP9aIdk0dPb3mDq5ShEanEhG1pVaowsA+HiCPslCW/gKnC/WZ5b8z7fQmqRhMjha1hmKwm0XXt2rXKJlyePSmF67NeeNE1nLyH8jJmENymazVDpP0dAlr1txojhYbUJrRz0qH8VReCChtX7ZIsQS6kw/efTWorEUxI5GTHPRB/cC4yeAK0SyBlIL1dt95Dp3MGqWnmbvHW+WP8iOA7ZDTaWKQGjhk4LP5pV4R44fnPsK52h2PF6/Jr8OCjBr17MoLmk3pZfuopr9pT5nhfTC5+BE1cow== 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=XARXGLgZ6aVhHDWK19/XaNahMdf+FyADYmEydfD1Mgs=; b=UO1MSWzfL3szbOo1N6mFgtF3H/kfDa8LJi24bS1Ej/9iPb3pX59SyH/h76hNXw8dTHpeU1aerl5xyGkzBFDvIKIcHxPo40I6rVp+0Ik1SW9x0CSnb3PUVgMZE6iiduPLy9arRfVHKBhMRQfEyFcvQex09GOfVQLZ+9mR6RYgVtWlq7fMgzWmhghZ+fXYLp1QJGRlb0NOuSdK6A/RHTwUjDYkXRkHXsfh3R7QURJPbPGfVVTVDGVkOn4UEZJNar4muxXTSAo0QsNS4h3QQZ2RK6DB+9o2EqVQYs53sLXFv60Av/LeVRUWdlGfqObTpLgXh/sYzZi6+/iT1ybEoF/2vQ== 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=XARXGLgZ6aVhHDWK19/XaNahMdf+FyADYmEydfD1Mgs=; b=sb2tVrUThMvBbX/xRuhhpFqJSXOc9grC0wo0D5v/A7tvOKCcl7+qwkA7PkToEIxFxgthxfZ3SS0nw4GZfDQTuyTuRrma+q8ikr+LxJpDhbYmExAyBJB+OSW/xvxr68h7AMWYM6mWjF80jfjCaGB42O/qCE0WHI9b71TdEOXB+6U= 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 DU0PR04MB9635.eurprd04.prod.outlook.com (2603:10a6:10:31f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.27; Thu, 7 Dec 2023 19:35:16 +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.026; Thu, 7 Dec 2023 19:35:16 +0000 From: Frank Li To: helgaas@kernel.org, manivannan.sadhasivam@linaro.org Cc: Frank.li@nxp.com, bhelgaas@google.com, conor+dt@kernel.org, devicetree@vger.kernel.org, festevam@gmail.com, 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, robh@kernel.org, s.hauer@pengutronix.de, shawnguo@kernel.org Subject: [PATCH v2 5/9] PCI: imx6: Simplify ltssm_enable() by using ltssm_off and ltssm_mask Date: Thu, 7 Dec 2023 14:34:26 -0500 Message-Id: <20231207193430.431994-6-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231207193430.431994-1-Frank.Li@nxp.com> References: <20231207193430.431994-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR03CA0348.namprd03.prod.outlook.com (2603:10b6:a03:39c::23) 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_|DU0PR04MB9635:EE_ X-MS-Office365-Filtering-Correlation-Id: c4f8da61-a6d9-40b2-2593-08dbf75ba3c8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JbnhgXCI9EvM13AK3kWeSHckIJn4bme8SY+jim1UXz7QcMhZnKtzujSyD1B1ItToDv8Wxtv561CT8UO3FLQM2bEVLxv9yEkY2ZQYertqZPUT9EqUXlWVYjGsBYD5SsUdKDE5U3HZriOeZe0S6t8U870xniuZgmt2oP0jw8R2Gm3+T9mpkFvzFrBeolQF5l9rHzNZLwx4bEP9momHRNaEmQTXa3l9cQG7BNMCe2/7PPFIiKVzbeG8gN2wc5kRQsX+m1rcCGGogoH+hJOWLxhxk3PzL+9+eFKbwQH75uYbOgaxOLLiH0H+/Zj4/Wsf9Xr2L2RS3PrVqODTRv0BQ4A70iRM5AZxhV4mlmQ8+p+oj8eJ7bKLnKI0U9JcGJaqvheBksWvv8wswhM7twrEdrcArl29SElkAHj+Uw6pd+aX3W+EnprzflVPYaQYV+IWBaFBuhc9KGD1YZjlxm/9PVvJRzdMF0bj2FA8GE1p66uQCr3SQakQlHsLrPqPG5aUyZTJY6qrae10SMW1OSTb0Fp+auGPIHBOZkRiO9T9cVnUmsv46gqvciEFyARttM04Bqx4GTEZsTO2WfEx96aR74J++zfeFcJdWsKslHcDXfd4AtMZilCxqvzJMky/B4tAGbNx 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)(396003)(376002)(346002)(136003)(39860400002)(366004)(230922051799003)(186009)(64100799003)(451199024)(1800799012)(52116002)(6512007)(38100700002)(66556008)(66476007)(66946007)(316002)(6666004)(6486002)(1076003)(2616005)(26005)(6506007)(83380400001)(478600001)(8936002)(8676002)(4326008)(2906002)(7416002)(5660300002)(86362001)(41300700001)(36756003)(38350700005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: JwyJNOGGzvB/LzzxM3Ro9Gc8jk+p8mA6XEdJDo89ZxznOyUSfqMD13xx7X+J0pXoPYacLhhAHqXlzy3wpa9czPyFjHDShxcrUC1vApyySLz10t8bnBretNrw8izmUc8jJ/MHLEaGRj6VwErOAeyf/VWKbM/SzNASHH/F7kb+t81ooPdcbLIKUdgLElrtzLylg437AyXikoFvroof4s2U7lKFor0YPFUWQCcv8dx/9UAWoJiW42TZ0kX1GimE4B5wh+n1f93lz8Be3Bb5jZUY1QOO6sMgOxLY6DN3Rq6qLF0wvV5CiDZ5fvxE1QmWtOS9u2Li//+/ODJkO2TFr3QRso+5sVvc6DFF3ZEEUtYr3ZcBoCCwhC08DwHnAmxIjt7nMjuKQ1bEJ8lTA5p8tSoKr3arj6r+KJhbFjL6X5QcLVrafcrWUsy83syJhQG0zkpzsSyHMZ0qJevGr9Xb0YPfDDXfUx5aCyEnYaBNwrFdz0wYNbtE2mLzsOOXliuYB8SGZvq2qYZISZxcMagADN91kNG5F9fNOOyYHTagCfW2ntbMf5/TweKFYYwoqgvIwdGnZQ1jJsqr3DH3vW1AU/Om/M6vVeiO/3tzUalL8VHhQmZJIyHuFi0C7h7lvndn7YXWQ9etmsy0/AmLMGZLjpK7ywAzffzknaVfPKypQeBsfO6is2BPYZdX1AXZdwa6UzszFvJjwJJ47nFqZQPbjqZYdPGwxlRN2Mur/yit6n6jhO8/CDNofDZ/tYIRwjIK0b8gJBC0zgRgpBaDe3j3kt4ObvBVik3PWAQSIHMu5c1bNRCE+/5bYj1M458Psx9vix29QfpQZIucabexhi2iwoXz7NxuNmBJDc3xW1GjZpYd41fswX5SnebLbGNxjc9E4vxj47OhnV6z0k4aRAbvl8tBi8ScUXsUPiKjv96MpbRQmFVeBg9MrHcHwtSnOeHywg9Bq3SoGnevBDfEs1crckCK6bnV+ycFsqYqKJt6Vd/GE/tZ65x1Du/k9jHqJYF6j26rfGql0u7oVTxEdIVcUhYVH6dEA+mYSWE845599hKeugRhLVicKBs670Nd2VsvCaM/+Nr5AiMER5ux8+4EpKkDZLXJsom0MKv0882PeGexwAfjSbBw5IvOYmXkX7gGV0PWg7jT0IVVVhBDXoR0hELkZ/O4GqYyznr81LxQwBhc2ThD3nV8AHic/zg66f0y0XJaxVV3aTOXGt22wavMT0GRrI4OoU1WWVWlJ86eYqJ+VS5NJk7IOrcC8SObENCsQO4WLsgY4kFOWjcrqsSdOPA/4G+tXsGvk1wg2V4sTfA01CUTRIspaNWMgIZHTmbG+cZGp24jeLfaMmwMfm37r8sczejTsbZXFVKhQFyyohCZ7us0CdQANqTrLjTLj/DHnUz85SN/8d/7zz5PKpvpDdi4rfHpFrtCtw076ZwghrvGeb61wGLGav+kJBTb65k1SoCy/3lF7okcvzpCaK+hXM1HuOTwazDhs6XRNBvmzK/AxMQB6pcOPPA00c5mErJJvMBeHoiPx3HWVQ3bzxHlaksHcd/1LH/zCnzZiWeg1jqQ+Bw= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c4f8da61-a6d9-40b2-2593-08dbf75ba3c8 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2023 19:35:16.6602 (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: iyA1qa29jbC1+0rVj3bjt7qb6I18iy61gnQx1vvVWUFJ/hP3AKEJYurgvMfcDifP0VPqYx8wyf/YduPsiyNEFQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9635 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 548034151ee1a..5bfb780e441fd 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 { @@ -811,18 +813,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); } @@ -830,17 +825,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); } @@ -1446,6 +1435,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, @@ -1454,6 +1445,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, @@ -1462,6 +1455,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 Thu Dec 7 19:34:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 751219 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="kFEptx5g" Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2073.outbound.protection.outlook.com [40.107.104.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3211710E3; Thu, 7 Dec 2023 11:35:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W5aMTzic88ux6gzj21Ac3bxKGPr4q+ZlMZLa80MudEcwTkGhQJ8ExnoLCB+f5g1RarlIcm6YEP1lW381p2MGp2+xl+749WHsBmhhfLuibnPk3jh4okugZRziP+Rm+97q+0e4ogGvqTCygr7v6Lmhovw2pkN6Qx9nJMJkNudwL7anIp3jP5WAS+mmtvQgEGxlHSLx7/ns+8jctsXSXkAvO0L7/A7+hS7/gWRF85qGg8byXlUPkAVuEVJmECJeExqmmu5/9Df7lVc8wfAmImtbV9bqLG/mGqT7MWGEBxsGzTKGlUoiRwg0xIMF04BkOSncscpl0bTRrOnN2oNrZcJkkg== 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=FH/6zAS11kQqbmCKblM3aWi63sdAWsoeLepIjHxsGqA=; b=cNFGZtkjeAPJk+BQk1tjJUR+p+xkM3GsPgHG3+bKqdHe2VAl0EJPs3IP7dSLDqQd/auyYyAGExC5a3pFU7mLrb/QUFe8vjD6wijGEHDlJdygN6TH4zs0kEwm2cCzNOyPzxpC0bNh4cXMY/46hbP1cn1vz6ADHZ6QRID0ldKjSsLkxqaG9S/q7n0r9Zq6wZnajctVM+dfqEvv6myPS5QaMR5mnOuNizuZmKINOLupGN3NVefTKt+PlSEXoRcqnq1THtu3Yb8KnbFexyJue2GE/5CshZNvzVSEffQJCLWbPUYSWrFljH0ZNqv/80BrgcPLw2hIQt2p4Ydx66LE3/y68A== 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=FH/6zAS11kQqbmCKblM3aWi63sdAWsoeLepIjHxsGqA=; b=kFEptx5gUu/GTCyAJxusZlVICc/Az9PcvFPWEl86stl2ctUK0UHxUcEtTqqCSejgup45tkq6atm43Nb8Oui5nMpcZC9n6321R1CJdZBpz0/Y6cbC3ABzZU2xsdI8+qbe6QXovZlYiQnK90S/gRYt/nTojeOiFzGTg4faZooRcXc= 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 DU0PR04MB9635.eurprd04.prod.outlook.com (2603:10a6:10:31f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.27; Thu, 7 Dec 2023 19:35:21 +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.026; Thu, 7 Dec 2023 19:35:21 +0000 From: Frank Li To: helgaas@kernel.org, manivannan.sadhasivam@linaro.org Cc: Frank.li@nxp.com, bhelgaas@google.com, conor+dt@kernel.org, devicetree@vger.kernel.org, festevam@gmail.com, 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, robh@kernel.org, s.hauer@pengutronix.de, shawnguo@kernel.org Subject: [PATCH v2 6/9] PCI: imx6: Simplify configure_type() by using mode_off and mode_mask Date: Thu, 7 Dec 2023 14:34:27 -0500 Message-Id: <20231207193430.431994-7-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231207193430.431994-1-Frank.Li@nxp.com> References: <20231207193430.431994-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR03CA0348.namprd03.prod.outlook.com (2603:10b6:a03:39c::23) 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_|DU0PR04MB9635:EE_ X-MS-Office365-Filtering-Correlation-Id: 3c17876a-7e4d-48f9-c5c6-08dbf75ba6d3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: M2Lu/00cSJqZ+Ec3aOvWhYldQHSm8ALaJmqX6vMuZLVcPwUCRJ9LRtTLdYP5JR3vpPQPZ3mM0vygdUAIpigxXJOaNiEdeOxUI1XXAUNQBgqXFYe64X2Eciqo0hwkz7jeVKjeCADKWUDnmv+kzWxds5h4H5pzWQjcg60z9nrNhxHoe9Ixs+2c3gYWnWqI6fFFaJ8dIf1a1tMBT4cZqIKgQC3ntj+txXEdLCGncMVlz9rCnrdl8ScTIpyl30bjkMqEGGiBlDzHbMC6pG0DR9I+j8iDHb0kF3WWw7nRZ9n8g25jB54KOC/FPwjm+G3OmVlYjgoeqKh6YFKIQHOeMd+5Y2DeN7Cx8vh9oJXnd4a1YMq6jwS53WeUP5OJIICNOSZy6VM5iID1+nBw0GM3pa7qAyky96EKRW62KqwTz/SqyvyeaUCGUg4bpR86pVoW8qJFm3gHKEQLFBsJwP//5sRZDRddrA2MIbvivZH9WokUWoyL6rANGjIhQ1f7n0DHoUXv2+b2hN8Ro5jvC3kGec34FVVj3YRE12jQhcM5FQViO/pD+/z+DYVtF4Z8wElhKeZKP/mIe8ztpbclTHMMxOh64fMRU6qRpXbwWCUGB2QZPNt2sHRaSz/orLzvEjbwJP0X 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)(396003)(376002)(346002)(136003)(39860400002)(366004)(230922051799003)(186009)(64100799003)(451199024)(1800799012)(52116002)(6512007)(38100700002)(66556008)(66476007)(66946007)(316002)(6486002)(1076003)(2616005)(26005)(6506007)(83380400001)(478600001)(8936002)(8676002)(4326008)(2906002)(7416002)(5660300002)(86362001)(41300700001)(36756003)(38350700005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9NqNHcYKalIinhXkbXwKtDT54J8E021QQr6KOQ2Gcn1rB/DXPEXlxQ0p2URHqvFLjwH9ZIX7rgHyAKqIHsFkoW6FYE/fofxl5/b4Qd6tTkxTC+Bmp6TummVgIy2Zn9bl/iBf6qlZpsyjwz8qQrHmpPV0iAOjYJeJ6DyQ7FY9S8e1U0kFLH2ktyQbu5GWf0jpM0PSGmViYSA+ItrpmoSg2yHyznS0NnXSHv5LoGDQxM9H+oybFjlXSH9OpQQW/vipS4RuQ4mN5jvo3eNM4/aVFzAIzxlzz20w+jGM7SR6Kw7CKAMK5vSxFFKyPwutsbRQikYXKUVpb+HyoPoML8rotHlXUzgKmkny6/ZAFxsH3qOFjpg5dvM7tZbiBrbxQGC3qD+kgbXCZoiBCF1V7r0FFfyvJIG4RyMRD6K084eXYrhhj13L+68yphFKRks+n7z7CWGqkdce9IggwsVomCdVOTk4A7qrE9Z6GwpE+N8W7FuP3hGVrsQER3gnaNAnDcGuoz1fnLqpv13HU7/+xHiDlob5pxmdQjomtiOjgA91PgdpxPuZGgcxwJoTELHF2yc7ksR6C3mU3LFmA4xTbeZi+WzswpeElBuAKUFtij9ideGnmHhFFE0Zu7+/FmKI8Jiily27oPS52hy2gIxjRwzAZDvurIb8ynXf2JhLmivn8vXSQyn1SJWD1poUBhGKI75B0hC+E3hcNc3TlUzjixfmCJFus0TJ35onj9KSnF/MrNM6oGqS0zXSx4MDxkwd8448+hw31h8xuuOaJ11OIQpMWDjEmsnPjQc+oW9XTAi3jPeotnKehbDe6qtiIzYw0lNpNa47nffncF5iaT/bfZVpk/AsuuHAImqEjkQPLDOab+75XydqtB0G+q9bHw/wjYQryUi5caIIyyreS+GwX0+LMpzziobtFNUFVU/o9bz8UVbBN42dukyGblOkEM/q07u8FUb2nuR3Zn14I9Ms0b7PXzUunhG0TlKE7JeCQ7HYKk/PYl4jiEYhVAexuecYKFLnZEoGhoruyyqDJ1fmcKQPPSmHPNEw70UBOPZaloOwqxBe4KdpQah4PWdMFJvXv6MKKykfhFF3mYcdYjmhhXuWWerWB39Y7AjeGAI2AZNKGuFf9O6Ln2gkbR7EKotUhAeKXFhvWp6Lax+t9Px16sYjZD1BkqCv+C8JF798yTNMWCM7UhM2K2hAucgEwwXrZ0IEFHk7agr3h3m5ZNMG5rX1CKPgfdbfSZgiM776Y/PbeibosrULU28QMn9Wy7LWL/4nEIKvL7P+PyPIHrFJ/qqv1KZ88TypSbPRB9KypLiU1R8seMh2/moIW0UXrUrQElJuFuiS0VAdk0G658UQrpXaMGqvtD6+3L4lfWZXiobDGUYuSstlHC8lXisMbd+VoN47mAAgJUQGXbHb1xAD0O9tu9t4OYHDYfra8clRgKDIbDbcXiucllL84IRwRtukZuQmeaN9Zic4F9xa3orCvG2gKLJ1uPGpn2qz1XakykcUkUUbUx9Wh3ruwzbAHfTZWa5lkPsa4OIZfZS62HzqOh982NMBq6ekCqfKJMwpB0fnk4w= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3c17876a-7e4d-48f9-c5c6-08dbf75ba6d3 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2023 19:35:21.7608 (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: UM4+HVgzmFuCL3f5MMuLRVOgt+K3bxCArCXdSJ0AOtEaDiMBhAwBQgJAtqeVCzwPBaqHv6ot95uUhcdYWdZNSw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9635 Add drvdata::mode_off and drvdata::mode_mask to simple imx6_pcie_configure_type() logic. Signed-off-by: Frank Li --- Notes: Change from v1 to v2 - use ffs() to fixe build error. powerpc-linux-ld: drivers/pci/controller/dwc/pci-imx6.o: in function `imx6_pcie_host_init': >> pci-imx6.c:(.text.imx6_pcie_host_init+0x120): undefined reference to `__ffsdi2' drivers/pci/controller/dwc/pci-imx6.c | 60 ++++++++++++++++++--------- 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index 5bfb780e441fd..1fac6129eeb5f 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -69,6 +69,7 @@ enum imx6_pcie_variants { #define imx6_check_flag(pci, val) (pci->drvdata->flags & val) +#define IMX6_PCIE_MAX_INSTANCES 2 struct imx6_pcie_drvdata { enum imx6_pcie_variants variant; enum dw_pcie_device_mode mode; @@ -77,6 +78,8 @@ struct imx6_pcie_drvdata { const char *gpr; const u32 ltssm_off; const u32 ltssm_mask; + const u32 mode_off[IMX6_PCIE_MAX_INSTANCES]; + const u32 mode_mask[IMX6_PCIE_MAX_INSTANCES]; }; struct imx6_pcie { @@ -177,32 +180,25 @@ static unsigned int imx6_pcie_grp_offset(const struct imx6_pcie *imx6_pcie) static void imx6_pcie_configure_type(struct imx6_pcie *imx6_pcie) { - unsigned int mask, val, mode; + const struct imx6_pcie_drvdata *drvdata = imx6_pcie->drvdata; + unsigned int mask, val, mode, id; - if (imx6_pcie->drvdata->mode == DW_PCIE_EP_TYPE) + if (drvdata->mode == DW_PCIE_EP_TYPE) mode = PCI_EXP_TYPE_ENDPOINT; else mode = PCI_EXP_TYPE_ROOT_PORT; - switch (imx6_pcie->drvdata->variant) { - case IMX8MQ: - case IMX8MQ_EP: - if (imx6_pcie->controller_id == 1) { - mask = IMX8MQ_GPR12_PCIE2_CTRL_DEVICE_TYPE; - val = FIELD_PREP(IMX8MQ_GPR12_PCIE2_CTRL_DEVICE_TYPE, - mode); - } else { - mask = IMX6Q_GPR12_DEVICE_TYPE; - val = FIELD_PREP(IMX6Q_GPR12_DEVICE_TYPE, mode); - } - break; - default: - mask = IMX6Q_GPR12_DEVICE_TYPE; - val = FIELD_PREP(IMX6Q_GPR12_DEVICE_TYPE, mode); - break; - } + id = imx6_pcie->controller_id; + + /* If mode_mask[id] is zero, means each controller have its individual gpr */ + if (!drvdata->mode_mask[id]) + id = 0; + + mask = drvdata->mode_mask[id]; + /* FIELD_PREP mask have been constant */ + val = mode << (ffs(mask) - 1); - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, mask, val); + regmap_update_bits(imx6_pcie->iomuxc_gpr, drvdata->mode_off[id], mask, val); } static int pcie_phy_poll_ack(struct imx6_pcie *imx6_pcie, bool exp_val) @@ -1437,6 +1433,8 @@ static const struct imx6_pcie_drvdata drvdata[] = { .gpr = "fsl,imx6q-iomuxc-gpr", .ltssm_off = IOMUXC_GPR12, .ltssm_mask = IMX6Q_GPR12_PCIE_CTL_2, + .mode_off[0] = IOMUXC_GPR12, + .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, }, [IMX6SX] = { .variant = IMX6SX, @@ -1447,6 +1445,8 @@ static const struct imx6_pcie_drvdata drvdata[] = { .gpr = "fsl,imx6q-iomuxc-gpr", .ltssm_off = IOMUXC_GPR12, .ltssm_mask = IMX6Q_GPR12_PCIE_CTL_2, + .mode_off[0] = IOMUXC_GPR12, + .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, }, [IMX6QP] = { .variant = IMX6QP, @@ -1457,6 +1457,8 @@ static const struct imx6_pcie_drvdata drvdata[] = { .gpr = "fsl,imx6q-iomuxc-gpr", .ltssm_off = IOMUXC_GPR12, .ltssm_mask = IMX6Q_GPR12_PCIE_CTL_2, + .mode_off[0] = IOMUXC_GPR12, + .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, }, [IMX7D] = { .variant = IMX7D, @@ -1464,6 +1466,8 @@ static const struct imx6_pcie_drvdata drvdata[] = { IMX6_PCIE_FLAG_HAS_APP_RESET | IMX6_PCIE_FLAG_HAS_PHY_RESET, .gpr = "fsl,imx7d-iomuxc-gpr", + .mode_off[0] = IOMUXC_GPR12, + .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, }, [IMX8MQ] = { .variant = IMX8MQ, @@ -1471,6 +1475,10 @@ static const struct imx6_pcie_drvdata drvdata[] = { IMX6_PCIE_FLAG_HAS_APP_RESET | IMX6_PCIE_FLAG_HAS_PHY_RESET, .gpr = "fsl,imx8mq-iomuxc-gpr", + .mode_off[0] = IOMUXC_GPR12, + .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, + .mode_off[1] = IOMUXC_GPR12, + .mode_mask[1] = IMX8MQ_GPR12_PCIE2_CTRL_DEVICE_TYPE, }, [IMX8MM] = { .variant = IMX8MM, @@ -1479,6 +1487,8 @@ static const struct imx6_pcie_drvdata drvdata[] = { IMX6_PCIE_FLAG_HAS_PHY | IMX6_PCIE_FLAG_HAS_APP_RESET, .gpr = "fsl,imx8mm-iomuxc-gpr", + .mode_off[0] = IOMUXC_GPR12, + .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, }, [IMX8MP] = { .variant = IMX8MP, @@ -1487,6 +1497,8 @@ static const struct imx6_pcie_drvdata drvdata[] = { IMX6_PCIE_FLAG_HAS_PHY | IMX6_PCIE_FLAG_HAS_APP_RESET, .gpr = "fsl,imx8mp-iomuxc-gpr", + .mode_off[0] = IOMUXC_GPR12, + .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, }, [IMX8MQ_EP] = { .variant = IMX8MQ_EP, @@ -1495,6 +1507,10 @@ static const struct imx6_pcie_drvdata drvdata[] = { IMX6_PCIE_FLAG_HAS_PHY_RESET, .mode = DW_PCIE_EP_TYPE, .gpr = "fsl,imx8mq-iomuxc-gpr", + .mode_off[0] = IOMUXC_GPR12, + .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, + .mode_off[1] = IOMUXC_GPR12, + .mode_mask[1] = IMX8MQ_GPR12_PCIE2_CTRL_DEVICE_TYPE, }, [IMX8MM_EP] = { .variant = IMX8MM_EP, @@ -1502,12 +1518,16 @@ static const struct imx6_pcie_drvdata drvdata[] = { IMX6_PCIE_FLAG_HAS_PHY, .mode = DW_PCIE_EP_TYPE, .gpr = "fsl,imx8mm-iomuxc-gpr", + .mode_off[0] = IOMUXC_GPR12, + .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, }, [IMX8MP_EP] = { .variant = IMX8MP_EP, .flags = IMX6_PCIE_FLAG_HAS_CLK_AUX, .mode = DW_PCIE_EP_TYPE, .gpr = "fsl,imx8mp-iomuxc-gpr", + .mode_off[0] = IOMUXC_GPR12, + .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, }, }; From patchwork Thu Dec 7 19:34:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 751815 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="cbi2qICh" Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2070.outbound.protection.outlook.com [40.107.104.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36CAA10E3; Thu, 7 Dec 2023 11:35:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PWOVr4va6qS7LYlh5wEsyBG6d66GRfalTC+5Lw45SsGvI0lZFSJ2MASxVuZc0yEt1OJ6w7XmhMJtDYF0e7TpxFKAZImAovPw0gcNf1eFTOtDnhSZXyeLrM5Msz3e8Uw/xc7Uk/PIJ344Qr1WhjVidnECKV95t3IIsoa3HgQ0jBE4r46Fo/DisktgLXhm8t4DJpFEsOLn/cIigatOj/d2SgXwMAZ9MbuwR9uID/INfdheML4hKhtg8wvjZBpr/aOffvPYcRRL2Hjm938AkVxwLog5aqMJzsLK/boiL1vJ7VQtyFujHv3TACqUwG3yexRN599CrxsNT2ywvc6Il92SHQ== 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=USVYs4/Ey2cQMssv3OIw9XzOwZ9t3+TOU2azctiZStw=; b=V0icdqcyc5lJda3CAReNvNlTl7Se5jCH8KVOB7vppxHtpNdD9BVG2KyzeFi54fpoEi6b7O8nyS0t6yHRraqan7hHY3FLNVF/Hrnw8V2azmxp2b7hUhQE5UcbQdjR6Spqw/3VC5h30jVR52LAMKCb+qdHL8c4yo8Cjx9O0Oj/t3QD5ZWu60EleAkP/q3wnk6oGclrbeEv2biEji1vBmXHeb+qgCKaTauSua3MKGAz8Ap4F+x5p5SqDY+98Wiq19MG/JT7LTmN59q3tKpKuYWRGOXiR0us8+vahbSj4JzbA9OI+IMBvOT7aiVCMG8uwD0paLCRJj9kWoEWfcaArVcsKA== 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=USVYs4/Ey2cQMssv3OIw9XzOwZ9t3+TOU2azctiZStw=; b=cbi2qIChM268jZt3jKucaezhGh1X6Px8NaSLj8aYVgivT00sVqiVKgQuvoFZLLj94GIvQdkylqqh7TX1TfDGUde33JPfBb8zyJV9+7E2EZv923FUgHgPbq7+Rc+lezlV0LvH2I6i48xoYSiEuCH8/YrNFykgojVaHFYZZ4lf2no= 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 DU0PR04MB9635.eurprd04.prod.outlook.com (2603:10a6:10:31f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.27; Thu, 7 Dec 2023 19:35:27 +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.026; Thu, 7 Dec 2023 19:35:27 +0000 From: Frank Li To: helgaas@kernel.org, manivannan.sadhasivam@linaro.org Cc: Frank.li@nxp.com, bhelgaas@google.com, conor+dt@kernel.org, devicetree@vger.kernel.org, festevam@gmail.com, 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, robh@kernel.org, s.hauer@pengutronix.de, shawnguo@kernel.org Subject: [PATCH v2 7/9] PCI: imx6: Simplify switch-case logic by involve init_phy callback Date: Thu, 7 Dec 2023 14:34:28 -0500 Message-Id: <20231207193430.431994-8-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231207193430.431994-1-Frank.Li@nxp.com> References: <20231207193430.431994-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR03CA0348.namprd03.prod.outlook.com (2603:10b6:a03:39c::23) 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_|DU0PR04MB9635:EE_ X-MS-Office365-Filtering-Correlation-Id: 9d1c14e9-64be-4bba-d96d-08dbf75baa13 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gxe+qtRv+VTD04KI9BNPqC6Jxyte/IMN92kBNrk9wDk1hqRuc+E35DrQQfJ8HopZoG2JnsS1orJwOIBupQg39i8jqo+9DktWPGSi9ivmWu0TrxqME2MPptLJDglGiIl1+8oHGnqOsQmGyTz0U1406HLFbXv4R1iGpW0O+ejiUXc5QdXKj+sl73AtjiPSkRvnpkz4DbHemSVZf1RQ7ZnoG9AUllGyojGWCvjWyh48ftLB5D/U0STPoLHhQP1mQPxzfD8bvoxfKvc8ilTCg5XtfkZIIOcDG9gRQOdiHoDx7l5rd1MROYBeU0wDCzwYh4NKEbhyxsERm8lflC3yOTLlPt4pD85idlJE1Nc4SLLMfMfkOMuXNFys6tw3m4kHgh5+dfBa2yEfClxqVZYNnWJrfLiaG+v+573yzW7qLeJt9yI8e1330FBLYzZ6y6nqJkjVKPa1/qV+wwispBmoGyFqyAAbvX0YcZDhRCSW5Nqj6LqqDHO8CbyzqdSU+u8Qh59HkEBOK2HZDH64BVKjFEX3jTPpKvtWpY6zrngqmxxZEbyP14axMJ/eCCVpfyNOt9S2YbhXB+OHz5TCirouE3deAzhVCCmPXP+aOWiUhjSzF8xd5zfzGfot0cverXj66q/c1aK2QiRrYOI9XkTEeoGpIAeK6ZzUaDzG2Of6KpBE9k0= 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)(396003)(376002)(346002)(136003)(39860400002)(366004)(230922051799003)(230273577357003)(230173577357003)(186009)(64100799003)(451199024)(1800799012)(52116002)(6512007)(38100700002)(66556008)(66476007)(66946007)(316002)(6486002)(1076003)(2616005)(26005)(6506007)(83380400001)(478600001)(8936002)(8676002)(4326008)(2906002)(7416002)(5660300002)(86362001)(41300700001)(36756003)(38350700005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CxRucTMphaivV0vTLUklXABOTfBmr7aY5SmVBTEt/DV0b36ZMzwUXK7MOWWp9jFIv6b3WaYpZm0p3TUgx5xSY3liZMi+brFJVC62qbbZbEY3qZw1S6ZdVuemcxUTnpwe6fjCwUpD0PsKf9J2vsZn2yXr1Ta4GQZyKy2N3Gr89tvqeM60EadHlqf6/7TBms/nKKdCd0tgz5BNevGNmPeVW+/roj0R/fjs7szUSsP/YOmXIzkCE3gKtdgPS7hI8Ci26jmPs+vpnebw3bWL8G+Ct5+gJhZtUZyViqfpXMc5Gaej3Rlh76Odvsq4s8kLZu7EB/vxn/xDur1pCFJZCIZVRbUvYhQtOcZw5vYxCJKz8AtgfzkcqXndw98+4AY0ZFtJO5iB66abi5RKQMrnXxdYFcIvxe2weWemDPegQ3PfP9Yz19ch65/pDqepdo56cz/mQ+VdM3Ecfenwku+TVsg9IErCSLNyCbmIIMrvLT9ESHYotvyDZYTWNYxNpiiZqT392twox65hMxXGeNXbwZnL5ALdz80uX5cf4H2Rk/dBUpFZIHhh6RwPGn3Fmg2Y961lYttMv9upM8bofk5QZ3RMPMw6DF0qyZ0uOKwl6mvDIqjORk+xYT3Xx4kocUgHzamUQHWWUh/UYSyR3h+d9UX0xMCL+QYpmu4UdqfhiEdHZKfvA9ZDgQ9TmpgOXPvvgaeq7K/c8PZ01cq+NJ6GGd8SV+/mxDBvcixhsgdHFm3ByAUOCfs2pbAdJTHnZF+vHBy8ve++/9+lUZALl0d7RbOZLZlVeeWNOv01lKpJ9SPkO0Djx9iMXPXQerzNbXJNlaRhVX5L6hn17/hU8b56XgRvglkMQB7GxOyLIlcabvxbeShBCkCs0GqS4bBUFG3LsXv5VchNmfOdWSBOaDy2HRN1nbx5EIOh1g9aMmx2B71851zwq/40kJAAO6/VRGFuOU+W3qcVgB/4UE4IWaHbE++x4QM7ISIXPb/MyXEsfgA/dlZFcHV7dfyCGoKUVJlGZu+/LGH5sEyltQww/grAKDBccVFlwYu6ad3FWLEx3rMTVbK57Oe/8kjKwty4YOSr/cuksuvy/Z1LWpAcfkycU8qTGMzJ1ZRNz5Iz+F9RLeAfjAVx7JesRWL1xVilYnLUrwUpYphtOUJA6j/Zr/4h+6OO2OI4wJFiC8GoF+cuCqTla3zn0isNqMf2NGFkNT4jSBEBhElfgxxsDL6+YSkVFgTskxhQbIETyIbjIp3I8hsHZN4BMCC0sXDsoHnAP5ZEch/8oPpn1iKVCuADOVDgkZ7nggHVJ/bXubmLXN8FTNgD2QWQCwd5L/k6rVrCVgmKVEsDg/5C89lvNNxgbfvKWdhdbd85e9Kd5kx7cw/PJarNmHyXLdT+g3KsU08H0LX1YGmCXM98S7N5qhbeXB09vZKJrGOQlwLdVvIDrJdFwmeTfVYVsJVC7b+dj2ND0P2HTw3YlD9ONluXRdU7ImAiyKTuYtqtlltrTAHVVBtIds3EueEJMYehYylTLRC0ClA79pw7wNGx79gIooOUkqkAxqLLZTWgSX4jEwnNcymavzWN634= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9d1c14e9-64be-4bba-d96d-08dbf75baa13 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2023 19:35:27.3368 (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: HpBJmowdDDX3bfX4znCmkrvc5/fiuoUU930qgcfV58JWzdp141hFhygdn2HRRnS/ayLqEnr+hD4lCHKFD/kUpg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9635 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 1fac6129eeb5f..4e55b629d4efb 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) @@ -939,7 +936,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) { @@ -1435,6 +1436,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, @@ -1447,6 +1449,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, @@ -1459,6 +1462,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, @@ -1468,6 +1472,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, @@ -1479,6 +1484,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, @@ -1511,6 +1517,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 Thu Dec 7 19:34:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 751218 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="ZTnXADX/" Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2054.outbound.protection.outlook.com [40.107.104.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1135D10E3; Thu, 7 Dec 2023 11:35:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bca5vfpsY0vogu10hNFyuK20NNLIzDZWlDbU/VsTtCNnBhRABeeUUJfZoBoMQcMzxDi3LrcnQ0ebTfwl+K8D/scniEZsmAWP6lnrsHYWrj5TO3DEajAew8SwyQagam87PEgLVOzjVQ6Cco9CdehSRI1V7VNjdC9xChFsOj2R5sfXo9ivQ/wbkFshDYWXWM4Dt9OSusT8oHHsHmkojdtWyaLPMez+/q4Oj5MCREF1FoaVf9p7Ckh6RNZeM9sNsp8HpqDO8sKoMzw4YKR2UWe9dNaAjzWuYTEo2sbLc2Sqp5eAoi9qv9wZa9NNHnUAR4qiizhNx6BJYCg9Q6LOk219Rg== 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=ISoeuM5qc9C6CwkUoT+MeGLOPLvC3YYCBpts0PS+AF0=; b=gvA/oL9Jm/nNAQhP44wAfX5OId0sUWj/VkSdkcRj8/49kzLnwlsIV/2vXiiWdbAKghNMAZb1XzqlMySdNFQAlB1BUzB4iedBfo4R6idbsEb6eu86ZeCAWlKx3D/TR4OsfhMpQWRY/D+tVcsq9cfjVZmaKd2aWVenPWCIw73lkA8CRQZCrvV7Nz2AOw8liLc3tCGdq7fy1mip/KdjwRM1YwXaV4yNR10eeoXhNoU9aDjnIv0cWs3Ofs8E+GGNzsJ5dKvOIMbw1xO/sRa9BYwUjqIvl84JX01UEhovmI7trB0zLBbGbkO77S77VBRiJFhDTh9OsCQYpkuVCxsitqW/Vg== 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=ISoeuM5qc9C6CwkUoT+MeGLOPLvC3YYCBpts0PS+AF0=; b=ZTnXADX/DrHcXkCMZUqLC5HuvcfMFHfweBxfRk43g99y0s3I/OiXL+z/2njdeFOfEupOibG+SKenovsyOFnWozfhTLKGsR6WmBX6Nsk8hqhKUXgZoTqFEn2UN4wD32iBMsocH2reW1ZJa7EV/5Ncc0Y9Xyhh0biDaXyzMoJtWNg= 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 DU0PR04MB9635.eurprd04.prod.outlook.com (2603:10a6:10:31f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.27; Thu, 7 Dec 2023 19:35:33 +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.026; Thu, 7 Dec 2023 19:35:33 +0000 From: Frank Li To: helgaas@kernel.org, manivannan.sadhasivam@linaro.org Cc: Frank.li@nxp.com, bhelgaas@google.com, conor+dt@kernel.org, devicetree@vger.kernel.org, festevam@gmail.com, 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, robh@kernel.org, s.hauer@pengutronix.de, shawnguo@kernel.org Subject: [PATCH v2 8/9] dt-bindings: imx6q-pcie: Add imx95 pcie compatible string Date: Thu, 7 Dec 2023 14:34:29 -0500 Message-Id: <20231207193430.431994-9-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231207193430.431994-1-Frank.Li@nxp.com> References: <20231207193430.431994-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR03CA0348.namprd03.prod.outlook.com (2603:10b6:a03:39c::23) 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_|DU0PR04MB9635:EE_ X-MS-Office365-Filtering-Correlation-Id: 384ca9bc-840f-4028-3b60-08dbf75bad62 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /uv7rhXhyXYwgxiEd5QejdvrWjJXK8K0rirFRHzYr8Zibk9tQh37hbOQkY1hktPwvxHd8tObDZJz6WQA872EI4AKNotXPJNQniXDRXXSfRCeEkXsaD+w3QnXvrD4QvZeeIyCiJdYMPD8Au7cKdgTgpbqYerZW9ufGh7fjYOjoTmRzFR9FaAJsgIC9DVv33NoCvlsKxmLJ/ZhCYGcFKc22nQ1vaf2E3uGS2xjlTVZT4RheeEKk7irQBGvP3TQTebdXKskqDR+uTQ2BxIeSezdQ/JNWXiwnkyK9jp8vWbX4rtkh/8vjAttOMumkzwQUPKS+C2oX3NwFGdUfH+9U1IncPKiPVD2ZKD9NwO29wuDkW1umVXNe06y++OnJhgmpxZ/r3NMZoE6iyEC6esS6CHgixx5Z3/6grCEK/MrhiLHglxkrpaRH3k2xNHGX1gtmzqs3IECL1WwcLD4KOYlMHxLwUu2eHpbGVDbCihe4XStmFYcNiWSRLJMn2WAKXiNCO1LHDRQchWLj7VTXKFxTe8Va4o9axGpadmusnJBOwE4zVR41jZGv9jGhNU0Bn3TWWMudkqkjOsucfmn2qK9twiUq83fSl5MSC76Ijd3R1YlTbsgXvdhdGU4x9Mjf5iFDPF2M+ANZrxNo5Ejy5mAre3faw== 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)(396003)(376002)(346002)(136003)(39860400002)(366004)(230922051799003)(186009)(64100799003)(451199024)(1800799012)(52116002)(6512007)(38100700002)(66556008)(66476007)(66946007)(316002)(6666004)(6486002)(1076003)(2616005)(26005)(6506007)(478600001)(8936002)(8676002)(4326008)(4744005)(2906002)(7416002)(5660300002)(86362001)(41300700001)(36756003)(38350700005)(32563001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: v2xmZDUcgMaKTpXh0S1H7Ly9kY2lkCHNQ2Vw9IfNQGUogLRV/Jqf8GqULIpsNyLynd2YS0C7zKgPV2R/ruN5hwd3eigVxeMxl7AtlikY0IKg7cljfSI9xl1grnWkjigZ/tdZPAqN7E4/Sr0Jy9h7kwrnb79JMbTqODyu4z0Kq9V7CTiR1H4COiCbMEoV/Q98Kh1ZVvmJK6XuBExBT7RaRVPf3J8qT4OC27kpGVlmtYy3NLNYtTNGqUiphBcmgfmGKefD0DxRbeaCDrgD/Q8VAa/lT69CrT4735zgbFQnjkafu19zusqbSWJeju2dU/cdpBKcnloevzvZ8WODxiX2pYOKXucWsZro+DDm7Q7NKJ300uLaDO5cw9rPgZ0T4f765zWHNXDEWwue+Vo0RDWwKoCuQ19uy9xa3ETgJEIzIjT0PYwO3YbbJIS7DepXxrqgVHdq55gnMPVeVri8tFkT1fmIq2SPNCUOe7m7lMUms5s+cdoPFZ1k9Nlsf/3dCIA4YxxeuPAsnWd+1I/ptISdxy5/GwJ6T4e5Gx3kKNLRxkALuzJo6zWxUQPETX5G8reJknQ8aW1aKxP4nILYi9/JDu4hgBtDjpb88/R++HB12hkyZrsCu0T4/g+X+/WeEa0IpzY1WYFosp9iqmhf7/vR80Y4KiOjMmJiY+fejNdKzkkzlNKm90BD9/SLQDHNVJQugDpwVOfw0SdoQF+DV1OPgMRa2V32H3w8NWqCyL2nGMG+bcoR2lGwhnEzWzNpiDJPWpI9hbftEuD4ij8GOFTuUB8AkK8xeU35xWqLe2hHf6HAbRk4ZIkoBhkjDkCa2vCFPQLqTd4ymrfUDOfzBmxLQjf2DpdXqAZLSa+vkDbdf48HENfMmt2zRlbIM7eJoi8+5msubKb87+S9c0KWhK3O3Xk/Ss5pp8UDZvxxSw2Ha2DWRa9au6Ndk96pnDKB/1p8gZsxKuRYW6NePjj7ylLjU2/byacEu5msnLbEStkDsgX63wzEmo1MHjKsd2FfeXHGOem/Mf1MWJ6IXjc9WK8lz7m8rglj52PBKZnxqW9Ntb6bXJrZd5mnWG6np+8D/bXBoEoxokWwaWL1ACGqWRV3iT3T8pSjBAOw80xs8v8U58wjDHp26SfuqFT01p9vuxZT7/xvNBJLBRL9wjqdTb58FpfUn6kriEr2cCdj+TaS0XVJF05EQnsLuP4jDIDT23HOjCYtyyWNizkG/HVa5A3D12PCD6Evxb2bIfjgiLT4cweJapOnp1Ydj9Ka7Mn7TsrEe00EFwlCvigdlZJEg9N+Ltn3Y4jEb/oV2jROt3Ei8uQhvuRnv5b7luXFMS123xmnYjG2eoTOl028pFMiZtyrnXZcc/neioy9Fg8zxh/nVLY/4othyCwEbxvEB6uLNAoz33Ho/1yhLe9ymwwHPTmP/8ZhRxA0H1TDNmcGpv/PPhWL6g2Rvaboq2JKyN/2l5QWj6CfvYzXJ/c1IYH8cyougfXSReGhDhvTaFM4OaZfYkxuCW10EojJBS5j5Z5yYDhnbp7g8GpuesZ5wJ3HJ8lvn23Y+bFrs+Hlg5rF+dtt43Y= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 384ca9bc-840f-4028-3b60-08dbf75bad62 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2023 19:35:32.9215 (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: ZCSpRMYOmxiciyYwFgHVFvg9tUs9P3kCy+ldi9cnMTqofbljQT3m1m+gz6s5l47XMfpBv6YtOrrHGSyrNF5dtw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9635 From: Richard Zhu Add i.MX95 PCIe "fsl,imx95-pcie" compatible string. Acked-by: Krzysztof Kozlowski Signed-off-by: Richard Zhu --- Notes: Change from v1 to v2 - add Krzy's ACK tag Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.yaml b/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.yaml index 81bbb8728f0f9..7233357678431 100644 --- a/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.yaml +++ b/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.yaml @@ -29,6 +29,7 @@ properties: - fsl,imx8mq-pcie - fsl,imx8mm-pcie - fsl,imx8mp-pcie + - fsl,imx95-pcie reg: items: From patchwork Thu Dec 7 19:34:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 751814 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="m3ApS3NN" Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2052.outbound.protection.outlook.com [40.107.104.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 048E310E3; Thu, 7 Dec 2023 11:35:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gZ5xrWo8Ziy4xNaBrJ0WMycyKU8P2pshvJHTX7fUzxT0TOBNmkarZrcx/PE1GlVn0F1K5Zb/SjZH44sqeUapc73ED4veOHjI8e6Cbluv0TjlMijbi/wruzG8lKahV4U1q583jFU6SZnPaGjJpinFq4+teR3WaWIZ52qXIo0tJs6/RdVgntyvuAXdNTxsXttXAq4r4OTELbuekwM/kjFYZvuPQQwPRp1iKU6McdjTmc5hYkVe2SqIYpAnJWYJv7Y3VDFGNNgdqnaWxNNB/itH96VERYvQEd9NmmQFcFvKQek1Ok7uwRMJulThAEcCvsukEP+8fxO0QIylYtHMX49Tfw== 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=3w0xFwXv5Kh/M+ZbnE7nYkzJC8jEbr5oxENekrjRIHA=; b=AcdMDOChK3AIFAUm6uNnLNcHsnhqnyOz0DNEN20CWg9i46i2s0O++8Saquof7svvscHKkfYViGnnsfpUHT8JG9J190A+Hwj/6YpBf8rZfVOLLkG1M8Pd6ilp3eTVf6XOG82ConHpcR8a7Qc5LAkHb2Vp8rR4CbxRNBzduMieZ/sE9ML5zIVLfAt2JuxABHwDGeY/fNUvcZic+QgyQmFY34wVsXi+3sMSmyI9Y7QGm/PUfCSFDZgHg7ROkgwtpF6mwiEimYI4ZcaxdpbP8lJfFh0hSAkRetPJbPhy4uPswi3jDM3XinpSvDK5VDOjMdQFDHC/sYP3SEnCXLdDOUnM1Q== 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=3w0xFwXv5Kh/M+ZbnE7nYkzJC8jEbr5oxENekrjRIHA=; b=m3ApS3NNardYmknrQ4IOwolU9SOtgC5Da7CyRrSGVZ4BFP3jZaYtnIX+X0EtULzvTdl9KN3Sio4y77ECccQpgXKfGnLugfNhy/ez1T0n6gQIQI+s2vbaWfpZVA+HcX3dlpSbADm91qa7X/uRTjZZXitNYE/vQcPdPXa67PfsULo= 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 DU0PR04MB9635.eurprd04.prod.outlook.com (2603:10a6:10:31f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.27; Thu, 7 Dec 2023 19:35: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.026; Thu, 7 Dec 2023 19:35:38 +0000 From: Frank Li To: helgaas@kernel.org, manivannan.sadhasivam@linaro.org Cc: Frank.li@nxp.com, bhelgaas@google.com, conor+dt@kernel.org, devicetree@vger.kernel.org, festevam@gmail.com, 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, robh@kernel.org, s.hauer@pengutronix.de, shawnguo@kernel.org Subject: [PATCH v2 9/9] PCI: imx6: Add iMX95 PCIe support Date: Thu, 7 Dec 2023 14:34:30 -0500 Message-Id: <20231207193430.431994-10-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231207193430.431994-1-Frank.Li@nxp.com> References: <20231207193430.431994-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR03CA0348.namprd03.prod.outlook.com (2603:10b6:a03:39c::23) 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_|DU0PR04MB9635:EE_ X-MS-Office365-Filtering-Correlation-Id: a3f11c98-16a9-403a-c433-08dbf75bb0b7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BQ4kC5XRf/tJUL/+BnsGdBmRU6jtePjV6SLzHm+iTl4bibz7C8cgfawxYMuV+3EOzR+kcdqtZTs5Qv87zdXzwEI1N4OsOj1UG24m7I3XhNvSCk02r8HSZPW2EMepFZelxWK9ipaJGqPhbhJ+6NZoO19hFQZA79JW9UaDA5hTP9CuYVSxP2804jrTChY7tfF7zmj9Vsg9vjDyWgHx/gNo4rxJRvN2Yp+ZUJw3cZhypdqGyGxf7GuchkPHKF9KCerN3MGOV2wu0mDZ7tQiiWxh0BAo0XS3XEmunsyhJVF9w/7MM7ERzPrSi/EdH4rzEVxlMI7D1uPAZCqHwYVT/JqakdplbwILkGE1fC8m7WZQ9DKA0Pj+Gk97oG6YYljC2CsqoKRc2ID0vbVM3zI4vGt0wboIvBfgVSu5tlmI+X+1fyUDSd9uGPtYowDhqGFkT+tLJ2p/i43UcHju5RADMCF7JBk2ofr7PF9hlldIWfBbdaVX1F9Nurq/BHf3gFf0fTkTfoCzvEdNpZkihDbicrPnOtd8rWJVfe+nb5VRI87Pt6yLVg1d0jD6yfy0uv9YA0Dux6wrsHR+gmnATtqXc9ZJ6v9FJ32TmYZLMUHa57MgPygDdDgPJU4tkJGSUtNc0oRp 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)(396003)(376002)(346002)(136003)(39860400002)(366004)(230922051799003)(186009)(64100799003)(451199024)(1800799012)(52116002)(6512007)(38100700002)(66556008)(66476007)(66946007)(316002)(6666004)(6486002)(1076003)(2616005)(26005)(6506007)(83380400001)(478600001)(8936002)(8676002)(4326008)(2906002)(7416002)(5660300002)(86362001)(41300700001)(36756003)(38350700005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Z50KeWAXX/MnVvabhbxc5DVaxEqUz3qtC4xNu8CnpxSvRx/Jzk7N4lbZP7DAbzpesEHfz31Z8HvqFT2BCKaJmnZ01DeSTNLOYozRCqV4XnL9FwAfPpTo6kbbe9fBElqbyqmtI7I9qBV8WLNdHe4LIe55TctajxVa0OBN6+++24HSSO8fWvazhDVEtm1VJiyIULaIiWIK9jm+nYFXSBtBT99PZKylb/SA65FhJk96EC4VtgL4kVVuIn/ZmqzTPCvVIqVG38k3hscFw6RRr6Ni99/nHU1WXs2o+m6kyp5HJbmeqP5VQtwmNTI0+kXWbt5MsPBkAan8iXRM67pnqO5C3vuxi/gE/AEtSY8jbBvEVHcxY8FVHUX/p/CcdzUbVM5cXjXLm19IwNtEjc9lCvPnmz/+FZVHDo8lDfGL2Lnq5LyutDmWI8NsCqt+XH3zsGlWNCSpiI2uXTBCDmK0EKNRoLSb9bY8fT6I6MP1+jYj85Ji1+e0RGWub+NbCvHZ18515TJouiV+LrBIkQ3E5QfgrcX8SzH5mC5jRTQUw++RCKtcBnKtxOyPJP93szJXkgb/3TDCSqX5C4/y1JaC9O6DqR84+AzMF4waoaRMIZ3uENN3qRiK8ojRda1/RWvTJKcnB0BhoPmMn+mBbajE865edOGzCiCVIZROJ02S+NyWZry8hSetroIAbNno9kEnizU4ftUXsPpXWHRpJCzy+EM21xmmGLCN3/M2yS6McOD7rlU/0l4qlZs14bvHyxsqYrAKfAE29TRgxxNpR1PLzXHIrH5PgCcjdSQl+9jSCk/rNKkiFv/2mFgBOYoYwMcaBcrLxFt9NNMhU7Pf2klsDOv7RPr5MZASMT88k2dlPX4m/3oVDnuResQcM9SvWvS9xfT07WyzeFS9BXW0qQlhaRmeYGoPsPhB0Fy6180PZjv+z3subwHUq5CLumySMjszAz0IRpxSJ7hop9p5rbtW/AVsKL+IVaAoZNRlDzTIVIBMc+XXNph6qlG6fsJ1ARW26bi6Ku6OT2gjYRk8Wn8ow6xoLbenx2acBS2+yi84S6fVA3cZSz5Nl8XOO6vVoJtYjbJNetbKdRMpduZdUL9FjNBcr+D263pRP/kEkk4MJfR1uEUZTfjis0fTtaOowNahOHm53al9WxepFDhloBMrI0pKFi0H84bQ9ruMsjrkGFWuBVfKGp7qHmGuL2Y7Ug9qMnykjAOLyAqkH3nGoSSrF6wougGD1d8NjA59zwv6ahJLl2VtsSOh8PDJimS0iLjHG5ZkiPZxp2ttqJz++TZBkfaidOnLSfYgK+26nETwex3UcTTYXn6+OFW8k0JxCSGcDGytZPjI4p5vdHkLOTHIruYRTXJfc8exZhyv/3DERXaaQSx9zxRXbnR4yKJu1E/9LQawKDQOBgOZ17V0u5ATFhmgTM+wUxOyzahku7802zWCMjW73Qw60HlHv/fdzPACrIKECPWq72nbAnYdqvwbl45aXBLqLyajB4fv+IrMgaQVzGieDs5avDAg1iRnkXxuhuR5GOGNGl0hZ45F6NjqVMdf6YCUmCJLCZd9mJaLe+JWIBA= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a3f11c98-16a9-403a-c433-08dbf75bb0b7 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2023 19:35:38.4565 (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: CWW7inJO+s28Ekan1E1hmJC5o5WqSKgJpBB7OVUerhTSih3hGUJAi/HWTVm248thmAdOUCceGGCPt6bUKIm5sQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9635 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 4e55b629d4efb..670d8d410febf 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: @@ -732,10 +772,19 @@ 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; 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 @@ -1343,12 +1392,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 */ @@ -1506,6 +1570,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 | @@ -1546,6 +1620,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], },