From patchwork Mon Dec 11 21:58: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: 752652 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="Lv9zjOsI" Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2048.outbound.protection.outlook.com [40.107.249.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B50F5A1; Mon, 11 Dec 2023 13:59:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ewdttP33gEaLJkkGpEs30YRT+eLecclyVOVhLi8xvOk9SNUIJ7eGhf5USfNHpJH+khakobXN+R1By57cezvE4z2WAImaATt/BQNk6nHk0ix7NGEr71VZfCikyLHoIYiJSNcsrhdWkuFSnrZylMafBZUfKqPLdwsufGKp6axn6IG0uBxonHQXlACAROluATAAbtCb8tePyF+X3PU7BLUWRjYRXEB0xVDM1QWOKlmTxT4KpIwANUjbNlgshcq9Q1/Bj6B94U/8T19u8SlDik+L+3p2sW3fd9mK02EvITbmczmcUY7dKEedvIITBrytCTI/WI2PVcVROm7hD89WwoiXAg== 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=TbBDDahxSHbHCrG7mS9eltoOKUQdf1aRukZRyyGFXdY=; b=AGJNwn8NSUvpSqTzP80/8mXNMHmVgOTNhXfuJamrh6a0718f1d0DY/nSK7ykIaQ3juRmIVzGrrl6JNpITIwmz6jNvj3AYT8Y6ZCPvbTsnmjPVV/VxV4R0op/pwmviAEPgbDdKjxXEYJRuCBziP2m5afeqod9Ih5AN1N5sXGgqcrNqnFPUR4+URzdRjeyIYzbNxlHGYmAa7uBixncyf2yArGpJ5/asGVn5q6N+4cytucv6WdQgxDb6zktwL6KCg1d4gRZ5eJhMCkwUi6fdhfvOB5AyAjS9e++FUqeuwFOEVjTU+lLOGfXYdUZTkb8cptFU8iqE90xVPnCweLXIIm6xw== 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=TbBDDahxSHbHCrG7mS9eltoOKUQdf1aRukZRyyGFXdY=; b=Lv9zjOsIyayVtWYKTIBW4eeJTkICTs0ITa6b4F7KN6QHBgl5WRcNWje1CK3d5mRNYI6LAt+or56nVEbjXkYzpBKXkz47JHbpQyi99vF5QSJzdTi2b3bxnaxDeKHRwbBmZcauGD5AJ7lJWFAPBwbhGu0j9Zlf//w+qAwhJfsitss= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB4845.eurprd04.prod.outlook.com (2603:10a6:803:51::30) by AM9PR04MB7569.eurprd04.prod.outlook.com (2603:10a6:20b:2d8::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.33; Mon, 11 Dec 2023 21:59:26 +0000 Received: from VI1PR04MB4845.eurprd04.prod.outlook.com ([fe80::dfaa:e869:45eb:76e5]) by VI1PR04MB4845.eurprd04.prod.outlook.com ([fe80::dfaa:e869:45eb:76e5%6]) with mapi id 15.20.7068.031; Mon, 11 Dec 2023 21:59:26 +0000 From: Frank Li To: frank.li@nxp.com Cc: bhelgaas@google.com, conor+dt@kernel.org, devicetree@vger.kernel.org, festevam@gmail.com, helgaas@kernel.org, hongxing.zhu@nxp.com, imx@lists.linux.dev, kernel@pengutronix.de, krzysztof.kozlowski+dt@linaro.org, kw@linux.com, l.stach@pengutronix.de, linux-arm-kernel@lists.infradead.org, linux-imx@nxp.com, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, lpieralisi@kernel.org, manivannan.sadhasivam@linaro.org, robh@kernel.org, s.hauer@pengutronix.de, shawnguo@kernel.org Subject: [PATCH v3 01/13] PCI: imx6: Simplify clock handling by using HAS_CLK_* bitmask Date: Mon, 11 Dec 2023 16:58:30 -0500 Message-Id: <20231211215842.134823-2-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231211215842.134823-1-Frank.Li@nxp.com> References: <20231211215842.134823-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR03CA0009.namprd03.prod.outlook.com (2603:10b6:a03:33a::14) To VI1PR04MB4845.eurprd04.prod.outlook.com (2603:10a6:803:51::30) 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: VI1PR04MB4845:EE_|AM9PR04MB7569:EE_ X-MS-Office365-Filtering-Correlation-Id: 2adae40c-1c7c-4529-64a0-08dbfa946fda X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oKAhGCcrRZwGo1uSBFrZ3mu6KMI6St9rxhQ96yI1jEipc8nLz2BiK+H472reOmDlDAQoOOaG7Hyv3jFiUBxTpV7l6SLkFwE/2GcpjTzBlniNJaah75kdXhknmB7ntnUbhPvrSBkh/WWaIxqKpEWWPuPGR6BDCiL4m3F2prHVD5KG9LPUkndm7yZEJ2F66spAKDFJDyf+A1hdvkyh2TsfkSLg+S/jBhX0MwxpYOOSiEgY3KScTwYR+oQvWRgiuROTltkBO03NW0qMcEgjz96A7UiWZMzN4uT0xB61STp8kHJPTRW1MrPiQfor1pvCHr1+5xwS+T1Vffx1nWJlSx5RkgLOQYiWd+w5IBOsY0okG2XSTwjkDPPE2ablhbvAIvUUi5i4EhkE618aVvWPuFiFp3/a8XkpaETeQbnm4eY6CSIOFvPccO6NQpo2aqWsmU6n4ebV8vIroPgqEufPgnwShqaz/UwgMKLlTJQO4uVxcTzUne99gFAfa1aZs5eMCXQzqMMiMZIIGOzf8zniro4FpyKT4JUAzFBOi43/4rKFN/weOwLnpVZOFlVhkdO1qiRiahWRmAl9SfYCVbXaHpK9jda6xSnNoXVtD3WdFHc+RdAmCisWAjbfw5fjc2lY6nNI X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB4845.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(39860400002)(136003)(396003)(346002)(366004)(376002)(230922051799003)(451199024)(1800799012)(186009)(64100799003)(1076003)(26005)(2616005)(6666004)(6506007)(6512007)(52116002)(83380400001)(5660300002)(7416002)(41300700001)(2906002)(478600001)(6486002)(8676002)(8936002)(4326008)(66946007)(66556008)(316002)(34206002)(37006003)(66476007)(86362001)(38100700002)(36756003)(38350700005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Fz4ObZDupr6bmWGs3vQGzDTdcfkQ1sI/ATHShFPUe02Xll3uYg/KYa43qH0kqQjcvLeDdVUx2dPARPzpLxMQUSi46freAhFy04stQdnX7kAUpHJR3s4LlUye96YvzdL7LSPGBfblF3glNBeg/U4kV0ftsErbU/PSTZybmWH31e1dYz8+qiNDw/qWPynTDVubiYsaSD5ciLs/SD3ACeO/MMZZXOHaWluvd9rKlsCLYMj64J1Y0THnvHBSnvx/nk07xa8vVvj8437NS2URNZJj2d0NO0nMXWnfhDZzLZF2usI05Vs3xfP+8LQRJp7ROPN7fZVC9wBeRJx1wI6QbIY5n3VBzNKaXvPp7wVkq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IfDlj7HfgSjJEXs0CbYqLcgfs2U0kx0WFyF5nuwsHImAVXkbXX5cZb9G2uFgN5w541JUsFLVmyuYrsYBmOhPgilhEuXZoz0/i7cR6rLsaziuOgr5gFOtnZa6VsZwIiS+oOt0hX+6k9rqFrzvBUHB5+3uxZEs11z1NpP2MUP X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2adae40c-1c7c-4529-64a0-08dbfa946fda X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB4845.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2023 21:59:24.4624 (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: esMg3kXDvfd2onBLRwOYFSn2ukRUvV+yYD9g0JVyQr1no4AjX9h9H3liRjnir9rHy3VXTxxPpQhHpOMVfSdxAg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB7569 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 --- Notes: Change from v1 to v3 - none 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 Mon Dec 11 21:58:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 752651 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="qet+IkKp" Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2045.outbound.protection.outlook.com [40.107.241.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E24AC2; Mon, 11 Dec 2023 13:59:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N3aP4biEmiocpwBECS6qLhw4oM0QYWvpFaQehcEtMubhbSTxy6SAEpdDALOk7zI3tA1IZtRPrAAYbiYxjAZCXWEGsS/hW7xZp1kj9s9xVofYSEnnqJ5udiRyyn5WsbnRHmQS1xyxbMF/1ZKLHiOy5fH/M6fPvKzS1sVbliEes0lCvUhNV26pXqDqY87adIwDLNQtUAk2r5ZOzDWA6/iFdfuDlLtSGmy9zuTAcntCN5LfzNAdnEZeH2rO+YUJO45AAEOZnYStyqEHonzAVt5dtpAv/5UKSdJbLUAmc5zFbkDOd3UDlxMETnNMuU5gGCcUP90KNAsJEfqfXFQo/eoSQQ== 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=a0wXuwG17CvtxjA4Vranekpk03tGXICeznPAWJhaCsk=; b=fwN17qL2W07QiqMtBPgDhhZGo2MtsH5QumqwX/3CNYtBls3bUhS/cCo3gt9KdjI2oY/Hwu85pHLGTxiUXzlUGDa/gWQhkKLlwK8v0dLf8PbWGWIg8KFkCdkqkmgO4/RcFC8svJqgU8fC8s4EDea/9getf4oZjzPm/uyStfUZk0zxe63P/n+Wt2Upd1a36pUJscggohBsW9cTiSMDPRR0BrAswkcn6o4Y4+doyMn23eW015jV+WSgKdSiGVHGx0WgGDJbqP+vLhyjklkKnQEam7O329Z3QsClTj1Ij8zxZ5xF5xtEeY6TSRuBMVRsgmkDAerGeUCV7ogDpMTzp0ajGg== 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=a0wXuwG17CvtxjA4Vranekpk03tGXICeznPAWJhaCsk=; b=qet+IkKpBd0cXFn7QlyFnO02MexIPw9cjeKzvPfyzHmEtZhiwrdQpvLh/f1R5DG3DoCNHZ8Bhq2mI9w76C/8rDlho/63pH+eYseI1siySPZ+r9cuG//LtTPMxnH8Ke77NDPO5+I68SqtYWYLsNEEqvOWuNhNp9Mp9oe9tbn2Om0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB4845.eurprd04.prod.outlook.com (2603:10a6:803:51::30) by AM9PR04MB7569.eurprd04.prod.outlook.com (2603:10a6:20b:2d8::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.33; Mon, 11 Dec 2023 21:59:35 +0000 Received: from VI1PR04MB4845.eurprd04.prod.outlook.com ([fe80::dfaa:e869:45eb:76e5]) by VI1PR04MB4845.eurprd04.prod.outlook.com ([fe80::dfaa:e869:45eb:76e5%6]) with mapi id 15.20.7068.031; Mon, 11 Dec 2023 21:59:35 +0000 From: Frank Li To: frank.li@nxp.com Cc: bhelgaas@google.com, conor+dt@kernel.org, devicetree@vger.kernel.org, festevam@gmail.com, helgaas@kernel.org, hongxing.zhu@nxp.com, imx@lists.linux.dev, kernel@pengutronix.de, krzysztof.kozlowski+dt@linaro.org, kw@linux.com, l.stach@pengutronix.de, linux-arm-kernel@lists.infradead.org, linux-imx@nxp.com, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, lpieralisi@kernel.org, manivannan.sadhasivam@linaro.org, robh@kernel.org, s.hauer@pengutronix.de, shawnguo@kernel.org Subject: [PATCH v3 03/13] PCI: imx6: Simplify reset handling by using by using *_FLAG_HAS_*_RESET Date: Mon, 11 Dec 2023 16:58:32 -0500 Message-Id: <20231211215842.134823-4-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231211215842.134823-1-Frank.Li@nxp.com> References: <20231211215842.134823-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR03CA0009.namprd03.prod.outlook.com (2603:10b6:a03:33a::14) To VI1PR04MB4845.eurprd04.prod.outlook.com (2603:10a6:803:51::30) 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: VI1PR04MB4845:EE_|AM9PR04MB7569:EE_ X-MS-Office365-Filtering-Correlation-Id: b62b6877-19e6-4d67-d988-08dbfa947668 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qtnxFHAu/GftuYIcY5Duh55WdIeeK7JtHY8sIeid5k6sXgtz8mHTR6dnR9iI4w7ErTtfIeiLXM9WAhbHo8DFV48Mf7Dbx6hrx/gRNwjgWLt0MnkMCW9BdfHk8pXm4BXG5H2IGGUlaqyEkS818Rnvn1euaNsLdd/VHPrl1Q4hkEGPT07tagKhbZiyw1i77Nt1Vq1XC9bQ34NCsKRTnxYhQOlJtKM6gxf1g2b5ellRA19JNk8nlDhgEOHSJqedPJ4uMHicbZdGaH4dnQW2bWOJjO8VxwhkLosfIGsSak7YowcU4YS6qvjudMRZ8DSeFZD95sSI0LdOFq84ZT5smXv2DCYZ5nc124nOcmGSAm1EQ7DkFMst76ZAFoBrsTAHhKvfsSQ8NEc3ns9Sj4UmxyfQBzeAQgMPzRgbyGrQDak0XV5D5v24t0cyyqBX8h5uPZeZUgmKRv0ITmoTUquYiG+1fjC9MxUQ5cuz6X0Pm4CanoE7lF6QamBGyz8NYw060M+baJWVBUm0OrWV/dCEUJjnluYZeZMHH2CS1Aa1ai3X5BlmwGNz6tkAQ2+eUKr7XwUBMQE3WhGfHgK7b5QzBklqR5t0md+z8gbpSw1QfX466nxePRBQPZVWZsC5NbhLXnAx X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB4845.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(39860400002)(136003)(396003)(346002)(366004)(376002)(230922051799003)(451199024)(1800799012)(186009)(64100799003)(1076003)(26005)(2616005)(6666004)(6506007)(6512007)(52116002)(83380400001)(5660300002)(7416002)(41300700001)(2906002)(478600001)(6486002)(8676002)(8936002)(4326008)(66946007)(66556008)(316002)(34206002)(37006003)(66476007)(86362001)(38100700002)(36756003)(38350700005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-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dR8RClOJlvTBIW8/e++SjFvQW7XrmIkF7NAiyrxtuGXU8RuRhisY/INMdKyaWmGskKro6RKRM+U0MyXUetcO5BmHi8zBZsbF49/BLXDhudt0SS2Zgm+x4H6SMiEyDC7vd+bqovD/Jz2ESoHfEmCXQzguDUmRNPk0RXBzfL0oKWVDrDzbEmwFdFGNH1kMimNvqwnNS8FgDFzH6td1R+BIuRpmfIGbmvP96vrwHxLy0LrXQXWAsi4YnEbInqYThCKhlmF9p4Ny4UGsdOefbjlEJx+Rkja9SX1EFZX8xQ7IJC/7i8dKl5nHrttPHvDDjyNd958C7gOMd9PxP5jDycs+F3e/rSSJ1W7q0Nd5BJM1i284VzdjIHOgXXfDN+mHk3gN4PbF0JBvnXUpCokaQvPSkXTeG2f299gHxCI5UuxLTtq2CecAvL/0hAANLC0XxqZx1PKzMi00PtlHuj942bgLoUolSsOV6abTGlCgH/3geoIXDyaQymdPMs917AxDxXWi9U5iA2jQ+aPfUsYL58WmDA+0TN97x X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b62b6877-19e6-4d67-d988-08dbfa947668 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB4845.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2023 21:59:35.6468 (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: ajd3eW5t6mLiqBEyojxZ6F7dXduCgaIawh97hOj1jdsEPmNBHSD/cFIq5EDd5kpQMJ+26SJaJOKLA8A56eqWEg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB7569 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. Reviewed-by: Philipp Zabel Signed-off-by: Frank Li --- Notes: Change from v2 to v3: - add Philipp's Reviewed-by tag 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. 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 Mon Dec 11 21:58:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 752650 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="PIVTUExg" Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2056.outbound.protection.outlook.com [40.107.249.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6316210C; Mon, 11 Dec 2023 13:59:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WIvYtjF9DtLl7U6ix0MVx80ojdqfrYcWsvOVYG7d6mkl2JpnNBMQ22xjvIgmjsH7KkYQkvcXhAz0qW8pxPZU0Q7odoY/DDvd9MLkZXdaFvdQh718MYT4QmI+Ftuv7tG7IRj02S+aidLdCh9HCppP0Elr4I7awSqA60k2Gm0dds4Vr33OIy4dcVmWwnHNDp/urj4Rf+g09en1/Z1ztNWMFiaHF1t3DIvj+Yaj5huS5t1jiOeVIRtBU/v7pg6FFpIzfeeu8WNJHi1n5eePlP5wSV9kTteMCjHd874QRw5X1DeK1SuASTxM/0goweoZjov8Gy0SBlN6iulqFsmUAAdsSw== 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=oAuYcnSxfUjuXCqJViD5s14jjKu2Y6OgCA8oY8DtnJA=; b=am5e4sJWaBRfmI2A6bZ1r9uqy5DSOeQjEkWx74lN8vFU/4z5irJBd0YV0o3I84/34av5TkSeSI7s40NiijS6WLyFSwCJOmSc1Hn4SijmKoLVKYLetTbTd8cTDI59i3h81buy4DP7pr+gQOJKZ9neDWNMU8ROW95yF0xW9Z6xJI6X7tapo8hmP2351fR89HwXrepy0MTLd3FVMUz5d5ATI2zYpYYt1Cg/E/vvn6RFW0qtrj9Sb9qL+WPIDeU2NbYujmnplWejKu9SM9V6/A2O+OQnfFx/PFHd0ZjDxd9JXgz8meIkwy7KDxzKMFzq4yfY+s7OzaEtZr+e16kytSab0Q== 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=oAuYcnSxfUjuXCqJViD5s14jjKu2Y6OgCA8oY8DtnJA=; b=PIVTUExgwA3CrJcO2lvV4XUotInU0L+SWpyFnksZXRJnyMRptHbQ0HgC3VEXUXmoQ/7OB/qN3B8COkJn4DxR2mEUF8bQRajP/KzhZUpmUREV9c7F1uh110yIyskkUjqWtCiDXdz1C5j8lRYnKFGI5UZcvjhj+ZLqJCX+4hj7IvU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB4845.eurprd04.prod.outlook.com (2603:10a6:803:51::30) by AM9PR04MB7569.eurprd04.prod.outlook.com (2603:10a6:20b:2d8::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.33; Mon, 11 Dec 2023 21:59:47 +0000 Received: from VI1PR04MB4845.eurprd04.prod.outlook.com ([fe80::dfaa:e869:45eb:76e5]) by VI1PR04MB4845.eurprd04.prod.outlook.com ([fe80::dfaa:e869:45eb:76e5%6]) with mapi id 15.20.7068.031; Mon, 11 Dec 2023 21:59:47 +0000 From: Frank Li To: frank.li@nxp.com Cc: bhelgaas@google.com, conor+dt@kernel.org, devicetree@vger.kernel.org, festevam@gmail.com, helgaas@kernel.org, hongxing.zhu@nxp.com, imx@lists.linux.dev, kernel@pengutronix.de, krzysztof.kozlowski+dt@linaro.org, kw@linux.com, l.stach@pengutronix.de, linux-arm-kernel@lists.infradead.org, linux-imx@nxp.com, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, lpieralisi@kernel.org, manivannan.sadhasivam@linaro.org, robh@kernel.org, s.hauer@pengutronix.de, shawnguo@kernel.org Subject: [PATCH v3 05/13] PCI: imx6: Simplify ltssm_enable() by using ltssm_off and ltssm_mask Date: Mon, 11 Dec 2023 16:58:34 -0500 Message-Id: <20231211215842.134823-6-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231211215842.134823-1-Frank.Li@nxp.com> References: <20231211215842.134823-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR03CA0009.namprd03.prod.outlook.com (2603:10b6:a03:33a::14) To VI1PR04MB4845.eurprd04.prod.outlook.com (2603:10a6:803:51::30) 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: VI1PR04MB4845:EE_|AM9PR04MB7569:EE_ X-MS-Office365-Filtering-Correlation-Id: eb3afe69-0f7f-499a-35d8-08dbfa947d60 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GlqWOI43ncdGRwjp6YhmEvZD2PtlqwE5y9TCrCngl7D6w7cwvU6+8LXzeHbqWsHVFwn6EBDvs+g04ozXU72zQYA6Z4T6lDfhiQeqG/ou1FAoT8K3Ft7mPiBYLGsN3jXyQtycT7bzmdvDQryL8OXcBDH55e5OxTgy7ksDbkX0BvSWtuA5RIRVdxODKM5pSruSXSytUd7Yl43JJuhJjNvZnmJlW7qYx3yKKzzFiGr9wj1VFH9bS9qfYJXhieV5AUmfkwXWXyAEH1R47ZlmJ3/nCbpBbBefe9MPlRCIgMCYl5yktqTM9uoODkZ5N+6vYZKK7qy7FIoOUJ7lVaROsW1Ri19PwWu+dvxLwAEKDhSlvpN0egfLfeFSE+ey4VwXoFrMbctNHKYvSqtfuzCvmt80v8x4GuhXt0cEr0D3dO71ya6Vp8oZDTC/gPQCjdUAd+8F1qMCMGCw7PtkARYJ7ldhdKkAlJXRPAshcdp0/oCudsjAKNUuF1z+NF6dAPjg8yy8EKl8yN5eMo8uiSph8dv7nXxrgJ2E48yoa+A03Y5x1lxouQgyP/WYSD+I4ObKcD2tUtc2Bish4dwKzjmRCM7bczeOUuElh9OlyO0z10ziFFKwaZzorsCO6IFC1pXt3c2K X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB4845.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(39860400002)(136003)(396003)(346002)(366004)(376002)(230922051799003)(451199024)(1800799012)(186009)(64100799003)(1076003)(26005)(2616005)(6666004)(6506007)(6512007)(52116002)(83380400001)(5660300002)(7416002)(41300700001)(2906002)(478600001)(6486002)(8676002)(8936002)(4326008)(66946007)(66556008)(316002)(34206002)(37006003)(66476007)(86362001)(38100700002)(36756003)(38350700005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FDQ8oQQq2OnH1JBEcSp7jMFp1eXIpayvIoSKloo+faYzI+j/NQmVqRbhpYgaKIZZMlI0RW7xdNumHPxlu5JfK5+KYxHzJ+wCQoVU8xuczhgh5uIuLNFcI6M40SUlZFIx9OI68xd3VTLy4TvHoXY076ufh0RpeM1CoqNIn3nHjUgIbMEbYfiIN18AOPE7B9DTunH5C7BhuwhB0wVmnAqtxjN15m2Chr80YAyoSaW1rJfp+bjtKs9e/r1eMb1s0X6SHqhAk7ZJLZAD3Adl7ZUSoWn8/Va821cRODg+I9TPYbjor+Mhgt9WWgFEp8Z69G8Ujs75maOXbUTiZBRrxs6Sls7kpuvbCgDIoyi6p+6RYEv4H151ZW8qujM/VbbBSVL4nGlF1HEnj/BSwj/8eGcgKwmLGXe7mVGGsPW7iZIB7U14bKGMirX/jSvy+P69C2LkFnDvO28n68EYWYls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eK+ZPn85rFPb4KTqQ1BMUrtnmRm/IEs/OtmOsNdXt38nZ X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: eb3afe69-0f7f-499a-35d8-08dbfa947d60 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB4845.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2023 21:59:47.0603 (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: sk0aondQGLKEyRQcCkvMB1U0BAUDC1JKBjYVS73qjgR+PHUb4tfFw4nl8hQSw13fBpu1qK0abcJkEIuWohGtAA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB7569 Add drvdata::ltssm_off and drvdata::ltssm_mask to simple imx6_pcie_ltssm_enable(disable)() logic. Signed-off-by: Frank Li --- Notes: Change from v1 to v3 - none drivers/pci/controller/dwc/pci-imx6.c | 37 ++++++++++++--------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index 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 Mon Dec 11 21:58:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 752649 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="YcLJ8U0f" Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2059.outbound.protection.outlook.com [40.107.249.59]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3868C10B; Mon, 11 Dec 2023 14:00:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TN4czJmuf+2MEfoormb7Io2UVfFhzVL6u+y3j9gG+nGPYJQMlzWzTbrAuydt6Y4EYcahW76aIE5EVgxVsUQjghQnuT40kutwGuxqKhy/IevCr/lwkjwkCiGI6TIKR7/aVj3XnQCCVLq13aC5q8KdYI/aEgLZE17tIBra5ZrKPZ7HQchOCko6m6YJ4cdp//Amo1S0lgIUbGmhHr1y0NxenPCSARWs/Q9JNzPcIfWvVm41m6jU5CiFcqQ7ObVwy0fehzYA+Mt4Wya/s0rw/VJL/q9qQ5Eg0wA0xQrsB9Meiwj+P6vDOyD564bsZsEr/i1eUgOHGyMf+D511nFD5hnQsA== 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=kIeBJ/yB30HaxfzsJAv6srBJhbj4M2EWXM3D2d4itTEctXHuped/N2LfyddUarEGTXf7jSIUvFdlUajbqOcrY05TSuw77PkBuuHBFLbgtf6ZQBna5ltCqWz+4V1I1uiLqwTAhPDI12immFHRu5NKJARxG+RezpgdnUhoo8pm3tEciEtFt5RGzpb+AdyXAYFVm8DgdOaoIjSvRRuYCQwWRtTi3qi86iPUih0YVbi7nc+ghTeKqAFNM4qnCatNyrnPBJw+ZZoWTcvyYwJmPJiSK6iYkwfRXO/JsfMjkKr0pEl4ByT/Yr5fuFcPZt7WCHMpFfZZiYP3ErX1HmiU6wTqng== 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=YcLJ8U0fAZpdzwgApJ4RrNEiv+ZdSgFZV1bbc9lpQMbyfyfL2+1ppXEyT4s1lkuGfI4g2zFRTcAL7o92jlNoKmF9LusPAon0yIx4IA2WW4cmMcrvcL5mHEhJTcXnWAEJ/2E39uq/KFM8mHgAQVNVqPpV5reytHuwLZ9AeCxTK84= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB4845.eurprd04.prod.outlook.com (2603:10a6:803:51::30) by AM9PR04MB7569.eurprd04.prod.outlook.com (2603:10a6:20b:2d8::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.33; Mon, 11 Dec 2023 21:59:58 +0000 Received: from VI1PR04MB4845.eurprd04.prod.outlook.com ([fe80::dfaa:e869:45eb:76e5]) by VI1PR04MB4845.eurprd04.prod.outlook.com ([fe80::dfaa:e869:45eb:76e5%6]) with mapi id 15.20.7068.031; Mon, 11 Dec 2023 21:59:58 +0000 From: Frank Li To: frank.li@nxp.com Cc: bhelgaas@google.com, conor+dt@kernel.org, devicetree@vger.kernel.org, festevam@gmail.com, helgaas@kernel.org, hongxing.zhu@nxp.com, imx@lists.linux.dev, kernel@pengutronix.de, krzysztof.kozlowski+dt@linaro.org, kw@linux.com, l.stach@pengutronix.de, linux-arm-kernel@lists.infradead.org, linux-imx@nxp.com, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, lpieralisi@kernel.org, manivannan.sadhasivam@linaro.org, robh@kernel.org, s.hauer@pengutronix.de, shawnguo@kernel.org Subject: [PATCH v3 07/13] PCI: imx6: Simplify switch-case logic by involve init_phy callback Date: Mon, 11 Dec 2023 16:58:36 -0500 Message-Id: <20231211215842.134823-8-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231211215842.134823-1-Frank.Li@nxp.com> References: <20231211215842.134823-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR03CA0009.namprd03.prod.outlook.com (2603:10b6:a03:33a::14) To VI1PR04MB4845.eurprd04.prod.outlook.com (2603:10a6:803:51::30) 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: VI1PR04MB4845:EE_|AM9PR04MB7569:EE_ X-MS-Office365-Filtering-Correlation-Id: f2bf809f-f7ab-4d65-96b1-08dbfa9483fa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: V8XovyCmuoaGKrc/EEtFoJgWZaa/vcvoSSGvM/9+ql02F/sFCGhIbvfEEzfonJmjRw5NCRQzrLKHik6H8669JXnmzU3EhHxZ7yFlZ0N7IiC4wy+46HLdvZSS+Vx0TjoCeR5anAZ54YbjHkV2RYo5bkboyBMRjFbmXJ3fpqPLEVaIKkTaNDpIIKl5ZgmcNKoOreUw0FHGuELetHAa/gAecpepZolpz6InWsu5z06mOxZ7l+s/zeOnne3gvAYyE5EPmRa9FKNIfGkrc+54pbjZ2iNhWkS1YAKks6w5G8MiJQjjotZM63Gw4NgobDwCiGXGS3CbHUN/VOa80JSkOMgtXqpp0eLvVy8A9FgNpn87Ssa9mKYOovw1dd4XsF8mdg765881qBxpmCQKFT6EFdpRPaKZtt9Pd5TcAxUnlfDt0aXRXF/C+9ed63mayNFZ1UAKmVgsexh0l6uPtMTxnpgBc5jf0bNHldXcOcJTSNncDkxR5pL7E3tfsjUw1oLd8pmM6dOlLTaW03qEhGFQusiYcnj/w2Oo5lBwLtXHfYDQ6Ya/mGFlwnarmMb7W/Qbz8Wsmmsi8usPGOP/X7EAmfGvN0lhMViX/vHbGFTAjzITl3iFLxXGMLXsK+P53nKTmvRxQTFOx6VjMjcWZsP1xuMCzCxCULHw0ZfgbBt0ZIx5z/o= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB4845.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(39860400002)(136003)(396003)(346002)(366004)(376002)(230173577357003)(230273577357003)(230922051799003)(451199024)(1800799012)(186009)(64100799003)(1076003)(26005)(2616005)(6666004)(6506007)(6512007)(52116002)(83380400001)(5660300002)(7416002)(41300700001)(2906002)(478600001)(6486002)(8676002)(8936002)(4326008)(66946007)(66556008)(316002)(34206002)(37006003)(66476007)(86362001)(38100700002)(36756003)(38350700005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6zqmGAZGHCVeJ5HJlu4q8BaRbyExUzbsJ/aeTb+ptDFytVBiFfFYyW3cuazVnMgtCFvmK0J5GLiuj5j9n6zfJMbPkKAAaw0nvEK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3Zt5ANgZq268nC945+6QEk9dpUslmNxjhXNRLgkBNBKfNX0qkNjc87Yt35AmXRqGRLFVTfCKtviPcCXzMd/nUAJEOz5MXzC7Zr1oMg4m0jYJct1MG7LJFwUTS+hB4LI5dHclxcWzecpXvwcNSDtf/4aDeSWIikYeq84EsHgjAjAX9/SZEPkCFg831umGWfzHkPM/VQDt7WrPo6ePdRB4DLX3xzE8hsQVQQ3Gd3OXBY/h72IGFEqO432XfVOHS/JS57PREIP/1eTvp5LyhrCztSSmVxDfuSVN2S+wmWJzsHci/S+05qy8hyA5WV5+rCk40cHyHncSWLFGjw5GnvWV2Jvu4/mormIPF3klJAlOpVKvQyDVAS1JC0Y3Kz0V1CtmKkV626S22FopHOdAt3yk6EMBt/15zerP4EuNUnor4mx X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f2bf809f-f7ab-4d65-96b1-08dbfa9483fa X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB4845.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2023 21:59:58.3183 (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: mF6th5KShC/1yKy56LmQiNhje1KnwWjwFv2ZdCObz5wrmblDVhz7XkOitKqN7q3e8BiKarTgX0ODnQ2U3f0k5g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB7569 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 Mon Dec 11 21:58:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 752648 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="bMliLSw3" Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2083.outbound.protection.outlook.com [40.107.241.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79655113; Mon, 11 Dec 2023 14:00:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XXwX3o4bvyhaJz7eTKGuK4EhT+hyDKB0GcyPFv+QngOdJ+xylaj/f3vxJjJ83asn1a4/Ggs5eoVHxRB79ATKNZzlD8AhkqaE2GUAxBxP2wwn73ZcHfPw6ny7xDCpDY3MACRywX0Dl1nAj+bsJLVh8AJRXdVPclb9EsE7ZO+Umh2DhDCMQvbBVzrYiKZeBL8NDT+psUTu8hkb8KhXGKrP3oQum4pSzoGnOkCjsdKROgwpC5XR5mN2i3W3h5bRNz3z70cYAAlGj9MFgoweEACdLXh2tASrvnp3eJLDacu+QmS5MP2wC/LFn7fRBRNTaQ69sEbdBiFqb/Ls7RwV+5s5VA== 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=uLpS2V7K1OZ7WBb/0qCh+MtUGmX0ebHK2c8bjaDFPKk=; b=iLkOZgk50P1325zBnkpr7DNMB/x1BtVrlWKhu5sK3PCgMHjpqm+aTBpoansru05TjASyKuEdhl3W59jrCHJvy0pyizsjnHhbjVT2EQwSxhaDqgo57xggE9IWLmTYezvhtJeDHP/qzxpYXiTozyQ/qxMIoQWI4UvTYRKw+dyijHRxMcMdWVyNdS7waryWbvDClPQ9b3Wljb11gV++6EXM5SXqTKjmOZyb/mJNqoAz0Lk8zeZNDI+sKRN3ZPGQaurgh0FQu5oZFm2Uzq//6x+V7/0TjrrqVl9W4Gwzeq8WywAVkD4YaYfp2G4QDZU2UcD0rvuFI+C9SHRLv+s2f5J9PA== 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=uLpS2V7K1OZ7WBb/0qCh+MtUGmX0ebHK2c8bjaDFPKk=; b=bMliLSw33gPT34MY6pBHP+KxleL9TpDc7PVYiS9J6uKEEkpcMNe+qHQ/t+Z4DBhNGXzGMFEOmrsuayuWaWBa9DYyzLfCBz+9kLUpOT3YzKK9EJ0hC1IE+bmFFUNuCnJKmMGIx6t1TMP2o1b01eUVDv5WHZkUVaGB0a1NINM/ukU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB4845.eurprd04.prod.outlook.com (2603:10a6:803:51::30) by AM9PR04MB7569.eurprd04.prod.outlook.com (2603:10a6:20b:2d8::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.33; Mon, 11 Dec 2023 22:00:08 +0000 Received: from VI1PR04MB4845.eurprd04.prod.outlook.com ([fe80::dfaa:e869:45eb:76e5]) by VI1PR04MB4845.eurprd04.prod.outlook.com ([fe80::dfaa:e869:45eb:76e5%6]) with mapi id 15.20.7068.031; Mon, 11 Dec 2023 22:00:08 +0000 From: Frank Li To: frank.li@nxp.com Cc: bhelgaas@google.com, conor+dt@kernel.org, devicetree@vger.kernel.org, festevam@gmail.com, helgaas@kernel.org, hongxing.zhu@nxp.com, imx@lists.linux.dev, kernel@pengutronix.de, krzysztof.kozlowski+dt@linaro.org, kw@linux.com, l.stach@pengutronix.de, linux-arm-kernel@lists.infradead.org, linux-imx@nxp.com, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, lpieralisi@kernel.org, manivannan.sadhasivam@linaro.org, robh@kernel.org, s.hauer@pengutronix.de, shawnguo@kernel.org Subject: [PATCH v3 09/13] PCI: imx6: Add iMX95 PCIe support Date: Mon, 11 Dec 2023 16:58:38 -0500 Message-Id: <20231211215842.134823-10-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231211215842.134823-1-Frank.Li@nxp.com> References: <20231211215842.134823-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR03CA0009.namprd03.prod.outlook.com (2603:10b6:a03:33a::14) To VI1PR04MB4845.eurprd04.prod.outlook.com (2603:10a6:803:51::30) 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: VI1PR04MB4845:EE_|AM9PR04MB7569:EE_ X-MS-Office365-Filtering-Correlation-Id: c32d5818-c808-4533-83d8-08dbfa948a60 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cQ8qijOHJ8AokE1czITLw9uJtstCAECP27DbCL2aLyRRJ63M5AYwNrT7mN9UrypkVduUEQoAGRBETd5q6hi/X3K1yV2E1RoHVvxuRdf1R1cyDk9YRXbAC9QvY+CGyJx0SbeVpGnECnkI+3NLegf/JtaFwN+hbqmp1ixJDkeoBRckHF35fwh8q9q2+gPrAMNiFnKoXPiU1HOjFCMFu0zSkQDSDwhldZcR56at3BZsPmyuC+8S73vJ0Jf+TUVLWLBqE/roS6vhCL0Q26YItb8Q+xiTFmJRHIZXugEijY1ue7MWxVn4/+CI/Sb/Rbd/IF08sr/wuEM14NYZARleucdi7i1NfTKPFXTlWamSEDMHPCoRKHPTS2Y3xb382eJdKKh2oA9RC5C7PyvQGpsaW1xyVrljei5ZspIcCPlUQSkYfWwyksG0ekLuWAiaoAyK21TOkxeOl1399hTyXdAdLsSNHGxs+171zBJpK4B/IqxXagBi6+Hq9OrdmuPU52Vvm/nr+63VMtdtXQGAcck7uGEci6Kn+uNCntX+/fa3irSn+Jlg39mB62+ACRXr1Go6jekwnQvzeJmyT7QHcATpUYNQB+WDhdoRWDbKogbk+Xz7EiTb0Aeu96cQkGzF1rUokxOE X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB4845.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(39860400002)(136003)(396003)(346002)(366004)(376002)(230922051799003)(451199024)(1800799012)(186009)(64100799003)(1076003)(26005)(2616005)(6666004)(6506007)(6512007)(52116002)(83380400001)(5660300002)(7416002)(41300700001)(2906002)(478600001)(6486002)(8676002)(8936002)(4326008)(66946007)(66556008)(316002)(34206002)(37006003)(66476007)(86362001)(38100700002)(36756003)(38350700005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6wjHYmTirznmj0i5Qo8uaYz4cAZRwaw4z5i5FlYFg78Ld9VleYSDfN0+gZAPvCZWF4sUccjJZ3Iz4WVA+mfDsIIonCDh3WgRj8s4CR4v1YcCha9sizhK3a36RFVPsDBc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Hm4WNR7nVP4SqAZVzO/PiA8jKAbHxKN8oFNtv4+T6o0yf5Xt6kmpTIPfa831C9tn5XkbhyvV7WgeQ/C+Nmv+YT9T1j3VD3Ag0ZuuI7IdrDnJp+AyGLZ4D/z5oOux8jZaRflDMJ0in34YMAjvO5Ko1Q/yQUmh5rgvbwZYa4tNGDf/LQ7UB/XXFeMwgjjyRoX843/D2dJloXNA9HNDU9vDxabWXrv6BgQ5oV6dsoFj58HGOglMx5FDhK50XKjZZO6aU+/NlYNTS6GQM0x8UA5zxyYoCeG1uuxlCPp+SRG06TNqtMLCYIhTp30G6eVy0ZGcFNebFTKIkwTw/995q46mc+oGInCF+xh9DTlg0GdBa4au8tPRPz5fOWecSu08W0I+QAS7gE7tmXr42Z0Y X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c32d5818-c808-4533-83d8-08dbfa948a60 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB4845.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2023 22:00:08.8048 (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: CKQ/chZLjVUWndkcxzuW2XBo1XSbjk8z+HyjwM8ajvSeZWmgts7DDh7B6rMgxcMs6xzydKCMLJxq/HY5hJitXg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB7569 Add iMX95 PCIe basic root complex function support. Signed-off-by: Frank Li --- Notes: Change from v1 to v3 - none drivers/pci/controller/dwc/pci-imx6.c | 89 +++++++++++++++++++++++++-- 1 file changed, 84 insertions(+), 5 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index 4e55b629d4efb..99022efe27334 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, @@ -66,6 +86,7 @@ enum imx6_pcie_variants { #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_PCIE_FLAG_HAS_SERDES BIT(8) #define imx6_check_flag(pci, val) (pci->drvdata->flags & val) @@ -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,32 @@ 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_check_flag(imx6_pcie, IMX6_PCIE_FLAG_HAS_SERDES)) { + void __iomem *off = devm_platform_ioremap_resource_byname(pdev, "serdes"); + + if (IS_ERR(off)) + return dev_err_probe(dev, PTR_ERR(off), + "unable to find serdes registers\n"); + + 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 +1575,15 @@ static const struct imx6_pcie_drvdata drvdata[] = { .mode_off[0] = IOMUXC_GPR12, .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, }, + [IMX95] = { + .variant = IMX95, + .flags = IMX6_PCIE_FLAG_HAS_CLK_AUX | IMX6_PCIE_FLAG_HAS_SERDES, + .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 +1624,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], }, From patchwork Mon Dec 11 21:58:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 752647 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="Ob84I823" Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2083.outbound.protection.outlook.com [40.107.241.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B0CBEB; Mon, 11 Dec 2023 14:00:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cfaqCIjae+pL20hgRTnQ7RdzEK9v405UH9SRSME5Y4drV2xkdjCYMZlKX600+OlEy0anz+3OcGXf4QHEaYNmZbM2P6GFtQKMqhpBwM40+sbhL7MHXnBmKWDyGexL8BGLFxKoW2Xh9w2dZO5av/iPRnlwUZeGC0D4OnCTiSOV3yfwc89kE+nZ+3So0HVicjwbX2yh/p4F8N0DkGzR9BpU/2YM96p+sBm1iHWzPyI+mic8CJUBX5K0sb+kk7dwI3eFCygnG/DyDGrsWi+4fzBynTYPbdTufUd6LDXGR3KBiBD7V1FYcN2rQ2HqIWlFmJqRC2ospwUFOXtRV2ADQcCh8g== 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=Q+O8KDC48w0NQMLHJPGOgAGokjP/XnC90cLpCcTuKZI=; b=DA7t+XmT2uKan9+1wj5Mqq5PNfg68M5iyxVD5QfnqNFOgDTLWE1mjYh0CKqXp/i3/tn5QXrWprHxKtSgI0N5YXjAylnBt4q4jnpanXA/cs74TCYYhUpZbLg2aJhDIs3l9D+Lkp/QO5t2Eg7In+WUKZVlzO6some7B57gwJR8hxQuiPGzA0fJ0ekY/8y18R+7U4VTkmty2u0CRzQATBCIUoL3LBAiQsKzH4q0MG5WKOVUGrHJXQ5ueIJlPk27YY+LjwqBoSyZE1oTEB9SkL7rjVFXqgnQ1xbax3Xivig1g/Yxlroo6DtPusj6WvgOMheeoQC3O1w6Aj9EZ+ZkI/pHaA== 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=Q+O8KDC48w0NQMLHJPGOgAGokjP/XnC90cLpCcTuKZI=; b=Ob84I8230pAw0LJZrknd/MazSP6D9kZgazNKEyxWGp7enDanwXMP+psZIbfBgnCUHHMYE0qrArq35+O7D6rxxua+13c1OY0nYdd0Riwnm6vdk2qLB40cv/62dSJFoQPY6jIDwTqV/Mm3w8vd5MiIeTmLFIY0GXfD/KtfHv3XwZI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB4845.eurprd04.prod.outlook.com (2603:10a6:803:51::30) by AM9PR04MB7569.eurprd04.prod.outlook.com (2603:10a6:20b:2d8::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.33; Mon, 11 Dec 2023 22:00:14 +0000 Received: from VI1PR04MB4845.eurprd04.prod.outlook.com ([fe80::dfaa:e869:45eb:76e5]) by VI1PR04MB4845.eurprd04.prod.outlook.com ([fe80::dfaa:e869:45eb:76e5%6]) with mapi id 15.20.7068.031; Mon, 11 Dec 2023 22:00:14 +0000 From: Frank Li To: frank.li@nxp.com Cc: bhelgaas@google.com, conor+dt@kernel.org, devicetree@vger.kernel.org, festevam@gmail.com, helgaas@kernel.org, hongxing.zhu@nxp.com, imx@lists.linux.dev, kernel@pengutronix.de, krzysztof.kozlowski+dt@linaro.org, kw@linux.com, l.stach@pengutronix.de, linux-arm-kernel@lists.infradead.org, linux-imx@nxp.com, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, lpieralisi@kernel.org, manivannan.sadhasivam@linaro.org, robh@kernel.org, s.hauer@pengutronix.de, shawnguo@kernel.org Subject: [PATCH v3 10/13] PCI: imx6: Clean up get addr_space code Date: Mon, 11 Dec 2023 16:58:39 -0500 Message-Id: <20231211215842.134823-11-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231211215842.134823-1-Frank.Li@nxp.com> References: <20231211215842.134823-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR03CA0009.namprd03.prod.outlook.com (2603:10b6:a03:33a::14) To VI1PR04MB4845.eurprd04.prod.outlook.com (2603:10a6:803:51::30) 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: VI1PR04MB4845:EE_|AM9PR04MB7569:EE_ X-MS-Office365-Filtering-Correlation-Id: 1568c97e-dd86-4ad1-be57-08dbfa948da7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HYTwZ+TQNKVGmR5mzYiEEHdPCXweyrlmmC04d7xJK+Yt0mJ9xj1+4ORiAHgr86KdE0+Au6KT6IvJfA6IKDZzDkih4NIlYM8Kxi74rQE/44pKFjFUIer40izJpEZVbnPh/ec7j9/d4MVM6LdNWHbEP0eDYbxS/QFn2dWlPCiI87pagnGgnGOdt5NuYu3Id6y9caWGMoRpVvf/JJjqHbYm5/8h9+Q3fm6A8uXAZfBRlfBYWWAUDkfkIUCzINOpYT0H9UzEvYykBG48q+ZAEO4KqLTVnJYQ++86JGrvWijgHG+nX3yLeS7kodL3f0h7b1ewMpMETksvF9CaO+JVqEhlwWPktNEjd64cohxXQlmTWX8cIjJCUUKverq/lLKacGjoAWpYNj1bzZIhCCeDw9vKcwvRxBLpJ6FCSmqNai8Q79U2xYAc1EZ8j6N4V1yYcgw9TID8vwXgzc1WxpEHTBhduMfpGAilLUCo2Nk34atN0fRD4ygcg3Sj2za8jT/XBsQqHHyHeG0ChmKxLpdMlEzG79UurWFL1TprGTicaMoJiZliD0nGzopZQn+dR8S32xSuqQI++W96AlccwBVy78WVFzBR421IjFjNneDOPI0yf/bLqlM+Xdh2EU4opAVGmGMm X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB4845.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(39860400002)(136003)(396003)(346002)(366004)(376002)(230922051799003)(451199024)(1800799012)(186009)(64100799003)(1076003)(26005)(2616005)(6666004)(6506007)(6512007)(52116002)(83380400001)(5660300002)(7416002)(41300700001)(2906002)(478600001)(6486002)(8676002)(8936002)(4326008)(66946007)(66556008)(316002)(34206002)(37006003)(66476007)(86362001)(38100700002)(36756003)(38350700005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Jm2cUxnir1W/HaRcKKXDYx89XQDEHt3QSdI+Ih9JL0VUnNuiOkqNBX+AhJdPQE/NyPBzb2P4l/JzczZV9PdjWPXsTUDJr24/mLYnzoTIfEZCnkszS+VLbhLUNGZBb2CccxhjyqL7o05d2TFWBYJs6iyr/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LiqEDtCP+B9XqXhYneuEVOWD1gtyRu7rGvQvPDhNOtCBXpOuDnMf3T2QfROdGUSdL04Vd/w4vgN5KJYb1QO7AghfJdOrt2gx0WKD/JfQOnlLfTMvXF5qCs4kIz3CGK+nuQ3hSIK+ZoQLf5sycMwTNyqClyCWpLckGJMPQBG0qW2LHhQF6RMw6O5i6Gqh6XMICKtSvgaybe0pCv28TTdNOYa3YifWPDgLCKOdo5DD6nYPcqD/M/Bd0UbR7hEX/BWOJkXt28vK3Xq4V2OJ83bvSL7G04GNx9OGGpT9RF6Y0ul9oGTSCEp0ThzTN7demHHnFgzShAGdZlnIaDA3shAqyMywOzxD9kVMdYpCttheYKhK3zRnXj X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1568c97e-dd86-4ad1-be57-08dbfa948da7 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB4845.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2023 22:00:14.5335 (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: AwpIhNzJa4sG/ZNzpI9pEJstewcQiJH6ybOcWyKs7SC6mXFqWJnyYFs4LR/HXK/6r+prann2UJoRGY6A3ty5+A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB7569 The common dw_pcie_ep_init() already do the same thing. Needn't platform driver do it again. Signed-off-by: Frank Li --- Notes: Change from v1 to v3 - new patches drivers/pci/controller/dwc/pci-imx6.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index 99022efe27334..eb4e954e3a167 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -1116,7 +1116,6 @@ static int imx6_add_pcie_ep(struct imx6_pcie *imx6_pcie, int ret; unsigned int pcie_dbi2_offset; struct dw_pcie_ep *ep; - struct resource *res; struct dw_pcie *pci = imx6_pcie->pci; struct dw_pcie_rp *pp = &pci->pp; struct device *dev = pci->dev; @@ -1135,14 +1134,8 @@ static int imx6_add_pcie_ep(struct imx6_pcie *imx6_pcie, pcie_dbi2_offset = SZ_4K; break; } - pci->dbi_base2 = pci->dbi_base + pcie_dbi2_offset; - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "addr_space"); - if (!res) - return -EINVAL; - ep->phys_base = res->start; - ep->addr_size = resource_size(res); - ep->page_size = SZ_64K; + pci->dbi_base2 = pci->dbi_base + pcie_dbi2_offset; ret = dw_pcie_ep_init(ep); if (ret) { From patchwork Mon Dec 11 21:58:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 752646 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="shMhsbbS" Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2083.outbound.protection.outlook.com [40.107.241.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81E11FE; Mon, 11 Dec 2023 14:01:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aP3EMeAGm95F/DyrQu7le5G0+bP/BNtP+saekuxUzUYgqqvOewOGcKlI6ahgSepGt9CqLwHHNP9JolWWp5uHFtsvzv3OltlCnRZDI4aGp5AhXY1FSjuCTgjPHr+D9eUrCbrhDBPRILS5xarnhxEH6Hs/2Qc5zCFLVrxUhE12Ca9y5cxubCGUzSD/MCyNw8czaRFSW5mi3+1+6hoX8Sdjd5fspt4JXFL7wFKrvD++eOi8U7rkBpMXd9iFxisd8ZLmHQr3C40zCKZHQEjfxt4N7EU2PznGq6V7uscOh39GbrHAiOj5mYd5cY4/p5kSK0Zwn6SVCOGnL0vhT5/N/YZQWg== 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=MJn1CcAug8mZf5HSinTejzQInL2u+Dc75u0Ow+OmQ3w=; b=Vs3G1E+xryfAQH0qzWW8/2d60Y305Ofze4dCT3ZwXSGrz8m/qWiKKPCy7FqT/H2T7j6aNZQ7ldTnMqhsVPPLrwxBcgaMADwHiKCuGbs08Yr5uH3aiddmd8kiT150kl4E3ZqIxyzdurR6Xtx2ZuskqoYwfO9+VqjcQ8dDHUrWDIGk5BmFtRHYXH1Cp8+3NHoEZVlLk7egU5e6OHxHrzj7u8sQHcC+BYNz8kA7+6TWVrGgADPfHG+F2gJozGSnJoqHKCA/+esyZNIkTkRyk14TujRx2HSy8evvp9QO3W1SU4riDGAktTdSmrdfp9TA6B5YHmtNcsNAf3QGvVfCgqroxg== 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=MJn1CcAug8mZf5HSinTejzQInL2u+Dc75u0Ow+OmQ3w=; b=shMhsbbSzqvf/Mx4aAlyejznfajY0EfbvtLuOffEFzyRwtIaOORo7SYnMKY73uVpbsmtwLNi6e1gJ6UM806CSTen00m1pcenggheNAI0mdFkrB402IE335lU1sxeDNl49MHF9nioZrirmN3Uf0T8eCAzeHDsynWkCqVWCIhOt/c= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB4845.eurprd04.prod.outlook.com (2603:10a6:803:51::30) by AM9PR04MB7569.eurprd04.prod.outlook.com (2603:10a6:20b:2d8::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.33; Mon, 11 Dec 2023 22:00:25 +0000 Received: from VI1PR04MB4845.eurprd04.prod.outlook.com ([fe80::dfaa:e869:45eb:76e5]) by VI1PR04MB4845.eurprd04.prod.outlook.com ([fe80::dfaa:e869:45eb:76e5%6]) with mapi id 15.20.7068.031; Mon, 11 Dec 2023 22:00:25 +0000 From: Frank Li To: frank.li@nxp.com Cc: bhelgaas@google.com, conor+dt@kernel.org, devicetree@vger.kernel.org, festevam@gmail.com, helgaas@kernel.org, hongxing.zhu@nxp.com, imx@lists.linux.dev, kernel@pengutronix.de, krzysztof.kozlowski+dt@linaro.org, kw@linux.com, l.stach@pengutronix.de, linux-arm-kernel@lists.infradead.org, linux-imx@nxp.com, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, lpieralisi@kernel.org, manivannan.sadhasivam@linaro.org, robh@kernel.org, s.hauer@pengutronix.de, shawnguo@kernel.org Subject: [PATCH v3 12/13] dt-bindings: imx6q-pcie: Add iMX95 pcie endpoint compatible string Date: Mon, 11 Dec 2023 16:58:41 -0500 Message-Id: <20231211215842.134823-13-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231211215842.134823-1-Frank.Li@nxp.com> References: <20231211215842.134823-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR03CA0009.namprd03.prod.outlook.com (2603:10b6:a03:33a::14) To VI1PR04MB4845.eurprd04.prod.outlook.com (2603:10a6:803:51::30) 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: VI1PR04MB4845:EE_|AM9PR04MB7569:EE_ X-MS-Office365-Filtering-Correlation-Id: 4c205792-e05b-406e-e6c7-08dbfa949408 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9YE7ToW4boflRLqwDkAZWA3C6bEVG2lBkx3qgrWqTE9olvuO8JbH7GTawMrKTwYEi9g8uC/IKdJkZYhTpxL+Jzgvv+FxkngqsG2GkoGyRbE/zLPF2hQ4JA+rMymnGmF6WHuyamvaBxDbYs/l//nv92Tt8aGJ9bdbzXgc5p/GLQ5meR202kWEAd2fAxn1DyW6mz46dqqdBA/GkhhT88qzUjJfOgfuuSU3PYn/gvAkLUrMD6FKxklXRQyI9trGokaykX+JP4rmvBPP1xKdYlV7ZjxBqwKFInZbr9fQufPiLlX5S6jW2QzK4fnfo4AXQTF54YD71f3VvCh3d/eWAx40+vrNoV4GJ8dDzRA+AelsPaLkhZPAG1JVrTunCyJ5QyoFSBRJK7EY9LJHo2tLqVzWfLi6VgdLJK01bMZQ3gK3Fpo2V0Y0D9iDRzl4GpJI3kIDxAWXqgKi2PL7NBlwF1GTn93GSsdJw3MSJ0zL6P81c6Ua8W5xxn8BT2xzQooLqa1dHqQnWIYN1xLq6FBcOBQMInb3IQYfKRkRcP+iPIjWkXiyZ4VOgVyb51PtD1G+V1PDpJMstgEJVz9AHA3R4Jn6j62b5340ayVYr8DGXoEaK0TInhWtRmDjRkl8irMzV5dvmM1XlU1cL2S+4pcKAGTy6w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB4845.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(39860400002)(136003)(396003)(346002)(366004)(376002)(230922051799003)(451199024)(1800799012)(186009)(64100799003)(1076003)(26005)(2616005)(6666004)(6506007)(6512007)(52116002)(83380400001)(5660300002)(7416002)(41300700001)(2906002)(478600001)(6486002)(8676002)(8936002)(4326008)(66946007)(66556008)(316002)(34206002)(37006003)(66476007)(86362001)(38100700002)(36756003)(38350700005)(32563001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3N+mg2QpOl9sE/+5Av7VPzeKa+pwItyCSZzlnBAlrwbhPXBrIO+6++d5aZUVgvWMjspxVGwp3uj95q+9xx1z9Z2hi8lfHZePKNafYPI4Y411KZ+jwAp5/wYS/AQpdyPH0UHrNBiGt2VTyqXnYAU0m/mXPG8qbnIWNB4Uh2cUcWVQUguPOGi1DlrnO6S7hguEUmkXR0f50+sSFrUd4JTpSEXYDYorI13xcoZEgJMukKt38EkPF0WG18/XkABzFWlCVCY09tfCSmAhHqqcC0lhtQX8Ul+FPN11pIxB7Hn4h+GyQI5CCS9y6fx2Cps8O/uMamqYrAyE0WjZaRAKL0vCkjsxrBBbbTthA5IZIAHwiv+26AcdRgD335iRprzSj6zZglEVirwJTE6iAn/UPy/glBdpKG8hVwR+BRSegJVsuGpsBQYVIA5eBnYbAYFtanOp7dfv3dsZPuvP0rEC+MOv+Ug63A/Ki5Q/9riMqt84J3oviBFhBvG8hkAm9JE8g7/XilO8uuHv729VIwhfl+4uIjgLwBcNxFR3HCQZtHtt/5txvISwtovnAfwTe4xDCxHSt99aAZn6gYMRbOecCmD/xoOp58vHNX605z/sPQWDbLJM3bl4AZQmRhT0109eOJP1714GWFt+4xtYEQKJpu3cTinqqfV2geeZxiKPXBp/DQ6bsGAfLZUfRvuFSRdQ+gmhE8AbMRtUVZSRMjueh3akyB/YXxIEjoJAgtBrmn0BQGXYX3Pn6QWfWwrbSPJsXD5kjz2JnBw9K7xnJZmgOQP3LohX4Y7OVTjCwomrYrTc3be6EUWlG/3i2eBJfRbIyAHVs0S69ufHWGqAqhm5BjNeWBibijcU+RYptQfk3FXVkJ6PorzC8cx9kG8zjAgJ8cf9aluyD6cdiDH6QwREvd5EbGKJtKk5eBDwFdPgUTBAP1U4mAkFdkz3gPhbAeZt+C1+/eQ89XQXJm0g5HTsZ59fCdYfGCS1jq5Ht63ZGBVcfi0yv6Vc+1ih2N5SGSecNrIh1DpKHtCBzGqIRUA+3YkHSznlAlkLco1JlZuOG+kbsrAhm+/bC2rWBpb7p7nr8SpP1kBP3hokNcE0++ROTDF0euYI76HflNU6H/zs7sJxbh3CRTjSAGun6fVOlxYhPXM1STjeDac8Y47BqbLgFM+Bqf4UXy0ogYNXMiVB/i3iYjVyCBPAn27JVdgmNQ29u79wsY4Essp9OCsubnXee+dRg7uzVRU+Cdln1QmKb51IMXOh9UpUeGR1LRmZAr3/Sp9r84XcFBV/zE5T1XV7f6Lz/YjBoot5jK5K2rweYG1oaETKrQGj9/10jTc25pwSE2dKptjU70s+9LTeaKf06Tbxf5bcluT5mXasAANqUdXiFbkrGWupNwBO+GPNFQLTAbDS0QfB++MuAt3Ln5KMfLgfPh9zIUDxTNggvgkZgFtKRsW4i45MSm1t580ubk0C8vgcTmtKXqZSnL7ErIiNE9xIpEQBLJdZeTZj+6aJzu0JFOnPiyoonHuMdwEweeTWn9wamfJ2YAdNDHESgxoVsUcOVL/qjF+E/9f1sykf0FmSLZ1QqM1eI1HlPeMApzYOEUxe X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4c205792-e05b-406e-e6c7-08dbfa949408 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB4845.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2023 22:00:25.0637 (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: 229KVatznAuJU9Kx8VPeook8qSfNwVcRSDBAyce5oTegobTR8AjWOckKP3r7NyMzV3UQ+tUubkJVhjg40mLV9Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB7569 Add i.MX95 PCIe "fsl,imx95-pcie-ep" compatible string. Add reg-name: "atu", "dbi2", "dma" and "serdes". Signed-off-by: Frank Li --- Notes: Change from v1 to v3 - new patches at v3 .../bindings/pci/fsl,imx6q-pcie-ep.yaml | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie-ep.yaml b/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie-ep.yaml index ee155ed5f1811..36d8f117fdfb3 100644 --- a/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie-ep.yaml +++ b/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie-ep.yaml @@ -22,6 +22,7 @@ properties: - fsl,imx8mm-pcie-ep - fsl,imx8mq-pcie-ep - fsl,imx8mp-pcie-ep + - fsl,imx95-pcie-ep reg: minItems: 2 @@ -62,11 +63,30 @@ required: allOf: - $ref: /schemas/pci/snps,dw-pcie-ep.yaml# - $ref: /schemas/pci/fsl,imx6q-pcie-common.yaml# + - if: + properties: + compatible: + enum: + - fsl,imx95-pcie-ep + then: + properties: + reg: + minItems: 6 + reg-names: + items: + - const: dbi + - const: atu + - const: dbi2 + - const: serdes + - const: dma + - const: addr_space + - if: properties: compatible: enum: - fsl,imx8mq-pcie-ep + - fsl,imx95-pcie-ep then: properties: clocks: