From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (EUR04-VI1-obe.outbound.protection.outlook.com [40.107.8.77]) by mx.groups.io with SMTP id smtpd.web10.7246.1591535774486828826 for ; Sun, 07 Jun 2020 06:16:14 -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=VmvFmkvv; spf=pass (domain: oss.nxp.com, ip: 40.107.8.77, mailfrom: wasim.khan@oss.nxp.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RxwvHlfsaC5k6uiZGOIDA1aUe8MjdOVoq96ffCzUgziZJwZuRazJ8zI2S8RxaX25GthB1UCM2lMVufo2yteQFQgSJKkj6CjAAsOJSOaYiodcCYHjiZbQ8xgSdoajsLS507g6AHOm8+wk8bHUqUmdye2cghWozQl1HD/ocuvfuwnFFRxufSarQRTbdtkztbBgev/+l0Oq8sYQjQoctIqRot39cGjecA/e0FRsE5w5vt8kYDkRzwAcx1tkbSbCigXcoeIbo0sTfOz1tCvKBiEMLE8LDb75DOq0mc6s5/p9+Fa2JZjCIJkZReXGkPRtwUeXgXKlOnAPrKXIKPsx9obJ5g== 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=zfUUWMpbJnmuKaqdSxrLoWx6SihBwb647E8saCm8+9o=; b=oEiWHZ+vauGULvTbeLpFCt/OxtV2Ge7er1DRkCV0ZFu+zOUisamsoaRXzu4IgCRTVgvIzCCtKJgK8h3SQBaAo6qArG7sMBy81SKuXOd5ZNnVC32z+SljVVhue6oxIPSFQLYzblliyfMJnjym8Lu69sJc1+9S/bANJV5s/SPiSAUS0GWjMC3TUWfKGGX/fwxhmD7lvVV3H8Yk9f+HMUEC5RjyL/2KqfcfyvXl3uDHlPk4bBkxueoZBNrs1vrQQ7ZnAg3DOnBazW3xLT6JRUTLkf+qQM4vRVk7VGJIvJTTCLlrwsX7PW8E0LIeqjhybqvaPwhs2ny8mk0gD9dQpOyeLQ== 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=zfUUWMpbJnmuKaqdSxrLoWx6SihBwb647E8saCm8+9o=; b=VmvFmkvv+/HSZTk0WxfhlzqZ6m4m4tXY86pF6vqPNX87sVuO5QdmowBHJ5JG9dZkNgTTijdPVRed0jD4ezRQ6GY+CtY7JGE0DrjRyasPORCBuEqepD0L7P5Tj2cZxSzQs5xT8NI73BuI1VJpcuSWpJizXnERUZr3A8s3jN6OnfA= 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 VE1PR04MB6493.eurprd04.prod.outlook.com (2603:10a6:803:11f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.20; Sun, 7 Jun 2020 13:16:11 +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; Sun, 7 Jun 2020 13:16:11 +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 v2 3/3] Silicon/NXP: PciHostBridgeLib: Initialize only enabled PCIe controllers Date: Sun, 7 Jun 2020 18:45:50 +0530 Message-ID: <1591535750-15743-4-git-send-email-wasim.khan@oss.nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1591535750-15743-1-git-send-email-wasim.khan@oss.nxp.com> References: <1591535750-15743-1-git-send-email-wasim.khan@oss.nxp.com> X-ClientProxiedBy: BM1PR01CA0153.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:68::23) 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.47.233.236) by BM1PR01CA0153.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:68::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.3066.18 via Frontend Transport; Sun, 7 Jun 2020 13:16:09 +0000 X-Mailer: git-send-email 2.7.4 X-Originating-IP: [157.47.233.236] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: a8932be9-f536-4b51-af13-08d80ae4f2b3 X-MS-TrafficTypeDiagnostic: VE1PR04MB6493: 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-Forefront-PRVS: 04270EF89C X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gi/0bh0gAuZclUHeWa4VdRj5ZoRtWUbv6z3bItFF+70WGN8l/3DpNtIRFWFMd4RhUFYyROUcDxlQdaJZLuhSLZ0uCJybKH5+/6URw5H44wtnliLsWQWa93baQohF/jrA/bgC1OlOy/BVcl6KfZs1AL3HXHvxbK+YpyNsVqEeUU+lvQ+r/qO98tFtSkh0ZaPVTqYHbwA7Hjs0I1WJbbwduDMpRJg5xY4a+j1R8dbyvHT3yXE+3QZP/hRxdljjAJ0wrfA31j/E0nUfvZCanuHsd7rvd6rrgd9IabSzj11itYEGLV0cmJybdldqlTWo1UwQ52IFxrVoatcsipVzbEdjAg== 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)(346002)(39860400002)(366004)(136003)(396003)(376002)(186003)(26005)(16526019)(86362001)(478600001)(83380400001)(4326008)(8936002)(8676002)(5660300002)(44832011)(6486002)(66946007)(6666004)(66556008)(6512007)(316002)(6506007)(2906002)(52116002)(2616005)(956004)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 4Y12LRdnHmDIW4oJtv4H6Llf+ACGYLrjPBt5FxmU1NY3YL9SmmAHx7KL/glEppu7gkqFwdVc6g/Vfadw8j/2nhRAIntNM7NngQyefCQwjJBEwS3GdG6OczjYn8l3vfj79/yTATk22SoZQ1MaJ3OXR/LZH0eOfnTIs2RSp+BiXFqs4fT37VqV0xqTFzvw6jSUpEgd8jIwC0mlZlnEo8GvYpArY6xo53rEgAQ8gJGpOWa1YEqF6cq7kK8motLOMKDYvaDPIadFhIMYNktynQhb4vUZs9NDf5e+kwh51DXNL34/u4IAf5p2x7kTo49VHrZaD6JjW4VXQnn9iVYHSJT7SQ+vvIS4B3FQXFv/0+4FBEGc4V4lsNml87tPplOIs0/SQLBf1LwH0ZJmdkGLXgtKk5F+vtoNff3tVm+K2tUgMeplODbnWGstGo8LoMbvJ2KErhYR6S4KO8pLXn4Fct88BVHXoMB6BSiReZVptsTJ7fwm7hMTubBrUcpS4LQ2alZI X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a8932be9-f536-4b51-af13-08d80ae4f2b3 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jun 2020 13:16:11.5637 (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: 7XaZdoAK45uWndmGObN2m95xb8+W6tBuU0HhZpDIRtGWus2HKitwliPuiui8VW9vqIALIRWeHnBSNdpQLHmgdg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6493 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain 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 --- Notes: 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