From nobody Mon Feb 9 11:32:24 2026 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+60123+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+60123+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 1590144604742192.77623650357862; Fri, 22 May 2020 03:50:04 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id WezRYY1788612xNcnxg2w1m3; Fri, 22 May 2020 03:50:04 -0700 X-Received: from EUR05-VI1-obe.outbound.protection.outlook.com (EUR05-VI1-obe.outbound.protection.outlook.com [40.107.21.61]) by mx.groups.io with SMTP id smtpd.web11.3409.1590102222229358545 for ; Thu, 21 May 2020 16:03:42 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K+qukt5ESnTjT6PxtfV83ToFmP12W/XGbOSSJDMTUhe8nnhqCuivhaMlzMwW1iU31ifyYUPz1fhDuLzoeNDeXF+bHLdbpqLnbMSe8TP5moOty4UQQBPFshg3ZQmlWBzUEN0q/42509zWz2F+VqBbPBQ+MnvSduGbADlR1Si//ygF8g5e+pK8Vy5UROJI/R9OdSXEcd0cWfVV2CDFEtK0GxXG3cCzpldQI77oy4D+vOiSHbXZq+d/mOrKKswNFRGiaglpGpFN/ol5w+xtZMApj8o3qdyDNdt62Pe8MW1SqKJylrTXztzoMJiJUBgcUG8xX99Tcho3uq8X4f9Gt2wCHg== 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=33IQtFbzpBfJ7I77TDJ8HHFJ02fjT+TXMUlJx9pDWiU=; b=GugYB6cWMQlpJvig6VhPzngN8HbwkRaPe7i8IUDXjOn4OIB1lun9BEBxCwI6ETjdGWPZegybP/R+xQsIti3+hexkNKrSk8hprnHoFfpfqT2iXrytOZdHLThg/dbK+vwO4xVGWlp54p7xMjLL3NhJgBroglLcS+qrNAh16oqFsO404BkHDoarpspM6YMQ9grqlxSJmGpDIDOQl8ksUfz1bE1y/te4QukiPPH2AzeH8SZjg5qXEJFv5j2ezrg76i9Yvt0h9CQEnhU6dmYHTBi4L9cbbD8+Jb6mZIY0W/Df3mCfFh1sXzRekCBJKfEZU5mnn0bbrPoprHMB6VWZsKSD9Q== 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 VE1PR04MB6381.eurprd04.prod.outlook.com (2603:10a6:803:119::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.27; Thu, 21 May 2020 23:03:39 +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.3021.020; Thu, 21 May 2020 23:03:39 +0000 From: Wasim Khan To: devel@edk2.groups.io, meenakshi.aggarwal@nxp.com, vabhav.sharma@nxp.com, V.Sethi@nxp.com, ard.biesheuvel@arm.com, leif@nuviainc.com, jon@solid-run.com CC: Wasim Khan Subject: [edk2-devel] [PATCH edk2-platforms 11/16] Silicon/NXP: PciSegmentLib: Add support PCIe LsGen4 Controller Date: Fri, 22 May 2020 04:32:14 +0530 Message-ID: <1590102139-16588-12-git-send-email-wasim.khan@oss.nxp.com> In-Reply-To: <1590102139-16588-1-git-send-email-wasim.khan@oss.nxp.com> References: <1590102139-16588-1-git-send-email-wasim.khan@oss.nxp.com> X-ClientProxiedBy: PN1PR01CA0071.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:1::11) 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.47.200.219) by PN1PR01CA0071.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:1::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.3021.23 via Frontend Transport; Thu, 21 May 2020 23:03:37 +0000 X-Originating-IP: [157.47.200.219] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: b561c153-7c58-4c34-bf1c-08d7fddb3308 X-MS-TrafficTypeDiagnostic: VE1PR04MB6381: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3968; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: xn0RX06iNv01dXWV/O5Eu9Auf5dp8fQ7+sowZe4uWwEOZHMdZmx5T47N53TZIUfcchxUQtXWb5zCv7FyhEkRh5oraoVhq4YJJuTIjxpC7l0zZgS6Ap4vUlivZ+tsEM8ee5PAbyNzq8dDW+Xq+aQ0FNxQn1aQJT9q95LS8YN/KCaXcSx4BLNjSJMzihqsuSukMUUZfXgILl6wu5vGDvAEyiuhdyVAKdiySiGT75QQNQCzQFbQGbOQ1npId1VOquH9XtuBI46k6aIiFxxbgWnpfVeDls2r0nbGXjKy9oGmvX8P9yCKZzVKf3mrCKot0GpS X-MS-Exchange-AntiSpam-MessageData: lXLBh4QPTwVdISJCCwyTgIqyzAoWPy6SwKxg9PGy9s5ERuF3PfOUQ0qYGYYYwWTzCcSAULkoT2y166njVQGZqnumbWDVg+7PeBo6BTsTdm600vr27OwEYOBMA8dMzMpUnG6kEGA7rwOOtdDSXlOFnSRsDfL0uUlf5zJhDfd0ofFIE/OcNndqKYeeFg8bbSHrahqLoKPh3ycTKoB6rfbnORSaHgtCSbdPflT2Z98xRLcA6DW8sAL/Adj3FLnau5vEW9L2Qy1qjO+6ibXPB8x4X9Csfcw0w7pdAU+ZbSyiMkqpuJLfWJpemLK/2ei98pBW0uOh9xxv91w6FcaJ3kj3nCYDxrry1/ZtWKboeAtKUQk3eQs/6krmdEytUGkwQ3IhL18aax6xB5B2gyJ0n/0GZitg+OHTJcJgOmVx35FP/wr50l/pUTddWxtvW6T9e43sq9apkz7zodP40C+87DL7Hkkt2Ei4RUj2MAnVsnnrDh0= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b561c153-7c58-4c34-bf1c-08d7fddb3308 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 May 2020 23:03:39.5468 (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: WBZFE1bhPwxL+sSVIgBmhgbJMvcCUFOwO7PBRr0jLfjQoCXrXde9LJj0VLaSv0EPvbWJDowX0L1vEHmJ9DfZwg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6381 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: h0NH0YtdTlQyOtxqb6Bi4sGix1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1590144604; bh=wb62m2fWbALcBHs7NjIatupVX9oHLNSNpn4WhjOfilc=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=rdLntLTiP9RSTniBWVGuvzE02WIwSUB46FviwbuiA2Mw2mdwfNK+tJm1Swke+jDnUVv yRCMLxAHNEERf4q1gl8Wkxtfc5YSXKwK13H5WcrqNnpWY9vMNrcxt++P3+qy9I6e93oLh dWRAODj7nUbNFpaPX2dGu4YvI2E9kLIgBvI= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From: Wasim Khan PCIe Layerscape Gen4 controller is not ECAM complaint and have different PCI config space region for bus 0 (Controller space) and bus[0x1-0xff] on NXP SoCs. For config transactions for Bus0: - Config transaction address =3D PCIe controller address + offset For config transactions for Bus[0x1-0xff]: - PCIe IP requires target BDF to be written at bit[31:16] of PCIe outbound configuration window. PCIe LsGen4 controller uses paging mechanism to access registers. To access PCIe CCSR registers which are above 3KB offset, page number must be set in Bridge Control Register. Signed-off-by: Vabhav Sharma Signed-off-by: Wasim Khan --- .../NXP/Library/PciSegmentLib/PciSegmentLib.inf | 1 + Silicon/NXP/Library/PciSegmentLib/PciSegmentLib.c | 60 ++++++++++++++++++= +++- 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/Silicon/NXP/Library/PciSegmentLib/PciSegmentLib.inf b/Silicon/= NXP/Library/PciSegmentLib/PciSegmentLib.inf index 936213dc8a9d..d6d7ea6e3b6b 100755 --- a/Silicon/NXP/Library/PciSegmentLib/PciSegmentLib.inf +++ b/Silicon/NXP/Library/PciSegmentLib/PciSegmentLib.inf @@ -33,3 +33,4 @@ [FixedPcd] =20 [Pcd] gNxpQoriqLsTokenSpaceGuid.PcdPciCfgShiftEnable + gNxpQoriqLsTokenSpaceGuid.PcdPciLsGen4Ctrl diff --git a/Silicon/NXP/Library/PciSegmentLib/PciSegmentLib.c b/Silicon/NX= P/Library/PciSegmentLib/PciSegmentLib.c index 552a425c6832..02a1525ef308 100755 --- a/Silicon/NXP/Library/PciSegmentLib/PciSegmentLib.c +++ b/Silicon/NXP/Library/PciSegmentLib/PciSegmentLib.c @@ -35,6 +35,58 @@ typedef enum { ASSERT (((A) & (0xffff0000f0000000ULL | (M))) =3D=3D 0) =20 static BOOLEAN CfgShiftEnable; +static BOOLEAN PciLsGen4Ctrl; + +STATIC +VOID +PcieCfgSetTarget ( + IN EFI_PHYSICAL_ADDRESS Dbi, + IN UINT32 Target) +{ + PciLsGen4Write32 ((UINTN)Dbi, PAB_AXI_AMAP_PEX_WIN_L(0), Target); + PciLsGen4Write32 ((UINTN)Dbi, PAB_AXI_AMAP_PEX_WIN_H(0), 0); +} + +/** + Function to return PCIe Physical Address(PCIe view) or Controller + Address(CPU view) for NXP Layerscape Gen4 SoC + + @param Address Address passed from bus layer. + @param Segment Segment number for Root Complex. + @param Offset Config space register offset. + @param Bus PCIe Bus number. + + @return Return PCIe CPU or Controller address. + +**/ +STATIC +UINT64 +PciLsGen4GetConfigBase ( + IN UINT64 Address, + IN UINT16 Segment, + IN UINT16 Offset, + IN UINT8 Bus + ) +{ + UINT32 Target; + + if (Bus) { + Target =3D ((((Address >> 20) & 0xFF) << 24) | + (((Address >> 15) & 0x1F) << 19) | + (((Address >> 12) & 0x7) << 16)); + + PcieCfgSetTarget ((PCI_SEG0_DBI_BASE + PCI_DBI_SIZE_DIFF* Segment), Ta= rget); + return PCI_SEG0_MMIO_MEMBASE + Offset + PCI_BASE_DIFF * Segment; + } else { + if (Offset < INDIRECT_ADDR_BNDRY) { + PciLsGen4SetPg (PCI_SEG0_DBI_BASE + PCI_DBI_SIZE_DIFF * Segment, 0= ); + return (PCI_SEG0_DBI_BASE + PCI_DBI_SIZE_DIFF * Segment + Offset); + } + PciLsGen4SetPg (PCI_SEG0_DBI_BASE + PCI_DBI_SIZE_DIFF * Segment, OFF= SET_TO_PAGE_IDX (Offset)); + Offset =3D OFFSET_TO_PAGE_ADDR (Offset); + return (PCI_SEG0_DBI_BASE + PCI_DBI_SIZE_DIFF * Segment + Offset); + } +} =20 STATIC UINT64 @@ -129,7 +181,12 @@ PciSegmentLibGetConfigBase ( UINT8 Bus; =20 Bus =3D ((UINT32)Address >> 20) & 0xff; - return PciLsGetConfigBase (Address, Segment, Offset, Bus); + + if (PciLsGen4Ctrl) { + return PciLsGen4GetConfigBase (Address, Segment, Offset, Bus); + } else { + return PciLsGetConfigBase (Address, Segment, Offset, Bus); + } } =20 /** @@ -620,5 +677,6 @@ PciSegLibInit ( ) { CfgShiftEnable =3D CFG_SHIFT_ENABLE; + PciLsGen4Ctrl =3D PCI_LS_GEN4_CTRL; 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 (#60123): https://edk2.groups.io/g/devel/message/60123 Mute This Topic: https://groups.io/mt/74396467/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-