From patchwork Mon Jul 29 20:18:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13745686 Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03on2049.outbound.protection.outlook.com [40.107.103.49]) (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 677D1190473; Mon, 29 Jul 2024 20:19:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.103.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722284386; cv=fail; b=sXgUCzvS0u7OEG2hzStgGizadjgBhPWIU3POnlNxLpMsOI83wkp7YPyVIJ/XbQFn/m2KvQ6eFp2ej4TVIP1husbe5qAvijhMTcExu5DpGoZZVeln72U0/7hRsv3ZYTmTMMfx7Oi/0dcw0aMWuOOkAwFK0RuXuCeZvsaOuh3VljU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722284386; c=relaxed/simple; bh=xnegrrqq+Q1Ekgre7IoRsuq7FwdKEEV8MnDreE+OHeQ=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=e66IJDnblFO1ytTREK3MY53TEEns0+aazdjV+//c7WsiD7Ad/ieLazhx3nmS8CZXd+9j7dXUzQMPkRkXRTKnfjPM/3g2YIXAKH9gRo3sj2tI9QGzIwrhwuCh3G6KFS37X8bBJpG17yjy5Krj48SD1MN2HLegS9caLrEHwaXCvDQ= 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=ap+1KBwS; arc=fail smtp.client-ip=40.107.103.49 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="ap+1KBwS" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=U8p87ruLpFvkif9bPJmyTeVpdHisL7UoscE9uL6Y8BJ6uEOOQBQe4L8NRGF3+/+h3VMXL0/QtLpbf1OkaoT/a36uqkrU/ahepcUhSKQbj3pTAAS4dnDZWTkr0ovFPvUNMwk5To3I3NVKeut2dFvXJmHYs5yHqIf5ZwNTp6XeOydBKSKCvHJiYE+0TmEV9vCZG1WDnzZa+rmdEs/r2uEZ41rPMirCNzetNe4eh0EIrZkJYLObY6IOetZA9Wgtyb56W8zTx8R8NKmRVdhhG0rVAyH2bv+28j2FXaKm7td9areO4gZwb2Fpccak701T59Jo1p+98pM5YmnxIx2PPdphTA== 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=IBwLRFPfd+0byJrsW+igL3Gd6ozPrhPd3TitZlHjCHM=; b=T4aw5KUrKVJocWNMxB4aOocYy/G+aHSLxwS9fvT++JZ2H5J4JCHyb6ic1RDhDdVPcaScI+pwHd+jxfmN6R4f1C6nYY5pERY6GQIrDUVkgZd82v31Jo/EUgg+vUosuVrKYg4lnNMA3vVDpi33y3IyLVY6S6B/7iLYb9kQ2vaurTrIGr/0Wyzt0X1YnSpfPk3voW+xCgYgTK+vr40oNKXrQdk8iaH4Q/+8rBLMBAO1NhvdRFvbC9r+AdOUMuqOImdAwbC4ayRY15Y84y52s9qEZXNxqcZfUK4dcGnf7XtZo2Q8A+nARXGEgnr8bXz9aHy65fnZMMiCc5k8ZO8r8rMAkw== 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=IBwLRFPfd+0byJrsW+igL3Gd6ozPrhPd3TitZlHjCHM=; b=ap+1KBwSyeEpPsOpbQNhTy+2+y+1nI4pVrvwOSD2NX4ivw73r9xldX3f73RW/aEhBYEw9YIAP4yalyvA7UU4FEJJEQdrxWV4TQb0sbGMsWguVA1pVcYT+mgUR/lwUpg1MFFuE5J2c8sJ6sTQzyIHWCowxF3AwcKsQuFUqGYkXp74HvPj6BeOrHSci3uiMyf2z7p9m+nDuOorr7cdIjtHIUE21kL/obEd2nzusgFu4V6BGl7UkvW8hxmXEGThf85i4WZOcmnbbNTcNq8552/JVb/p5JVGoqOBmhyoX4C9ZD+F7HqA1cW5qooxtK/GSm4rJVbP+9/GoICA0BWcBNEUTw== 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:40 +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:40 +0000 From: Frank Li Date: Mon, 29 Jul 2024 16:18:17 -0400 Subject: [PATCH v8 10/11] PCI: imx6: Call common PHY API to set mode, speed, and submode Message-Id: <20240729-pci2_upstream-v8-10-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=2619; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=xnegrrqq+Q1Ekgre7IoRsuq7FwdKEEV8MnDreE+OHeQ=; b=3FmqDsHSTKKkzp+9sX7JBJOjNmCre53DefCsAe67ExslztvYHsn8f4rmrntF3dj1hUY4im/Qz GITWKhfUMSGCU0nCedF5e4B4e/G+HHiAiwjoLqsBpkEQmB8MD6SFm4W 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: bpf@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: ec0118d5-3f30-49fc-d490-08dcb00bc6ad 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?6Y8Vko0eY3aPhIMDdn4EVe0fXREWk5S?= =?utf-8?q?BHhc43GZZaeuFLt+pvXSumKIGffD0AVKjDimnnwa58MZ5BGa+2/F6oKNn2qTr7RoA?= =?utf-8?q?ezu5YSqHR+aHP3/78VzSSUCpbvQfsuuVKQgxtOnGuNkmec+dem/IXj4uqZE2VupuY?= =?utf-8?q?X0TFSG/c6Sfo50Xs7NeHKs4nvpsfCVXiR7afNnSCmXeXgY5OpzM9gcWeidgNVq9LJ?= =?utf-8?q?A+bY/wBqPt4o0bwi/JnQ2pUuCpBcr0l6cd4Y8Vokr/fCdNzNPSfSTThI5zCS9SB3U?= =?utf-8?q?h1hbv9FvExilJPI3aG7qrvgnl/7Zvz6juuD7412xW+rAlNTebBNVpifYdZ3GMSW8x?= =?utf-8?q?3vb7PTZVn7BfhJtQcHMk3qCQDatXzUkohNOSRM32/ci1osaGy9I8VUByVd6FlItPY?= =?utf-8?q?spuxeknuGE5S5ztIG2+KQ3BYYhrWcNTBZ3qxTV1MQb5304PWfp+UPWVAldTOrgk4A?= =?utf-8?q?18za7MqsBfVvFrJlFl1gBbtKiBlISVBFX+ktZwXh+fIGrXl15OLq4Z3NvB7CCd/D6?= =?utf-8?q?pyvcSJNOxp8+XXdjrKyMjwGP5m/F+ekjQEECddDFTGjElZngI/UBk/SPaIhgBrnZg?= =?utf-8?q?8D9EkoYddsBd0kTK17ZT1w5IAX9fjZg6zFC65LFI7o6DHOANIvaHEMtgE6loTgk0f?= =?utf-8?q?14D2gElUIurF1+eZoWqTDUKdoyRFgSGJT5bisf5Vo6MxjhypYyioYqN95FtYjhNbB?= =?utf-8?q?VABsksnInPc54JSFP2DajDO2sV/wbWWoqw3OAyJrXaxxqenWnaujEHQ1/1dLzicA7?= =?utf-8?q?FuS3NHROwsp3W4LetIK+MzwrS+H8vVx0iFRDDkfjEJrDTqG0x8KiPgkV2hYaPVsym?= =?utf-8?q?FbjZN3HLksKr7RXDQrGYHXqJMCO51RAyfaNnvz42mINxl5F5ZZyMkpdjqr9P8eBP3?= =?utf-8?q?hel6r1BUfdMm71MMsd+G3DDNiRtl8ztUiO8CNfpcJ2VlExUst2La2cDqvSr6LJGNN?= =?utf-8?q?WctiKFEhXjrZvJN+INpoTqrY0iPffFQzMFjPZlVlQphcwX0c9s1fo5xCMAThCVHmc?= =?utf-8?q?uHnwiN8enkUOeIUpHx/LQ8HLJN/G4AzQSHe3ybPA4RmwJxfpY5hUL2K/n/zmuLjUG?= =?utf-8?q?6jz4nHlfCuL2yYtpazBiYAu6syOZCefho5cdrvwm7DIHLg5vwXUM3wqlCpKxnb1++?= =?utf-8?q?N1+BuY8fxu8UdNEV115OXRRPK/gHUfFyLJedUUrV4CCdmR5v2Rxaib+YMcYA7nh/E?= =?utf-8?q?9Ej/wS6dqH3WttwnZhNo7FQO+IE535BmmDAS1W36VxDeYXxn4yoxShq8si+UTtL0V?= =?utf-8?q?jdzLTA5CUgxX5ao04Ia7sPTpkP0KSLaeEAVul4AGnzU/IXNcHbF4xhd7lrpdiVlnG?= =?utf-8?q?HtAY1vfsgD12kfVX2wmkTkMKtJtLuPlwNiA1/l1P5+ujkLVVBhLt/W0=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?3rPjfHFh/EpuddG2xRL1XU/Lc1hG?= =?utf-8?q?YKMrpPZ2bal4c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+UAuz1FsqVyIykW/y+x9CisBlZjIVD135btwCWCU?= =?utf-8?q?6fFXaAoUEP75qzoFvqnPQGfYXM/Uop1shmvS9hrrfdqyCrDFK0Rwlz0/GtiuanZI0?= =?utf-8?q?DIOkI5B0unNSK8l1oluoaeuN+j7RiDsfBnQrsTNBQf1MRR3+0PfLeKGfoEltejbdS?= =?utf-8?q?M3wJGWKiRk9VUJjQOgufLDprGTUUYbawMJKFPp/0aov1ZAbeqfW1Yscy1Pgav/9YE?= =?utf-8?q?3RobtYk/X/PjPztLI4cZVkAmQbdjGm4AFJ+Jqe7+6/l38C7qmwzbW5Fqg/0flLjYt?= =?utf-8?q?ELRcPHK51AKUlz1F1oGAc5xk6Yhv69rz89gr3YhKjO7uX8DvtuSzKpIZ6GDmGoADh?= =?utf-8?q?hFHCpNLsVrf5wmU/97u5fqelWwhrfOD+LkoAgKKUiH0G+YHosm93TidpdKM62X2XQ?= =?utf-8?q?ZyAaTnMvwzaDsUP3bczf9dpbGekFvpvssJXFAZpYIZIwvA1R7df3471VEnlJRy+C1?= =?utf-8?q?9xSOjZ7hcAKTMw9FgxSinX4zH7AWXpdJJZBUj2z7btDBZ7z2NZbb3DT19yQ0Ebu9S?= =?utf-8?q?IkWREBqokI13v34DGpYQtH09REQ8GywnlVBamZiLlQbCD9vjJBDrB5zLxwPPYrD0R?= =?utf-8?q?Lfg+vJU3Obn3?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ec0118d5-3f30-49fc-d490-08dcb00bc6ad 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:40.5169 (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: Pw83kBQPGbL1dZfbBLglZMVmw7+67gVVExWGmdwkOLZRAk2p6lIHO7qOdhrkneLVbYeaVgmYhCpmh1m6QwBIzg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7382 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. Reviewed-by: Manivannan Sadhasivam Signed-off-by: Frank Li --- drivers/pci/controller/dwc/pci-imx6.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index ccb7cdae32756..91aab0288fdcb 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -227,6 +228,10 @@ static void imx_pcie_configure_type(struct imx_pcie *imx_pcie) id = imx_pcie->controller_id; + /* If mode_mask is 0, then generic PHY driver is used to set the 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; @@ -802,7 +807,11 @@ 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; + u8 offset = dw_pcie_find_capability(imx_pcie->pci, PCI_CAP_ID_EXP); + u32 tmp; + tmp = dw_pcie_readl_dbi(imx_pcie->pci, offset + PCI_EXP_LNKCAP); + phy_set_speed(imx_pcie->phy, FIELD_GET(PCI_EXP_LNKCAP_SLS, tmp)); if (drvdata->ltssm_mask) regmap_update_bits(imx_pcie->iomuxc_gpr, drvdata->ltssm_off, drvdata->ltssm_mask, drvdata->ltssm_mask); @@ -815,6 +824,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); @@ -950,6 +960,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_exit; + } + ret = phy_power_on(imx_pcie->phy); if (ret) { dev_err(dev, "waiting for PHY ready timeout!\n");