From patchwork Tue May 7 18:45:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13657555 X-Patchwork-Delegate: kw@linux.com Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2045.outbound.protection.outlook.com [40.107.15.45]) (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 5FE7B16D4FA; Tue, 7 May 2024 18:46:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.15.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715107589; cv=fail; b=GKQlYalqlREiCXktgip80euLihPm7tj9YDQzbbiTU1oazVdI8VWsCJ8a5psWmGW2md7Z/78czuGJyvFE0CmpYYnqvAxF/Y+KPfwMXOze4XTp0pNiTk4OvlmqLtGmOysVUWHHwhHiLLoYG8577sjMkisALmpI1gnqQcssxaJBqgY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715107589; c=relaxed/simple; bh=YcV+bPfbQ8hPERCV2SDvifRpdqJ80QqWgg+hJThYFEQ=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=kqP1+TCzu/CzqK9l8YJLKcPlyRcgELuDC34678RPcRk/CZleyE4RHS4b5senfFIL1m/T6qRz9vZr6ucCAjcrvPP7VvyH3iXxZjfMKgT6NVqcFUq2FbXQDE8w5u1A8+LhQFfS0GU2IXPoniTQJ4kwSQbNsNtFLihh64UQxP+SoQ0= 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 (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=mPyY7mSE; arc=fail smtp.client-ip=40.107.15.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="mPyY7mSE" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mv6diUiM95Eu1f5Qu98gYoFhdKy1IJDvX2CGZlGAQh5gOKa4yp1+T4E7iGDjiEJqtns0iXUYYmoOyrHoxtZwtMJv/YbecXhUy2Xdhx77XH58XyiyMeVQUv0EK1Ikl/p6CXnMF/ZBF4mp9SETd1qhq3/cPMddAjQmFlENWwaXViSoXjkNLW5Pha+QC3KTxLrSE3hgOQFn4Myjz0cA9fKAi10SWQvXJ9dMt4tOTrBwx9oxUSrivqJXKP1fpqAqyucZOnd7VNtIEcgKLF1d9zwhArYp1qHLovhCvxwVv9bd/SyaAOiD+6Rn6OTYRTqXs/6MkCPMxlyd8ZYWZD1j7qALoQ== 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=vNogCV8zOg8H4Xb+q+NRE8ieQG+DU65n0HRUvVRx0GM=; b=dYZ0KDicNlRd4Y7XfbMuEzy/XpPCNitPtjNIW4b/7QoqrTzx/rGGEVd2k4nCATYrG162PRToF3K7Mb5oPebS3zFyZNyHoPFaVjxkGBDIKdm+/C6104nx6E+dj/byWSu8OmcLS2Q/GxxoaONktB0yFWj9SHYh9Raa3oVQ/wjIdH2rZTtBCIjAk1lm4N8P4kv8uyMJU2n0J3e4GheI7cMv9Ff1TECzdCuG9YTmhG2IzP+RbjrvubohrdhxcjqvhMJHDVhpGSWkMb0KyYXlQ0+IOFurj4Fc/hGsj8nifolo4cME3WnXvWOMMOy0wmnANPwiHE0ij1USOVBAdHrQUxYLUw== 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=vNogCV8zOg8H4Xb+q+NRE8ieQG+DU65n0HRUvVRx0GM=; b=mPyY7mSERXgH/us2NuPCyyeJL3DGanG0Md3X9f2dahFKyPAabBDFYSpVy2aBktSPJZ7s+DqDuv3LwQXXYqgKB8eBXaTJGbOxuJmvgXteM9bv9D82NAoz/LpD2qlVAUzXCsDhzXSIuvVlrUeCdLRP9OFvYnfsVWezQQue9IBJY5A= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by DB9PR04MB8204.eurprd04.prod.outlook.com (2603:10a6:10:240::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.39; Tue, 7 May 2024 18:46:25 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::1e67:dfc9:d0c1:fe58]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::1e67:dfc9:d0c1:fe58%7]) with mapi id 15.20.7544.041; Tue, 7 May 2024 18:46:25 +0000 From: Frank Li Date: Tue, 07 May 2024 14:45:39 -0400 Subject: [PATCH v4 01/12] PCI: imx6: Fix establish link failure in EP mode for iMX8MM and iMX8MP Message-Id: <20240507-pci2_upstream-v4-1-e8c80d874057@nxp.com> References: <20240507-pci2_upstream-v4-0-e8c80d874057@nxp.com> In-Reply-To: <20240507-pci2_upstream-v4-0-e8c80d874057@nxp.com> To: Richard Zhu , Lucas Stach , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Bjorn Helgaas , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Philipp Zabel , Liam Girdwood , Mark Brown , Manivannan Sadhasivam , Krzysztof Kozlowski , Conor Dooley Cc: linux-pci@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, devicetree@vger.kernel.org, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1715107574; l=1456; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=xoxDn+MAsMCimd0wOl6G3C1M0+8a1hMq0JrOR9jgWlM=; b=txg6As3KcI6mOVHnc0/xjYotiu8vNM79HNmEQ+CdRoAqJpUEZyzcsWQ8ZM5IFKNj6T6qZT/X3 maY87uil+5ZC3yKRyYRq1BDgEZfXWkehY48e56/mddt6SXn6YRcVqcp X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BY5PR17CA0026.namprd17.prod.outlook.com (2603:10b6:a03:1b8::39) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DB9PR04MB8204:EE_ X-MS-Office365-Filtering-Correlation-Id: b0a883aa-a5ca-4916-c539-08dc6ec5ffb6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|7416005|1800799015|52116005|376005|366007|38350700005|921011; X-Microsoft-Antispam-Message-Info: =?utf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7mpHP8pfOEBrLXBnVut2M53Jl5loGYH2bs8fFfKyKW6cujU7W?= =?utf-8?q?Cnuo1N6uK+6t0dlGAIgzvOJ9rZPlvYZ06+tLhC/YH1H99tWoCGsUDIKUjoY9mpHOs?= =?utf-8?q?vgRJz8Gg78TZEznlpx54kQUiI0ivq78fGaG9tA2CfzeGWA6DmBjhE8ujORatwEqcQ?= =?utf-8?q?nJXPAucIvpHJCMDm1ucXJpJgc6fefFKVAGejGDB8A6dBSIrH2LLeAsH22NYChZQF5?= =?utf-8?q?mnT209jMThA1iGYFoqRXUNypGvtyIA8udPp53m9Ud8NuXuAEPphIJtERf9ItTnCIz?= =?utf-8?q?0Rd9odJzuorTDctzlXCE44oQvaMZQWrnR4s+lsMnsB5GGsFQyacJGoYRKWvE09Epj?= =?utf-8?q?85iw94OnbAJDPI0u2yGQC8TGfW96t9t9PXOpiZ64vJDCx/oN1peI3OTzVZVdi/Q8o?= =?utf-8?q?hx7f1QbtfyZDN4Iwy2TC2Q2ven0O2AGqjz1Qs7fwfrNsN3zrvBn8t4aE=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(7416005)(1800799015)(52116005)(376005)(366007)(38350700005)(921011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?nXRZLL6H/2vNUq3Rg835h9YhVc4V?= =?utf-8?q?LmKgREfDnJkJkGpgUevcPExOSBLEfO9fGE7bREI7/Dwyatw5e71UG4zoilxhR6qdJ?= =?utf-8?q?0L3nX8Cpt1QNvJSK15UNnwTKtFisAzhr0nfS2pBIPb7pI6uP8T2VcZxmOOHymo03s?= =?utf-8?q?CmYXlq19fdUf+I4U4KQu2TBLwa6PedQkfqJOtv3oJXmi7LnSOaV2qUVGaPxW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vQXcUBo4y?= =?utf-8?q?O2kzTXjs45z/2a/iAfh46E5T9JtC3Z0tP7A66FIUPQUeNt1ydLR2KLOINBvFLB7UM?= =?utf-8?q?V7JP0HxMoawaHMJgvtC+/v5y7Xr6Nznl5oBtLwmpzeFeCF2uUJWmjKeJDWavi/zlQ?= =?utf-8?q?ZeeI+F9dmdzOY0nCzICSCjpilySrWd9z2gl7o3vwnsii0AuWrfGmy3FPXfwSZOH/Y?= =?utf-8?q?hnwcYiuXeyTdK884ZZDb1vVz3w+4gBMbj8mPw7PTi36D5sytGkRrHN/C26v29o+Cl?= =?utf-8?q?M8sA9eAyXFUrRnjTen8Xr16VBtyNeIHa30mUggInJqkzdE6/qCp0r9WHxv81u44vW?= =?utf-8?q?WsUd8GYEhbaouNQgUG4dN6tE8Xp/2gcERoT3c0VdE7UynmedvEjll6zHl6REaR2cS?= =?utf-8?q?2r1oo8+5qIQhv4NNlDGzcildsb4US6/3J4OlEcMkjRvqZCb7oqYJa9ZQHKOAckoNV?= =?utf-8?q?s7vJC2AJldt4?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b0a883aa-a5ca-4916-c539-08dc6ec5ffb6 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2024 18:46:25.8500 (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: G9tM9vHOWeDxWLNloUwmejTGTR2Uopf+f/2HHieWGAgcPq/Q92bUBzPczK7hzWqChZKjm1gjaPpJQSMrgTEiQw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8204 From: Richard Zhu Add IMX6_PCIE_FLAG_HAS_APP_RESET flag to IMX8MM_EP and IMX8MP_EP drvdata. This flag was overlooked during code restructuring. It is crucial to release the app-reset from the System Reset Controller before initiating LTSSM to rectify the issue Fixes: 0c9651c21f2a ("PCI: imx6: Simplify reset handling by using *_FLAG_HAS_*_RESET") Signed-off-by: Richard Zhu Signed-off-by: Frank Li --- drivers/pci/controller/dwc/pci-imx6.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index 99a60270b26cd..e43eda6b33ca7 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -1568,7 +1568,8 @@ static const struct imx6_pcie_drvdata drvdata[] = { }, [IMX8MM_EP] = { .variant = IMX8MM_EP, - .flags = IMX6_PCIE_FLAG_HAS_PHYDRV, + .flags = IMX6_PCIE_FLAG_HAS_APP_RESET | + IMX6_PCIE_FLAG_HAS_PHYDRV, .mode = DW_PCIE_EP_TYPE, .gpr = "fsl,imx8mm-iomuxc-gpr", .clk_names = imx8mm_clks, @@ -1579,7 +1580,8 @@ static const struct imx6_pcie_drvdata drvdata[] = { }, [IMX8MP_EP] = { .variant = IMX8MP_EP, - .flags = IMX6_PCIE_FLAG_HAS_PHYDRV, + .flags = IMX6_PCIE_FLAG_HAS_APP_RESET | + IMX6_PCIE_FLAG_HAS_PHYDRV, .mode = DW_PCIE_EP_TYPE, .gpr = "fsl,imx8mp-iomuxc-gpr", .clk_names = imx8mm_clks, From patchwork Tue May 7 18:45:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13657556 X-Patchwork-Delegate: kw@linux.com Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2051.outbound.protection.outlook.com [40.107.15.51]) (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 28E0C16D4F6; Tue, 7 May 2024 18:46:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.15.51 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715107595; cv=fail; b=Fi2KPRByk+KgYHQP2vBe51jW3HDz66vvC9vUWj/DMdlqdgjrUHssZprq6BRG8UwDmCJoigF9ZxN8W9vX13/egqU6DiYHbM6M1jstPvwBs+hUKg9L9VQCGu5GjXLC6jchmblF48TsCuVZEI2qIDOXHha1z7EqQfIy6tAcPd7mB8A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715107595; c=relaxed/simple; bh=OgpauZFcGum+MIZkOfelPjFuUuL0H86OUPMoXcG8FfA=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=G6pGG9RI9DSt7dolpK58mUnmPpYjauUcXncQwAxPfGkNqnP7w48EqHFm9oi3NYD66KaWLDMFKtZEnxNTmlJJ6FccZ8ubdReTPi2OyOFq0oxQyWKQ+3I+uf+hNXWgYekGNdnOKSKQ0MOEE65vNs5gx6ultnpmZnBcAg0cvYs0J5k= 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 (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=kA5dPyB2; arc=fail smtp.client-ip=40.107.15.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="kA5dPyB2" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IMjsteSB8W0YXCpAvrCc/ogQip0X8Fw3L7yPbDyLpFEUJg2shX1IYPvZnfWB7NnX9N8yBxH6N+qUDixeEKmuw8Ms2mNbVBnPwz2rmkxQ2YagcCI2RJSHfP0HAZe9CP4zSdtTBkGTrYlNHRu/FA5x4RDpWOk6k2QdY0tWHI4UAg6OFpa2F6hdXyG6YPc8TcmoLD7r8Cw8bVPoWjnFYUnocHvLd89VwAnoCHlgu1gODHnorqFo+8JuVVE1Gp40onK3lNfk6vAmoxZ1VTCbRL9iVHORY+5CBd2qEDFcZ3g9jF6UoXwubo3xyNuPTS8bgmzNbMs4GSWCVhGCd3GxKixi8g== 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=zrkaTSZzqqw8GcBn/WHt/2B3DkpbPCMJ0WUaK9Q0H5k=; b=Duc2VXJm2+T9+jPBk7whvHD79m+GjrPMVZ82AM4SxIb1QYSFHHhtQQT7HOpD5nD1BV0SEVldVRM51c+YZS6SPMPfoDM8DjQCdkw10SLncMcWZkBMGd31+2+Jt0z3Lw5hORy+hfqvPG9pxBfMq96JAhfHYZWv6aqJ18FDAvF2jUFrp8PBvUWm0r+R4+vOGYOnLMR75xNZT9W4830+WUOlXW4YhSUBJr1jSEuxREqn/naJB7rTFZ8Dng1VooKSMGpt+Qa6L9kGoes7GxNoMNsMIOPXRdesIe9/bzkGuPEnjDLJ2EeGUhs87/8EFOl8wAuJVCFLp8GYMOM5KBWm0WMAlQ== 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=zrkaTSZzqqw8GcBn/WHt/2B3DkpbPCMJ0WUaK9Q0H5k=; b=kA5dPyB2T75oPiOQkMN7xCJblS5kKeBwA+zzTyao0cdOrlsz8D+HrEQCAhLr3u20w+Yhvs7USQ/PRm31dKgI8uqic9XkUdGPJATykcueaR20QNrOxA4Cv1P3RNC9M071Hfi6bcaFjk6H9rBesi2VPj71PzVUtrnG+iuMAW+KM+s= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by DB9PR04MB8204.eurprd04.prod.outlook.com (2603:10a6:10:240::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.39; Tue, 7 May 2024 18:46:31 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::1e67:dfc9:d0c1:fe58]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::1e67:dfc9:d0c1:fe58%7]) with mapi id 15.20.7544.041; Tue, 7 May 2024 18:46:31 +0000 From: Frank Li Date: Tue, 07 May 2024 14:45:40 -0400 Subject: [PATCH v4 02/12] PCI: imx6: Fix i.MX8MP PCIe EP's occasional failure to trigger MSI Message-Id: <20240507-pci2_upstream-v4-2-e8c80d874057@nxp.com> References: <20240507-pci2_upstream-v4-0-e8c80d874057@nxp.com> In-Reply-To: <20240507-pci2_upstream-v4-0-e8c80d874057@nxp.com> To: Richard Zhu , Lucas Stach , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Bjorn Helgaas , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Philipp Zabel , Liam Girdwood , Mark Brown , Manivannan Sadhasivam , Krzysztof Kozlowski , Conor Dooley Cc: linux-pci@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, devicetree@vger.kernel.org, Frank Li , Jason Liu X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1715107574; l=1357; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=ol8CdKOtRGfAfsl8PVkNMeRQytaQpVg/b6Q5f4hgeBo=; b=kfE4VU+auk2OhfU4mAa+5x3eXAFW2Gnjj2rphlD9YN/sg5IHSwSNmM4pIo1eWAPtsBvzc7ar0 h4B6uEzoTytCPYgT70kExZGyRcVHi8AxIORRMbJVl13dpRqeKpzZbyP X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BY5PR17CA0026.namprd17.prod.outlook.com (2603:10b6:a03:1b8::39) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DB9PR04MB8204:EE_ X-MS-Office365-Filtering-Correlation-Id: 21d98d75-2c3c-4153-5e34-08dc6ec60317 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|7416005|1800799015|52116005|376005|366007|38350700005|921011; X-Microsoft-Antispam-Message-Info: =?utf-8?q?AFF0zKpWxvHHFFievnuHLISiMi7Kkjj?= =?utf-8?q?nvzCwdM1QJbt24TcM9xIGk3HVRlqE2ujmLkyl04Fy5wHOwcbwBytYf4T5c2P9UNQ5?= =?utf-8?q?UPmIF2BCdyJKH4+CG+nRFzNGBU9El6dRE9zmu+Kvz4iL0uWMMYdPgcyQmJHSdh92c?= =?utf-8?q?YLWDhf3LnnA/TDpwu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/4tRSx9+YEdyL2CrJktaGsnLn8JTCMBjUe0J2ao4iMhe?= =?utf-8?q?nFUYR3T5M0PT00H8X77hOxZNO08pAsCKf34GS373bkjdnXYKmvOIyA6eslRXzPe9W?= =?utf-8?q?XVU+pPsZdclnJ7WjURyXJfWM1X5d5K3LZ8oCiMNfyl9GfbMRC+y/JcTyE2FiWlLRD?= =?utf-8?q?11uMtMNf1I9ep8KKo+YkC0o42x27YgNG2p7IRzKde6bMLICGiYYf7ZcKB51Wl6LSr?= =?utf-8?q?jdd35zjCIhrseex5YY7o7UwStUYRaFIcDgefp3Da2i1y9qdcxkYdatGI=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(7416005)(1800799015)(52116005)(376005)(366007)(38350700005)(921011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?+VmpgFMwI0sjoRoK6xd0VgI09zmo?= =?utf-8?q?6Hf2iUTWaYo3kQD9Ay9rqdHQ9EUED7zZOgrdfeCvSyKDG1wL2bPB0lQnbDyeNCMal?= =?utf-8?q?01dcxhNeCUVvs3hREe1RYvRTar36RipxFUQpQU2Agk89NFSS+9Kmxd2Xbl863CvkK?= =?utf-8?q?thDv6ZBlCTiEr+QWHCfhiwOxUxw0zzlvDte8t156HPl6uri9QDHmoYL2alCFV5L8g?= =?utf-8?q?QoHVjIYiKG+rN9q964jQFJ7isWPCTXQtli/RNdOSzRW5L+sEfyK+58q7vn5xS3uEe?= =?utf-8?q?uMFuhe1YOxg0289SJMnKZlznojXqpnxwFSZTgjLR0yaDYe3IxqfZz+GfeoKCeIdCP?= =?utf-8?q?KuhOrxf/vhOB3lZ8XJQXdpfILBROrQTOc/kPrvkQ+OXCYlyLoEcFf4npTX8zaZhp2?= =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?2tBK6jaOoGdfu2ynB6sKuBBJqJogUcmMPSSjCsHKCacgRxONNjeMB/z956d08/xX7?= =?utf-8?q?fYKlXzwhGK9qvGNd3MiHFCqpdIM9QUfKt3KPfaFV4VDspwm1LUEixHF+2xJFLt9Hi?= =?utf-8?q?2T6pBAI0mJPK+r6GUQnE0i4mly2quw8TUXkjDTZngoTFS47AQIQOi2r5HXkaLaL5h?= =?utf-8?q?9an/eyCL8QHCPHsVdF1bW4s3JDRdox55iIFYHyHMxlwQVg2ogARtv3IoE9tQ1f+LX?= =?utf-8?q?uIM1aqjiNcE6?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 21d98d75-2c3c-4153-5e34-08dc6ec60317 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2024 18:46:31.5050 (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: +4Eyfj4Df6/2karId8j7zLFiljMXNwsHVqZVzqwxrwyKCntBHXWljCfu+lLb4vLbYVzDIRjS4Yd5x9tAe71uxQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8204 From: Richard Zhu Correct occasional MSI triggering failures in i.MX8MP PCIe EP by apply 64KB hardware alignment requirement. MSI triggering fail if the outbound MSI memory region (ep->msi_mem) is not aligned to 64KB. In dw_pcie_ep_init(): ep->msi_mem = pci_epc_mem_alloc_addr(epc, &ep->msi_mem_phys, epc->mem->window.page_size); Set ep->page_size to match drvdata::epc_features::align since different SOCs have different alignment requirements. Fixes: 1bd0d43dcf3b ("PCI: imx6: Clean up addr_space retrieval code") Signed-off-by: Richard Zhu Acked-by: Jason Liu Signed-off-by: Frank Li --- drivers/pci/controller/dwc/pci-imx6.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index e43eda6b33ca7..6c4d25b92225e 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -1118,6 +1118,8 @@ static int imx6_add_pcie_ep(struct imx6_pcie *imx6_pcie, if (imx6_check_flag(imx6_pcie, IMX6_PCIE_FLAG_SUPPORT_64BIT)) dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64)); + ep->page_size = imx6_pcie->drvdata->epc_features->align; + ret = dw_pcie_ep_init(ep); if (ret) { dev_err(dev, "failed to initialize endpoint\n"); From patchwork Tue May 7 18:45:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13657557 X-Patchwork-Delegate: kw@linux.com Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2058.outbound.protection.outlook.com [40.107.8.58]) (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 7490D16D9B8; Tue, 7 May 2024 18:46:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.8.58 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715107605; cv=fail; b=Vhro72PWYIxPjx58YAXJgLYiFvLsl2+/q8CDoOb34Q9YyZn3Bnv7hk9MYkXsjYjciIvo163c5/lDCQaCgNblIBWN49kGopVFO15PVh0OUbeZIr9KvaBLUdlU0asdIWdxAA6CdfIF1Lmnc1UDvi5sjymy3aXsEeyaeIiEdvnWN/g= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715107605; c=relaxed/simple; bh=HCs3Wou5DFarLwoI6aIxuSzOvMEjwtlZi8aqBlBUjdA=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=QI1OPjfuHvDKFYLF5Y+NL+rpI5ddfQWY536TdxiiOx55sertKe5tPfSKlhQbWuRFiPOMLjxbl8i7G9Q0xmtPMwTJsqf0vDfJtAUypza+mpnLi+DFhDJ/BAbexFrEjET06WqaDk3iG3bgOh0i3NvvKuuOsqMTRgWjgXZ8nliG6JI= 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 (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=iY7MDhio; arc=fail smtp.client-ip=40.107.8.58 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="iY7MDhio" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NccucNeq7bIg7BOUD42CGWM9vn4MQctgV6XTMXfZEQVDk8tb7RzoilawAEFtIk3SdRBTLE4pd88IqMuj186UYVz4riiGfjLc5OAa5oM1tp9zM4Txs1zbHt19xXcfzF1y+thbt3mgnDvumsTjUPP70Jmxal4syK3Xb642e6X/igs4F6kgGuwnawLtuhEV17PFIa7EwoqmUlQJNnXoiq7SqJzjN2O7Pl/cA0Bv0HA/wenxtZH4YJmKvZLYZ7KJnRK6vQMF+SCbutCXYQicTAGnMpVQHKnMDLaVVLl8RBiv2S0cfjYqkH6fquXJQZgvTjrqr8/JOe3VygF3+HAaMo6b+g== 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=erpcWbumm90hy5oYfTa/e6aTdCigYZ4TJDrOE+jefNg=; b=MRV4oOaQyjBbqDTJdmVUzJKhN+f5Cu+U0ZWqcGDC1kig3rsmxsQimUSG5+h5O9nK4Yn750nSmvmCuDv+RymQsfUJCYP/A4s5JtAC9rhLbmF8xEtjKRtduxDrysoQybWT5aZk5nxhdTMS3osbGJq5bbz7hW+9FGQQ28mvrbi+nYOk8j2AiohQEZy1RR2jrpsHzByY8LCHlIJHiMS9ul7/OlYmO5kVrKGIuYAtuvQ8m728ggVKEI9aGqEnH6m4NsBbB2sqwf5Ui7hQZTLTamkvndqSaaEgCw8mRK6nMCk3bhVeJwGQrFXMtYhQvuqwg/LjixUIKpDQk43xHvmL4ZqLLQ== 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=erpcWbumm90hy5oYfTa/e6aTdCigYZ4TJDrOE+jefNg=; b=iY7MDhiocP7gfJlh/98YshwcqMQLQrT21E3GWrXZAmweATirJOZuRXnKr5CPcAeMv83DhQLfImgG/Anu02tQYl6JICUOjlyMCNRvnpVyTkcbgyAMzneH9MpMC8g4dHABFdczCOTEqc8CHl1wkKYnbha8kJr1Pr2HYb5kNvIzris= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by DU0PR04MB9636.eurprd04.prod.outlook.com (2603:10a6:10:320::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41; Tue, 7 May 2024 18:46:37 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::1e67:dfc9:d0c1:fe58]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::1e67:dfc9:d0c1:fe58%7]) with mapi id 15.20.7544.041; Tue, 7 May 2024 18:46:37 +0000 From: Frank Li Date: Tue, 07 May 2024 14:45:41 -0400 Subject: [PATCH v4 03/12] PCI: imx6: Rename imx6_* with imx_* Message-Id: <20240507-pci2_upstream-v4-3-e8c80d874057@nxp.com> References: <20240507-pci2_upstream-v4-0-e8c80d874057@nxp.com> In-Reply-To: <20240507-pci2_upstream-v4-0-e8c80d874057@nxp.com> To: Richard Zhu , Lucas Stach , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Bjorn Helgaas , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Philipp Zabel , Liam Girdwood , Mark Brown , Manivannan Sadhasivam , Krzysztof Kozlowski , Conor Dooley Cc: linux-pci@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, devicetree@vger.kernel.org, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1715107574; l=59933; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=HCs3Wou5DFarLwoI6aIxuSzOvMEjwtlZi8aqBlBUjdA=; b=XLCaxA+7UHo0i46rF7W4IF6sFAxTxNnuPjpdpb4on9hdIlpb8WI+EZU/heOXpea4oRqtee9hj 9INvus67tj7CWdBRHPy+hxM+VoMq7CM7nWMI69QG8p7M6yPtrh5R+81 X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BY5PR17CA0026.namprd17.prod.outlook.com (2603:10b6:a03:1b8::39) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DU0PR04MB9636:EE_ X-MS-Office365-Filtering-Correlation-Id: ed9855b4-b6ec-4236-a5e3-08dc6ec6065e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|376005|7416005|52116005|366007|921011|38350700005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?h+DsJJEK9DR8z95uwNmlZYo95sf7qAH?= =?utf-8?q?UhMcexXRcs0VXaXybKEyBFJ84SzTOdzcNams0/4CHBy4Wjto1EYH/isx6rawuvUme?= =?utf-8?q?Ch9LwGym5OVuW4c+WlCemCWiX7Yi3Eu7FLrNzomsHtm/0cpCVOuHyA1No+PMskdNO?= =?utf-8?q?a/DnyFMhT+sCPzaw1GeqBCfbJgd97PnxAdjnAcXMJBbHKDt7aO/nnaB0fdNUkv6hP?= =?utf-8?q?+v6YvWCQnjB644DvhoZTBHBl5GoVEDb/FA6+NiWcVwtVysyXW8+So5TaPCzNdGmX2?= =?utf-8?q?JmNRr8ARmH9SMHYLHR2zYFJsJ20MIrV3Ls9OxjT6FPb4Qd2c3T/ACPl7tIZnByIBY?= =?utf-8?q?yxsOoJ5EmTymTLiHFjmZas+C6aW73Ofa+Fa//wvvZCGi9IlcCtPGaQZGnQVEITBEb?= =?utf-8?q?8ZTkB6FfO83VyaVKxYqm4/aYurMgo1OEo4JbFcaEdBvWLk1ehM0cartu+5voGBkjB?= =?utf-8?q?BZdROJCk1rJM859tz4La7gq5/3DX1mcwF+gwMeKscHVhQdDT2kDb5Tf0gm0Y31Qb6?= =?utf-8?q?ZUlr53V3Tm1+gOX4fP/VSQinCxBFC7HCo0PUDx4sSzS5FBtikMUcNHnXE91KN5oSY?= =?utf-8?q?B9rewuQit+K+mQ9Pzefsgv0uexyS/Lb4hvqr55iZg0T+KAo1DO8zmeugHVYwymeKe?= =?utf-8?q?feErYiYjlPd9YaUdt/VRDTCADtLYxKyabEycpzpTitseQesllYYPlNbm1y/tIL7sH?= =?utf-8?q?0f7z9pgbUXyvM4a6HsVeCkQGdZhU1Oa0lEyuWPxOcPrn6v7lNrtRiK/jxHXhqx9Za?= =?utf-8?q?TM5VmBQIA7l2dGGfO60sYk1XDApFWsq2FvumLcwnTBU1AxW5pDONMydK+F3Nqvcg9?= =?utf-8?q?q7m2bQTGT+ZdMVCn92R5jardy30CHAzpyiU5NDRWSz92kQdbJG+lYiw/OZRqSBcT6?= =?utf-8?q?QieNzDHsnDS7otMnTV2KTdGes9+8ymRq4WeWbez3fhIZLciwEXPKjKXDWAYaOo6zn?= =?utf-8?q?ojz5hHNZ4FW2/2oP9hUcx9pNVunSucmr4tIy0fc/QBMNVa/SID7ZkOF3RAyms7dF0?= =?utf-8?q?l5WYXdynTbGaujOq8TsKyU/HEAa9syWG/5jH4Y+sdx1R7GueXIncQpdfqpYKc4se/?= =?utf-8?q?m4GZj7VeT0paEPz6Z7h2eU+A0+P4BbiY9uYHNkYNKNxqc7zKOBE3CN0q/JHJlybQT?= =?utf-8?q?71wvYtNESfJw9bN1mE/dZWbf6iVqR0VvZ8h5cR79aM6ToUTX923IeA1VnMFRt4ENX?= =?utf-8?q?sqM5gbJC+sd/zYxI15EpjFogZmCvayA01caIby7gztw4tor2oQHOk9nAuojeD780r?= =?utf-8?q?spFFEUFYR/fI41FESQpMdmLrrhfZMpMW5ReMCGJxalPOdrfWad0kut0M=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(376005)(7416005)(52116005)(366007)(921011)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?OQlAQqbqVd0qCv+xRcdMzhXKTWX/?= =?utf-8?q?pzlVFB56EqftzV7fsyTpVdUHy4tkBLsTmqt7AB4x0GVjUdC/e8SGau2ZZM/WtwJ7S?= =?utf-8?q?h3PCf3EWPyTxNsnrvn8yh2iDP1dxYGIAc9nLq84ER8nApXxFPOMz1YwXlHoFT+DX9?= =?utf-8?q?0ivY5sHJwhNEPfBGQsNjub+s3zuxEDnk6Sdf24zuXvPbWcVHLu5gC7PWtILoHjSye?= =?utf-8?q?KGadFkhhSWcTcbmh/WmyCt7vE4VqQA4ADPh73uLSaESAAWkZWnRgkUcedmt6cv6ge?= =?utf-8?q?rQjQBo5S/tNPIwltZ4KVRTXfAsp29SiAx5p/yYW9d1eD+McNpuGUUtfRDqvcGV4Ed?= =?utf-8?q?z9LxvMcE6fAgYc0C9WhA+LOjs7rk0cwF+PCkfeclfeXQ7zB5O24jbegI4JWnMyPQj?= =?utf-8?q?2HI4Siw8fj/hLn7E7HNNCzvGEC48RJQWVfxfy5QelefvCPm6hPwajPyNPGXrIa6nB?= =?utf-8?q?25WugZgv2b6YImqNaL3ETghtIM7V8tUFhNX8Fp5mi+K0MsYGTd1H5WXV2qkcpvatK?= =?utf-8?q?6NU5foRPPIOOkrHshgQ4ApxS95IP08faTcFM11WmTF/P0OKdnlUKRsp64Kmk6k928?= =?utf-8?q?8uSwvaIWzIL+dJAcmWUQuaPg8zQyEQUvoEsm0LbcXy0elnR9UCz1famh8evxzPkq+?= =?utf-8?q?U2DWlb4GgmJEmAU7ivjmVT3V6SR5jqnskrSKIPHoJ4m292tVc7LwcQkb7Ibd13xe5?= =?utf-8?q?jPzwiDtcC2O4yB7uLxdvmzfe07TKZc9iTKzQSVM83AvPD2N5patkbuKO6kmc+asTV?= =?utf-8?q?ZGMtBqT225oVNJqaC8mmaMQpqj3clhzg96UQR+osqMWIWkMFEvvg2CkSr0DZGzp/q?= =?utf-8?q?8GQFcVq3CNvd4QLBjCp96+PKklxDHDgiCXl4/7KViw+qWkatfH8ChUOkBqssjWw9J?= =?utf-8?q?eomHcZcE4AFaTMOP26RGZbmGXqrv2IjlPgzfN3tsCNo9psQt6uaKCVc2t/Mu9zxeY?= =?utf-8?q?Dtcj4sQUThr0RGFVb3h+sN30G+B+K/gcwHvdZ87lQ8kCLgswfKk5TsyZcylyvMGQ8?= =?utf-8?q?+VtFfQBWLppSXOf+tZaMTbJbHNRCgWOZ6kdo8hMfgUZvNIcvKdZwTzsVXhMdXHFnv?= =?utf-8?q?bGetKdLWbmjPr2TH3pjDQ19cJZBNutJ1yFX5DDg8TnFJ+zUN99Li3Bkjbg+8UdRTg?= =?utf-8?q?ytalXVjeWm7yAeud0AcOiq1u21mlorj9k1sjT3mgyj7XA6sgkStCzNtJYAJx5uPMr?= =?utf-8?q?XLN2PvpPOykPijii7znRG9nwoiEQjKrv5swQlIf6/9MLVrgZ00r8xu7WRtwa66wUr?= =?utf-8?q?FeyhAg9oO33eguS+K8DGN3hx6OA9cd/TPlR03l24v32gnA61BzLsm6k0cgNu9vRy3?= =?utf-8?q?KsGFDZV2LaVj/AqK7Z23ftq+rBf+STBkU+j1PDqz+KuIkDc8sO75rW7e05k4axtFP?= =?utf-8?q?9fXf0P5bLuARpuMcoMecB64WwybKIBLUMRtVqhtF+En3sY1nwaSt2U/oWbWbXfMyr?= =?utf-8?q?c3TucvHcAhU4fgkhhajju+bJXiFN5XJ1P4gU58I72kY12Yeg2fY0Iro6NxTvsb+t9?= =?utf-8?q?fKEj2VjVEYs0?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ed9855b4-b6ec-4236-a5e3-08dc6ec6065e X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2024 18:46:37.1902 (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: RNbxieO+q/2Wm3ufWJ3CTJrgBhiW9hWawuqL4yHjE68fsfZsYUDjuw6eB5JmA7CTlpuHhkXQmR4OEm1sX7OQlQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9636 Since this driver has evolved to support other i.MX SoCs such as i.MX7/8/9, let's rename the 'imx6' prefix to 'imx' to avoid confusion. But the driver name is left unchanged to avoid breaking userspace scripts Reviewed-by: Manivannan Sadhasivam Signed-off-by: Frank Li --- drivers/pci/controller/dwc/pci-imx6.c | 760 +++++++++++++++++----------------- 1 file changed, 380 insertions(+), 380 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index 6c4d25b92225e..e93070d60df52 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -55,9 +55,9 @@ #define IMX95_PE0_GEN_CTRL_3 0x1058 #define IMX95_PCIE_LTSSM_EN BIT(0) -#define to_imx6_pcie(x) dev_get_drvdata((x)->dev) +#define to_imx_pcie(x) dev_get_drvdata((x)->dev) -enum imx6_pcie_variants { +enum imx_pcie_variants { IMX6Q, IMX6SX, IMX6QP, @@ -72,25 +72,25 @@ enum imx6_pcie_variants { IMX95_EP, }; -#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_PHYDRV BIT(3) -#define IMX6_PCIE_FLAG_HAS_APP_RESET BIT(4) -#define IMX6_PCIE_FLAG_HAS_PHY_RESET BIT(5) -#define IMX6_PCIE_FLAG_HAS_SERDES BIT(6) -#define IMX6_PCIE_FLAG_SUPPORT_64BIT BIT(7) +#define IMX_PCIE_FLAG_IMX_PHY BIT(0) +#define IMX_PCIE_FLAG_IMX_SPEED_CHANGE BIT(1) +#define IMX_PCIE_FLAG_SUPPORTS_SUSPEND BIT(2) +#define IMX_PCIE_FLAG_HAS_PHYDRV BIT(3) +#define IMX_PCIE_FLAG_HAS_APP_RESET BIT(4) +#define IMX_PCIE_FLAG_HAS_PHY_RESET BIT(5) +#define IMX_PCIE_FLAG_HAS_SERDES BIT(6) +#define IMX_PCIE_FLAG_SUPPORT_64BIT BIT(7) -#define imx6_check_flag(pci, val) (pci->drvdata->flags & val) +#define imx_check_flag(pci, val) (pci->drvdata->flags & val) -#define IMX6_PCIE_MAX_CLKS 6 +#define IMX_PCIE_MAX_CLKS 6 -#define IMX6_PCIE_MAX_INSTANCES 2 +#define IMX_PCIE_MAX_INSTANCES 2 -struct imx6_pcie; +struct imx_pcie; -struct imx6_pcie_drvdata { - enum imx6_pcie_variants variant; +struct imx_pcie_drvdata { + enum imx_pcie_variants variant; enum dw_pcie_device_mode mode; u32 flags; int dbi_length; @@ -99,18 +99,18 @@ struct imx6_pcie_drvdata { const u32 clks_cnt; const u32 ltssm_off; const u32 ltssm_mask; - const u32 mode_off[IMX6_PCIE_MAX_INSTANCES]; - const u32 mode_mask[IMX6_PCIE_MAX_INSTANCES]; + const u32 mode_off[IMX_PCIE_MAX_INSTANCES]; + const u32 mode_mask[IMX_PCIE_MAX_INSTANCES]; const struct pci_epc_features *epc_features; - int (*init_phy)(struct imx6_pcie *pcie); + int (*init_phy)(struct imx_pcie *pcie); }; -struct imx6_pcie { +struct imx_pcie { struct dw_pcie *pci; int reset_gpio; bool gpio_active_high; bool link_is_up; - struct clk_bulk_data clks[IMX6_PCIE_MAX_CLKS]; + struct clk_bulk_data clks[IMX_PCIE_MAX_CLKS]; struct regmap *iomuxc_gpr; u16 msi_ctrl; u32 controller_id; @@ -131,7 +131,7 @@ struct imx6_pcie { /* power domain for pcie phy */ struct device *pd_pcie_phy; struct phy *phy; - const struct imx6_pcie_drvdata *drvdata; + const struct imx_pcie_drvdata *drvdata; }; /* Parameters for the waiting for PCIe PHY PLL to lock on i.MX7 */ @@ -186,28 +186,28 @@ struct imx6_pcie { #define PHY_RX_OVRD_IN_LO_RX_DATA_EN BIT(5) #define PHY_RX_OVRD_IN_LO_RX_PLL_EN BIT(3) -static unsigned int imx6_pcie_grp_offset(const struct imx6_pcie *imx6_pcie) +static unsigned int imx_pcie_grp_offset(const struct imx_pcie *imx_pcie) { - WARN_ON(imx6_pcie->drvdata->variant != IMX8MQ && - imx6_pcie->drvdata->variant != IMX8MQ_EP && - imx6_pcie->drvdata->variant != IMX8MM && - imx6_pcie->drvdata->variant != IMX8MM_EP && - imx6_pcie->drvdata->variant != IMX8MP && - imx6_pcie->drvdata->variant != IMX8MP_EP); - return imx6_pcie->controller_id == 1 ? IOMUXC_GPR16 : IOMUXC_GPR14; + WARN_ON(imx_pcie->drvdata->variant != IMX8MQ && + imx_pcie->drvdata->variant != IMX8MQ_EP && + imx_pcie->drvdata->variant != IMX8MM && + imx_pcie->drvdata->variant != IMX8MM_EP && + imx_pcie->drvdata->variant != IMX8MP && + imx_pcie->drvdata->variant != IMX8MP_EP); + return imx_pcie->controller_id == 1 ? IOMUXC_GPR16 : IOMUXC_GPR14; } -static int imx95_pcie_init_phy(struct imx6_pcie *imx6_pcie) +static int imx95_pcie_init_phy(struct imx_pcie *imx_pcie) { - regmap_update_bits(imx6_pcie->iomuxc_gpr, + regmap_update_bits(imx_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, + regmap_update_bits(imx_pcie->iomuxc_gpr, IMX95_PCIE_PHY_GEN_CTRL, IMX95_PCIE_REF_USE_PAD, 0); - regmap_update_bits(imx6_pcie->iomuxc_gpr, + regmap_update_bits(imx_pcie->iomuxc_gpr, IMX95_PCIE_SS_RW_REG_0, IMX95_PCIE_REF_CLKEN, IMX95_PCIE_REF_CLKEN); @@ -215,9 +215,9 @@ static int imx95_pcie_init_phy(struct imx6_pcie *imx6_pcie) return 0; } -static void imx6_pcie_configure_type(struct imx6_pcie *imx6_pcie) +static void imx_pcie_configure_type(struct imx_pcie *imx_pcie) { - const struct imx6_pcie_drvdata *drvdata = imx6_pcie->drvdata; + const struct imx_pcie_drvdata *drvdata = imx_pcie->drvdata; unsigned int mask, val, mode, id; if (drvdata->mode == DW_PCIE_EP_TYPE) @@ -225,7 +225,7 @@ static void imx6_pcie_configure_type(struct imx6_pcie *imx6_pcie) else mode = PCI_EXP_TYPE_ROOT_PORT; - id = imx6_pcie->controller_id; + id = imx_pcie->controller_id; /* If mode_mask[id] is zero, means each controller have its individual gpr */ if (!drvdata->mode_mask[id]) @@ -234,12 +234,12 @@ static void imx6_pcie_configure_type(struct imx6_pcie *imx6_pcie) mask = drvdata->mode_mask[id]; val = mode << (ffs(mask) - 1); - regmap_update_bits(imx6_pcie->iomuxc_gpr, drvdata->mode_off[id], mask, val); + regmap_update_bits(imx_pcie->iomuxc_gpr, drvdata->mode_off[id], mask, val); } -static int pcie_phy_poll_ack(struct imx6_pcie *imx6_pcie, bool exp_val) +static int pcie_phy_poll_ack(struct imx_pcie *imx_pcie, bool exp_val) { - struct dw_pcie *pci = imx6_pcie->pci; + struct dw_pcie *pci = imx_pcie->pci; bool val; u32 max_iterations = 10; u32 wait_counter = 0; @@ -258,9 +258,9 @@ static int pcie_phy_poll_ack(struct imx6_pcie *imx6_pcie, bool exp_val) return -ETIMEDOUT; } -static int pcie_phy_wait_ack(struct imx6_pcie *imx6_pcie, int addr) +static int pcie_phy_wait_ack(struct imx_pcie *imx_pcie, int addr) { - struct dw_pcie *pci = imx6_pcie->pci; + struct dw_pcie *pci = imx_pcie->pci; u32 val; int ret; @@ -270,24 +270,24 @@ static int pcie_phy_wait_ack(struct imx6_pcie *imx6_pcie, int addr) val |= PCIE_PHY_CTRL_CAP_ADR; dw_pcie_writel_dbi(pci, PCIE_PHY_CTRL, val); - ret = pcie_phy_poll_ack(imx6_pcie, true); + ret = pcie_phy_poll_ack(imx_pcie, true); if (ret) return ret; val = PCIE_PHY_CTRL_DATA(addr); dw_pcie_writel_dbi(pci, PCIE_PHY_CTRL, val); - return pcie_phy_poll_ack(imx6_pcie, false); + return pcie_phy_poll_ack(imx_pcie, false); } /* Read from the 16-bit PCIe PHY control registers (not memory-mapped) */ -static int pcie_phy_read(struct imx6_pcie *imx6_pcie, int addr, u16 *data) +static int pcie_phy_read(struct imx_pcie *imx_pcie, int addr, u16 *data) { - struct dw_pcie *pci = imx6_pcie->pci; + struct dw_pcie *pci = imx_pcie->pci; u32 phy_ctl; int ret; - ret = pcie_phy_wait_ack(imx6_pcie, addr); + ret = pcie_phy_wait_ack(imx_pcie, addr); if (ret) return ret; @@ -295,7 +295,7 @@ static int pcie_phy_read(struct imx6_pcie *imx6_pcie, int addr, u16 *data) phy_ctl = PCIE_PHY_CTRL_RD; dw_pcie_writel_dbi(pci, PCIE_PHY_CTRL, phy_ctl); - ret = pcie_phy_poll_ack(imx6_pcie, true); + ret = pcie_phy_poll_ack(imx_pcie, true); if (ret) return ret; @@ -304,18 +304,18 @@ static int pcie_phy_read(struct imx6_pcie *imx6_pcie, int addr, u16 *data) /* deassert Read signal */ dw_pcie_writel_dbi(pci, PCIE_PHY_CTRL, 0x00); - return pcie_phy_poll_ack(imx6_pcie, false); + return pcie_phy_poll_ack(imx_pcie, false); } -static int pcie_phy_write(struct imx6_pcie *imx6_pcie, int addr, u16 data) +static int pcie_phy_write(struct imx_pcie *imx_pcie, int addr, u16 data) { - struct dw_pcie *pci = imx6_pcie->pci; + struct dw_pcie *pci = imx_pcie->pci; u32 var; int ret; /* write addr */ /* cap addr */ - ret = pcie_phy_wait_ack(imx6_pcie, addr); + ret = pcie_phy_wait_ack(imx_pcie, addr); if (ret) return ret; @@ -326,7 +326,7 @@ static int pcie_phy_write(struct imx6_pcie *imx6_pcie, int addr, u16 data) var |= PCIE_PHY_CTRL_CAP_DAT; dw_pcie_writel_dbi(pci, PCIE_PHY_CTRL, var); - ret = pcie_phy_poll_ack(imx6_pcie, true); + ret = pcie_phy_poll_ack(imx_pcie, true); if (ret) return ret; @@ -335,7 +335,7 @@ static int pcie_phy_write(struct imx6_pcie *imx6_pcie, int addr, u16 data) dw_pcie_writel_dbi(pci, PCIE_PHY_CTRL, var); /* wait for ack de-assertion */ - ret = pcie_phy_poll_ack(imx6_pcie, false); + ret = pcie_phy_poll_ack(imx_pcie, false); if (ret) return ret; @@ -344,7 +344,7 @@ static int pcie_phy_write(struct imx6_pcie *imx6_pcie, int addr, u16 data) dw_pcie_writel_dbi(pci, PCIE_PHY_CTRL, var); /* wait for ack */ - ret = pcie_phy_poll_ack(imx6_pcie, true); + ret = pcie_phy_poll_ack(imx_pcie, true); if (ret) return ret; @@ -353,7 +353,7 @@ static int pcie_phy_write(struct imx6_pcie *imx6_pcie, int addr, u16 data) dw_pcie_writel_dbi(pci, PCIE_PHY_CTRL, var); /* wait for ack de-assertion */ - ret = pcie_phy_poll_ack(imx6_pcie, false); + ret = pcie_phy_poll_ack(imx_pcie, false); if (ret) return ret; @@ -362,74 +362,74 @@ static int pcie_phy_write(struct imx6_pcie *imx6_pcie, int addr, u16 data) return 0; } -static int imx8mq_pcie_init_phy(struct imx6_pcie *imx6_pcie) +static int imx8mq_pcie_init_phy(struct imx_pcie *imx_pcie) { /* TODO: Currently this code assumes external oscillator is being used */ - regmap_update_bits(imx6_pcie->iomuxc_gpr, - imx6_pcie_grp_offset(imx6_pcie), + regmap_update_bits(imx_pcie->iomuxc_gpr, + imx_pcie_grp_offset(imx_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), + if (imx_pcie->vph && regulator_get_voltage(imx_pcie->vph) > 3000000) + regmap_update_bits(imx_pcie->iomuxc_gpr, + imx_pcie_grp_offset(imx_pcie), IMX8MQ_GPR_PCIE_VREG_BYPASS, 0); return 0; } -static int imx7d_pcie_init_phy(struct imx6_pcie *imx6_pcie) +static int imx7d_pcie_init_phy(struct imx_pcie *imx_pcie) { - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, IMX7D_GPR12_PCIE_PHY_REFCLK_SEL, 0); + regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR12, IMX7D_GPR12_PCIE_PHY_REFCLK_SEL, 0); return 0; } -static int imx6_pcie_init_phy(struct imx6_pcie *imx6_pcie) +static int imx_pcie_init_phy(struct imx_pcie *imx_pcie) { - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, + regmap_update_bits(imx_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, + regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR12, IMX6Q_GPR12_LOS_LEVEL, 9 << 4); - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR8, + regmap_update_bits(imx_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, + imx_pcie->tx_deemph_gen1 << 0); + regmap_update_bits(imx_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, + imx_pcie->tx_deemph_gen2_3p5db << 6); + regmap_update_bits(imx_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, + imx_pcie->tx_deemph_gen2_6db << 12); + regmap_update_bits(imx_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, + imx_pcie->tx_swing_full << 18); + regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR8, IMX6Q_GPR8_TX_SWING_LOW, - imx6_pcie->tx_swing_low << 25); + imx_pcie->tx_swing_low << 25); return 0; } -static int imx6sx_pcie_init_phy(struct imx6_pcie *imx6_pcie) +static int imx6sx_pcie_init_phy(struct imx_pcie *imx_pcie) { - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, + regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR12, IMX6SX_GPR12_PCIE_RX_EQ_MASK, IMX6SX_GPR12_PCIE_RX_EQ_2); - return imx6_pcie_init_phy(imx6_pcie); + return imx_pcie_init_phy(imx_pcie); } -static void imx7d_pcie_wait_for_phy_pll_lock(struct imx6_pcie *imx6_pcie) +static void imx7d_pcie_wait_for_phy_pll_lock(struct imx_pcie *imx_pcie) { u32 val; - struct device *dev = imx6_pcie->pci->dev; + struct device *dev = imx_pcie->pci->dev; - if (regmap_read_poll_timeout(imx6_pcie->iomuxc_gpr, + if (regmap_read_poll_timeout(imx_pcie->iomuxc_gpr, IOMUXC_GPR22, val, val & IMX7D_GPR22_PCIE_PHY_PLL_LOCKED, PHY_PLL_LOCK_WAIT_USLEEP_MAX, @@ -437,19 +437,19 @@ static void imx7d_pcie_wait_for_phy_pll_lock(struct imx6_pcie *imx6_pcie) dev_err(dev, "PCIe PLL lock timeout\n"); } -static int imx6_setup_phy_mpll(struct imx6_pcie *imx6_pcie) +static int imx_setup_phy_mpll(struct imx_pcie *imx_pcie) { unsigned long phy_rate = 0; int mult, div; u16 val; int i; - if (!(imx6_pcie->drvdata->flags & IMX6_PCIE_FLAG_IMX6_PHY)) + if (!(imx_pcie->drvdata->flags & IMX_PCIE_FLAG_IMX_PHY)) return 0; - for (i = 0; i < imx6_pcie->drvdata->clks_cnt; i++) - if (strncmp(imx6_pcie->clks[i].id, "pcie_phy", 8) == 0) - phy_rate = clk_get_rate(imx6_pcie->clks[i].clk); + for (i = 0; i < imx_pcie->drvdata->clks_cnt; i++) + if (strncmp(imx_pcie->clks[i].id, "pcie_phy", 8) == 0) + phy_rate = clk_get_rate(imx_pcie->clks[i].clk); switch (phy_rate) { case 125000000: @@ -467,46 +467,46 @@ static int imx6_setup_phy_mpll(struct imx6_pcie *imx6_pcie) div = 1; break; default: - dev_err(imx6_pcie->pci->dev, + dev_err(imx_pcie->pci->dev, "Unsupported PHY reference clock rate %lu\n", phy_rate); return -EINVAL; } - pcie_phy_read(imx6_pcie, PCIE_PHY_MPLL_OVRD_IN_LO, &val); + pcie_phy_read(imx_pcie, PCIE_PHY_MPLL_OVRD_IN_LO, &val); val &= ~(PCIE_PHY_MPLL_MULTIPLIER_MASK << PCIE_PHY_MPLL_MULTIPLIER_SHIFT); val |= mult << PCIE_PHY_MPLL_MULTIPLIER_SHIFT; val |= PCIE_PHY_MPLL_MULTIPLIER_OVRD; - pcie_phy_write(imx6_pcie, PCIE_PHY_MPLL_OVRD_IN_LO, val); + pcie_phy_write(imx_pcie, PCIE_PHY_MPLL_OVRD_IN_LO, val); - pcie_phy_read(imx6_pcie, PCIE_PHY_ATEOVRD, &val); + pcie_phy_read(imx_pcie, PCIE_PHY_ATEOVRD, &val); val &= ~(PCIE_PHY_ATEOVRD_REF_CLKDIV_MASK << PCIE_PHY_ATEOVRD_REF_CLKDIV_SHIFT); val |= div << PCIE_PHY_ATEOVRD_REF_CLKDIV_SHIFT; val |= PCIE_PHY_ATEOVRD_EN; - pcie_phy_write(imx6_pcie, PCIE_PHY_ATEOVRD, val); + pcie_phy_write(imx_pcie, PCIE_PHY_ATEOVRD, val); return 0; } -static void imx6_pcie_reset_phy(struct imx6_pcie *imx6_pcie) +static void imx_pcie_reset_phy(struct imx_pcie *imx_pcie) { u16 tmp; - if (!(imx6_pcie->drvdata->flags & IMX6_PCIE_FLAG_IMX6_PHY)) + if (!(imx_pcie->drvdata->flags & IMX_PCIE_FLAG_IMX_PHY)) return; - pcie_phy_read(imx6_pcie, PHY_RX_OVRD_IN_LO, &tmp); + pcie_phy_read(imx_pcie, PHY_RX_OVRD_IN_LO, &tmp); tmp |= (PHY_RX_OVRD_IN_LO_RX_DATA_EN | PHY_RX_OVRD_IN_LO_RX_PLL_EN); - pcie_phy_write(imx6_pcie, PHY_RX_OVRD_IN_LO, tmp); + pcie_phy_write(imx_pcie, PHY_RX_OVRD_IN_LO, tmp); usleep_range(2000, 3000); - pcie_phy_read(imx6_pcie, PHY_RX_OVRD_IN_LO, &tmp); + pcie_phy_read(imx_pcie, PHY_RX_OVRD_IN_LO, &tmp); tmp &= ~(PHY_RX_OVRD_IN_LO_RX_DATA_EN | PHY_RX_OVRD_IN_LO_RX_PLL_EN); - pcie_phy_write(imx6_pcie, PHY_RX_OVRD_IN_LO, tmp); + pcie_phy_write(imx_pcie, PHY_RX_OVRD_IN_LO, tmp); } #ifdef CONFIG_ARM @@ -545,22 +545,22 @@ static int imx6q_pcie_abort_handler(unsigned long addr, } #endif -static int imx6_pcie_attach_pd(struct device *dev) +static int imx_pcie_attach_pd(struct device *dev) { - struct imx6_pcie *imx6_pcie = dev_get_drvdata(dev); + struct imx_pcie *imx_pcie = dev_get_drvdata(dev); struct device_link *link; /* Do nothing when in a single power domain */ if (dev->pm_domain) return 0; - imx6_pcie->pd_pcie = dev_pm_domain_attach_by_name(dev, "pcie"); - if (IS_ERR(imx6_pcie->pd_pcie)) - return PTR_ERR(imx6_pcie->pd_pcie); + imx_pcie->pd_pcie = dev_pm_domain_attach_by_name(dev, "pcie"); + if (IS_ERR(imx_pcie->pd_pcie)) + return PTR_ERR(imx_pcie->pd_pcie); /* Do nothing when power domain missing */ - if (!imx6_pcie->pd_pcie) + if (!imx_pcie->pd_pcie) return 0; - link = device_link_add(dev, imx6_pcie->pd_pcie, + link = device_link_add(dev, imx_pcie->pd_pcie, DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE); @@ -569,11 +569,11 @@ static int imx6_pcie_attach_pd(struct device *dev) return -EINVAL; } - imx6_pcie->pd_pcie_phy = dev_pm_domain_attach_by_name(dev, "pcie_phy"); - if (IS_ERR(imx6_pcie->pd_pcie_phy)) - return PTR_ERR(imx6_pcie->pd_pcie_phy); + imx_pcie->pd_pcie_phy = dev_pm_domain_attach_by_name(dev, "pcie_phy"); + if (IS_ERR(imx_pcie->pd_pcie_phy)) + return PTR_ERR(imx_pcie->pd_pcie_phy); - link = device_link_add(dev, imx6_pcie->pd_pcie_phy, + link = device_link_add(dev, imx_pcie->pd_pcie_phy, DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE); @@ -585,20 +585,20 @@ static int imx6_pcie_attach_pd(struct device *dev) return 0; } -static int imx6_pcie_enable_ref_clk(struct imx6_pcie *imx6_pcie) +static int imx_pcie_enable_ref_clk(struct imx_pcie *imx_pcie) { unsigned int offset; int ret = 0; - switch (imx6_pcie->drvdata->variant) { + switch (imx_pcie->drvdata->variant) { case IMX6SX: - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, + regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR12, IMX6SX_GPR12_PCIE_TEST_POWERDOWN, 0); break; case IMX6QP: case IMX6Q: /* power up core phy and enable ref clock */ - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1, + regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR1, IMX6Q_GPR1_PCIE_TEST_PD, 0 << 18); /* * the async reset input need ref clock to sync internally, @@ -607,7 +607,7 @@ static int imx6_pcie_enable_ref_clk(struct imx6_pcie *imx6_pcie) * add one ~10us delay here. */ usleep_range(10, 100); - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1, + regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR1, IMX6Q_GPR1_PCIE_REF_CLK_EN, 1 << 16); break; case IMX7D: @@ -620,15 +620,15 @@ static int imx6_pcie_enable_ref_clk(struct imx6_pcie *imx6_pcie) case IMX8MQ_EP: case IMX8MP: case IMX8MP_EP: - offset = imx6_pcie_grp_offset(imx6_pcie); + offset = imx_pcie_grp_offset(imx_pcie); /* * Set the over ride low and enabled * make sure that REF_CLK is turned on. */ - regmap_update_bits(imx6_pcie->iomuxc_gpr, offset, + regmap_update_bits(imx_pcie->iomuxc_gpr, offset, IMX8MQ_GPR_PCIE_CLK_REQ_OVERRIDE, 0); - regmap_update_bits(imx6_pcie->iomuxc_gpr, offset, + regmap_update_bits(imx_pcie->iomuxc_gpr, offset, IMX8MQ_GPR_PCIE_CLK_REQ_OVERRIDE_EN, IMX8MQ_GPR_PCIE_CLK_REQ_OVERRIDE_EN); break; @@ -637,19 +637,19 @@ static int imx6_pcie_enable_ref_clk(struct imx6_pcie *imx6_pcie) return ret; } -static void imx6_pcie_disable_ref_clk(struct imx6_pcie *imx6_pcie) +static void imx_pcie_disable_ref_clk(struct imx_pcie *imx_pcie) { - switch (imx6_pcie->drvdata->variant) { + switch (imx_pcie->drvdata->variant) { case IMX6QP: case IMX6Q: - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1, + regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR1, IMX6Q_GPR1_PCIE_REF_CLK_EN, 0); - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1, + regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR1, IMX6Q_GPR1_PCIE_TEST_PD, IMX6Q_GPR1_PCIE_TEST_PD); break; case IMX7D: - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, + regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR12, IMX7D_GPR12_PCIE_PHY_REFCLK_SEL, IMX7D_GPR12_PCIE_PHY_REFCLK_SEL); break; @@ -658,17 +658,17 @@ static void imx6_pcie_disable_ref_clk(struct imx6_pcie *imx6_pcie) } } -static int imx6_pcie_clk_enable(struct imx6_pcie *imx6_pcie) +static int imx_pcie_clk_enable(struct imx_pcie *imx_pcie) { - struct dw_pcie *pci = imx6_pcie->pci; + struct dw_pcie *pci = imx_pcie->pci; struct device *dev = pci->dev; int ret; - ret = clk_bulk_prepare_enable(imx6_pcie->drvdata->clks_cnt, imx6_pcie->clks); + ret = clk_bulk_prepare_enable(imx_pcie->drvdata->clks_cnt, imx_pcie->clks); if (ret) return ret; - ret = imx6_pcie_enable_ref_clk(imx6_pcie); + ret = imx_pcie_enable_ref_clk(imx_pcie); if (ret) { dev_err(dev, "unable to enable pcie ref clock\n"); goto err_ref_clk; @@ -679,41 +679,41 @@ static int imx6_pcie_clk_enable(struct imx6_pcie *imx6_pcie) return 0; err_ref_clk: - clk_bulk_disable_unprepare(imx6_pcie->drvdata->clks_cnt, imx6_pcie->clks); + clk_bulk_disable_unprepare(imx_pcie->drvdata->clks_cnt, imx_pcie->clks); return ret; } -static void imx6_pcie_clk_disable(struct imx6_pcie *imx6_pcie) +static void imx_pcie_clk_disable(struct imx_pcie *imx_pcie) { - imx6_pcie_disable_ref_clk(imx6_pcie); - clk_bulk_disable_unprepare(imx6_pcie->drvdata->clks_cnt, imx6_pcie->clks); + imx_pcie_disable_ref_clk(imx_pcie); + clk_bulk_disable_unprepare(imx_pcie->drvdata->clks_cnt, imx_pcie->clks); } -static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie) +static void imx_pcie_assert_core_reset(struct imx_pcie *imx_pcie) { - reset_control_assert(imx6_pcie->pciephy_reset); - reset_control_assert(imx6_pcie->apps_reset); + reset_control_assert(imx_pcie->pciephy_reset); + reset_control_assert(imx_pcie->apps_reset); - switch (imx6_pcie->drvdata->variant) { + switch (imx_pcie->drvdata->variant) { case IMX6SX: - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, + regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR12, IMX6SX_GPR12_PCIE_TEST_POWERDOWN, IMX6SX_GPR12_PCIE_TEST_POWERDOWN); /* Force PCIe PHY reset */ - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR5, + regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR5, IMX6SX_GPR5_PCIE_BTNRST_RESET, IMX6SX_GPR5_PCIE_BTNRST_RESET); break; case IMX6QP: - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1, + regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR1, IMX6Q_GPR1_PCIE_SW_RST, IMX6Q_GPR1_PCIE_SW_RST); break; case IMX6Q: - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1, + regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR1, IMX6Q_GPR1_PCIE_TEST_PD, 1 << 18); - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1, + regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR1, IMX6Q_GPR1_PCIE_REF_CLK_EN, 0 << 16); break; default: @@ -721,47 +721,47 @@ static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie) } /* Some boards don't have PCIe reset GPIO. */ - if (gpio_is_valid(imx6_pcie->reset_gpio)) - gpio_set_value_cansleep(imx6_pcie->reset_gpio, - imx6_pcie->gpio_active_high); + if (gpio_is_valid(imx_pcie->reset_gpio)) + gpio_set_value_cansleep(imx_pcie->reset_gpio, + imx_pcie->gpio_active_high); } -static int imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie) +static int imx_pcie_deassert_core_reset(struct imx_pcie *imx_pcie) { - struct dw_pcie *pci = imx6_pcie->pci; + struct dw_pcie *pci = imx_pcie->pci; struct device *dev = pci->dev; - reset_control_deassert(imx6_pcie->pciephy_reset); + reset_control_deassert(imx_pcie->pciephy_reset); - switch (imx6_pcie->drvdata->variant) { + switch (imx_pcie->drvdata->variant) { case IMX7D: /* Workaround for ERR010728, failure of PCI-e PLL VCO to * oscillate, especially when cold. This turns off "Duty-cycle * Corrector" and other mysterious undocumented things. */ - if (likely(imx6_pcie->phy_base)) { + if (likely(imx_pcie->phy_base)) { /* De-assert DCC_FB_EN */ writel(PCIE_PHY_CMN_REG4_DCC_FB_EN, - imx6_pcie->phy_base + PCIE_PHY_CMN_REG4); + imx_pcie->phy_base + PCIE_PHY_CMN_REG4); /* Assert RX_EQS and RX_EQS_SEL */ writel(PCIE_PHY_CMN_REG24_RX_EQ_SEL | PCIE_PHY_CMN_REG24_RX_EQ, - imx6_pcie->phy_base + PCIE_PHY_CMN_REG24); + imx_pcie->phy_base + PCIE_PHY_CMN_REG24); /* Assert ATT_MODE */ writel(PCIE_PHY_CMN_REG26_ATT_MODE, - imx6_pcie->phy_base + PCIE_PHY_CMN_REG26); + imx_pcie->phy_base + PCIE_PHY_CMN_REG26); } else { dev_warn(dev, "Unable to apply ERR010728 workaround. DT missing fsl,imx7d-pcie-phy phandle ?\n"); } - imx7d_pcie_wait_for_phy_pll_lock(imx6_pcie); + imx7d_pcie_wait_for_phy_pll_lock(imx_pcie); break; case IMX6SX: - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR5, + regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR5, IMX6SX_GPR5_PCIE_BTNRST_RESET, 0); break; case IMX6QP: - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1, + regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR1, IMX6Q_GPR1_PCIE_SW_RST, 0); usleep_range(200, 500); @@ -771,10 +771,10 @@ static int imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie) } /* Some boards don't have PCIe reset GPIO. */ - if (gpio_is_valid(imx6_pcie->reset_gpio)) { + if (gpio_is_valid(imx_pcie->reset_gpio)) { msleep(100); - gpio_set_value_cansleep(imx6_pcie->reset_gpio, - !imx6_pcie->gpio_active_high); + gpio_set_value_cansleep(imx_pcie->reset_gpio, + !imx_pcie->gpio_active_high); /* Wait for 100ms after PERST# deassertion (PCIe r5.0, 6.6.1) */ msleep(100); } @@ -782,9 +782,9 @@ static int imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie) return 0; } -static int imx6_pcie_wait_for_speed_change(struct imx6_pcie *imx6_pcie) +static int imx_pcie_wait_for_speed_change(struct imx_pcie *imx_pcie) { - struct dw_pcie *pci = imx6_pcie->pci; + struct dw_pcie *pci = imx_pcie->pci; struct device *dev = pci->dev; u32 tmp; unsigned int retries; @@ -801,33 +801,33 @@ static int imx6_pcie_wait_for_speed_change(struct imx6_pcie *imx6_pcie) return -ETIMEDOUT; } -static void imx6_pcie_ltssm_enable(struct device *dev) +static void imx_pcie_ltssm_enable(struct device *dev) { - struct imx6_pcie *imx6_pcie = dev_get_drvdata(dev); - const struct imx6_pcie_drvdata *drvdata = imx6_pcie->drvdata; + struct imx_pcie *imx_pcie = dev_get_drvdata(dev); + const struct imx_pcie_drvdata *drvdata = imx_pcie->drvdata; if (drvdata->ltssm_mask) - regmap_update_bits(imx6_pcie->iomuxc_gpr, drvdata->ltssm_off, drvdata->ltssm_mask, + regmap_update_bits(imx_pcie->iomuxc_gpr, drvdata->ltssm_off, drvdata->ltssm_mask, drvdata->ltssm_mask); - reset_control_deassert(imx6_pcie->apps_reset); + reset_control_deassert(imx_pcie->apps_reset); } -static void imx6_pcie_ltssm_disable(struct device *dev) +static void imx_pcie_ltssm_disable(struct device *dev) { - struct imx6_pcie *imx6_pcie = dev_get_drvdata(dev); - const struct imx6_pcie_drvdata *drvdata = imx6_pcie->drvdata; + struct imx_pcie *imx_pcie = dev_get_drvdata(dev); + const struct imx_pcie_drvdata *drvdata = imx_pcie->drvdata; if (drvdata->ltssm_mask) - regmap_update_bits(imx6_pcie->iomuxc_gpr, drvdata->ltssm_off, + regmap_update_bits(imx_pcie->iomuxc_gpr, drvdata->ltssm_off, drvdata->ltssm_mask, 0); - reset_control_assert(imx6_pcie->apps_reset); + reset_control_assert(imx_pcie->apps_reset); } -static int imx6_pcie_start_link(struct dw_pcie *pci) +static int imx_pcie_start_link(struct dw_pcie *pci) { - struct imx6_pcie *imx6_pcie = to_imx6_pcie(pci); + struct imx_pcie *imx_pcie = to_imx_pcie(pci); struct device *dev = pci->dev; u8 offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP); u32 tmp; @@ -846,7 +846,7 @@ static int imx6_pcie_start_link(struct dw_pcie *pci) dw_pcie_dbi_ro_wr_dis(pci); /* Start LTSSM. */ - imx6_pcie_ltssm_enable(dev); + imx_pcie_ltssm_enable(dev); ret = dw_pcie_wait_for_link(pci); if (ret) @@ -869,8 +869,8 @@ static int imx6_pcie_start_link(struct dw_pcie *pci) dw_pcie_writel_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL, tmp); dw_pcie_dbi_ro_wr_dis(pci); - if (imx6_pcie->drvdata->flags & - IMX6_PCIE_FLAG_IMX6_SPEED_CHANGE) { + if (imx_pcie->drvdata->flags & + IMX_PCIE_FLAG_IMX_SPEED_CHANGE) { /* * On i.MX7, DIRECT_SPEED_CHANGE behaves differently * from i.MX6 family when no link speed transition @@ -880,7 +880,7 @@ static int imx6_pcie_start_link(struct dw_pcie *pci) * failure. */ - ret = imx6_pcie_wait_for_speed_change(imx6_pcie); + ret = imx_pcie_wait_for_speed_change(imx_pcie); if (ret) { dev_err(dev, "Failed to bring link up!\n"); goto err_reset_phy; @@ -895,37 +895,37 @@ static int imx6_pcie_start_link(struct dw_pcie *pci) dev_info(dev, "Link: Only Gen1 is enabled\n"); } - imx6_pcie->link_is_up = true; + imx_pcie->link_is_up = true; tmp = dw_pcie_readw_dbi(pci, offset + PCI_EXP_LNKSTA); dev_info(dev, "Link up, Gen%i\n", tmp & PCI_EXP_LNKSTA_CLS); return 0; err_reset_phy: - imx6_pcie->link_is_up = false; + imx_pcie->link_is_up = false; dev_dbg(dev, "PHY DEBUG_R0=0x%08x DEBUG_R1=0x%08x\n", dw_pcie_readl_dbi(pci, PCIE_PORT_DEBUG0), dw_pcie_readl_dbi(pci, PCIE_PORT_DEBUG1)); - imx6_pcie_reset_phy(imx6_pcie); + imx_pcie_reset_phy(imx_pcie); return 0; } -static void imx6_pcie_stop_link(struct dw_pcie *pci) +static void imx_pcie_stop_link(struct dw_pcie *pci) { struct device *dev = pci->dev; /* Turn off PCIe LTSSM */ - imx6_pcie_ltssm_disable(dev); + imx_pcie_ltssm_disable(dev); } -static int imx6_pcie_host_init(struct dw_pcie_rp *pp) +static int imx_pcie_host_init(struct dw_pcie_rp *pp) { struct dw_pcie *pci = to_dw_pcie_from_pp(pp); struct device *dev = pci->dev; - struct imx6_pcie *imx6_pcie = to_imx6_pcie(pci); + struct imx_pcie *imx_pcie = to_imx_pcie(pci); int ret; - if (imx6_pcie->vpcie) { - ret = regulator_enable(imx6_pcie->vpcie); + if (imx_pcie->vpcie) { + ret = regulator_enable(imx_pcie->vpcie); if (ret) { dev_err(dev, "failed to enable vpcie regulator: %d\n", ret); @@ -933,83 +933,83 @@ static int imx6_pcie_host_init(struct dw_pcie_rp *pp) } } - imx6_pcie_assert_core_reset(imx6_pcie); + imx_pcie_assert_core_reset(imx_pcie); - if (imx6_pcie->drvdata->init_phy) - imx6_pcie->drvdata->init_phy(imx6_pcie); + if (imx_pcie->drvdata->init_phy) + imx_pcie->drvdata->init_phy(imx_pcie); - imx6_pcie_configure_type(imx6_pcie); + imx_pcie_configure_type(imx_pcie); - ret = imx6_pcie_clk_enable(imx6_pcie); + ret = imx_pcie_clk_enable(imx_pcie); if (ret) { dev_err(dev, "unable to enable pcie clocks: %d\n", ret); goto err_reg_disable; } - if (imx6_pcie->phy) { - ret = phy_init(imx6_pcie->phy); + if (imx_pcie->phy) { + ret = phy_init(imx_pcie->phy); if (ret) { dev_err(dev, "pcie PHY power up failed\n"); goto err_clk_disable; } } - if (imx6_pcie->phy) { - ret = phy_power_on(imx6_pcie->phy); + if (imx_pcie->phy) { + ret = phy_power_on(imx_pcie->phy); if (ret) { dev_err(dev, "waiting for PHY ready timeout!\n"); goto err_phy_off; } } - ret = imx6_pcie_deassert_core_reset(imx6_pcie); + ret = imx_pcie_deassert_core_reset(imx_pcie); if (ret < 0) { dev_err(dev, "pcie deassert core reset failed: %d\n", ret); goto err_phy_off; } - imx6_setup_phy_mpll(imx6_pcie); + imx_setup_phy_mpll(imx_pcie); return 0; err_phy_off: - if (imx6_pcie->phy) - phy_exit(imx6_pcie->phy); + if (imx_pcie->phy) + phy_exit(imx_pcie->phy); err_clk_disable: - imx6_pcie_clk_disable(imx6_pcie); + imx_pcie_clk_disable(imx_pcie); err_reg_disable: - if (imx6_pcie->vpcie) - regulator_disable(imx6_pcie->vpcie); + if (imx_pcie->vpcie) + regulator_disable(imx_pcie->vpcie); return ret; } -static void imx6_pcie_host_exit(struct dw_pcie_rp *pp) +static void imx_pcie_host_exit(struct dw_pcie_rp *pp) { struct dw_pcie *pci = to_dw_pcie_from_pp(pp); - struct imx6_pcie *imx6_pcie = to_imx6_pcie(pci); + struct imx_pcie *imx_pcie = to_imx_pcie(pci); - if (imx6_pcie->phy) { - if (phy_power_off(imx6_pcie->phy)) + if (imx_pcie->phy) { + if (phy_power_off(imx_pcie->phy)) dev_err(pci->dev, "unable to power off PHY\n"); - phy_exit(imx6_pcie->phy); + phy_exit(imx_pcie->phy); } - imx6_pcie_clk_disable(imx6_pcie); + imx_pcie_clk_disable(imx_pcie); - if (imx6_pcie->vpcie) - regulator_disable(imx6_pcie->vpcie); + if (imx_pcie->vpcie) + regulator_disable(imx_pcie->vpcie); } -static const struct dw_pcie_host_ops imx6_pcie_host_ops = { - .init = imx6_pcie_host_init, - .deinit = imx6_pcie_host_exit, +static const struct dw_pcie_host_ops imx_pcie_host_ops = { + .init = imx_pcie_host_init, + .deinit = imx_pcie_host_exit, }; static const struct dw_pcie_ops dw_pcie_ops = { - .start_link = imx6_pcie_start_link, - .stop_link = imx6_pcie_stop_link, + .start_link = imx_pcie_start_link, + .stop_link = imx_pcie_stop_link, }; -static void imx6_pcie_ep_init(struct dw_pcie_ep *ep) +static void imx_pcie_ep_init(struct dw_pcie_ep *ep) { enum pci_barno bar; struct dw_pcie *pci = to_dw_pcie_from_ep(ep); @@ -1018,7 +1018,7 @@ static void imx6_pcie_ep_init(struct dw_pcie_ep *ep) dw_pcie_ep_reset_bar(pci, bar); } -static int imx6_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 func_no, +static int imx_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 func_no, unsigned int type, u16 interrupt_num) { struct dw_pcie *pci = to_dw_pcie_from_ep(ep); @@ -1065,35 +1065,35 @@ static const struct pci_epc_features imx95_pcie_epc_features = { }; static const struct pci_epc_features* -imx6_pcie_ep_get_features(struct dw_pcie_ep *ep) +imx_pcie_ep_get_features(struct dw_pcie_ep *ep) { struct dw_pcie *pci = to_dw_pcie_from_ep(ep); - struct imx6_pcie *imx6_pcie = to_imx6_pcie(pci); + struct imx_pcie *imx_pcie = to_imx_pcie(pci); - return imx6_pcie->drvdata->epc_features; + return imx_pcie->drvdata->epc_features; } static const struct dw_pcie_ep_ops pcie_ep_ops = { - .init = imx6_pcie_ep_init, - .raise_irq = imx6_pcie_ep_raise_irq, - .get_features = imx6_pcie_ep_get_features, + .init = imx_pcie_ep_init, + .raise_irq = imx_pcie_ep_raise_irq, + .get_features = imx_pcie_ep_get_features, }; -static int imx6_add_pcie_ep(struct imx6_pcie *imx6_pcie, +static int imx_add_pcie_ep(struct imx_pcie *imx_pcie, struct platform_device *pdev) { int ret; unsigned int pcie_dbi2_offset; struct dw_pcie_ep *ep; - struct dw_pcie *pci = imx6_pcie->pci; + struct dw_pcie *pci = imx_pcie->pci; struct dw_pcie_rp *pp = &pci->pp; struct device *dev = pci->dev; - imx6_pcie_host_init(pp); + imx_pcie_host_init(pp); ep = &pci->ep; ep->ops = &pcie_ep_ops; - switch (imx6_pcie->drvdata->variant) { + switch (imx_pcie->drvdata->variant) { case IMX8MQ_EP: case IMX8MM_EP: case IMX8MP_EP: @@ -1115,10 +1115,10 @@ static int imx6_add_pcie_ep(struct imx6_pcie *imx6_pcie, if (device_property_match_string(dev, "reg-names", "dbi2") >= 0) pci->dbi_base2 = NULL; - if (imx6_check_flag(imx6_pcie, IMX6_PCIE_FLAG_SUPPORT_64BIT)) + if (imx_check_flag(imx_pcie, IMX_PCIE_FLAG_SUPPORT_64BIT)) dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64)); - ep->page_size = imx6_pcie->drvdata->epc_features->align; + ep->page_size = imx_pcie->drvdata->epc_features->align; ret = dw_pcie_ep_init(ep); if (ret) { @@ -1126,30 +1126,30 @@ static int imx6_add_pcie_ep(struct imx6_pcie *imx6_pcie, return ret; } /* Start LTSSM. */ - imx6_pcie_ltssm_enable(dev); + imx_pcie_ltssm_enable(dev); return 0; } -static void imx6_pcie_pm_turnoff(struct imx6_pcie *imx6_pcie) +static void imx_pcie_pm_turnoff(struct imx_pcie *imx_pcie) { - struct device *dev = imx6_pcie->pci->dev; + struct device *dev = imx_pcie->pci->dev; /* Some variants have a turnoff reset in DT */ - if (imx6_pcie->turnoff_reset) { - reset_control_assert(imx6_pcie->turnoff_reset); - reset_control_deassert(imx6_pcie->turnoff_reset); + if (imx_pcie->turnoff_reset) { + reset_control_assert(imx_pcie->turnoff_reset); + reset_control_deassert(imx_pcie->turnoff_reset); goto pm_turnoff_sleep; } /* Others poke directly at IOMUXC registers */ - switch (imx6_pcie->drvdata->variant) { + switch (imx_pcie->drvdata->variant) { case IMX6SX: case IMX6QP: - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, + regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR12, IMX6SX_GPR12_PCIE_PM_TURN_OFF, IMX6SX_GPR12_PCIE_PM_TURN_OFF); - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, + regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR12, IMX6SX_GPR12_PCIE_PM_TURN_OFF, 0); break; default: @@ -1168,73 +1168,73 @@ static void imx6_pcie_pm_turnoff(struct imx6_pcie *imx6_pcie) usleep_range(1000, 10000); } -static void imx6_pcie_msi_save_restore(struct imx6_pcie *imx6_pcie, bool save) +static void imx_pcie_msi_save_restore(struct imx_pcie *imx_pcie, bool save) { u8 offset; u16 val; - struct dw_pcie *pci = imx6_pcie->pci; + struct dw_pcie *pci = imx_pcie->pci; if (pci_msi_enabled()) { offset = dw_pcie_find_capability(pci, PCI_CAP_ID_MSI); if (save) { val = dw_pcie_readw_dbi(pci, offset + PCI_MSI_FLAGS); - imx6_pcie->msi_ctrl = val; + imx_pcie->msi_ctrl = val; } else { dw_pcie_dbi_ro_wr_en(pci); - val = imx6_pcie->msi_ctrl; + val = imx_pcie->msi_ctrl; dw_pcie_writew_dbi(pci, offset + PCI_MSI_FLAGS, val); dw_pcie_dbi_ro_wr_dis(pci); } } } -static int imx6_pcie_suspend_noirq(struct device *dev) +static int imx_pcie_suspend_noirq(struct device *dev) { - struct imx6_pcie *imx6_pcie = dev_get_drvdata(dev); - struct dw_pcie_rp *pp = &imx6_pcie->pci->pp; + struct imx_pcie *imx_pcie = dev_get_drvdata(dev); + struct dw_pcie_rp *pp = &imx_pcie->pci->pp; - if (!(imx6_pcie->drvdata->flags & IMX6_PCIE_FLAG_SUPPORTS_SUSPEND)) + if (!(imx_pcie->drvdata->flags & IMX_PCIE_FLAG_SUPPORTS_SUSPEND)) return 0; - imx6_pcie_msi_save_restore(imx6_pcie, true); - imx6_pcie_pm_turnoff(imx6_pcie); - imx6_pcie_stop_link(imx6_pcie->pci); - imx6_pcie_host_exit(pp); + imx_pcie_msi_save_restore(imx_pcie, true); + imx_pcie_pm_turnoff(imx_pcie); + imx_pcie_stop_link(imx_pcie->pci); + imx_pcie_host_exit(pp); return 0; } -static int imx6_pcie_resume_noirq(struct device *dev) +static int imx_pcie_resume_noirq(struct device *dev) { int ret; - struct imx6_pcie *imx6_pcie = dev_get_drvdata(dev); - struct dw_pcie_rp *pp = &imx6_pcie->pci->pp; + struct imx_pcie *imx_pcie = dev_get_drvdata(dev); + struct dw_pcie_rp *pp = &imx_pcie->pci->pp; - if (!(imx6_pcie->drvdata->flags & IMX6_PCIE_FLAG_SUPPORTS_SUSPEND)) + if (!(imx_pcie->drvdata->flags & IMX_PCIE_FLAG_SUPPORTS_SUSPEND)) return 0; - ret = imx6_pcie_host_init(pp); + ret = imx_pcie_host_init(pp); if (ret) return ret; - imx6_pcie_msi_save_restore(imx6_pcie, false); + imx_pcie_msi_save_restore(imx_pcie, false); dw_pcie_setup_rc(pp); - if (imx6_pcie->link_is_up) - imx6_pcie_start_link(imx6_pcie->pci); + if (imx_pcie->link_is_up) + imx_pcie_start_link(imx_pcie->pci); return 0; } -static const struct dev_pm_ops imx6_pcie_pm_ops = { - NOIRQ_SYSTEM_SLEEP_PM_OPS(imx6_pcie_suspend_noirq, - imx6_pcie_resume_noirq) +static const struct dev_pm_ops imx_pcie_pm_ops = { + NOIRQ_SYSTEM_SLEEP_PM_OPS(imx_pcie_suspend_noirq, + imx_pcie_resume_noirq) }; -static int imx6_pcie_probe(struct platform_device *pdev) +static int imx_pcie_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct dw_pcie *pci; - struct imx6_pcie *imx6_pcie; + struct imx_pcie *imx_pcie; struct device_node *np; struct resource *dbi_base; struct device_node *node = dev->of_node; @@ -1242,8 +1242,8 @@ static int imx6_pcie_probe(struct platform_device *pdev) u16 val; int i; - imx6_pcie = devm_kzalloc(dev, sizeof(*imx6_pcie), GFP_KERNEL); - if (!imx6_pcie) + imx_pcie = devm_kzalloc(dev, sizeof(*imx_pcie), GFP_KERNEL); + if (!imx_pcie) return -ENOMEM; pci = devm_kzalloc(dev, sizeof(*pci), GFP_KERNEL); @@ -1252,10 +1252,10 @@ static int imx6_pcie_probe(struct platform_device *pdev) pci->dev = dev; pci->ops = &dw_pcie_ops; - pci->pp.ops = &imx6_pcie_host_ops; + pci->pp.ops = &imx_pcie_host_ops; - imx6_pcie->pci = pci; - imx6_pcie->drvdata = of_device_get_match_data(dev); + imx_pcie->pci = pci; + imx_pcie->drvdata = of_device_get_match_data(dev); /* Find the PHY if one is defined, only imx7d uses it */ np = of_parse_phandle(node, "fsl,imx7d-pcie-phy", 0); @@ -1267,9 +1267,9 @@ static int imx6_pcie_probe(struct platform_device *pdev) dev_err(dev, "Unable to map PCIe PHY\n"); return ret; } - imx6_pcie->phy_base = devm_ioremap_resource(dev, &res); - if (IS_ERR(imx6_pcie->phy_base)) - return PTR_ERR(imx6_pcie->phy_base); + imx_pcie->phy_base = devm_ioremap_resource(dev, &res); + if (IS_ERR(imx_pcie->phy_base)) + return PTR_ERR(imx_pcie->phy_base); } pci->dbi_base = devm_platform_get_and_ioremap_resource(pdev, 0, &dbi_base); @@ -1277,12 +1277,12 @@ static int imx6_pcie_probe(struct platform_device *pdev) return PTR_ERR(pci->dbi_base); /* Fetch GPIOs */ - imx6_pcie->reset_gpio = of_get_named_gpio(node, "reset-gpio", 0); - imx6_pcie->gpio_active_high = of_property_read_bool(node, + imx_pcie->reset_gpio = of_get_named_gpio(node, "reset-gpio", 0); + imx_pcie->gpio_active_high = of_property_read_bool(node, "reset-gpio-active-high"); - if (gpio_is_valid(imx6_pcie->reset_gpio)) { - ret = devm_gpio_request_one(dev, imx6_pcie->reset_gpio, - imx6_pcie->gpio_active_high ? + if (gpio_is_valid(imx_pcie->reset_gpio)) { + ret = devm_gpio_request_one(dev, imx_pcie->reset_gpio, + imx_pcie->gpio_active_high ? GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW, "PCIe reset"); @@ -1290,70 +1290,70 @@ static int imx6_pcie_probe(struct platform_device *pdev) dev_err(dev, "unable to get reset gpio\n"); return ret; } - } else if (imx6_pcie->reset_gpio == -EPROBE_DEFER) { - return imx6_pcie->reset_gpio; + } else if (imx_pcie->reset_gpio == -EPROBE_DEFER) { + return imx_pcie->reset_gpio; } - if (imx6_pcie->drvdata->clks_cnt >= IMX6_PCIE_MAX_CLKS) + if (imx_pcie->drvdata->clks_cnt >= IMX_PCIE_MAX_CLKS) return dev_err_probe(dev, -ENOMEM, "clks_cnt is too big\n"); - for (i = 0; i < imx6_pcie->drvdata->clks_cnt; i++) - imx6_pcie->clks[i].id = imx6_pcie->drvdata->clk_names[i]; + for (i = 0; i < imx_pcie->drvdata->clks_cnt; i++) + imx_pcie->clks[i].id = imx_pcie->drvdata->clk_names[i]; /* Fetch clocks */ - ret = devm_clk_bulk_get(dev, imx6_pcie->drvdata->clks_cnt, imx6_pcie->clks); + ret = devm_clk_bulk_get(dev, imx_pcie->drvdata->clks_cnt, imx_pcie->clks); if (ret) return ret; - if (imx6_check_flag(imx6_pcie, IMX6_PCIE_FLAG_HAS_PHYDRV)) { - 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), + if (imx_check_flag(imx_pcie, IMX_PCIE_FLAG_HAS_PHYDRV)) { + imx_pcie->phy = devm_phy_get(dev, "pcie-phy"); + if (IS_ERR(imx_pcie->phy)) + return dev_err_probe(dev, PTR_ERR(imx_pcie->phy), "failed to get pcie phy\n"); } - 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), + if (imx_check_flag(imx_pcie, IMX_PCIE_FLAG_HAS_APP_RESET)) { + imx_pcie->apps_reset = devm_reset_control_get_exclusive(dev, "apps"); + if (IS_ERR(imx_pcie->apps_reset)) + return dev_err_probe(dev, PTR_ERR(imx_pcie->apps_reset), "failed to get pcie apps reset control\n"); } - 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), + if (imx_check_flag(imx_pcie, IMX_PCIE_FLAG_HAS_PHY_RESET)) { + imx_pcie->pciephy_reset = devm_reset_control_get_exclusive(dev, "pciephy"); + if (IS_ERR(imx_pcie->pciephy_reset)) + return dev_err_probe(dev, PTR_ERR(imx_pcie->pciephy_reset), "Failed to get PCIEPHY reset control\n"); } - switch (imx6_pcie->drvdata->variant) { + switch (imx_pcie->drvdata->variant) { case IMX8MQ: case IMX8MQ_EP: case IMX7D: if (dbi_base->start == IMX8MQ_PCIE2_BASE_ADDR) - imx6_pcie->controller_id = 1; + imx_pcie->controller_id = 1; break; default: break; } /* Grab turnoff reset */ - imx6_pcie->turnoff_reset = devm_reset_control_get_optional_exclusive(dev, "turnoff"); - if (IS_ERR(imx6_pcie->turnoff_reset)) { + imx_pcie->turnoff_reset = devm_reset_control_get_optional_exclusive(dev, "turnoff"); + if (IS_ERR(imx_pcie->turnoff_reset)) { dev_err(dev, "Failed to get TURNOFF reset control\n"); - return PTR_ERR(imx6_pcie->turnoff_reset); + return PTR_ERR(imx_pcie->turnoff_reset); } - if (imx6_pcie->drvdata->gpr) { + if (imx_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)) - return dev_err_probe(dev, PTR_ERR(imx6_pcie->iomuxc_gpr), + imx_pcie->iomuxc_gpr = + syscon_regmap_lookup_by_compatible(imx_pcie->drvdata->gpr); + if (IS_ERR(imx_pcie->iomuxc_gpr)) + return dev_err_probe(dev, PTR_ERR(imx_pcie->iomuxc_gpr), "unable to find iomuxc registers\n"); } - if (imx6_check_flag(imx6_pcie, IMX6_PCIE_FLAG_HAS_SERDES)) { + if (imx_check_flag(imx_pcie, IMX_PCIE_FLAG_HAS_SERDES)) { void __iomem *off = devm_platform_ioremap_resource_byname(pdev, "app"); if (IS_ERR(off)) @@ -1366,59 +1366,59 @@ static int imx6_pcie_probe(struct platform_device *pdev) .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), + imx_pcie->iomuxc_gpr = devm_regmap_init_mmio(dev, off, ®map_config); + if (IS_ERR(imx_pcie->iomuxc_gpr)) + return dev_err_probe(dev, PTR_ERR(imx_pcie->iomuxc_gpr), "unable to find iomuxc registers\n"); } /* Grab PCIe PHY Tx Settings */ if (of_property_read_u32(node, "fsl,tx-deemph-gen1", - &imx6_pcie->tx_deemph_gen1)) - imx6_pcie->tx_deemph_gen1 = 0; + &imx_pcie->tx_deemph_gen1)) + imx_pcie->tx_deemph_gen1 = 0; if (of_property_read_u32(node, "fsl,tx-deemph-gen2-3p5db", - &imx6_pcie->tx_deemph_gen2_3p5db)) - imx6_pcie->tx_deemph_gen2_3p5db = 0; + &imx_pcie->tx_deemph_gen2_3p5db)) + imx_pcie->tx_deemph_gen2_3p5db = 0; if (of_property_read_u32(node, "fsl,tx-deemph-gen2-6db", - &imx6_pcie->tx_deemph_gen2_6db)) - imx6_pcie->tx_deemph_gen2_6db = 20; + &imx_pcie->tx_deemph_gen2_6db)) + imx_pcie->tx_deemph_gen2_6db = 20; if (of_property_read_u32(node, "fsl,tx-swing-full", - &imx6_pcie->tx_swing_full)) - imx6_pcie->tx_swing_full = 127; + &imx_pcie->tx_swing_full)) + imx_pcie->tx_swing_full = 127; if (of_property_read_u32(node, "fsl,tx-swing-low", - &imx6_pcie->tx_swing_low)) - imx6_pcie->tx_swing_low = 127; + &imx_pcie->tx_swing_low)) + imx_pcie->tx_swing_low = 127; /* Limit link speed */ pci->link_gen = 1; of_property_read_u32(node, "fsl,max-link-speed", &pci->link_gen); - imx6_pcie->vpcie = devm_regulator_get_optional(&pdev->dev, "vpcie"); - if (IS_ERR(imx6_pcie->vpcie)) { - if (PTR_ERR(imx6_pcie->vpcie) != -ENODEV) - return PTR_ERR(imx6_pcie->vpcie); - imx6_pcie->vpcie = NULL; + imx_pcie->vpcie = devm_regulator_get_optional(&pdev->dev, "vpcie"); + if (IS_ERR(imx_pcie->vpcie)) { + if (PTR_ERR(imx_pcie->vpcie) != -ENODEV) + return PTR_ERR(imx_pcie->vpcie); + imx_pcie->vpcie = NULL; } - imx6_pcie->vph = devm_regulator_get_optional(&pdev->dev, "vph"); - if (IS_ERR(imx6_pcie->vph)) { - if (PTR_ERR(imx6_pcie->vph) != -ENODEV) - return PTR_ERR(imx6_pcie->vph); - imx6_pcie->vph = NULL; + imx_pcie->vph = devm_regulator_get_optional(&pdev->dev, "vph"); + if (IS_ERR(imx_pcie->vph)) { + if (PTR_ERR(imx_pcie->vph) != -ENODEV) + return PTR_ERR(imx_pcie->vph); + imx_pcie->vph = NULL; } - platform_set_drvdata(pdev, imx6_pcie); + platform_set_drvdata(pdev, imx_pcie); - ret = imx6_pcie_attach_pd(dev); + ret = imx_pcie_attach_pd(dev); if (ret) return ret; - if (imx6_pcie->drvdata->mode == DW_PCIE_EP_TYPE) { - ret = imx6_add_pcie_ep(imx6_pcie, pdev); + if (imx_pcie->drvdata->mode == DW_PCIE_EP_TYPE) { + ret = imx_add_pcie_ep(imx_pcie, pdev); if (ret < 0) return ret; } else { @@ -1438,12 +1438,12 @@ static int imx6_pcie_probe(struct platform_device *pdev) return 0; } -static void imx6_pcie_shutdown(struct platform_device *pdev) +static void imx_pcie_shutdown(struct platform_device *pdev) { - struct imx6_pcie *imx6_pcie = platform_get_drvdata(pdev); + struct imx_pcie *imx_pcie = platform_get_drvdata(pdev); /* bring down link, so bootloader gets clean state in case of reboot */ - imx6_pcie_assert_core_reset(imx6_pcie); + imx_pcie_assert_core_reset(imx_pcie); } static const char * const imx6q_clks[] = {"pcie_bus", "pcie", "pcie_phy"}; @@ -1451,11 +1451,11 @@ 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 struct imx6_pcie_drvdata drvdata[] = { +static const struct imx_pcie_drvdata drvdata[] = { [IMX6Q] = { .variant = IMX6Q, - .flags = IMX6_PCIE_FLAG_IMX6_PHY | - IMX6_PCIE_FLAG_IMX6_SPEED_CHANGE, + .flags = IMX_PCIE_FLAG_IMX_PHY | + IMX_PCIE_FLAG_IMX_SPEED_CHANGE, .dbi_length = 0x200, .gpr = "fsl,imx6q-iomuxc-gpr", .clk_names = imx6q_clks, @@ -1464,13 +1464,13 @@ 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, + .init_phy = imx_pcie_init_phy, }, [IMX6SX] = { .variant = IMX6SX, - .flags = IMX6_PCIE_FLAG_IMX6_PHY | - IMX6_PCIE_FLAG_IMX6_SPEED_CHANGE | - IMX6_PCIE_FLAG_SUPPORTS_SUSPEND, + .flags = IMX_PCIE_FLAG_IMX_PHY | + IMX_PCIE_FLAG_IMX_SPEED_CHANGE | + IMX_PCIE_FLAG_SUPPORTS_SUSPEND, .gpr = "fsl,imx6q-iomuxc-gpr", .clk_names = imx6sx_clks, .clks_cnt = ARRAY_SIZE(imx6sx_clks), @@ -1482,9 +1482,9 @@ static const struct imx6_pcie_drvdata drvdata[] = { }, [IMX6QP] = { .variant = IMX6QP, - .flags = IMX6_PCIE_FLAG_IMX6_PHY | - IMX6_PCIE_FLAG_IMX6_SPEED_CHANGE | - IMX6_PCIE_FLAG_SUPPORTS_SUSPEND, + .flags = IMX_PCIE_FLAG_IMX_PHY | + IMX_PCIE_FLAG_IMX_SPEED_CHANGE | + IMX_PCIE_FLAG_SUPPORTS_SUSPEND, .dbi_length = 0x200, .gpr = "fsl,imx6q-iomuxc-gpr", .clk_names = imx6q_clks, @@ -1493,13 +1493,13 @@ 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, + .init_phy = imx_pcie_init_phy, }, [IMX7D] = { .variant = IMX7D, - .flags = IMX6_PCIE_FLAG_SUPPORTS_SUSPEND | - IMX6_PCIE_FLAG_HAS_APP_RESET | - IMX6_PCIE_FLAG_HAS_PHY_RESET, + .flags = IMX_PCIE_FLAG_SUPPORTS_SUSPEND | + IMX_PCIE_FLAG_HAS_APP_RESET | + IMX_PCIE_FLAG_HAS_PHY_RESET, .gpr = "fsl,imx7d-iomuxc-gpr", .clk_names = imx6q_clks, .clks_cnt = ARRAY_SIZE(imx6q_clks), @@ -1509,8 +1509,8 @@ static const struct imx6_pcie_drvdata drvdata[] = { }, [IMX8MQ] = { .variant = IMX8MQ, - .flags = IMX6_PCIE_FLAG_HAS_APP_RESET | - IMX6_PCIE_FLAG_HAS_PHY_RESET, + .flags = IMX_PCIE_FLAG_HAS_APP_RESET | + IMX_PCIE_FLAG_HAS_PHY_RESET, .gpr = "fsl,imx8mq-iomuxc-gpr", .clk_names = imx8mq_clks, .clks_cnt = ARRAY_SIZE(imx8mq_clks), @@ -1522,9 +1522,9 @@ static const struct imx6_pcie_drvdata drvdata[] = { }, [IMX8MM] = { .variant = IMX8MM, - .flags = IMX6_PCIE_FLAG_SUPPORTS_SUSPEND | - IMX6_PCIE_FLAG_HAS_PHYDRV | - IMX6_PCIE_FLAG_HAS_APP_RESET, + .flags = IMX_PCIE_FLAG_SUPPORTS_SUSPEND | + IMX_PCIE_FLAG_HAS_PHYDRV | + IMX_PCIE_FLAG_HAS_APP_RESET, .gpr = "fsl,imx8mm-iomuxc-gpr", .clk_names = imx8mm_clks, .clks_cnt = ARRAY_SIZE(imx8mm_clks), @@ -1533,9 +1533,9 @@ static const struct imx6_pcie_drvdata drvdata[] = { }, [IMX8MP] = { .variant = IMX8MP, - .flags = IMX6_PCIE_FLAG_SUPPORTS_SUSPEND | - IMX6_PCIE_FLAG_HAS_PHYDRV | - IMX6_PCIE_FLAG_HAS_APP_RESET, + .flags = IMX_PCIE_FLAG_SUPPORTS_SUSPEND | + IMX_PCIE_FLAG_HAS_PHYDRV | + IMX_PCIE_FLAG_HAS_APP_RESET, .gpr = "fsl,imx8mp-iomuxc-gpr", .clk_names = imx8mm_clks, .clks_cnt = ARRAY_SIZE(imx8mm_clks), @@ -1544,7 +1544,7 @@ static const struct imx6_pcie_drvdata drvdata[] = { }, [IMX95] = { .variant = IMX95, - .flags = IMX6_PCIE_FLAG_HAS_SERDES, + .flags = IMX_PCIE_FLAG_HAS_SERDES, .clk_names = imx8mq_clks, .clks_cnt = ARRAY_SIZE(imx8mq_clks), .ltssm_off = IMX95_PE0_GEN_CTRL_3, @@ -1555,8 +1555,8 @@ static const struct imx6_pcie_drvdata drvdata[] = { }, [IMX8MQ_EP] = { .variant = IMX8MQ_EP, - .flags = IMX6_PCIE_FLAG_HAS_APP_RESET | - IMX6_PCIE_FLAG_HAS_PHY_RESET, + .flags = IMX_PCIE_FLAG_HAS_APP_RESET | + IMX_PCIE_FLAG_HAS_PHY_RESET, .mode = DW_PCIE_EP_TYPE, .gpr = "fsl,imx8mq-iomuxc-gpr", .clk_names = imx8mq_clks, @@ -1570,8 +1570,8 @@ static const struct imx6_pcie_drvdata drvdata[] = { }, [IMX8MM_EP] = { .variant = IMX8MM_EP, - .flags = IMX6_PCIE_FLAG_HAS_APP_RESET | - IMX6_PCIE_FLAG_HAS_PHYDRV, + .flags = IMX_PCIE_FLAG_HAS_APP_RESET | + IMX_PCIE_FLAG_HAS_PHYDRV, .mode = DW_PCIE_EP_TYPE, .gpr = "fsl,imx8mm-iomuxc-gpr", .clk_names = imx8mm_clks, @@ -1582,8 +1582,8 @@ static const struct imx6_pcie_drvdata drvdata[] = { }, [IMX8MP_EP] = { .variant = IMX8MP_EP, - .flags = IMX6_PCIE_FLAG_HAS_APP_RESET | - IMX6_PCIE_FLAG_HAS_PHYDRV, + .flags = IMX_PCIE_FLAG_HAS_APP_RESET | + IMX_PCIE_FLAG_HAS_PHYDRV, .mode = DW_PCIE_EP_TYPE, .gpr = "fsl,imx8mp-iomuxc-gpr", .clk_names = imx8mm_clks, @@ -1594,8 +1594,8 @@ static const struct imx6_pcie_drvdata drvdata[] = { }, [IMX95_EP] = { .variant = IMX95_EP, - .flags = IMX6_PCIE_FLAG_HAS_SERDES | - IMX6_PCIE_FLAG_SUPPORT_64BIT, + .flags = IMX_PCIE_FLAG_HAS_SERDES | + IMX_PCIE_FLAG_SUPPORT_64BIT, .clk_names = imx8mq_clks, .clks_cnt = ARRAY_SIZE(imx8mq_clks), .ltssm_off = IMX95_PE0_GEN_CTRL_3, @@ -1608,7 +1608,7 @@ static const struct imx6_pcie_drvdata drvdata[] = { }, }; -static const struct of_device_id imx6_pcie_of_match[] = { +static const struct of_device_id imx_pcie_of_match[] = { { .compatible = "fsl,imx6q-pcie", .data = &drvdata[IMX6Q], }, { .compatible = "fsl,imx6sx-pcie", .data = &drvdata[IMX6SX], }, { .compatible = "fsl,imx6qp-pcie", .data = &drvdata[IMX6QP], }, @@ -1624,19 +1624,19 @@ static const struct of_device_id imx6_pcie_of_match[] = { {}, }; -static struct platform_driver imx6_pcie_driver = { +static struct platform_driver imx_pcie_driver = { .driver = { .name = "imx6q-pcie", - .of_match_table = imx6_pcie_of_match, + .of_match_table = imx_pcie_of_match, .suppress_bind_attrs = true, - .pm = &imx6_pcie_pm_ops, + .pm = &imx_pcie_pm_ops, .probe_type = PROBE_PREFER_ASYNCHRONOUS, }, - .probe = imx6_pcie_probe, - .shutdown = imx6_pcie_shutdown, + .probe = imx_pcie_probe, + .shutdown = imx_pcie_shutdown, }; -static void imx6_pcie_quirk(struct pci_dev *dev) +static void imx_pcie_quirk(struct pci_dev *dev) { struct pci_bus *bus = dev->bus; struct dw_pcie_rp *pp = bus->sysdata; @@ -1646,33 +1646,33 @@ static void imx6_pcie_quirk(struct pci_dev *dev) return; /* Make sure we only quirk devices associated with this driver */ - if (bus->dev.parent->parent->driver != &imx6_pcie_driver.driver) + if (bus->dev.parent->parent->driver != &imx_pcie_driver.driver) return; if (pci_is_root_bus(bus)) { struct dw_pcie *pci = to_dw_pcie_from_pp(pp); - struct imx6_pcie *imx6_pcie = to_imx6_pcie(pci); + struct imx_pcie *imx_pcie = to_imx_pcie(pci); /* * Limit config length to avoid the kernel reading beyond * the register set and causing an abort on i.MX 6Quad */ - if (imx6_pcie->drvdata->dbi_length) { - dev->cfg_size = imx6_pcie->drvdata->dbi_length; + if (imx_pcie->drvdata->dbi_length) { + dev->cfg_size = imx_pcie->drvdata->dbi_length; dev_info(&dev->dev, "Limiting cfg_size to %d\n", dev->cfg_size); } } } DECLARE_PCI_FIXUP_CLASS_HEADER(PCI_VENDOR_ID_SYNOPSYS, 0xabcd, - PCI_CLASS_BRIDGE_PCI, 8, imx6_pcie_quirk); + PCI_CLASS_BRIDGE_PCI, 8, imx_pcie_quirk); -static int __init imx6_pcie_init(void) +static int __init imx_pcie_init(void) { #ifdef CONFIG_ARM struct device_node *np; - np = of_find_matching_node(NULL, imx6_pcie_of_match); + np = of_find_matching_node(NULL, imx_pcie_of_match); if (!np) return -ENODEV; of_node_put(np); @@ -1688,6 +1688,6 @@ static int __init imx6_pcie_init(void) "external abort on non-linefetch"); #endif - return platform_driver_register(&imx6_pcie_driver); + return platform_driver_register(&imx_pcie_driver); } -device_initcall(imx6_pcie_init); +device_initcall(imx_pcie_init); From patchwork Tue May 7 18:45:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13657558 X-Patchwork-Delegate: kw@linux.com Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2058.outbound.protection.outlook.com [40.107.8.58]) (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 CDFC116D9C9; Tue, 7 May 2024 18:46:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.8.58 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715107607; cv=fail; b=W4Kp+uY/djAKUfeFWIKdccHb2d+HceJ1mw37cVrb9zYD3+qkOF2hS44n65O4oR/uynSyrnnO/LqbqH7pT7YPUlrMTmUv5yGK29QzcmoP+UyILrJt9eoxI0mt+gAbmOp5FajybKwGLPv1Voeo38e7BO1kgjmSH2AOjPX2NuXOhPA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715107607; c=relaxed/simple; bh=HrUWeYVHmrmTKrUKCJaXU6dRl1HPsn7pr8zXgIWX2Cg=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=VfODdjsciv7DHHmnMlcYrOxQgYrFkE4DucPpYmrVkZPNE0dLuzJx+tUHYfii0EJxWvs0See3rMGFvcVX+qp8wiDCOkTyO5q7OLVo5HPq5oi7ERTOmNfeO4SrcKHCfh317fhya54jRliAtUNY03xJpVQwwiNCvk6UA1j8aiAmnNo= 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 (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=dfhlR0Vc; arc=fail smtp.client-ip=40.107.8.58 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="dfhlR0Vc" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CLmTQkOJI2gOR9vb7pKtGWjJrlUM0hZyKEoShUtjyUVmtXYxSlDtLBpHQpIBjzY6YjCCXfHOinh2ZIQ7hnXilWQZO2fuY8J9uSWhRIRv1sV6tFJjeL2ioUKSvO65gVknZNCiVlnvx4S4u5bdXN1N0Pg3mHYLFRtL0UqiBu33KkG+TrLdJqqddVzuWLdn/hoyerHUGDHDBbv3iIHP4qliNT+UqLmRRzNbeiSXbVTWWUNJ9UzPlakIfvVYVmnGTdCtvdeJrBaAImpExgY/2gvu/00o3Vkm/ebzJTTK5wR+hm9ssRHBCk4ZKROU6RmMGSz/JSb75dHipybOc2BU7QgXhg== 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=wOyhcvTM1KJi2/kosZfh6oxXMrJ/Mmmbikrfp4HxhaE=; b=oIEUdfdR+nvE2rCUlpBF/8jML/+5TBB47niPO13TvFe831pTaBEKWgy65/XxjIGwfSMhV2x0xUPl8FGqWYEt0Mw8gu1xuXDz00Iy0X2TkmMPuEBgmhqysYZYU3Z5Pys47i5GJqEq/bx+SOIUntY6GA4cjfdpxzuza/v5Q51g+6ubZ1m3Hg2ua463w/n7tQDaZrX9r71iI03jbb5IEMCG1MMS9DbAUEkHn97IUvYP64GTuCokrfYVJN7kQx1qdxlJ7u9UWegckQ126WkYBS7evTo+P2WQNA85gZi1t5LVIoBbMElRlFCKyv43Ehte8Gg8s07EVSIBNru7Ya0KiV1BRw== 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=wOyhcvTM1KJi2/kosZfh6oxXMrJ/Mmmbikrfp4HxhaE=; b=dfhlR0VczfACm3bLo2CX/9CfaDbBSk3FxUt/TpScUyITwg+DvQkPurR8IH7Ccz+K9ZanqAFN5FvCs4jPWyykVUAYg7tZRGd3p6MTBEytGCAgBOIiWL9O/i2yj0CuttJEpXmztk70HTTCHGv5ayisy3An8XALzy9/cH5DeTbLrxY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by DU0PR04MB9636.eurprd04.prod.outlook.com (2603:10a6:10:320::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41; Tue, 7 May 2024 18:46:42 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::1e67:dfc9:d0c1:fe58]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::1e67:dfc9:d0c1:fe58%7]) with mapi id 15.20.7544.041; Tue, 7 May 2024 18:46:42 +0000 From: Frank Li Date: Tue, 07 May 2024 14:45:42 -0400 Subject: [PATCH v4 04/12] PCI: imx6: Introduce SoC specific callbacks for controlling REFCLK Message-Id: <20240507-pci2_upstream-v4-4-e8c80d874057@nxp.com> References: <20240507-pci2_upstream-v4-0-e8c80d874057@nxp.com> In-Reply-To: <20240507-pci2_upstream-v4-0-e8c80d874057@nxp.com> To: Richard Zhu , Lucas Stach , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Bjorn Helgaas , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Philipp Zabel , Liam Girdwood , Mark Brown , Manivannan Sadhasivam , Krzysztof Kozlowski , Conor Dooley Cc: linux-pci@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, devicetree@vger.kernel.org, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1715107574; l=8294; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=HrUWeYVHmrmTKrUKCJaXU6dRl1HPsn7pr8zXgIWX2Cg=; b=zr+Tq+E2eWIJb0kq+osrJSOtneDvx5fVh1GaNBh9txRy090jx1RPQ04ivfZ4LVyFUNDYd4yeS 3oqP9xlIoeQA81OHLh7MQ7IOZcHLtenATKREK/8VbNyd+zOTJhkUeT2 X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BY5PR17CA0026.namprd17.prod.outlook.com (2603:10b6:a03:1b8::39) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DU0PR04MB9636:EE_ X-MS-Office365-Filtering-Correlation-Id: d0843cc9-2c3f-4b09-3072-08dc6ec609c3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|376005|7416005|52116005|366007|921011|38350700005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?2ky7Wcpr5aMtAO6A3gqn1wWZX0hiKI/?= =?utf-8?q?CDOH1THZhMCB/UDPRWnwZ7o7Nb5wSdFBChErEsG5AMswstD0ASUGNz+3Zlb4bX7E8?= =?utf-8?q?+9EB9DAiEYAwah0Mt02oUZRlB6BYJkVC8/dDqLWP9qPIdQo8+5gYCyJOY08gYM7ha?= =?utf-8?q?F9OEgGrkA8SOroDJ9pzqdDe3o+1jVUX1fczsKEFbKDuaxc4WiJthcOG7unjxjQKqk?= =?utf-8?q?r1O2WJPUsPU9Um2HnKUHk2HT2U+dse4UqDiQpqMEn86CSZpSM9G+O7bAS+zbjM2wU?= =?utf-8?q?NzCa9dGdnPNn4asnYelB+DwkuAzWkaowPMtTOvaXVv7vQeigP/WcCAlG1QsnkV0LV?= =?utf-8?q?BhD8Cg4jHPUz41nLmj1ollhfA/U723rPusWyvFr++BeUTzAVHYiQdz3ecDKMkYMRY?= =?utf-8?q?6p7bAurFLFAA7uCi1o9lijW2NC3KmHLvdHg3lqvSejuf9RVh2re5huwMsguGzjymq?= =?utf-8?q?SGq4NDRe7zsPVXaljEMhnQ3Tetp6pSzcAh490G6nn0Tt1SZr+2kvIeewl8tcIt6re?= =?utf-8?q?Tr1hCI/FopaS/D3J1WusRZu8oHcjtbG08BHSXYCG1Ekid0yc+mRkn8stPxP+j5K3C?= =?utf-8?q?CPjWEllQ9WtwgRY6ih/EkL2X26Ict0Jt3qHX3UL3FBE0pYxdOTIrFXa9+BsMYDazf?= =?utf-8?q?h5GiWka49C34VvZrUT7gWzUHEHH7ogVl6O1gMer8ckL9yGUBWw82oWPsZGX6IiYfJ?= =?utf-8?q?8tqTKmc61c/YVaj8dtphoECr9W0rvGtODyYCUrOHQk56yflghZTusHRgjvtYAcwfM?= =?utf-8?q?gVaAxxi0JxtnEsAlgjEO4JoDi4dPuOeBmkE9W790W5/WgdCT/Lb7AEWCME+N7dNv5?= =?utf-8?q?WmvBygLT6fX2n1Oeh3v+RUHNw7EjbTWhmY+bC/C9HElh4v6q4Ym9zMkJANx3MI8g2?= =?utf-8?q?M8xSvTr0PgdlgKwrrh5of1Q6SE6rJej57sMe5m/b4By6uO92Nu8oKnxuJcP0DxJGf?= =?utf-8?q?E5N6UMwQMrxaComcx72lZXMePors/ORiwny9ryU/g6v3sU4h62ogKf/lem9CV/+C4?= =?utf-8?q?Q18HBdpB1b5HUvXXFBRTM3fggnRG6AxlvkdASXNeTeVcDMXJkzaNrrZeiIuPvDyl3?= =?utf-8?q?g3G3VZlL+DYzbwURq1pbYoXAxUzvjnIaapN2AuFB0Rxxz088VjeQt59Buiw4yF+4y?= =?utf-8?q?+LKcPon7GQKTlXB++uxDHRSEwxWCe1epcslYp4f9N6gkU0yvUkqr4N357TfmozVOf?= =?utf-8?q?jg2SU4xY5I4DsWvqgoB7Kl41RYuzb4vaEABkk6aISA34ep2TNtKjiQYw0zTRq+taz?= =?utf-8?q?9sJ38FvyhaRdkrcUypqPywL5uhAVdbQqsD5kR2hzWz+Z6XH8AVFwBPks=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(376005)(7416005)(52116005)(366007)(921011)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?OIFZIhx/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YJrJHDUC89MWNp2kSag?= =?utf-8?q?L5AohGUIxeHvDRwMOBmzoO3OniCmPT1h7ibuidWFkSuIiLfF/D0xk5/OG75/yGk/p?= =?utf-8?q?hLlJAdc+xBm3LFNCB+SFtEhv6/g6SXR9ZC8k4vOcW6tdd+FI8CbkInD2FjF7lG5Rh?= =?utf-8?q?EmGI/6ND6LhRj5gKAlabFiYYt2b/che18isyUCgjlcC8ipdF6RyUw/QQO//2nojtH?= =?utf-8?q?SoS/aX/V3GyDnKPnc/+4NVTVz4cRVjQU3gZlt6u0tOBCYyVV6LEaWo3lVewbpVfd8?= =?utf-8?q?e+k+9al8QxNnS/H6R0FaFPORdB0CGa0TgBNWGemohF86oXAwJjDuioPjGUBZ34ON6?= =?utf-8?q?sMtL9ZhfTLIpcss5Iasq3LpC2kQeN/t9sCYV8SUXZEMjbe8keNHDk8eIyUG8FZzqi?= =?utf-8?q?hZDrP+zi0QyGw+sRWuVfcdBM1ATtS5ppwjTmQe4eF/isKCw8AXzYT3AFgF8aXcO24?= =?utf-8?q?CMca+evQ6/p3yDzkV3BPDtTt2hGCZzDUnRAhnOMAvaFLd4px264/t1Y4WY5CpKDDe?= =?utf-8?q?fx84Aa5BCOZCRtOcG098/5iVwUPf2arZSMpir0ww2psAASqbDFjZCgWQ25F7KwhWK?= =?utf-8?q?GQzZRnYgwuUbNuoOtzxc8rJ2kjsL1AXP5HvTJFsbv+sAP+euYDn6UO6DMuoOhpRth?= =?utf-8?q?EcKqiN5SY1LR?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d0843cc9-2c3f-4b09-3072-08dc6ec609c3 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2024 18:46:42.7384 (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: hkswfPf+UoRNCVdho15zEYg5FlSeCe7E93rrhHop2aKj9KTUEGTc/oMNpkP0Ocu7lcYxZ6HOLOITgOD2i/SLCw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9636 Instead of using the switch case statement to enable/disable the reference clock handled by this driver itself, let's introduce a new callback set_ref_clk() and define it for platforms that require it. This simplifies the code. Signed-off-by: Frank Li --- drivers/pci/controller/dwc/pci-imx6.c | 112 ++++++++++++++++------------------ 1 file changed, 52 insertions(+), 60 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index e93070d60df52..cf1b487b3f625 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -103,6 +103,7 @@ struct imx_pcie_drvdata { const u32 mode_mask[IMX_PCIE_MAX_INSTANCES]; const struct pci_epc_features *epc_features; int (*init_phy)(struct imx_pcie *pcie); + int (*set_ref_clk)(struct imx_pcie *pcie, bool enable); }; struct imx_pcie { @@ -585,21 +586,19 @@ static int imx_pcie_attach_pd(struct device *dev) return 0; } -static int imx_pcie_enable_ref_clk(struct imx_pcie *imx_pcie) +static int imx6sx_pcie_set_ref_clk(struct imx_pcie *imx_pcie, bool enable) { - unsigned int offset; - int ret = 0; + regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR12, IMX6SX_GPR12_PCIE_TEST_POWERDOWN, + enable ? 0 : IMX6SX_GPR12_PCIE_TEST_POWERDOWN); - switch (imx_pcie->drvdata->variant) { - case IMX6SX: - regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR12, - IMX6SX_GPR12_PCIE_TEST_POWERDOWN, 0); - break; - case IMX6QP: - case IMX6Q: + return 0; +} + +static int imx6q_pcie_set_ref_clk(struct imx_pcie *imx_pcie, bool enable) +{ + if (enable) { /* power up core phy and enable ref clock */ - regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR1, - IMX6Q_GPR1_PCIE_TEST_PD, 0 << 18); + regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR1, IMX6Q_GPR1_PCIE_TEST_PD, 0); /* * the async reset input need ref clock to sync internally, * when the ref clock comes after reset, internal synced @@ -608,54 +607,34 @@ static int imx_pcie_enable_ref_clk(struct imx_pcie *imx_pcie) */ usleep_range(10, 100); regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR1, - IMX6Q_GPR1_PCIE_REF_CLK_EN, 1 << 16); - break; - case IMX7D: - case IMX95: - case IMX95_EP: - break; - case IMX8MM: - case IMX8MM_EP: - case IMX8MQ: - case IMX8MQ_EP: - case IMX8MP: - case IMX8MP_EP: - offset = imx_pcie_grp_offset(imx_pcie); - /* - * Set the over ride low and enabled - * make sure that REF_CLK is turned on. - */ - regmap_update_bits(imx_pcie->iomuxc_gpr, offset, - IMX8MQ_GPR_PCIE_CLK_REQ_OVERRIDE, - 0); - regmap_update_bits(imx_pcie->iomuxc_gpr, offset, - IMX8MQ_GPR_PCIE_CLK_REQ_OVERRIDE_EN, - IMX8MQ_GPR_PCIE_CLK_REQ_OVERRIDE_EN); - break; + IMX6Q_GPR1_PCIE_REF_CLK_EN, IMX6Q_GPR1_PCIE_REF_CLK_EN); + } else { + regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR1, + IMX6Q_GPR1_PCIE_REF_CLK_EN, 0); + regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR1, + IMX6Q_GPR1_PCIE_TEST_PD, IMX6Q_GPR1_PCIE_TEST_PD); } - return ret; + return 0; } -static void imx_pcie_disable_ref_clk(struct imx_pcie *imx_pcie) +static int imx8mm_pcie_set_ref_clk(struct imx_pcie *imx_pcie, bool enable) { - switch (imx_pcie->drvdata->variant) { - case IMX6QP: - case IMX6Q: - regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR1, - IMX6Q_GPR1_PCIE_REF_CLK_EN, 0); - regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR1, - IMX6Q_GPR1_PCIE_TEST_PD, - IMX6Q_GPR1_PCIE_TEST_PD); - break; - case IMX7D: - regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR12, - IMX7D_GPR12_PCIE_PHY_REFCLK_SEL, - IMX7D_GPR12_PCIE_PHY_REFCLK_SEL); - break; - default: - break; - } + int offset = imx_pcie_grp_offset(imx_pcie); + + /* Set the over ride low and enabled make sure that REF_CLK is turned on.*/ + regmap_update_bits(imx_pcie->iomuxc_gpr, offset, IMX8MQ_GPR_PCIE_CLK_REQ_OVERRIDE, + enable ? 0 : IMX8MQ_GPR_PCIE_CLK_REQ_OVERRIDE); + regmap_update_bits(imx_pcie->iomuxc_gpr, offset, IMX8MQ_GPR_PCIE_CLK_REQ_OVERRIDE_EN, + enable ? IMX8MQ_GPR_PCIE_CLK_REQ_OVERRIDE_EN : 0); + return 0; +} + +static int imx7d_pcie_set_ref_clk(struct imx_pcie *imx_pcie, bool enable) +{ + regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR12, IMX7D_GPR12_PCIE_PHY_REFCLK_SEL, + enable ? 0 : IMX7D_GPR12_PCIE_PHY_REFCLK_SEL); + return 0; } static int imx_pcie_clk_enable(struct imx_pcie *imx_pcie) @@ -668,10 +647,12 @@ static int imx_pcie_clk_enable(struct imx_pcie *imx_pcie) if (ret) return ret; - ret = imx_pcie_enable_ref_clk(imx_pcie); - if (ret) { - dev_err(dev, "unable to enable pcie ref clock\n"); - goto err_ref_clk; + if (imx_pcie->drvdata->set_ref_clk) { + ret = imx_pcie->drvdata->set_ref_clk(imx_pcie, true); + if (ret) { + dev_err(dev, "Failed to enable PCIe REFCLK\n"); + goto err_ref_clk; + } } /* allow the clocks to stabilize */ @@ -686,7 +667,8 @@ static int imx_pcie_clk_enable(struct imx_pcie *imx_pcie) static void imx_pcie_clk_disable(struct imx_pcie *imx_pcie) { - imx_pcie_disable_ref_clk(imx_pcie); + if (imx_pcie->drvdata->set_ref_clk) + imx_pcie->drvdata->set_ref_clk(imx_pcie, false); clk_bulk_disable_unprepare(imx_pcie->drvdata->clks_cnt, imx_pcie->clks); } @@ -1465,6 +1447,7 @@ static const struct imx_pcie_drvdata drvdata[] = { .mode_off[0] = IOMUXC_GPR12, .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, .init_phy = imx_pcie_init_phy, + .set_ref_clk = imx6q_pcie_set_ref_clk, }, [IMX6SX] = { .variant = IMX6SX, @@ -1479,6 +1462,7 @@ static const struct imx_pcie_drvdata drvdata[] = { .mode_off[0] = IOMUXC_GPR12, .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, .init_phy = imx6sx_pcie_init_phy, + .set_ref_clk = imx6sx_pcie_set_ref_clk, }, [IMX6QP] = { .variant = IMX6QP, @@ -1494,6 +1478,7 @@ static const struct imx_pcie_drvdata drvdata[] = { .mode_off[0] = IOMUXC_GPR12, .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, .init_phy = imx_pcie_init_phy, + .set_ref_clk = imx6q_pcie_set_ref_clk, }, [IMX7D] = { .variant = IMX7D, @@ -1506,6 +1491,7 @@ static const struct imx_pcie_drvdata drvdata[] = { .mode_off[0] = IOMUXC_GPR12, .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, .init_phy = imx7d_pcie_init_phy, + .set_ref_clk = imx7d_pcie_set_ref_clk, }, [IMX8MQ] = { .variant = IMX8MQ, @@ -1519,6 +1505,7 @@ static const struct imx_pcie_drvdata drvdata[] = { .mode_off[1] = IOMUXC_GPR12, .mode_mask[1] = IMX8MQ_GPR12_PCIE2_CTRL_DEVICE_TYPE, .init_phy = imx8mq_pcie_init_phy, + .set_ref_clk = imx8mm_pcie_set_ref_clk, }, [IMX8MM] = { .variant = IMX8MM, @@ -1530,6 +1517,7 @@ static const struct imx_pcie_drvdata drvdata[] = { .clks_cnt = ARRAY_SIZE(imx8mm_clks), .mode_off[0] = IOMUXC_GPR12, .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, + .set_ref_clk = imx8mm_pcie_set_ref_clk, }, [IMX8MP] = { .variant = IMX8MP, @@ -1541,6 +1529,7 @@ static const struct imx_pcie_drvdata drvdata[] = { .clks_cnt = ARRAY_SIZE(imx8mm_clks), .mode_off[0] = IOMUXC_GPR12, .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, + .set_ref_clk = imx8mm_pcie_set_ref_clk, }, [IMX95] = { .variant = IMX95, @@ -1567,6 +1556,7 @@ static const struct imx_pcie_drvdata drvdata[] = { .mode_mask[1] = IMX8MQ_GPR12_PCIE2_CTRL_DEVICE_TYPE, .epc_features = &imx8m_pcie_epc_features, .init_phy = imx8mq_pcie_init_phy, + .set_ref_clk = imx8mm_pcie_set_ref_clk, }, [IMX8MM_EP] = { .variant = IMX8MM_EP, @@ -1579,6 +1569,7 @@ static const struct imx_pcie_drvdata drvdata[] = { .mode_off[0] = IOMUXC_GPR12, .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, .epc_features = &imx8m_pcie_epc_features, + .set_ref_clk = imx8mm_pcie_set_ref_clk, }, [IMX8MP_EP] = { .variant = IMX8MP_EP, @@ -1591,6 +1582,7 @@ static const struct imx_pcie_drvdata drvdata[] = { .mode_off[0] = IOMUXC_GPR12, .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, .epc_features = &imx8m_pcie_epc_features, + .set_ref_clk = imx8mm_pcie_set_ref_clk, }, [IMX95_EP] = { .variant = IMX95_EP, From patchwork Tue May 7 18:45:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13657559 X-Patchwork-Delegate: kw@linux.com Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2051.outbound.protection.outlook.com [40.107.8.51]) (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 0FC3B16EC15; Tue, 7 May 2024 18:46:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.8.51 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715107614; cv=fail; b=OCyHRuMMW5QUzzYFLT0gsUu32jU+yKBtD1Fvo87Js1zCU7m0AOBL/jGJ0MEIdLuCNR1OR6T0fdq+If2iup58wFolxichtigmcKJadRkumwzktMqpG82WB8lkXsqnhBgCyowCM8N/XqprSbB30hR+h841PvbQkA+3w+plB0HSZaU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715107614; c=relaxed/simple; bh=Cpqug5G7k49MqW0A3NFncM6Y5cYEpxavVt54pyo/9Qo=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=tIJiDmCWHqoTLbGpn2wxisFb5Fz4/Ryfe/ztIKvK2RqfgTcKWV6Mhv0ihZ4wTtKVAzNmBGt6D08NsLA5QdN7K3iTwEOcKggW8JyacQGpPnzs1cy8+jSpLQYmqMG1m+TYK8HwHdEEYOVUsyocIBB0TKIxH99SaZpGsfPJ5ZNlDAI= 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 (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=UCaex8/p; arc=fail smtp.client-ip=40.107.8.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="UCaex8/p" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X04qXaaiC0595okiuRTgeJ5h0C7PK5co38cw1HDgZRpSWJ36ERX+Qh3nR4VOpSBT0Cty+3NGfllkQlOK7FJbqAJdTpfvx/DxXR0XYmU3FplNGemT5+86TTLdkYcr8NJUqSvaQdsQkBEk4hfpSagS/EUMR2kSEsOuXLt1araawdnkbH2chFTpgc8PoVlSFFHkEmVACl2r06AMwiKh3osudeNMQRPLaGg5DS0Ztsh+ja0vMUdYb2kJ4b0whr8U1tqGFZTzr1uyDXr60Oft6wpqnKNKPWy7uKvZo5Sj/jd2W6nUhnAPiNr9J16IJX9F1vesNCmLSJbvob0Vyn9zTQ68ag== 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=1nl/ELpxThlz8kTl1lbs0j8zTFjcylBahXo9Jv8iXEQ=; b=STE0mmZDrX9hhAOVD7lrmzGPyjuRCS0Ij0oRy60OFv8peYGqJvmHr4DQJ6tEo9neqeJaBOEBMEerFgq/7Shb8dfmggiBLhCiCNlvBGg54aUYHW6GBessGHwqXWeWZNyxpoIfEOQfh0OG3FSS17hBHKcN8bMgDdS5qzfo7uLQ2RaGJxgQ4rabhrQPT3VOrE+zT72mpUiIXsqZ80Qvy6xzXZEK4wvfr+ie+TspltnFzHv92pIrau1gg8rkp941vg62EF7pgmW9fSt0/gOvwKyi2r3IBCRpJFxU/n9ZnkYcL+tFhiSQpzh6fOJ2giNtK8QvzUpnHFoMoiqTYEyKDAHPRg== 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=1nl/ELpxThlz8kTl1lbs0j8zTFjcylBahXo9Jv8iXEQ=; b=UCaex8/p1vPPrz21votM0zO6eoLEhHantCIdjlBf79AjJ2ODzaDtXAAiK0GRRF7c4D4SqrzRVuQPWSEx2dHXVPQ6hH7VszRRDULYYFreYt/ks9ZBkA3Idja3tPmJkhA2SgR+4pimqfmtQjfa84IP5W58kY6Qp3z1/ZMrqhGhz70= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by DU0PR04MB9636.eurprd04.prod.outlook.com (2603:10a6:10:320::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41; Tue, 7 May 2024 18:46:48 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::1e67:dfc9:d0c1:fe58]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::1e67:dfc9:d0c1:fe58%7]) with mapi id 15.20.7544.041; Tue, 7 May 2024 18:46:48 +0000 From: Frank Li Date: Tue, 07 May 2024 14:45:43 -0400 Subject: [PATCH v4 05/12] PCI: imx6: Simplify switch-case logic by involve core_reset callback Message-Id: <20240507-pci2_upstream-v4-5-e8c80d874057@nxp.com> References: <20240507-pci2_upstream-v4-0-e8c80d874057@nxp.com> In-Reply-To: <20240507-pci2_upstream-v4-0-e8c80d874057@nxp.com> To: Richard Zhu , Lucas Stach , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Bjorn Helgaas , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Philipp Zabel , Liam Girdwood , Mark Brown , Manivannan Sadhasivam , Krzysztof Kozlowski , Conor Dooley Cc: linux-pci@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, devicetree@vger.kernel.org, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1715107574; l=7027; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=Cpqug5G7k49MqW0A3NFncM6Y5cYEpxavVt54pyo/9Qo=; b=lEu/WKLevwLBU+GsXyEDwvrd1ECLpXCE+545syYEZrWi459n2RA8Kly2lP5zalZ9HTiR+1r5W Fea6U/DC0OED4frS1NOFa2IqxnLTcpo54e9NgZsJt7QhU/DJh5OAcP7 X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BY5PR17CA0026.namprd17.prod.outlook.com (2603:10b6:a03:1b8::39) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DU0PR04MB9636:EE_ X-MS-Office365-Filtering-Correlation-Id: c0271a42-03b3-4e7e-a494-08dc6ec60d0f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|376005|7416005|52116005|366007|921011|38350700005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?AU6XW3EXou5XG99J/1I0hVyCmJKL+nD?= =?utf-8?q?9ZM5kq7M89Sc/XF3iv5odM4khKGh9ym2a7fHUD259aPv5fCNMa4NZosAVKzR67zQj?= =?utf-8?q?95PY18ZsorxywAhboMA3LERxa+foMeab5Fha4af+aJjPK7q3YzAXaZ7uJ4bZm7Uzn?= =?utf-8?q?Idy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Wh10KnDYJPswpeEd05JTVCx5kXLsnRBSmZAC?= =?utf-8?q?QKGZLPb4dSWCOKZtUGeWmCyovtgo26OapsP6oG1KkZu9wDO1MQAIr4NTUdY+UTBc3?= =?utf-8?q?PSqBUJMdP43cSoPAJ9Y2NEvpSKtjsXClE6flYiJSymzHOAAnZWBM2X9TVZb+HA0E/?= =?utf-8?q?nuVERPLyLNuRXCRIl6Sm20RVHbGzM60A81BKkX/PEx0GfgG+lKhLrklCjduHoYbCR?= =?utf-8?q?KXU438913IiwkRsvYUMO3Cnw8zQsyJX2lbcdVTXLz+gW12+3Je2FU/us=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(376005)(7416005)(52116005)(366007)(921011)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?/XpP8x1uvO6MYnginIUDc8E88k05?= =?utf-8?q?/+dYsPLmyZQe6nsGDWciNROkVY3QMyJdi/rZnvMaXLm20MTUCstkuWlPjc7vqS3rZ?= =?utf-8?q?8uF1JNH1IMvwiXHG+K3A3UAmXc4TPyLXkdOAw6qAVqFEFo++YYpwIzi1nWN/1IB8L?= =?utf-8?q?23his9MxKUIjTG7xy5aU5mx5OOuCEg/aB/dXb9x65M0JB6vvAWAOmI1gPEwtQFV8g?= =?utf-8?q?rY1k3t+qjBulh4NQRUHtqg9fakK04n31pzRuqUmP8DTmLKoTNvtRGe8hXuDm0Jq/l?= =?utf-8?q?Pi6D5aqXjWisT0kbe9qS/9PZVYrhkxAD/poFfwRw66h79xEnbfUqCMK31HDg/V83L?= =?utf-8?q?QJZnuKtPCEgP+1CRsRwSqsxtMTwN17HDJWtj23hKCmOvBC8oLIYjqW4SDxe7r6FfK?= =?utf-8?q?3od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7p2EmnZ3QC8cCW7CS/m7X1Q4ThzvWs5shBsHMmmKr?= =?utf-8?q?U7Gz7d1I4n1QgId0z/l4htnSe+eiNF0Q0rzk9hYo+8N1zs1drz1gWWRtNqp5tDG9j?= =?utf-8?q?ep7eSs+315GR0kB30w78Ip/iTZhguwh6gYk8/3YjhO42IqmyGCOE5gGW9B6R8kFBv?= =?utf-8?q?64LdM5sXqdu/wVVga8szIrMzl3BAgxZXV+wXNgvSgGUhGe446D5Ltqx+4JnWUwjg4?= =?utf-8?q?3WGyMGnHUcig?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c0271a42-03b3-4e7e-a494-08dc6ec60d0f X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2024 18:46:48.8087 (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: KszmCK5zHC0m2Q4kON4cTUQDZIzGZsS46RJEd+26QsyJ++wbNQaLlOBUmvv9dUcKGVniQ5Hf7ptSsEifRBgRyg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9636 Instead of using the switch case statement to assert/dassert the core reset handled by this driver itself, let's introduce a new callback core_reset() and define it for platforms that require it. This simplifies the code. Signed-off-by: Frank Li --- drivers/pci/controller/dwc/pci-imx6.c | 134 ++++++++++++++++++---------------- 1 file changed, 71 insertions(+), 63 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index cf1b487b3f625..7396f0d51119a 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -104,6 +104,7 @@ struct imx_pcie_drvdata { const struct pci_epc_features *epc_features; int (*init_phy)(struct imx_pcie *pcie); int (*set_ref_clk)(struct imx_pcie *pcie, bool enable); + int (*core_reset)(struct imx_pcie *pcie, bool assert); }; struct imx_pcie { @@ -672,35 +673,75 @@ static void imx_pcie_clk_disable(struct imx_pcie *imx_pcie) clk_bulk_disable_unprepare(imx_pcie->drvdata->clks_cnt, imx_pcie->clks); } +static int imx6sx_pcie_core_reset(struct imx_pcie *imx_pcie, bool assert) +{ + if (assert) + regmap_set_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR12, + IMX6SX_GPR12_PCIE_TEST_POWERDOWN); + + /* Force PCIe PHY reset */ + regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR5, IMX6SX_GPR5_PCIE_BTNRST_RESET, + assert ? IMX6SX_GPR5_PCIE_BTNRST_RESET : 0); + return 0; +} + +static int imx6qp_pcie_core_reset(struct imx_pcie *imx_pcie, bool assert) +{ + regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR1, IMX6Q_GPR1_PCIE_SW_RST, + assert ? IMX6Q_GPR1_PCIE_SW_RST : 0); + if (!assert) + usleep_range(200, 500); + + return 0; +} + +static int imx6q_pcie_core_reset(struct imx_pcie *imx_pcie, bool assert) +{ + if (!assert) + return 0; + + regmap_set_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR1, IMX6Q_GPR1_PCIE_TEST_PD); + regmap_set_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR1, IMX6Q_GPR1_PCIE_REF_CLK_EN); + + return 0; +} + +static int imx7d_pcie_core_reset(struct imx_pcie *imx_pcie, bool assert) +{ + struct dw_pcie *pci = imx_pcie->pci; + struct device *dev = pci->dev; + + if (assert) + return 0; + + /* + * 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. + */ + + if (likely(imx_pcie->phy_base)) { + /* De-assert DCC_FB_EN */ + writel(PCIE_PHY_CMN_REG4_DCC_FB_EN, imx_pcie->phy_base + PCIE_PHY_CMN_REG4); + /* Assert RX_EQS and RX_EQS_SEL */ + writel(PCIE_PHY_CMN_REG24_RX_EQ_SEL | PCIE_PHY_CMN_REG24_RX_EQ, + imx_pcie->phy_base + PCIE_PHY_CMN_REG24); + /* Assert ATT_MODE */ + writel(PCIE_PHY_CMN_REG26_ATT_MODE, imx_pcie->phy_base + PCIE_PHY_CMN_REG26); + } else { + dev_warn(dev, "Unable to apply ERR010728 workaround. DT missing fsl,imx7d-pcie-phy phandle ?\n"); + } + imx7d_pcie_wait_for_phy_pll_lock(imx_pcie); + return 0; +} + static void imx_pcie_assert_core_reset(struct imx_pcie *imx_pcie) { reset_control_assert(imx_pcie->pciephy_reset); reset_control_assert(imx_pcie->apps_reset); - switch (imx_pcie->drvdata->variant) { - case IMX6SX: - regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR12, - IMX6SX_GPR12_PCIE_TEST_POWERDOWN, - IMX6SX_GPR12_PCIE_TEST_POWERDOWN); - /* Force PCIe PHY reset */ - regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR5, - IMX6SX_GPR5_PCIE_BTNRST_RESET, - IMX6SX_GPR5_PCIE_BTNRST_RESET); - break; - case IMX6QP: - regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR1, - IMX6Q_GPR1_PCIE_SW_RST, - IMX6Q_GPR1_PCIE_SW_RST); - break; - case IMX6Q: - regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR1, - IMX6Q_GPR1_PCIE_TEST_PD, 1 << 18); - regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR1, - IMX6Q_GPR1_PCIE_REF_CLK_EN, 0 << 16); - break; - default: - break; - } + if (imx_pcie->drvdata->core_reset) + imx_pcie->drvdata->core_reset(imx_pcie, true); /* Some boards don't have PCIe reset GPIO. */ if (gpio_is_valid(imx_pcie->reset_gpio)) @@ -710,47 +751,10 @@ static void imx_pcie_assert_core_reset(struct imx_pcie *imx_pcie) static int imx_pcie_deassert_core_reset(struct imx_pcie *imx_pcie) { - struct dw_pcie *pci = imx_pcie->pci; - struct device *dev = pci->dev; - reset_control_deassert(imx_pcie->pciephy_reset); - switch (imx_pcie->drvdata->variant) { - case IMX7D: - /* Workaround for ERR010728, failure of PCI-e PLL VCO to - * oscillate, especially when cold. This turns off "Duty-cycle - * Corrector" and other mysterious undocumented things. - */ - if (likely(imx_pcie->phy_base)) { - /* De-assert DCC_FB_EN */ - writel(PCIE_PHY_CMN_REG4_DCC_FB_EN, - imx_pcie->phy_base + PCIE_PHY_CMN_REG4); - /* Assert RX_EQS and RX_EQS_SEL */ - writel(PCIE_PHY_CMN_REG24_RX_EQ_SEL - | PCIE_PHY_CMN_REG24_RX_EQ, - imx_pcie->phy_base + PCIE_PHY_CMN_REG24); - /* Assert ATT_MODE */ - writel(PCIE_PHY_CMN_REG26_ATT_MODE, - imx_pcie->phy_base + PCIE_PHY_CMN_REG26); - } else { - dev_warn(dev, "Unable to apply ERR010728 workaround. DT missing fsl,imx7d-pcie-phy phandle ?\n"); - } - - imx7d_pcie_wait_for_phy_pll_lock(imx_pcie); - break; - case IMX6SX: - regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR5, - IMX6SX_GPR5_PCIE_BTNRST_RESET, 0); - break; - case IMX6QP: - regmap_update_bits(imx_pcie->iomuxc_gpr, IOMUXC_GPR1, - IMX6Q_GPR1_PCIE_SW_RST, 0); - - usleep_range(200, 500); - break; - default: - break; - } + if (imx_pcie->drvdata->core_reset) + imx_pcie->drvdata->core_reset(imx_pcie, false); /* Some boards don't have PCIe reset GPIO. */ if (gpio_is_valid(imx_pcie->reset_gpio)) { @@ -1448,6 +1452,7 @@ static const struct imx_pcie_drvdata drvdata[] = { .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, .init_phy = imx_pcie_init_phy, .set_ref_clk = imx6q_pcie_set_ref_clk, + .core_reset = imx6q_pcie_core_reset, }, [IMX6SX] = { .variant = IMX6SX, @@ -1463,6 +1468,7 @@ static const struct imx_pcie_drvdata drvdata[] = { .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, .init_phy = imx6sx_pcie_init_phy, .set_ref_clk = imx6sx_pcie_set_ref_clk, + .core_reset = imx6sx_pcie_core_reset, }, [IMX6QP] = { .variant = IMX6QP, @@ -1479,6 +1485,7 @@ static const struct imx_pcie_drvdata drvdata[] = { .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, .init_phy = imx_pcie_init_phy, .set_ref_clk = imx6q_pcie_set_ref_clk, + .core_reset = imx6qp_pcie_core_reset, }, [IMX7D] = { .variant = IMX7D, @@ -1492,6 +1499,7 @@ static const struct imx_pcie_drvdata drvdata[] = { .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, .init_phy = imx7d_pcie_init_phy, .set_ref_clk = imx7d_pcie_set_ref_clk, + .core_reset = imx7d_pcie_core_reset, }, [IMX8MQ] = { .variant = IMX8MQ, From patchwork Tue May 7 18:45:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13657560 X-Patchwork-Delegate: kw@linux.com Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2044.outbound.protection.outlook.com [40.107.8.44]) (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 39F7816F0E3; Tue, 7 May 2024 18:46:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.8.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715107619; cv=fail; b=F5tFo0YHnB6QXy0Y/5Ukg9lH97Z8ZNfa/3XWUAaGIt+lskRa4ABYpe696EmmwNef8akJhV7DhFvdyEWJ6yxZmAJ1TLnbFhqi1BfEmA8NlAJVcz7+qYV7CvoZkcj691RqaLlHd7fH6nRHlei1bMlHTYjUxHnD1rH/HJwtIBHIN0U= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715107619; c=relaxed/simple; bh=6PxVWHNhAUXVQqBSArIaUpWHawAqcbFt/BL4vN7KTrw=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=gZLYIG8qG/xX/wmMWQw1zxdBMGfN62vTVs29hbAwdVRsyrQQ9r5L6SK8143ONdp32RYWLhnaT0+IaylazKhnQKqMlfNwbzAqaWva0Flc5I+ZlqJWMwzq0OUO+8pi5ZiauDYS1eAtiIN0l2fQ7aUOjrTNARFIx+KCEPYlqCXYptY= 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 (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=WEB15Wy+; arc=fail smtp.client-ip=40.107.8.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="WEB15Wy+" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U4MX9g+jjk9C+QMTTHZ5xww+LblaKFr7hpLrTJmerUEbhSNtV/1AMH/v50a/Rc2nHAY7wk2UGkfe00QzqOmn9JrGhCeihYtqsGpkypFIZe5b9KpMoJejMEM+H1r67JwEIJJf2alg3IuReJ7eACnE2EqWmN5G6Ni8xTF8JfhmVwhVoDXFHuGyAdFVmAoQK+S+av6hZclT06FjRSxexsuBoem2qQq48sPlJmnTu6/CGiqyLs/ep40Q477B3xchYMWM6xZk/Hsr0FeJieCpyOfTizxyhGTQHzNOAYSfkqKicBqfGEBHnGEs1envvp5C1tkrxUtQxQP/l+xqZ27XLKKzbg== 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=No1e6ggxcaWM6w5fhc2pL0xcstqCy/cseH/nZ7iA8to=; b=aqqeCNyumq6CPqj9pUE3L73D1ci7/D06Lln1rZTL5V47E7ynk63mKG0IbaAEaIUjEQlR0Fh07rHdSfncUuAM+IMT9Ms+ee9eo4C9U9G5o+OpyXntLeuAtJq/6WD0714wLCwj56pAsbEl5ecVUzvPX6FrrDQ6+gBvVXrV1ib4HeNyI7CKD8R5//FGHI0w47P1b8DGwG7OSLL0SF2Ay+YRPiCHM+ZwiHi08CEfWewn7fSu1njXNrHUqB0byGxXzehp851deDD1Em4hcv2weDZvsVsnyklqS425xlF2FznmuPwzoYoOE28mHqLA0ixLrV50NqQ1uFS5pqJhy5TZXct0gA== 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=No1e6ggxcaWM6w5fhc2pL0xcstqCy/cseH/nZ7iA8to=; b=WEB15Wy+argoIz62i/qYWNa6CbiwqKMHlQyZ8XXOfBYDIu8rRkUSsV/kqUS7TzQQdl0YSbh2zjk1ReWqJTAch2EvGUTtCbsTkCsSpGOpRPTEMgcPpqZykK/5tnZWOR8coOnWOPDi3Cx4oy1MtdqJsdxb6YIU1TXFjMl15uScl2U= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by DU0PR04MB9636.eurprd04.prod.outlook.com (2603:10a6:10:320::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41; Tue, 7 May 2024 18:46:54 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::1e67:dfc9:d0c1:fe58]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::1e67:dfc9:d0c1:fe58%7]) with mapi id 15.20.7544.041; Tue, 7 May 2024 18:46:54 +0000 From: Frank Li Date: Tue, 07 May 2024 14:45:44 -0400 Subject: [PATCH v4 06/12] PCI: imx6: Improve comment for workaround ERR010728 Message-Id: <20240507-pci2_upstream-v4-6-e8c80d874057@nxp.com> References: <20240507-pci2_upstream-v4-0-e8c80d874057@nxp.com> In-Reply-To: <20240507-pci2_upstream-v4-0-e8c80d874057@nxp.com> To: Richard Zhu , Lucas Stach , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Bjorn Helgaas , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Philipp Zabel , Liam Girdwood , Mark Brown , Manivannan Sadhasivam , Krzysztof Kozlowski , Conor Dooley Cc: linux-pci@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, devicetree@vger.kernel.org, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1715107574; l=1779; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=6PxVWHNhAUXVQqBSArIaUpWHawAqcbFt/BL4vN7KTrw=; b=dpNV5b7Bcq3i+CJaFrMuFzOmeJ6VpzfhNg34d2e3wRjWnU0GZTkhcGKtpAUhtZZx45/Bkr5Ol WJicUuCTpvxBJsXNiunlXbJq7f8T69owYCw67y5cKdixklWYeoW+KGg X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BY5PR17CA0026.namprd17.prod.outlook.com (2603:10b6:a03:1b8::39) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DU0PR04MB9636:EE_ X-MS-Office365-Filtering-Correlation-Id: 6cfba788-ca66-41e4-9ab7-08dc6ec610a6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|376005|7416005|52116005|366007|921011|38350700005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?wfW7UHugsY80yA2WUgebMYR/I/2hV18?= =?utf-8?q?KbQXUkz7NeFu8Gw0/ZvFDlcApaC9gdd05zc/JYYNEwuPM/B0vzCwYCeirm0y9bQfB?= =?utf-8?q?cXyXDwr7z9JSsZKsbam979+mJqCwb79D5tXom3F2OE6N67or/ygce+c+HxhQSEHUB?= =?utf-8?q?HSilywO/yPAUbOxDTb3lLI+m8Du1k2Qf4m0q1jp9301srWoNvskb2sEyk2oOsNRvY?= =?utf-8?q?vqnfNyI/ayZk6Nw1mc+wp6GBrtP1BMJ2lxXO5oL12m2XN0i9MkMyupxDQ/9yr3oIv?= =?utf-8?q?mSz/qiNkZkDCdor9a6QOzzOvvr64YEMFprwnxNrXGrl9a2LRAfLb6TNCF4hOHykKL?= =?utf-8?q?Kexivj48edPFyLSQgDqD6Vt91s46XR2LbscK+V8cF0SBP9yloCH2NCmxCM95agjxi?= =?utf-8?q?30g6jB2v3YddAJybG8mrzoyiI1cgrS4LfrDNhdAs/ls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-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(376005)(7416005)(52116005)(366007)(921011)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?AdQG/V+pfeM1VPQr+jI1SV3RIx7Q?= =?utf-8?q?UKOq1OKRkhPXRzYVDDxUW/haAeUNbd8NCZYm49EGpedBI0GEuHKUtMeIR1Og8VLOx?= =?utf-8?q?qO/tWtOGnnOB1lfxzCsYNeGuZW+4HAYZKpVhinWhpzN95FwAsCPs9ishe2KR7661W?= =?utf-8?q?UCu7e301tyX+KimN+sHcRk/IV8wIMfxW6RGRLEpdbOPZqKpT8BIQLrxtKUvCSkHOc?= =?utf-8?q?VPmUcp2AzygznGmz+42s/2RpcKnMQFEr79ReO8C5oMxS6rjDXZ9u7ghecwlSiNxIH?= =?utf-8?q?cxl2yksObxsq/6rVExhXFCAHZPgGq8UYGujzxZ9GAAhtYfyoay6N+qc1fwqKI16z9?= =?utf-8?q?RmTssnlSdPJynzxm+QM97AkBDIbS6Qrm7xtkMBekz8OCmLNiQ2FA4V/XprJ7SeEYc?= =?utf-8?q?uxIDLrBXx8Wt4qaE3sJWqY4nxUr2CSMq1WT9Yog3WcA80Tikg+2UVlcNtvmmnnElT?= =?utf-8?q?e8w4a411gBfyB3Qhr5ZLcB8pTJ8hdo45WdIZzlX2LL7wLgeul6qgx0rZUKKNReGoU?= =?utf-8?q?qqNydoxmWZowcimGqJOaagQWEsrQtiurkJnM6aC1+Hahrsxj0kv9u3lYciaed4HnI?= =?utf-8?q?Ht+ZoIZgnI2LkIhVh5mtUXN0oUSJGS9Ry9S9zrYFiRNxKoULQTJ1IMEi0wjl6peJZ?= =?utf-8?q?qeoUVwCmy0ZI94dtaTZ8IAPbllZx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rg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6cfba788-ca66-41e4-9ab7-08dc6ec610a6 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2024 18:46:54.2410 (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: 9Ur58RFRXbUWyNqOIZIDMk+veh+BF0b3gVqfX5l4fG30qrzrZ4kRFvYV0YEKB3d24eN3WfpZaEQxHpKnzsG84A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9636 Improve comment about workaround ERR010727 by using official errata document content. Signed-off-by: Frank Li --- drivers/pci/controller/dwc/pci-imx6.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index 7396f0d51119a..d074bcc34d7a7 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -715,9 +715,25 @@ static int imx7d_pcie_core_reset(struct imx_pcie *imx_pcie, bool assert) return 0; /* - * 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. + * Workaround for ERR010728 (IMX7DS_2N09P, Rev. 1.1, 4/2023): + * + * PCIe: PLL may fail to lock under corner conditions Initial VCO + * oscillation may fail under corner conditions such as cold + * temperature which will cause the PCIe PLL fail to lock in the + * initialization phase. + * + * The Duty-cycle Corrector calibration must be disabled. + * + * 1. De-assert the G_RST signal by clearing + * SRC_PCIEPHY_RCR[PCIEPHY_G_RST]. + * 2. De-assert DCC_FB_EN by writing data “0x29” to the register + * address 0x306d0014 (PCIE_PHY_CMN_REG4). + * 3. Assert RX_EQS, RX_EQ_SEL by writing data “0x48” to the register + * address 0x306d0090 (PCIE_PHY_CMN_REG24). + * 4. Assert ATT_MODE by writing data “0xbc” to the register + * address 0x306d0098 (PCIE_PHY_CMN_REG26). + * 5. De-assert the CMN_RST signal by clearing register bit + * SRC_PCIEPHY_RCR[PCIEPHY_BTN] */ if (likely(imx_pcie->phy_base)) { From patchwork Tue May 7 18:45:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13657561 X-Patchwork-Delegate: kw@linux.com Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2047.outbound.protection.outlook.com [40.107.8.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB02816F293; Tue, 7 May 2024 18:47:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.8.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715107624; cv=fail; b=tLHaxGJ1CdBN2b31KF5Wk4ZxpXJ4KgnYcZdQsAxvBQ83NnweoM5uBGqows4yF8VZfRGifCFnktf4Z4yC5SAs9pnBurqwcZHhALB8eldpFQOUw52pw8/4tnfZNx3fJ7zVMC0kWe9IppBIAr9/70dJVGjHhONLsM5i2/2QacERn/k= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715107624; c=relaxed/simple; bh=fRuAnexzFcdciFfcdAEZxW1Yau8j1A65EcffAYhydkg=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=cURfM1nFjsugAQIdpFkxQDnQltrkyTxQ29KlNf97JBxcEm2z5BACgipvvJRGDJEJCvELjN6nQ5xo8WqyeJ3PiDerLhL7TEcBlkMn+wgoUobv+ygqo0e73FPTjc4z89F9OK1+YHaPXRSYs2AAHQs/kmFf98bP+2sWveYf8gOC6eQ= 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 (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=VbFJIgtf; arc=fail smtp.client-ip=40.107.8.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="VbFJIgtf" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gay4YOq0YjuUS26IcPIf3HDtwjKXyzNsRrazs5XWZ/Aj9U0AH+Glyuq5o7rIBC4iF8GapKK9zdjen8qCAEzaX292F7+vnu1nWz7c1ZJU1fnNLoN5DNkW8GQ+W2Pk58B4tp/Pw4t3zIh5gR7SA7v0ioonTsc6eeYoWuw3MKVwyQ2JsvLa6xoejIt857pcBJyJ5YeCJzfKjCaeLgqHdjwogRrEX2UYnu5HmoEjokFeqhxb5O4sC/D8cF10jVkZ9a+hECCeDTEt7KRXgK3KckLC4PoxXPwx5+frr5Ehuu8JgIdHd6P5MCeIKa6wsBA/yfmt507aaM4qgLmG7NahvRv8Ww== 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=l3hLRtu6tlq4CUbpU2aouIFuo+Jil+5bWfaulAUHiw8=; b=OXF97OIAwyKj/qFsv7TF6dmx7Bthn2Xf+/iWd+sIzmcoPNF+ZvPRHCZe0GbMEakxgxhJOcT5cIjZpRmoGDmK6BmyPrPyw/oOszQ2XugCh5HQRybhZa5vufpUe61mEbQN1YXSEFzxdk39hDc6LjpuEkSeHw3MLDJLv4kF7FMB+moEE3VueAVfhOrsyCxIS3pS5lkripigaBzITH5kUx3gwQREZ5qwW8+B4mRDQx1xoMe3yT8Bqf1vNrnhqslsVJ0yJHFp3NHUQ2ASXC+QjdWR/JL3/gn37hZ0G6PaJQPaVU8eDujNYB7rzP8x4Owj6qt+Ja9AOrwApipUm6kfiYTFJQ== 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=l3hLRtu6tlq4CUbpU2aouIFuo+Jil+5bWfaulAUHiw8=; b=VbFJIgtfeatXeQJkNCBu/BJpzB8hQik3CsFqy7Bfe5debo2P68reGUI/Y8tX+0iNHBFZNRwMxBwjbNuw3N1FAljHLUbUR1r8mJMsmQFSIYVg38Xps0/AyKq5AftYsMTC3KXI8ogGwBkjfYQMVAP6n24+WElItL7qP3Fqsk2MUVI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by DU0PR04MB9636.eurprd04.prod.outlook.com (2603:10a6:10:320::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41; Tue, 7 May 2024 18:46:59 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::1e67:dfc9:d0c1:fe58]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::1e67:dfc9:d0c1:fe58%7]) with mapi id 15.20.7544.041; Tue, 7 May 2024 18:46:59 +0000 From: Frank Li Date: Tue, 07 May 2024 14:45:45 -0400 Subject: [PATCH v4 07/12] PCI: imx6: Add help function imx_pcie_match_device() Message-Id: <20240507-pci2_upstream-v4-7-e8c80d874057@nxp.com> References: <20240507-pci2_upstream-v4-0-e8c80d874057@nxp.com> In-Reply-To: <20240507-pci2_upstream-v4-0-e8c80d874057@nxp.com> To: Richard Zhu , Lucas Stach , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Bjorn Helgaas , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Philipp Zabel , Liam Girdwood , Mark Brown , Manivannan Sadhasivam , Krzysztof Kozlowski , Conor Dooley Cc: linux-pci@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, devicetree@vger.kernel.org, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1715107574; l=1526; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=fRuAnexzFcdciFfcdAEZxW1Yau8j1A65EcffAYhydkg=; b=3YVnuaByILStdkLLA+qLb8m/jl0Ys3Esr56UQFrMbjUc1CPdSlChVR5pnQ8FAP07s7WOxK2KU H0G5o2iU/gsBz0ZKjM153QM8huItXIre0UgtwS4oPNLhrHg9M2WpD7Q X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BY5PR17CA0026.namprd17.prod.outlook.com (2603:10b6:a03:1b8::39) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DU0PR04MB9636:EE_ X-MS-Office365-Filtering-Correlation-Id: 7d3c31d0-1b84-47c8-883c-08dc6ec613e4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|376005|7416005|52116005|366007|921011|38350700005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?4CRdyQKF5AqUHFOVPwlrgICbHyWl8s1?= =?utf-8?q?YwYTWyWYobmLxCbPqhdym7cgoYnDZ2GqDmOLQDsCnGSjEpdHtMR994t6GVxfFISpU?= =?utf-8?q?p3CFDqlN+saUsErupxkDQohjlmp2Ptk0qJtA1RrXu+WgjifxpWN4j4paUDFzWnXU5?= =?utf-8?q?/WIBFc+bYEVCXtXk5v8FcGaS91l3qJtieiPJHtNozU1xOnqLYxdx+3jnucuCUiydW?= =?utf-8?q?AqfQVvxT/ZS60lxLNwBBicQmjtpbFVQ8Ps46v45sw81V0foyz2cx0i8VXZIGcsdy5?= =?utf-8?q?hVV9dZCi4+8paLXfoQ2sX6tXteQjvVjUHuGzgrnT5NuJFmjWHju6XUqNiN/hJAjCj?= =?utf-8?q?fZ8eGdr6gM1e+yiHDe7GFugWsJykBm/KL7o49McEr+xbzi7HVxRrn0FXCl4xYsEFr?= =?utf-8?q?YmpG7LrWbx0R/AiInkJqDIJAhNDU2MiPrqpr4710C4u4ww0sEJHG1ndy90DOB2IxM?= =?utf-8?q?TBsV2j0XcC6cZNGrQJ2q5dTZtVjzpYy0jxqAn138ieJ/SHystFdTKhMiNVMk1tl9p?= =?utf-8?q?OW2nxhcdqBBJjwj/5vrY7ki/5bc2sYNj2GxNwQbEsrISA5lWAIPMpsUFEygIeehdI?= =?utf-8?q?PtG6RbmBq5FK7A+a3c68SUJzsAhUFYuYYpSOWrFuYSMZHVgIz/SWAjUx5KEkss8vx?= =?utf-8?q?UYJTzA0QPJzZQX0F4VJoPv9aZMfg9xxkjMpvrOwxLBpIPuzDK5ueDyBCW6y/EwoDM?= =?utf-8?q?xbpmpH8BGkFo1GI5JJybTiWu2j3Uu+0LLpm5CASl/xdlf1i8TtXyJppjfpkXhN6jo?= =?utf-8?q?+1m0gE+fGBOlYOajkQ6NU2s/exmEovrAA8LgcdoWf28x9n3PIx1o7UeLJTJIGMHJZ?= =?utf-8?q?dn1RK+cpegeUpW6LaK+b8VVEVHOD6oc1SPrSt1/HbEe2sym8cJ/Rk301NUwiymiVt?= =?utf-8?q?rjeswG+Btk2iO8AjUHctYF7YylddgtECDxNoNgYj3OTewbWiwnYBIValEhn8u4ATb?= =?utf-8?q?pYz9RiaJI2A+G/t1TZcKr1VoQ11oLSHCA2Dt4w/Dso5UvhjbSyPNFLq93hkIqNgZt?= =?utf-8?q?CiXt4ndTDZcDTXmHRKEgKlVryO5WbdQni5gSuMpGVFdoKDf8Fwvu/VQ0AMw4ubtZC?= =?utf-8?q?nAfGkaF4X4fITJmZ9ue4CzBVTyGt73+ZbrEylUMEMT4a5SDieS4Kip8MVAQLbd6Ke?= =?utf-8?q?jLtktx2lJF5RMugtJSL8Gdal4bEkVqEVnLiQqcWPJtN2EVRAdXCfAKXHOhsIxLWRo?= =?utf-8?q?bdyB64dOFcwSB8wawSGpAV6aQ3+cxqriByRDZzNSLIdHafcesgstmFJ8242h7k5QW?= =?utf-8?q?xdEU4OOGs3SbqFX2HNceqOGLSQ6Y2YYkADVrFAp6vVntyWnDrzQGL0v0=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(376005)(7416005)(52116005)(366007)(921011)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?Xg4mbzMBIgNsg5CW05eV3OwOw9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-8?q?1dDMynwIJ62hgAZDbvVDGTRahgS5s/jCd7BKsQP0IZmpXrC92qic6OFDOgE49Hupk?= =?utf-8?q?VuynPA5XohSnYYB720nmK2Fh7+cDeGSOAUrGqcEOVTqezkM3y3liSG9Y+Lgtg6AYw?= =?utf-8?q?ZWUNz6AdXpFqzEnB12IXrAGSjFjyH0+ofuIznbZ1p0PygVgwLzpOYr5oQlfZxTx63?= =?utf-8?q?cuV0kePVy8tHWzszl7wkI5RT1898fOgFGMNHJFUeG0geY57C8YhSWpSOe/zQcYFkJ?= =?utf-8?q?X/t8UmvIXWHlFIPJjvDR8vRrERP2WJtloIaoIO+qEBGx7Hii1ouLGE6RXvQLsiGIh?= =?utf-8?q?dStfMfcAa7spyMk5GSctPuGGOG9TZpTOAyCP96IGve7QtM3YBhkx6T870xlvW55JK?= =?utf-8?q?rgdFuh28lUVAYxWrXxjodCCv5frR44dptZv0vxsL95tCk26kWZbSmemHX5JoaDhsb?= =?utf-8?q?H5s/jpFte15JBkg0MR0rlruODynmIiGOXqcFIpoQmsesWl0RwcWWOwlxkPgz8cyiz?= =?utf-8?q?kWCehvlaSEN3OBUG0LghbbDCfWQt1zWE0w2PWkIFp/iTWRuouvx+uiYCNi7zbYGYn?= =?utf-8?q?5TrM3qFWz9vHdJvEtc2d2NHvJlGhhz0nyZA6dtluIcWIisGCzO+kTuy+9ynQ2533k?= =?utf-8?q?J1/sjJKjjj/Q?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7d3c31d0-1b84-47c8-883c-08dc6ec613e4 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2024 18:46:59.6986 (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: ARu326s5w14mlG5Cdhah7zUOuU37OQ/ZoUbIsHGFgtQjRc14+kUy5haKFFG6oFKOZJxBHK5/sUwCzDEFHGjWfw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9636 Introduce the help function imx_pcie_match_device() to facilitate imx_pcie_quirk() in verifying whether the device's bus driver corresponds to the IMX6 PCI controller. This addition lays the groundwork for future support of ITS and IOMMU in the IMX95. Signed-off-by: Frank Li --- drivers/pci/controller/dwc/pci-imx6.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index d074bcc34d7a7..b33d8790a93af 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -1652,17 +1652,25 @@ static struct platform_driver imx_pcie_driver = { .shutdown = imx_pcie_shutdown, }; -static void imx_pcie_quirk(struct pci_dev *dev) +static bool imx_pcie_match_device(struct pci_bus *bus) { - struct pci_bus *bus = dev->bus; - struct dw_pcie_rp *pp = bus->sysdata; - /* Bus parent is the PCI bridge, its parent is this platform driver */ if (!bus->dev.parent || !bus->dev.parent->parent) - return; + return false; /* Make sure we only quirk devices associated with this driver */ if (bus->dev.parent->parent->driver != &imx_pcie_driver.driver) + return false; + + return true; +} + +static void imx_pcie_quirk(struct pci_dev *dev) +{ + struct pci_bus *bus = dev->bus; + struct dw_pcie_rp *pp = bus->sysdata; + + if (!imx_pcie_match_device(bus)) return; if (pci_is_root_bus(bus)) { From patchwork Tue May 7 18:45:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13657562 X-Patchwork-Delegate: kw@linux.com Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2088.outbound.protection.outlook.com [40.107.8.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 3A3A74C8A; Tue, 7 May 2024 18:47:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.8.88 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715107630; cv=fail; b=SIyt6fbqHtn4BLPAAtTb16E3VTmH7EqEuUVRyHRyXw5ewoeyDhErHwurWBzT4Xr/udfQ/0ikFr/0TcSwOZuH9uRvz5x02cG1OqN7GcDdNGJoidwWRdRTY/3wBGbwb3zsvK/rp1UvuRbqxCi1TrUECVy6I/83/ue4U6nrjtWmqTc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715107630; c=relaxed/simple; bh=yIrgxNwnmNXUu+Xre51WI5K2xwHWcW1tzJ/Z0ZY1NwA=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=bhlu09bgiwq2uuf/CbrT7KNAWbqbimnvi+9DewxnSIVGQvS1VTsh2+tJQ+poD2Io0jhhVq9AICq40+vrZ/3EQnChzcU2b35lfst9fag7KHuKZWUQUD9nUK2CLujB5t1M8rOu8TV90CSlgEjUxvnM/NyF02anyPlMBQC805GxsQo= 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 (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=HjRlmyDi; arc=fail smtp.client-ip=40.107.8.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 (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="HjRlmyDi" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kJ8U1BefEGpUcX5CyF4c9aSZsIIyBv2UQRH3otAPHwW9I2EnhnV2NxjLZcuu17Mfm6x6nwBe+YON2Tx+yvbe6hvejMneJgRLqtS09UMrficfrYv8fCmcbPSduzt+jpCyTRWA1ucAnuMdrt0bYMzjIWm+XizeoXj99avesqkLSYi9OfX+B/ju/YdXuxoNDOmXWde/q75sLTzP6mw8JmDpVCMDoUsH3R31PUrn7A4JjLe0J8RxGV75pjsbDXDLcHxRp1A6hnjbbAo7FHnwnXR8aCk45FkGmOjOLNqOllAFKQ3xia6IjVzdIHpd0RZG/ubqarHT+CTneWgdzvvU/urAIw== 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=zY5T/oWna/5HjL2EqSYd7JGvKX/go1wp1bRk/SJgUGg=; b=JtfZTlk2UYyouGrhs3HIVd2hEosJcABnsIMocSgEa8I1oRWL4qbMUKEWpSmyvk0xnYTRH0MaQpzaRd+xZHb1G7FgLYCtxTJ0MCNQg7JDggN22idVOyU4fenBV7dUQ58Ffn7b+FNRTJooHm5/r7Td2xvaeRcpSoQ6Zt1rFqf+20goEL9Vw3U7E1mxbDhvjzCFbYcZiefvkG9sSI/YQwLb+T+yQzuCTRPmLXtIhGD8J+TDdpU1hwY+s7YdEQEoCtM0JLTb4OvSWyQOYq8F41ICxnO4DJ/IMHKN7nYNbCOdiPnfCg9Ck/msLcYmSeKCkIzmwou7/03uBKCRYpHPfkkgSg== 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=zY5T/oWna/5HjL2EqSYd7JGvKX/go1wp1bRk/SJgUGg=; b=HjRlmyDi/IybXyF8p+z/Mq939YA0IbWS0jWSxGam931AO83Hrub2YgKl+NL2LSzaGYUdQjUptjDS1X25f5IP8OjGTC5tGx2OZxGHF0nfjSvEp0jb4zNclUGA5e6dphMW/M8Mbm6H7Dn2cXEVK3orgtWmN5LWJnN7xA9L9+4fT6c= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by DU0PR04MB9636.eurprd04.prod.outlook.com (2603:10a6:10:320::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41; Tue, 7 May 2024 18:47:05 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::1e67:dfc9:d0c1:fe58]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::1e67:dfc9:d0c1:fe58%7]) with mapi id 15.20.7544.041; Tue, 7 May 2024 18:47:05 +0000 From: Frank Li Date: Tue, 07 May 2024 14:45:46 -0400 Subject: [PATCH v4 08/12] PCI: imx6: Config look up table(LUT) to support MSI ITS and IOMMU for i.MX95 Message-Id: <20240507-pci2_upstream-v4-8-e8c80d874057@nxp.com> References: <20240507-pci2_upstream-v4-0-e8c80d874057@nxp.com> In-Reply-To: <20240507-pci2_upstream-v4-0-e8c80d874057@nxp.com> To: Richard Zhu , Lucas Stach , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Bjorn Helgaas , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Philipp Zabel , Liam Girdwood , Mark Brown , Manivannan Sadhasivam , Krzysztof Kozlowski , Conor Dooley Cc: linux-pci@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, devicetree@vger.kernel.org, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1715107574; l=7874; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=yIrgxNwnmNXUu+Xre51WI5K2xwHWcW1tzJ/Z0ZY1NwA=; b=gEDVVe7ncxBPhBycpIKpSQb9a0bq1Vgfh5CoJiS3J91K6frQlbIQ6Cty4KOj4STrOJOPjwDR0 oENOuE/5rDmBn2LHdI1G6NoQ7W5Y5RN+7qWj0lWHsAwzsgc7Ioy8l96 X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BY5PR17CA0026.namprd17.prod.outlook.com (2603:10b6:a03:1b8::39) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DU0PR04MB9636:EE_ X-MS-Office365-Filtering-Correlation-Id: 499d5d02-1ad8-4dbc-fc78-08dc6ec6172b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|376005|7416005|52116005|366007|921011|38350700005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?3t9b2THP0MjfWtUunAaIawyfXkpqsGL?= =?utf-8?q?TwcK8W9fL9YbPaBZXyrq1TEvv1dg4YQVjHeofmMx2DEdtBceuAVGC0KXUlvvxpZCM?= =?utf-8?q?0u1eqpjRmZAM4LdeYRGz9sf51BQInldvcuZQp6rk+s/+K04X5JS0qm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buJ2LiRkF?= =?utf-8?q?xg/3InkJ7Ch4PnQ4g/oOCiAcmOuXIbcteiSNlnPs7zFqJEBp3OIprBjdhaob0Sr/t?= =?utf-8?q?SHbwOPuzQPPplv+pONxVLDSkj5M/+FW5JgmVy4wOAlfmcA2nDbma4UJEHQg3pyAZ9?= =?utf-8?q?ONwMeobddnWBuh6PQHZTbpG/4mOxWIMvnEOdva5fNvTF5OTBwJWHpjam1XjrJdRN3?= =?utf-8?q?0kifMEiHyJJdKt4I+PW5JHM70p+OrIc3Jd5jWnM9yrDhWIkXAyJWLeUVo91+Q3+tI?= =?utf-8?q?hWEdZq/XPYRM7IS+l4KihOsZ7u1mP9ve52FJGyPO/UkSoAG/Ep5t1R+s=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(376005)(7416005)(52116005)(366007)(921011)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?ES/HVHxjJ/m8CIQY3z2XsPMuh7Fd?= =?utf-8?q?wOjPM8VeW/kkugkOlfScwDPlUVszKbdE7K9YWDcGXmeRBxZU4NEjjURVaqjYx3Mb9?= =?utf-8?q?+TNtWwFhfn9BtGCZvdtnTgnwcF6AWoNqtIehcq5J16m9JXw28tgKlXD9PrYYmaNwN?= =?utf-8?q?QW9KpBmIuAzkatVooBUuOzzsk+0BESSe4NF2dZxZOdwa78zQSkTPvdigBJyFV4QI4?= =?utf-8?q?kH+qMEdMDxNrdmvswWHQP6tfCjJ7aq0EULhDuDJNStsiBYDTH1Tde6IxM5oehCZWv?= =?utf-8?q?xyZqNUUH/ohK4m3iANmG0kg6sWlBr3yMmHX3k0dwORxhQa2kt8qa/tf6pY0GK2v0A?= =?utf-8?q?LeTwZBUCF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Czrl0ffMSsTV/M8AGDeljeyxKRiq+haYWZCxyGq35xsMs7?= =?utf-8?q?5m2gHr6vzR7D0e5YpKr5FSE+W+IJJxtApfaDdpYkuGo7MNRoQB4dX3+YYcU3MBVcl?= =?utf-8?q?E+3uKShSYH1mhLY5MPDW1siB1vvVYDT8dY8ER2nPHuPsJgmeiMJhucb43YwoZWezy?= =?utf-8?q?QSJB2sZyTzLQ/yQPcmsSVV5rEVpwklT2DnPhi93s7ZsqVSSPwiWiS3d6nJYdLcoh/?= =?utf-8?q?Ljx4PJgjddv6OeE5Bcbc0uGC+2mO6Ht1nH8aEffEnmCzJx9sr0G4sA+AABH/QsnRE?= =?utf-8?q?NB3pbSTKaABo?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 499d5d02-1ad8-4dbc-fc78-08dc6ec6172b X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2024 18:47:05.2505 (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: zBKcmKWX2uVYzHemRLGFKWz7C15GajKSPTm0nnKbdIGGtlhRIuq82uGDvJ6i//MXOp1Sq9wLOdE1jM9JW7vyHg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9636 For the i.MX95, configuration of a LUT is necessary to convert Bus Device Function (BDF) to stream IDs, which are utilized by both IOMMU and ITS. This involves examining the msi-map and smmu-map to ensure consistent mapping of PCI BDF to the same stream IDs. Subsequently, LUT-related registers are configured. In the absence of an msi-map, the built-in MSI controller is utilized as a fallback. Additionally, register a PCI bus notifier to trigger imx_pcie_add_device() upon the appearance of a new PCI device and when the bus is an iMX6 PCI controller. This function configures the correct LUT based on Device Tree Settings (DTS). Signed-off-by: Frank Li --- drivers/pci/controller/dwc/pci-imx6.c | 175 +++++++++++++++++++++++++++++++++- 1 file changed, 174 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index b33d8790a93af..66573ef7a002b 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -55,6 +55,22 @@ #define IMX95_PE0_GEN_CTRL_3 0x1058 #define IMX95_PCIE_LTSSM_EN BIT(0) +#define IMX95_PE0_LUT_ACSCTRL 0x1008 +#define IMX95_PEO_LUT_RWA BIT(16) +#define IMX95_PE0_LUT_ENLOC GENMASK(4, 0) + +#define IMX95_PE0_LUT_DATA1 0x100c +#define IMX95_PE0_LUT_VLD BIT(31) +#define IMX95_PE0_LUT_DAC_ID GENMASK(10, 8) +#define IMX95_PE0_LUT_STREAM_ID GENMASK(5, 0) + +#define IMX95_PE0_LUT_DATA2 0x1010 +#define IMX95_PE0_LUT_REQID GENMASK(31, 16) +#define IMX95_PE0_LUT_MASK GENMASK(15, 0) + +#define IMX95_SID_MASK GENMASK(5, 0) +#define IMX95_MAX_LUT 32 + #define to_imx_pcie(x) dev_get_drvdata((x)->dev) enum imx_pcie_variants { @@ -80,6 +96,7 @@ enum imx_pcie_variants { #define IMX_PCIE_FLAG_HAS_PHY_RESET BIT(5) #define IMX_PCIE_FLAG_HAS_SERDES BIT(6) #define IMX_PCIE_FLAG_SUPPORT_64BIT BIT(7) +#define IMX_PCIE_FLAG_MONITOR_DEV BIT(8) #define imx_check_flag(pci, val) (pci->drvdata->flags & val) @@ -134,6 +151,8 @@ struct imx_pcie { struct device *pd_pcie_phy; struct phy *phy; const struct imx_pcie_drvdata *drvdata; + + struct mutex lock; }; /* Parameters for the waiting for PCIe PHY PLL to lock on i.MX7 */ @@ -217,6 +236,66 @@ static int imx95_pcie_init_phy(struct imx_pcie *imx_pcie) return 0; } +static int imx_pcie_config_lut(struct imx_pcie *imx_pcie, u16 reqid, u8 sid) +{ + struct dw_pcie *pci = imx_pcie->pci; + struct device *dev = pci->dev; + u32 data1, data2; + int i; + + if (sid >= 64) { + dev_err(dev, "Invalid SID for index %d\n", sid); + return -EINVAL; + } + + guard(mutex)(&imx_pcie->lock); + + for (i = 0; i < IMX95_MAX_LUT; i++) { + regmap_write(imx_pcie->iomuxc_gpr, IMX95_PE0_LUT_ACSCTRL, IMX95_PEO_LUT_RWA | i); + + regmap_read(imx_pcie->iomuxc_gpr, IMX95_PE0_LUT_DATA1, &data1); + if (data1 & IMX95_PE0_LUT_VLD) + continue; + + data1 = FIELD_PREP(IMX95_PE0_LUT_DAC_ID, 0); + data1 |= FIELD_PREP(IMX95_PE0_LUT_STREAM_ID, sid); + data1 |= IMX95_PE0_LUT_VLD; + + regmap_write(imx_pcie->iomuxc_gpr, IMX95_PE0_LUT_DATA1, data1); + + data2 = 0xffff; + data2 |= FIELD_PREP(IMX95_PE0_LUT_REQID, reqid); + + regmap_write(imx_pcie->iomuxc_gpr, IMX95_PE0_LUT_DATA2, data2); + + regmap_write(imx_pcie->iomuxc_gpr, IMX95_PE0_LUT_ACSCTRL, i); + + return 0; + } + + dev_err(dev, "All lut already used\n"); + return -EINVAL; +} + +static void imx_pcie_remove_lut(struct imx_pcie *imx_pcie, u16 reqid) +{ + u32 data2 = 0; + int i; + + guard(mutex)(&imx_pcie->lock); + + for (i = 0; i < IMX95_MAX_LUT; i++) { + regmap_write(imx_pcie->iomuxc_gpr, IMX95_PE0_LUT_ACSCTRL, IMX95_PEO_LUT_RWA | i); + + regmap_read(imx_pcie->iomuxc_gpr, IMX95_PE0_LUT_DATA2, &data2); + if (FIELD_GET(IMX95_PE0_LUT_REQID, data2) == reqid) { + regmap_write(imx_pcie->iomuxc_gpr, IMX95_PE0_LUT_DATA1, 0); + regmap_write(imx_pcie->iomuxc_gpr, IMX95_PE0_LUT_DATA2, 0); + regmap_write(imx_pcie->iomuxc_gpr, IMX95_PE0_LUT_ACSCTRL, i); + } + } +} + static void imx_pcie_configure_type(struct imx_pcie *imx_pcie) { const struct imx_pcie_drvdata *drvdata = imx_pcie->drvdata; @@ -1227,6 +1306,85 @@ static int imx_pcie_resume_noirq(struct device *dev) return 0; } +static bool imx_pcie_match_device(struct pci_bus *bus); + +static int imx_pcie_add_device(struct imx_pcie *imx_pcie, struct pci_dev *pdev) +{ + u32 sid_i = 0, sid_m = 0, rid = pci_dev_id(pdev); + struct device *dev = imx_pcie->pci->dev; + int err; + + err = of_map_id(dev->of_node, rid, "iommu-map", "iommu-map-mask", NULL, &sid_i); + if (err) + return err; + + err = of_map_id(dev->of_node, rid, "msi-map", "msi-map-mask", NULL, &sid_m); + if (err) + return err; + + if (sid_i != rid && sid_m != rid) + if ((sid_i & IMX95_SID_MASK) != (sid_m & IMX95_SID_MASK)) { + dev_err(dev, "its and iommu stream id miss match, please check dts file\n"); + return -EINVAL; + } + + /* if iommu-map is not existed then use msi-map's stream id*/ + if (sid_i == rid) + sid_i = sid_m; + + sid_i &= IMX95_SID_MASK; + + if (sid_i != rid) + return imx_pcie_config_lut(imx_pcie, rid, sid_i); + + /* Use dwc built-in MSI controller */ + return 0; +} + +static void imx_pcie_del_device(struct imx_pcie *imx_pcie, struct pci_dev *pdev) +{ + imx_pcie_remove_lut(imx_pcie, pci_dev_id(pdev)); +} + + +static int imx_pcie_bus_notifier(struct notifier_block *nb, unsigned long action, void *data) +{ + struct pci_host_bridge *host; + struct imx_pcie *imx_pcie; + struct pci_dev *pdev; + int err; + + pdev = to_pci_dev(data); + host = pci_find_host_bridge(pdev->bus); + + if (!imx_pcie_match_device(host->bus)) + return NOTIFY_OK; + + imx_pcie = to_imx_pcie(to_dw_pcie_from_pp(host->sysdata)); + + if (!imx_check_flag(imx_pcie, IMX_PCIE_FLAG_MONITOR_DEV)) + return NOTIFY_OK; + + switch (action) { + case BUS_NOTIFY_ADD_DEVICE: + err = imx_pcie_add_device(imx_pcie, pdev); + if (err) + return notifier_from_errno(err); + break; + case BUS_NOTIFY_DEL_DEVICE: + imx_pcie_del_device(imx_pcie, pdev); + break; + default: + return NOTIFY_DONE; + } + + return NOTIFY_OK; +} + +static struct notifier_block imx_pcie_nb = { + .notifier_call = imx_pcie_bus_notifier, +}; + static const struct dev_pm_ops imx_pcie_pm_ops = { NOIRQ_SYSTEM_SLEEP_PM_OPS(imx_pcie_suspend_noirq, imx_pcie_resume_noirq) @@ -1259,6 +1417,8 @@ static int imx_pcie_probe(struct platform_device *pdev) imx_pcie->pci = pci; imx_pcie->drvdata = of_device_get_match_data(dev); + mutex_init(&imx_pcie->lock); + /* Find the PHY if one is defined, only imx7d uses it */ np = of_parse_phandle(node, "fsl,imx7d-pcie-phy", 0); if (np) { @@ -1557,7 +1717,8 @@ static const struct imx_pcie_drvdata drvdata[] = { }, [IMX95] = { .variant = IMX95, - .flags = IMX_PCIE_FLAG_HAS_SERDES, + .flags = IMX_PCIE_FLAG_HAS_SERDES | + IMX_PCIE_FLAG_MONITOR_DEV, .clk_names = imx8mq_clks, .clks_cnt = ARRAY_SIZE(imx8mq_clks), .ltssm_off = IMX95_PE0_GEN_CTRL_3, @@ -1693,6 +1854,8 @@ DECLARE_PCI_FIXUP_CLASS_HEADER(PCI_VENDOR_ID_SYNOPSYS, 0xabcd, static int __init imx_pcie_init(void) { + int ret; + #ifdef CONFIG_ARM struct device_node *np; @@ -1711,7 +1874,17 @@ static int __init imx_pcie_init(void) hook_fault_code(8, imx6q_pcie_abort_handler, SIGBUS, 0, "external abort on non-linefetch"); #endif + ret = bus_register_notifier(&pci_bus_type, &imx_pcie_nb); + if (ret) + return ret; return platform_driver_register(&imx_pcie_driver); } + +static void __exit imx_pcie_exit(void) +{ + bus_unregister_notifier(&pci_bus_type, &imx_pcie_nb); +} + device_initcall(imx_pcie_init); +__exitcall(imx_pcie_exit); From patchwork Tue May 7 18:45:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13657563 X-Patchwork-Delegate: kw@linux.com Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2055.outbound.protection.outlook.com [40.107.8.55]) (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 39D2616F85B; Tue, 7 May 2024 18:47:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.8.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715107635; cv=fail; b=SZUb10CNcFWHrvm1jhZUWCSUU/Wnf/7egexhE2KQ1BqnyeGbDJBHMEOyP7VDrnmsYUx32dUgsemtrEh0qcUK2feUNUQJoa0o0Dt0kWPOvkzoZdOvqXBr1Ib/dMA/8HeLk+C1EvnKFMwWcLDdDQEhV5EE9clpBEbhQKrCsez3AY0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715107635; c=relaxed/simple; bh=uRbYV+8P6VjCoxmSQ3mxj6dE+Tuv3Whv1pWoX9EvqFU=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=bmzSGevl6XEMygoInxhFnTAvVsIsnkqGoT+Wzf/Up9pJt9T9xlXGxwhCdm3In0gbKNygdXceKFqaXoepVrZsUprrLi6Kp5DFK/ZPbwZ8ro1UPYTkxCYjZqFFw08K0l5i0FbN5dATZAj77RXuaQEtxHVKZUnKp5mEqvpfN9m1S+w= 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 (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=GGSHFOI+; arc=fail smtp.client-ip=40.107.8.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="GGSHFOI+" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mXpKnvREYuj7Y72Xc3NUtLx9JXn19fwMT1UQ2LcIHxnnzDZZoGGNLNyKYZBdgnofKeKWS0tqp621LfeMVy2ZBAE+Xke3ieDvv3P+WQmvuw78fyWiri5vZ4XcOMLS2cP5UTa5MUgz90wtAvdEaRygqIafHmbds53lYyJ491yHyf0YSdJ4+mtCC9Aajp0vPQBpexO1+ZoVQcK97VQkAR1eWle8BpvEJS6GG+gH0HXA/XD16oZam416EQgscVEA5+4bzJJB0KSM37zMPHaOOdjV4BtuSaYSr36KYhBgQPlzV7tOIxkAOyhYND2aTb4yA0x7ukoG1ULcwLkwvxytllIngA== 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=IJ8+34n6tB2srgggrSYc9JS7VpTWsMEFMzObdI2BDY4=; b=j2kGg+bhM42UI4jsKC4w+X9TS+jPOuND2TIWXAZVIEhK34X/vCuIuxLUMAmJRgw+hgTruC5mpBXjXoZHxZa1zwuPY1T52WMXCgIVR+m29UUOeNfohwoWEMIfGsmKRpjmQCyV/bbHwaQFDl6CZfvMAWwrX15md4h4CTXBpuf8ayIkomMuVpOlakhXWtTT8taYzQ44nsGx8lLijfuehLFCKUpvGsup08B/6tQ1KY70uHr4ymP2Ik4t2zn3fKOXvZnTUkFiE+6HXARSROG5RpuPnpAfRNMPAPmS8K/0gYuemh4hkdOaMA/NSsEAfIWdcK6MwLwd8//Bi8DYWjgyIvM6+g== 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=IJ8+34n6tB2srgggrSYc9JS7VpTWsMEFMzObdI2BDY4=; b=GGSHFOI+41Fg8phLddLCnSE12xkidgN1GUVFW4VWlrjLuTN6QU1Lig/A6TEZoQohNKLs8Eeiaqjy/Vz3QgXxTfzQm5AvMHhecCp/j5FJazoY/VU9lw8dd7wYOUGiAU7PxfHb9gGq7tOesTY6JJPJpyj/4SpaYRG3e5JEhQs50Mo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by DU0PR04MB9636.eurprd04.prod.outlook.com (2603:10a6:10:320::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41; Tue, 7 May 2024 18:47:11 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::1e67:dfc9:d0c1:fe58]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::1e67:dfc9:d0c1:fe58%7]) with mapi id 15.20.7544.041; Tue, 7 May 2024 18:47:11 +0000 From: Frank Li Date: Tue, 07 May 2024 14:45:47 -0400 Subject: [PATCH v4 09/12] PCI: imx6: Consolidate redundant if-checks Message-Id: <20240507-pci2_upstream-v4-9-e8c80d874057@nxp.com> References: <20240507-pci2_upstream-v4-0-e8c80d874057@nxp.com> In-Reply-To: <20240507-pci2_upstream-v4-0-e8c80d874057@nxp.com> To: Richard Zhu , Lucas Stach , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Bjorn Helgaas , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Philipp Zabel , Liam Girdwood , Mark Brown , Manivannan Sadhasivam , Krzysztof Kozlowski , Conor Dooley Cc: linux-pci@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, devicetree@vger.kernel.org, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1715107574; l=1050; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=uRbYV+8P6VjCoxmSQ3mxj6dE+Tuv3Whv1pWoX9EvqFU=; b=3MmPWG8waR7Qnxd0N8fgyHKND+oBRxlIJRVKYtKS5OrYj7pKzRCJ52p106JvTjOIql/eVVDx6 AvFjIssgrH3B9nSVsgDfpFHU5zj2Jdn0SILSp7uOAnm3aRSS6xeIY+n X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BY5PR17CA0026.namprd17.prod.outlook.com (2603:10b6:a03:1b8::39) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DU0PR04MB9636:EE_ X-MS-Office365-Filtering-Correlation-Id: e11fba36-25a4-4ffd-2581-08dc6ec61a8e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|376005|7416005|52116005|366007|921011|38350700005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?DQ+Q/l0JiehnF2ABw5atm2GFbdKu2VS?= =?utf-8?q?WEMoeSA/bkFkcHlA2CMzd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4Ux53FhiHQF9A5FIGmJc0ftFlbTqrpP6hk3Mxg5OG7axC?= =?utf-8?q?5ixv8MhudGC6b24BKph7QOlP8STOvkkBwXIg4To/rEXvbnO4uVS08+7tgUIk8lU36?= =?utf-8?q?B6p+XECLADtJxnYID2KUQfKPU4WOo4gbBiT6eRWw+bp2h4TViwIt3dXZvuj5CZ6Vm?= =?utf-8?q?F44bXoWA60Ap4c+lBxNN1CQDQV5JGWKUX/vPNy5ZqV+dwBmOUrdlCH7pNikDX2WEM?= =?utf-8?q?42jx0yZSXRNzScIlE52J/Uxo5s6OSjp3v8wXuSpEFnMMPUF4Bop6qIQluNT7PbyjK?= =?utf-8?q?a5k7Shr4QjWDPkSsGjSVxShBLogSYtGGO3cCAsrdKgdq+Y5R/3lnJsw2fknEmXDwB?= =?utf-8?q?oRhfyIgLnOTP3vJtXrR5FvcWvBSzxke/E+AXgSq/ILjzz0SXabmCh7DA=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(376005)(7416005)(52116005)(366007)(921011)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?qmRw+0gJENd6Iu6CwNhye4dyY3eD?= =?utf-8?q?4Qm7G9c/7rqyTjM+TuGk8b+I9VpwcaAQsv6+TuF8gzqCBtoMhSDmgiIpdlDGx7Rih?= =?utf-8?q?ckb4tDPoM0HTm8hxJRxqSOGR6PMBiblSrP7nPSpiF5B2cIMUXAm8hIzPYwFyx00wn?= =?utf-8?q?baK+D//8QlUDfcpPikJD/Evt6tGc+QPthnv7S93TCrJE+AFpne5Y3hRqgCLlBKzeQ?= =?utf-8?q?5Xw76ZYsFTG/1oU7axL60enfFajoIqY2IyGEscq/DCzvpkHeWBpE/zd5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=?utf-8?q?51H6E5Jc3NZkRrJMkFEdws0swy2JRTEdIBYvT+mKM1D79rknzQBN11cyoRC9zCVNw?= =?utf-8?q?2ZQq474Togwf85P4dVtY8fjWzRqXNCk5W3mvbrH/LB1oPGprTPDcWfubEgBHWw4zb?= =?utf-8?q?WC+T8JorOCl0ed9wHDHWVNdtw/2YxkmTlB+uH6OsgE+fj/HmlKYRqKTcB1G45DLXK?= =?utf-8?q?Kx/+n4N3cqJyMx5YsgyjTFWNkxWXSEHLrWpuMahHiCaVWGPftAKT2NA9oJ7NhUDIn?= =?utf-8?q?KA2Wr6cq7/guUd049ijnZOI/Yhs7NUS74fcnWq84ZuhNDT597jnKODfw4kNvkV/zv?= =?utf-8?q?VFJRv2wASbsbiuBPzo50ILvJq/Yxx7Kef7kOzbZb0xM6zx4ZT8C+ryMwUkVti8cvs?= =?utf-8?q?vxons0e6k8U8?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e11fba36-25a4-4ffd-2581-08dc6ec61a8e X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2024 18:47:11.1642 (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: ouo/zVVN/tohMTENLt1VHAQkdQu0AsDS+fddF3hkweZvusMCxqI4Pqj9kS6zMGMAeluNFQU9+EvayFDzlFEbIA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9636 Consolidated redundant if-checks pertaining to imx_pcie->phy. Instead of two separate checks, merged them into one to improve code readability. if (imx_pcie->phy) { ... code 1 } if (imx_pcie->phy) { ... code 2 } Merge into one if block. if (imx_pcie->phy) { ... code 1 ... code 2 } Reviewed-by: Manivannan Sadhasivam Signed-off-by: Frank Li --- drivers/pci/controller/dwc/pci-imx6.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index 66573ef7a002b..9d53b545540c6 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -1033,9 +1033,7 @@ static int imx_pcie_host_init(struct dw_pcie_rp *pp) dev_err(dev, "pcie PHY power up failed\n"); goto err_clk_disable; } - } - if (imx_pcie->phy) { ret = phy_power_on(imx_pcie->phy); if (ret) { dev_err(dev, "waiting for PHY ready timeout!\n"); From patchwork Tue May 7 18:45:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13657564 X-Patchwork-Delegate: kw@linux.com Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2045.outbound.protection.outlook.com [40.107.8.45]) (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 94A2016F911; Tue, 7 May 2024 18:47:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.8.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715107641; cv=fail; b=D/rD1V/jZpOCJqTWifu1G9sSzYdUmSBLXxAU52PLVfW+38gJXp3YdT/SPtSVzYlvtCkxODfGbFrd0OGnD+O5btTZ0H4NB3NYZA0PjCk6yd03JsgSDcMy/4GslIVzOotHUolbulcJf4YmueDegW5x7+NY0qS8IWIDK35LZR3WnxA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715107641; c=relaxed/simple; bh=ZVcPE4dOaT6EXgzn2/jF23hc8fTkYFYmiyfbQxh1zCA=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=pSLKIESrBEV9Y/lZqI9V/7hwQqUuH0OGX5IAj5hkG8Z5h1gewfjKTB9Nq+rHZdpSly1ebaIkseq/ISHD54vLfjbwjAqNUOofIm8URxquHDF8cCgdfnlGDMGmOrq2lm1zLLOj2FWtewScbiCBh1vL4pYUUataqFDSzyOkb+rcYNY= 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 (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=b7Hl1ujY; arc=fail smtp.client-ip=40.107.8.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="b7Hl1ujY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nFasrKR8D6WtKDiUrrj9XwOdVh0t/oUD1WGUVUhDnuDPW2Ku4ISPE3602NeRYdHXffcLDTRAt8LAxffehCIck0sI4IJEI9fsfR23Kz0q+sqf+IZmUGrKLTDBAC/7uQ6p+W5VM+unOmVF3RD84O8SNhAiKJyVVaHzfkjmI4JT4awghpsOJ0acmp+XtDoGKz/iER5fA9254mK3L6PO1jKLKTbn0uyOT5r44f4/xnIcyyFo89A6XsOZRIU80ewRBARBZbbtESdoNmPVfh6egfDnynaGo3+k3kQ84jQ6wLOSxVzd/sMLIKi+qXPMEp1iTUU9uGBnjbdacjDr3ao5abRk3A== 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=a7lkqnRaz7I/AFHpfK0i9KlaovJZS3cHmfRuCx3nJQY=; b=eIWMUNVoiFyYGlpEJ2OH1TG5KCKGi6L/C85O+DRsTBNAYIcEwkgn53xWu4EMa2vNat1/hQCrueE8sYNjRMO4MkC6IXbq+toXC5jB9J/sAcsFglgfuevcsAE4Hoshunz42yrLYLLGmd153gw/cXMUBX2KqUIqhhF0VCPdQq931mi/ZnSwUlpIhWz/VFjSIqSvUsot8abJ2wx4oHfsjyMe4EwKx6glEYxBWLayuOW2T8rRO+9nlT6L04TKnHYB96IBgWk1q+Ns37GVLejhdx2sghO6pNOLpPikGPk+ABjYkvt+OqIzUPdm5Zb/zISaWt7VGQsooP/UZGqenC8nFNDQrg== 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=a7lkqnRaz7I/AFHpfK0i9KlaovJZS3cHmfRuCx3nJQY=; b=b7Hl1ujYtM7kHYXgbC85HYhYHnZ8PqiJys0/xCMDhPhbV5hcHxu42eHeUjwLvhFRdel/IDHxbEIaoTKOIb2KDl7zHfs5kpzFKhR1Bz36FPoexl7JHuDNgxZuOvXUE/l61Jsgn72psqablaRPwhuYY18Or4EmwoAI9xHB/9oEPjI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by DU0PR04MB9636.eurprd04.prod.outlook.com (2603:10a6:10:320::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41; Tue, 7 May 2024 18:47:16 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::1e67:dfc9:d0c1:fe58]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::1e67:dfc9:d0c1:fe58%7]) with mapi id 15.20.7544.041; Tue, 7 May 2024 18:47:16 +0000 From: Frank Li Date: Tue, 07 May 2024 14:45:48 -0400 Subject: [PATCH v4 10/12] dt-bindings: imx6q-pcie: Add i.MX8Q pcie compatible string Message-Id: <20240507-pci2_upstream-v4-10-e8c80d874057@nxp.com> References: <20240507-pci2_upstream-v4-0-e8c80d874057@nxp.com> In-Reply-To: <20240507-pci2_upstream-v4-0-e8c80d874057@nxp.com> To: Richard Zhu , Lucas Stach , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Bjorn Helgaas , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Philipp Zabel , Liam Girdwood , Mark Brown , Manivannan Sadhasivam , Krzysztof Kozlowski , Conor Dooley Cc: linux-pci@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, devicetree@vger.kernel.org, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1715107574; l=1253; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=45O/Z6HdjXbmyLNxdhyNfezc2z72stjqhDhWD7DVlek=; b=9pk9TRw5qEYgwsxJrNxHDYiTh43vqgWOHK938A44rBBYbM7vWaJHd/zzudI49yRJ8//CaX5LF pmOpASngQzKDivvBF/E1ajxzTZmDkCZONYujc1tO7MVcF3Te487Wn50 X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BY5PR17CA0026.namprd17.prod.outlook.com (2603:10b6:a03:1b8::39) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DU0PR04MB9636:EE_ X-MS-Office365-Filtering-Correlation-Id: 7a8e12ff-fde4-4613-d1b7-08dc6ec61dfd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|376005|7416005|52116005|366007|921011|38350700005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?PTkCjDms9Now//6bpk5coidgwpWnVNn?= =?utf-8?q?n0QnnO89IgTDvi3ZABWGGEdTd9sUVBEQdWLRedyru6eQjVkdJWPQn2QoS5898AjwS?= =?utf-8?q?VfgWg/2bcTMgabDvGZM2W3j9aoB044A1j9lqp6Sm/DrOSUQX1324rwsHQsvZ9biR7?= =?utf-8?q?l1N/gvR07mgB5Ia9Xl3/FrkRA9aEesHfbUtogKzympN/Vl1hHIEhqMhGPHnK5NAWc?= =?utf-8?q?IOV4Nw22ihVFZb1koZ+smkHiVBZidhf93cF5oD2bJeoINhbrSwHbOdEvbhP7tF5g8?= =?utf-8?q?uUMh9y7NQSvMv+TAojTufik2AGEsTDYbpIMt7ZdD0Qm9MWNIwBM35zHLHiR/7qowo?= =?utf-8?q?qZt6V/2XUj0Mb0rNnzOCB3GWO2Cm/Atbt+MNcJpio3gHFbuIYKTARwu/fPJLeACpk?= =?utf-8?q?L7Lcz9YfPRfA1wtmVVoUuUlkrDpUBRafb8zELzQeGqLSa4fGqBjI5+9iKOiBz5Em6?= =?utf-8?q?YtHuUaJHc9gR2YG2JFfIeEgIYNNHqFFXug8bAGXTNI7DmvA70o9lAY5ihu+vp9+fU?= =?utf-8?q?a1DmqMREkwJoJoiLTMlko7g5SWzCGJiDiMcmdinXf6u/uwIo4AHenkUD1X3SD45Hz?= =?utf-8?q?1f/3jTpVUQRTEDJb+m+GefJQQ9r3WuC5Jp+vT/cIKcw9YI6aYIIjXHuq6OVYTv5DZ?= =?utf-8?q?Xws1uOAnQfm8JGSVaV/4aZQUneSS+enXSYRZ+sBC/x1nLVPc3vZ8noiIlP8PBRk/P?= =?utf-8?q?MD0oUdKbNyDpIotZmTd4K2OavgcudPXREQJMGs/gTxc6l7Am0r8C26N8bUBdjMrE/?= =?utf-8?q?r9uydY9S9W7w+cTYziQ3bptG+l6ULM3YDlF9Gf+SOJsdbmLsZVX1IKcmIx1VvFiY4?= =?utf-8?q?OsE+HxK0DIGbJnqYxEXuxW7H9BDI2msrk/8a4P24PqE6OKGvLhdTuS+02Xq3oYmZ2?= =?utf-8?q?GlCcsMyiccd7+tBYtKEAk5HTGGyVwFtJo4peElo0AC/EU2ZDD8o4F3DgDpFa3ULpQ?= =?utf-8?q?AmIaqfVdaUFPVvMuU15+A6BFTjwhRyy8BzHRLvLVaR+JnNf/K7REQqfmThz6+0cil?= =?utf-8?q?XKvapo7P4AE4sLpz8K1G2vHXG5PfKrLxgHdJfADhdhx3dAnqmmv6I+4s2KtCNbrqE?= =?utf-8?q?VDaaQJzwC3/fnZ5hy0bd5/sqeHivcBwQkttdB3cKIIDAcy1beu/OQIHzmGopMZkVT?= =?utf-8?q?/sgcew9i14rndicF6QOiTcZKnD/dY2WqrUem4AVGzhP/329/FbVB8k+FoG4ev1/2x?= =?utf-8?q?bHq748Ie3jHckHbVq3nF+qvDnTDc0cKNFwEEH7471Bln8w4Xr9o86MM0FNrk3/t3X?= =?utf-8?q?UPlXbGYQ8+L1e8A/bVAA0sOthQzknIDPAh2VKvd7MV/V3O39WCNySsBQ=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(376005)(7416005)(52116005)(366007)(921011)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WjnxEO+GY7ibIJAUshQeAVUM2QfqZqPiLaHOqjtwj4IytdBLHCtSpX?= =?utf-8?q?RNWsnKul5QEY+cLsxjL7AP6y2kZOTiElwox4TSPBVIyOUvO8WLg9W9CCEo1fhyFDN?= =?utf-8?q?3s3Ux33Q2ZcDBflJ50B6vROBT/azpbkEQvUD70GGT6JCCldgRK8jWmP4xO5alJ0rN?= =?utf-8?q?nbBEacAbp+Ma7Oaf+DKP6UZDfXhSzD0TvtLIe8SOSBjY8fOwipki5DrGKBXzmWtRl?= =?utf-8?q?EcpCtLAfI+ouRjtwpz2G8EVgo9oF36hCxH8DrTJDY+aTtMMVZQDdgimbcKA3zAfVu?= =?utf-8?q?51HGdPtt2lGh0cRAYv/S896j00SjPIEuxNntVTrwPGuRuj7AiV858ziDKe6Ngumfj?= =?utf-8?q?j49qe/3lw6d8OllNMIL+A3b6x8ReJkChyTJPB9rA/9F4sEFqRmauwiqacpX5Pb2t0?= =?utf-8?q?arfaj5oPck3pmpAUXQ1qitSfAYrB05S3Cde0+3BVy0jQtg7ivzyZnX+APcUoKnjHa?= =?utf-8?q?AXF+sCd4jAEJ8D6JTJ14mBqEpCWkEDYA69AAJNej9jjw7/RlocJAd9oIPGHHDRl52?= =?utf-8?q?YR+Q8MMppND4mmKWhDdiWEB1KltcIfe3iEJlB+wQ+KuuDnkjAmyJoo5pzpcl3cTeY?= =?utf-8?q?+FcJooN+ylFK64xB7u/esHq6kSU2MekvJZ05aFKT6mqdc2xgy+ElLchQm2ymhgh0q?= =?utf-8?q?CVpilwJL0OsEHcUVPbvoGtTUAYA5+CDMF7oLQYDba8i8yX9VaQcY7XOLP2Aagp1ng?= =?utf-8?q?qwsFEH9KLEcO?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7a8e12ff-fde4-4613-d1b7-08dc6ec61dfd X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2024 18:47:16.6517 (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: x504eAceJBE+apObBX5mrBRvPW8E2lE/i/UcNOHq2UZ/rbws6L4s+J2ouTW7AxOGumfaDU5XoThEeQctJzYIKA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9636 From: Richard Zhu Add i.MX8Q PCIe "fsl,imx8q-pcie" compatible strings. clock-names align dwc common naming convension. Signed-off-by: Richard Zhu Signed-off-by: Frank Li Acked-by: Conor Dooley Reviewed-by: Rob Herring (Arm) --- .../devicetree/bindings/pci/fsl,imx6q-pcie.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.yaml b/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.yaml index 8b8d77b1154b5..1e05c560d7975 100644 --- a/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.yaml +++ b/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.yaml @@ -30,6 +30,7 @@ properties: - fsl,imx8mm-pcie - fsl,imx8mp-pcie - fsl,imx95-pcie + - fsl,imx8q-pcie clocks: minItems: 3 @@ -184,6 +185,21 @@ allOf: - const: pcie_bus - const: pcie_aux + - if: + properties: + compatible: + enum: + - fsl,imx8q-pcie + then: + properties: + clocks: + maxItems: 3 + clock-names: + items: + - const: dbi + - const: mstr + - const: slv + unevaluatedProperties: false examples: From patchwork Tue May 7 18:45:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13657565 X-Patchwork-Delegate: kw@linux.com Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2047.outbound.protection.outlook.com [40.107.8.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 920B616D9AC; Tue, 7 May 2024 18:47:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.8.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715107647; cv=fail; b=W8KQJ4Q5+h40ZvpZfZaF68T9PHFNg3mPSoAPQPZsEaylvKsnWJq2p+c1TwcSW8EUX9NHms4+lhPu12kT3b6kpa4x/8LMVKpj7jz2C2gjo4Wi7Yt9QIn9FDhReZ/DUxHpgl/RlqWP0bkY6F7dYqus+P/OlaWW7tS894kkYcnZ7n0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715107647; c=relaxed/simple; bh=rRm5SujhEiX9hVYVjrxBprduIqi9bHP431kr+qPwfZU=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=FelqPxWTz34Cb6my9812JjQU+SohXLexrNO1/OZaxOlC19gJITP/RefXojUfq+bObGJHy6bLyYd+c/2MztzYB9KPuBphduEbK8Onz2Px1iG3CbAM7iHmswzr9gYux0jXWY6qA69iqDzFSEee6MOx5Arb58LYB8tNrDb69NwfyGk= 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 (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=pj48bWJx; arc=fail smtp.client-ip=40.107.8.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="pj48bWJx" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BVC0slsCU7m6rwCaqyU0zemLyqnpdMNp4/iBP1A0gATqMJ1S/lok8CgSg/V/C78FNhHI8JZmSa8tJ4S3fX6L1mer3lx24/ZrpnWzNr2NTvqRfusiAQQCLt+puocB4OJ/1Xd4eiDXAj2kKYivPI56CtMD5QSwoOJsIMWZ3Bmxt12AbLWIt/Bi5ptzvJXTum0Rxg6xVFXO30zUmj8N+w38Im9WegGGgKT25AO8akFGhnPXMmyx8NHxsflfOZA8FP5zzK7ZGX5vVTILiJ2zm0ybv66Um5TiXCgko87QcMyRJCXoRfDt1rSM682gF1YnJGz5fbSyh2dpleYS+6Fm/WUO1g== 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=3gTTDoBfA/yf91PPA7MqT/q+r+bNwi1FVYdnjZCH/pM=; b=AY2iTw9Rt+1nZPoVfXCpaRXzhL+ij8CHgco5qb7EqRaCAG3mT86wFxS1C2y+yqEwvJaOUvmx17q/8JVp0pmWVxsygSqGsC7TBHMUW77nhXg3lq5ePgFpltsQ2nZKd6dqvBuE27cMGT6c9GdmcH5VDBsLrJWt3nJmiFZN9NoaTR9sgxhD3EDq/dCsiJ+hdWWY1NSg9MOv6O93foeVRqnXtqxJfzxXZywcmTFImsip/D9TU6YXY6BJz+fFFnpFng+BeCOb2htK6Kn1TzH3Y1sWvKdVduDhpaWsIRavXLfFg9NCMLfhBOiRZJIRn0kkeWjkpCJjdSeQbXTR4hegnYDlww== 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=3gTTDoBfA/yf91PPA7MqT/q+r+bNwi1FVYdnjZCH/pM=; b=pj48bWJx3lGiBnoAHuTDveo/2hVXXWvQXRKRg8ZhyodlObgQiMLuQ9dTCJ0NQXPRhPXICQbejmbCAg8o7Q3EWryvI40z7FpRgu0QKlYLJioMsNY/ZSeGeMkGuHu1lcBThziwXGc4iAe+p7WtSRV+958TekhI9LpCN2H9bURyPgM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by DU0PR04MB9636.eurprd04.prod.outlook.com (2603:10a6:10:320::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41; Tue, 7 May 2024 18:47:22 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::1e67:dfc9:d0c1:fe58]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::1e67:dfc9:d0c1:fe58%7]) with mapi id 15.20.7544.041; Tue, 7 May 2024 18:47:22 +0000 From: Frank Li Date: Tue, 07 May 2024 14:45:49 -0400 Subject: [PATCH v4 11/12] PCI: imx6: Call: Common PHY API to set mode, speed, and submode Message-Id: <20240507-pci2_upstream-v4-11-e8c80d874057@nxp.com> References: <20240507-pci2_upstream-v4-0-e8c80d874057@nxp.com> In-Reply-To: <20240507-pci2_upstream-v4-0-e8c80d874057@nxp.com> To: Richard Zhu , Lucas Stach , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Bjorn Helgaas , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Philipp Zabel , Liam Girdwood , Mark Brown , Manivannan Sadhasivam , Krzysztof Kozlowski , Conor Dooley Cc: linux-pci@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, devicetree@vger.kernel.org, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1715107574; l=2344; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=rRm5SujhEiX9hVYVjrxBprduIqi9bHP431kr+qPwfZU=; b=WnHtWsp2PCQ89Q1ObmF3XJCsbhZXA9pISVqfFPDcdZvNNlXxL+QnVzS9Awh0VaZGnDJc4pQFV LpJsjSeWcV8AYCsOyL7PfeeZ2dJyupXyMN5LEntzJxC+NB0RcLE+lhY X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BY5PR17CA0026.namprd17.prod.outlook.com (2603:10b6:a03:1b8::39) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DU0PR04MB9636:EE_ X-MS-Office365-Filtering-Correlation-Id: 577e8acb-a1d5-4427-4e5e-08dc6ec62161 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|376005|7416005|52116005|366007|921011|38350700005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?gpFbGQ0Q8Bu2KdG4H8gQ6LcpKbRQ5SB?= =?utf-8?q?EsvwUSBHKQoFBE351kBYK/sZF2YDu0ry9sjfuRksRsZ0853w8GBT5G2w2plsseQRl?= =?utf-8?q?pMdczNRQKxkTQO68rvtFW60qZ/sCdGr+wPnyL9K0lSdSTH+gZ1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=?utf-8?q?R0is+6xm/sbSkgRAPatOtgIz192UuLJVGIcWEKakRNG6HugAEGmPLYdFvT/TxtJ4S?= =?utf-8?q?HO/Qpa1aVQa/nmyBL25FsW4sX3P8//77eAGOuG33Q5DSaFqwWSyEAtiy3BK/MFzSW?= =?utf-8?q?1HCHR3KGYrSymgMJwPEknDZhiLjJLkmTeOoxQAblaOnJ0J88EcUJfNkinW1mApHav?= =?utf-8?q?+YBcAMb9WXSPiRBSpBEDvizlVVgfHZb39ApzPJ+aV90ywDqAaLnoYZEkVz8Y1KNG4?= =?utf-8?q?08cLo92bDZJYDjGigmK+vCZ4EclE0+r+0aNCD7nMV6kpUmSh4B9pDLSk=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(376005)(7416005)(52116005)(366007)(921011)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?R+vQTVb7HgUpIXIhMmRRmtR7mStM?= =?utf-8?q?a/2rWRiAyvN5sXiLTWS2CThtPO1g3Yjqd+IMeB1iTK4x8AFTWL7Bbf6+cA0g+mcap?= =?utf-8?q?3GC/3c4VxmEbuCgiKTvFWbPTShnfxqzxgit5cdXhxGtAB0PartM8EZecxIBl6G8MC?= =?utf-8?q?uY3RRw6/oEK67N8cMim+h1Jg+yg/UgbV4B1y3UUgKf/5f10bW+XFlZpoBRylrKY5f?= =?utf-8?q?ORii49fpcg51CtSPF3G7HEuNul09L7x//cajE6DOPQjZJlYPA6eQkH9IEfVXlTK2k?= =?utf-8?q?9heIVU2PNnB83rFoy42E6j99e8VhN0vNwDVIBdfplE9vkKRCkSujjtZ8xbnN8NPrZ?= =?utf-8?q?eZtN4aj7QM3s1Q/mPAoeNRqZEj3Kcz6K3H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O81eu9AVmH9VLmTsP2oWUcY0SM/xORWi4U?= =?utf-8?q?oW3iz8O0xE3TzuPBRwiE+YRNQYUlf0wsQ4pIF38wI5uN1iNNRhxJxiuKF1eitzvAR?= =?utf-8?q?Iqpt8lVGNBXocGTbTL3BdQuHBTLvnUgIHqVsEBcS+REiWvS3TrmP4Z3DYKCiYBWHD?= =?utf-8?q?raT++WrODjNBLfr3mUGJVzdr0B8e5U15h1xLcO+jiU6aQc0XMwEAlvO3tfxWyKGhj?= =?utf-8?q?PRXQR08SF/f1Et+ou7BHceddu3F0tABAcJBNoYO9vaMWNV9HVYsut6AQfuVyj9HMW?= =?utf-8?q?xwjwCZzJ9Xj5?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 577e8acb-a1d5-4427-4e5e-08dc6ec62161 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2024 18:47:22.3242 (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: nvrNUWcSTYaHBRMGb/2tH2Oe3m8IcLfb1K1D352gy2T62g3yZIPHSLBCLJfG77LzK/rhBQvymM9HjEJa/MGoyA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9636 Invoke the common PHY API to configure mode, speed, and submode. While these functions are optional in the PHY interface, they are necessary for certain PHY drivers. Lack of support for these functions in a PHY driver does not cause harm. Signed-off-by: Frank Li --- drivers/pci/controller/dwc/pci-imx6.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index 9d53b545540c6..df623977d8fe6 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -308,6 +309,10 @@ static void imx_pcie_configure_type(struct imx_pcie *imx_pcie) id = imx_pcie->controller_id; + /* If mode_mask[0] is 0, means use phy driver to set mode */ + if (!drvdata->mode_mask[0]) + return; + /* If mode_mask[id] is zero, means each controller have its individual gpr */ if (!drvdata->mode_mask[id]) id = 0; @@ -887,6 +892,7 @@ static void imx_pcie_ltssm_enable(struct device *dev) struct imx_pcie *imx_pcie = dev_get_drvdata(dev); const struct imx_pcie_drvdata *drvdata = imx_pcie->drvdata; + phy_set_speed(imx_pcie->phy, PCI_EXP_LNKCAP_SLS_2_5GB); if (drvdata->ltssm_mask) regmap_update_bits(imx_pcie->iomuxc_gpr, drvdata->ltssm_off, drvdata->ltssm_mask, drvdata->ltssm_mask); @@ -899,6 +905,7 @@ static void imx_pcie_ltssm_disable(struct device *dev) struct imx_pcie *imx_pcie = dev_get_drvdata(dev); const struct imx_pcie_drvdata *drvdata = imx_pcie->drvdata; + phy_set_speed(imx_pcie->phy, 0); if (drvdata->ltssm_mask) regmap_update_bits(imx_pcie->iomuxc_gpr, drvdata->ltssm_off, drvdata->ltssm_mask, 0); @@ -1034,6 +1041,12 @@ static int imx_pcie_host_init(struct dw_pcie_rp *pp) goto err_clk_disable; } + ret = phy_set_mode_ext(imx_pcie->phy, PHY_MODE_PCIE, PHY_MODE_PCIE_RC); + if (ret) { + dev_err(dev, "unable to set pcie PHY mode\n"); + goto err_phy_off; + } + ret = phy_power_on(imx_pcie->phy); if (ret) { dev_err(dev, "waiting for PHY ready timeout!\n"); From patchwork Tue May 7 18:45:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13657566 X-Patchwork-Delegate: kw@linux.com Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2057.outbound.protection.outlook.com [40.107.8.57]) (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 0509F16E88F; Tue, 7 May 2024 18:47:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.8.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715107652; cv=fail; b=ZaVNPhbWYDhucF501PzKmrzuerdwnsPTsbpMIaPBxop8xlZ9bhGhPlOwp3lyX8Gn3pSmOaOUFCgqO4ho45aSe8nV0ANz6M1d2JPFErqgjVkJ2dxl9zdOh/14i5QemvGPsO9vouzjIeqOjdbMrY56+Qj1NAi6UpuperR2evRMLJw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715107652; c=relaxed/simple; bh=sRfIC9eIMs35HNpGNTm9ilEMNUkn4dvgFYwTvQZ8kuQ=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=eMVbtbF89koq3LAIYT+kZQjBqHCne0KkMNcVjTU8FAUiWcqFfY8l1t6qjGufFjREg6kfm7BmHtHTrGed66oUZQS3ve5oj5EF5Wgy6yBd5MkIRVsEqraXQ5SCCUSxk0OfolXs66yiM1CFAvNnKCSmuMjbKQ712LUVVzb2uffOXd8= 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 (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=C7nPY7v0; arc=fail smtp.client-ip=40.107.8.57 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="C7nPY7v0" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LBqjZz9rPcNr9PLlySFIIXg+1hclH7pQPyg2jLKWDFnV76ImoZF6PXmyDFhZMiB9vK6M1CESvXUR6nGLUZqjB/L3qU5ypMfaRhrh9dYMBcugsKcRmokadZ8ZlF81LkuVVRnm44Y+S5RlZHQ/3VzvfT+E6IybicPn2wXA6SDn/SGY6MltVKUKidFWBnNPgK5lVTd6UwmZUtjJED6YhVI92X/CVoCJxm1aZA3a50GQ/kIzd46fZeDDiwCTfJpvJgUUZNC1xxNy1PxE0LcElFAzhPoeverzYSJr0ZUhEmf2q8stRRS1aXwbZcVjf0A/kjsx+eGYyNnZET/ptfaOPlpDVw== 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=K9ARmSVB6q3UGh+IrKQPkWi3XFtpb4PQIRo1doqw2yw=; b=Ro8KnDy6eABec4Qikt1Yc9hdTpu97pJxeQSUrooNWqPHsEIIn2e7YW386qpY13KKScyqbp77MvyvApA0TskJbovBqJj8fawnz7BJBspEDz7OH/v5W3tVsU9iINYC/sv0M34p/T9iUegXFNJILtOvXpCUiq3xuC128LbY57t6iEdeP5BPHsz6LECessjWcaL5Fl30uuMRKW40jPoG9dstGgEExSrDjIzxuMUqy3Gb1+1mfmvXEAin77KBsaMoTlTKq6ebICQYhCocKioel9n3kdscYtlQNxY0Jm4A5eWX74a6DCMoQBAZjYp5TjUAs+6+wB22c0PPHuQjEECJClXjtA== 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=K9ARmSVB6q3UGh+IrKQPkWi3XFtpb4PQIRo1doqw2yw=; b=C7nPY7v0NR78kPdZGGKKkSa/kK9Aqm+no5igLUimCvGJhknlmv3s2iqEqSg6kxhJoARojKekNvOr872E7WW3l8Sliy1YJm7Pca24TmykaKIsWACIWMZImJFLruKiZ9d/X1P1UtHI5pf5sg39XwGQF9ywybGWZ9m/BaFILrIJP9I= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by DU0PR04MB9636.eurprd04.prod.outlook.com (2603:10a6:10:320::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41; Tue, 7 May 2024 18:47:28 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::1e67:dfc9:d0c1:fe58]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::1e67:dfc9:d0c1:fe58%7]) with mapi id 15.20.7544.041; Tue, 7 May 2024 18:47:27 +0000 From: Frank Li Date: Tue, 07 May 2024 14:45:50 -0400 Subject: [PATCH v4 12/12] PCI: imx6: Add i.MX8Q PCIe root complex (RC) support Message-Id: <20240507-pci2_upstream-v4-12-e8c80d874057@nxp.com> References: <20240507-pci2_upstream-v4-0-e8c80d874057@nxp.com> In-Reply-To: <20240507-pci2_upstream-v4-0-e8c80d874057@nxp.com> To: Richard Zhu , Lucas Stach , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Bjorn Helgaas , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Philipp Zabel , Liam Girdwood , Mark Brown , Manivannan Sadhasivam , Krzysztof Kozlowski , Conor Dooley Cc: linux-pci@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, devicetree@vger.kernel.org, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1715107574; l=4309; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=ZPjAcBxtYZJ5XniaGZi6HJYuwyn8TYkFm7iZBMDoWyQ=; b=N9Nuh+GGq78j5duB6mgd1DTwhcXW8tEGRaXD2TuBw1H0WsH1ex7NBVYWqdvCxjs80qQIdrTFH LAg8rwiM7NOCJi53O8ZNlbd6O5+s5fZntngaQHNIUwdUkQ/niVLmylQ X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BY5PR17CA0026.namprd17.prod.outlook.com (2603:10b6:a03:1b8::39) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DU0PR04MB9636:EE_ X-MS-Office365-Filtering-Correlation-Id: 4c11f36d-28db-4f78-fb4b-08dc6ec624a5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|376005|7416005|52116005|366007|921011|38350700005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?snqZvx25/mbnWGpAXsyHsKbe5U1ba04?= =?utf-8?q?Q8KmTF5u38miYWStDv03+u8GpQDQLVWD7ifV9tUxIbgCjW3JR4Hm9dMInGS1Hswho?= =?utf-8?q?0p4WWcaPEZ300ZTtekD54jwxjSafY+6rcmFRqb4a5Iw7hNtJtK9FYH/ET8apGqw2R?= =?utf-8?q?G+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dMuXJrO3Ns5mG/IXEBQrfq1rninTfBokQm1Jb6PS7W5Ne7xl7IHpeEZ/4+r/ZA/u?= =?utf-8?q?806hVj3Dcfjkx7W46+WlJ1Cb7fP7LkrhCRRxTz+ceM9KrHF3aPYdhHwzLTt23MeRU?= =?utf-8?q?4coY2eCpMxZ6XolcOucL4qU+ZphbZrUN1fJCB4M2F+ouNehNVJd+SsE/wOGr1ftu6?= =?utf-8?q?5s3JfwwcUTCmVPe0z/JCHvowS/PerRpiqGd/CcrDnROHvN6sdkgy5MIIeVeJZhgO7?= =?utf-8?q?1+zXI5eLA2O/I62gfHjPmek6HwgvQTXeMKA=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(376005)(7416005)(52116005)(366007)(921011)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?R6WjmpW/wBRL+cA1qhvMqy0KXseH?= =?utf-8?q?j+9ObYgYs+yqkwmKsiXN1yvI1+U1DRbLqWhhTUtCNnT9c30lUHMEpLE14VsuBM6Lt?= =?utf-8?q?cuFohOH3w2W1pvQwL36/qTCXSRIV2CNQX3G68UkDGzDK/as/oL2lyqEdevjE/uRHD?= =?utf-8?q?6U2jM9yO2ZNgO+YSwUtlCHQ4xEBerM/kRBbHIneWa/D4v82nVc7wmsimfriBzWOMi?= =?utf-8?q?FUJ0/8Q/gzxIPjAHvNfuF8F7ibZTgLV1QNZccaCRQ4X9gMqn0+UdB6H+XsvI+xZWL?= =?utf-8?q?+5zKsonWCOMnTLpVZQSKrq6nj8J/PTqAz1UilnKW4IjjA0MIdZuAZtIOwcGCi6Yyv?= =?utf-8?q?8qVP6Cth3xh7EowHItprdqZ0YZ12F9zKVoqSn5ltt6WcPI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ofG2wR6L2?= =?utf-8?q?edZEToExFnKH8+bQmvnYgL58FaEvLkWZ73IMTfEprN9mBMtR/R7IQOa9bLtXZFQGX?= =?utf-8?q?Flg1vD+/ehF7QAMnzDaEJrEmKefOxRHXpJ1SjUdXO3CO1BCRfe+8cj6LMzYWZNJK6?= =?utf-8?q?fG7PDJR3U4tj+4eUy4ORjx270HpYhrM/S2GfMSzHKUSzcJikxViQ3V9UQ6jpILna/?= =?utf-8?q?w/8IbZI1qpPbbH7y+sp8ak86fDdeh7vH1NYVHXPIA/yDfIWcMG2zNyxwbWZ0cnKtv?= =?utf-8?q?8WghoHolkwZW?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4c11f36d-28db-4f78-fb4b-08dc6ec624a5 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2024 18:47:27.8307 (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: c252wehaEyfmzzF57iSFhRpekzgJm51HrBSbR8OZmfSrsJxa7U5hgFfwlnGuEt8GWebUo7oaz4xEgTCLIiyCIg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9636 From: Richard Zhu Implement i.MX8Q (i.MX8QM, i.MX8QXP, and i.MX8DXL) PCIe RC support. While the controller resembles that of iMX8MP, the PHY differs significantly. Notably, there's a distinction between PCI bus addresses and CPU addresses. Introduce IMX_PCIE_FLAG_CPU_ADDR_FIXUP in drvdata::flags to indicate driver need the cpu_addr_fixup() callback to facilitate CPU address to PCI bus address conversion according to "range" property. Signed-off-by: Richard Zhu Signed-off-by: Frank Li --- drivers/pci/controller/dwc/pci-imx6.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index df623977d8fe6..a5af3e874613d 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 { IMX8MQ, IMX8MM, IMX8MP, + IMX8Q, IMX95, IMX8MQ_EP, IMX8MM_EP, @@ -98,6 +99,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_MONITOR_DEV BIT(8) +#define IMX_PCIE_FLAG_CPU_ADDR_FIXUP BIT(9) #define imx_check_flag(pci, val) (pci->drvdata->flags & val) @@ -1091,6 +1093,22 @@ static void imx_pcie_host_exit(struct dw_pcie_rp *pp) regulator_disable(imx_pcie->vpcie); } +static u64 imx_pcie_cpu_addr_fixup(struct dw_pcie *pcie, u64 cpu_addr) +{ + struct imx_pcie *imx_pcie = to_imx_pcie(pcie); + struct dw_pcie_rp *pp = &pcie->pp; + struct resource_entry *entry; + unsigned int offset; + + if (!(imx_pcie->drvdata->flags & IMX_PCIE_FLAG_CPU_ADDR_FIXUP)) + return cpu_addr; + + entry = resource_list_first_type(&pp->bridge->windows, IORESOURCE_MEM); + offset = entry->offset; + + return (cpu_addr - offset); +} + static const struct dw_pcie_host_ops imx_pcie_host_ops = { .init = imx_pcie_host_init, .deinit = imx_pcie_host_exit, @@ -1099,6 +1117,7 @@ static const struct dw_pcie_host_ops imx_pcie_host_ops = { static const struct dw_pcie_ops dw_pcie_ops = { .start_link = imx_pcie_start_link, .stop_link = imx_pcie_stop_link, + .cpu_addr_fixup = imx_pcie_cpu_addr_fixup, }; static void imx_pcie_ep_init(struct dw_pcie_ep *ep) @@ -1599,6 +1618,13 @@ static int imx_pcie_probe(struct platform_device *pdev) if (ret < 0) return ret; + if (imx_check_flag(imx_pcie, IMX_PCIE_FLAG_CPU_ADDR_FIXUP)) { + if (!resource_list_first_type(&pci->pp.bridge->windows, IORESOURCE_MEM)) { + dw_pcie_host_deinit(&pci->pp); + return dev_err_probe(dev, -EINVAL, "DTS Miss PCI memory range"); + } + } + if (pci_msi_enabled()) { u8 offset = dw_pcie_find_capability(pci, PCI_CAP_ID_MSI); @@ -1623,6 +1649,7 @@ static const char * const imx6q_clks[] = {"pcie_bus", "pcie", "pcie_phy"}; 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 struct imx_pcie_drvdata drvdata[] = { [IMX6Q] = { @@ -1726,6 +1753,13 @@ static const struct imx_pcie_drvdata drvdata[] = { .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, .set_ref_clk = imx8mm_pcie_set_ref_clk, }, + [IMX8Q] = { + .variant = IMX8Q, + .flags = IMX_PCIE_FLAG_HAS_PHYDRV | + IMX_PCIE_FLAG_CPU_ADDR_FIXUP, + .clk_names = imx8q_clks, + .clks_cnt = ARRAY_SIZE(imx8q_clks), + }, [IMX95] = { .variant = IMX95, .flags = IMX_PCIE_FLAG_HAS_SERDES | @@ -1804,6 +1838,7 @@ static const struct of_device_id imx_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,imx8q-pcie", .data = &drvdata[IMX8Q], }, { .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], },