From patchwork Mon Jul 8 17:08:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13726898 Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012005.outbound.protection.outlook.com [52.101.66.5]) (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 A3A7814E2CF; Mon, 8 Jul 2024 17:08:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.66.5 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720458536; cv=fail; b=J45F91ypqKeBY8SIPUp5kwLErjht7GlqG9mCjFm2G38LgsTBhRLz5G/xBjxTnk0TApikcxy3rHaV5m09qufQb95zNLxa554W7rjwdw8/ran3JzVHXvL8qVB39BhA00dRni8pNy1SVxQ/bRzPCUgzJPvzsOaSeLxD7YVuD6wRriQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720458536; c=relaxed/simple; bh=0PCynYDtS2c/Buu1JgYFZeq5Vw2vOSSVM5N+Ad5tguo=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=h+xD5saNoimmtPEf5DHieYJgd4REGC3uxxni3Um0QUjlqFHxCeOsRzHUs62TfCuhP8o+RbvD1YVuyHTpsN/YzNcQoj30KqPOTwU1kdfTq4AnE8EO5oLDx2yGBdJViiwiEoQOKqAqQ5bxgLvIvhkPK8Kh2qVnG2DXL5spgp1GZ+M= 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=afp2h6mP; arc=fail smtp.client-ip=52.101.66.5 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="afp2h6mP" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N2XhTrsOcnPgXrfFUeuxE4+ByVKwIBoUrepRbewgfp/s2+inI2VTph3K6T2DyExGlHpo7oMKnng8Jzh7nEmGJ9/EWDIOxz/6aJap05GeNg8fEn23xMkr+8Hrxdz6lPEQbNgi+GJfdmt0dcqsZp5m5tQHpuTsOfU8tTfKDdLeh/qrv40FxNu0Mb7+P16HHY1kpI9al6i06yPRjtAfKsZqJHvyGa+N+ANEwUcmeQYGQwaVChdTIVQsh39cSyEBhezGUZ/VB63TenfHFisAUM9pfhuJWqr1ES9gSkCQlh8nc14ZCtmK0c4rYzQ49su790fUAiqDp4ojP+9anLsCQuPYMw== 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=/0hS/iqnnqj6vsmpa6ZBf3F3fkX+7Gf7/1PukbpIC1Y=; b=ZEYiKeh4lRVqeEsDv1tPaUQOQgwK4O0Y39kRRH0E/il5SFXihyTW5qsFvTYW9mad7czDbTArqOTEmJcqm3NNXMLVqGVkVw1XM9sHP1KFKfES8D7sdzEXASBWtCiTlV0FN+FMnH6SNheAVwXWeUP6Llm+d1BuEL0p60x8HiXRCI0HEr1JKYtUry2R8ZQDxBvWAOlBr1hW4gEpHDW+MoT7+vBY0YZjE/ZKwexrCHiBhOirEQFWxTxuGweZIpeRBKPDk7gSGDbO2LpOdy7ea+UEyClvvabL5tD6+GWPhSECo8YFqdoHtn6W1LcLOQnOnErMgvClHWLbziSwC0xjV2RFHg== 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=/0hS/iqnnqj6vsmpa6ZBf3F3fkX+7Gf7/1PukbpIC1Y=; b=afp2h6mPoTTCGCAm3WvAg+713oRjiQy+euX4YU9DbQyhjvVxQJd2pl/LgzCKZ+r69g+ZMtEKVZrOu85/5OVwdoeuh03FMbf5bev+en1tIIsIe8kSmp1n8GYTj0sVudbgj+OPW9A0USlKU0TALVeKSANzCh6zfCofEDpfKhZGKwU= 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 DBBPR04MB7867.eurprd04.prod.outlook.com (2603:10a6:10:1e5::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.35; Mon, 8 Jul 2024 17:08:51 +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.7741.033; Mon, 8 Jul 2024 17:08:51 +0000 From: Frank Li Date: Mon, 08 Jul 2024 13:08:09 -0400 Subject: [PATCH v7 05/10] PCI: imx6: Simplify switch-case logic by involve core_reset callback Message-Id: <20240708-pci2_upstream-v7-5-ac00b8174f89@nxp.com> References: <20240708-pci2_upstream-v7-0-ac00b8174f89@nxp.com> In-Reply-To: <20240708-pci2_upstream-v7-0-ac00b8174f89@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=1720458497; l=7125; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=0PCynYDtS2c/Buu1JgYFZeq5Vw2vOSSVM5N+Ad5tguo=; b=4kvuSv3xf6MeaiSIZAJsfIDFdi0s7azcmfkS7aZRg7u5aEMh+kaE7jytNB6IDm10HtELpFA9Z MRJD9YLw2wwBhX32TDy3ralFwkHNRDf59AA+3qE2GH4fp1a0q2luYXv X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0198.namprd13.prod.outlook.com (2603:10b6:a03:2c3::23) 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_|DBBPR04MB7867:EE_ X-MS-Office365-Filtering-Correlation-Id: 0cc25eb5-0cc9-4b40-ddf5-08dc9f70a3ed X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|52116014|7416014|1800799024|38350700014|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?SpS6Zq/Q2KDGvTjdrm37r4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xLbXRy?= =?utf-8?q?HkGC93Ihu7cTEJRPnRNkIBlkhWs5fzYQJbfilJyPrH0EOeIwyt0DfPJDm17veOOz7?= =?utf-8?q?jgUd2FS64RF1g+uiBI3L+ZDYUXL/VPz0wBkbGasBv98TKMQncKwrXLF1VnObJ5ilA?= =?utf-8?q?AAlFoha0fDPuY7LQhHGjkRA7xYCORllxvCos9R44NYowsTjJGtu1hBJGYF//LNMgl?= =?utf-8?q?v0xvzLC0pfONRgbkn5Q4u6WUU2TH3ATtc1L9J3YOdCOxx7PkhKUDNCI6JcpKnTr3w?= =?utf-8?q?d1IWlu53SAUECW3tYkOTirbp9IrcjMOHsSAoga0jtQOnLOqSxS3hWpO8N6p/Jrtsy?= =?utf-8?q?tpdyyyS2humgQG+htlzeSL6ns99dipt92HSOQoJnorn9Iw1Dr9Vz7jHorJ1S8td6z?= =?utf-8?q?hCdTfs9X9EzdWahgOSu+94ZkVLLPQT0h8bKurvY08tSfPHgzuUQerNEWOQH0n/nX1?= =?utf-8?q?BKKSQVymw2MFmHIIExWcqL2xI0pJzoQYuoSRS4MstDYt4+A+N+yU14Y=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)(366016)(376014)(52116014)(7416014)(1800799024)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?RFf6F8QW+FdJFTRV2zE/YNvogvIW?= =?utf-8?q?ev+cjn1GzhmFJbw07awTTZjqwhq2jVGOq6bhPUcS8wZhnpmTi083SCiUe7XhN8MzF?= =?utf-8?q?c4yNkya7jkZjHxOMoobbOLglwtFv9sQlPyxQcEBbkqxhzIxtFHQyLbPdW1LBjBMu9?= =?utf-8?q?G1b3ota8tzXIsGXv0d3D92LpVJ2IGd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KiIVKaGdf61rOh?= =?utf-8?q?J81V5zMJu9Sau23D00ECRMfDgVqJJeNRf/qdCzetqDoTrUbPTMC5sp05LRM3rvnYh?= =?utf-8?q?ZJR2hrNLALlFQUImbIDy3LebV+a7xEnynDzXbb5UeMydiOH72xgI+Ir+hx+so4h41?= =?utf-8?q?vdZS9HukKW5vvCFcrGblIJrve/KBhEnMZbsu0q7HaG8t+u6fi9NByZF46wcWhEeh4?= =?utf-8?q?8IOzb+wEcZsPZeKHZlZraxP1WPWersGdo+FeTx/gQ7KtpN76+akUjY6jKmjbxqSVL?= =?utf-8?q?NjDqti/y+XJOpexOHJssUIUQ5RCIJTjzp2p7Io3JPMCJwLM5UHAUNq7GM8s7HVNiI?= =?utf-8?q?t2h1JlKOO5icbig3L+kne0R1mwz7yudkbIW/55BU8VGrKot4pKr4pUaRHN2ECUso4?= =?utf-8?q?cRa7jCwlp4PR1eTLcxhkRa7OJnM8ikjEg5y8cma4I+A1pkE9dIFYG7eQ=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0cc25eb5-0cc9-4b40-ddf5-08dc9f70a3ed X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2024 17:08:51.6319 (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: dNYYugwzIivB9vI8y9flVHQVwkDUm7xiJIgwzntkoGPeoGSZel9r3XbaBrG6mxOUU66VxyifWW56fluvWBB6xQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7867 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 dbcb70186036e..2c60858b74a09 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 (*enable_ref_clk)(struct imx_pcie *pcie, bool enable); + int (*core_reset)(struct imx_pcie *pcie, bool assert); }; struct imx_pcie { @@ -671,35 +672,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)) @@ -709,47 +750,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)) { @@ -1457,6 +1461,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, @@ -1472,6 +1477,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, @@ -1488,6 +1494,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, @@ -1501,6 +1508,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,