From patchwork Mon Jul 29 20:18:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13745670 X-Patchwork-Delegate: kw@linux.com Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2048.outbound.protection.outlook.com [40.107.104.48]) (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 686E318E75A; Mon, 29 Jul 2024 20:19:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.104.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722284363; cv=fail; b=cx1WIaDgEs7ozPwwaqKgKvBEfswQ+4iLutr5XhSimj/xvB16ystale50aDZ1slRssPsog2r7ojmv39qiIsAcBxgPLjoPhVS8ntRk2qh4zr8XeeAkM+voaqiqdpA6mRC5M5IS6i0Kqfs9ALzJrq8eWR93+dW+w4XlyDQTk3CyQRA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722284363; c=relaxed/simple; bh=l6u7V1/pCtBjFxMkz39fZGAw07dHKSYZdHO4bMuhkdo=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=BFpAyJrXJM5mRHHQUFQyiaqPCta158cj4a83qGbn/JOjmc9qB6BiA/JjQGnK04RBbxcQFyVVQHmISL2OPJ++UiEcfnSsih4vLGiEqXIaNQh7gxp+rfadnaxNHm47PoB8gm9iRc2/sa2/b/0xwZn0WL2rYoZDEBw23McQx7ysTow= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=ADpsCdEh; arc=fail smtp.client-ip=40.107.104.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="ADpsCdEh" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cUoYVuMzLeUeS8/wTLpFIjTj1c8Jh0gmEpoK3YuRYUoUnHzPgxER26lBZt7drN+VZRCU69DZ7QYBohEZflTINbF8zyhLIA1iEPh1N3oSzVlvrkTZhSu7qJQXB0F4ugOBOAoyQ3yH8OonTy//KHc81Sp9fv36buTE9JT3uvw7TXWRxaznXQXGblPtGrd1ysgksKSkOA1u48oeIiehsAEdCj/BweO6C0N0BVjO+0RIKfn8t5FUHxKsz5XkNg5GHM/KtPhIuSHTXn8sW5L3GkcwkUh1hr7TTLIhLoloNxR5s4o7TmE56Osqd+ZnhHbcLmsSuqxlbuGKSjGNhiM6N4+pBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=N/QA2uinC+ZPsfCdu0G7gGvjslyL0frrBFiMN/7ouRQ=; b=jH7OLSRiWm7hdopfZzEbvnxFBU3AoT4hSXmf/PnyIirNhXjAjS7npvCU20dW5xQK4QYhykjRZwOSIDmR8yrAHIzZSZkHTYcdHNO+Bb6KbGLdAaHklJReGeAtnV5xteeNYPrAZTEtcO8TiEbl8LxKP9gLBDJoNgEukaeE2eUCLHWj/yO/o4blujrkLuLOfiQm0fWcTG9WneL9sQ2RMFIgX5yl9uOOwZfb/FRebkb4y/ddaF6NZ8vBKA4ua3y74qqOmdDkdxJMo0jPJDCo06HRxNsDSsnU5PXNpOMQnVd53O4w+NzOjY81dlKnVgNdgV6plLT7ORZMCther1G9uoACDg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=N/QA2uinC+ZPsfCdu0G7gGvjslyL0frrBFiMN/7ouRQ=; b=ADpsCdEhgeEgoK9xs6zg8CN3dafWFBc2Wx6WRWaJO8ftrugc4c0Sz0TsRZ0/73o+1eB3N7AEvk9ndfNeHDBHnJeK3NOTFlSE0hk7L4kiuc+aX9AxHb/OaDo9/i9y+dQ71Yi8Vutux2CSsd2M8cxtTP612Hb5x+eKFKV4SbfYQbp3dA1ePUfO93OQ2IU10N00bmDt9q8XRlpdp2tm2VWA3H6CA7xiyQZwPjZ+ckteEV/wDGbtNLLKdJb9PoGzF88rTp3UY8P/Qe5BzqMHjnhNhqoiUy+4BigrJMcuxgbeUU2YPd3ffiVIcTnTWp8dvDr0J1NR3ffGfOhZXHhW9lo3Jw== 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 DBAPR04MB7382.eurprd04.prod.outlook.com (2603:10a6:10:1ab::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7807.27; Mon, 29 Jul 2024 20:19:17 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%5]) with mapi id 15.20.7807.026; Mon, 29 Jul 2024 20:19:17 +0000 From: Frank Li Date: Mon, 29 Jul 2024 16:18:13 -0400 Subject: [PATCH v8 06/11] PCI: imx6: Simplify switch-case logic by involve core_reset callback Message-Id: <20240729-pci2_upstream-v8-6-b68ee5ef2b4d@nxp.com> References: <20240729-pci2_upstream-v8-0-b68ee5ef2b4d@nxp.com> In-Reply-To: <20240729-pci2_upstream-v8-0-b68ee5ef2b4d@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=1722284317; l=7122; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=l6u7V1/pCtBjFxMkz39fZGAw07dHKSYZdHO4bMuhkdo=; b=shKot/hisTnDMqzj/nvUxxC3nka7UotQLVSp9NCqGWdCD0iEENfuye2ecoH5KncI9ZHLCkcXp Ga72Mrepd+eDxdMWVnED9n845fcBwWNlzd1I7IiESWzWjM4sGU/CPZ1 X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR03CA0069.namprd03.prod.outlook.com (2603:10b6:a03:331::14) 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_|DBAPR04MB7382:EE_ X-MS-Office365-Filtering-Correlation-Id: 02e66897-25c3-4081-e513-08dcb00bb91f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|366016|52116014|1800799024|38350700014|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?BbF5aMEINXga4Fsz2OMg8o/W8DIr/Ns?= =?utf-8?q?vuh/t1YI8mZQ0/fvg7vIgIx7Kp5i5zKH26iox60QxXMScUP8bOGI38k7O/g776Wao?= =?utf-8?q?fAMPS5mSfFRlTOpWSGMjWs9+iL45WlnAyHOv4NfBY0Yfq506ZucaFxrwd2PlIj+GC?= =?utf-8?q?THhp30l0AgRCkq6LXJddSQSXdymZY+smghIC6MsP5gd+U+tag6nxlrvj36AA1Kz6/?= =?utf-8?q?R1fJeG8O/t+kv12RKK9R4F4jfAXevC9scCjoNHQ1jgIjW7pkDd8InYCg/M+Aj880a?= =?utf-8?q?tvTkvNU/i1PxPgldox5wBRh8s0MBG2ogSjoomcRZndnz657/wXcuB9yVuR5s4Ji00?= =?utf-8?q?MERsJ6n3vHW+awAPoT2SR0fYe+WINx5TKEXUV3Yw3dDmIdftdhQZoTPPoZp8p2wFB?= =?utf-8?q?FwumIs6Etx7jY5QVGg66IN8WGJ3QMqkzY0ktpxM50x6dXR+woG8WeHT5GDcXtZ0Cu?= =?utf-8?q?saEV0+zrWyLKNJhtw7io3RRQ+2kVqUVhzNhFiK9MNUrXUMLKi1psrli1X8I3cO1nB?= =?utf-8?q?zTbAmqlZsqHsoKXnN5f8pYn5s/YnM2wGNHsSXCUEruC0oEl+T0EYLnzb6+s2GHHOX?= =?utf-8?q?igf+qda9uFt1lxbsykfUK2RYFguS8+D+XFiCHsB93VMdjWqmWY3ROvTsJHO+Q8Fl6?= =?utf-8?q?Js/ndoKaKFeN2Rro1WfcojOdODDLfaSkS1ajTX3x4we/8FUlDGoUVDCjitg2at/Ow?= =?utf-8?q?k6e3tmLHnGHKWlNY1KOg8YOs/htYC5IXcO/TLQMP7y6sqYonuWVHLF0SFiakA0lPa?= =?utf-8?q?4iD2ly/Z0UUgFfi5188VT0NONctjgh3AuatlI/GyFvrq/cqeLlrWkbk4RJ4CMMmFi?= =?utf-8?q?hMBGYIiqiGWxUpvUqsMbvHMja7p1rAOOXGAohAa5bwbvAhFgdVhMtEYqCao3VwJwb?= =?utf-8?q?WsjlVSIz5jAAS2GWMrZS5wyUTw/uq8twWr3Mz+1yuHQvabacL7JMq5szzVKP71qb2?= =?utf-8?q?YofGF2WFMLgPUaqyRpYYXSWkdXSDbIzsXP/NbkpSSwFJntQjZJFDFaShG8I5GwHsi?= =?utf-8?q?zHdOURldAApO/S85x8eB7I3EvINCrDiEGCDrp0L00tdTIb83QkEBaaPtKrc5m4Kc9?= =?utf-8?q?d9w6DZO2pydLdVVVguhrBsQA8uOP1YO9RIvvTj6hRDfud9Fl9lkxQ8tMAPfciwn5n?= =?utf-8?q?X2XoD7yNS4sxaijcvTtYTBhYFKSWG3IVgtBcAm+wYrM5wxNyFlAzB/6BjL9Rr9bKC?= =?utf-8?q?AWH8nfO2eD035d6xs3gQjr1eFsYG/7jwOIlaVrosVfIVkEePo+MY7doR4+SnK2nM0?= =?utf-8?q?8k2jmclDTAnJU8ODE/QwtKOe9jN7CYHGUycPnS5eLpWT+kt1k8Qf2Zi7X0iXusej4?= =?utf-8?q?PHfM/1TKDOJ8UsXWTVWPRXCnHD7Uh73mWCWDfQxt8k/VYfxJVGf1658=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:(13230040)(376014)(7416014)(366016)(52116014)(1800799024)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?sxGhGkBIRmdPgepQbYpxlANtYz/v?= =?utf-8?q?Wc9kHTnsYY6Hzp1ZzuDSjEFS+JAFhsIOEf0mYTCD6PC9Zmfowrf3WLyjP3FN6KolJ?= =?utf-8?q?9lzh6U2ApstJYLMZRmFfyyZrJgZ3qSEOdBdBmhT9HJoTFmPTlLx7u/u/DWQto1rfu?= =?utf-8?q?HM/B5TZ615vZ+gW7pbcFfB2fINUc1vxrerTZ5FsrsbJ49TYNPG0iwM+YPtzELVmvS?= =?utf-8?q?VNtNgqgFbWI89lC8CQziqpaIPUWacURHwXXKxY7KgFV5ylwMf1RkfRt8qHQqA/NjK?= =?utf-8?q?XvA4m69UrpamTuTWlLTtrfOMs2Ix43+q4jcYeApDrAc74CH0KSzsg/LZqS7ahey34?= =?utf-8?q?c5YFXwUWKNnEImdnulIeQ+1VU9FxAR2HuuXsU1Dy8vXrgez19I682oWCAmQVGyizp?= =?utf-8?q?snarl6n/fERhuRH/GW0xlYBrNOgSxs7Um7s8PhHPnhlJIGXJ7ZVXiOkT4LfsxURIb?= =?utf-8?q?HwSx1eK9u2WOqpRpYFWLZtjN7nAOceIaT1DvxYUCjPHjbuMeM9BzSrWwSOo26/vxp?= =?utf-8?q?gXkhGZhO53e9802od6oPvZiPFhFLxmY0f1Po7yDI8jcq54htxWWXeNwFYDHYmUEPF?= =?utf-8?q?1C4fHwkg2fDofG3lHbsTu7EAtiIwl+RPaXYi1tdhr3wZsoCltB9CBKyHSgXwKpNtP?= =?utf-8?q?FcQkSpp7iW0owp+P4xcZ4iWT/Y86qlwvkuG40dYvGSuvLVOBQvMTgFu+wdeRH8FYU?= =?utf-8?q?gGorH7TZUCDgJ55SfZ2RUK7mbi4ydfPFdLmiPgJKUmcnvkmqlwWlwiy9vWqAKOK5a?= =?utf-8?q?ER5UHA6ebvduBijiQO7ejHHr52wFMzZdS7sbFRdPNEF2k5ywWx4EcW/xAk6rp8/a4?= =?utf-8?q?wSthT1W2QVp/3pFiLsqEU4qdyV4BqwzJapxrB6ppOJmYEg0ny9GaJJWJu60nmMt+m?= =?utf-8?q?fP58zH/ewIotbZshMS4GuIIo8vNdNhNBhdXZnsFAQPm2kT/8ugOfTnHU94jrsz7fZ?= =?utf-8?q?hmYJZYlfZS82fLARMKU2wpJdLglnIEvPddU8kPp/phYeGF6uP6qXwauHNuFZYbIGz?= =?utf-8?q?Hn42hnOPAqkahNnZy9pqXztlVi5AtLiXfwqBsB3dO0cCVZ3uW+rKKSPX9kRaeb/aU?= =?utf-8?q?BnJv6J3WCadGaP0Lp8o9geiRKYtVX5HuUSeYpIiy6KfCp3pySd9YRIRF44fx8GF/P?= =?utf-8?q?FNq9wYxWs2ykjr1cLS+Q8y90iAYZp+mGC8NG6OAUOv56kIfQvdOtQ6aNGxP0I+H+I?= =?utf-8?q?VxzL29eXjU/Iq8PZAJpxDW9xQBxBwJHH1geSnqzs2G0XOS7jO1bE4kOvRNtPw/HMt?= =?utf-8?q?Wp6yYqCcffd1Wkk3o+cbGHOHvNbzA5ijUCAsE7HcsAkKohB6eBMEfLjbADV1uOYjd?= =?utf-8?q?pJThkWja9jZf0Nmi7b81eiA+QeXYNgZes/YYbegaEuaYHQeIMUnQsB1qCC69EonGt?= =?utf-8?q?YHf9+sPhZsI5SDUlA+ek8Lt/H6ONqqA8iqQ7X1N+f6cWXuF67yEpt13GBa37vX0ve?= =?utf-8?q?y3eyd+noWz14bnklIAFBzpYkv54GV3qJf5dqgzZnOhekYV2kizFHvJYsGApqhI0dj?= =?utf-8?q?/m3V9m6l2S0/?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 02e66897-25c3-4081-e513-08dcb00bb91f X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jul 2024 20:19:17.7571 (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: gWxpp4qvgSUqeio8xku9qDPoYWvIn0ylanWSLKy9/9uNmDtPQ9F+P1s3kWeUnsZd85c/fyMGV6sFu89jfdyPug== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7382 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. Reviewed-by: Manivannan Sadhasivam 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 b68a817ccc86b..e295c7bef732e 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 struct pci_epc_features *epc_features; int (*init_phy)(struct imx_pcie *pcie); int (*enable_ref_clk)(struct imx_pcie *pcie, bool enable); + int (*core_reset)(struct imx_pcie *pcie, bool assert); }; struct imx_pcie { @@ -669,35 +670,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. */ gpiod_set_value_cansleep(imx_pcie->reset_gpiod, 1); @@ -705,47 +746,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 (imx_pcie->reset_gpiod) { @@ -1442,6 +1446,7 @@ static const struct imx_pcie_drvdata drvdata[] = { .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, .init_phy = imx_pcie_init_phy, .enable_ref_clk = imx6q_pcie_enable_ref_clk, + .core_reset = imx6q_pcie_core_reset, }, [IMX6SX] = { .variant = IMX6SX, @@ -1457,6 +1462,7 @@ static const struct imx_pcie_drvdata drvdata[] = { .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, .init_phy = imx6sx_pcie_init_phy, .enable_ref_clk = imx6sx_pcie_enable_ref_clk, + .core_reset = imx6sx_pcie_core_reset, }, [IMX6QP] = { .variant = IMX6QP, @@ -1473,6 +1479,7 @@ static const struct imx_pcie_drvdata drvdata[] = { .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, .init_phy = imx_pcie_init_phy, .enable_ref_clk = imx6q_pcie_enable_ref_clk, + .core_reset = imx6qp_pcie_core_reset, }, [IMX7D] = { .variant = IMX7D, @@ -1486,6 +1493,7 @@ static const struct imx_pcie_drvdata drvdata[] = { .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, .init_phy = imx7d_pcie_init_phy, .enable_ref_clk = imx7d_pcie_enable_ref_clk, + .core_reset = imx7d_pcie_core_reset, }, [IMX8MQ] = { .variant = IMX8MQ,