From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR02-HE1-obe.outbound.protection.outlook.com (EUR02-HE1-obe.outbound.protection.outlook.com [40.107.1.64]) by mx.groups.io with SMTP id smtpd.web11.27.1591637335865799614 for ; Mon, 08 Jun 2020 10:28:56 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@nxp1.onmicrosoft.com header.s=selector2-nxp1-onmicrosoft-com header.b=F4Toovax; spf=pass (domain: oss.nxp.com, ip: 40.107.1.64, mailfrom: wasim.khan@oss.nxp.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AZfs6jTdFJl93mRe3rXNTejbKoB0mecKTMlQwlBAfGNuFUarQlDawiRnzLgWsY6665CSEUz8r4kg+6jfhcTl2krZLdx9Ck7KLiLr68aVYms7sXy9+4GYGPGqr7fUzTS1i+KS88WSvpfQSL4xWCO4gHOD+MND8mgDiss1oFaKCsmFMfTz5Pd2J2qp0Cogn54mIu7J3icQfb4F5LDmwlS1jfP6qCx5EkJrIOxsVVrry9oMCYFskfShEsUEmVTa8vxiwwxg0P9jfHzWjA9J2gLcuSw1yYkQk/pHvvLVnQZLGTOe0fnrQj3t8WXKWi5M5H+WWM3nmi1VII19K5jUHsfGvw== 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=Ob8QTzyy1kF3OF+fIf08PCVLzi9j16/H0QZC8ns0fPY=; b=PxhUI3PkaLIjaHTbVRrnNRdasUYjR4oWOE/b94PzriFAAWqUq0Au+EZQe/I5FkGBjz5dk456Z+VW//sCXGecNLASkZLA9kKnDkcNr9e2jWCZx5KzDUNfYPE6j3x/aNr1OwXtA5BT7+vnarLv30XOs8CbFg/TUTOjQXE4jsiuQ1dvpFofnuHf7kpF2hOYG4MpLI6adKdtp17boxs8f+wiqoCYGaamcUd4ewQSstLrhvxrQCiNpCX7knCTnepwptuTz8ffrUQ6lFkjY7pTDfbJp7C6K7KGeaDMtJC31i/FOPAz1k0pVMMD/KcZS+WhQaR+1++lN/tCGYVZBiQGh805Ow== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ob8QTzyy1kF3OF+fIf08PCVLzi9j16/H0QZC8ns0fPY=; b=F4ToovaxT9FHb3Rj6zljvFsdXELkyCZUxP4/aAUMyCdCPCcvc+llmkpOa+jXwgBX5ul6WBJqdt6SmXqsUY58v2aSjQ8ZZu0csJn9mZPrnb3QCT2nhDYQXxhsQVUL8l7gyyu95Ym+ccDlaTH3ECyWfVSDlYzZLChIEPLjk5dshTI= Authentication-Results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=oss.nxp.com; Received: from VE1PR04MB6702.eurprd04.prod.outlook.com (2603:10a6:803:123::13) by VE1PR04MB6671.eurprd04.prod.outlook.com (2603:10a6:803:11f::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18; Mon, 8 Jun 2020 17:28:53 +0000 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 17:28:53 +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: [PATCH edk2-platforms v3 2/3] Silicon/NXP: LS1043A: Add SerDes Support Date: Mon, 8 Jun 2020 22:58:16 +0530 Message-ID: <1591637297-16073-3-git-send-email-wasim.khan@oss.nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1591637297-16073-1-git-send-email-wasim.khan@oss.nxp.com> References: <1591637297-16073-1-git-send-email-wasim.khan@oss.nxp.com> X-ClientProxiedBy: BM1PR0101CA0064.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:19::26) To VE1PR04MB6702.eurprd04.prod.outlook.com (2603:10a6:803:123::13) Return-Path: wasim.khan@oss.nxp.com MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wasimk-VirtualBox.nxp.com (157.37.163.9) by BM1PR0101CA0064.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:19::26) 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 17:28:47 +0000 X-Mailer: git-send-email 2.7.4 X-Originating-IP: [157.37.163.9] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 2be88307-ce78-4e36-0bb1-08d80bd169aa X-MS-TrafficTypeDiagnostic: VE1PR04MB6671: 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-Forefront-PRVS: 042857DBB5 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Wq5WLbCjo2tjlSd7i1pDB/DGbLobyoms59syVxBcIj7/FVHPTEv0oER97qs4U9JW4UDwoIHxioFszVo7elLF1bxHSpdtHzX+ioOLDjHrRYLigr1eNirjbLpP15nBbMa5/BkUpDCWym1dBocYEDEgJ+1DxX0YpAfZf0MYm25E5pSuXql5mnsGKdBl9ojJF4TGQMO6Xsp8VnxUjG///9OHrkoQX0LnXV0usSHdGMoB4j1l+YBkT588a79CLxvXREyTI5lTOipG7WSUtjHhIT+RZXVFn/4afRyumt3LAJbFNeammT+dct7K8j15Nff1C97l6wWZmxAW7iIwd8b1Xd+6lA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6702.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(136003)(39860400002)(366004)(346002)(396003)(376002)(4326008)(2906002)(6512007)(66946007)(6486002)(66556008)(66476007)(19627235002)(186003)(478600001)(2616005)(956004)(316002)(86362001)(26005)(5660300002)(6506007)(6666004)(44832011)(52116002)(16526019)(8936002)(83380400001)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: nNbgGTiHBR14uz1tkvNsXBhQHHAkB50p8uVxtqWSvOBCY2FnOrGPrIffNhwjArG2rfaDU/3iMXJzewz6LQPYe8/8Gn25U+xJPdla6LbozaXL85kN2cdhCgljWkvhEyzH/9NgekOR0csM8KwehfJFh/SM5acpBCitiCJUBb53OfGLsbyvo46W0e991XFbtRTYWUMPvrrCxCGf10VBv5X08Xe3DIrLbbbf8KVGIGGkccaHFOSjEBYePODrXnTFTvW4bvz3RvbEqAEiTbB4xdbzegNztWUUQlX2nyR79kfnp3GDTnwIlOTVEBcnze9rrIl+/6z5Xhx3H+wQyX5Mny8tWugnK4MnHUAjFFzyYh9TfWq+T6jtHVhif1IS3iiN5CzC8/kvJLFCo9OO6VaazgLW/BhhZRLYS+ZRKdoOerYegs9IfoCT22AMAjy+zt8HWhHx3o/VpL3TV5pZm3y7h1A5LfA+WFYGXsqi2KM6slEs/nY= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2be88307-ce78-4e36-0bb1-08d80bd169aa X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jun 2020 17:28:53.1251 (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: 2Qp6m+iAPn5mALI1tUtlx3XVZWEbxr588dnlAT0IhOEj1ZA5TuL5QLtqzxqHQ2RHHFg9v7vj5+GBTUOX+Mfh7Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6671 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain 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 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/Library/SocLib/SerDes.c | 119 ++++++++++++++++++++ 4 files changed, 155 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/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 Registe= r +#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