From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (NAM12-MW2-obe.outbound.protection.outlook.com [40.107.244.41]) by mx.groups.io with SMTP id smtpd.web12.3032.1629490512789175091 for ; Fri, 20 Aug 2021 13:15:13 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@vmware.com header.s=selector2 header.b=OM5BP7oT; spf=pass (domain: vmware.com, ip: 40.107.244.41, mailfrom: awarkentin@vmware.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Pi3maiwix8m/n5/OGRrQGYXT0LnDHfEN1RtMZ32wZ6KhIgntyGVkZvpEQux1XKM1kxQz92SlGbpDmLFdINj0TEO+QpH8NMFKcCx37gGFHSMBxWSbz42HvWyhB7Kehi99PDtNy6P4cqd2OLOg7wX2LEdPe3j58FxGZGCOZajjn/2EYIhrCIuCkNOEbg0VZPS+vGF4q/52MDbLD7rXfku2+FvMZ9g5fwiCK38t2ctdXzOSoCinp36/BN41Xx2b+DjPqWXNDyQbz3Em3yzaYcniddmAgXOZlM6fHtLyqsT3NqT8MnC7n7K/qobmgOE6NCfu5OyqNrrMTRDoT+SfLNcwFg== 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=6GRHQ7975fY8ouddM2qnkPa1uMfgXn12ZWCBOoyp1hs=; b=nIg5US9FtwOF/Snzf9NiDl/LM4QLL2dnoS4k0FzEBnWrvjob4p0Dd5M/KknxpF97yGQdAJxGZXAEvS44MeSDcs3V1DFP3gW/j9WFoInI9j32Awq93tuZp7OcwLTCGJCwWDH2V7zHqWtJmOK5DKvJC4ZVIgk2osAHjC3VeXR3fOFmvm6A6AgzbjmNsMr9gCliunQwdA75EyZEU7ZJpDBla3ikkalDfGkI45nk0G383W03weMEb9pSLVQLV+WC2i5iREgGG1mBiqXQaFgyRxMu7SD/CCvdUJcRGULSIimyk1hWCnzEu6cuTJQTattDoVIYfLrgG4rXjRjaw8bJvUbVpg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vmware.com; dmarc=pass action=none header.from=vmware.com; dkim=pass header.d=vmware.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vmware.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6GRHQ7975fY8ouddM2qnkPa1uMfgXn12ZWCBOoyp1hs=; b=OM5BP7oTuAwLswhW9iOQyehD/EdCGKOfiCNjOJ9+x1hANU1ot6b3K765q/x0zsv458BJh46UH53O3Zj6uay95dQNkCOVd6oDVr/6mbKomUK1o7tVhqNef5nmh0IIPCGXdJhAysxQ0yF2ifjg6fQYw2GN22ceFWbrxSsuyPdEUF0= Received: from PH0PR05MB8702.namprd05.prod.outlook.com (2603:10b6:510:b2::21) by PH0PR05MB8637.namprd05.prod.outlook.com (2603:10b6:510:b5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.5; Fri, 20 Aug 2021 20:15:08 +0000 Received: from PH0PR05MB8702.namprd05.prod.outlook.com ([fe80::c88e:73c1:db37:5b94]) by PH0PR05MB8702.namprd05.prod.outlook.com ([fe80::c88e:73c1:db37:5b94%6]) with mapi id 15.20.4457.005; Fri, 20 Aug 2021 20:15:08 +0000 From: "Andrei Warkentin" To: Jeremy Linton , "devel@edk2.groups.io" CC: "pete@akeo.ie" , "ardb+tianocore@kernel.org" , "Sunny.Wang@arm.com" , "samer.el-haj-mahmoud@arm.com" Subject: Re: [PATCH v3 3/7] Platform/RaspberryPi: Add PCIe SSDT Thread-Topic: [PATCH v3 3/7] Platform/RaspberryPi: Add PCIe SSDT Thread-Index: AQHXlXokf5exfMS80kiBWurPp6kpLKt81S7a Date: Fri, 20 Aug 2021 20:15:08 +0000 Message-ID: References: <20210820041619.87248-1-jeremy.linton@arm.com> <20210820041619.87248-4-jeremy.linton@arm.com> In-Reply-To: <20210820041619.87248-4-jeremy.linton@arm.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=vmware.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 3841a751-2b45-4053-0516-08d964173524 x-ms-traffictypediagnostic: PH0PR05MB8637: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8273; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: aAo9ursnhWnUqsxmja97vaj0Q/1O331sMotpQ1aftURVgFGGEaI9vW7vsckC7vJ/j5ki8TC8iB2FjK3NSAVekiNMySyKx20y7FvMIoALGphEy/SMGlarEgPglMKk+kK5eRTuKqYllpwL7zfhykykcb9sSTAOhBG7587YhVHQa6HLyAs4wUPHJ1eas72cQmZJocjk3MF3fMtFnRJwYbWsaFAUTLPPSA9LjCUNVX4Kz7uNYOJfERWVZkDJzmnxMXnDTXwJl2B70+szlWeovqe/GwYeiJAhe/ZhNcbbzibN9k/nZIiHKS9y3FSaTrR0j6ZHda3A0oUna26tspzPBdch1dEkF4qril7Bz7axsfqk0LaEnaOkKSIB5SZzFCd+jx7veby/LDITaOrIjdjeFHvH5Y7J+0pc2L9q8X0mZlv/PBh8XAO+qkHgtMWsOI/1pevmxMt8AXv9DHB6WEaVmMF+aTIywigDgrEN0F6O8MXn1wv6wWA34tQFAK8n8rZ6j0idZAFDRoAK/VluGfX1MxHuVgMsAdLwm59iuobHgniM1DrRfr1cNrnwalypvo/9zrE39tYM7nULBGdyYigdQpQ/gJleiwKmm13uSCuB/9K0NCGNzkzXbP1EjdSFzZJosKasvb1CKQ/eBonHS3TRHlWouGAMe5PsjhBTIW/Aq4lYE72WW7u+sKfemMqW07xWTC/M9c6Gv6O8KBFTR9Q8OLy8Kg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR05MB8702.namprd05.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(33656002)(71200400001)(26005)(8936002)(8676002)(38100700002)(54906003)(316002)(55016002)(4326008)(6506007)(64756008)(508600001)(5660300002)(38070700005)(186003)(122000001)(9686003)(53546011)(110136005)(66476007)(52536014)(66446008)(2906002)(7696005)(83380400001)(91956017)(76116006)(66946007)(86362001)(19627405001)(66556008);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?8hfO6zejaxqIpS/7Crt3/sjPl5R0sBm4zA84CWlpM76ZcME6vkz4NiFxn2MT?= =?us-ascii?Q?Wb2/VbdDFIPUIoHuHtACnzNybb45zPuCkRhmJ6lAIPTu9nkbdEd+PClzAeOY?= =?us-ascii?Q?pPH4S7F9OlykiyI0lGC3SEtaXXPP6D2scfF3FgEP0rw7vMFa1p9idC2ehCqm?= =?us-ascii?Q?JC9cN1U4gwcUwRB++5WxlLk7aUWBAHrJyVMEdbwO27r7ELh+i0NhMb+zwuek?= =?us-ascii?Q?OfUdwA6C4WkKKuhI8Cd+NHTSugLCaK2e+DXzYVil9liZH8ZdEwR8i0fDt2Ox?= =?us-ascii?Q?/6y5V4W080WPqp+VoaedtqbOB4VWSRmR9Dzy5PnlYH8te2rbzYHybqS/hhE0?= =?us-ascii?Q?kr+s9MLpSMbFgP3xPN/akV4mEPKzM4TMHHbFG+g0QYGx049wA4L2o4nRss60?= =?us-ascii?Q?C5qxj7yqEbOPC14uunhHORfoi3CXpagdobbWPh787EOy2Tu18wtvOHIS5DBr?= =?us-ascii?Q?92gPwOhP9kfXZNRjMC5lMWTVkBHZvMpsn/n/oKUi/glT5plb8KyGfc0kTeD+?= =?us-ascii?Q?oUug6mm0LEYe9JxAbdkJ4QHNPF+xqhf0xDNlystCSpBpHNJEY+8y1xpPx7Gv?= =?us-ascii?Q?aY9O+GJpI5i8CQNxOyh6xI5Tgr6SKTCcenecFyANdDDArKnR/FChWJndruDR?= =?us-ascii?Q?dQWA1VWgKIisb6bkCyVV5JWntCugspU0WI82LahOQ7FSPsHQiNNlD61QcWfq?= =?us-ascii?Q?OxN+NznxOLS0ltGATil5t2P9a2kCI1Y5bbr6DuCNWu+FFej8+Vp/pZnSjvdU?= =?us-ascii?Q?ADLJeiQBxFcLdM3/bew0OsGynTGsU1CdqJgztQDMdmNeAI5AUiHL5sT2CmxF?= =?us-ascii?Q?pL40v7hB8NqoYwtwFZarscIg1Rh/rKuFTUzByZhMb/03v30ZCB0/Jo04evoi?= =?us-ascii?Q?YGzJsg0zTZLSxTN/7I2K5749IHQnmX6rVBJIoCM/xxhjGkqhVIqH8irzsJ50?= =?us-ascii?Q?SBQpDc4KAZyPW6uY/7plxEJJoynICYTXv9NZLa3XfWCdqcdkF4xMSuYvhqmu?= =?us-ascii?Q?ShIwRc2hMCjWnz/F8cb40Ai+N0/1g1UxKwASTF9IsEYUNHWTW1MlbaeBR6+v?= =?us-ascii?Q?FE7Am+x45AOP9cAHRqFG7OOc71TS2IB0XALJjCgGKwwNwxvvEsw0wgXKd05n?= =?us-ascii?Q?4GkdKWPxjSmDjwlwrpjrca1e4gSdpq/YelQnWTchBjBDwX/7s5vllutfzAXf?= =?us-ascii?Q?urUgTYPmq2wbhnu5+c4/VOuECzkdaQGMLtXiGHoIOpGmDZC7o+iJGz7HEqYy?= =?us-ascii?Q?Ifn5lFqeH0ASCaKkmYOGiU4Xg/+hpXWCmqnn49O6UmkGaEdL+VtU5MDjaIlG?= =?us-ascii?Q?On54jOg+McWoxwo73ssbL7Sg?= x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH0PR05MB8702.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3841a751-2b45-4053-0516-08d964173524 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Aug 2021 20:15:08.6760 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: E433pOh6mRtyub7JIalTIjYPkozaA6arYvrK1OZ9DBNjO6qh+3JceQ4BeioXKdU6MqkzOZB89Pke/UiQTQ0k8w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR05MB8637 Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_PH0PR05MB870234EF953DA09650BDBD86B9C19PH0PR05MB8702namp_" --_000_PH0PR05MB870234EF953DA09650BDBD86B9C19PH0PR05MB8702namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Andrei Warkentin ________________________________ From: Jeremy Linton Sent: Thursday, August 19, 2021 11:16 PM To: devel@edk2.groups.io Cc: pete@akeo.ie ; ardb+tianocore@kernel.org ; Andrei Warkentin ; Sunny.Wang@arm.com <= Sunny.Wang@arm.com>; samer.el-haj-mahmoud@arm.com ; Jeremy Linton Subject: [PATCH v3 3/7] Platform/RaspberryPi: Add PCIe SSDT Since we plan on toggling between XHCI and PCI the PCI root needs to be in its own SSDT. This is all thats needed of UEFI. The SMC conduit is provided directly to the running OS. When the OS detects this PCIe port on a machine without a MCFG it attempts to connect to the SMC conduit. The RPi definition doesn't have any power mgmt, and only provides a description of the root port. Signed-off-by: Jeremy Linton --- Platform/RaspberryPi/AcpiTables/AcpiTables.inf | 3 + Platform/RaspberryPi/AcpiTables/Pci.asl | 161 +++++++++++++++++= ++++ Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c | 6 + 3 files changed, 170 insertions(+) create mode 100644 Platform/RaspberryPi/AcpiTables/Pci.asl diff --git a/Platform/RaspberryPi/AcpiTables/AcpiTables.inf b/Platform/Rasp= berryPi/AcpiTables/AcpiTables.inf index f3e8d950c1..da2a6db85f 100644 --- a/Platform/RaspberryPi/AcpiTables/AcpiTables.inf +++ b/Platform/RaspberryPi/AcpiTables/AcpiTables.inf @@ -39,6 +39,7 @@ Pptt.aslc SsdtThermal.asl Xhci.asl + Pci.asl [Packages] ArmPkg/ArmPkg.dec @@ -59,6 +60,8 @@ gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase gArmTokenSpaceGuid.PcdGicDistributorBase gBcm27xxTokenSpaceGuid.PcdBcm27xxPciCpuMmioAdr + gBcm27xxTokenSpaceGuid.PcdBcm27xxPciBusMmioAdr + gBcm27xxTokenSpaceGuid.PcdBcm27xxPciBusMmioLen gBcm27xxTokenSpaceGuid.PcdBcm27xxPciRegBase gBcm27xxTokenSpaceGuid.PcdBcmGenetRegistersAddress gBcm283xTokenSpaceGuid.PcdBcm283xRegistersAddress diff --git a/Platform/RaspberryPi/AcpiTables/Pci.asl b/Platform/RaspberryPi= /AcpiTables/Pci.asl new file mode 100644 index 0000000000..dc2bd7bc9e --- /dev/null +++ b/Platform/RaspberryPi/AcpiTables/Pci.asl @@ -0,0 +1,161 @@ +/** @file + * + * Copyright (c) 2019 Linaro, Limited. All rights reserved. + * Copyright (c) 2021 Arm + * + * SPDX-License-Identifier: BSD-2-Clause-Patent + * + **/ + +#include + +#include "AcpiTables.h" + +/* + * The following can be used to remove parenthesis from + * defined macros that the compiler complains about. + */ +#define ISOLATE_ARGS(...) __VA_ARGS__ +#define REMOVE_PARENTHESES(x) ISOLATE_ARGS x + +#define SANITIZED_PCIE_CPU_MMIO_WINDOW REMOVE_PARENTHESES(PCIE_CPU_MMIO_W= INDOW) +#define SANITIZED_PCIE_MMIO_LEN REMOVE_PARENTHESES(PCIE_BRIDGE_MMI= O_LEN) +#define SANITIZED_PCIE_PCI_MMIO_BEGIN REMOVE_PARENTHESES(PCIE_TOP_OF_MEM= _WIN) + +DefinitionBlock (__FILE__, "SSDT", 5, "RPIFDN", "RPI4PCIE", 2) +{ + Scope (\_SB_) + { + Device(PCI0) + { + Name(_HID, EISAID("PNP0A08")) // PCI Express Root Bridge + Name(_CID, EISAID("PNP0A03")) // Compatible PCI Root Bridge + Name(_SEG, Zero) // PCI Segment Group number + Name(_BBN, Zero) // PCI Base Bus Number + Name(_CCA, 0) // Mark the PCI noncoherent + + // PCIe can only DMA to first 3GB with early SOC's + // But we keep the restriction on the later ones + // To avoid DMA translation problems. + Name (_DMA, ResourceTemplate() { + QWordMemory (ResourceProducer, + , + MinFixed, + MaxFixed, + NonCacheable, + ReadWrite, + 0x0, + 0x0, // MIN + 0xbfffffff, // MAX + 0x0, // TRA + 0xc0000000, // LEN + , + , + ) + }) + + // PCI Routing Table + Name(_PRT, Package() { + Package (4) { 0x0000FFFF, 0, zero, 175 }, + Package (4) { 0x0000FFFF, 1, zero, 176 }, + Package (4) { 0x0000FFFF, 2, zero, 177 }, + Package (4) { 0x0000FFFF, 3, zero, 178 } + }) + + // Root complex resources + Method (_CRS, 0, Serialized) { + Name (RBUF, ResourceTemplate () { + + // bus numbers assigned to this root + WordBusNumber ( + ResourceProducer, + MinFixed, MaxFixed, PosDecode, + 0, // AddressGranularity + 0, // AddressMinimum - Minimum Bus Number + 255, // AddressMaximum - Maximum Bus Number + 0, // AddressTranslation - Set to 0 + 256 // RangeLength - Number of Busses + ) + + // 32-bit mmio window in 64-bit addr + QWordMemory ( + ResourceProducer, PosDecode, + MinFixed, MaxFixed, + NonCacheable, ReadWrite, // cacheable + 0x00000000, // Granularity + 0, // SANITIZED_PCIE_PCI_MMIO_BEG= IN + 1, // SANITIZED_PCIE_MMIO_LEN + S= ANITIZED_PCIE_PCI_MMIO_BEGIN + SANITIZED_PCIE_CPU_MMIO_WINDOW, // SANITIZED_PCIE_PCI_MMIO_BEG= IN - SANITIZED_PCIE_CPU_MMIO_WINDOW + 2 // SANITIZED_PCIE_MMIO_LEN + 1 + ,,,MMI1,,TypeTranslation + ) + + // root port registers, not to be used if SMCCC is utilized + QWordMemory ( + ResourceConsumer, , + MinFixed, MaxFixed, + NonCacheable, ReadWrite, // cacheable + 0x00000000, // Granularity + 0xFD500000, // Root port begin + 0xFD509FFF, // Root port end + 0x00000000, // no translation + 0x0000A000, // size + ,, + ) + }) // end Name(RBUF) + + // Work around ASL's inability to add in a resource definition + // or for that matter compute the min,max,len properly + CreateQwordField (RBUF, MMI1._MIN, MMIB) + CreateQwordField (RBUF, MMI1._MAX, MMIE) + CreateQwordField (RBUF, MMI1._TRA, MMIT) + CreateQwordField (RBUF, MMI1._LEN, MMIL) + Add (MMIB, SANITIZED_PCIE_PCI_MMIO_BEGIN, MMIB) + Add (SANITIZED_PCIE_MMIO_LEN, SANITIZED_PCIE_PCI_MMIO_BEGIN, MMIE) + Subtract (MMIT, SANITIZED_PCIE_PCI_MMIO_BEGIN, MMIT) + Add (SANITIZED_PCIE_MMIO_LEN, 1 , MMIL) + + Return (RBUF) + } // end Method(_CRS) + + // OS Control Handoff + Name(SUPP, Zero) // PCI _OSC Support Field value + Name(CTRL, Zero) // PCI _OSC Control Field value + + // See [1] 6.2.10, [2] 4.5 + Method(_OSC,4) { + // Note, This code is very similar to the code in the PCIe firmwar= e + // specification which can be used as a reference + // Check for proper UUID + If(LEqual(Arg0,ToUUID("33DB4D5B-1FF7-401C-9657-7441C03DD766"))) { + // Create DWord-adressable fields from the Capabilities Buffer + CreateDWordField(Arg3,0,CDW1) + CreateDWordField(Arg3,4,CDW2) + CreateDWordField(Arg3,8,CDW3) + // Save Capabilities DWord2 & 3 + Store(CDW2,SUPP) + Store(CDW3,CTRL) + // Mask out Native HotPlug + And(CTRL,0x1E,CTRL) + // Always allow native PME, AER (no dependencies) + // Never allow SHPC (no SHPC controller in this system) + And(CTRL,0x1D,CTRL) + + If(LNotEqual(Arg1,One)) { // Unknown revision + Or(CDW1,0x08,CDW1) + } + + If(LNotEqual(CDW3,CTRL)) { // Capabilities bits were masked + Or(CDW1,0x10,CDW1) + } + // Update DWORD3 in the buffer + Store(CTRL,CDW3) + Return(Arg3) + } Else { + Or(CDW1,4,CDW1) // Unrecognized UUID + Return(Arg3) + } + } // End _OSC + } // PCI0 + } //end scope sb +} //end definition block diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c b/Platform/= RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c index 7c5786303d..4c40820858 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c @@ -821,6 +821,12 @@ STATIC CONST NAMESPACE_TABLES SdtTables[] =3D { PcdToken(PcdXhciPci), NULL }, + { + SIGNATURE_64 ('R', 'P', 'I', '4', 'P', 'C', 'I', 'E'), + PcdToken(PcdXhciPci), + 0, + NULL + }, #endif { // DSDT SIGNATURE_64 ('R', 'P', 'I', 0, 0, 0, 0, 0), -- 2.13.7 --_000_PH0PR05MB870234EF953DA09650BDBD86B9C19PH0PR05MB8702namp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable
Reviewed-by: Andrei Warkentin <awarkentin@vmware.com>

From: Jeremy Linton <jer= emy.linton@arm.com>
Sent: Thursday, August 19, 2021 11:16 PM
To: devel@edk2.groups.io <devel@edk2.groups.io>
Cc: pete@akeo.ie <pete@akeo.ie>; ardb+tianocore@kernel.org <= ;ardb+tianocore@kernel.org>; Andrei Warkentin <awarkentin@vmware.com&= gt;; Sunny.Wang@arm.com <Sunny.Wang@arm.com>; samer.el-haj-mahmoud@ar= m.com <samer.el-haj-mahmoud@arm.com>; Jeremy Linton <jeremy.linton= @arm.com>
Subject: [PATCH v3 3/7] Platform/RaspberryPi: Add PCIe SSDT
 
Since we plan on toggling between XHCI and PCI the= PCI
root needs to be in its own SSDT. This is all thats needed
of UEFI. The SMC conduit is provided directly to the running
OS. When the OS detects this PCIe port on a machine without
a MCFG it attempts to connect to the SMC conduit. The RPi
definition doesn't have any power mgmt, and only provides
a description of the root port.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
---
 Platform/RaspberryPi/AcpiTables/AcpiTables.inf    = ; |   3 +
 Platform/RaspberryPi/AcpiTables/Pci.asl     =        | 161 +++++++++++++++++++++
 Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c |   6 +<= br>  3 files changed, 170 insertions(+)
 create mode 100644 Platform/RaspberryPi/AcpiTables/Pci.asl

diff --git a/Platform/RaspberryPi/AcpiTables/AcpiTables.inf b/Platform/Rasp= berryPi/AcpiTables/AcpiTables.inf
index f3e8d950c1..da2a6db85f 100644
--- a/Platform/RaspberryPi/AcpiTables/AcpiTables.inf
+++ b/Platform/RaspberryPi/AcpiTables/AcpiTables.inf
@@ -39,6 +39,7 @@
   Pptt.aslc
   SsdtThermal.asl
   Xhci.asl
+  Pci.asl
 
 [Packages]
   ArmPkg/ArmPkg.dec
@@ -59,6 +60,8 @@
   gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase
   gArmTokenSpaceGuid.PcdGicDistributorBase
   gBcm27xxTokenSpaceGuid.PcdBcm27xxPciCpuMmioAdr
+  gBcm27xxTokenSpaceGuid.PcdBcm27xxPciBusMmioAdr
+  gBcm27xxTokenSpaceGuid.PcdBcm27xxPciBusMmioLen
   gBcm27xxTokenSpaceGuid.PcdBcm27xxPciRegBase
   gBcm27xxTokenSpaceGuid.PcdBcmGenetRegistersAddress
   gBcm283xTokenSpaceGuid.PcdBcm283xRegistersAddress
diff --git a/Platform/RaspberryPi/AcpiTables/Pci.asl b/Platform/RaspberryPi= /AcpiTables/Pci.asl
new file mode 100644
index 0000000000..dc2bd7bc9e
--- /dev/null
+++ b/Platform/RaspberryPi/AcpiTables/Pci.asl
@@ -0,0 +1,161 @@
+/** @file
+ *
+ *  Copyright (c) 2019 Linaro, Limited. All rights reserved.
+ *  Copyright (c) 2021 Arm
+ *
+ *  SPDX-License-Identifier: BSD-2-Clause-Patent
+ *
+ **/
+
+#include <IndustryStandard/Bcm2711.h>
+
+#include "AcpiTables.h"
+
+/*
+ * The following can be used to remove parenthesis from
+ * defined macros that the compiler complains about.
+ */
+#define ISOLATE_ARGS(...)        &= nbsp;      __VA_ARGS__
+#define REMOVE_PARENTHESES(x)       &nb= sp;   ISOLATE_ARGS x
+
+#define SANITIZED_PCIE_CPU_MMIO_WINDOW  REMOVE_PARENTHESES(PCIE_CPU_M= MIO_WINDOW)
+#define SANITIZED_PCIE_MMIO_LEN       &= nbsp; REMOVE_PARENTHESES(PCIE_BRIDGE_MMIO_LEN)
+#define SANITIZED_PCIE_PCI_MMIO_BEGIN   REMOVE_PARENTHESES(PCIE_= TOP_OF_MEM_WIN)
+
+DefinitionBlock (__FILE__, "SSDT", 5, "RPIFDN", "= RPI4PCIE", 2)
+{
+  Scope (\_SB_)
+  {
+    Device(PCI0)
+    {
+      Name(_HID, EISAID("PNP0A08")) // = PCI Express Root Bridge
+      Name(_CID, EISAID("PNP0A03")) // = Compatible PCI Root Bridge
+      Name(_SEG, Zero) // PCI Segment Group numbe= r
+      Name(_BBN, Zero) // PCI Base Bus Number
+      Name(_CCA, 0)    // Mark the= PCI noncoherent
+
+      // PCIe can only DMA to first 3GB with earl= y SOC's
+      // But we keep the restriction on the later= ones
+      // To avoid DMA translation problems.
+      Name (_DMA, ResourceTemplate() {
+        QWordMemory (ResourceProducer,<= br> +          ,
+          MinFixed,
+          MaxFixed,
+          NonCacheable,
+          ReadWrite,
+          0x0,
+          0x0,  &nb= sp;     // MIN
+          0xbfffffff, // MAX<= br> +          0x0,  &nb= sp;     // TRA
+          0xc0000000, // LEN<= br> +          ,
+          ,
+          )
+      })
+
+      // PCI Routing Table
+      Name(_PRT, Package() {
+        Package (4) { 0x0000FFFF, 0, ze= ro, 175 },
+        Package (4) { 0x0000FFFF, 1, ze= ro, 176 },
+        Package (4) { 0x0000FFFF, 2, ze= ro, 177 },
+        Package (4) { 0x0000FFFF, 3, ze= ro, 178 }
+      })
+
+      // Root complex resources
+      Method (_CRS, 0, Serialized) {
+        Name (RBUF, ResourceTemplate ()= {
+
+          // bus numbers assi= gned to this root
+          WordBusNumber (
+            Resourc= eProducer,
+            MinFixe= d, MaxFixed, PosDecode,
+            0, = ;  // AddressGranularity
+            0, = ;  // AddressMinimum - Minimum Bus Number
+            255, //= AddressMaximum - Maximum Bus Number
+            0, = ;  // AddressTranslation - Set to 0
+            256&nbs= p; // RangeLength - Number of Busses
+          )
+
+          // 32-bit mmio wind= ow in 64-bit addr
+          QWordMemory (
+            Resourc= eProducer, PosDecode,
+            MinFixe= d, MaxFixed,
+            NonCach= eable, ReadWrite,        // cacheable +            0x00000= 000,            = ;         // Granularity
+            0, = ;            &n= bsp;            = ;    // SANITIZED_PCIE_PCI_MMIO_BEGIN
+            1, = ;            &n= bsp;            = ;    // SANITIZED_PCIE_MMIO_LEN + SANITIZED_PCIE_PCI_MMIO_BE= GIN
+            SANITIZ= ED_PCIE_CPU_MMIO_WINDOW, // SANITIZED_PCIE_PCI_MMIO_BEGIN - SANITIZED_PCIE_= CPU_MMIO_WINDOW
+            2 =             &nb= sp;            =      // SANITIZED_PCIE_MMIO_LEN + 1
+            ,,,MMI1= ,,TypeTranslation
+          )
+
+          // root port regist= ers, not to be used if SMCCC is utilized
+          QWordMemory (
+            Resourc= eConsumer, ,
+            MinFixe= d, MaxFixed,
+            NonCach= eable, ReadWrite,        // cacheable +            0x00000= 000,            = ;         // Granularity
+            0xFD500= 000,            = ;         // Root port begin
+            0xFD509= FFF,            = ;         // Root port end
+            0x00000= 000,            = ;         // no translation
+            0x0000A= 000,            = ;         // size
+            ,,
+          )
+        }) // end Name(RBUF)
+
+        // Work around ASL's inability = to add in a resource definition
+        // or for that matter compute t= he min,max,len properly
+        CreateQwordField (RBUF, MMI1._M= IN, MMIB)
+        CreateQwordField (RBUF, MMI1._M= AX, MMIE)
+        CreateQwordField (RBUF, MMI1._T= RA, MMIT)
+        CreateQwordField (RBUF, MMI1._L= EN, MMIL)
+        Add (MMIB, SANITIZED_PCIE_PCI_M= MIO_BEGIN, MMIB)
+        Add (SANITIZED_PCIE_MMIO_LEN, S= ANITIZED_PCIE_PCI_MMIO_BEGIN, MMIE)
+        Subtract (MMIT, SANITIZED_PCIE_= PCI_MMIO_BEGIN, MMIT)
+        Add (SANITIZED_PCIE_MMIO_LEN, 1= , MMIL)
+
+        Return (RBUF)
+      } // end Method(_CRS)
+
+      // OS Control Handoff
+      Name(SUPP, Zero) // PCI _OSC Support Field = value
+      Name(CTRL, Zero) // PCI _OSC Control Field = value
+
+      // See [1] 6.2.10, [2] 4.5
+      Method(_OSC,4) {
+        // Note, This code is very simi= lar to the code in the PCIe firmware
+        // specification which can be u= sed as a reference
+        // Check for proper UUID
+        If(LEqual(Arg0,ToUUID("33D= B4D5B-1FF7-401C-9657-7441C03DD766"))) {
+          // Create DWord-adr= essable fields from the Capabilities Buffer
+          CreateDWordField(Ar= g3,0,CDW1)
+          CreateDWordField(Ar= g3,4,CDW2)
+          CreateDWordField(Ar= g3,8,CDW3)
+          // Save Capabilitie= s DWord2 & 3
+          Store(CDW2,SUPP) +          Store(CDW3,CTRL) +          // Mask out Native = HotPlug
+          And(CTRL,0x1E,CTRL)=
+          // Always allow nat= ive PME, AER (no dependencies)
+          // Never allow SHPC= (no SHPC controller in this system)
+          And(CTRL,0x1D,CTRL)=
+
+          If(LNotEqual(Arg1,O= ne)) { // Unknown revision
+            Or(CDW1= ,0x08,CDW1)
+          }
+
+          If(LNotEqual(CDW3,C= TRL)) {  // Capabilities bits were masked
+            Or(CDW1= ,0x10,CDW1)
+          }
+          // Update DWORD3 in= the buffer
+          Store(CTRL,CDW3) +          Return(Arg3)
+        } Else {
+          Or(CDW1,4,CDW1) // = Unrecognized UUID
+          Return(Arg3)
+        }
+      } // End _OSC
+    } // PCI0
+  } //end scope sb
+} //end definition block
diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c b/Platform/= RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
index 7c5786303d..4c40820858 100644
--- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
+++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
@@ -821,6 +821,12 @@ STATIC CONST NAMESPACE_TABLES SdtTables[] =3D {
     PcdToken(PcdXhciPci),
     NULL
   },
+  {
+    SIGNATURE_64 ('R', 'P', 'I', '4', 'P', 'C', 'I', 'E'),<= br> +    PcdToken(PcdXhciPci),
+    0,
+    NULL
+  },
 #endif
   { // DSDT
     SIGNATURE_64 ('R', 'P', 'I', 0, 0, 0, 0, 0),
--
2.13.7

--_000_PH0PR05MB870234EF953DA09650BDBD86B9C19PH0PR05MB8702namp_--