From patchwork Tue May 28 19:39:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13677241 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2078.outbound.protection.outlook.com [40.107.21.78]) (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 B73EC17B50A; Tue, 28 May 2024 19:39:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.78 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716925200; cv=fail; b=jJR0ehBCY9YQ3AMOftk14stS2ERw9Hg+rYJHtquz417LwpMNkWrNhDgTmBMc/yGW55B9vxsIHt5AyZ4uSXPwhX0IVoHyEqViJIYbCpOLIX+0ObBVp+99ZEEjP4zw496ip/UYNyLsFI8yq5HrVGQvX5TMB6pZV1T7XYYWn2c3rL4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716925200; c=relaxed/simple; bh=xzQ/sdh6rUEzBlHbjXDB3BdPseMVFXbJTzuQD00Xw3s=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=m+nt++6wwhZcrf+BXlpqoxlrj0VNxN2EuGRGOJilNE3UFDT7SezX4NQUvt3cu+7/S0/HV/E7H6rupVpzy4DSHOoQ+AI10PQGeF4twD2Sc4g2TLNXdvXuoSlQvR3T8LkX8MojcYvw6/VYlgwr84z7zT5BrIdi0TUP3aYm8XDuXEc= 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=efAkKEai; arc=fail smtp.client-ip=40.107.21.78 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="efAkKEai" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=npoNHR3XknOGHEdtS/dMnuCsG6cA7A7oTP3UCfon5RpYoMuzs/FUepl41hG4cRGvZUtDOCrlINyUoGI8SrK+R4DKf1KoPldvB6uS2hNaN5k1AR042gWVFfn2aU44OB/OzBXCwVSPfUQCCePvyycUBYJPsDUfbHYjYNLCtpbQoJYDRtVT+CHx6838ytuaDoD5EU7HAeup+DaZo/rZJ8D7PSOqfhPw6/JELVwQnm1iIT78g4ojItoZNNH7+IPFoQjzf/tPcHxWc7dW++BJ1+OLElPBqehe4YV5C54Kvu6X5ql9wxJaRvyA6u4aVxAw7pLJa/eikIlaY0rkgVOmiwulug== 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=Nc47JLvApIG1K14sltKfahrWUjVx+VnkoPE/T3p+JSs=; b=jTYui36vrniRrLLNmfIe/qd1qKbGJbye/5yp75xshzfjcIX2A8Rs6mCAqFep0/ICUu5oB3ZZtbsUNVp0bYkHdSknYvOpYR7iD4x7Eqbq6/lRsd2yB8J0maUyfuR+mWhtCP0SjC203IDL0axwBYou/61uU0sVYz8kdyjZ/HgbKIDB6q+lI6Rr09Ez2DHDvwozyJ8mBvLDZu7sEoXnCoB/6qyBge4m9iqvI1tdoGFMUPqsbpNaLotSfLnanTRL/EIIq/GCS3fjiR5gXjqNm9Tan/erVJB1pFIPQ0dMLa58oc0IbwylGtO2k9ebWpDSAXLhE7Rrv+THAey2jLRAqw+2EQ== 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=Nc47JLvApIG1K14sltKfahrWUjVx+VnkoPE/T3p+JSs=; b=efAkKEailpJp4T2vVn2zHi4jqPBj3mN0tIWXDXN6qNJZTcXC2SI8+Phvrnw9ZfBOMAlBK6erMHF15cI9AFgPdVIvH96eAmbowmDRVYbzaky/Z39eeCmtv1V+y+YnPDbE8DaALt7j+DsAHprPcX6jEBzypcfns1wn8edAC7lJl2g= 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 PAXPR04MB8655.eurprd04.prod.outlook.com (2603:10a6:102:21e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.30; Tue, 28 May 2024 19:39:55 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%2]) with mapi id 15.20.7611.016; Tue, 28 May 2024 19:39:55 +0000 From: Frank Li Date: Tue, 28 May 2024 15:39:18 -0400 Subject: [PATCH v5 05/12] PCI: imx6: Simplify switch-case logic by involve core_reset callback Message-Id: <20240528-pci2_upstream-v5-5-750aa7edb8e2@nxp.com> References: <20240528-pci2_upstream-v5-0-750aa7edb8e2@nxp.com> In-Reply-To: <20240528-pci2_upstream-v5-0-750aa7edb8e2@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=1716925161; l=7024; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=xzQ/sdh6rUEzBlHbjXDB3BdPseMVFXbJTzuQD00Xw3s=; b=/IFX7MJ56McmsJfPS4f8VHp38XUN2x1PUemrjH3NqoRV0CVgd2Q0Yjx46mNVyxggFkFKiT+P5 ulpCC1SK/j7AF0MMHw6GRf27ieJPwGRKbag1PSufJkHwnjTYoF3PlIF X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR05CA0021.namprd05.prod.outlook.com (2603:10b6:a03:c0::34) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|PAXPR04MB8655:EE_ X-MS-Office365-Filtering-Correlation-Id: 57dd02ae-a9d1-43db-2130-08dc7f4df3a2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|52116005|7416005|1800799015|366007|921011|38350700005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?6ritbmCMZmDE63/FOKTy34QVgrG6SdE?= =?utf-8?q?hw0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PzMu+MKVaQKimiACUjWATd4I6CD43qC08AwNtPScueDw3I8ZzzbFWYD?= =?utf-8?q?aAPFX755uPvXs7xmii6j1ki64yRK6JNErgzCJiAhxIG9zqv2jd92OeaPRLihEXpqy?= =?utf-8?q?5MJK76VjayNrtHnR0lRv6UV7eB1cgQnH762QCP2SuM2V4iRpesGXwDZ0dWq1cMsK+?= =?utf-8?q?Jfhu4vO2ehGmhtPB5PSBHNptV60nGpWY0IE0ueRwBOav40GPpaQEt4zHsyhVUzbtm?= =?utf-8?q?TswOYFrYm7yUGNqzm6RgA8XZE8Ysvlk0D/zvG3ZBgcmxkfcdhBhhtsuIozOxES7T5?= =?utf-8?q?91TISGGbHgj/d8rJbc1YkVRfJeMjXb56xYiFQ2CJQ3RPViURg2Jgat40DekG0gpyF?= =?utf-8?q?Qm/dsxw37CKeJekbiO95vPD1VRQCE+8jV4gWcWupTwDckUs53yf2TCyw=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)(376005)(52116005)(7416005)(1800799015)(366007)(921011)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?N5BcbjTfXnVILHPmMAvoK8mhiocp?= =?utf-8?q?0OSxzc5pF/0HAcKoIJqkIog5ysrwDqjk5qhIe7qW+9WaCvg8okELX7eeEXEsKMe+t?= =?utf-8?q?Cjco7pBxI2FrswUZuoJhmREHg62q1DwecSY4AYt9CcwhGO/Fo2497ip0DHy87J0ZJ?= =?utf-8?q?Jsfv7HbI4nIfntNPoHd8i9+cPNo0EXVDQXzic+d26igLckxO+9xO4hNeUz5dzeMPl?= =?utf-8?q?UWjmyRzT2ZDEQhXoU8An14T8/Weso9ZGZFs3nEVHqSxVF9QWp8cFrg6wCPq/YFg9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IRObTA9SUlmJc+FodZ5Al60QWGRuKesNPS0kf/BhumeeiDGQdwn3IiSxC?= =?utf-8?q?7K18aIRsnKoPSQgc564v9ukww4DZFdB9ku/FOPPLqM5DFTytRSzLoi/Tfe0R/TgCY?= =?utf-8?q?6/VRyjXHMR41/cg2LWKzB4qNciK4zGRFup1lL3IajYAsCt2h+Vaf60m1O6UXOSA5O?= =?utf-8?q?rl/daNabAwoIOMsg6We0YyC8Nq2Ku+cCdLtCJlYvYfckLjVyfTvo4l+FyQEWFdfNS?= =?utf-8?q?hiLuPXdNp8OIEWzqSLGDqwHRC6EhrETTCU02phbQqSF5BWPlNOYhIQa9KpCS1Sn3+?= =?utf-8?q?Zgl4wjlqSR4hche7ZRNVnYimToNdEtTj4HQ4zAWTi6LrkEOaeyGVcDXE=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 57dd02ae-a9d1-43db-2130-08dc7f4df3a2 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 May 2024 19:39:55.7303 (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: JKDnMsHbXnIzYKgIHOB3OD+pUeO+2mVafYHJ3gz+1W1BcqCOgxbJItR7vn8TtNQoQ750cV8b3qabA8h7fvMkaA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8655 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 c5d490afa981e..5e21fc942e90e 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 (*set_ref_clk)(struct imx_pcie *pcie, bool enable); + int (*core_reset)(struct imx_pcie *pcie, bool assert); }; struct imx_pcie { @@ -670,35 +671,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); @@ -706,47 +747,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, .set_ref_clk = imx6q_pcie_set_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, .set_ref_clk = imx6sx_pcie_set_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, .set_ref_clk = imx6q_pcie_set_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, .set_ref_clk = imx7d_pcie_set_ref_clk, + .core_reset = imx7d_pcie_core_reset, }, [IMX8MQ] = { .variant = IMX8MQ,