From nobody Mon Apr 29 03:51:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+60904+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+60904+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=oss.nxp.com Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1591643475064676.1340608855355; Mon, 8 Jun 2020 12:11:15 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id zIM6YY1788612xAiMceANCBJ; Mon, 08 Jun 2020 12:11:14 -0700 X-Received: from EUR04-HE1-obe.outbound.protection.outlook.com (EUR04-HE1-obe.outbound.protection.outlook.com []) by mx.groups.io with SMTP id smtpd.web12.1244.1591640562976755607 for ; Mon, 08 Jun 2020 11:22:44 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c/rFTADCWu79W294MB2AOecUUUCZZnY3Ok75XXDirLgMzGe4PtarCDPyHmQq0m9eM/mE6iHIdUXWn/gqBw5PoA6hssIEzeomztwqpj5BIon6zXVYPbB/adojysxTVDikksBlHcKJyb+e6btqtyQDB3exZQKmLLoioIc8y7HXtcPIbEvtoXeGUlCuI69PjE8pmBXjcsE2j1O4fsREZzcasCqTDYrv0AEECnOnHjlnEwVEF7SoPEVqHLygGTMBa83+3IYkygmtaDKsKLghk47wRHHg31rRozgxbfOEYCflgpAZwdpayWeuXYSArys0olE7rMwmmuEbGD8fgAHHWXPPXg== 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-SenderADCheck; bh=BqmmNKd/stB5XIDcv3zNbRIoBgw3b6T9XdeGuNphMPQ=; b=m22EdzVc+XvT9ZnBxg+ejDPDCigybbIGOZb5bsmi280395a/MjmdIOauGabNfkAIrcqWE9+TjT4Lsezkd/6rYXGQqGy3v+Q4YWFK4h3StMeab3q8wOcpbjz3VwYgQLkxSHtw/TcxhNVNHds8mvZQaav/ml1UZMcFLM+PkkqkgUr1q0rf5/M0JJxWi/lGHpCnw/ygzdAU5/4DNE7rxCx+SjYbaXWEcJvebJhwJV1yY9jD6uMd3emUMu8dBmi1At29u8axStq/Ezsov0cx0w6FGXMgJd5wCSbe0J7mA1LzCvEM8RG8/b/NQ1A4CqzkrlZA6mWUYL/1O4aoed6HG/VAEQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none X-Received: from VE1PR04MB6702.eurprd04.prod.outlook.com (2603:10a6:803:123::13) by VE1PR04MB6525.eurprd04.prod.outlook.com (2603:10a6:803:120::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.20; Mon, 8 Jun 2020 18:22:43 +0000 X-Received: from VE1PR04MB6702.eurprd04.prod.outlook.com ([fe80::81c4:97a6:7592:f225]) by VE1PR04MB6702.eurprd04.prod.outlook.com ([fe80::81c4:97a6:7592:f225%7]) with mapi id 15.20.3066.023; Mon, 8 Jun 2020 18:22:43 +0000 From: Wasim Khan To: devel@edk2.groups.io, meenakshi.aggarwal@nxp.com, V.Sethi@nxp.com, ard.biesheuvel@arm.com, leif@nuviainc.com CC: Wasim Khan Subject: [edk2-devel] [PATCH edk2-platforms v4 1/3] Silicon/NXP/Library: Implement SerDesHelperLib Date: Mon, 8 Jun 2020 23:52:16 +0530 Message-ID: <1591640538-24751-2-git-send-email-wasim.khan@oss.nxp.com> In-Reply-To: <1591640538-24751-1-git-send-email-wasim.khan@oss.nxp.com> References: <1591640538-24751-1-git-send-email-wasim.khan@oss.nxp.com> X-ClientProxiedBy: PN1PR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:d::27) To VE1PR04MB6702.eurprd04.prod.outlook.com (2603:10a6:803:123::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Received: from wasimk-VirtualBox.nxp.com (157.37.163.9) by PN1PR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:d::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.3066.18 via Frontend Transport; Mon, 8 Jun 2020 18:22:40 +0000 X-Originating-IP: [157.37.163.9] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: acbaa998-fab0-4600-0b8c-08d80bd8ef29 X-MS-TrafficTypeDiagnostic: VE1PR04MB6525: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: DBXO63EXEfN3qqSSwpxvJbAqk59R2xRH4IjuLMTbQ66SympHbX9wU1PlNMfsXz9gZUgA3S2LNrMXGUXBDQclnX3O/zwdQJJaibmfyZA6y8LB03+tUNaElyqMt9NtrKksCF9Pkp4CPqk2Kcsezv/6+7A78QS4M3UMMJV36c4ciYWEH02THB0VhI+KoxjzsqtA+rjvb/rOYzkDyehybUB0mEGLBGFa3JMlANwSKKt3sE8zpMPk5YFLp8CuBc5tbtB6hfip+zybMUWRkiKcYsiP9R3GEgRrabrCeCBwg8RR5FHtc+Dp7Gz4nXcVaoBJPIKnW8WqKg0iZoUAoChWBggxUA== X-MS-Exchange-AntiSpam-MessageData: 6ND9ygvv/oV+26sUFdXh70e8S2pKP5OzKKsuH8siVm7TywpBLlASl3YSVGg5kSerUjCxdEU1J+W69pYE30hM9HSQG/Phtqi9m5ErYxTcUn24XOOHOR7JkCvSn+/m8LY5sv/+FB7YIAoiTHWH6+CepOgSfdNoe5JLNMcLWxvrUhOLWGTkTzR6Taar+65tY1TY9vY07Pmf0ybjEPUfdZwMBWxDHPuFluNcd7RdIy6jWSmO27EuYGM4d6W9hH8s/PPFkK/JktD5ZpyghygKEA3dFXGrZW3PBxPBzTtreEjMui9je00DY/8Kh/VQJ/pR5Hg/m+f/lb/vueJigvbGSWUORYE2r66pZTjQNYUp8yiWuKDUC72jTsSD7aYFyLiBTxG0PPGyNo0YdDxTZoVO3TRIVPj1YoGZABPUa54/AXk5h/CJHDxEohH2+EZtnSS6Lxk00A1bcaFkyHx+x/vMIR3Rg3LINvTdlJdg9CTuM/+8u7c= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: acbaa998-fab0-4600-0b8c-08d80bd8ef29 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jun 2020 18:22:43.1897 (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: 5CNaTmprrwevNeCrMGguOVaLvNwtUyCDEy7GOT91ZzkOGrNd8Gn+hRP95DqMBryKN6XLBCqcpU+yujopkiZtGA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6525 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,wasim.khan@oss.nxp.com X-Gm-Message-State: VPPqvY2dhQbxXgJl5UBthOLdx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1591643474; bh=xKv9LGaOp+m2q2HY3YjRf4KLlMGbWYtvFTNIQGqOsqw=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=wCeP3XWmoldu5CAdL7WOcmv/Via/0uFuHgcrLJPdbWioxaIWXKUOrPvAZevCi9akb8V PBVFVYUbVzneJDlwYeUc0pv0b21LqZkfKkrWa5gCAIZ5rGyz06cVekjgcxrxr7mUW7CUP IZ1Aa65bM6Dl/cRSTZugukExDl/dA+5nFNo= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From: Wasim Khan Implement SerDesHelperLib to provide helper functions which can be used for SoC specific SerDes configuration. Signed-off-by: Wasim Khan --- Notes: Changes in V4: - No Change =20 Changes in V3: - Change variable name LanePrtc to LaneProtocol =20 Changes in V2: - Addressed review comments for structure, variable and function names - Using BIT0 instead of 0x1u Silicon/NXP/NxpQoriqLs.dec | 1 + Silicon/NXP/Library/SerDesHelperLib/SerDesHelperLib.inf | 28 ++++ Silicon/NXP/Include/Library/SerDesHelperLib.h | 64 ++++++++ Silicon/NXP/Library/SerDesHelperLib/SerDesHelperLib.c | 164 ++++++++++++= ++++++++ 4 files changed, 257 insertions(+) diff --git a/Silicon/NXP/NxpQoriqLs.dec b/Silicon/NXP/NxpQoriqLs.dec index d4d3057af509..d09a1ae194be 100644 --- a/Silicon/NXP/NxpQoriqLs.dec +++ b/Silicon/NXP/NxpQoriqLs.dec @@ -35,6 +35,7 @@ [PcdsFixedAtBuild.common] gNxpQoriqLsTokenSpaceGuid.PcdNumPciController|0|UINT32|0x00000501 gNxpQoriqLsTokenSpaceGuid.PcdPcieLutBase|0x0|UINT32|0x00000502 gNxpQoriqLsTokenSpaceGuid.PcdPcieLutDbg|0x0|UINT32|0x00000503 + gNxpQoriqLsTokenSpaceGuid.PcdSerDesLanes|0x0|UINT8|0x00000504 =20 [PcdsDynamic.common] gNxpQoriqLsTokenSpaceGuid.PcdPciCfgShiftEnable|FALSE|BOOLEAN|0x00000600 diff --git a/Silicon/NXP/Library/SerDesHelperLib/SerDesHelperLib.inf b/Sili= con/NXP/Library/SerDesHelperLib/SerDesHelperLib.inf new file mode 100644 index 000000000000..7a781620e449 --- /dev/null +++ b/Silicon/NXP/Library/SerDesHelperLib/SerDesHelperLib.inf @@ -0,0 +1,28 @@ +## @file +# +# Copyright 2020 NXP +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION =3D 0x0001001A + BASE_NAME =3D SerDesHelperLib + FILE_GUID =3D 2930e932-a700-41e8-80f9-f1a2dedd2c4f + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D SerDesHelperLib + +[Packages] + MdePkg/MdePkg.dec + Silicon/NXP/NxpQoriqLs.dec + +[LibraryClasses] + DebugLib + PcdLib + +[Sources.common] + SerDesHelperLib.c + +[FixedPcd] + gNxpQoriqLsTokenSpaceGuid.PcdSerDesLanes diff --git a/Silicon/NXP/Include/Library/SerDesHelperLib.h b/Silicon/NXP/In= clude/Library/SerDesHelperLib.h new file mode 100644 index 000000000000..377f020e0b3a --- /dev/null +++ b/Silicon/NXP/Include/Library/SerDesHelperLib.h @@ -0,0 +1,64 @@ +/** SerDesHelperLib.h + The Header file for SerDesHelperLib + + Copyright 2020 NXP + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef SERDES_HELPER_LIB_H +#define SERDES_HELPER_LIB_H + +#include +#include + +typedef struct { + UINT16 Protocol; + UINT8 SerDesLane[FixedPcdGet8 (PcdSerDesLanes)]; +} SERDES_CONFIG; + +typedef enum { + SERDES_1 =3D 0, + SERDES_2, + SERDES_3, + SERDES_MAX +} SERDES_NUMBER; + +UINT32 +GetSerDesProtocol ( + IN INTN SerDes, + IN INTN SerDesProtocol, + IN INTN Lane, + IN UINT32 SerDesMaxProtocol, + IN SERDES_CONFIG *Config + ); + +EFI_STATUS +IsSerDesProtocolValid ( + IN INTN SerDes, + IN UINT32 SerDesProtocol, + IN UINT8 SerDesNumLanes, + IN SERDES_CONFIG *Config + ); + +EFI_STATUS +GetSerDesMap ( + IN UINT32 SerDes, + IN UINT32 SerDesProtocol, + IN UINT8 SerDesNumLanes, + IN UINT32 SerDesMaxProtocol, + IN SERDES_CONFIG *Config, + OUT UINT64 *SerDesProtocolMap + ); + +VOID +SerDesInstanceProbeLanes ( + IN UINT32 SerDes, + IN UINT32 SerDesProtocol, + IN UINT8 SerDesNumLanes, + IN UINT32 SerDesMaxProtocol, + IN SERDES_CONFIG *Config, + IN SERDES_PROBE_LANES_CALLBACK SerDesLaneProbeCallback, + IN VOID *Arg + ); +#endif diff --git a/Silicon/NXP/Library/SerDesHelperLib/SerDesHelperLib.c b/Silico= n/NXP/Library/SerDesHelperLib/SerDesHelperLib.c new file mode 100644 index 000000000000..ddefcc2fac98 --- /dev/null +++ b/Silicon/NXP/Library/SerDesHelperLib/SerDesHelperLib.c @@ -0,0 +1,164 @@ +/** SerDes.c + Provides SoC specific SerDes interface + + Copyright 2020 NXP + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include + +/** + Function to get SerDes Lane protocol corresponding to + SerDes protocol. + + @param SerDes SerDes number. + @param SerDesProtocol SerDes protocol number. + @param Lane SerDes Lane number. + @param SerDesMaxProtocol Max SerDes protocol number. + @param Config SerDes Configuration. + + @return SerDes Lane protocol. + +**/ +UINT32 +GetSerDesProtocol ( + IN INTN SerDes, + IN INTN SerDesProtocol, + IN INTN Lane, + IN UINT32 SerDesMaxProtocol, + IN SERDES_CONFIG *Config + ) +{ + while (Config->Protocol) { + if (Config->Protocol =3D=3D SerDesProtocol) { + return Config->SerDesLane[Lane]; + } + Config++; + } + + return SerDesMaxProtocol; +} + +/** + Function to validate input SerDes protocol. + + @param SerDes SerDes number. + @param SerDesProtocol SerDes protocol number. + @param SerDesNumLanes Number of SerDes Lanes. + @param Config SerDes Configuration. + + @return EFI_NOT_FOUND SerDes Protocol not a valid protocol. + @return EFI_SUCCESS SerDes Protocol is a valid protocol. + +**/ +EFI_STATUS +IsSerDesProtocolValid ( + IN INTN SerDes, + IN UINT32 SerDesProtocol, + IN UINT8 SerDesNumLanes, + IN SERDES_CONFIG *Config + ) +{ + UINT8 Count; + + while (Config->Protocol) { + if (Config->Protocol =3D=3D SerDesProtocol) { + DEBUG ((DEBUG_INFO, "Protocol: %x Matched with the one in Table\n", = SerDesProtocol)); + break; + } + Config++; + } + + if (!Config->Protocol) { + return EFI_NOT_FOUND; + } + + for (Count =3D 0; Count < SerDesNumLanes; Count++) { + if (Config->SerDesLane[Count] !=3D 0) { + return EFI_SUCCESS; + } + } + + return EFI_NOT_FOUND; +} + +/** + Get Lane protocol on provided SerDes Lane and execute callback function. + + @param SerDes SerDes number. + @param SerDesProtocol SerDes protocol number. + @param SerDesNumLanes Number of SerDes Lanes. + @param SerDesMaxProtocol Max SerDes protocol number. + @param Config SerDes Configuration. + @param SerDesLaneProbeCallback Pointer Callback function to be called f= or Lane protocol + @param Arg Pointer to Arguments to be passed to cal= lback function. +**/ +VOID +SerDesInstanceProbeLanes ( + IN UINT32 SerDes, + IN UINT32 SerDesProtocol, + IN UINT8 SerDesNumLanes, + IN UINT32 SerDesMaxProtocol, + IN SERDES_CONFIG *Config, + IN SERDES_PROBE_LANES_CALLBACK SerDesLaneProbeCallback, + IN VOID *Arg + ) +{ + INT8 Lane; + UINT32 LaneProtocol; + + // Invoke callback for all lanes in the SerDes instance: + for (Lane =3D 0; Lane < SerDesNumLanes; Lane++) { + LaneProtocol =3D GetSerDesProtocol (SerDes, SerDesProtocol, Lane, SerD= esMaxProtocol, Config); + ASSERT (LaneProtocol < SerDesMaxProtocol); + if (LaneProtocol !=3D 0x0) { + SerDesLaneProbeCallback (LaneProtocol, Arg); + } + } +} + +/** + Function to fill SerDes map information. + + @param SerDes SerDes number. + @param SerDesProtocol SerDes protocol number. + @param SerDesNumLanes Number of SerDes Lanes. + @param SerDesMaxProtocol Max SerDes protocol number. + @param Config SerDes Configuration. + @param SerDesProtocolMap Output SerDes protocol map of enabled device= s. + +**/ +EFI_STATUS +GetSerDesMap ( + IN UINT32 SerDes, + IN UINT32 SerDesProtocol, + IN UINT8 SerDesNumLanes, + IN UINT32 SerDesMaxProtocol, + IN SERDES_CONFIG *Config, + OUT UINT64 *SerDesProtocolMap + ) +{ + INTN Lane; + EFI_STATUS Status; + UINT32 LaneProtocol; + + Status =3D IsSerDesProtocolValid (SerDes, SerDesProtocol, SerDesNumLanes= , Config); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: SERDES%d[PRTCL] =3D 0x%x is not valid, Statu= s =3D %r \n", + __FUNCTION__, SerDes + 1, SerDesProtocol, Status)); + return Status; + } + + for (Lane =3D 0; Lane < SerDesNumLanes; Lane++) { + LaneProtocol =3D GetSerDesProtocol (SerDes, SerDesProtocol, Lane, SerD= esMaxProtocol, Config); + if (LaneProtocol >=3D SerDesMaxProtocol) { + DEBUG ((DEBUG_ERROR, "Unknown SerDes lane protocol %d\n", LaneProtoc= ol)); + return EFI_NO_MAPPING; + } + *SerDesProtocolMap |=3D (BIT0 << (LaneProtocol)); + } + + return EFI_SUCCESS; +} --=20 2.7.4 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#60904): https://edk2.groups.io/g/devel/message/60904 Mute This Topic: https://groups.io/mt/74759290/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Mon Apr 29 03:51:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+60905+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+60905+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=oss.nxp.com Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1591643474730287.6660962303497; Mon, 8 Jun 2020 12:11:14 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id GiDvYY1788612x0fmpmC9uuk; Mon, 08 Jun 2020 12:11:14 -0700 X-Received: from EUR05-VI1-obe.outbound.protection.outlook.com (EUR05-VI1-obe.outbound.protection.outlook.com [40.107.21.72]) by mx.groups.io with SMTP id smtpd.web12.1245.1591640568206726431 for ; Mon, 08 Jun 2020 11:22:48 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oKoYVuUI35i0p1iDhzux/Gq1m1LBIzdwA7/8t/je/A0fYwhu29GCa2G8iy69EB3lgaPR8JB7spi4F+QERwMdRliG6YKZZ7F08UrOKZCR2fhXx/4vICISXB+BPgWtVbfnFmjqSdLhyGwldBgSikIMfUlxWB3iEHCTy/8rzdpHth2mBU4Zlpvns1evZ3MBMahXNW0YOJ4AgQJPmf2sjGaN+AETbwHt4CNZk4gQ2VwNdPgHA0wxtfan3RjBV9isIRNulMM46rUMCkzE9YQhf6lV5XPeYPU+s2kkW8lAJA3MCW8SVciHF83rYV1yqP3b7+RYYh78qNNEBjDS/hu+wyVBKQ== 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-SenderADCheck; bh=foYf2qsnbtzNXaHSAP1KDtKbeU3tgfNveeXAFnZB2cY=; b=HJUTzKSoM3nbDl4USzCVTYTmE5uKrP2tuJlNAWNGWse3DByzdm05zcc6mlHh30HPjpcz0zqz4CUV6lz6Kd9y0MTXJPYxGBAqLBbEIxjELeVVNrzOzu6aaqmj6VWE54jqXiasO4JuvrKnjvMNvUW6oW/DRE+4b2sJzhnWklaRZ0IEkswG27Is3x4FM12DV2NPS3Z5EWQ3tO1lzdBMVhJc5gvQREuT7g/EFfWD49mPibaH01hJ4JO5wV/p6yP9RGZeNbOh2ZpD1hCSRbR0ksLkkx5OZ80IV5FW4j5aCUc6bk3H3p70vIpVExskGqs0y/fDC/OPb9Oq7SGOLELjEosrKQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none X-Received: from VE1PR04MB6702.eurprd04.prod.outlook.com (2603:10a6:803:123::13) by VE1PR04MB6525.eurprd04.prod.outlook.com (2603:10a6:803:120::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.20; Mon, 8 Jun 2020 18:22:46 +0000 X-Received: from VE1PR04MB6702.eurprd04.prod.outlook.com ([fe80::81c4:97a6:7592:f225]) by VE1PR04MB6702.eurprd04.prod.outlook.com ([fe80::81c4:97a6:7592:f225%7]) with mapi id 15.20.3066.023; Mon, 8 Jun 2020 18:22:46 +0000 From: Wasim Khan To: devel@edk2.groups.io, meenakshi.aggarwal@nxp.com, V.Sethi@nxp.com, ard.biesheuvel@arm.com, leif@nuviainc.com CC: Wasim Khan Subject: [edk2-devel] [PATCH edk2-platforms v4 2/3] Silicon/NXP: LS1043A: Add SerDes Support Date: Mon, 8 Jun 2020 23:52:17 +0530 Message-ID: <1591640538-24751-3-git-send-email-wasim.khan@oss.nxp.com> In-Reply-To: <1591640538-24751-1-git-send-email-wasim.khan@oss.nxp.com> References: <1591640538-24751-1-git-send-email-wasim.khan@oss.nxp.com> X-ClientProxiedBy: PN1PR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:d::27) To VE1PR04MB6702.eurprd04.prod.outlook.com (2603:10a6:803:123::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Received: from wasimk-VirtualBox.nxp.com (157.37.163.9) by PN1PR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:d::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.3066.18 via Frontend Transport; Mon, 8 Jun 2020 18:22:43 +0000 X-Originating-IP: [157.37.163.9] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 2aa31a0e-b5d3-4434-526b-08d80bd8f0df X-MS-TrafficTypeDiagnostic: VE1PR04MB6525: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: +dziPj04AlC1XWjWSNfMd0MpkpkWLj+0Ij6vYVN3+WSxAvUfL78j4wPgHRGik/9F8KEQi4RVJiA9TdjRURIiCOF7djDdmKNWi3cR/nrGX3VkifqI3+CmB3JMQwc13FCoHsfaOR0tdAigNV7XPVZ+4WBGGQ8r9Ce1isRw/8BaJv90jv3LvouOaiakWkH2/rDfCPCT2fMiA6PCg25psAUxri2CsusE2XUVzmE8yqp93VTeGeDCq1VZQXG1gv62CXg9UoESaFLuJrydUGmXGre52OhypqXjcnDSM7dDkmCo0c7BZTpeDJ0xED4fF/B8CfL4AHvz7OqarbKMBQQUWShv6A== X-MS-Exchange-AntiSpam-MessageData: 6wmdzcz5A9fcvWpWHAnRHGxPQujv6we6exM/B2vkv8kvPGL78vNwouwOuGJi4xNkv9Fbgmja2DEJ/dwyfG1Vo2uTvaQWWPnVD/JPxwkTPGc4kYIxIfzOq4unR7BKKQNOWygqmI4fPp4xPK0KqpVfuovCV3wTEoowyyiUJEFrPeVGwg8jdmvZuKsklJ68Q51yOoPjwQou9QhB+M3zcXLzrgraaLq+ItydW9luSBzUf4zIjFlLzROaUp8hDi9chHIfTk6aLVtnVnCZLEzTYDWX453BQciLBVNleq/DFjiFr66z6y9NSxiKPw5Z1MbhQaz59UkpEG01SWWGHeZQdEFFWkxez5eK07WQesjSJ3Csf2CRaS0rsy6mkiP/ElhnYnCYgPS/P0EpDTEGgD168njZfUylubDOREfOduaPkfrVRlw8cjFUG9Y/9WWYvII5U0qnf/8QYwMZow9jHWiRGb+pDVMbiSW61RmDj8CA1OVgGjM= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2aa31a0e-b5d3-4434-526b-08d80bd8f0df X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jun 2020 18:22:45.9161 (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: 8+NSdhe8b2qKQZwd4/2NSbQasgjApx25HWW9SgSp1ope74TDK+lpGH/ElK9SxhKL0CrFmyjAERaPUwSQlunnGw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6525 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,wasim.khan@oss.nxp.com X-Gm-Message-State: bekkD3TBvllhg1vyKymzXGCOx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1591643474; bh=E8/JXXVZ7DdOmS8c9rdhKimkWnR7SJhzqcZM9xr3KF4=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=u4+vSDYN5Fc78wWIKwaqAa5EzqR/CO6Of4x8oa+anfyB/XlZSZWwZRbkMWmj7rv6fHG xOfCZKAetfDU1ZHkiLk9MZ8cYfFOHcfMfIU6tAkjdLgkauYQaEnaaxwopW16qgXF2UBAX hFdzG4xFnOC0CeNLPO+V0xuBjEVR+TaYitg= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From: Wasim Khan Based on SerDes protocol value in reset configuration word (RCW) different IP blocks gets enabled in HW. Add SoC specific SerDes configuration for LS1043A, which can be used by different IPs to know the enabled interfaces and perform the required initialization. Signed-off-by: Wasim Khan --- Notes: Changes in V4: - Include SocSerDes.h =20 Changes in V3: - Indentation changes - Moved enum to header file. =20 Changes in V2: - Addressed review comments for structure, variable and function names - Removed SocSerDes.h and moved data definitions to SerDes.c Silicon/NXP/LS1043A/LS1043A.dsc.inc | 2 + Silicon/NXP/LS1043A/Library/SocLib/SocLib.inf | 6 + Silicon/NXP/Include/Library/SerDes.h | 28 +++++ Silicon/NXP/LS1043A/Include/SocSerDes.h | 33 ++++++ Silicon/NXP/LS1043A/Library/SocLib/SerDes.c | 119 ++++++++++++++++++++ 5 files changed, 188 insertions(+) diff --git a/Silicon/NXP/LS1043A/LS1043A.dsc.inc b/Silicon/NXP/LS1043A/LS10= 43A.dsc.inc index e023bfbc7c04..1ac7c6da7092 100644 --- a/Silicon/NXP/LS1043A/LS1043A.dsc.inc +++ b/Silicon/NXP/LS1043A/LS1043A.dsc.inc @@ -12,6 +12,7 @@ [LibraryClasses.common] SocLib|Silicon/NXP/LS1043A/Library/SocLib/SocLib.inf SerialPortLib|Silicon/NXP/Library/DUartPortLib/DUartPortLib.inf + SerDesHelperLib|Silicon/NXP/Library/SerDesHelperLib/SerDesHelperLib.inf =20 ##########################################################################= ###### # @@ -37,4 +38,5 @@ [PcdsFixedAtBuild.common] gNxpQoriqLsTokenSpaceGuid.PcdNumPciController|3 gNxpQoriqLsTokenSpaceGuid.PcdPcieLutBase|0x10000 gNxpQoriqLsTokenSpaceGuid.PcdPcieLutDbg|0x7FC + gNxpQoriqLsTokenSpaceGuid.PcdSerDesLanes|0x4 ## diff --git a/Silicon/NXP/LS1043A/Library/SocLib/SocLib.inf b/Silicon/NXP/LS= 1043A/Library/SocLib/SocLib.inf index 3d0f988e1c67..728e8f0c8ee1 100644 --- a/Silicon/NXP/LS1043A/Library/SocLib/SocLib.inf +++ b/Silicon/NXP/LS1043A/Library/SocLib/SocLib.inf @@ -22,6 +22,12 @@ [Packages] [LibraryClasses] ChassisLib DebugLib + PcdLib + SerDesHelperLib =20 [Sources.common] + SerDes.c SocLib.c + +[FixedPcd] + gNxpQoriqLsTokenSpaceGuid.PcdSerDesLanes diff --git a/Silicon/NXP/Include/Library/SerDes.h b/Silicon/NXP/Include/Lib= rary/SerDes.h new file mode 100644 index 000000000000..f015b40403c5 --- /dev/null +++ b/Silicon/NXP/Include/Library/SerDes.h @@ -0,0 +1,28 @@ +/** SerDes.h + Header file for SoC specific SerDes routines + + Copyright 2017-2020 NXP + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef SERDES_H +#define SERDES_H + +VOID +GetSerDesProtocolMap ( + OUT UINT64 *SerDesProtocolMap + ); + +typedef VOID +(*SERDES_PROBE_LANES_CALLBACK) ( + IN UINT32 LaneProtocol, + IN VOID *Arg + ); + +VOID +SerDesProbeLanes ( + IN SERDES_PROBE_LANES_CALLBACK SerDesLaneProbeCallback, + IN VOID *Arg + ); +#endif diff --git a/Silicon/NXP/LS1043A/Include/SocSerDes.h b/Silicon/NXP/LS1043A/= Include/SocSerDes.h new file mode 100644 index 000000000000..db56ca98e0be --- /dev/null +++ b/Silicon/NXP/LS1043A/Include/SocSerDes.h @@ -0,0 +1,33 @@ +/** SocSerDes.h + SoC Specific header file for SerDes + + Copyright 2017-2020 NXP + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef SOC_SERDES_H +#define SOC_SERDES_H + +typedef enum { + NONE =3D 0, + PCIE1, + PCIE2, + PCIE3, + SATA, + SGMII_FM1_DTSEC1, + SGMII_FM1_DTSEC2, + SGMII_FM1_DTSEC5, + SGMII_FM1_DTSEC6, + SGMII_FM1_DTSEC9, + SGMII_FM1_DTSEC10, + QSGMII_FM1_A, + XFI_FM1_MAC9, + XFI_FM1_MAC10, + SGMII_2500_FM1_DTSEC2, + SGMII_2500_FM1_DTSEC5, + SGMII_2500_FM1_DTSEC9, + SGMII_2500_FM1_DTSEC10, + SERDES_PRTCL_COUNT +} SERDES_PROTOCOL; +#endif diff --git a/Silicon/NXP/LS1043A/Library/SocLib/SerDes.c b/Silicon/NXP/LS10= 43A/Library/SocLib/SerDes.c new file mode 100644 index 000000000000..b34da76eeac9 --- /dev/null +++ b/Silicon/NXP/LS1043A/Library/SocLib/SerDes.c @@ -0,0 +1,119 @@ +/** SerDes.c + Provides SoC specific SerDes interface + + Copyright 2017-2020 NXP + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include +#include +#include +#include +#include + +// SerDes1 Protocol Mask in Reset Configuration Word (RCW) Status Register +#define SERDES1_PROTOCOL_MASK 0xffff0000 + +// SerDes1 Protocol Shift in Reset Configuration Word (RCW) Status Register +#define SERDES1_PROTOCOL_SHIFT 16 + +SERDES_CONFIG gSerDes1ConfigTable[] =3D { + {0x1555, {XFI_FM1_MAC9, PCIE1, PCIE2, PCIE3 } }, + {0x2555, {SGMII_2500_FM1_DTSEC9, PCIE1, PCIE2, PCIE3 } }, + {0x4555, {QSGMII_FM1_A, PCIE1, PCIE2, PCIE3 } }, + {0x4558, {QSGMII_FM1_A, PCIE1, PCIE2, SATA } }, + {0x1355, {XFI_FM1_MAC9, SGMII_FM1_DTSEC2, PCIE2, PCIE3 } }, + {0x2355, {SGMII_2500_FM1_DTSEC9, SGMII_FM1_DTSEC2, PCIE2, PCIE3 } }, + {0x3335, {SGMII_FM1_DTSEC9, SGMII_FM1_DTSEC2, SGMII_FM1_DTSEC5, PCIE3 } = }, + {0x3355, {SGMII_FM1_DTSEC9, SGMII_FM1_DTSEC2, PCIE2, PCIE3 } }, + {0x3358, {SGMII_FM1_DTSEC9, SGMII_FM1_DTSEC2, PCIE2, SATA } }, + {0x3555, {SGMII_FM1_DTSEC9, PCIE1, PCIE2, PCIE3 } }, + {0x3558, {SGMII_FM1_DTSEC9, PCIE1, PCIE2, SATA } }, + {0x7000, {PCIE1, PCIE1, PCIE1, PCIE1 } }, + {0x9998, {PCIE1, PCIE2, PCIE3, SATA } }, + {0x6058, {PCIE1, PCIE1, PCIE2, SATA } }, + {0x1455, {XFI_FM1_MAC9, QSGMII_FM1_A, PCIE2, PCIE3 } }, + {0x2455, {SGMII_2500_FM1_DTSEC9, QSGMII_FM1_A, PCIE2, PCIE3 } }, + {0x2255, {SGMII_2500_FM1_DTSEC9, SGMII_2500_FM1_DTSEC2, PCIE2, PCIE3 } }, + {0x3333, {SGMII_FM1_DTSEC9, SGMII_FM1_DTSEC2, SGMII_FM1_DTSEC5, SGMII_FM= 1_DTSEC6 } }, + {0x1460, {XFI_FM1_MAC9, QSGMII_FM1_A, PCIE3, PCIE3 } }, + {0x2460, {SGMII_2500_FM1_DTSEC9, QSGMII_FM1_A, PCIE3, PCIE3 } }, + {0x3460, {SGMII_FM1_DTSEC9, QSGMII_FM1_A, PCIE3, PCIE3 } }, + {0x3455, {SGMII_FM1_DTSEC9, QSGMII_FM1_A, PCIE2, PCIE3 } }, + {0x9960, {PCIE1, PCIE2, PCIE3, PCIE3 } }, + {0x2233, {SGMII_2500_FM1_DTSEC9, SGMII_FM1_DTSEC2, SGMII_FM1_DTSEC5, SGM= II_FM1_DTSEC6 } }, + {0x2533, {SGMII_2500_FM1_DTSEC9, PCIE1, SGMII_FM1_DTSEC5, SGMII_FM1_DTSE= C6 } }, + {} +}; + +SERDES_CONFIG *gSerDesConfig[] =3D { + gSerDes1ConfigTable +}; + +/** + Probe all SerDes for lane protocol and execute provided callback functio= n. + + @param SerDesLaneProbeCallback Pointer Callback function to be called f= or Lane protocol + @param Arg Pointer to Arguments to be passed to cal= lback function. + +**/ +VOID +SerDesProbeLanes ( + IN SERDES_PROBE_LANES_CALLBACK SerDesLaneProbeCallback, + IN VOID *Arg + ) +{ + UINT32 SerDesProtocol; + LS1043A_DEVICE_CONFIG *DeviceConfig; + + DeviceConfig =3D (LS1043A_DEVICE_CONFIG *)LS1043A_DCFG_ADDRESS; + SerDesProtocol =3D DcfgRead32 ((UINTN)&DeviceConfig->RcwSr[4]) & SERDES1= _PROTOCOL_MASK; + SerDesProtocol >>=3D SERDES1_PROTOCOL_SHIFT; + + SerDesInstanceProbeLanes ( + SERDES_1, + SerDesProtocol, + FixedPcdGet8 (PcdSerDesLanes), + SERDES_PROTOCOL_COUNT, + gSerDesConfig[SERDES_1], + SerDesLaneProbeCallback, + Arg + ); +} + +/** + Function to return SerDes protocol map for all SerDes available on board. + + @param SerDesProtocolMap Pointer to SerDes protocl map. + +**/ +VOID +GetSerDesProtocolMap ( + OUT UINT64 *SerDesProtocolMap + ) +{ + UINT32 SerDesProtocol; + LS1043A_DEVICE_CONFIG *DeviceConfig; + EFI_STATUS Status; + + *SerDesProtocolMap =3D 0; + DeviceConfig =3D (LS1043A_DEVICE_CONFIG *)LS1043A_DCFG_ADDRESS; + SerDesProtocol =3D DcfgRead32 ((UINTN)&DeviceConfig->RcwSr[4]) & SERDES1= _PROTOCOL_MASK; + SerDesProtocol >>=3D SERDES1_PROTOCOL_SHIFT; + + Status =3D GetSerDesMap ( + SERDES_1, + SerDesProtocol, + FixedPcdGet8 (PcdSerDesLanes), + SERDES_PROTOCOL_COUNT, + gSerDesConfig[SERDES_1], + SerDesProtocolMap + ); + + if (Status !=3D EFI_SUCCESS) { + DEBUG ((DEBUG_ERROR, "%a: failed for SerDes1 \n",__FUNCTION__)); + *SerDesProtocolMap =3D 0; + } +} --=20 2.7.4 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#60905): https://edk2.groups.io/g/devel/message/60905 Mute This Topic: https://groups.io/mt/74759291/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Mon Apr 29 03:51:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+60906+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+60906+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=oss.nxp.com Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1591643473496543.1718674769411; Mon, 8 Jun 2020 12:11:13 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id bvQnYY1788612xMyxUnUYPGO; Mon, 08 Jun 2020 12:11:13 -0700 X-Received: from EUR05-VI1-obe.outbound.protection.outlook.com (EUR05-VI1-obe.outbound.protection.outlook.com [40.107.21.47]) by mx.groups.io with SMTP id smtpd.web12.1246.1591640570941326549 for ; Mon, 08 Jun 2020 11:22:51 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DcQZdIjOIMJjaZQ4cik3l6Ck/ZHLYgiQpcP+MD/IfykzVlDlleDfOzZAfbnIQAgH/CjTC8RgT0eHTp25dANYXDs/ijd6bJHh08sulQivzwUr3Gd3BcKRvVbhKpFG4jjWu+WOpn6fMC/voWqAngllz2tCnNeaHLEqzXQCqj2Xl8YDu8hHKEpv4aEBabPLBzcG4OHg1ejGsDO2yWg4ycqP9C2B+ivo65xfodkMaAE/2pBXCNBlaEteU1Mhg70TuXTUfDTskRE64Jtg1E236SIcxdfCP5j787ZCK7xP5x+avo7A654cqT6u3v9iNk2ziD9tgnjF1Q6f5E+U8EJi5lOLwg== 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-SenderADCheck; bh=JcLpvcqYSTP9rt7DrDICckIT76U+WVGDbZrtXQsatAM=; b=D7lKKjn3fdAksAJ8GVfPwprrNArwWxaqM660bi0UCE84SES3uwfxDS6KpJyUe0A4J6FjEtp0zs4fPtrgtYhZIkpE8THYPLB+I8ZFBQaWn8SViASmw+egjtjYTxW5bq4Sr2G009DAX2zhPveab/AORcKv6mvEXWMnlNXg2p6a3zN5YZvrAlE+ZqzCk3y0qK6V8YInDpQuh+gDvMlM8AxPX1XNTyMXyq6nTpv0w7/+nuYu8ssAMziK0FfC36t0j5qVH+Mtbc9bG6f5dhBN+GIt3LtKX20Z1Uy/sA/75Dd+DDxz7f+J8wQiMie1jx8LhGtJqp0Oqyy3WNiua2FuDDs0Ig== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none X-Received: from VE1PR04MB6702.eurprd04.prod.outlook.com (2603:10a6:803:123::13) by VE1PR04MB6525.eurprd04.prod.outlook.com (2603:10a6:803:120::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.20; Mon, 8 Jun 2020 18:22:48 +0000 X-Received: from VE1PR04MB6702.eurprd04.prod.outlook.com ([fe80::81c4:97a6:7592:f225]) by VE1PR04MB6702.eurprd04.prod.outlook.com ([fe80::81c4:97a6:7592:f225%7]) with mapi id 15.20.3066.023; Mon, 8 Jun 2020 18:22:48 +0000 From: Wasim Khan To: devel@edk2.groups.io, meenakshi.aggarwal@nxp.com, V.Sethi@nxp.com, ard.biesheuvel@arm.com, leif@nuviainc.com CC: Wasim Khan Subject: [edk2-devel] [PATCH edk2-platforms v4 3/3] Silicon/NXP: PciHostBridgeLib: Initialize only enabled PCIe controllers Date: Mon, 8 Jun 2020 23:52:18 +0530 Message-ID: <1591640538-24751-4-git-send-email-wasim.khan@oss.nxp.com> In-Reply-To: <1591640538-24751-1-git-send-email-wasim.khan@oss.nxp.com> References: <1591640538-24751-1-git-send-email-wasim.khan@oss.nxp.com> X-ClientProxiedBy: PN1PR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:d::27) To VE1PR04MB6702.eurprd04.prod.outlook.com (2603:10a6:803:123::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Received: from wasimk-VirtualBox.nxp.com (157.37.163.9) by PN1PR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:d::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.3066.18 via Frontend Transport; Mon, 8 Jun 2020 18:22:46 +0000 X-Originating-IP: [157.37.163.9] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 2e6eb2f8-2789-4bf7-3e77-08d80bd8f292 X-MS-TrafficTypeDiagnostic: VE1PR04MB6525: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: PfMCNBO4nFXwyvTU9G3I8eKNHzxkC8A4ZAMkZOl7qNu9n6oajm6sAUYHIe/qpHcbbY81gMq500FRHBV+aT9l35KF/GX3eHIxMRAJu+6oShOcWdcpON9WnP3V92r/zXJW+KlzGsiUgNIgSnkWZ+CFE88LKIuVXMGCjC6T2OsyiqThjLJl3vhFHWrxDSqjaMtiSo+ROXSs2+xu3rVGr2B2or6Ub0iRkD/nbYyofMoSXJxJw3jsQkHsacZ5GMtX1yHlicyIgqygp3gUcUmASRM3c/NezLpCbD2IoZgf/UL95lIhqCa96R8r0R5ERMbf78rmrZmOC1Uj3ZjXiRGemCfkXQ== X-MS-Exchange-AntiSpam-MessageData: 7flEa+NYMSNs+sJBnbnkdajtEVXWjkjWNFOWf7sUOWsCdXSwfDyczF4mipl2A1REhyquQvHp3S0roiyQLIzO1r3auJP8s8l2rW2O7xDhkCeVo2jkhO4D1UrPZI6WtzxVVtElyUjV6xPMUfnEhyK0KpmcUjj8YF/Z2Y4m75+gFTOeXUtpQYvnnLqZ8YVghRoXRp/Ly4FknFhy798dGmdHipxl6NeYwGs07f4qJOB1Kotl0u4pu0GnPpm5Z6zqzkPMSXCCbMtsv+B8lJvMjOOn6/yAAriEB1BLmeDQHKxrb7jPXIrVoNOQDx/E5D716+DNsEjdpVKJiMfY7XvYF+AwqJox4P9azM484907Qs2Zywuf5KWb07flA0wvcm/yK01zsWUv13C3cGKtANzkPLA6ZT6wgKX0P8MdqrCRenuz0hNaMMmSMeU5zhizuURdccrhfDSFz0Kop1oeb0hynmHuBw7ajBB9MDWxAEp3j8xkaaA= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2e6eb2f8-2789-4bf7-3e77-08d80bd8f292 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jun 2020 18:22:48.7075 (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: S7sEWqFUKwY8Oak1DMA1x3hnbAaS2t964CME8gAORcVIMZRAVIPxeiuee3yznpwmhN5fEEgr/liHlKLeouBRjg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6525 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,wasim.khan@oss.nxp.com X-Gm-Message-State: iXRznhuv7t7NC3aIzJsztHhJx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1591643473; bh=Kfv3NTKYlV973U3xqcEoDyFrV+bwaDPTL6H4gAw0BdM=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=frzSJwxde1jAD8L6ADm0Scvo4r20FDu/rODB0WkpEwe7goCWa4vhXLeVu/nmAEMzpIa rRW4uWvYXN+dgKCzAcm+T1Sbtoe82YnfaQ1RZLowLuk7Owb4Lq2lOegXO+5vExkBiRuXE pxtcRT4eoPOLzIsrwqOHDod3FCoyhWYr9uw= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From: Wasim Khan Based on the serdes protocol value in reset configuration word (RCW), different PCIe controllers are enabled. Get SerDes protocol map and initialize only enabled PCIe controllers. Signed-off-by: Wasim Khan Reviewed-by: Leif Lindholm --- Notes: Changes in V4: - No Change =20 Changes in V3: - No Change =20 Changes in V2: - Addressed review comments for structure, variable and function names - Using BIT0 instead of 0x1u Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.inf | 1 + Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.c | 35 +++++++++++= ++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.inf b/Si= licon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.inf index aa5a9dec7c34..6003da708698 100644 --- a/Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.inf +++ b/Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.inf @@ -28,6 +28,7 @@ [LibraryClasses] IoAccessLib MemoryAllocationLib PcdLib + SocLib =20 [FeaturePcd] gNxpQoriqLsTokenSpaceGuid.PcdPciLutBigEndian diff --git a/Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.c b/Sili= con/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.c index e5309a4f4248..8bbbaaa6e24d 100644 --- a/Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.c +++ b/Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -721,6 +722,32 @@ PcieSetupCntrl ( } =20 /** + This function checks whether PCIe is enabled or not + depending upon SoC serdes protocol map + + @param PcieNum PCIe number. + + @return The PCIe number enabled in map. + @return FALSE PCIe number is disabled in map. + +**/ +STATIC +BOOLEAN +IsPcieNumEnabled( + IN UINTN PcieNum + ) +{ + UINT64 SerDesProtocolMap; + + SerDesProtocolMap =3D 0; + + // Reading serdes protocol map + GetSerDesProtocolMap (&SerDesProtocolMap); + + return (SerDesProtocolMap & (BIT0 << (PcieNum))) !=3D 0; +} + +/** Return all the root bridge instances in an array. =20 @param Count Return the count of root bridge instances. @@ -752,13 +779,19 @@ PciHostBridgeGetRootBridges ( PciPhyIoAddr [Idx] =3D PCI_SEG0_PHY_IO_BASE + (PCI_BASE_DIFF * Idx); Regs[Idx] =3D PCI_SEG0_DBI_BASE + (PCI_DBI_SIZE_DIFF * Idx); =20 + // Check is the PCIe controller is enabled + if (IsPcieNumEnabled (Idx + 1) =3D=3D 0) { + DEBUG ((DEBUG_INFO, "PCIE%d reg @ 0x%lx is disabled \n", Idx + 1, Re= gs[Idx])); + continue; + } + // Check PCIe Link LinkUp =3D PcieLinkUp(Regs[Idx], Idx); =20 if (!LinkUp) { continue; } - DEBUG ((DEBUG_INFO, "PCIE%d Passed Linkup Phase\n", Idx + 1)); + DEBUG ((DEBUG_INFO, "PCIE%d reg @ 0x%lx :Passed Linkup Phase\n", Idx += 1, Regs[Idx])); // Set up PCIe Controller and ATU windows PcieSetupCntrl (Regs[Idx], PciPhyCfg0Addr[Idx], --=20 2.7.4 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#60906): https://edk2.groups.io/g/devel/message/60906 Mute This Topic: https://groups.io/mt/74759292/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-