From patchwork Thu Oct 31 08:06:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongxing Zhu X-Patchwork-Id: 13857676 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2088.outbound.protection.outlook.com [40.107.241.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB0D714B976 for ; Thu, 31 Oct 2024 07:57:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.88 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730361431; cv=fail; b=I6xg8xEZxdZ+avVB0FMHTsfxI53Ut4PUwGw6g3xTaAckSn6oxzFbkRpJEQ+rRCGM/FRbFocrOncfGAjVhRAhSISlyrUNyXcfGPFUGiWmwp9Ckq5TpgmPZtEqfN8K6Xup+k0JQz3x7jXRqR/7878Vr3P7E+YyPdfdY6ilzjmfGb0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730361431; c=relaxed/simple; bh=6w8RYn1ibG5NVnncYNGrFsHIkIhj3Kb90A79geEGLdI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=eMkZWoWpNgAlnf/Nd4UoV+D8lAG5pc8RZH8aYpQTIBgRoV6GkchZn3tIsJQBFpoF1+TkOpAeaEpWqecnyHPgsS20yJjFOi6XqfrRWEnyE0i3l8UB1cXcGZCA3Y0naOcYuWdMjYL3s1Apw6/A1uQwM/88d9amiNwaUSXIY7ilKgY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=bQnFVW3f; arc=fail smtp.client-ip=40.107.241.88 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="bQnFVW3f" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Yy2A2Epom73rVMPrjmYQxSX/9hU/Rg+oyhuu0h2WsM6iGcj5VdubKho512SKCp2490kXI7z4rC/V4qGJffsZ6ehZH9mhv6FOhLA2S0BSZDNJftr/sXPTIx1uaNnd9aWj86CzzvX6t14oAwWu7nuw+9gqFEZVTaUxvPuXDQqFSXjqYi07yWha77+ErhVRIEBKvvsLon42EJ1X6sNjNi3lDwioC2ij7Y7nVcHGhmyvHb+ayzvyU5/eD2me8pe/UtSXdPteF1tGPq7b8adBSNjjxug369bWrMFDfNIRF+7imfHvQU2njciyY4Fx/zauLm7pPWthuQHM1GBMuBc1eWfMMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=HkWozaYB6c4gmku3Xai3zp9D5hIcsNaCS/eKBvHqTEM=; b=BUkZvmBCAe22K+OpbTEWSx1e9RwGzG//UwBVEC62A2IcW82S4QARDZx9fM5DaU6gTh/pSgkUvLPHfPJlW/S6LI5ocaUDL9Bl0apHggdiis+bidSytRSshgbUqAxExuMGmO3UEbMJFUpN554prsPJyIIsmLhSglGYBU//HCLrJnRt1b+fl9sc1nh3sl/N1t5G1avfpJWAYvdJb+tpZw2VRxPYKzzf03KPAoz/8L7jp9XG4ajQzB61rJ0pN7Be9oU6oqWX//hRqjC2cIXaYxcZJM2xtNrdK42BQZng2ngJVJetXc3D4ccK+D+X5bH4qSn5uNVRk31Plvrbgk7+zwgaYg== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HkWozaYB6c4gmku3Xai3zp9D5hIcsNaCS/eKBvHqTEM=; b=bQnFVW3f6h+tO33EIIIqunYI48MP2RorkbMjUQIOPKJ2vxdJVD68KheN9drY/fNW/RcDOv0UtM3HHgPNq0twDsp+FYKYrHp6F8ZgyLD9qhlS/mVrBhDJzaN0XNOQCS2nGHORJ7ZLqVGy9ysr+5Q+zW/OupcB8VwWm4+uwVY+x5/HGM3XkSrWhl1pwTpMFCJo6A5YitLkLGiBUSQ2jBE85cCgY9AY10bkFGobZxgelsQMZknCTmS14ylVF7z6ZBRMvboKzHC2oO++MuaEMyzX/j3OP3sEFAVOmMRZzYXR8aJvtGvyP8giOftBeRSqHBM1/fSFKsPr8xcGxu0LvkSIcQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8676.eurprd04.prod.outlook.com (2603:10a6:20b:42b::10) by DB9PR04MB8139.eurprd04.prod.outlook.com (2603:10a6:10:248::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Thu, 31 Oct 2024 07:57:06 +0000 Received: from AS8PR04MB8676.eurprd04.prod.outlook.com ([fe80::28b2:de72:ad25:5d93]) by AS8PR04MB8676.eurprd04.prod.outlook.com ([fe80::28b2:de72:ad25:5d93%6]) with mapi id 15.20.8114.015; Thu, 31 Oct 2024 07:57:06 +0000 From: Richard Zhu To: l.stach@pengutronix.de, bhelgaas@google.com, lpieralisi@kernel.org, kw@linux.com, manivannan.sadhasivam@linaro.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, shawnguo@kernel.org, frank.li@nxp.com, s.hauer@pengutronix.de, festevam@gmail.com Cc: imx@lists.linux.dev, kernel@pengutronix.de, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Richard Zhu , Frank Li Subject: [PATCH v5 02/10] PCI: imx6: Add ref clock for i.MX95 PCIe Date: Thu, 31 Oct 2024 16:06:47 +0800 Message-Id: <20241031080655.3879139-3-hongxing.zhu@nxp.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20241031080655.3879139-1-hongxing.zhu@nxp.com> References: <20241031080655.3879139-1-hongxing.zhu@nxp.com> X-ClientProxiedBy: SG2PR04CA0184.apcprd04.prod.outlook.com (2603:1096:4:14::22) To AS8PR04MB8676.eurprd04.prod.outlook.com (2603:10a6:20b:42b::10) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8676:EE_|DB9PR04MB8139:EE_ X-MS-Office365-Filtering-Correlation-Id: b2fd7a23-eb07-4190-c2d0-08dcf9819cf8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|52116014|376014|1800799024|366016|921020|38350700014; X-Microsoft-Antispam-Message-Info: csOaY+bnHa6WFnDqv/vQpszWPoWLgknzh4BWdK212QPq0rtWK7JGuDEIcDkSd+tNA7mMKckvmo7Rxrmr94zn3/qWLqSruBoylx71yMITpdZifRvE56T1gicr0jKGryNEG8Tt8UsDaf4aF9jXgYnO5VWQQO135zgvKXeTPVkgmoSx/2raBlbilqzTghl1Q33G5vBcsAownSLpe1pYVD3ZydNE15y27COTUdtED9dnCcfF3CryMYb0A4njiDGFZh46a8qhFAykOMwHtGb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3DpmGc/0FIPsN8ASUdpEhcdcGwL9ONT3VRt3FIHFqUpirN7c1dJ0J2nI+2k X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR04MB8676.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(52116014)(376014)(1800799024)(366016)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gubltHupomvLCQc9jZ5v7iL2McudcAkTu07T7dx7MGNgOG72XJaAAK7zcDfI+oQTQqztJtS5cdxZPQtoh2JJZ1ldrAH4vGJfZjtEkl4ZqN90/q1KWbgOPy574VYLUKP9w6bQajXatKXdCQ3Vg1jeKVP0YI7hwlrg60liBqoxc7st713huXM4EsG+DEuvwfPW5L3tQW5TJpwTJkec8TpGWaoU84hLj3YY5V4c3fv5SxSskYjzvKxhCytrVUPQAnnBA2Th750mMkp5MdCyVPCuRNCGrmTvXLNHDe1rzA1svwnB/NR8ntjYZR2sgCWQMMMP27Ular1veYCobqIz9Mg8IN7PaeOMaZE9z6pCSYs0m1wtxIpmI7HHGHG3CtO1rnFWGoWKGe1b3e17s8vZnFz5xj2DPIm3zHvyLGLwr1GM+WG6lR8nGHjL7vYf86PPH9bsVHuGjkS3XxzUxn9/M2LS8GxR/76bPrEM8TOkaCZTUJMP9f7AWNXUjhsN6tPT0UZErRvwIleQ2nBYX49htST3B7SnUvkN8eN19Ni9Ak0qSst6aGWsHdtYITljFCGV0dgbNC6u/iaBjB72uYCpqikrwLQOy0acBNcZew0TIRsry+jqR8g4K5B/BFXmITVMLdbdVRq4jnlo+wEZ7TkDsOHuw4WN9dtUton3ITGeuOUVbmnMrEBQPz0rjlaXiKcSIp3DZY0Prk1tPy2/8OIL9PRryysMnxGbvpt2USLf/S6cdsw5GLljuC7r1tE0NJHAlYJQfl+eyKb1EokKEYU4DuyMKI/cta0fvQ4H8eEfiGaDKa+wW9Y7k7D7tW/FcL4cDsN76qiJ2BLQMZW0+8Iwf80k8VopaHhYFhmQtmbBMDDAK3B/UDIPFQvRQQk9Wca9ovVr8Iz4I7EYFacMv0nX5Vq4UFE+8og9PiVa/iwoRgK/oNhEnqOQcacWJH1XVRFgxXS3yviFJH1pZFaKyeVwVer6QXor6JMHx5VjRZrQoSly0eWb17QHLLmkUL07v9DfCmOMG/0za+/N3m9izIbfiFx3PiKOGSTm3nrYkomo5AP7uQPh27+fzJzY9SoZunCzBuJwNummH31rZuSnW0ndvXY9M8iavuM3GaDUj/vwLZcly2iLxFP5EzsuLGcm+xrNHm3pLo+JM827igc+LubacItdjHEz776/iO71PJlYoL4ErYWsSp/GXRcnFOFXoSsE7ju1bHE1CijHf2/EhJ2zJ6E4id1XRtGgKp/28aT7hum7BcDhRlP/SaNTJXyPJlA6MMVe8CUDN7jbByR/8e3hwu70SJOJo8wHOpCEl7iwCP4Rikusvd9kTsza0OkJ+QdrYjbOBupaciOExTa4/49P6lnGNEvRjREsZ2v8zxtNAelqCPxMwRgBbJ1Wi25DJqcoyKRUpUoNXFaImbox5dT1ecds6sp89eSgYHx7exsUEBH7rC/ruyNKI8NTor77jw2yOjLw0nfuledJQH0LvnC7227clNPIDNYHT76lkNdnKrUw53mqVGUnE9WnznNBEPFqAtxdGY7eqmTEtGlHhbgv8czPPkUfriF2Y215kE4bY/ZTPFg+Weooi7Nta16g4sRJvXnF X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b2fd7a23-eb07-4190-c2d0-08dcf9819cf8 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8676.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 07:57:06.2352 (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: rzMD5tupll80yODrMMz9F4aSzBiIfc877Jv2qOSYatXFi/9sv80cnJoCAZmnJMVbrE53qdkqvrwDhcCTym0SFw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8139 Add "ref" clock to enable reference clock. To avoid the DT compatibility, i.MX95 REF clock might be optional. Replace the devm_clk_bulk_get() by devm_clk_bulk_get_optional() to fetch i.MX95 PCIe clocks in driver. If use external clock, ref clock should point to external reference. If use internal clock, CREF_EN in LAST_TO_REG controls reference output, which implement in drivers/clk/imx/clk-imx95-blk-ctl.c. Signed-off-by: Richard Zhu Reviewed-by: Frank Li --- drivers/pci/controller/dwc/pci-imx6.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index 808d1f105417..73cb69ba8933 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -82,6 +82,7 @@ enum imx_pcie_variants { #define IMX_PCIE_FLAG_HAS_SERDES BIT(6) #define IMX_PCIE_FLAG_SUPPORT_64BIT BIT(7) #define IMX_PCIE_FLAG_CPU_ADDR_FIXUP BIT(8) +#define IMX_PCIE_FLAG_CLOCKS_OPTIONAL BIT(9) #define imx_check_flag(pci, val) (pci->drvdata->flags & val) @@ -1330,7 +1331,12 @@ static int imx_pcie_probe(struct platform_device *pdev) imx_pcie->clks[i].id = imx_pcie->drvdata->clk_names[i]; /* Fetch clocks */ - ret = devm_clk_bulk_get(dev, imx_pcie->drvdata->clks_cnt, imx_pcie->clks); + if (imx_check_flag(imx_pcie, IMX_PCIE_FLAG_CLOCKS_OPTIONAL)) + ret = devm_clk_bulk_get_optional(dev, imx_pcie->drvdata->clks_cnt, + imx_pcie->clks); + else + ret = devm_clk_bulk_get(dev, imx_pcie->drvdata->clks_cnt, + imx_pcie->clks); if (ret) return ret; @@ -1480,6 +1486,8 @@ static const char * const imx8mm_clks[] = {"pcie_bus", "pcie", "pcie_aux"}; static const char * const imx8mq_clks[] = {"pcie_bus", "pcie", "pcie_phy", "pcie_aux"}; static const char * const imx6sx_clks[] = {"pcie_bus", "pcie", "pcie_phy", "pcie_inbound_axi"}; static const char * const imx8q_clks[] = {"mstr", "slv", "dbi"}; +static const char * const imx95_clks[] = {"pcie_bus", "pcie", "pcie_phy", "pcie_aux", "ref"}; +static const char * const imx95_ext_osc_clks[] = {"pcie_bus", "pcie", "pcie_phy", "pcie_aux"}; static const struct imx_pcie_drvdata drvdata[] = { [IMX6Q] = { @@ -1592,9 +1600,10 @@ static const struct imx_pcie_drvdata drvdata[] = { }, [IMX95] = { .variant = IMX95, - .flags = IMX_PCIE_FLAG_HAS_SERDES, - .clk_names = imx8mq_clks, - .clks_cnt = ARRAY_SIZE(imx8mq_clks), + .flags = IMX_PCIE_FLAG_HAS_SERDES | + IMX_PCIE_FLAG_CLOCKS_OPTIONAL, + .clk_names = imx95_clks, + .clks_cnt = ARRAY_SIZE(imx95_clks), .ltssm_off = IMX95_PE0_GEN_CTRL_3, .ltssm_mask = IMX95_PCIE_LTSSM_EN, .mode_off[0] = IMX95_PE0_GEN_CTRL_1,