From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (EUR05-DB8-obe.outbound.protection.outlook.com [40.107.20.58]) by mx.groups.io with SMTP id smtpd.web11.1909.1591642381456195463 for ; Mon, 08 Jun 2020 11:53:01 -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=kxOmYan8; spf=pass (domain: oss.nxp.com, ip: 40.107.20.58, mailfrom: wasim.khan@oss.nxp.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N9mltBE3p9CRSxG0yF6FHGdI2EbETEbRyRy0gzBa0I3mhleiSj2Cbh97UXwIQivyvgYMTmRmsvY7FxM+Ec7Y9LiqJ9xOz4n14QqvzFx2lYOOoSwNMaMPsdcnugib0xVUGBjWYHOgVDyeeA0hkIPLe+gBRCMZdIWFRPIDxErfiOv76FTTxlsCLHPCLUKuORpjZFbOodrlZw0oDQaYvStYP22SRpzpTVMEHC5yV3ekp2cL/Hb0s0ZZT1MUtsJVDLfYHEvbQEIeUjZOym5bcYsJco0DocoUsXIuHCM6ZJ2szHOaThQFv9v1dEllxYeFmtZwjFg317uG3UOGyhpPepGveg== 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=HcljJ6HAPOmlQ5h8K6RRZNrLXbBvesNOcB87namX0ds=; b=V89sEglO0XDAMEp1o4dzDIFN4zUgt58BFHVwdzPh3Zv8YeHYhpgkE0/2ASsiqonbWSHEHNu8fT5V1d6GmM2DjkBNjITkgPyk5Y5SRwFWi6H1otPWkwcc6YUbdjiNN4gEj6mG4+8IRXpwSU+66v9HWVSt5UMhGgITdOb5fBgWVuUXAXsuMdwNf1RrvbM5p+uTl39GfRr9m0dC0/vLoSVTUxdZ6ytSmonCeMUmHfXMnMxHUQZZSiGVZkUftpsoR0BKzhC5yJsPW2uW6/gDEVSi6UXSOoGqQASjkQqVbYSY0VWY7oSb1HAwdolo8XRS/pytM6H9tT14ThykgB1QcJqQJw== 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=HcljJ6HAPOmlQ5h8K6RRZNrLXbBvesNOcB87namX0ds=; b=kxOmYan87LgkXuViObcoZnVHxtXXlS7EPpQ3TzEU7DS2soDWE7ohj9psKhbqRz0hExjUtdQgWvMUI6MxTdJqHHaQwJqv45i3T+gYcsycRYeDTKzIjEevkZDI8jA5+jLCmOw5B2SMzNKEeDywlZk5HoJ23pcDwChsrl2UdNuVV6E= 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 VE1PR04MB6606.eurprd04.prod.outlook.com (2603:10a6:803:127::10) 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 18:52:59 +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 18:52:59 +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 v5 2/3] Silicon/NXP: LS1043A: Add SerDes Support Date: Tue, 9 Jun 2020 00:22:34 +0530 Message-ID: <1591642355-26470-3-git-send-email-wasim.khan@oss.nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1591642355-26470-1-git-send-email-wasim.khan@oss.nxp.com> References: <1591642355-26470-1-git-send-email-wasim.khan@oss.nxp.com> X-ClientProxiedBy: PN1PR01CA0078.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:1::18) 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 PN1PR01CA0078.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:1::18) 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:52:56 +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: 78c1d994-4974-4fe0-7b73-08d80bdd29c2 X-MS-TrafficTypeDiagnostic: VE1PR04MB6606: 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: BHcAdoUq7Z+shHs+HTrYSHLJ1vG+CIYg8A+FGjvyT5CxprFqCXnDamz17SYQLxSglCyOepUfTVpuCKwj1deljCWcQDXDoNBlQHnIwKX3ZTauuiHMPCiUQ7aw+mOV6BvDrFTDAmrL7BI+0IVy08BaiS5PaPOlyOzSl76Ltqp+2cLnBwgp9Niy4etgx0z8G/+mUys0cfBnIPx9KV3nex5/pZ/CYEHp9rDBuM9i5QwovHg2Z7FUqszpGn9MJwNXMQ9CHmuGQpOkHjulgiwlJgALmsO41oE+RqnCd9D9Y+r41ZUDtip7iowDBVioSjcmMu7iqPFl5L/OAB0JBT1F1EUXDA== 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)(376002)(366004)(39860400002)(346002)(396003)(26005)(66946007)(8936002)(66476007)(4326008)(6486002)(5660300002)(66556008)(956004)(52116002)(2616005)(86362001)(19627235002)(6512007)(8676002)(316002)(478600001)(2906002)(83380400001)(6506007)(6666004)(186003)(16526019)(44832011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: OUJxapqUc6vmstHlg4dGSmTX9WyJ3ZNX9UiN8bqiyiRnegEhJt/QWxwTUW1gTmlFHyhiOjUVpSbYzH7DDfSJSpH6/8FdZI9cEEbVSIGv2ZNRW2J1I7yj2M2GXyf5D7IVAwO5NhAb67qq2ZI+VmgS3m7iBrdfVcnCw83EI+VTLQEStq34URwQcGCt6BCVijUwj1EedaFFFHiL1BPINeHfgFTy5vJqKFfdqHUtLeSSKKZEs72poybvUoInATuhRucvTldbKnl+1X2+PUh7R8IQRjtqUWMFFSfmnnlAX41eAPmdCLxWYdb9hhBHVgvR4tzy1CoojAU825iiZGzqdmX7Qk5eSL1Ik5MJvIe6rtlYOJ/MkXFr2zpwUxMEQpmXzqdGKw2n4uBqOlBfPx7IYgTPCxDH60GgE0vWCGYTAoVNJ3d9IMcCcNfOfDOS0g0OuKgOYXvE/rvTx2Fu7upzxHo3B4zZ92W9qqENaWD+PJnFGKs= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 78c1d994-4974-4fe0-7b73-08d80bdd29c2 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jun 2020 18:52:59.3781 (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: SwhZyuFBXaWSa1xH4tEtzRS5fFfcM4JBTsmAIDjDh4kfePY6f6zboKSLRHK72wOMU4xLOfsmMzkCekIRcfXyVQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6606 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 V5: - Corrected enum value and CheckPatch fix =20 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..2fc5651c004c --- /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_PROTOCOL_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 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