From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (EUR05-AM6-obe.outbound.protection.outlook.com [40.107.22.75]) by mx.groups.io with SMTP id smtpd.web11.46892.1590482300588857313 for ; Tue, 26 May 2020 01:38:20 -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=dQg1qdkt; spf=pass (domain: oss.nxp.com, ip: 40.107.22.75, mailfrom: wasim.khan@oss.nxp.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mdZJP8bTKr60qigOVG6DZZ2h6N2iMsvc22vgQmTepwwaZ4NnNXQI2SPi2dal3rXqwSNvwVojaM+Z90fmpC2mBeSCt822gwvFaC63+h/EXTdJRcss0ujuXEo2DWgvZi40xpsF43Wz1RG9y6PhtKpu7oPnzXpIkggkZ/6VrbTdBBimeXTMxV4BB6CN/IafPFsJ/RUTKYlhS1VFTPjtnqaTGG4ZNPQBS6NMsbCIXCsa/apG+YkXN09+8AVCICnE6nq2DEG4E5EY37Yp2ZLBRISlIe5nSApW283w0EDuuMhXiY7MDJgcY4ZCDMY5DlfKNZXkzfxqWp2V4xNSjyVwAtKHUw== 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=AOCagTXmqjdEpq7Ybcqf3D9HoKH2DjgZtsRaeSVbnTA=; b=XENR/+RRY4/IiTrt4vBC7wQklvv0rHOhw36sur98mhb5uFf6jCHhQw12vE2/fSffleVs9K55waxGyOCpDb+MYujbLAxzGFUk8JQ2Ns/HmIE7wh3/N3zy2kfULeYqaN+pQPno5MB+XPVwqAgq3cQ/RcVubPcY1/OxGJcYRDbMfq3WwtsRt6QJvtdDZlqWDHi/oWPVQq4rYCNPVZIUDEFUBHUOk7UQdRyXqb5R2UohnZ9NNu0b9XpYPEmQPDL2xZMxU6NgseqIwFNP5ZFpM2apheA6+wnQ6soCqySvm4yKpLFfA22VzsTNRkjGV6FOxFzu4apxzq/K9XXYZ3BjaUwn1w== 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=AOCagTXmqjdEpq7Ybcqf3D9HoKH2DjgZtsRaeSVbnTA=; b=dQg1qdktGAaUR8X9Lna0U/DvQcsABGunnvL+spkrPWic+gD3a/qYk3VPz+a7WDBihL88x4bhTETO3Vdr4xBlknisZ5Oqu11JGp4xzM7/5Cz4lYgYXb/pekg4xHWHaeocHGGh2PwsAkeD16hRdAp1DsVPv6cCW6+xfoiEr0EbxgE= 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 VE1PR04MB6367.eurprd04.prod.outlook.com (2603:10a6:803:11a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.27; Tue, 26 May 2020 08:38:18 +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.029; Tue, 26 May 2020 08:38:18 +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 v2 04/16] Silicon/NXP: PciHostBridgeLib: CFG Shift feature support for PCIeLS Ctrl Date: Tue, 26 May 2020 14:07:09 +0530 Message-ID: <1590482241-13132-5-git-send-email-wasim.khan@oss.nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1590482241-13132-1-git-send-email-wasim.khan@oss.nxp.com> References: <1590482241-13132-1-git-send-email-wasim.khan@oss.nxp.com> X-ClientProxiedBy: BM1PR0101CA0015.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:18::25) 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 (171.79.147.152) by BM1PR0101CA0015.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:18::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.3021.23 via Frontend Transport; Tue, 26 May 2020 08:38:15 +0000 X-Mailer: git-send-email 2.7.4 X-Originating-IP: [171.79.147.152] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 07672f22-f4e2-4c2f-d704-08d801502394 X-MS-TrafficTypeDiagnostic: VE1PR04MB6367: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-Forefront-PRVS: 041517DFAB X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wElB8oyt4oU90UnMX2i36FHdW01UvCPfQBBSjyNBStv8zfmFkPxPgop2aDVjNJk+CUNq8SDzj54PKyM1jiz0bW60OjnDw3qHFhMbDU2w/hrsJsDacauOsjg4E06GuX1gTOVFFMtmzaxheznPkstzN43sR3pg1S38zpBP3oMz9XL4LYKdp55cMq0rUdZ0fYvkiinzdZeTzboESf3wC800Sg5MdifZ0w3vnQxwJiiw10i5j+zsxA3iQIZ3zxh+Ubw43vYlbTiF3dschCVl8b7UXa99dgiGbiEOEmU72KEbBV0RpxXoKjYAy58rzvK63aocs6Nbtqj5fDtO+aQJZGJxbA== 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)(376002)(396003)(346002)(39860400002)(366004)(136003)(478600001)(6666004)(66946007)(86362001)(956004)(66476007)(44832011)(5660300002)(66556008)(316002)(2616005)(8936002)(2906002)(8676002)(6506007)(4326008)(16526019)(6486002)(52116002)(26005)(186003)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: HdNhJk67Duj6dTU8MhAe96qpbDsYcI5+mSo6mJGB/HyF0tcDiTvFKFyg93womgV8TEZmpjbdjkhHIDBYrnnRN9VnFb3gJsHejUmMeSgfBSPeLoYronJPDNawn6NokD3XPMz+QzR8HBxn+bHAsZhlWdLF1CKNyxyg3CB0hb11B2gDNgyg+y14uCsNClL8vRh+REDS4V1tRETC4ezGkEnaqCz14Gc/F0PydiN9wQCqBDUMXA9h1aw0+JFx1lhQugWIaEI64RLLozBSPGB+DhrRqGlvufkrxG5OQWUBMMGL85x6HBwzxbvLCZeQX9NTkSvrkgUhfTI0MLVfZY2BPiHHGaABmU8vY8rPfumlnC1XAvOSHHfR6qHGyY56RabuGExopwdXr0YdmIY5YMkFYLeEUNCCLB8bvZ3Dxq6ta1csHpU35XvudsZz878tbPnKOA6aw8eEh5IYeJh3qdM4SDiJNzeWvlRIe+G0tM7HzFLKwMafAlEmqm7+tWqZqSFyNpeT X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 07672f22-f4e2-4c2f-d704-08d801502394 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 May 2020 08:38:18.4270 (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: C75JKvkFDb+s4bLTpBcl6zGO/mGLNHOHq6qfA+QGb4cruEujCA27K/7hCCAIRS+zAjKpHzxhqwnHMU+d1eLLhQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6367 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain From: Wasim Khan PCIe layerscape controller supports CFG Shift feature. It can be enabled by setting BIT[28] of iATU Control 2 Register. Check PcdPciCfgShiftEnable to enable 'CFG Shift feature' in PCIe controller. if enable, PCIe layerscape controller shifts BDF from bits[27:12] to bits[31:16] and supports Enhanced Configuration Address Mapping (ECAM) mechanism. PCIe layerscape controller is ECAM complaint for bus[0x1-0xff]. So create outbound CFG windows from 1MB-256MB (255 buses) for type0/type1 configuration access. PCIe layerscape controller is Non-ECAM complaint for bus 0.It does not support device > 0 on bus 0. PciSegmentLib should handles this limitation. Co-authored-by: Vabhav Sharma Co-authored-by: Wasim Khan Signed-off-by: Wasim Khan --- Notes: V2: - Removed Signed-off and added Co-authored-by for co-author - Introduced ECAM_BUS_SIZE and ECAM_CFG_REGION_SIZE for CFG region size and added comments for same. Silicon/NXP/NxpQoriqLs.dec | 3 ++ Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.inf | 3 ++ Silicon/NXP/Include/Pcie.h | 5 +++ Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.c | 37 +++++++++++= ++++----- 4 files changed, 40 insertions(+), 8 deletions(-) diff --git a/Silicon/NXP/NxpQoriqLs.dec b/Silicon/NXP/NxpQoriqLs.dec index 9ff5ce8a1c6e..5358aaeb037e 100644 --- a/Silicon/NXP/NxpQoriqLs.dec +++ b/Silicon/NXP/NxpQoriqLs.dec @@ -35,3 +35,6 @@ [PcdsFixedAtBuild.common] gNxpQoriqLsTokenSpaceGuid.PcdNumPciController|0|UINT32|0x00000501 gNxpQoriqLsTokenSpaceGuid.PcdPcieLutBase|0x0|UINT32|0x00000502 gNxpQoriqLsTokenSpaceGuid.PcdPcieLutDbg|0x0|UINT32|0x00000503 + +[PcdsDynamic.common] + gNxpQoriqLsTokenSpaceGuid.PcdPciCfgShiftEnable|FALSE|BOOLEAN|0x00000600 diff --git a/Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.inf b/Si= licon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.inf index aa4802b019f6..99807d5beb1f 100644 --- a/Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.inf +++ b/Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.inf @@ -37,3 +37,6 @@ [FixedPcd] gNxpQoriqLsTokenSpaceGuid.PcdNumPciController gNxpQoriqLsTokenSpaceGuid.PcdPcieLutBase gNxpQoriqLsTokenSpaceGuid.PcdPcieLutDbg + +[Pcd] + gNxpQoriqLsTokenSpaceGuid.PcdPciCfgShiftEnable diff --git a/Silicon/NXP/Include/Pcie.h b/Silicon/NXP/Include/Pcie.h index 9dbe876b9c1a..f7c18c3aa094 100755 --- a/Silicon/NXP/Include/Pcie.h +++ b/Silicon/NXP/Include/Pcie.h @@ -27,6 +27,8 @@ #define PCI_SEG_PORTIO_MIN 0x0 #define PCI_SEG_PORTIO_MAX 0xffff #define SEG_CFG_SIZE 0x00001000 +#define ECAM_BUS_SIZE SIZE_1MB +#define ECAM_CFG_REGION_SIZE SIZE_256MB #define SEG_MEM_BASE 0x40000000 #define SEG_MEM_SIZE 0xC0000000 #define SEG_MEM_LIMIT SEG_MEM_BASE + (SEG_MEM_SIZE -1) @@ -64,6 +66,7 @@ #define IATU_UPPER_TARGET_ADDR_OFF_OUTBOUND_0 0x91C #define IATU_VIEWPORT_OUTBOUND 0x0 #define IATU_REGION_CTRL_2_OFF_OUTBOUND_0_REGION_EN BIT31 +#define IATU_ENABLE_CFG_SHIFT_FEATURE BIT28 =20 // ATU Programming #define IATU_REGION_CTRL_1_OFF_OUTBOUND_0_TYPE_MEM 0x0 @@ -77,4 +80,6 @@ #define SEG_IO_SIZE 0x10000 #define SEG_IO_BUS 0x0 =20 +#define CFG_SHIFT_ENABLE (PcdGetBool (PcdPciCfgShiftEnable)) + #endif diff --git a/Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.c b/Sili= con/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.c index 230fcf57690e..9fae19095cba 100644 --- a/Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.c +++ b/Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.c @@ -259,8 +259,17 @@ PcieOutboundSet ( MmioWrite32 (Dbi + IATU_REGION_CTRL_1_OFF_OUTBOUND_0, (UINT32)Type); =20 - MmioWrite32 (Dbi + IATU_REGION_CTRL_2_OFF_OUTBOUND_0, - IATU_REGION_CTRL_2_OFF_OUTBOUND_0_REGION_EN); + if (CFG_SHIFT_ENABLE && + ((Type =3D=3D IATU_REGION_CTRL_1_OFF_OUTBOUND_0_TYPE_CFG0) || + (Type =3D=3D IATU_REGION_CTRL_1_OFF_OUTBOUND_0_TYPE_CFG1))) { + MmioWrite32 (Dbi + IATU_REGION_CTRL_2_OFF_OUTBOUND_0, + (IATU_REGION_CTRL_2_OFF_OUTBOUND_0_REGION_EN | + IATU_ENABLE_CFG_SHIFT_FEATURE) + ); + } else { + MmioWrite32 (Dbi + IATU_REGION_CTRL_2_OFF_OUTBOUND_0, + IATU_REGION_CTRL_2_OFF_OUTBOUND_0_REGION_EN); + } } =20 /** @@ -293,12 +302,24 @@ PcieLsSetupAtu ( UINT64 Mem64End; UINT32 Index; =20 - Cfg0BaseAddr =3D Cfg0Base; - Cfg1BaseAddr =3D Cfg1Base; - Cfg0BusAddress =3D SEG_CFG_BUS; - Cfg1BusAddress =3D SEG_CFG_BUS; - Cfg0Size =3D SEG_CFG_SIZE; - Cfg1Size =3D SEG_CFG_SIZE; + if (CFG_SHIFT_ENABLE) { + DEBUG ((DEBUG_INFO, "PCIe: CFG Shift Method Enabled \n")); + Cfg0BaseAddr =3D Cfg0Base + SIZE_1MB; + Cfg1BaseAddr =3D Cfg0Base + SIZE_2MB; + Cfg0BusAddress =3D SIZE_1MB; + Cfg1BusAddress =3D SIZE_2MB; + // Region for type0 CFG transactions (only for bus1) + Cfg0Size =3D ECAM_BUS_SIZE; + // Region for type1 CFG transactions (for bus > 1) + Cfg1Size =3D (ECAM_CFG_REGION_SIZE - ECAM_BUS_SIZE); // 255MB + } else { + Cfg0BaseAddr =3D Cfg0Base; + Cfg1BaseAddr =3D Cfg1Base; + Cfg0BusAddress =3D SEG_CFG_BUS; + Cfg1BusAddress =3D SEG_CFG_BUS; + Cfg0Size =3D SEG_CFG_SIZE; + Cfg1Size =3D SEG_CFG_SIZE; + } =20 Index =3D 0; // iATU : OUTBOUND WINDOW 1 : CFG0 --=20 2.7.4