From mboxrd@z Thu Jan 1 00:00:00 1970 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 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=g+y7RrMR; spf=pass (domain: oss.nxp.com, ip: 40.107.21.61, mailfrom: wasim.khan@oss.nxp.com) 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 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=33IQtFbzpBfJ7I77TDJ8HHFJ02fjT+TXMUlJx9pDWiU=; b=g+y7RrMRR78VLRCWjPeKbJkFu4w+Xp8EV9PSG0bSKQxsNOkSia4bPquI6e2L4TXcNARB3MlOCeOhGNL/0b0OSzNnamligpjMrDSacIsDvstyS0FNgNku3l6yHDCrhfk/Gf3bpngwM0rIkTUfJS8X9yL6k2u847icZqj9qgJK0mE= 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 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 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: [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> X-Mailer: git-send-email 2.7.4 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) Return-Path: wasim.khan@oss.nxp.com MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 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-Mailer: git-send-email 2.7.4 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-Forefront-PRVS: 041032FF37 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xn0RX06iNv01dXWV/O5Eu9Auf5dp8fQ7+sowZe4uWwEOZHMdZmx5T47N53TZIUfcchxUQtXWb5zCv7FyhEkRh5oraoVhq4YJJuTIjxpC7l0zZgS6Ap4vUlivZ+tsEM8ee5PAbyNzq8dDW+Xq+aQ0FNxQn1aQJT9q95LS8YN/KCaXcSx4BLNjSJMzihqsuSukMUUZfXgILl6wu5vGDvAEyiuhdyVAKdiySiGT75QQNQCzQFbQGbOQ1npId1VOquH9XtuBI46k6aIiFxxbgWnpfVeDls2r0nbGXjKy9oGmvX8P9yCKZzVKf3mrCKot0GpS 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:(6029001)(4636009)(346002)(376002)(136003)(366004)(396003)(39860400002)(6506007)(52116002)(66476007)(2616005)(956004)(44832011)(66946007)(8936002)(8676002)(4326008)(316002)(478600001)(2906002)(16526019)(186003)(66556008)(86362001)(6512007)(19627235002)(5660300002)(6666004)(6486002)(26005);DIR:OUT;SFP:1101; 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain 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