From patchwork Mon Jul 8 17:08: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: 13726914 Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012027.outbound.protection.outlook.com [52.101.66.27]) (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 A22BC152164 for ; Mon, 8 Jul 2024 17:09:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.66.27 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720458558; cv=fail; b=dq8Qz4j5L0VC6Z30i9gdVWu3dMcD1K70d5TxcHKfpBPCukdY2Nb3XlZZIX3raewAFMqe1G4oplL4T8vWzcA2z0S+vGfPJbWYvHDYaXirYOXGHD575F2B9FHmG1vTjws2FlmSC4bh4Mdu/JvEmnkSC+wsJmE8LhE4o4u2+cAKVlU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720458558; c=relaxed/simple; bh=3aNGqHlOMNr6i4SFVYb1me/IgqHGDiN1jvYfErB5JwM=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=YTHejI+8gDmdgE1Nq1EBrlbdjqYQXb8gFyr0a0EydFWM3PYx7Mx4rR6BNZ2kkGmMVit71KxPEuU+vSbkAfbKR66zC/nzazsTE50UE3K7Vg7C5qP1UltewDrCDnRUZSavE+ezuMtq+HJnsLOEnQ1Jxah6eLhafd+g0272j8o4BaM= 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=sMRj1QS9; arc=fail smtp.client-ip=52.101.66.27 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="sMRj1QS9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TVH5yf0SW+0NXDKUUZFX3/FRhhVYUmj9qKJlBhuSLPIa5D0yGD8DmJFWdQ94PmdKvVscub7Wkul7+7jE9uO7IidfVErvEBDtwf6CTu/ucZid73F72OxZ++isdLpLQCkrIalXRiHfVK39xFqWmVt9n+GyBGz9uDVbJrXMqUHTx+40K42U/FkTP8RYTrqc/5tLyxocfSenCEYzYQ4YIfJeUzR0sYWtV/FHAyILqy+Z2be9jzFv0WTZ8RWkC/yHndu3Y0jl57xUJb1zt1d08UC/1L/kwvmBPRbtrFbcrgLswMHVsi87d3lA3Dld5+pOfkslpe0QKMgKyn9ZRVKY3KBAgQ== 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=nUsi8PtQ6ZoYIQbcE1/BBFOJeawxB66B13RTY3Vv2Ec=; b=CvqIE4bWtdBgEMftMw3d5Ye32TMXkJXfsvkYdtF7lgfyePNUcK7HSWh1cBTgTmtyuYQZQzXMKMwaNQ2nPfkP/SRxMDYEn/7+ahkPuyAH16NGoHVgUM71ERJQMgmcVcf1UIqmxLdPVRvLUn9pFpIlArAF57AoHG4BCXondYjPrxC0tYVJaTuFR6xc+NDbGQ0jIa9a0hhWa0hI4AxJ0owtcczdBbfSdTlACdHpeFpXf9bxjFO2VHRecM8qUSX/xJnEO78ahsGVNQEeLdFGUMNtH7MeBaLX+zNO68BgtRouX9ltnhoRapeVN58aqTnZqeB8kEQePqTx5umTRfZIoqi+Uw== 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=nUsi8PtQ6ZoYIQbcE1/BBFOJeawxB66B13RTY3Vv2Ec=; b=sMRj1QS9eJNElOKKSCKx6S9Np/Vwo0taUMZ03VTvBO0GOtyyHyOYy0PtoopWlRnnvcjYvxqi0QK9/0l0H/1dSGCLK/Vym2QsM3kEf6os96HyD0j7yM8RRG1cp+5yK/vHgnCXt7HJz4laXLywXCuk3xvvfvPdYyrRcn0D7/VWnJM= 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:09:14 +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:09:13 +0000 From: Frank Li Date: Mon, 08 Jul 2024 13:08:13 -0400 Subject: [PATCH v7 09/10] PCI: imx6: Call common PHY API to set mode, speed, and submode Message-Id: <20240708-pci2_upstream-v7-9-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=2547; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=3aNGqHlOMNr6i4SFVYb1me/IgqHGDiN1jvYfErB5JwM=; b=4zaUhTYSpwb0Zq0TEZaxqr/0QfUBioLO725+K0h/QUyguiRaqR9ovTiYk1zgxHjfReTWBrwy7 oUR8hdGU1stBc08gSNTV/Oqc7XhbqxbvpzXogmuzP9PMZcxzHgnQBHT 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: imx@lists.linux.dev 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: 5edbb483-7aa0-40b6-6d53-08dc9f70b139 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?PmPIBgqu2UrLx/w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VZME2jXN8hKlAPeLMiT5g?= =?utf-8?q?foG7T17JeAk/syDzRs3qtcG67Dsfmt+P8HRURJmI0XqHE0x7A44s+mpRzoF1Da96W?= =?utf-8?q?zVAWarWGlvv4BySx/1Tciv55j8PPi1c73LJmKPFWEI4g4aaMQWavs4q6dTqgTrX4I?= =?utf-8?q?2QXA+IuM1gUm+k077jUWCvqbavFXl2B+qNAfOws2CL0Hn+x8j4uHcW2Cbvj6Zk5Ae?= =?utf-8?q?0+npRtAxb+UHg5vCRJMm5DWZKpizmihcJMoG0xdycNaSygEy9D7LkU/5ohXRsVOTT?= =?utf-8?q?zYsq4rn40Be96kUJn0N+UYWAW/ZjASVjumGXssIV9hdQgmgAotEt+ircCMziuZqfH?= =?utf-8?q?YZ6aRXTLbOK5MBhc40G8Rj2SSs9QLO2qPybjSeJcSzeM1J0VyHDufaUaAx+O8aYDC?= =?utf-8?q?YVbr7rLt3Gl0dPm6SQFyaNyUP+1uJEasRjS0FstpCSm32S7k7e44fhKBuUrEBfaTj?= =?utf-8?q?nF52fdvoKcm/up+opgnJJn5QTxZohIThWT7L+mvsH2WKczFkh7j9nDI=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?2W42QdcOONliXKrQYFPC+KDLe3M2?= =?utf-8?q?q2HsjoMkWq27/0xyBWqrI1fenrxxV+1Z7rL8IaHBxrcwMi2hGkJdueTNtiPOTOe2C?= =?utf-8?q?PwVtq2HOB6IdfdyODdo7ISzdC6MXwO4JSEZNFbSRLrSwSIfeEKJGt3ac8yvJkEkl8?= =?utf-8?q?BuW0k1s3nTb8JQhU+z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vvrFtLpoG4Rj3MiNNI+1HWeImSMj5zauTCxM4fbe9FTQPF4N?= =?utf-8?q?fmgAdgXu2jvTp9Q3z9FZoiRDXfre/yhDyzjr2eYBQx0cddsu7wgd1QjFecWURB4yl?= =?utf-8?q?GluUPsLDyMVH57oKzGX93cIzd/wg1to4cZQFNBqQPILpGOSmfJxkrLncuR/3vz8WO?= =?utf-8?q?opMMGQ3Ti6Zkd4D3ytYA93/ckNwhS511qvB0hKLrVGOyBSdnC8YjaseBhkWe9KAcd?= =?utf-8?q?Zuw9oPEfV5tc4aYfk+fztnhgeipzw+iQ/73b/Sf4t37haYUw13JzGN8iiEJld7jCZ?= =?utf-8?q?HKnEDZPiOJB+XDWVcUENizvgITIssgQkRWPfzahdePh5qeFGkN9bVT6QSc5Jdl4/C?= =?utf-8?q?HWQAOcF0wGUFVZrT0axuEzqG2ui0X99VxDw5sWbupJw3eaXuzdoAyK5g+9s+berFy?= =?utf-8?q?SlWe2Q9SC6Bh6C2t9Nzno4PYQEpnE1K+oMfb+Y1lCKfyNYx+VFTIlnyU=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5edbb483-7aa0-40b6-6d53-08dc9f70b139 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:09:13.9313 (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: s+ZrDtF/qpHHMuSa/UJcMzR8AU9L2n29bPVtwvTgeoEYjomoPJzWwLslT78+PdQ+Ey/aggb7yO1xuTj9smI3Dg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7867 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 Reviewed-by: Manivannan Sadhasivam --- 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 57814a0cfab8c..c72c7a0b0e02d 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -229,6 +230,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; @@ -807,7 +812,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); @@ -820,6 +829,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); @@ -955,6 +965,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");