public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-platforms][PATCH 00/15] Platform/RPi: Clean up and factorize ACPI
@ 2020-02-28 10:38 Pete Batard
  2020-02-28 10:38 ` [edk2-platforms][PATCH 01/15] Platform/RPi: Move DW USB base address to Silicon Pete Batard
                   ` (15 more replies)
  0 siblings, 16 replies; 23+ messages in thread
From: Pete Batard @ 2020-02-28 10:38 UTC (permalink / raw)
  To: devel; +Cc: ard.biesheuvel, leif, philmd

Most of the ACPI sources being used for the Raspberry Pi 4 are
actually very similar to the Raspberty Pi 3 ones, barring a few
constant changes (base addresses, interrupts) or leftover binary
blobs that could be converted to formal ASLC.

As a result, with the goal of simplifying maintenance as well as
helping make the ACPI differences between the two platforms more
prominent, we see it as a very desireable effort to try to merge
the two separate AcpiTables section into a common factorized one.

This patch series accomplishes just that by:
* Removing the hardcoded numeric values from the ACPI tables and
  moving them to more appropriate headers.
* Cleaning up the existing ACPI tables and removing most of the
  leftover binary blobs.
* Adding a small amount of block conditionals needed to ensure
  that our ACPI tables can serve both platforms.
* Factorizing the now common ACPI code.

The commits from this patchset can also be viewed on GitHub at:
https://github.com/pftf/edk2-platforms/commits/acpi_factorization

Pete Batard (15):
  Platform/RPi: Move DW USB base address to Silicon
  Silicon/Bcm283x: Add missing peripherals constants
  Silicon/Bcm283x: Add GPU/VideoCore and Power Management constants
  Silicon/BcmGenet: Add missing I/O mapping length and clean up
  Platform/RPi4: Use Silicon constants in ACPI headers
  Platform/RPi3: Use Silicon constants in ACPI headers
  Platform/RPi3: Switch to .aslc for serial related ACPI tables
  Platform/RPi3: Update CSRT table to ACPI 5.1
  Platform/RPi3: Use proper aslc for FADT, GTDT and MADT tables
    generation
  Platform/RPi4: Add RPI_MODEL constant and replace PL011_ENABLE
  Platform/RPi4: Move ACPI interrupts definitions to AcpiTables.h
  Platform/RPi3: Move ACPI interrupts definitions to AcpiTables.h
  Platform/RPi4: Prepare ACPI code for factorization
  Platform/RPi3: Merge ACPI code from RPi4
  Platform/RPi: Factorize ACPI tables

 Platform/RaspberryPi/AcpiTables/AcpiTables.h                      | 164 ++++++
 Platform/RaspberryPi/{RPi4 => }/AcpiTables/AcpiTables.inf         |   9 +-
 Platform/RaspberryPi/{RPi4 => }/AcpiTables/Csrt.aslc              |   7 +-
 Platform/RaspberryPi/{RPi4 => }/AcpiTables/Dbg2.aslc              |   2 +-
 Platform/RaspberryPi/AcpiTables/Dsdt.asl                          | 567 ++++++++++++++++++++
 Platform/RaspberryPi/{RPi4 => }/AcpiTables/Fadt.aslc              |   0
 Platform/RaspberryPi/{RPi4 => }/AcpiTables/Gtdt.aslc              |   1 -
 Platform/RaspberryPi/{RPi4 => }/AcpiTables/Madt.aslc              |  15 +
 Platform/RaspberryPi/{RPi4 => }/AcpiTables/Pep.asl                |   0
 Platform/RaspberryPi/{RPi4 => }/AcpiTables/Pep.c                  |   0
 Platform/RaspberryPi/{RPi4 => }/AcpiTables/Pep.h                  |   0
 Platform/RaspberryPi/{RPi3 => }/AcpiTables/Rhpx.asl               |   0
 Platform/RaspberryPi/{RPi4 => }/AcpiTables/Sdhc.asl               |  32 +-
 Platform/RaspberryPi/{RPi4 => }/AcpiTables/Spcr.aslc              |   3 +-
 Platform/RaspberryPi/{RPi4 => }/AcpiTables/Uart.asl               |  79 +--
 Platform/RaspberryPi/{RPi4 => }/AcpiTables/Xhci.asl               |   2 +
 Platform/RaspberryPi/Drivers/DwUsbHostDxe/DwUsbHostDxe.c          |   3 +-
 Platform/RaspberryPi/Drivers/DwUsbHostDxe/DwcHw.h                 |   6 +-
 Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.h                 |  76 ---
 Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.inf               |  40 --
 Platform/RaspberryPi/RPi3/AcpiTables/Csrt.aslc                    | 326 -----------
 Platform/RaspberryPi/RPi3/AcpiTables/Dbg2.aslc                    |  28 -
 Platform/RaspberryPi/RPi3/AcpiTables/Dsdt.asl                     | 505 -----------------
 Platform/RaspberryPi/RPi3/AcpiTables/Fadt.aslc                    |  46 --
 Platform/RaspberryPi/RPi3/AcpiTables/Gtdt.aslc                    |  27 -
 Platform/RaspberryPi/RPi3/AcpiTables/Madt.aslc                    |  56 --
 Platform/RaspberryPi/RPi3/AcpiTables/Pep.asl                      |  89 ---
 Platform/RaspberryPi/RPi3/AcpiTables/Pep.c                        |  78 ---
 Platform/RaspberryPi/RPi3/AcpiTables/Pep.h                        | 120 -----
 Platform/RaspberryPi/RPi3/AcpiTables/Sdhc.asl                     |  99 ----
 Platform/RaspberryPi/RPi3/AcpiTables/Spcr.asl                     |  47 --
 Platform/RaspberryPi/RPi3/AcpiTables/Uart.asl                     | 152 ------
 Platform/RaspberryPi/RPi3/RPi3.dsc                                |  10 +-
 Platform/RaspberryPi/RPi3/RPi3.fdf                                |   2 +-
 Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.h                 |  92 ----
 Platform/RaspberryPi/RPi4/AcpiTables/Dsdt.asl                     | 535 ------------------
 Platform/RaspberryPi/RPi4/AcpiTables/Rhpx.asl                     | 195 -------
 Platform/RaspberryPi/RPi4/RPi4.dsc                                |   6 +-
 Platform/RaspberryPi/RPi4/RPi4.fdf                                |   2 +-
 Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h       |  46 +-
 Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836Gpio.h   |   6 +-
 Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836Gpu.h    |  48 ++
 Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836Pwm.h    |  34 ++
 Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836SdHost.h |   6 +-
 Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836Sdio.h   |  44 +-
 Silicon/Broadcom/Drivers/Net/BcmGenetDxe/Genet.h                  |   3 +-
 Silicon/Broadcom/Drivers/Net/BcmNet.dec                           |   3 +
 47 files changed, 1000 insertions(+), 2611 deletions(-)
 create mode 100644 Platform/RaspberryPi/AcpiTables/AcpiTables.h
 rename Platform/RaspberryPi/{RPi4 => }/AcpiTables/AcpiTables.inf (82%)
 rename Platform/RaspberryPi/{RPi4 => }/AcpiTables/Csrt.aslc (94%)
 rename Platform/RaspberryPi/{RPi4 => }/AcpiTables/Dbg2.aslc (97%)
 create mode 100644 Platform/RaspberryPi/AcpiTables/Dsdt.asl
 rename Platform/RaspberryPi/{RPi4 => }/AcpiTables/Fadt.aslc (100%)
 rename Platform/RaspberryPi/{RPi4 => }/AcpiTables/Gtdt.aslc (95%)
 rename Platform/RaspberryPi/{RPi4 => }/AcpiTables/Madt.aslc (74%)
 rename Platform/RaspberryPi/{RPi4 => }/AcpiTables/Pep.asl (100%)
 rename Platform/RaspberryPi/{RPi4 => }/AcpiTables/Pep.c (100%)
 rename Platform/RaspberryPi/{RPi4 => }/AcpiTables/Pep.h (100%)
 rename Platform/RaspberryPi/{RPi3 => }/AcpiTables/Rhpx.asl (100%)
 rename Platform/RaspberryPi/{RPi4 => }/AcpiTables/Sdhc.asl (64%)
 rename Platform/RaspberryPi/{RPi4 => }/AcpiTables/Spcr.aslc (95%)
 rename Platform/RaspberryPi/{RPi4 => }/AcpiTables/Uart.asl (62%)
 rename Platform/RaspberryPi/{RPi4 => }/AcpiTables/Xhci.asl (96%)
 delete mode 100644 Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.h
 delete mode 100644 Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.inf
 delete mode 100644 Platform/RaspberryPi/RPi3/AcpiTables/Csrt.aslc
 delete mode 100644 Platform/RaspberryPi/RPi3/AcpiTables/Dbg2.aslc
 delete mode 100644 Platform/RaspberryPi/RPi3/AcpiTables/Dsdt.asl
 delete mode 100644 Platform/RaspberryPi/RPi3/AcpiTables/Fadt.aslc
 delete mode 100644 Platform/RaspberryPi/RPi3/AcpiTables/Gtdt.aslc
 delete mode 100644 Platform/RaspberryPi/RPi3/AcpiTables/Madt.aslc
 delete mode 100644 Platform/RaspberryPi/RPi3/AcpiTables/Pep.asl
 delete mode 100644 Platform/RaspberryPi/RPi3/AcpiTables/Pep.c
 delete mode 100644 Platform/RaspberryPi/RPi3/AcpiTables/Pep.h
 delete mode 100644 Platform/RaspberryPi/RPi3/AcpiTables/Sdhc.asl
 delete mode 100644 Platform/RaspberryPi/RPi3/AcpiTables/Spcr.asl
 delete mode 100644 Platform/RaspberryPi/RPi3/AcpiTables/Uart.asl
 delete mode 100644 Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.h
 delete mode 100644 Platform/RaspberryPi/RPi4/AcpiTables/Dsdt.asl
 delete mode 100644 Platform/RaspberryPi/RPi4/AcpiTables/Rhpx.asl
 create mode 100644 Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836Gpu.h
 create mode 100644 Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836Pwm.h

-- 
2.21.0.windows.1


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [edk2-platforms][PATCH 01/15] Platform/RPi: Move DW USB base address to Silicon
  2020-02-28 10:38 [edk2-platforms][PATCH 00/15] Platform/RPi: Clean up and factorize ACPI Pete Batard
@ 2020-02-28 10:38 ` Pete Batard
  2020-03-02 11:21   ` Philippe Mathieu-Daudé
  2020-02-28 10:38 ` [edk2-platforms][PATCH 02/15] Silicon/Bcm283x: Add missing peripherals constants Pete Batard
                   ` (14 subsequent siblings)
  15 siblings, 1 reply; 23+ messages in thread
From: Pete Batard @ 2020-02-28 10:38 UTC (permalink / raw)
  To: devel; +Cc: ard.biesheuvel, leif, philmd

The official BCM2835 ARM Peripherals guide lists the DW USB
controller as standard SoC device.
Treat is as such by adding its base address to Silicon.

Signed-off-by: Pete Batard <pete@akeo.ie>
---
 Platform/RaspberryPi/Drivers/DwUsbHostDxe/DwUsbHostDxe.c    | 3 ++-
 Platform/RaspberryPi/Drivers/DwUsbHostDxe/DwcHw.h           | 6 +-----
 Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h | 5 +++++
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/Platform/RaspberryPi/Drivers/DwUsbHostDxe/DwUsbHostDxe.c b/Platform/RaspberryPi/Drivers/DwUsbHostDxe/DwUsbHostDxe.c
index 37ebf503fd60..4f6f60b1eb5f 100644
--- a/Platform/RaspberryPi/Drivers/DwUsbHostDxe/DwUsbHostDxe.c
+++ b/Platform/RaspberryPi/Drivers/DwUsbHostDxe/DwUsbHostDxe.c
@@ -7,6 +7,7 @@
  *
  **/
 
+#include <IndustryStandard/Bcm2836.h>
 #include "DwUsbHostDxe.h"
 #include "DwcHw.h"
 
@@ -1548,7 +1549,7 @@ CreateDwUsbHc (
   DwHc->DwUsbOtgHc.ClearRootHubPortFeature        = DwHcClearRootHubPortFeature;
   DwHc->DwUsbOtgHc.MajorRevision                  = 0x02;
   DwHc->DwUsbOtgHc.MinorRevision                  = 0x00;
-  DwHc->DwUsbBase                                 = DW2_USB_BASE_ADDRESS;
+  DwHc->DwUsbBase                                 = BCM2836_USB_BASE_ADDRESS;
 
   Pages = EFI_SIZE_TO_PAGES (DWC2_STATUS_BUF_SIZE);
   DwHc->StatusBuffer = AllocatePages (Pages);
diff --git a/Platform/RaspberryPi/Drivers/DwUsbHostDxe/DwcHw.h b/Platform/RaspberryPi/Drivers/DwUsbHostDxe/DwcHw.h
index ddbf69a1d608..12fbde9ff6f2 100644
--- a/Platform/RaspberryPi/Drivers/DwUsbHostDxe/DwcHw.h
+++ b/Platform/RaspberryPi/Drivers/DwUsbHostDxe/DwcHw.h
@@ -10,11 +10,7 @@
 #ifndef __DWCHW_H__
 #define __DWCHW_H__
 
-#define DW2_USB_OFFSET                  0x00980000
-#define DW2_USB_BASE_ADDRESS            (FixedPcdGet64 (PcdBcm283xRegistersAddress) \
-                                        + DW2_USB_OFFSET)
-
-#define HSOTG_REG(x)    (x)
+#define HSOTG_REG(x)                    (x)
 
 #define HCCHAR(_ch)                     HSOTG_REG(0x0500 + 0x20 * (_ch))
 #define HCSPLT(_ch)                     HSOTG_REG(0x0504 + 0x20 * (_ch))
diff --git a/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h b/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h
index 7ba4877337a8..cee5fb6a4e15 100644
--- a/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h
+++ b/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h
@@ -70,6 +70,11 @@
 #define BCM2836_INTC_TIMER_CONTROL_OFFSET                   0x00000040
 #define BCM2836_INTC_TIMER_PENDING_OFFSET                   0x00000060
 
+/* usb constants */
+#define BCM2836_USB_OFFSET                                  0x00980000
+#define BCM2836_USB_BASE_ADDRESS                            (BCM2836_SOC_REGISTERS + BCM2836_USB_OFFSET)
+#define BCM2836_USB_LENGTH                                  0x00010000
+
 /* uart constants */
 #define BCM2836_PL011_UART_OFFSET                           0x00201000
 #define BCM2836_PL011_UART_BASE_ADDRESS                     (BCM2836_SOC_REGISTERS + BCM2836_PL011_UART_OFFSET)
-- 
2.21.0.windows.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [edk2-platforms][PATCH 02/15] Silicon/Bcm283x: Add missing peripherals constants
  2020-02-28 10:38 [edk2-platforms][PATCH 00/15] Platform/RPi: Clean up and factorize ACPI Pete Batard
  2020-02-28 10:38 ` [edk2-platforms][PATCH 01/15] Platform/RPi: Move DW USB base address to Silicon Pete Batard
@ 2020-02-28 10:38 ` Pete Batard
  2020-02-28 10:38 ` [edk2-platforms][PATCH 03/15] Silicon/Bcm283x: Add GPU/VideoCore and Power Management constants Pete Batard
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 23+ messages in thread
From: Pete Batard @ 2020-02-28 10:38 UTC (permalink / raw)
  To: devel; +Cc: ard.biesheuvel, leif, philmd

In order to be able to reference them in ACPI tables and elsewhere
we add some missing constants to be the Bcm283x headers.
These include:
* I2C, SPI and DMA constants
* Length of the peripherals register space

We also take this opportunity to clean up and harmonize the headers.

Signed-off-by: Pete Batard <pete@akeo.ie>
---
 Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h       | 39 ++++++++++++++++-
 Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836Gpio.h   |  6 ++-
 Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836SdHost.h |  6 ++-
 Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836Sdio.h   | 44 ++++++++++----------
 4 files changed, 71 insertions(+), 24 deletions(-)

diff --git a/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h b/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h
index cee5fb6a4e15..0b402e9ac56e 100644
--- a/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h
+++ b/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h
@@ -56,6 +56,7 @@
 /* mailbox interface constants */
 #define BCM2836_MBOX_OFFSET                                 0x0000b880
 #define BCM2836_MBOX_BASE_ADDRESS                           (BCM2836_SOC_REGISTERS + BCM2836_MBOX_OFFSET)
+#define BCM2836_MBOX_LENGTH                                 0x00000024
 #define BCM2836_MBOX_READ_OFFSET                            0x00000000
 #define BCM2836_MBOX_STATUS_OFFSET                          0x00000018
 #define BCM2836_MBOX_CONFIG_OFFSET                          0x0000001c
@@ -75,7 +76,7 @@
 #define BCM2836_USB_BASE_ADDRESS                            (BCM2836_SOC_REGISTERS + BCM2836_USB_OFFSET)
 #define BCM2836_USB_LENGTH                                  0x00010000
 
-/* uart constants */
+/* serial based protocol constants */
 #define BCM2836_PL011_UART_OFFSET                           0x00201000
 #define BCM2836_PL011_UART_BASE_ADDRESS                     (BCM2836_SOC_REGISTERS + BCM2836_PL011_UART_OFFSET)
 #define BCM2836_PL011_UART_LENGTH                           0x00001000
@@ -86,4 +87,40 @@
 #define BCM2836_MINI_UART_LENGTH                            0x00000070
 #define BCM2836_MINI_UART_INTERRUPT                         0x7D
 
+#define BCM2836_I2C0_OFFSET                                 0x00205000
+#define BCM2836_I2C0_BASE_ADDRESS                           (BCM2836_SOC_REGISTERS + BCM2836_I2C0_OFFSET)
+#define BCM2836_I2C0_LENGTH                                 0x00000020
+
+#define BCM2836_I2C1_OFFSET                                 0x00804000
+#define BCM2836_I2C1_BASE_ADDRESS                           (BCM2836_SOC_REGISTERS + BCM2836_I2C1_OFFSET)
+#define BCM2836_I2C1_LENGTH                                 0x00000020
+
+#define BCM2836_I2C2_OFFSET                                 0x00805000
+#define BCM2836_I2C2_BASE_ADDRESS                           (BCM2836_SOC_REGISTERS + BCM2836_I2C2_OFFSET)
+#define BCM2836_I2C2_LENGTH                                 0x00000020
+
+#define BCM2836_SPI0_OFFSET                                 0x00204000
+#define BCM2836_SPI0_BASE_ADDRESS                           (BCM2836_SOC_REGISTERS + BCM2836_SPI0_OFFSET)
+#define BCM2836_SPI0_LENGTH                                 0x00000020
+
+#define BCM2836_SPI1_OFFSET                                 0x00215080
+#define BCM2836_SPI1_LENGTH                                 0x00000040
+#define BCM2836_SPI1_BASE_ADDRESS                           (BCM2836_SOC_REGISTERS + BCM2836_SPI1_OFFSET)
+
+#define BCM2836_SPI2_OFFSET                                 0x002150C0
+#define BCM2836_SPI2_LENGTH                                 0x00000040
+#define BCM2836_SPI2_BASE_ADDRESS                           (BCM2836_SOC_REGISTERS + BCM2836_SPI2_OFFSET)
+
+/* dma constants */
+#define BCM2836_DMA0_OFFSET                                 0x00007000
+#define BCM2836_DMA0_BASE_ADDRESS                           (BCM2836_SOC_REGISTERS + BCM2836_DMA0_OFFSET)
+
+#define BCM2836_DMA15_OFFSET                                0x00E05000
+#define BCM2836_DMA15_BASE_ADDRESS                          (BCM2836_SOC_REGISTERS + BCM2836_DMA15_OFFSET)
+
+#define BCM2836_DMA_CTRL_OFFSET                             0x00007FE0
+#define BCM2836_DMA_CTRL_BASE_ADDRESS                       (BCM2836_SOC_REGISTERS + BCM2836_DMA_CTRL_OFFSET)
+
+#define BCM2836_DMA_CHANNEL_LENGTH                          0x00000100
+
 #endif /*__BCM2836_H__ */
diff --git a/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836Gpio.h b/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836Gpio.h
index 123de2c2d1ad..e65cc5c3bbb4 100644
--- a/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836Gpio.h
+++ b/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836Gpio.h
@@ -7,10 +7,14 @@
  *
  **/
 
+#include <IndustryStandard/Bcm2836.h>
+
 #ifndef __BCM2836_GPIO_H__
 #define __BCM2836_GPIO_H__
 
-#define GPIO_BASE_ADDRESS  (BCM2836_SOC_REGISTERS + 0x00200000)
+#define GPIO_OFFSET        0x00200000
+#define GPIO_BASE_ADDRESS  (BCM2836_SOC_REGISTERS + GPIO_OFFSET)
+#define GPIO_LENGTH        0x000000B4
 
 #define GPIO_GPFSEL0       (GPIO_BASE_ADDRESS + 0x00)
 #define GPIO_GPFSEL1       (GPIO_BASE_ADDRESS + 0x04)
diff --git a/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836SdHost.h b/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836SdHost.h
index d0492a4ff43d..83fbeb99cb35 100644
--- a/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836SdHost.h
+++ b/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836SdHost.h
@@ -7,10 +7,14 @@
  *
  **/
 
+#include <IndustryStandard/Bcm2836.h>
+
 #ifndef __BCM2836_SDHOST_H__
 #define __BCM2836_SDHOST_H__
 
-#define SDHOST_BASE_ADDRESS         (BCM2836_SOC_REGISTERS + 0x00202000)
+#define SDHOST_OFFSET               0x00202000
+#define SDHOST_BASE_ADDRESS         (BCM2836_SOC_REGISTERS + SDHOST_OFFSET)
+#define SDHOST_LENGTH               0x00000100
 #define SDHOST_REG(X)               (SDHOST_BASE_ADDRESS + (X))
 #define SDHOST_CMD                  SDHOST_REG(0x0)
 #define SDHOST_ARG                  SDHOST_REG(0x4)
diff --git a/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836Sdio.h b/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836Sdio.h
index 708a1d7a4f47..fd07b4717068 100644
--- a/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836Sdio.h
+++ b/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836Sdio.h
@@ -6,20 +6,22 @@
  *
  **/
 
+#include <IndustryStandard/Bcm2836.h>
+
 #ifndef __BCM2836_SDIO_H__
 #define __BCM2836_SDIO_H__
 
-//MMC/SD/SDIO1 register definitions.
+// MMC/SD/SDIO1 register definitions.
 #define MMCHS1_OFFSET     0x00300000
-#define MMCHS1BASE        (FixedPcdGet64 (PcdBcm283xRegistersAddress) \
-                          + MMCHS1_OFFSET)
+#define MMCHS1_BASE       (BCM2836_SOC_REGISTERS + MMCHS1_OFFSET)
+#define MMCHS1_LENGTH     0x00000100
 
-#define MMCHS_BLK         (MMCHS1BASE + 0x4)
+#define MMCHS_BLK         (MMCHS1_BASE + 0x4)
 #define BLEN_512BYTES     (0x200UL << 0)
 
-#define MMCHS_ARG         (MMCHS1BASE + 0x8)
+#define MMCHS_ARG         (MMCHS1_BASE + 0x8)
 
-#define MMCHS_CMD         (MMCHS1BASE + 0xC)
+#define MMCHS_CMD         (MMCHS1_BASE + 0xC)
 #define BCE_ENABLE        BIT1
 #define DDIR_READ         BIT4
 #define DDIR_WRITE        (0x0UL << 4)
@@ -41,13 +43,13 @@
 #define INDX(CMD_INDX)       (TYPE(CMD_TYPE_NORMAL) | _INDX(CMD_INDX))
 #define INDX_ABORT(CMD_INDX) (TYPE(CMD_TYPE_ABORT) | _INDX(CMD_INDX))
 
-#define MMCHS_RSP10       (MMCHS1BASE + 0x10)
-#define MMCHS_RSP32       (MMCHS1BASE + 0x14)
-#define MMCHS_RSP54       (MMCHS1BASE + 0x18)
-#define MMCHS_RSP76       (MMCHS1BASE + 0x1C)
-#define MMCHS_DATA        (MMCHS1BASE + 0x20)
+#define MMCHS_RSP10       (MMCHS1_BASE + 0x10)
+#define MMCHS_RSP32       (MMCHS1_BASE + 0x14)
+#define MMCHS_RSP54       (MMCHS1_BASE + 0x18)
+#define MMCHS_RSP76       (MMCHS1_BASE + 0x1C)
+#define MMCHS_DATA        (MMCHS1_BASE + 0x20)
 
-#define MMCHS_PRES_STATE  (MMCHS1BASE + 0x24)
+#define MMCHS_PRES_STATE  (MMCHS1_BASE + 0x24)
 #define CMDI_MASK         BIT0
 #define CMDI_ALLOWED      (0x0UL << 0)
 #define CMDI_NOT_ALLOWED  BIT0
@@ -56,7 +58,7 @@
 #define DATI_NOT_ALLOWED  BIT1
 #define WRITE_PROTECT_OFF BIT19
 
-#define MMCHS_HCTL        (MMCHS1BASE + 0x28)
+#define MMCHS_HCTL        (MMCHS1_BASE + 0x28)
 #define DTW_1_BIT         (0x0UL << 1)
 #define DTW_4_BIT         BIT1
 #define SDBP_MASK         BIT8
@@ -66,7 +68,7 @@
 #define SDVS_3_0_V        (0x6UL << 9)
 #define IWE               BIT24
 
-#define MMCHS_SYSCTL      (MMCHS1BASE + 0x2C)
+#define MMCHS_SYSCTL      (MMCHS1_BASE + 0x2C)
 #define ICE               BIT0
 #define ICS_MASK          BIT1
 #define ICS               BIT1
@@ -82,7 +84,7 @@
 #define SRC               BIT25
 #define SRD               BIT26
 
-#define MMCHS_INT_STAT    (MMCHS1BASE + 0x30)
+#define MMCHS_INT_STAT    (MMCHS1_BASE + 0x30)
 #define CC                BIT0
 #define TC                BIT1
 #define BWR               BIT4
@@ -94,7 +96,7 @@
 #define DCRC              BIT21
 #define DEB               BIT22
 
-#define MMCHS_IE          (MMCHS1BASE + 0x34)
+#define MMCHS_IE          (MMCHS1_BASE + 0x34)
 #define CC_EN             BIT0
 #define TC_EN             BIT1
 #define BWR_EN            BIT4
@@ -110,7 +112,7 @@
 #define BADA_EN           BIT29
 #define ALL_EN            0xFFFFFFFF
 
-#define MMCHS_ISE         (MMCHS1BASE + 0x38)
+#define MMCHS_ISE         (MMCHS1_BASE + 0x38)
 #define CC_SIGEN          BIT0
 #define TC_SIGEN          BIT1
 #define BWR_SIGEN         BIT4
@@ -125,14 +127,14 @@
 #define CERR_SIGEN        BIT28
 #define BADA_SIGEN        BIT29
 
-#define MMCHS_AC12        (MMCHS1BASE + 0x3C)
+#define MMCHS_AC12        (MMCHS1_BASE + 0x3C)
 
-#define MMCHS_CAPA        (MMCHS1BASE + 0x40)
+#define MMCHS_CAPA        (MMCHS1_BASE + 0x40)
 #define VS30              BIT25
 #define VS18              BIT26
 
-#define MMCHS_CUR_CAPA    (MMCHS1BASE + 0x48)
-#define MMCHS_REV         (MMCHS1BASE + 0xFC)
+#define MMCHS_CUR_CAPA    (MMCHS1_BASE + 0x48)
+#define MMCHS_REV         (MMCHS1_BASE + 0xFC)
 
 #define BLOCK_COUNT_SHIFT 16
 #define RCA_SHIFT         16
-- 
2.21.0.windows.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [edk2-platforms][PATCH 03/15] Silicon/Bcm283x: Add GPU/VideoCore and Power Management constants
  2020-02-28 10:38 [edk2-platforms][PATCH 00/15] Platform/RPi: Clean up and factorize ACPI Pete Batard
  2020-02-28 10:38 ` [edk2-platforms][PATCH 01/15] Platform/RPi: Move DW USB base address to Silicon Pete Batard
  2020-02-28 10:38 ` [edk2-platforms][PATCH 02/15] Silicon/Bcm283x: Add missing peripherals constants Pete Batard
@ 2020-02-28 10:38 ` Pete Batard
  2020-02-28 10:38 ` [edk2-platforms][PATCH 04/15] Silicon/BcmGenet: Add missing I/O mapping length and clean up Pete Batard
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 23+ messages in thread
From: Pete Batard @ 2020-02-28 10:38 UTC (permalink / raw)
  To: devel; +Cc: ard.biesheuvel, leif, philmd

Whereas these devices are not explicitly described in the BCM2835
ARM Peripheral guide, they come as standard with the SoC and their
constants can easily be found in the Device Trees for Bcm283x based
devices.

Create 2 new Silicon headers to host these constants.

Signed-off-by: Pete Batard <pete@akeo.ie>
---
 Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836Gpu.h | 48 ++++++++++++++++++++
 Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836Pwm.h | 34 ++++++++++++++
 2 files changed, 82 insertions(+)

diff --git a/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836Gpu.h b/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836Gpu.h
new file mode 100644
index 000000000000..4eea4cf22fd8
--- /dev/null
+++ b/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836Gpu.h
@@ -0,0 +1,48 @@
+/** @file
+ *
+ *  Copyright (c) 2020, Pete Batard <pete@akeo.ie>
+ *
+ *  SPDX-License-Identifier: BSD-2-Clause-Patent
+ *
+ **/
+
+#include <IndustryStandard/Bcm2836.h>
+
+#ifndef __BCM2836_GPU_H__
+#define __BCM2836_GPU_H__
+
+/* VideoCore constants */
+
+#define BCM2836_VCHIQ_OFFSET                                0x0000B840
+#define BCM2836_VCHIQ_BASE_ADDRESS                          (BCM2836_SOC_REGISTERS + BCM2836_VCHIQ_OFFSET)
+#define BCM2836_VCHIQ_LENGTH                                0x00000010
+
+#define BCM2836_V3D_BUS_OFFSET                              0x00C00000
+#define BCM2836_V3D_BUS_BASE_ADDRESS                        (BCM2836_SOC_REGISTERS + BCM2836_V3D_BUS_OFFSET)
+#define BCM2836_V3D_BUS_LENGTH                              0x00001000
+
+#define BCM2836_HVS_OFFSET                                  0x00400000
+#define BCM2836_HVS_BASE_ADDRESS                            (BCM2836_SOC_REGISTERS + BCM2836_HVS_OFFSET)
+#define BCM2836_HVS_LENGTH                                  0x00006000
+
+#define BCM2836_PV0_OFFSET                                  0x00206000
+#define BCM2836_PV0_BASE_ADDRESS                            (BCM2836_SOC_REGISTERS + BCM2836_PV0_OFFSET)
+#define BCM2836_PV0_LENGTH                                  0x00000100
+
+#define BCM2836_PV1_OFFSET                                  0x00207000
+#define BCM2836_PV1_BASE_ADDRESS                            (BCM2836_SOC_REGISTERS + BCM2836_PV1_OFFSET)
+#define BCM2836_PV1_LENGTH                                  0x00000100
+
+#define BCM2836_PV2_OFFSET                                  0x00807000
+#define BCM2836_PV2_BASE_ADDRESS                            (BCM2836_SOC_REGISTERS + BCM2836_PV2_OFFSET)
+#define BCM2836_PV2_LENGTH                                  0x00000100
+
+#define BCM2836_HDMI0_OFFSET                                0x00902000
+#define BCM2836_HDMI0_BASE_ADDRESS                          (BCM2836_SOC_REGISTERS + BCM2836_HDMI0_OFFSET)
+#define BCM2836_HDMI0_LENGTH                                0x00000600
+
+#define BCM2836_HDMI1_OFFSET                                0x00808000
+#define BCM2836_HDMI1_BASE_ADDRESS                          (BCM2836_SOC_REGISTERS + BCM2836_HDMI1_OFFSET)
+#define BCM2836_HDMI1_LENGTH                                0x00000100
+
+#endif /* __BCM2836_MISC_H__ */
diff --git a/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836Pwm.h b/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836Pwm.h
new file mode 100644
index 000000000000..e2581b8901ad
--- /dev/null
+++ b/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836Pwm.h
@@ -0,0 +1,34 @@
+/** @file
+ *
+ *  Copyright (c) 2020, Pete Batard <pete@akeo.ie>
+ *
+ *  SPDX-License-Identifier: BSD-2-Clause-Patent
+ *
+ **/
+
+#include <IndustryStandard/Bcm2836.h>
+
+#ifndef __BCM2836_PWM_H__
+#define __BCM2836_PWM_H__
+
+/* Power Management constants */
+
+#define BCM2836_PWM_DMA_OFFSET                              0x00007B00
+#define BCM2836_PWM_DMA_BASE_ADDRESS                        (BCM2836_SOC_REGISTERS + BCM2836_PWM_DMA_OFFSET)
+#define BCM2836_PWM_DMA_LENGTH                              0x00000100
+
+#define BCM2836_PWM_CLK_OFFSET                              0x001010A0
+#define BCM2836_PWM_CLK_BASE_ADDRESS                        (BCM2836_SOC_REGISTERS + BCM2836_PWM_CLK_OFFSET)
+#define BCM2836_PWM_CLK_LENGTH                              0x00000008
+
+#define BCM2836_PWM_CTRL_OFFSET                             0x0020C000
+#define BCM2836_PWM_CTRL_BASE_ADDRESS                       (BCM2836_SOC_REGISTERS + BCM2836_PWM_CTRL_OFFSET)
+#define BCM2836_PWM_CTRL_LENGTH                             0x00000028
+
+#define BCM2836_PWM_BUS_BASE_ADDRESS                        0x7E20C000
+#define BCM2836_PWM_BUS_LENGTH                              0x00000028
+
+#define BCM2836_PWM_CTRL_UNCACHED_BASE_ADDRESS              0xFF20C000
+#define BCM2836_PWM_CTRL_UNCACHED_LENGTH                    0x00000028
+
+#endif /* __BCM2836_PWM_H__ */
-- 
2.21.0.windows.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [edk2-platforms][PATCH 04/15] Silicon/BcmGenet: Add missing I/O mapping length and clean up
  2020-02-28 10:38 [edk2-platforms][PATCH 00/15] Platform/RPi: Clean up and factorize ACPI Pete Batard
                   ` (2 preceding siblings ...)
  2020-02-28 10:38 ` [edk2-platforms][PATCH 03/15] Silicon/Bcm283x: Add GPU/VideoCore and Power Management constants Pete Batard
@ 2020-02-28 10:38 ` Pete Batard
  2020-02-28 10:45   ` Ard Biesheuvel
  2020-02-28 10:38 ` [edk2-platforms][PATCH 05/15] Platform/RPi4: Use Silicon constants in ACPI headers Pete Batard
                   ` (11 subsequent siblings)
  15 siblings, 1 reply; 23+ messages in thread
From: Pete Batard @ 2020-02-28 10:38 UTC (permalink / raw)
  To: devel; +Cc: ard.biesheuvel, leif, philmd

Remove unneeded extra parenthesis on PCD, which can cause problems
when used with ACPI ASL macros and add an [Includes] section to the
.inf, so that the Genet.h header can be referenced where required.

Signed-off-by: Pete Batard <pete@akeo.ie>
---
 Silicon/Broadcom/Drivers/Net/BcmGenetDxe/Genet.h | 3 ++-
 Silicon/Broadcom/Drivers/Net/BcmNet.dec          | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/Genet.h b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/Genet.h
index 4a3827c0e0d1..f56fb2977422 100644
--- a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/Genet.h
+++ b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/Genet.h
@@ -11,7 +11,8 @@
 
 #include <Library/PcdLib.h>
 
-#define GENET_BASE_ADDRESS         (FixedPcdGet64 (PcdBcmGenetRegistersAddress))
+#define GENET_BASE_ADDRESS         FixedPcdGet64 (PcdBcmGenetRegistersAddress)
+#define GENET_LENGTH               0x00010000
 
 #define GENET_SYS_RBUF_FLUSH_CTRL  0x0008
 #define GENET_UMAC_MAC0            0x080c
diff --git a/Silicon/Broadcom/Drivers/Net/BcmNet.dec b/Silicon/Broadcom/Drivers/Net/BcmNet.dec
index 2a8688cb09a7..483b033af51c 100644
--- a/Silicon/Broadcom/Drivers/Net/BcmNet.dec
+++ b/Silicon/Broadcom/Drivers/Net/BcmNet.dec
@@ -12,6 +12,9 @@ [Defines]
   PACKAGE_GUID                   = 34E19823-D23A-41AB-9C09-ED1225B32DFF
   PACKAGE_VERSION                = 1.0
 
+[Includes]
+  .
+
 [Guids]
   gBcmNetTokenSpaceGuid = {0x12b97d70, 0x9149, 0x4c2f, {0x82, 0xd5, 0xad, 0xa9, 0x1e, 0x92, 0x75, 0xa1}}
 
-- 
2.21.0.windows.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [edk2-platforms][PATCH 05/15] Platform/RPi4: Use Silicon constants in ACPI headers
  2020-02-28 10:38 [edk2-platforms][PATCH 00/15] Platform/RPi: Clean up and factorize ACPI Pete Batard
                   ` (3 preceding siblings ...)
  2020-02-28 10:38 ` [edk2-platforms][PATCH 04/15] Silicon/BcmGenet: Add missing I/O mapping length and clean up Pete Batard
@ 2020-02-28 10:38 ` Pete Batard
  2020-02-28 10:38 ` [edk2-platforms][PATCH 06/15] Platform/RPi3: " Pete Batard
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 23+ messages in thread
From: Pete Batard @ 2020-02-28 10:38 UTC (permalink / raw)
  To: devel; +Cc: ard.biesheuvel, leif, philmd

With the new constants added, remove some of the hardcoded values from
the ACPI tables.

Note that because the ASL compiler is very limited in terms of macro
processing, we can not use any arithmetic constants (e.g BASE + OFFSET)
as parameters to MEMORY32FIXED (), and instead must alter the base
address using CreateDwordField () after MEMORY32FIXED () has been
invoked.

To achieve that, we create a MEMORY32SETBASE () macro and move the
MEMORY32FIXED () calls outside of Method (_CRS...).

Signed-off-by: Pete Batard <pete@akeo.ie>
---
 Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.h   |   8 +
 Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf |   2 +
 Platform/RaspberryPi/RPi4/AcpiTables/Csrt.aslc      |   7 +-
 Platform/RaspberryPi/RPi4/AcpiTables/Dsdt.asl       | 422 +++++++++++---------
 Platform/RaspberryPi/RPi4/AcpiTables/Sdhc.asl       |  32 +-
 Platform/RaspberryPi/RPi4/AcpiTables/Uart.asl       |  77 ++--
 6 files changed, 302 insertions(+), 246 deletions(-)

diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.h b/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.h
index dcdbac7a0b7b..fcfad3b5d93b 100644
--- a/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.h
+++ b/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.h
@@ -15,6 +15,14 @@
 
 #include <IndustryStandard/Acpi.h>
 
+// The ASL compiler can't perform arithmetic on MEMORY32SETBASE ()
+// parameters so you can't pass a constant like BASE + OFFSET (the
+// compiler just silently sets it to zero). So we need a macro that
+// can perform arithmetic base address update with an offset.
+#define MEMORY32SETBASE(BufName, MemName, VarName, Offset)       \
+    CreateDwordField (^BufName, ^MemName._BAS, VarName)          \
+    Add (BCM2836_SOC_REGISTERS, Offset, VarName)
+
 #define EFI_ACPI_OEM_ID                       {'M','C','R','S','F','T'} // OEMID 6 bytes long
 #define EFI_ACPI_OEM_TABLE_ID                 SIGNATURE_64 ('R','P','I','4','E','D','K','2') // OEM table id 8 bytes long
 #define EFI_ACPI_OEM_REVISION                 0x02000820
diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf b/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf
index aa8f67dec95e..358c315b6da1 100644
--- a/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf
+++ b/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf
@@ -41,6 +41,7 @@ [Packages]
   MdePkg/MdePkg.dec
   Silicon/Broadcom/Bcm27xx/Bcm27xx.dec
   Silicon/Broadcom/Bcm283x/Bcm283x.dec
+  Silicon/Broadcom/Drivers/Net/BcmNet.dec
 
 [FixedPcd]
   gArmTokenSpaceGuid.PcdArmArchTimerIntrNum
@@ -52,6 +53,7 @@ [FixedPcd]
   gBcm27xxTokenSpaceGuid.PcdBcm27xxPciCpuMmioAdr
   gBcm27xxTokenSpaceGuid.PcdBcm27xxPciRegBase
   gBcm283xTokenSpaceGuid.PcdBcm283xRegistersAddress
+  gBcmNetTokenSpaceGuid.PcdBcmGenetRegistersAddress
   gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate
   gEmbeddedTokenSpaceGuid.PcdInterruptBaseAddress
 
diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Csrt.aslc b/Platform/RaspberryPi/RPi4/AcpiTables/Csrt.aslc
index f8bf3f26a341..03d888fffb8b 100644
--- a/Platform/RaspberryPi/RPi4/AcpiTables/Csrt.aslc
+++ b/Platform/RaspberryPi/RPi4/AcpiTables/Csrt.aslc
@@ -10,6 +10,7 @@
  **/
 
 #include <IndustryStandard/Acpi.h>
+#include <IndustryStandard/Bcm2836.h>
 
 #include "AcpiTables.h"
 
@@ -137,9 +138,9 @@ EFI_ACPI_5_1_CSRT_TABLE Csrt =
       {
         sizeof (DMA_CONTROLLER_VENDOR_DATA),  // Controller vendor data here
         1,
-        0xFE007000,                   // Base address for channels
-        RPI_DMA_CHANNEL_COUNT * 0x100, // Base size = Number of channels x 0x100 size for each channel
-        0xFE007FE0,                   // Base address for controller
+        BCM2836_DMA0_BASE_ADDRESS,    // Base address for channels
+        RPI_DMA_CHANNEL_COUNT * BCM2836_DMA_CHANNEL_LENGTH, // Base size = Number of channels x channel size
+        BCM2836_DMA_CTRL_BASE_ADDRESS,// Base address for controller
         8,                            // Base size = two registers
         RPI_DMA_USED_CHANNEL_COUNT,
         0,                            // cannot use controller interrupt
diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Dsdt.asl b/Platform/RaspberryPi/RPi4/AcpiTables/Dsdt.asl
index 8d2938a6596c..c505413bcba2 100644
--- a/Platform/RaspberryPi/RPi4/AcpiTables/Dsdt.asl
+++ b/Platform/RaspberryPi/RPi4/AcpiTables/Dsdt.asl
@@ -2,6 +2,7 @@
  *
  *  Differentiated System Definition Table (DSDT)
  *
+ *  Copyright (c) 2020, Pete Batard <pete@akeo.ie>
  *  Copyright (c) 2018, Andrey Warkentin <andrey.warkentin@gmail.com>
  *  Copyright (c) Microsoft Corporation. All rights reserved.
  *
@@ -9,6 +10,14 @@
  *
  **/
 
+#include <BcmGenetDxe/Genet.h>
+#include <IndustryStandard/Bcm2836.h>
+#include <IndustryStandard/Bcm2836Gpio.h>
+#include <IndustryStandard/Bcm2836Gpu.h>
+#include <IndustryStandard/Bcm2836Pwm.h>
+
+#include "AcpiTables.h"
+
 #define BCM_ALT0 0x4
 #define BCM_ALT1 0x5
 #define BCM_ALT2 0x6
@@ -75,14 +84,15 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       {
         Return (0xf)
       }
+      Name (RBUF, ResourceTemplate ()
+      {
+        MEMORY32FIXED (ReadWrite, 0, BCM2836_USB_LENGTH, RMEM)
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x69 }
+      })
       Method (_CRS, 0x0, Serialized)
       {
-        Name (RBUF, ResourceTemplate ()
-        {
-          MEMORY32FIXED(ReadWrite, 0xFE980000, 0x10000,)
-          Interrupt(ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x69 }
-        })
-        Return(RBUF)
+        MEMORY32SETBASE (RBUF, RMEM, RBAS, BCM2836_USB_OFFSET)
+        Return (^RBUF)
       }
     }
 
@@ -97,44 +107,49 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       {
         Return(0xf)
       }
+      Name (RBUF, ResourceTemplate ()
+      {
+        // Memory and interrupt for the GPU
+        MEMORY32FIXED (ReadWrite, 0, BCM2836_V3D_BUS_LENGTH, RM01)
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x2A }
+
+        // HVS - Hardware Video Scalar
+        MEMORY32FIXED (ReadWrite, 0, BCM2836_HVS_LENGTH, RM02)
+        // The HVS interrupt is reserved by the VPU
+        // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x41 }
+
+        // PixelValve0 - DSI0 or DPI
+        // MEMORY32FIXED (ReadWrite, BCM2836_PV0_BASE_ADDRESS, BCM2836_PV0_LENGTH, RM03)
+        // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x4D }
+
+        // PixelValve1 - DS1 or SMI
+        // MEMORY32FIXED (ReadWrite, BCM2836_PV1_BASE_ADDRESS, BCM2836_PV1_LENGTH, RM04)
+        // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x4E }
+
+        // PixelValve2 - HDMI output - connected to HVS display FIFO 1
+        MEMORY32FIXED (ReadWrite, 0, BCM2836_PV2_LENGTH, RM05)
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x4A }
+
+        // HDMI registers
+        MEMORY32FIXED (ReadWrite, 0, BCM2836_HDMI0_LENGTH, RM06)
+        MEMORY32FIXED (ReadWrite, 0, BCM2836_HDMI1_LENGTH, RM07)
+        // hdmi_int[0]
+        // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x48 }
+        // hdmi_int[1]
+        // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x49 }
+
+        // HDMI DDC connection
+        I2CSerialBus (0x50,, 100000,, "\\_SB.I2C2",,,,)  // EDID
+        I2CSerialBus (0x30,, 100000,, "\\_SB.I2C2",,,,)  // E-DDC Segment Pointer
+      })
       Method (_CRS, 0x0, Serialized)
       {
-        Name (RBUF, ResourceTemplate ()
-        {
-          // Memory and interrupt for the GPU
-          MEMORY32FIXED(ReadWrite, 0xFEC00000, 0x1000,)
-          Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x2A }
-
-          // HVS - Hardware Video Scalar
-          MEMORY32FIXED (ReadWrite, 0xFE400000, 0x6000,)
-          // The HVS interrupt is reserved by the VPU
-          // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x41 }
-
-          // PixelValve0 - DSI0 or DPI
-          // MEMORY32FIXED (ReadWrite, 0xFE206000, 0x100,)
-          // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x4D }
-
-          // PixelValve1 - DS1 or SMI
-          // MEMORY32FIXED (ReadWrite, 0xFE207000, 0x100,)
-          // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x4E }
-
-          // PixelValve2 - HDMI output - connected to HVS display FIFO 1
-          MEMORY32FIXED (ReadWrite, 0xFE807000, 0x100,)
-          Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x4A }
-
-          // HDMI registers
-          MEMORY32FIXED (ReadWrite, 0xFE902000, 0x600,)   // HDMI registers
-          MEMORY32FIXED (ReadWrite, 0xFE808000, 0x100,)   // HD registers
-          // hdmi_int[0]
-          // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x48 }
-          // hdmi_int[1]
-          // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x49 }
-
-          // HDMI DDC connection
-          I2CSerialBus (0x50,, 100000,, "\\_SB.I2C2",,,,)  // EDID
-          I2CSerialBus (0x30,, 100000,, "\\_SB.I2C2",,,,)  // E-DDC Segment Pointer
-        })
-        Return(RBUF)
+        MEMORY32SETBASE (RBUF, RM01, RB01, BCM2836_V3D_BUS_OFFSET)
+        MEMORY32SETBASE (RBUF, RM02, RB02, BCM2836_HVS_OFFSET)
+        MEMORY32SETBASE (RBUF, RM05, RB05, BCM2836_PV2_OFFSET)
+        MEMORY32SETBASE (RBUF, RM06, RB06, BCM2836_HDMI0_OFFSET)
+        MEMORY32SETBASE (RBUF, RM07, RB07, BCM2836_HDMI1_OFFSET)
+        Return (^RBUF)
       }
 
       // GPU Power Management Component Data
@@ -196,14 +211,16 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       {
         Return (0xf)
       }
+      Name (RBUF, ResourceTemplate ()
+      {
+        MEMORY32FIXED (ReadWrite, 0, BCM2836_MBOX_LENGTH, RMEM)
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x61 }
+      })
+
       Method (_CRS, 0x0, Serialized)
       {
-        Name (RBUF, ResourceTemplate ()
-        {
-          Memory32Fixed (ReadWrite, 0xFE00B880, 0x00000024,)
-          Interrupt(ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x61 }
-        })
-        Return (RBUF)
+        MEMORY32SETBASE (RBUF, RMEM, RBAS, BCM2836_MBOX_OFFSET)
+        Return (^RBUF)
       }
     }
 
@@ -219,14 +236,16 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       {
          Return (0xf)
       }
+      Name (RBUF, ResourceTemplate ()
+      {
+        MEMORY32FIXED (ReadWrite, 0, BCM2836_VCHIQ_LENGTH, RMEM)
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x62 }
+      })
+
       Method (_CRS, 0x0, Serialized)
       {
-        Name (RBUF, ResourceTemplate ()
-        {
-          Memory32Fixed (ReadWrite, 0xFE00B840, 0x00000010,)
-          Interrupt(ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x62 }
-        })
-        Return (RBUF)
+        MEMORY32SETBASE (RBUF, RMEM, RBAS, BCM2836_VCHIQ_OFFSET)
+        Return (^RBUF)
       }
     }
 
@@ -255,15 +274,15 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       {
         Return(0xf)
       }
+      Name (RBUF, ResourceTemplate ()
+      {
+        MEMORY32FIXED (ReadWrite, 0, GPIO_LENGTH, RMEM)
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { 0x51, 0x53 }
+      })
       Method (_CRS, 0x0, Serialized)
       {
-        Name (RBUF, ResourceTemplate ()
-        {
-          MEMORY32FIXED (ReadWrite, 0xFE200000, 0xB4, )
-          Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { 0x51 }
-          Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { 0x53 }
-        })
-        Return (RBUF)
+        MEMORY32SETBASE (RBUF, RMEM, RBAS, GPIO_OFFSET)
+        Return (^RBUF)
       }
     }
 
@@ -281,9 +300,9 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       {
         Name (RBUF, ResourceTemplate ()
         {
-          Memory32Fixed (ReadWrite, 0xfd580000, 0x10000, )
-          Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0xBD }
-          Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0xBE }
+          // No need for MEMORY32SETBASE on Genet as we have a straight base address constant
+          MEMORY32FIXED (ReadWrite, GENET_BASE_ADDRESS, GENET_LENGTH, )
+          Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0xBD, 0xBE }
         })
         Return (RBUF)
       }
@@ -307,30 +326,31 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       {
         Return(0xf)
       }
-      Method (_CRS, 0x0, Serialized)
+      Name (RBUF, ResourceTemplate ()
       {
-        Name (RBUF, ResourceTemplate ()
-        {
-          Memory32Fixed(ReadWrite, 0xFE804000, 0x20)
-          Interrupt(ResourceConsumer, Level, ActiveHigh, Shared) {0x55}
+        MEMORY32FIXED (ReadWrite, 0, BCM2836_I2C1_LENGTH, RMEM)
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { 0x55 }
 
-          //
-          // MsftFunctionConfig is encoded as the VendorLong.
-          //
-          // MsftFunctionConfig (Exclusive, PullUp, BCM_ALT0, "\\_SB.GPI0", 0, ResourceConsumer,) {2, 3}
-          //
-          VendorLong ()      // Length = 0x31
-          {
-            /* 0000 */  0x00, 0x60, 0x44, 0xD5, 0xF3, 0x1F, 0x11, 0x60,  // .`D....`
-            /* 0008 */  0x4A, 0xB8, 0xB0, 0x9C, 0x2D, 0x23, 0x30, 0xDD,  // J...-#0.
-            /* 0010 */  0x2F, 0x8D, 0x1D, 0x00, 0x01, 0x10, 0x00, 0x01,  // /.......
-            /* 0018 */  0x04, 0x00, 0x12, 0x00, 0x00, 0x16, 0x00, 0x20,  // ........
-            /* 0020 */  0x00, 0x00, 0x00, 0x02, 0x00, 0x03, 0x00, 0x5C,  // ........
-            /* 0028 */  0x5F, 0x53, 0x42, 0x2E, 0x47, 0x50, 0x49, 0x30,  // _SB.GPI0
-            /* 0030 */  0x00                                             // .
-          }
-        })
-        Return (RBUF)
+        //
+        // MsftFunctionConfig is encoded as the VendorLong.
+        //
+        // MsftFunctionConfig (Exclusive, PullUp, BCM_ALT0, "\\_SB.GPI0", 0, ResourceConsumer,) {2, 3}
+        //
+        VendorLong ()      // Length = 0x31
+        {
+          /* 0000 */  0x00, 0x60, 0x44, 0xD5, 0xF3, 0x1F, 0x11, 0x60,  // .`D....`
+          /* 0008 */  0x4A, 0xB8, 0xB0, 0x9C, 0x2D, 0x23, 0x30, 0xDD,  // J...-#0.
+          /* 0010 */  0x2F, 0x8D, 0x1D, 0x00, 0x01, 0x10, 0x00, 0x01,  // /.......
+          /* 0018 */  0x04, 0x00, 0x12, 0x00, 0x00, 0x16, 0x00, 0x20,  // ........
+          /* 0020 */  0x00, 0x00, 0x00, 0x02, 0x00, 0x03, 0x00, 0x5C,  // ........
+          /* 0028 */  0x5F, 0x53, 0x42, 0x2E, 0x47, 0x50, 0x49, 0x30,  // _SB.GPI0
+          /* 0030 */  0x00                                             // .
+        }
+      })
+      Method (_CRS, 0x0, Serialized)
+      {
+        MEMORY32SETBASE (RBUF, RMEM, RBAS, BCM2836_I2C1_OFFSET)
+        Return (^RBUF)
       }
     }
 
@@ -345,14 +365,16 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       {
         Return (0xf)
       }
+      Name (RBUF, ResourceTemplate()
+      {
+        MEMORY32FIXED (ReadWrite, 0, BCM2836_I2C2_LENGTH, RMEM)
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { 0x55 }
+      })
+
       Method (_CRS, 0x0, Serialized)
       {
-        Name (RBUF, ResourceTemplate()
-        {
-          Memory32Fixed (ReadWrite, 0xFE805000, 0x20)
-          Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) {0x55}
-        })
-        Return (RBUF)
+        MEMORY32SETBASE (RBUF, RMEM, RBAS, BCM2836_I2C2_OFFSET)
+        Return (^RBUF)
       }
     }
 
@@ -367,57 +389,59 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       {
         Return (0xf)
       }
+      Name (RBUF, ResourceTemplate ()
+      {
+        MEMORY32FIXED (ReadWrite, 0, BCM2836_SPI0_LENGTH, RMEM)
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { 0x56 }
+
+        //
+        // MsftFunctionConfig is encoded as the VendorLong.
+        //
+        // MsftFunctionConfig (Exclusive, PullDown, BCM_ALT0, "\\_SB.GPI0", 0, ResourceConsumer, ) {9, 10, 11} // MISO, MOSI, SCLK
+        VendorLong ()      // Length = 0x33
+        {
+          /* 0000 */  0x00, 0x60, 0x44, 0xD5, 0xF3, 0x1F, 0x11, 0x60,  // .`D....`
+          /* 0008 */  0x4A, 0xB8, 0xB0, 0x9C, 0x2D, 0x23, 0x30, 0xDD,  // J...-#0.
+          /* 0010 */  0x2F, 0x8D, 0x1F, 0x00, 0x01, 0x10, 0x00, 0x02,  // /.......
+          /* 0018 */  0x04, 0x00, 0x12, 0x00, 0x00, 0x18, 0x00, 0x22,  // ......."
+          /* 0020 */  0x00, 0x00, 0x00, 0x09, 0x00, 0x0A, 0x00, 0x0B,  // ........
+          /* 0028 */  0x00, 0x5C, 0x5F, 0x53, 0x42, 0x2E, 0x47, 0x50,  // .\_SB.GP
+          /* 0030 */  0x49, 0x30, 0x00                                 // I0.
+        }
+
+        //
+        // MsftFunctionConfig is encoded as the VendorLong.
+        //
+        // MsftFunctionConfig (Exclusive, PullUp, BCM_ALT0, "\\_SB.GPI0", 0, ResourceConsumer, ) {8}     // CE0
+        VendorLong ()      // Length = 0x2F
+        {
+          /* 0000 */  0x00, 0x60, 0x44, 0xD5, 0xF3, 0x1F, 0x11, 0x60,  // .`D....`
+          /* 0008 */  0x4A, 0xB8, 0xB0, 0x9C, 0x2D, 0x23, 0x30, 0xDD,  // J...-#0.
+          /* 0010 */  0x2F, 0x8D, 0x1B, 0x00, 0x01, 0x10, 0x00, 0x01,  // /.......
+          /* 0018 */  0x04, 0x00, 0x12, 0x00, 0x00, 0x14, 0x00, 0x1E,  // ........
+          /* 0020 */  0x00, 0x00, 0x00, 0x08, 0x00, 0x5C, 0x5F, 0x53,  // .....\_S
+          /* 0028 */  0x42, 0x2E, 0x47, 0x50, 0x49, 0x30, 0x00         // B.GPI0.
+        }
+
+        //
+        // MsftFunctionConfig is encoded as the VendorLong.
+        //
+        // MsftFunctionConfig (Exclusive, PullUp, BCM_ALT0, "\\_SB.GPI0", 0, ResourceConsumer, ) {7}     // CE1
+        VendorLong ()      // Length = 0x2F
+        {
+          /* 0000 */  0x00, 0x60, 0x44, 0xD5, 0xF3, 0x1F, 0x11, 0x60,  // .`D....`
+          /* 0008 */  0x4A, 0xB8, 0xB0, 0x9C, 0x2D, 0x23, 0x30, 0xDD,  // J...-#0.
+          /* 0010 */  0x2F, 0x8D, 0x1B, 0x00, 0x01, 0x10, 0x00, 0x01,  // /.......
+          /* 0018 */  0x04, 0x00, 0x12, 0x00, 0x00, 0x14, 0x00, 0x1E,  // ........
+          /* 0020 */  0x00, 0x00, 0x00, 0x07, 0x00, 0x5C, 0x5F, 0x53,  // .....\_S
+          /* 0028 */  0x42, 0x2E, 0x47, 0x50, 0x49, 0x30, 0x00         // B.GPI0.
+        }
+      })
+
       Method (_CRS, 0x0, Serialized)
       {
-        Name (RBUF, ResourceTemplate ()
-        {
-          MEMORY32FIXED (ReadWrite, 0xFE204000, 0x20,)
-          Interrupt(ResourceConsumer, Level, ActiveHigh, Shared) {0x56}
-
-          //
-          // MsftFunctionConfig is encoded as the VendorLong.
-          //
-          // MsftFunctionConfig (Exclusive, PullDown, BCM_ALT0, "\\_SB.GPI0", 0, ResourceConsumer, ) {9, 10, 11} // MISO, MOSI, SCLK
-          VendorLong ()      // Length = 0x33
-          {
-            /* 0000 */  0x00, 0x60, 0x44, 0xD5, 0xF3, 0x1F, 0x11, 0x60,  // .`D....`
-            /* 0008 */  0x4A, 0xB8, 0xB0, 0x9C, 0x2D, 0x23, 0x30, 0xDD,  // J...-#0.
-            /* 0010 */  0x2F, 0x8D, 0x1F, 0x00, 0x01, 0x10, 0x00, 0x02,  // /.......
-            /* 0018 */  0x04, 0x00, 0x12, 0x00, 0x00, 0x18, 0x00, 0x22,  // ......."
-            /* 0020 */  0x00, 0x00, 0x00, 0x09, 0x00, 0x0A, 0x00, 0x0B,  // ........
-            /* 0028 */  0x00, 0x5C, 0x5F, 0x53, 0x42, 0x2E, 0x47, 0x50,  // .\_SB.GP
-            /* 0030 */  0x49, 0x30, 0x00                                 // I0.
-          }
-
-          //
-          // MsftFunctionConfig is encoded as the VendorLong.
-          //
-          // MsftFunctionConfig (Exclusive, PullUp, BCM_ALT0, "\\_SB.GPI0", 0, ResourceConsumer, ) {8}     // CE0
-          VendorLong ()      // Length = 0x2F
-          {
-            /* 0000 */  0x00, 0x60, 0x44, 0xD5, 0xF3, 0x1F, 0x11, 0x60,  // .`D....`
-            /* 0008 */  0x4A, 0xB8, 0xB0, 0x9C, 0x2D, 0x23, 0x30, 0xDD,  // J...-#0.
-            /* 0010 */  0x2F, 0x8D, 0x1B, 0x00, 0x01, 0x10, 0x00, 0x01,  // /.......
-            /* 0018 */  0x04, 0x00, 0x12, 0x00, 0x00, 0x14, 0x00, 0x1E,  // ........
-            /* 0020 */  0x00, 0x00, 0x00, 0x08, 0x00, 0x5C, 0x5F, 0x53,  // .....\_S
-            /* 0028 */  0x42, 0x2E, 0x47, 0x50, 0x49, 0x30, 0x00         // B.GPI0.
-          }
-
-          //
-          // MsftFunctionConfig is encoded as the VendorLong.
-          //
-          // MsftFunctionConfig (Exclusive, PullUp, BCM_ALT0, "\\_SB.GPI0", 0, ResourceConsumer, ) {7}     // CE1
-          VendorLong ()      // Length = 0x2F
-          {
-            /* 0000 */  0x00, 0x60, 0x44, 0xD5, 0xF3, 0x1F, 0x11, 0x60,  // .`D....`
-            /* 0008 */  0x4A, 0xB8, 0xB0, 0x9C, 0x2D, 0x23, 0x30, 0xDD,  // J...-#0.
-            /* 0010 */  0x2F, 0x8D, 0x1B, 0x00, 0x01, 0x10, 0x00, 0x01,  // /.......
-            /* 0018 */  0x04, 0x00, 0x12, 0x00, 0x00, 0x14, 0x00, 0x1E,  // ........
-            /* 0020 */  0x00, 0x00, 0x00, 0x07, 0x00, 0x5C, 0x5F, 0x53,  // .....\_S
-            /* 0028 */  0x42, 0x2E, 0x47, 0x50, 0x49, 0x30, 0x00         // B.GPI0.
-          }
-        })
-        Return (RBUF)
+        MEMORY32SETBASE (RBUF, RMEM, RBAS, BCM2836_SPI0_OFFSET)
+        Return (^RBUF)
       }
     }
 
@@ -432,43 +456,45 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       {
         Return (0xf)
       }
+      Name (RBUF, ResourceTemplate ()
+      {
+        MEMORY32FIXED (ReadWrite, 0, BCM2836_SPI1_LENGTH, RMEM)
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Shared,) { 0x3D }
+
+        //
+        // MsftFunctionConfig is encoded as the VendorLong.
+        //
+        // MsftFunctionConfig(Exclusive, PullDown, BCM_ALT4, "\\_SB.GPI0", 0, ResourceConsumer, ) {19, 20, 21} // MISO, MOSI, SCLK
+        VendorLong ()      // Length = 0x33
+        {
+          /* 0000 */  0x00, 0x60, 0x44, 0xD5, 0xF3, 0x1F, 0x11, 0x60,  // .`D....`
+          /* 0008 */  0x4A, 0xB8, 0xB0, 0x9C, 0x2D, 0x23, 0x30, 0xDD,  // J...-#0.
+          /* 0010 */  0x2F, 0x8D, 0x1F, 0x00, 0x01, 0x10, 0x00, 0x02,  // /.......
+          /* 0018 */  0x03, 0x00, 0x12, 0x00, 0x00, 0x18, 0x00, 0x22,  // ......."
+          /* 0020 */  0x00, 0x00, 0x00, 0x13, 0x00, 0x14, 0x00, 0x15,  // ........
+          /* 0028 */  0x00, 0x5C, 0x5F, 0x53, 0x42, 0x2E, 0x47, 0x50,  // .\_SB.GP
+          /* 0030 */  0x49, 0x30, 0x00                                 // I0.
+        }
+
+        //
+        // MsftFunctionConfig is encoded as the VendorLong.
+        //
+        // MsftFunctionConfig(Exclusive, PullDown, BCM_ALT4, "\\_SB.GPI0", 0, ResourceConsumer, ) {16} // CE2
+        VendorLong ()      // Length = 0x2F
+        {
+          /* 0000 */  0x00, 0x60, 0x44, 0xD5, 0xF3, 0x1F, 0x11, 0x60,  // .`D....`
+          /* 0008 */  0x4A, 0xB8, 0xB0, 0x9C, 0x2D, 0x23, 0x30, 0xDD,  // J...-#0.
+          /* 0010 */  0x2F, 0x8D, 0x1B, 0x00, 0x01, 0x10, 0x00, 0x02,  // /.......
+          /* 0018 */  0x03, 0x00, 0x12, 0x00, 0x00, 0x14, 0x00, 0x1E,  // ........
+          /* 0020 */  0x00, 0x00, 0x00, 0x10, 0x00, 0x5C, 0x5F, 0x53,  // .....\_S
+          /* 0028 */  0x42, 0x2E, 0x47, 0x50, 0x49, 0x30, 0x00         // B.GPI0.
+        }
+      })
+
       Method (_CRS, 0x0, Serialized)
       {
-        Name (RBUF, ResourceTemplate ()
-        {
-          MEMORY32FIXED (ReadWrite, 0xFE215080, 0x40,)
-          Interrupt (ResourceConsumer, Level, ActiveHigh, Shared,) {0x3D}
-
-          //
-          // MsftFunctionConfig is encoded as the VendorLong.
-          //
-          // MsftFunctionConfig(Exclusive, PullDown, BCM_ALT4, "\\_SB.GPI0", 0, ResourceConsumer, ) {19, 20, 21} // MISO, MOSI, SCLK
-          VendorLong ()      // Length = 0x33
-          {
-            /* 0000 */  0x00, 0x60, 0x44, 0xD5, 0xF3, 0x1F, 0x11, 0x60,  // .`D....`
-            /* 0008 */  0x4A, 0xB8, 0xB0, 0x9C, 0x2D, 0x23, 0x30, 0xDD,  // J...-#0.
-            /* 0010 */  0x2F, 0x8D, 0x1F, 0x00, 0x01, 0x10, 0x00, 0x02,  // /.......
-            /* 0018 */  0x03, 0x00, 0x12, 0x00, 0x00, 0x18, 0x00, 0x22,  // ......."
-            /* 0020 */  0x00, 0x00, 0x00, 0x13, 0x00, 0x14, 0x00, 0x15,  // ........
-            /* 0028 */  0x00, 0x5C, 0x5F, 0x53, 0x42, 0x2E, 0x47, 0x50,  // .\_SB.GP
-            /* 0030 */  0x49, 0x30, 0x00                                 // I0.
-          }
-
-          //
-          // MsftFunctionConfig is encoded as the VendorLong.
-          //
-          // MsftFunctionConfig(Exclusive, PullDown, BCM_ALT4, "\\_SB.GPI0", 0, ResourceConsumer, ) {16} // CE2
-          VendorLong ()      // Length = 0x2F
-          {
-            /* 0000 */  0x00, 0x60, 0x44, 0xD5, 0xF3, 0x1F, 0x11, 0x60,  // .`D....`
-            /* 0008 */  0x4A, 0xB8, 0xB0, 0x9C, 0x2D, 0x23, 0x30, 0xDD,  // J...-#0.
-            /* 0010 */  0x2F, 0x8D, 0x1B, 0x00, 0x01, 0x10, 0x00, 0x02,  // /.......
-            /* 0018 */  0x03, 0x00, 0x12, 0x00, 0x00, 0x14, 0x00, 0x1E,  // ........
-            /* 0020 */  0x00, 0x00, 0x00, 0x10, 0x00, 0x5C, 0x5F, 0x53,  // .....\_S
-            /* 0028 */  0x42, 0x2E, 0x47, 0x50, 0x49, 0x30, 0x00         // B.GPI0.
-          }
-        })
-        Return (RBUF)
+        MEMORY32SETBASE (RBUF, RMEM, RBAS, BCM2836_SPI1_OFFSET)
+        Return (^RBUF)
       }
     }
 
@@ -488,8 +514,8 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
     //   {
     //     Name (RBUF, ResourceTemplate ()
     //     {
-    //       MEMORY32FIXED (ReadWrite, 0xFE2150C0, 0x40,)
-    //       Interrupt (ResourceConsumer, Level, ActiveHigh, Shared,) {0x3D}
+    //       MEMORY32FIXED (ReadWrite, BCM2836_SPI2_BASE_ADDRESS, BCM2836_SPI2_LENGTH, RMEM)
+    //       Interrupt (ResourceConsumer, Level, ActiveHigh, Shared,) { 0x3D }
     //     })
     //     Return (RBUF)
     //   }
@@ -506,26 +532,30 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       {
         Return (0xf)
       }
+      Name (RBUF, ResourceTemplate ()
+      {
+        // DMA channel 11 control
+        MEMORY32FIXED (ReadWrite, 0, BCM2836_PWM_DMA_LENGTH, RM01)
+        // PWM control
+        MEMORY32FIXED (ReadWrite, 0, BCM2836_PWM_CTRL_LENGTH, RM02)
+        // PWM control bus
+        MEMORY32FIXED (ReadWrite, BCM2836_PWM_BUS_BASE_ADDRESS, BCM2836_PWM_BUS_LENGTH, )
+        // PWM control uncached
+        MEMORY32FIXED (ReadWrite, BCM2836_PWM_CTRL_UNCACHED_BASE_ADDRESS, BCM2836_PWM_CTRL_UNCACHED_LENGTH, )
+        // PWM clock control
+        MEMORY32FIXED (ReadWrite, 0, BCM2836_PWM_CLK_LENGTH, RM03)
+        // Interrupt DMA channel 11
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x3B }
+        // DMA channel 11, DREQ 5 for PWM
+        FixedDMA (5, 11, Width32Bit, )
+      })
+
       Method (_CRS, 0x0, Serialized)
       {
-        Name (RBUF, ResourceTemplate ()
-        {
-          // DMA channel 11 control
-          Memory32Fixed (ReadWrite, 0xFE007B00, 0x00000100,)
-          // PWM control
-          Memory32Fixed (ReadWrite, 0xFE20C000, 0x00000028,)
-          // PWM control bus
-          Memory32Fixed (ReadWrite, 0x7E20C000, 0x00000028,)
-          // PWM control uncached
-          Memory32Fixed (ReadWrite, 0xFF20C000, 0x00000028,)
-          // PWM clock control
-          Memory32Fixed (ReadWrite, 0xFE1010A0, 0x00000008,)
-          // Interrupt DMA channel 11
-          Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x3B }
-          // DMA channel 11, DREQ 5 for PWM
-          FixedDMA (5, 11, Width32Bit, )
-        })
-        Return (RBUF)
+        MEMORY32SETBASE (RBUF, RM01, RB01, BCM2836_PWM_DMA_OFFSET)
+        MEMORY32SETBASE (RBUF, RM02, RB02, BCM2836_PWM_CTRL_OFFSET)
+        MEMORY32SETBASE (RBUF, RM03, RB03, BCM2836_PWM_CLK_OFFSET)
+        Return (^RBUF)
       }
     }
 
diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Sdhc.asl b/Platform/RaspberryPi/RPi4/AcpiTables/Sdhc.asl
index 56d15c392743..590c71edd484 100644
--- a/Platform/RaspberryPi/RPi4/AcpiTables/Sdhc.asl
+++ b/Platform/RaspberryPi/RPi4/AcpiTables/Sdhc.asl
@@ -2,6 +2,7 @@
  *
  *  [DSDT] SD controller/card definition (SDHC)
  *
+ *  Copyright (c) 2020, Pete Batard <pete@akeo.ie>
  *  Copyright (c) 2018, Andrey Warkentin <andrey.warkentin@gmail.com>
  *  Copyright (c) Microsoft Corporation. All rights reserved.
  *
@@ -9,6 +10,11 @@
  *
  **/
 
+#include <IndustryStandard/Bcm2836SdHost.h>
+#include <IndustryStandard/Bcm2836Sdio.h>
+
+#include "AcpiTables.h"
+
 //
 // Note: UEFI can use either SDHost or Arasan. We expose both to the OS.
 //
@@ -28,14 +34,15 @@ Device (SDC1)
   {
     Return(0xf)
   }
+  Name (RBUF, ResourceTemplate ()
+  {
+    MEMORY32FIXED (ReadWrite, 0, MMCHS1_LENGTH, RMEM)
+    Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x9E }
+  })
   Method (_CRS, 0x0, Serialized)
   {
-    Name (RBUF, ResourceTemplate ()
-    {
-      MEMORY32FIXED (ReadWrite, 0xFE300000, 0x100,)
-      Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x9E }
-    })
-    Return (RBUF)
+    MEMORY32SETBASE (RBUF, RMEM, RBAS, MMCHS1_OFFSET)
+    Return (^RBUF)
   }
 
   //
@@ -71,14 +78,15 @@ Device (SDC2)
   {
     Return (0xf)
   }
+  Name (RBUF, ResourceTemplate ()
+  {
+    MEMORY32FIXED (ReadWrite, 0, SDHOST_LENGTH, RMEM)
+    Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x98 }
+  })
   Method (_CRS, 0x0, Serialized)
   {
-    Name (RBUF, ResourceTemplate ()
-    {
-      MEMORY32FIXED (ReadWrite, 0xFE202000, 0x100,)
-      Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x98 }
-    })
-    Return (RBUF)
+    MEMORY32SETBASE (RBUF, RMEM, RBAS, SDHOST_OFFSET)
+    Return (^RBUF)
   }
 
   //
diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Uart.asl b/Platform/RaspberryPi/RPi4/AcpiTables/Uart.asl
index 5b59f2dd3e16..ad9d21e6272d 100644
--- a/Platform/RaspberryPi/RPi4/AcpiTables/Uart.asl
+++ b/Platform/RaspberryPi/RPi4/AcpiTables/Uart.asl
@@ -2,6 +2,7 @@
  *
  *  [DSDT] Serial devices (UART).
  *
+ *  Copyright (c) 2020, Pete Batard <pete@akeo.ie>
  *  Copyright (c) 2018, Andrey Warkentin <andrey.warkentin@gmail.com>
  *  Copyright (c) Microsoft Corporation. All rights reserved.
  *
@@ -9,6 +10,10 @@
  *
  **/
 
+#include <IndustryStandard/Bcm2836.h>
+
+#include "AcpiTables.h"
+
 // PL011 based UART.
 Device (URT0)
 {
@@ -20,14 +25,15 @@ Device (URT0)
   {
     Return (0xf)
   }
+  Name (RBUF, ResourceTemplate ()
+  {
+    MEMORY32FIXED (ReadWrite, 0, BCM2836_PL011_UART_LENGTH, RMEM)
+    Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x99 }
+  })
   Method (_CRS, 0x0, Serialized)
   {
-    Name (RBUF, ResourceTemplate ()
-    {
-      MEMORY32FIXED (ReadWrite, 0xFE201000, 0x1000,)
-      Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x99 }
-    })
-    Return (RBUF)
+    MEMORY32SETBASE (RBUF, RMEM, RBAS, BCM2836_PL011_UART_OFFSET)
+    Return (^RBUF)
   }
 
   Name (CLCK, 48000000)
@@ -59,37 +65,38 @@ Device (URTM)
   {
     Return (0xf)
   }
+  Name (RBUF, ResourceTemplate ()
+  {
+    MEMORY32FIXED (ReadWrite, 0, BCM2836_MINI_UART_LENGTH, RMEM)
+    Interrupt(ResourceConsumer, Level, ActiveHigh, Shared) { 0x7D }
+
+    // NTRAID#MSFT-7141401-2016/04/7-jordanrh - disable UART muxing
+    // until a proper solution can be created for the dmap conflict.
+    // When muxing is enabled, must consider DBG2 table conflict.
+    // The alternate function resource needs to be reserved when
+    // the kernel debugger is enabled to prevent another client
+    // from muxing the pins away.
+
+    //
+    // MsftFunctionConfig is encoded as the VendorLong.
+    //
+    // MsftFunctionConfig(Exclusive, PullDown, BCM_ALT5, "\\_SB.GPI0", 0, ResourceConsumer, ) {14, 15}
+    // VendorLong  ()      // Length = 0x31
+    // {
+    //   /* 0000 */  0x00, 0x60, 0x44, 0xD5, 0xF3, 0x1F, 0x11, 0x60,  // .`D....`
+    //   /* 0008 */  0x4A, 0xB8, 0xB0, 0x9C, 0x2D, 0x23, 0x30, 0xDD,  // J...-#0.
+    //   /* 0010 */  0x2F, 0x8D, 0x1D, 0x00, 0x01, 0x10, 0x00, 0x02,  // /.......
+    //   /* 0018 */  0x02, 0x00, 0x12, 0x00, 0x00, 0x16, 0x00, 0x20,  // .......
+    //   /* 0020 */  0x00, 0x00, 0x00, 0x0E, 0x00, 0x0F, 0x00, 0x5C,  // .......\
+    //   /* 0028 */  0x5F, 0x53, 0x42, 0x2E, 0x47, 0x50, 0x49, 0x30,  // _SB.GPI0
+    //   /* 0030 */  0x00                                             // .
+    //}
+
+  })
   Method (_CRS, 0x0, Serialized)
   {
-    Name (RBUF, ResourceTemplate ()
-    {
-      MEMORY32FIXED (ReadWrite, 0xFE215000, 0x70,)
-      Interrupt(ResourceConsumer, Level, ActiveHigh, Shared) { 0x7D }
-
-      // NTRAID#MSFT-7141401-2016/04/7-jordanrh - disable UART muxing
-      // until a proper solution can be created for the dmap conflict.
-      // When muxing is enabled, must consider DBG2 table conflict.
-      // The alternate function resource needs to be reserved when
-      // the kernel debugger is enabled to prevent another client
-      // from muxing the pins away.
-
-      //
-      // MsftFunctionConfig is encoded as the VendorLong.
-      //
-      // MsftFunctionConfig(Exclusive, PullDown, BCM_ALT5, "\\_SB.GPI0", 0, ResourceConsumer, ) {14, 15}
-      // VendorLong  ()      // Length = 0x31
-      // {
-      //   /* 0000 */  0x00, 0x60, 0x44, 0xD5, 0xF3, 0x1F, 0x11, 0x60,  // .`D....`
-      //   /* 0008 */  0x4A, 0xB8, 0xB0, 0x9C, 0x2D, 0x23, 0x30, 0xDD,  // J...-#0.
-      //   /* 0010 */  0x2F, 0x8D, 0x1D, 0x00, 0x01, 0x10, 0x00, 0x02,  // /.......
-      //   /* 0018 */  0x02, 0x00, 0x12, 0x00, 0x00, 0x16, 0x00, 0x20,  // .......
-      //   /* 0020 */  0x00, 0x00, 0x00, 0x0E, 0x00, 0x0F, 0x00, 0x5C,  // .......\
-      //   /* 0028 */  0x5F, 0x53, 0x42, 0x2E, 0x47, 0x50, 0x49, 0x30,  // _SB.GPI0
-      //   /* 0030 */  0x00                                             // .
-      //}
-
-    })
-    Return (RBUF)
+    MEMORY32SETBASE (RBUF, RMEM, RBAS, BCM2836_MINI_UART_OFFSET)
+    Return (^RBUF)
   }
 }
 
-- 
2.21.0.windows.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [edk2-platforms][PATCH 06/15] Platform/RPi3: Use Silicon constants in ACPI headers
  2020-02-28 10:38 [edk2-platforms][PATCH 00/15] Platform/RPi: Clean up and factorize ACPI Pete Batard
                   ` (4 preceding siblings ...)
  2020-02-28 10:38 ` [edk2-platforms][PATCH 05/15] Platform/RPi4: Use Silicon constants in ACPI headers Pete Batard
@ 2020-02-28 10:38 ` Pete Batard
  2020-02-28 10:38 ` [edk2-platforms][PATCH 07/15] Platform/RPi3: Switch to .aslc for serial related ACPI tables Pete Batard
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 23+ messages in thread
From: Pete Batard @ 2020-02-28 10:38 UTC (permalink / raw)
  To: devel; +Cc: ard.biesheuvel, leif, philmd

With the new constants added, remove some of the hardcoded values from
the ACPI tables.

Note that because the ASL compiler is very limited in terms of macro
processing, we can not use any arithmetic constants (e.g BASE + OFFSET)
as parameters to MEMORY32FIXED (), and instead must alter the base
address using CreateDwordField () after MEMORY32FIXED () has been
invoked.

To achieve that, we create a MEMORY32SETBASE () macro and move the
MEMORY32FIXED () calls outside of Method (_CRS...).

Signed-off-by: Pete Batard <pete@akeo.ie>
---
 Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.h   |   8 +
 Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.inf |   2 +
 Platform/RaspberryPi/RPi3/AcpiTables/Csrt.aslc      |   8 +-
 Platform/RaspberryPi/RPi3/AcpiTables/Dsdt.asl       | 415 +++++++++++---------
 Platform/RaspberryPi/RPi3/AcpiTables/Sdhc.asl       |  32 +-
 Platform/RaspberryPi/RPi3/AcpiTables/Uart.asl       |  87 ++--
 6 files changed, 306 insertions(+), 246 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.h b/Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.h
index 958af026c8a3..3e68923d3c05 100644
--- a/Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.h
+++ b/Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.h
@@ -14,6 +14,14 @@
 
 #include <IndustryStandard/Acpi50.h>
 
+// The ASL compiler can't perform arithmetic on MEMORY32SETBASE ()
+// parameters so you can't pass a constant like BASE + OFFSET (the
+// compiler just silently sets it to zero). So we need a macro that
+// can perform arithmetic base address update with an offset.
+#define MEMORY32SETBASE(BufName, MemName, VarName, Offset)       \
+    CreateDwordField (^BufName, ^MemName._BAS, VarName)          \
+    Add (BCM2836_SOC_REGISTERS, Offset, VarName)
+
 #define EFI_ACPI_OEM_ID                       {'M','C','R','S','F','T'} // OEMID 6 bytes long
 #define EFI_ACPI_OEM_TABLE_ID                 SIGNATURE_64 ('R','P','I','3','E','D','K','2') // OEM table id 8 bytes long
 #define EFI_ACPI_OEM_REVISION                 0x02000820
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.inf b/Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.inf
index 7ef41e79ad46..942acf2c6660 100644
--- a/Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.inf
+++ b/Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.inf
@@ -35,6 +35,8 @@ [Sources]
 [Packages]
   MdePkg/MdePkg.dec
   EmbeddedPkg/EmbeddedPkg.dec
+  Silicon/Broadcom/Bcm283x/Bcm283x.dec
 
 [FixedPcd]
+  gBcm283xTokenSpaceGuid.PcdBcm283xRegistersAddress
   gEmbeddedTokenSpaceGuid.PcdInterruptBaseAddress
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Csrt.aslc b/Platform/RaspberryPi/RPi3/AcpiTables/Csrt.aslc
index 3b617c0a832b..62f1a1fbdf19 100644
--- a/Platform/RaspberryPi/RPi3/AcpiTables/Csrt.aslc
+++ b/Platform/RaspberryPi/RPi3/AcpiTables/Csrt.aslc
@@ -8,6 +8,8 @@
  *
  **/
 
+#include <IndustryStandard/Bcm2836.h>
+
 #include "AcpiTables.h"
 
 #define DMA_MAX_REQ_LINES 32
@@ -134,9 +136,9 @@ EFI_ACPI_5_0_CSRT_TABLE Csrt =
       {
         sizeof (DMA_CONTROLLER_VENDOR_DATA),  // Controller vendor data here
         1,
-        0x3F007000,                   // Base address for channels
-        RPI3_DMA_CHANNEL_COUNT * 0x100, // Base size = Number of channels x 0x100 size for each channel
-        0x3F007FE0,                   // Base address for controller
+        BCM2836_DMA0_BASE_ADDRESS,    // Base address for channels
+        RPI3_DMA_CHANNEL_COUNT * BCM2836_DMA_CHANNEL_LENGTH, // Base size = Number of channels x channel size
+        BCM2836_DMA_CTRL_BASE_ADDRESS,// Base address for controller
         8,                            // Base size = two registers
         RPI3_DMA_USED_CHANNEL_COUNT,
         0,                            // cannot use controller interrupt
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Dsdt.asl b/Platform/RaspberryPi/RPi3/AcpiTables/Dsdt.asl
index ab4d4bf4851f..693e4b15e985 100644
--- a/Platform/RaspberryPi/RPi3/AcpiTables/Dsdt.asl
+++ b/Platform/RaspberryPi/RPi3/AcpiTables/Dsdt.asl
@@ -2,6 +2,7 @@
  *
  *  Differentiated System Definition Table (DSDT)
  *
+ *  Copyright (c) 2020, Pete Batard <pete@akeo.ie>
  *  Copyright (c) 2018, Andrey Warkentin <andrey.warkentin@gmail.com>
  *  Copyright (c) Microsoft Corporation. All rights reserved.
  *
@@ -9,6 +10,13 @@
  *
  **/
 
+#include <IndustryStandard/Bcm2836.h>
+#include <IndustryStandard/Bcm2836Gpio.h>
+#include <IndustryStandard/Bcm2836Gpu.h>
+#include <IndustryStandard/Bcm2836Pwm.h>
+
+#include "AcpiTables.h"
+
 #define BCM_ALT0 0x4
 #define BCM_ALT1 0x5
 #define BCM_ALT2 0x6
@@ -74,14 +82,15 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       {
         Return (0xf)
       }
+      Name (RBUF, ResourceTemplate ()
+      {
+        MEMORY32FIXED (ReadWrite, 0, BCM2836_USB_LENGTH, RMEM)
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x29 }
+      })
       Method (_CRS, 0x0, Serialized)
       {
-        Name (RBUF, ResourceTemplate ()
-        {
-          MEMORY32FIXED(ReadWrite, 0x3F980000, 0x10000,)
-          Interrupt(ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x29 }
-        })
-        Return(RBUF)
+        MEMORY32SETBASE (RBUF, RMEM, RBAS, BCM2836_USB_OFFSET)
+        Return (^RBUF)
       }
     }
 
@@ -96,44 +105,49 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       {
         Return(0xf)
       }
+      Name (RBUF, ResourceTemplate ()
+      {
+        // Memory and interrupt for the GPU
+        MEMORY32FIXED (ReadWrite, 0, BCM2836_V3D_BUS_LENGTH, RM01)
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x2A }
+
+        // HVS - Hardware Video Scalar
+        MEMORY32FIXED (ReadWrite, 0, BCM2836_HVS_LENGTH, RM02)
+        // The HVS interrupt is reserved by the VPU
+        // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x41 }
+
+        // PixelValve0 - DSI0 or DPI
+        // MEMORY32FIXED (ReadWrite, BCM2836_PV0_BASE_ADDRESS, BCM2836_PV0_LENGTH, RM03)
+        // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x4D }
+
+        // PixelValve1 - DS1 or SMI
+        // MEMORY32FIXED (ReadWrite, BCM2836_PV1_BASE_ADDRESS, BCM2836_PV1_LENGTH, RM04)
+        // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x4E }
+
+        // PixelValve2 - HDMI output - connected to HVS display FIFO 1
+        MEMORY32FIXED (ReadWrite, 0, BCM2836_PV2_LENGTH, RM05)
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x4A }
+
+        // HDMI registers
+        MEMORY32FIXED (ReadWrite, 0, BCM2836_HDMI0_LENGTH, RM06)
+        MEMORY32FIXED (ReadWrite, 0, BCM2836_HDMI1_LENGTH, RM07)
+        // hdmi_int[0]
+        // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x48 }
+        // hdmi_int[1]
+        // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x49 }
+
+        // HDMI DDC connection
+        I2CSerialBus (0x50,, 100000,, "\\_SB.I2C2",,,,)  // EDID
+        I2CSerialBus (0x30,, 100000,, "\\_SB.I2C2",,,,)  // E-DDC Segment Pointer
+      })
       Method (_CRS, 0x0, Serialized)
       {
-        Name (RBUF, ResourceTemplate ()
-        {
-          // Memory and interrupt for the GPU
-          MEMORY32FIXED(ReadWrite, 0x3FC00000, 0x1000,)
-          Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x2A }
-
-          // HVS - Hardware Video Scalar
-          MEMORY32FIXED (ReadWrite, 0x3F400000, 0x6000,)
-          // The HVS interrupt is reserved by the VPU
-          // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x41 }
-
-          // PixelValve0 - DSI0 or DPI
-          // MEMORY32FIXED (ReadWrite, 0x3F206000, 0x100,)
-          // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x4D }
-
-          // PixelValve1 - DS1 or SMI
-          // MEMORY32FIXED (ReadWrite, 0x73F207000, 0x100,)
-          // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x4E }
-
-          // PixelValve2 - HDMI output - connected to HVS display FIFO 1
-          MEMORY32FIXED (ReadWrite, 0x3F807000, 0x100,)
-          Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x4A }
-
-          // HDMI registers
-          MEMORY32FIXED (ReadWrite, 0x3F902000, 0x600,)   // HDMI registers
-          MEMORY32FIXED (ReadWrite, 0x3F808000, 0x100,)   // HD registers
-          // hdmi_int[0]
-          // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x48 }
-          // hdmi_int[1]
-          // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x49 }
-
-          // HDMI DDC connection
-          I2CSerialBus (0x50,, 100000,, "\\_SB.I2C2",,,,)  // EDID
-          I2CSerialBus (0x30,, 100000,, "\\_SB.I2C2",,,,)  // E-DDC Segment Pointer
-        })
-        Return(RBUF)
+        MEMORY32SETBASE (RBUF, RM01, RB01, BCM2836_V3D_BUS_OFFSET)
+        MEMORY32SETBASE (RBUF, RM02, RB02, BCM2836_HVS_OFFSET)
+        MEMORY32SETBASE (RBUF, RM05, RB05, BCM2836_PV2_OFFSET)
+        MEMORY32SETBASE (RBUF, RM06, RB06, BCM2836_HDMI0_OFFSET)
+        MEMORY32SETBASE (RBUF, RM07, RB07, BCM2836_HDMI1_OFFSET)
+        Return (^RBUF)
       }
 
       // GPU Power Management Component Data
@@ -195,14 +209,16 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       {
         Return (0xf)
       }
+      Name (RBUF, ResourceTemplate ()
+      {
+        MEMORY32FIXED (ReadWrite, 0, BCM2836_MBOX_LENGTH, RMEM)
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x61 }
+      })
+
       Method (_CRS, 0x0, Serialized)
       {
-        Name (RBUF, ResourceTemplate ()
-        {
-          Memory32Fixed (ReadWrite, 0x3F00B880, 0x00000024,)
-          Interrupt(ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x61 }
-        })
-        Return (RBUF)
+        MEMORY32SETBASE (RBUF, RMEM, RBAS, BCM2836_MBOX_OFFSET)
+        Return (^RBUF)
       }
     }
 
@@ -218,14 +234,16 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       {
          Return (0xf)
       }
+      Name (RBUF, ResourceTemplate ()
+      {
+        MEMORY32FIXED (ReadWrite, 0, BCM2836_VCHIQ_LENGTH, RMEM)
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x62 }
+      })
+
       Method (_CRS, 0x0, Serialized)
       {
-        Name (RBUF, ResourceTemplate ()
-        {
-          Memory32Fixed (ReadWrite, 0x3F00B840, 0x00000010,)
-          Interrupt(ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x62 }
-        })
-        Return (RBUF)
+        MEMORY32SETBASE (RBUF, RMEM, RBAS, BCM2836_VCHIQ_OFFSET)
+        Return (^RBUF)
       }
     }
 
@@ -254,15 +272,15 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       {
         Return(0xf)
       }
+      Name (RBUF, ResourceTemplate ()
+      {
+        MEMORY32FIXED (ReadWrite, 0, GPIO_LENGTH, RMEM)
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { 0x51, 0x53 }
+      })
       Method (_CRS, 0x0, Serialized)
       {
-        Name (RBUF, ResourceTemplate ()
-        {
-          MEMORY32FIXED (ReadWrite, 0x3F200000, 0xB4, )
-          Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { 0x51 }
-          Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { 0x53 }
-        })
-        Return (RBUF)
+        MEMORY32SETBASE (RBUF, RMEM, RBAS, GPIO_OFFSET)
+        Return (^RBUF)
       }
     }
 
@@ -277,30 +295,31 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       {
         Return(0xf)
       }
-      Method (_CRS, 0x0, Serialized)
+      Name (RBUF, ResourceTemplate ()
       {
-        Name (RBUF, ResourceTemplate ()
-        {
-          Memory32Fixed(ReadWrite, 0x3F804000, 0x20)
-          Interrupt(ResourceConsumer, Level, ActiveHigh, Shared) {0x55}
+        MEMORY32FIXED (ReadWrite, 0, BCM2836_I2C1_LENGTH, RMEM)
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { 0x55 }
 
-          //
-          // MsftFunctionConfig is encoded as the VendorLong.
-          //
-          // MsftFunctionConfig (Exclusive, PullUp, BCM_ALT0, "\\_SB.GPI0", 0, ResourceConsumer,) {2, 3}
-          //
-          VendorLong ()      // Length = 0x31
-          {
-            /* 0000 */  0x00, 0x60, 0x44, 0xD5, 0xF3, 0x1F, 0x11, 0x60,  // .`D....`
-            /* 0008 */  0x4A, 0xB8, 0xB0, 0x9C, 0x2D, 0x23, 0x30, 0xDD,  // J...-#0.
-            /* 0010 */  0x2F, 0x8D, 0x1D, 0x00, 0x01, 0x10, 0x00, 0x01,  // /.......
-            /* 0018 */  0x04, 0x00, 0x12, 0x00, 0x00, 0x16, 0x00, 0x20,  // ........
-            /* 0020 */  0x00, 0x00, 0x00, 0x02, 0x00, 0x03, 0x00, 0x5C,  // ........
-            /* 0028 */  0x5F, 0x53, 0x42, 0x2E, 0x47, 0x50, 0x49, 0x30,  // _SB.GPI0
-            /* 0030 */  0x00                                             // .
-          }
-        })
-        Return (RBUF)
+        //
+        // MsftFunctionConfig is encoded as the VendorLong.
+        //
+        // MsftFunctionConfig (Exclusive, PullUp, BCM_ALT0, "\\_SB.GPI0", 0, ResourceConsumer,) {2, 3}
+        //
+        VendorLong ()      // Length = 0x31
+        {
+          /* 0000 */  0x00, 0x60, 0x44, 0xD5, 0xF3, 0x1F, 0x11, 0x60,  // .`D....`
+          /* 0008 */  0x4A, 0xB8, 0xB0, 0x9C, 0x2D, 0x23, 0x30, 0xDD,  // J...-#0.
+          /* 0010 */  0x2F, 0x8D, 0x1D, 0x00, 0x01, 0x10, 0x00, 0x01,  // /.......
+          /* 0018 */  0x04, 0x00, 0x12, 0x00, 0x00, 0x16, 0x00, 0x20,  // ........
+          /* 0020 */  0x00, 0x00, 0x00, 0x02, 0x00, 0x03, 0x00, 0x5C,  // ........
+          /* 0028 */  0x5F, 0x53, 0x42, 0x2E, 0x47, 0x50, 0x49, 0x30,  // _SB.GPI0
+          /* 0030 */  0x00                                             // .
+        }
+      })
+      Method (_CRS, 0x0, Serialized)
+      {
+        MEMORY32SETBASE (RBUF, RMEM, RBAS, BCM2836_I2C1_OFFSET)
+        Return (^RBUF)
       }
     }
 
@@ -315,14 +334,16 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       {
         Return (0xf)
       }
+      Name (RBUF, ResourceTemplate()
+      {
+        MEMORY32FIXED (ReadWrite, 0, BCM2836_I2C2_LENGTH, RMEM)
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { 0x55 }
+      })
+
       Method (_CRS, 0x0, Serialized)
       {
-        Name (RBUF, ResourceTemplate()
-        {
-          Memory32Fixed (ReadWrite, 0x3F805000, 0x20)
-          Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) {0x55}
-        })
-        Return (RBUF)
+        MEMORY32SETBASE (RBUF, RMEM, RBAS, BCM2836_I2C2_OFFSET)
+        Return (^RBUF)
       }
     }
 
@@ -337,57 +358,59 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       {
         Return (0xf)
       }
+      Name (RBUF, ResourceTemplate ()
+      {
+        MEMORY32FIXED (ReadWrite, 0, BCM2836_SPI0_LENGTH, RMEM)
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { 0x56 }
+
+        //
+        // MsftFunctionConfig is encoded as the VendorLong.
+        //
+        // MsftFunctionConfig (Exclusive, PullDown, BCM_ALT0, "\\_SB.GPI0", 0, ResourceConsumer, ) {9, 10, 11} // MISO, MOSI, SCLK
+        VendorLong ()      // Length = 0x33
+        {
+          /* 0000 */  0x00, 0x60, 0x44, 0xD5, 0xF3, 0x1F, 0x11, 0x60,  // .`D....`
+          /* 0008 */  0x4A, 0xB8, 0xB0, 0x9C, 0x2D, 0x23, 0x30, 0xDD,  // J...-#0.
+          /* 0010 */  0x2F, 0x8D, 0x1F, 0x00, 0x01, 0x10, 0x00, 0x02,  // /.......
+          /* 0018 */  0x04, 0x00, 0x12, 0x00, 0x00, 0x18, 0x00, 0x22,  // ......."
+          /* 0020 */  0x00, 0x00, 0x00, 0x09, 0x00, 0x0A, 0x00, 0x0B,  // ........
+          /* 0028 */  0x00, 0x5C, 0x5F, 0x53, 0x42, 0x2E, 0x47, 0x50,  // .\_SB.GP
+          /* 0030 */  0x49, 0x30, 0x00                                 // I0.
+        }
+
+        //
+        // MsftFunctionConfig is encoded as the VendorLong.
+        //
+        // MsftFunctionConfig (Exclusive, PullUp, BCM_ALT0, "\\_SB.GPI0", 0, ResourceConsumer, ) {8}     // CE0
+        VendorLong ()      // Length = 0x2F
+        {
+          /* 0000 */  0x00, 0x60, 0x44, 0xD5, 0xF3, 0x1F, 0x11, 0x60,  // .`D....`
+          /* 0008 */  0x4A, 0xB8, 0xB0, 0x9C, 0x2D, 0x23, 0x30, 0xDD,  // J...-#0.
+          /* 0010 */  0x2F, 0x8D, 0x1B, 0x00, 0x01, 0x10, 0x00, 0x01,  // /.......
+          /* 0018 */  0x04, 0x00, 0x12, 0x00, 0x00, 0x14, 0x00, 0x1E,  // ........
+          /* 0020 */  0x00, 0x00, 0x00, 0x08, 0x00, 0x5C, 0x5F, 0x53,  // .....\_S
+          /* 0028 */  0x42, 0x2E, 0x47, 0x50, 0x49, 0x30, 0x00         // B.GPI0.
+        }
+
+        //
+        // MsftFunctionConfig is encoded as the VendorLong.
+        //
+        // MsftFunctionConfig (Exclusive, PullUp, BCM_ALT0, "\\_SB.GPI0", 0, ResourceConsumer, ) {7}     // CE1
+        VendorLong ()      // Length = 0x2F
+        {
+          /* 0000 */  0x00, 0x60, 0x44, 0xD5, 0xF3, 0x1F, 0x11, 0x60,  // .`D....`
+          /* 0008 */  0x4A, 0xB8, 0xB0, 0x9C, 0x2D, 0x23, 0x30, 0xDD,  // J...-#0.
+          /* 0010 */  0x2F, 0x8D, 0x1B, 0x00, 0x01, 0x10, 0x00, 0x01,  // /.......
+          /* 0018 */  0x04, 0x00, 0x12, 0x00, 0x00, 0x14, 0x00, 0x1E,  // ........
+          /* 0020 */  0x00, 0x00, 0x00, 0x07, 0x00, 0x5C, 0x5F, 0x53,  // .....\_S
+          /* 0028 */  0x42, 0x2E, 0x47, 0x50, 0x49, 0x30, 0x00         // B.GPI0.
+        }
+      })
+
       Method (_CRS, 0x0, Serialized)
       {
-        Name (RBUF, ResourceTemplate ()
-        {
-          MEMORY32FIXED (ReadWrite, 0x3F204000, 0x20,)
-          Interrupt(ResourceConsumer, Level, ActiveHigh, Shared) {0x56}
-
-          //
-          // MsftFunctionConfig is encoded as the VendorLong.
-          //
-          // MsftFunctionConfig (Exclusive, PullDown, BCM_ALT0, "\\_SB.GPI0", 0, ResourceConsumer, ) {9, 10, 11} // MISO, MOSI, SCLK
-          VendorLong ()      // Length = 0x33
-          {
-            /* 0000 */  0x00, 0x60, 0x44, 0xD5, 0xF3, 0x1F, 0x11, 0x60,  // .`D....`
-            /* 0008 */  0x4A, 0xB8, 0xB0, 0x9C, 0x2D, 0x23, 0x30, 0xDD,  // J...-#0.
-            /* 0010 */  0x2F, 0x8D, 0x1F, 0x00, 0x01, 0x10, 0x00, 0x02,  // /.......
-            /* 0018 */  0x04, 0x00, 0x12, 0x00, 0x00, 0x18, 0x00, 0x22,  // ......."
-            /* 0020 */  0x00, 0x00, 0x00, 0x09, 0x00, 0x0A, 0x00, 0x0B,  // ........
-            /* 0028 */  0x00, 0x5C, 0x5F, 0x53, 0x42, 0x2E, 0x47, 0x50,  // .\_SB.GP
-            /* 0030 */  0x49, 0x30, 0x00                                 // I0.
-          }
-
-          //
-          // MsftFunctionConfig is encoded as the VendorLong.
-          //
-          // MsftFunctionConfig (Exclusive, PullUp, BCM_ALT0, "\\_SB.GPI0", 0, ResourceConsumer, ) {8}     // CE0
-          VendorLong ()      // Length = 0x2F
-          {
-            /* 0000 */  0x00, 0x60, 0x44, 0xD5, 0xF3, 0x1F, 0x11, 0x60,  // .`D....`
-            /* 0008 */  0x4A, 0xB8, 0xB0, 0x9C, 0x2D, 0x23, 0x30, 0xDD,  // J...-#0.
-            /* 0010 */  0x2F, 0x8D, 0x1B, 0x00, 0x01, 0x10, 0x00, 0x01,  // /.......
-            /* 0018 */  0x04, 0x00, 0x12, 0x00, 0x00, 0x14, 0x00, 0x1E,  // ........
-            /* 0020 */  0x00, 0x00, 0x00, 0x08, 0x00, 0x5C, 0x5F, 0x53,  // .....\_S
-            /* 0028 */  0x42, 0x2E, 0x47, 0x50, 0x49, 0x30, 0x00         // B.GPI0.
-          }
-
-          //
-          // MsftFunctionConfig is encoded as the VendorLong.
-          //
-          // MsftFunctionConfig (Exclusive, PullUp, BCM_ALT0, "\\_SB.GPI0", 0, ResourceConsumer, ) {7}     // CE1
-          VendorLong ()      // Length = 0x2F
-          {
-            /* 0000 */  0x00, 0x60, 0x44, 0xD5, 0xF3, 0x1F, 0x11, 0x60,  // .`D....`
-            /* 0008 */  0x4A, 0xB8, 0xB0, 0x9C, 0x2D, 0x23, 0x30, 0xDD,  // J...-#0.
-            /* 0010 */  0x2F, 0x8D, 0x1B, 0x00, 0x01, 0x10, 0x00, 0x01,  // /.......
-            /* 0018 */  0x04, 0x00, 0x12, 0x00, 0x00, 0x14, 0x00, 0x1E,  // ........
-            /* 0020 */  0x00, 0x00, 0x00, 0x07, 0x00, 0x5C, 0x5F, 0x53,  // .....\_S
-            /* 0028 */  0x42, 0x2E, 0x47, 0x50, 0x49, 0x30, 0x00         // B.GPI0.
-          }
-        })
-        Return (RBUF)
+        MEMORY32SETBASE (RBUF, RMEM, RBAS, BCM2836_SPI0_OFFSET)
+        Return (^RBUF)
       }
     }
 
@@ -402,43 +425,45 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       {
         Return (0xf)
       }
+      Name (RBUF, ResourceTemplate ()
+      {
+        MEMORY32FIXED (ReadWrite, 0, BCM2836_SPI1_LENGTH, RMEM)
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Shared,) { 0x3D }
+
+        //
+        // MsftFunctionConfig is encoded as the VendorLong.
+        //
+        // MsftFunctionConfig(Exclusive, PullDown, BCM_ALT4, "\\_SB.GPI0", 0, ResourceConsumer, ) {19, 20, 21} // MISO, MOSI, SCLK
+        VendorLong ()      // Length = 0x33
+        {
+          /* 0000 */  0x00, 0x60, 0x44, 0xD5, 0xF3, 0x1F, 0x11, 0x60,  // .`D....`
+          /* 0008 */  0x4A, 0xB8, 0xB0, 0x9C, 0x2D, 0x23, 0x30, 0xDD,  // J...-#0.
+          /* 0010 */  0x2F, 0x8D, 0x1F, 0x00, 0x01, 0x10, 0x00, 0x02,  // /.......
+          /* 0018 */  0x03, 0x00, 0x12, 0x00, 0x00, 0x18, 0x00, 0x22,  // ......."
+          /* 0020 */  0x00, 0x00, 0x00, 0x13, 0x00, 0x14, 0x00, 0x15,  // ........
+          /* 0028 */  0x00, 0x5C, 0x5F, 0x53, 0x42, 0x2E, 0x47, 0x50,  // .\_SB.GP
+          /* 0030 */  0x49, 0x30, 0x00                                 // I0.
+        }
+
+        //
+        // MsftFunctionConfig is encoded as the VendorLong.
+        //
+        // MsftFunctionConfig(Exclusive, PullDown, BCM_ALT4, "\\_SB.GPI0", 0, ResourceConsumer, ) {16} // CE2
+        VendorLong ()      // Length = 0x2F
+        {
+          /* 0000 */  0x00, 0x60, 0x44, 0xD5, 0xF3, 0x1F, 0x11, 0x60,  // .`D....`
+          /* 0008 */  0x4A, 0xB8, 0xB0, 0x9C, 0x2D, 0x23, 0x30, 0xDD,  // J...-#0.
+          /* 0010 */  0x2F, 0x8D, 0x1B, 0x00, 0x01, 0x10, 0x00, 0x02,  // /.......
+          /* 0018 */  0x03, 0x00, 0x12, 0x00, 0x00, 0x14, 0x00, 0x1E,  // ........
+          /* 0020 */  0x00, 0x00, 0x00, 0x10, 0x00, 0x5C, 0x5F, 0x53,  // .....\_S
+          /* 0028 */  0x42, 0x2E, 0x47, 0x50, 0x49, 0x30, 0x00         // B.GPI0.
+        }
+      })
+
       Method (_CRS, 0x0, Serialized)
       {
-        Name (RBUF, ResourceTemplate ()
-        {
-          MEMORY32FIXED (ReadWrite, 0x3F215080, 0x40,)
-          Interrupt (ResourceConsumer, Level, ActiveHigh, Shared,) {0x3D}
-
-          //
-          // MsftFunctionConfig is encoded as the VendorLong.
-          //
-          // MsftFunctionConfig(Exclusive, PullDown, BCM_ALT4, "\\_SB.GPI0", 0, ResourceConsumer, ) {19, 20, 21} // MISO, MOSI, SCLK
-          VendorLong ()      // Length = 0x33
-          {
-            /* 0000 */  0x00, 0x60, 0x44, 0xD5, 0xF3, 0x1F, 0x11, 0x60,  // .`D....`
-            /* 0008 */  0x4A, 0xB8, 0xB0, 0x9C, 0x2D, 0x23, 0x30, 0xDD,  // J...-#0.
-            /* 0010 */  0x2F, 0x8D, 0x1F, 0x00, 0x01, 0x10, 0x00, 0x02,  // /.......
-            /* 0018 */  0x03, 0x00, 0x12, 0x00, 0x00, 0x18, 0x00, 0x22,  // ......."
-            /* 0020 */  0x00, 0x00, 0x00, 0x13, 0x00, 0x14, 0x00, 0x15,  // ........
-            /* 0028 */  0x00, 0x5C, 0x5F, 0x53, 0x42, 0x2E, 0x47, 0x50,  // .\_SB.GP
-            /* 0030 */  0x49, 0x30, 0x00                                 // I0.
-          }
-
-          //
-          // MsftFunctionConfig is encoded as the VendorLong.
-          //
-          // MsftFunctionConfig(Exclusive, PullDown, BCM_ALT4, "\\_SB.GPI0", 0, ResourceConsumer, ) {16} // CE2
-          VendorLong ()      // Length = 0x2F
-          {
-            /* 0000 */  0x00, 0x60, 0x44, 0xD5, 0xF3, 0x1F, 0x11, 0x60,  // .`D....`
-            /* 0008 */  0x4A, 0xB8, 0xB0, 0x9C, 0x2D, 0x23, 0x30, 0xDD,  // J...-#0.
-            /* 0010 */  0x2F, 0x8D, 0x1B, 0x00, 0x01, 0x10, 0x00, 0x02,  // /.......
-            /* 0018 */  0x03, 0x00, 0x12, 0x00, 0x00, 0x14, 0x00, 0x1E,  // ........
-            /* 0020 */  0x00, 0x00, 0x00, 0x10, 0x00, 0x5C, 0x5F, 0x53,  // .....\_S
-            /* 0028 */  0x42, 0x2E, 0x47, 0x50, 0x49, 0x30, 0x00         // B.GPI0.
-          }
-        })
-        Return (RBUF)
+        MEMORY32SETBASE (RBUF, RMEM, RBAS, BCM2836_SPI1_OFFSET)
+        Return (^RBUF)
       }
     }
 
@@ -458,8 +483,8 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
     //   {
     //     Name (RBUF, ResourceTemplate ()
     //     {
-    //       MEMORY32FIXED (ReadWrite, 0x3F2150C0, 0x40,)
-    //       Interrupt (ResourceConsumer, Level, ActiveHigh, Shared,) {0x3D}
+    //       MEMORY32FIXED (ReadWrite, BCM2836_SPI2_BASE_ADDRESS, BCM2836_SPI2_LENGTH, RMEM)
+    //       Interrupt (ResourceConsumer, Level, ActiveHigh, Shared,) { 0x3D }
     //     })
     //     Return (RBUF)
     //   }
@@ -476,26 +501,30 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       {
         Return (0xf)
       }
+      Name (RBUF, ResourceTemplate ()
+      {
+        // DMA channel 11 control
+        MEMORY32FIXED (ReadWrite, 0, BCM2836_PWM_DMA_LENGTH, RM01)
+        // PWM control
+        MEMORY32FIXED (ReadWrite, 0, BCM2836_PWM_CTRL_LENGTH, RM02)
+        // PWM control bus
+        MEMORY32FIXED (ReadWrite, BCM2836_PWM_BUS_BASE_ADDRESS, BCM2836_PWM_BUS_LENGTH, )
+        // PWM control uncached
+        MEMORY32FIXED (ReadWrite, BCM2836_PWM_CTRL_UNCACHED_BASE_ADDRESS, BCM2836_PWM_CTRL_UNCACHED_LENGTH, )
+        // PWM clock control
+        MEMORY32FIXED (ReadWrite, 0, BCM2836_PWM_CLK_LENGTH, RM03)
+        // Interrupt DMA channel 11
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x3B }
+        // DMA channel 11, DREQ 5 for PWM
+        FixedDMA (5, 11, Width32Bit, )
+      })
+
       Method (_CRS, 0x0, Serialized)
       {
-        Name (RBUF, ResourceTemplate ()
-        {
-          // DMA channel 11 control
-          Memory32Fixed (ReadWrite, 0x3F007B00, 0x00000100,)
-          // PWM control
-          Memory32Fixed (ReadWrite, 0x3F20C000, 0x00000028,)
-          // PWM control bus
-          Memory32Fixed (ReadWrite, 0x7E20C000, 0x00000028,)
-          // PWM control uncached
-          Memory32Fixed (ReadWrite, 0xFF20C000, 0x00000028,)
-          // PWM clock control
-          Memory32Fixed (ReadWrite, 0x3F1010A0, 0x00000008,)
-          // Interrupt DMA channel 11
-          Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x3B }
-          // DMA channel 11, DREQ 5 for PWM
-          FixedDMA (5, 11, Width32Bit, )
-        })
-        Return (RBUF)
+        MEMORY32SETBASE (RBUF, RM01, RB01, BCM2836_PWM_DMA_OFFSET)
+        MEMORY32SETBASE (RBUF, RM02, RB02, BCM2836_PWM_CTRL_OFFSET)
+        MEMORY32SETBASE (RBUF, RM03, RB03, BCM2836_PWM_CLK_OFFSET)
+        Return (^RBUF)
       }
     }
 
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Sdhc.asl b/Platform/RaspberryPi/RPi3/AcpiTables/Sdhc.asl
index 0d42db30ae22..f7553280b60e 100644
--- a/Platform/RaspberryPi/RPi3/AcpiTables/Sdhc.asl
+++ b/Platform/RaspberryPi/RPi3/AcpiTables/Sdhc.asl
@@ -2,6 +2,7 @@
  *
  *  [DSDT] SD controller/card definition (SDHC)
  *
+ *  Copyright (c) 2020, Pete Batard <pete@akeo.ie>
  *  Copyright (c) 2018, Andrey Warkentin <andrey.warkentin@gmail.com>
  *  Copyright (c) Microsoft Corporation. All rights reserved.
  *
@@ -9,6 +10,11 @@
  *
  **/
 
+#include <IndustryStandard/Bcm2836SdHost.h>
+#include <IndustryStandard/Bcm2836Sdio.h>
+
+#include "AcpiTables.h"
+
 //
 // Note: UEFI can use either SDHost or Arasan. We expose both to the OS.
 //
@@ -28,14 +34,15 @@ Device (SDC1)
   {
     Return(0xf)
   }
+  Name (RBUF, ResourceTemplate ()
+  {
+    MEMORY32FIXED (ReadWrite, 0, MMCHS1_LENGTH, RMEM)
+    Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x5E }
+  })
   Method (_CRS, 0x0, Serialized)
   {
-    Name (RBUF, ResourceTemplate ()
-    {
-      MEMORY32FIXED (ReadWrite, 0x3F300000, 0x100,)
-      Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x5E }
-    })
-    Return (RBUF)
+    MEMORY32SETBASE (RBUF, RMEM, RBAS, MMCHS1_OFFSET)
+    Return (^RBUF)
   }
 
   //
@@ -71,14 +78,15 @@ Device (SDC2)
   {
     Return (0xf)
   }
+  Name (RBUF, ResourceTemplate ()
+  {
+    MEMORY32FIXED (ReadWrite, 0, SDHOST_LENGTH, RMEM)
+    Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x58 }
+  })
   Method (_CRS, 0x0, Serialized)
   {
-    Name (RBUF, ResourceTemplate ()
-    {
-      MEMORY32FIXED (ReadWrite, 0x3F202000, 0x100,)
-      Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x58 }
-    })
-    Return (RBUF)
+    MEMORY32SETBASE (RBUF, RMEM, RBAS, SDHOST_OFFSET)
+    Return (^RBUF)
   }
 
   //
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Uart.asl b/Platform/RaspberryPi/RPi3/AcpiTables/Uart.asl
index a0067c82c661..ddab63f15268 100644
--- a/Platform/RaspberryPi/RPi3/AcpiTables/Uart.asl
+++ b/Platform/RaspberryPi/RPi3/AcpiTables/Uart.asl
@@ -2,6 +2,7 @@
  *
  *  [DSDT] Serial devices (UART).
  *
+ *  Copyright (c) 2020, Pete Batard <pete@akeo.ie>
  *  Copyright (c) 2018, Andrey Warkentin <andrey.warkentin@gmail.com>
  *  Copyright (c) Microsoft Corporation. All rights reserved.
  *
@@ -9,28 +10,33 @@
  *
  **/
 
+#include <IndustryStandard/Bcm2836.h>
+
+#include "AcpiTables.h"
+
 // PL011 based UART.
 Device (URT0)
 {
   Name (_HID, "BCM2837")
-  Name (_CID, "HID3123")
+  Name (_CID, "ARMH0011")
   Name (_UID, 0x4)
   Name (_CCA, 0x0)
   Method (_STA)
   {
     Return (0xf)
   }
+  Name (RBUF, ResourceTemplate ()
+  {
+    MEMORY32FIXED (ReadWrite, 0, BCM2836_PL011_UART_LENGTH, RMEM)
+    Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x59 }
+  })
   Method (_CRS, 0x0, Serialized)
   {
-    Name (RBUF, ResourceTemplate ()
-    {
-      MEMORY32FIXED (ReadWrite, 0x3F201000, 0x1000,)
-      Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x59 }
-    })
-    Return (RBUF)
+    MEMORY32SETBASE (RBUF, RMEM, RBAS, BCM2836_PL011_UART_OFFSET)
+    Return (^RBUF)
   }
 
-  Name (CLCK, 3000000)
+  Name (CLCK, 48000000)
 
   Name (_DSD, Package ()
   {
@@ -59,37 +65,38 @@ Device (URTM)
   {
     Return (0xf)
   }
+  Name (RBUF, ResourceTemplate ()
+  {
+    MEMORY32FIXED (ReadWrite, 0, BCM2836_MINI_UART_LENGTH, RMEM)
+    Interrupt(ResourceConsumer, Level, ActiveHigh, Shared) { 0x3D }
+
+    // NTRAID#MSFT-7141401-2016/04/7-jordanrh - disable UART muxing
+    // until a proper solution can be created for the dmap conflict.
+    // When muxing is enabled, must consider DBG2 table conflict.
+    // The alternate function resource needs to be reserved when
+    // the kernel debugger is enabled to prevent another client
+    // from muxing the pins away.
+
+    //
+    // MsftFunctionConfig is encoded as the VendorLong.
+    //
+    // MsftFunctionConfig(Exclusive, PullDown, BCM_ALT5, "\\_SB.GPI0", 0, ResourceConsumer, ) {14, 15}
+    // VendorLong  ()      // Length = 0x31
+    // {
+    //   /* 0000 */  0x00, 0x60, 0x44, 0xD5, 0xF3, 0x1F, 0x11, 0x60,  // .`D....`
+    //   /* 0008 */  0x4A, 0xB8, 0xB0, 0x9C, 0x2D, 0x23, 0x30, 0xDD,  // J...-#0.
+    //   /* 0010 */  0x2F, 0x8D, 0x1D, 0x00, 0x01, 0x10, 0x00, 0x02,  // /.......
+    //   /* 0018 */  0x02, 0x00, 0x12, 0x00, 0x00, 0x16, 0x00, 0x20,  // .......
+    //   /* 0020 */  0x00, 0x00, 0x00, 0x0E, 0x00, 0x0F, 0x00, 0x5C,  // .......\
+    //   /* 0028 */  0x5F, 0x53, 0x42, 0x2E, 0x47, 0x50, 0x49, 0x30,  // _SB.GPI0
+    //   /* 0030 */  0x00                                             // .
+    //}
+
+  })
   Method (_CRS, 0x0, Serialized)
   {
-    Name (RBUF, ResourceTemplate ()
-    {
-      MEMORY32FIXED (ReadWrite, 0x3F215000, 0x70,)
-      Interrupt(ResourceConsumer, Level, ActiveHigh, Shared) {0x3D}
-
-      // NTRAID#MSFT-7141401-2016/04/7-jordanrh - disable UART muxing
-      // until a proper solution can be created for the dmap conflict.
-      // When muxing is enabled, must consider DBG2 table conflict.
-      // The alternate function resource needs to be reserved when
-      // the kernel debugger is enabled to prevent another client
-      // from muxing the pins away.
-
-      //
-      // MsftFunctionConfig is encoded as the VendorLong.
-      //
-      // MsftFunctionConfig(Exclusive, PullDown, BCM_ALT5, "\\_SB.GPI0", 0, ResourceConsumer, ) {14, 15}
-      // VendorLong  ()      // Length = 0x31
-      // {
-      //   /* 0000 */  0x00, 0x60, 0x44, 0xD5, 0xF3, 0x1F, 0x11, 0x60,  // .`D....`
-      //   /* 0008 */  0x4A, 0xB8, 0xB0, 0x9C, 0x2D, 0x23, 0x30, 0xDD,  // J...-#0.
-      //   /* 0010 */  0x2F, 0x8D, 0x1D, 0x00, 0x01, 0x10, 0x00, 0x02,  // /.......
-      //   /* 0018 */  0x02, 0x00, 0x12, 0x00, 0x00, 0x16, 0x00, 0x20,  // .......
-      //   /* 0020 */  0x00, 0x00, 0x00, 0x0E, 0x00, 0x0F, 0x00, 0x5C,  // .......\
-      //   /* 0028 */  0x5F, 0x53, 0x42, 0x2E, 0x47, 0x50, 0x49, 0x30,  // _SB.GPI0
-      //   /* 0030 */  0x00                                             // .
-      //}
-
-    })
-    Return (RBUF)
+    MEMORY32SETBASE (RBUF, RMEM, RBAS, BCM2836_MINI_UART_OFFSET)
+    Return (^RBUF)
   }
 }
 
@@ -108,7 +115,7 @@ Device(BTH0)
   {
     Name (RBUF, ResourceTemplate ()
     {
-      // BT UART: UART0 (PL011)
+      // BT UART: URT0 (PL011) or URTM (miniUART)
       UARTSerialBus(
         115200,        // InitialBaudRate: in BPS
         ,              // BitsPerByte: default to 8 bits
@@ -133,7 +140,11 @@ Device(BTH0)
                        //   no flow control.
         16,            // ReceiveBufferSize
         16,            // TransmitBufferSize
+#ifdef PL011_ENABLE
+        "\\_SB.URTM",  // ResourceSource:
+#else
         "\\_SB.URT0",  // ResourceSource:
+#endif
                        //   UART bus controller name
         ,              // ResourceSourceIndex: assumed to be 0
         ,              // ResourceUsage: assumed to be
-- 
2.21.0.windows.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [edk2-platforms][PATCH 07/15] Platform/RPi3: Switch to .aslc for serial related ACPI tables
  2020-02-28 10:38 [edk2-platforms][PATCH 00/15] Platform/RPi: Clean up and factorize ACPI Pete Batard
                   ` (5 preceding siblings ...)
  2020-02-28 10:38 ` [edk2-platforms][PATCH 06/15] Platform/RPi3: " Pete Batard
@ 2020-02-28 10:38 ` Pete Batard
  2020-02-28 10:38 ` [edk2-platforms][PATCH 08/15] Platform/RPi3: Update CSRT table to ACPI 5.1 Pete Batard
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 23+ messages in thread
From: Pete Batard @ 2020-02-28 10:38 UTC (permalink / raw)
  To: devel; +Cc: ard.biesheuvel, leif, philmd

Apart from the serial interrupt constants, the SPCR and DBG2 .aslc
we use for the Pi 4 platform can be applied as is for the Pi 3.

As a result, we replace the existing binary blobs with formal ASLC.

Signed-off-by: Pete Batard <pete@akeo.ie>
---
 Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.inf |   3 +-
 Platform/RaspberryPi/RPi3/AcpiTables/Dbg2.aslc      | 105 +++++++++++++++++---
 Platform/RaspberryPi/RPi3/AcpiTables/Spcr.asl       |  47 ---------
 Platform/RaspberryPi/RPi3/AcpiTables/Spcr.aslc      |  96 ++++++++++++++++++
 4 files changed, 189 insertions(+), 62 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.inf b/Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.inf
index 942acf2c6660..4b4e431da650 100644
--- a/Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.inf
+++ b/Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.inf
@@ -30,7 +30,7 @@ [Sources]
   Gtdt.aslc
   Dsdt.asl
   Csrt.aslc
-  Spcr.asl
+  Spcr.aslc
 
 [Packages]
   MdePkg/MdePkg.dec
@@ -39,4 +39,5 @@ [Packages]
 
 [FixedPcd]
   gBcm283xTokenSpaceGuid.PcdBcm283xRegistersAddress
+  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate
   gEmbeddedTokenSpaceGuid.PcdInterruptBaseAddress
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Dbg2.aslc b/Platform/RaspberryPi/RPi3/AcpiTables/Dbg2.aslc
index 9315f23e0d2d..dcad8e205596 100644
--- a/Platform/RaspberryPi/RPi3/AcpiTables/Dbg2.aslc
+++ b/Platform/RaspberryPi/RPi3/AcpiTables/Dbg2.aslc
@@ -2,27 +2,104 @@
  *
  *  Debug Port Table (DBG2)
  *
- *  Copyright (c) Microsoft Corporation. All rights reserved.
+ *  Copyright (c) 2019, Pete Batard <pete@akeo.ie>
+ *  Copyright (c) 2012-2016, ARM Limited. All rights reserved.
  *
  *  SPDX-License-Identifier: BSD-2-Clause-Patent
  *
  **/
 
-UINT8 Dbg2[92] = {
-  0x44, 0x42, 0x47, 0x32, 0x5C, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x4D, 0x53, 0x46, 0x54, 0x20, 0x20, 0x45, 0x44, 0x4B, 0x32,
-  0x20, 0x20, 0x20, 0x20, 0x01, 0x00, 0x00, 0x00, 0x4D, 0x53,
-  0x46, 0x54, 0x01, 0x00, 0x00, 0x00, 0x2C, 0x00, 0x00, 0x00,
-  0x01, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x01, 0x0A, 0x00,
-  0x26, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x80, 0x10, 0x00,
-  0x00, 0x00, 0x16, 0x00, 0x22, 0x00, 0x00, 0x20, 0x00, 0x10,
-  0x00, 0x50, 0x21, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x6C, 0x00,
-  0x00, 0x00, '\\',  '_',  'S',  'B',  '.',  'U',  'R',  'T',
-  'M', 0x00,
+#include <IndustryStandard/Acpi.h>
+#include <IndustryStandard/Bcm2836.h>
+#include <IndustryStandard/DebugPort2Table.h>
+#include <Library/AcpiLib.h>
+#include <Library/PcdLib.h>
+
+#include "AcpiTables.h"
+
+#pragma pack(1)
+
+#define RPI_DBG2_NUM_DEBUG_PORTS                        1
+#define RPI_DBG2_NUMBER_OF_GENERIC_ADDRESS_REGISTERS    1
+#define RPI_DBG2_NAMESPACESTRING_FIELD_SIZE             10
+
+#ifdef PL011_ENABLE
+#define RPI_UART_INTERFACE_TYPE                         EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_ARM_PL011_UART
+#define RPI_UART_BASE_ADDRESS                           BCM2836_PL011_UART_BASE_ADDRESS
+#define RPI_UART_LENGTH                                 BCM2836_PL011_UART_LENGTH
+#define RPI_UART_STR                                    { '\\', '_', 'S', 'B', '.', 'U', 'R', 'T', '0', 0x00 }
+#else
+#define RPI_UART_INTERFACE_TYPE                         EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_BCM2835_UART
+#define RPI_UART_BASE_ADDRESS                           BCM2836_MINI_UART_BASE_ADDRESS
+#define RPI_UART_LENGTH                                 BCM2836_MINI_UART_LENGTH
+//
+// RPI_UART_STR should match the value used Uart.asl
+//
+#define RPI_UART_STR                                    { '\\', '_', 'S', 'B', '.', 'U', 'R', 'T', 'M', 0x00 }
+#endif
+
+typedef struct {
+  EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT         Dbg2Device;
+  EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE                BaseAddressRegister;
+  UINT32                                                AddressSize;
+  UINT8                                                 NameSpaceString[RPI_DBG2_NAMESPACESTRING_FIELD_SIZE];
+} DBG2_DEBUG_DEVICE_INFORMATION;
+
+typedef struct {
+  EFI_ACPI_DEBUG_PORT_2_DESCRIPTION_TABLE               Description;
+  DBG2_DEBUG_DEVICE_INFORMATION                         Dbg2DeviceInfo[RPI_DBG2_NUM_DEBUG_PORTS];
+} DBG2_TABLE;
+
+
+#define DBG2_DEBUG_PORT_DDI(NumReg, SubType, UartBase, UartAddrLen, UartNameStr) {                                    \
+    {                                                                                                                 \
+      EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT_REVISION,         /* UINT8     Revision */                        \
+      sizeof (DBG2_DEBUG_DEVICE_INFORMATION),                         /* UINT16    Length */                          \
+      NumReg,                                                         /* UINT8     NumberofGenericAddressRegisters */ \
+      RPI_DBG2_NAMESPACESTRING_FIELD_SIZE,                            /* UINT16    NameSpaceStringLength */           \
+      OFFSET_OF (DBG2_DEBUG_DEVICE_INFORMATION, NameSpaceString),     /* UINT16    NameSpaceStringOffset */           \
+      0,                                                              /* UINT16    OemDataLength */                   \
+      0,                                                              /* UINT16    OemDataOffset */                   \
+      EFI_ACPI_DBG2_PORT_TYPE_SERIAL,                                 /* UINT16    Port Type */                       \
+      SubType,                                                        /* UINT16    Port Subtype */                    \
+      {EFI_ACPI_RESERVED_BYTE, EFI_ACPI_RESERVED_BYTE},               /* UINT8     Reserved[2] */                     \
+      OFFSET_OF (DBG2_DEBUG_DEVICE_INFORMATION, BaseAddressRegister), /* UINT16    BaseAddressRegister Offset */      \
+      OFFSET_OF (DBG2_DEBUG_DEVICE_INFORMATION, AddressSize)          /* UINT16    AddressSize Offset */              \
+    },                                                                                                                \
+    ARM_GAS32 (UartBase),                            /* EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE BaseAddressRegister */ \
+    UartAddrLen,                                     /* UINT32  AddressSize */                                        \
+    UartNameStr                                      /* UINT8   NameSpaceString[MAX_DBG2_NAME_LEN] */                 \
+  }
+
+
+STATIC DBG2_TABLE Dbg2 = {
+  {
+    ACPI_HEADER (
+      EFI_ACPI_5_1_DEBUG_PORT_2_TABLE_SIGNATURE,
+      DBG2_TABLE,
+      EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT_REVISION
+    ),
+    OFFSET_OF (DBG2_TABLE, Dbg2DeviceInfo),
+    RPI_DBG2_NUM_DEBUG_PORTS                                          /* UINT32  NumberDbgDeviceInfo */
+  },
+  {
+    /*
+     * Kernel Debug Port
+     */
+    DBG2_DEBUG_PORT_DDI (
+      RPI_DBG2_NUMBER_OF_GENERIC_ADDRESS_REGISTERS,
+      RPI_UART_INTERFACE_TYPE,
+      RPI_UART_BASE_ADDRESS,
+      RPI_UART_LENGTH,
+      RPI_UART_STR
+    ),
+  }
 };
 
+#pragma pack()
+
 //
-// Reference the table being generated to prevent the optimizer from removing the
-// data structure from the executable
+// Reference the table being generated to prevent the optimizer from removing
+// the data structure from the executable
 //
 VOID* CONST ReferenceAcpiTable = &Dbg2;
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Spcr.asl b/Platform/RaspberryPi/RPi3/AcpiTables/Spcr.asl
deleted file mode 100644
index 2e6a37323794..000000000000
--- a/Platform/RaspberryPi/RPi3/AcpiTables/Spcr.asl
+++ /dev/null
@@ -1,47 +0,0 @@
-/** @file
- *
- *  Serial Port Console Redirection Table (SPCR)
- *
- *  Copyright (c) 2017-2018, Andrey Warkentin <andrey.warkentin@gmail.com>
- *
- *  SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-[000h 0000   4]                    Signature : "SPCR"    [Serial Port Console Redirection table]
-[004h 0004   4]                 Table Length : 00000050
-[008h 0008   1]                     Revision : 02
-[009h 0009   1]                     Checksum : 00
-[00Ah 0010   6]                       Oem ID : "RPiEFI"
-[010h 0016   8]                 Oem Table ID : "RPi3UEFI"
-[018h 0024   4]                 Oem Revision : 00000001
-[01Ch 0028   4]              Asl Compiler ID : "----"
-[020h 0032   4]        Asl Compiler Revision : 00000000
-
-[024h 0036   1]               Interface Type : 10
-[025h 0037   3]                     Reserved : 000000
-
-[028h 0040  12]         Serial Port Register : [Generic Address Structure]
-[028h 0040   1]                     Space ID : 00 [SystemMemory]
-[029h 0041   1]                    Bit Width : 20
-[02Ah 0042   1]                   Bit Offset : 00
-[02Bh 0043   1]         Encoded Access Width : 03 [DWord Access:32]
-[02Ch 0044   8]                      Address : 000000003f215000
-
-[034h 0052   1]               Interrupt Type : 0E
-[035h 0053   1]          PCAT-compatible IRQ : 00
-[036h 0054   4]                    Interrupt : 3D
-[03Ah 0058   1]                    Baud Rate : 07
-[03Bh 0059   1]                       Parity : 00
-[03Ch 0060   1]                    Stop Bits : 01
-[03Dh 0061   1]                 Flow Control : 00
-[03Eh 0062   1]                Terminal Type : 00
-[04Ch 0076   1]                     Reserved : 00
-[040h 0064   2]                PCI Device ID : FFFF
-[042h 0066   2]                PCI Vendor ID : FFFF
-[044h 0068   1]                      PCI Bus : 00
-[045h 0069   1]                   PCI Device : 00
-[046h 0070   1]                 PCI Function : 00
-[047h 0071   4]                    PCI Flags : 00000000
-[04Bh 0075   1]                  PCI Segment : 00
-[04Ch 0076   4]                     Reserved : 00000000
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Spcr.aslc b/Platform/RaspberryPi/RPi3/AcpiTables/Spcr.aslc
new file mode 100644
index 000000000000..cfa1734a3980
--- /dev/null
+++ b/Platform/RaspberryPi/RPi3/AcpiTables/Spcr.aslc
@@ -0,0 +1,96 @@
+/** @file
+* SPCR Table
+*
+* Copyright (c) 2019 Pete Batard <pete@akeo.ie>
+* Copyright (c) 2014-2016, ARM Limited. All rights reserved.
+*
+* SPDX-License-Identifier: BSD-2-Clause-Patent
+*
+**/
+
+#include <IndustryStandard/Acpi.h>
+#include <IndustryStandard/Bcm2836.h>
+#include <IndustryStandard/SerialPortConsoleRedirectionTable.h>
+#include <Library/AcpiLib.h>
+#include <Library/PcdLib.h>
+
+#include "AcpiTables.h"
+
+#define RPI_UART_FLOW_CONTROL_NONE           0
+
+#ifdef PL011_ENABLE
+#define RPI_UART_INTERFACE_TYPE              EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_INTERFACE_TYPE_ARM_PL011_UART
+#define RPI_UART_BASE_ADDRESS                BCM2836_PL011_UART_BASE_ADDRESS
+#define RPI_UART_INTERRUPT                   0x59
+#else
+#define RPI_UART_INTERFACE_TYPE              EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_INTERFACE_TYPE_BCM2835_UART
+#define RPI_UART_BASE_ADDRESS                BCM2836_MINI_UART_BASE_ADDRESS
+#define RPI_UART_INTERRUPT                   0x3D
+#endif
+STATIC EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE Spcr = {
+  ACPI_HEADER (
+    EFI_ACPI_5_1_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE,
+    EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE,
+    EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_REVISION
+  ),
+  // UINT8                                   InterfaceType;
+  RPI_UART_INTERFACE_TYPE,
+  // UINT8                                   Reserved1[3];
+  {
+    EFI_ACPI_RESERVED_BYTE,
+    EFI_ACPI_RESERVED_BYTE,
+    EFI_ACPI_RESERVED_BYTE
+  },
+  // EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE  BaseAddress;
+  ARM_GAS32 (RPI_UART_BASE_ADDRESS),
+  // UINT8                                   InterruptType;
+  EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_INTERRUPT_TYPE_GIC,
+  // UINT8                                   Irq;
+  0,                                         // Not used on ARM
+  // UINT32                                  GlobalSystemInterrupt;
+  RPI_UART_INTERRUPT,
+  // UINT8                                   BaudRate;
+#if (FixedPcdGet64 (PcdUartDefaultBaudRate) == 9600)
+  EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_BAUD_RATE_9600,
+#elif (FixedPcdGet64 (PcdUartDefaultBaudRate) == 19200)
+  EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_BAUD_RATE_19200,
+#elif (FixedPcdGet64 (PcdUartDefaultBaudRate) == 57600)
+  EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_BAUD_RATE_57600,
+#elif (FixedPcdGet64 (PcdUartDefaultBaudRate) == 115200)
+  EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_BAUD_RATE_115200,
+#else
+#error Unsupported SPCR Baud Rate
+#endif
+  // UINT8                                   Parity;
+  EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_PARITY_NO_PARITY,
+  // UINT8                                   StopBits;
+  EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_STOP_BITS_1,
+  // UINT8                                   FlowControl;
+  RPI_UART_FLOW_CONTROL_NONE,
+  // UINT8                                   TerminalType;
+  EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_TERMINAL_TYPE_VT_UTF8,
+  // UINT8                                   Reserved2;
+  EFI_ACPI_RESERVED_BYTE,
+  // UINT16                                  PciDeviceId;
+  0xFFFF,
+  // UINT16                                  PciVendorId;
+  0xFFFF,
+  // UINT8                                   PciBusNumber;
+  0x00,
+  // UINT8                                   PciDeviceNumber;
+  0x00,
+  // UINT8                                   PciFunctionNumber;
+  0x00,
+  // UINT32                                  PciFlags;
+  0x00000000,
+  // UINT8                                   PciSegment;
+  0x00,
+  // UINT32                                  Reserved3;
+  EFI_ACPI_RESERVED_DWORD
+};
+
+//
+// Reference the table being generated to prevent the optimizer from removing the
+// data structure from the executable
+//
+VOID* CONST ReferenceAcpiTable = &Spcr;
-- 
2.21.0.windows.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [edk2-platforms][PATCH 08/15] Platform/RPi3: Update CSRT table to ACPI 5.1
  2020-02-28 10:38 [edk2-platforms][PATCH 00/15] Platform/RPi: Clean up and factorize ACPI Pete Batard
                   ` (6 preceding siblings ...)
  2020-02-28 10:38 ` [edk2-platforms][PATCH 07/15] Platform/RPi3: Switch to .aslc for serial related ACPI tables Pete Batard
@ 2020-02-28 10:38 ` Pete Batard
  2020-02-28 10:38 ` [edk2-platforms][PATCH 09/15] Platform/RPi3: Use proper aslc for FADT, GTDT and MADT tables generation Pete Batard
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 23+ messages in thread
From: Pete Batard @ 2020-02-28 10:38 UTC (permalink / raw)
  To: devel; +Cc: ard.biesheuvel, leif, philmd

This brings this table in line with what we have for Pi 4 and
will enable factorization of ACPI code between the two platforms.

Signed-off-by: Pete Batard <pete@akeo.ie>
---
 Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.h | 24 ++++++++++++++++----
 Platform/RaspberryPi/RPi3/AcpiTables/Csrt.aslc    | 14 ++++++------
 2 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.h b/Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.h
index 3e68923d3c05..9c76624e4ac8 100644
--- a/Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.h
+++ b/Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.h
@@ -2,6 +2,7 @@
  *
  *  RPi3 defines for constructing ACPI tables
  *
+ *  Copyright (c) 2019, ARM Ltd. All rights reserved.
  *  Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
  *  Copyright (c) Microsoft Corporation. All rights reserved.
  *
@@ -12,7 +13,7 @@
 #ifndef __ACPITABLES_H__
 #define __ACPITABLES_H__
 
-#include <IndustryStandard/Acpi50.h>
+#include <IndustryStandard/Acpi.h>
 
 // The ASL compiler can't perform arithmetic on MEMORY32SETBASE ()
 // parameters so you can't pass a constant like BASE + OFFSET (the
@@ -29,6 +30,21 @@
 #define EFI_ACPI_CREATOR_REVISION             0x00000097
 
 #define EFI_ACPI_VENDOR_ID                    SIGNATURE_32 ('M','S','F','T')
+
+// A macro to initialise the common header part of EFI ACPI tables as defined by
+// EFI_ACPI_DESCRIPTION_HEADER structure.
+#define ACPI_HEADER(Signature, Type, Revision) {                  \
+    Signature,                      /* UINT32  Signature */       \
+    sizeof (Type),                  /* UINT32  Length */          \
+    Revision,                       /* UINT8   Revision */        \
+    0,                              /* UINT8   Checksum */        \
+    EFI_ACPI_OEM_ID,                /* UINT8   OemId[6] */        \
+    EFI_ACPI_OEM_TABLE_ID,          /* UINT64  OemTableId */      \
+    EFI_ACPI_OEM_REVISION,          /* UINT32  OemRevision */     \
+    EFI_ACPI_CREATOR_ID,            /* UINT32  CreatorId */       \
+    EFI_ACPI_CREATOR_REVISION       /* UINT32  CreatorRevision */ \
+  }
+
 #define EFI_ACPI_CSRT_REVISION                0x00000005
 #define EFI_ACPI_CSRT_DEVICE_ID_DMA           0x00000009 // Fixed id
 #define EFI_ACPI_CSRT_RESOURCE_ID_IN_DMA_GRP  0x0 // Count up from 0
@@ -36,7 +52,7 @@
 #define RPI3_DMA_CHANNEL_COUNT                10 // All 10 DMA channels are listed, including the reserved ones
 #define RPI3_DMA_USED_CHANNEL_COUNT           5  // Use 5 DMA channels
 
-#define EFI_ACPI_5_0_CSRT_REVISION            0x00000000
+#define EFI_ACPI_5_1_CSRT_REVISION            0x00000000
 
 typedef enum
 {
@@ -68,7 +84,7 @@ typedef struct
   UINT16 Revision;                // 2 bytes
   UINT16 Reserved;                // 2 bytes
   UINT32 SharedInfoLength;        // 4 bytes
-} EFI_ACPI_5_0_CSRT_RESOURCE_GROUP_HEADER;
+} EFI_ACPI_5_1_CSRT_RESOURCE_GROUP_HEADER;
 
 //------------------------------------------------------------------------
 // CSRT Resource Descriptor 12 bytes total
@@ -79,6 +95,6 @@ typedef struct
   UINT16 ResourceType;            // 2 bytes
   UINT16 ResourceSubType;         // 2 bytes
   UINT32 UID;                     // 4 bytes
-} EFI_ACPI_5_0_CSRT_RESOURCE_DESCRIPTOR_HEADER;
+} EFI_ACPI_5_1_CSRT_RESOURCE_DESCRIPTOR_HEADER;
 
 #endif // __ACPITABLES_H__
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Csrt.aslc b/Platform/RaspberryPi/RPi3/AcpiTables/Csrt.aslc
index 62f1a1fbdf19..0a8393a8076b 100644
--- a/Platform/RaspberryPi/RPi3/AcpiTables/Csrt.aslc
+++ b/Platform/RaspberryPi/RPi3/AcpiTables/Csrt.aslc
@@ -39,7 +39,7 @@ typedef struct
 //------------------------------------------------------------------------
 typedef struct
 {
-  EFI_ACPI_5_0_CSRT_RESOURCE_DESCRIPTOR_HEADER DmaControllerHeader;
+  EFI_ACPI_5_1_CSRT_RESOURCE_DESCRIPTOR_HEADER DmaControllerHeader;
   DMA_CONTROLLER_VENDOR_DATA ControllerVendorData;
 } RD_DMA_CONTROLLER;
 
@@ -59,7 +59,7 @@ typedef struct
 //------------------------------------------------------------------------
 typedef struct
 {
-  EFI_ACPI_5_0_CSRT_RESOURCE_DESCRIPTOR_HEADER DmaChannelHeader;
+  EFI_ACPI_5_1_CSRT_RESOURCE_DESCRIPTOR_HEADER DmaChannelHeader;
   DMA_CHANNEL_VENDOR_DATA ChannelVendorData;
 } RD_DMA_CHANNEL;
 
@@ -69,7 +69,7 @@ typedef struct
 
 typedef struct
 {
-  EFI_ACPI_5_0_CSRT_RESOURCE_GROUP_HEADER ResGroupHeader;
+  EFI_ACPI_5_1_CSRT_RESOURCE_GROUP_HEADER ResGroupHeader;
   RD_DMA_CONTROLLER DmaController;
   RD_DMA_CHANNEL DmaChannels[RPI3_DMA_CHANNEL_COUNT];
 } RG_DMA;
@@ -85,17 +85,17 @@ typedef struct
 // DMA Resource Group
   RG_DMA DmaResourceGroup;
 
-} EFI_ACPI_5_0_CSRT_TABLE;
+} EFI_ACPI_5_1_CSRT_TABLE;
 
-EFI_ACPI_5_0_CSRT_TABLE Csrt =
+EFI_ACPI_5_1_CSRT_TABLE Csrt =
 {
   //------------------------------------------------------------------------
   // ACPI Table Header
   //------------------------------------------------------------------------
   {
-    EFI_ACPI_5_0_CORE_SYSTEM_RESOURCE_TABLE_SIGNATURE,       // Signature "CSRT"
+    EFI_ACPI_5_1_CORE_SYSTEM_RESOURCE_TABLE_SIGNATURE,       // Signature "CSRT"
     sizeof (EFI_ACPI_DESCRIPTION_HEADER) + sizeof (RG_DMA),  // Length
-    EFI_ACPI_5_0_CSRT_REVISION,     // Revision
+    EFI_ACPI_5_1_CSRT_REVISION,     // Revision
     0x00,                           // Checksum calculated at runtime.
     EFI_ACPI_OEM_ID,                // OEMID is a 6 bytes long field "BC2836"
     EFI_ACPI_OEM_TABLE_ID,          // OEM table identification(8 bytes long) "RPI3EDK2"
-- 
2.21.0.windows.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [edk2-platforms][PATCH 09/15] Platform/RPi3: Use proper aslc for FADT, GTDT and MADT tables generation
  2020-02-28 10:38 [edk2-platforms][PATCH 00/15] Platform/RPi: Clean up and factorize ACPI Pete Batard
                   ` (7 preceding siblings ...)
  2020-02-28 10:38 ` [edk2-platforms][PATCH 08/15] Platform/RPi3: Update CSRT table to ACPI 5.1 Pete Batard
@ 2020-02-28 10:38 ` Pete Batard
  2020-02-28 10:38 ` [edk2-platforms][PATCH 10/15] Platform/RPi4: Add RPI_MODEL constant and replace PL011_ENABLE Pete Batard
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 23+ messages in thread
From: Pete Batard @ 2020-02-28 10:38 UTC (permalink / raw)
  To: devel; +Cc: ard.biesheuvel, leif, philmd

The FADT and GTDT tables are virtually identical to the ones we use for
the Pi 4, except for the RPI_SYSTEM_TIMER_BASE_ADDRESS in Gtdt.aslc.

However, 2 changes are required for these tables to work with Windows:
1. The ACPI OEM ID for the FADT table MUST be "BC2836" (else Windows 10
   fails to boot) so we change the global value in AcpiTables.h.
2. The values for PcdArmArchTimerVirtIntrNum and PcdArmArchTimerHypIntrNum
   seem to have been swapped in our existing .dsc so we swap them back
   (Without this swap, Windows 10 simply refuses to boot).

The MADT table is deduced from the original Microsoft blob. The one thing
of notice is that no GIC Distributor section should exist in that table,
otherwise Windows 10 will fail to boot.

Obviously, all of the changes applied by this commit were validated on a
Raspberry Pi 3 running Windows 10.

Signed-off-by: Pete Batard <pete@akeo.ie>
---
 Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.h   |  2 +-
 Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.inf |  6 ++
 Platform/RaspberryPi/RPi3/AcpiTables/Fadt.aslc      | 99 ++++++++++++++------
 Platform/RaspberryPi/RPi3/AcpiTables/Gtdt.aslc      | 69 ++++++++++----
 Platform/RaspberryPi/RPi3/AcpiTables/Madt.aslc      | 98 +++++++++----------
 Platform/RaspberryPi/RPi3/RPi3.dsc                  |  4 +-
 6 files changed, 180 insertions(+), 98 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.h b/Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.h
index 9c76624e4ac8..c860b7881842 100644
--- a/Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.h
+++ b/Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.h
@@ -23,7 +23,7 @@
     CreateDwordField (^BufName, ^MemName._BAS, VarName)          \
     Add (BCM2836_SOC_REGISTERS, Offset, VarName)
 
-#define EFI_ACPI_OEM_ID                       {'M','C','R','S','F','T'} // OEMID 6 bytes long
+#define EFI_ACPI_OEM_ID                       {'B','C','2','8','3','6'} // OEMID 6 bytes long
 #define EFI_ACPI_OEM_TABLE_ID                 SIGNATURE_64 ('R','P','I','3','E','D','K','2') // OEM table id 8 bytes long
 #define EFI_ACPI_OEM_REVISION                 0x02000820
 #define EFI_ACPI_CREATOR_ID                   SIGNATURE_32 ('R','P','I','3')
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.inf b/Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.inf
index 4b4e431da650..9363660b0ef7 100644
--- a/Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.inf
+++ b/Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.inf
@@ -33,11 +33,17 @@ [Sources]
   Spcr.aslc
 
 [Packages]
+  ArmPkg/ArmPkg.dec
+  ArmPlatformPkg/ArmPlatformPkg.dec
   MdePkg/MdePkg.dec
   EmbeddedPkg/EmbeddedPkg.dec
   Silicon/Broadcom/Bcm283x/Bcm283x.dec
 
 [FixedPcd]
+  gArmTokenSpaceGuid.PcdArmArchTimerIntrNum
+  gArmTokenSpaceGuid.PcdArmArchTimerHypIntrNum
+  gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum
+  gArmTokenSpaceGuid.PcdArmArchTimerVirtIntrNum
   gBcm283xTokenSpaceGuid.PcdBcm283xRegistersAddress
   gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate
   gEmbeddedTokenSpaceGuid.PcdInterruptBaseAddress
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Fadt.aslc b/Platform/RaspberryPi/RPi3/AcpiTables/Fadt.aslc
index 3ef877fde5f4..ebf58fb7fc3c 100644
--- a/Platform/RaspberryPi/RPi3/AcpiTables/Fadt.aslc
+++ b/Platform/RaspberryPi/RPi3/AcpiTables/Fadt.aslc
@@ -2,6 +2,7 @@
  *
  *  Fixed ACPI Description Table (FADT)
  *
+ *  Copyright (c) 2019, Pete Batard <pete@akeo.ie>
  *  Copyright (c) 2018, Andrey Warkentin <andrey.warkentin@gmail.com>
  *  Copyright (c) Microsoft Corporation. All rights reserved.
  *
@@ -9,34 +10,76 @@
  *
  **/
 
-UINT8 Fadt[268] = {
-  0x46, 0x41, 0x43, 0x50, 0x0C, 0x01, 0x00, 0x00, 0x05, 0x00, /*   0 */
-  0x42, 0x43, 0x32, 0x38, 0x33, 0x36, 0x45, 0x44, 0x4B, 0x32, /*  10 */
-  0x20, 0x20, 0x20, 0x20, 0x01, 0x00, 0x00, 0x00, 0x4D, 0x53, /*  20 */
-  0x46, 0x54, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*  30 */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, /*  40 */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*  50 */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*  60 */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*  70 */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*  80 */
-  0x00, 0x04, 0x00, 0x00, 0x00, 0xE3, 0x00, 0x00, 0x00, 0x00, /*  90 */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, /* 100 */
-  0x00, 0x00, 0x21, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, /* 110 */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, /* 120 */
-  0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 130 */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 140 */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 150 */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 160 */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 170 */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 180 */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 190 */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 200 */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 210 */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 220 */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 230 */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 240 */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 250 */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00              /* 268 */
+#include <IndustryStandard/Acpi.h>
+#include <Library/AcpiLib.h>
+#include <Library/PcdLib.h>
+
+#include "AcpiTables.h"
+
+/*
+ * Note: Use ACPI 5.1 since we need to match MADT ACPI requirements
+ */
+EFI_ACPI_5_1_FIXED_ACPI_DESCRIPTION_TABLE Fadt = {
+  ACPI_HEADER (
+    EFI_ACPI_5_1_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE,
+    EFI_ACPI_5_1_FIXED_ACPI_DESCRIPTION_TABLE,
+    EFI_ACPI_5_1_FIXED_ACPI_DESCRIPTION_TABLE_REVISION
+  ),
+  0,                                                                        // UINT32     FirmwareCtrl
+  0,                                                                        // UINT32     Dsdt
+  EFI_ACPI_RESERVED_BYTE,                                                   // UINT8      Reserved0
+  EFI_ACPI_5_1_PM_PROFILE_APPLIANCE_PC,                                     // UINT8      PreferredPmProfile
+  0,                                                                        // UINT16     SciInt
+  0,                                                                        // UINT32     SmiCmd
+  0,                                                                        // UINT8      AcpiEnable
+  0,                                                                        // UINT8      AcpiDisable
+  0,                                                                        // UINT8      S4BiosReq
+  0,                                                                        // UINT8      PstateCnt
+  0,                                                                        // UINT32     Pm1aEvtBlk
+  0,                                                                        // UINT32     Pm1bEvtBlk
+  0,                                                                        // UINT32     Pm1aCntBlk
+  0,                                                                        // UINT32     Pm1bCntBlk
+  0,                                                                        // UINT32     Pm2CntBlk
+  0,                                                                        // UINT32     PmTmrBlk
+  0,                                                                        // UINT32     Gpe0Blk
+  0,                                                                        // UINT32     Gpe1Blk
+  0,                                                                        // UINT8      Pm1EvtLen
+  0,                                                                        // UINT8      Pm1CntLen
+  0,                                                                        // UINT8      Pm2CntLen
+  0,                                                                        // UINT8      PmTmrLen
+  0,                                                                        // UINT8      Gpe0BlkLen
+  0,                                                                        // UINT8      Gpe1BlkLen
+  0,                                                                        // UINT8      Gpe1Base
+  0,                                                                        // UINT8      CstCnt
+  0,                                                                        // UINT16     PLvl2Lat
+  0,                                                                        // UINT16     PLvl3Lat
+  0,                                                                        // UINT16     FlushSize
+  0,                                                                        // UINT16     FlushStride
+  0,                                                                        // UINT8      DutyOffset
+  0,                                                                        // UINT8      DutyWidth
+  0,                                                                        // UINT8      DayAlrm
+  0,                                                                        // UINT8      MonAlrm
+  0,                                                                        // UINT8      Century
+  EFI_ACPI_RESERVED_WORD,                                                   // UINT16     IaPcBootArch (Reserved on ARM)
+  EFI_ACPI_RESERVED_BYTE,                                                   // UINT8      Reserved1
+  EFI_ACPI_5_1_WBINVD | EFI_ACPI_5_1_SLP_BUTTON |                           // UINT32     Flags
+  EFI_ACPI_5_1_HW_REDUCED_ACPI,
+  NULL_GAS,                                                                 // EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE  ResetReg
+  0,                                                                        // UINT8      ResetValue
+  EFI_ACPI_5_1_ARM_PSCI_COMPLIANT,                                          // UINT16     ArmBootArchFlags
+  EFI_ACPI_5_1_FIXED_ACPI_DESCRIPTION_TABLE_MINOR_REVISION,                 // UINT8      MinorRevision
+  0,                                                                        // UINT64     XFirmwareCtrl
+  0,                                                                        // UINT64     XDsdt
+  NULL_GAS,                                                                 // EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE  XPm1aEvtBlk
+  NULL_GAS,                                                                 // EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE  XPm1bEvtBlk
+  NULL_GAS,                                                                 // EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE  XPm1aCntBlk
+  NULL_GAS,                                                                 // EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE  XPm1bCntBlk
+  NULL_GAS,                                                                 // EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE  XPm2CntBlk
+  NULL_GAS,                                                                 // EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE  XPmTmrBlk
+  NULL_GAS,                                                                 // EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE  XGpe0Blk
+  NULL_GAS,                                                                 // EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE  XGpe1Blk
+  NULL_GAS,                                                                 // EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE  SleepControlReg
+  NULL_GAS                                                                  // EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE  SleepStatusReg
 };
 
 //
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Gtdt.aslc b/Platform/RaspberryPi/RPi3/AcpiTables/Gtdt.aslc
index 6551315a5502..0cd6be8cadaa 100644
--- a/Platform/RaspberryPi/RPi3/AcpiTables/Gtdt.aslc
+++ b/Platform/RaspberryPi/RPi3/AcpiTables/Gtdt.aslc
@@ -1,27 +1,56 @@
 /** @file
- *
- *  Generic Timer Description Table (GTDT)
- *  Automatically generated by AutoAcpi
- *
- *  Copyright (c) Microsoft Corporation. All rights reserved.
- *
- *  SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
+*  Generic Timer Description Table (GTDT)
+*
+*  Copyright (c) 2018, Linaro Limited. All rights reserved.
+*  Copyright (c) 2012 - 2016, ARM Limited. All rights reserved.
+*
+*  SPDX-License-Identifier: BSD-2-Clause-Patent
+*
+**/
 
-UINT8 Gtdt[80] = {
-  0x47, 0x54, 0x44, 0x54, 0x50, 0x00, 0x00, 0x00, 0x01, 0x00,
-  0x4D, 0x53, 0x46, 0x54, 0x20, 0x20, 0x45, 0x44, 0x4B, 0x32,
-  0x20, 0x20, 0x20, 0x20, 0x01, 0x00, 0x00, 0x00, 0x4D, 0x53,
-  0x46, 0x54, 0x01, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x40,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+#include <IndustryStandard/Acpi.h>
+#include <Library/AcpiLib.h>
+#include <Library/PcdLib.h>
+
+#include "AcpiTables.h"
+
+#define RPI_SYSTEM_TIMER_BASE_ADDRESS   0x4000001C
+#define RPI_GTDT_GLOBAL_FLAGS           0
+#define RPI_GTDT_GTIMER_FLAGS           EFI_ACPI_5_1_GTDT_TIMER_FLAG_TIMER_INTERRUPT_POLARITY
+
+#pragma pack (1)
+
+typedef struct {
+  EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLE Gtdt;
+} EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLES;
+
+#pragma pack ()
+
+EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLES Gtdt = {
+  {
+    ACPI_HEADER(
+      EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE,
+      EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLES,
+      EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLE_REVISION
+    ),
+    RPI_SYSTEM_TIMER_BASE_ADDRESS,                // UINT64  PhysicalAddress
+    0,                                            // UINT32  Reserved
+    FixedPcdGet32 (PcdArmArchTimerSecIntrNum),    // UINT32  SecurePL1TimerGSIV
+    RPI_GTDT_GTIMER_FLAGS,                        // UINT32  SecurePL1TimerFlags
+    FixedPcdGet32 (PcdArmArchTimerIntrNum),       // UINT32  NonSecurePL1TimerGSIV
+    RPI_GTDT_GTIMER_FLAGS,                        // UINT32  NonSecurePL1TimerFlags
+    FixedPcdGet32 (PcdArmArchTimerVirtIntrNum),   // UINT32  VirtualTimerGSIV
+    RPI_GTDT_GTIMER_FLAGS,                        // UINT32  VirtualTimerFlags
+    FixedPcdGet32 (PcdArmArchTimerHypIntrNum),    // UINT32  NonSecurePL2TimerGSIV
+    RPI_GTDT_GTIMER_FLAGS,                        // UINT32  NonSecurePL2TimerFlags
+    0xFFFFFFFFFFFFFFFF,                           // UINT64  CntReadBasePhysicalAddress
+    0,                                            // UINT32  PlatformTimerCount
+    0                                             // UINT32 PlatfromTimerOffset
+  },
 };
 
 //
-// Reference the table being generated to prevent the optimizer from removing the
-// data structure from the executable
+// Reference the table being generated to prevent the optimizer
+// from removing the data structure from the executable
 //
 VOID* CONST ReferenceAcpiTable = &Gtdt;
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Madt.aslc b/Platform/RaspberryPi/RPi3/AcpiTables/Madt.aslc
index 39cd4c5cee6c..a42ddb8954df 100644
--- a/Platform/RaspberryPi/RPi3/AcpiTables/Madt.aslc
+++ b/Platform/RaspberryPi/RPi3/AcpiTables/Madt.aslc
@@ -1,52 +1,56 @@
 /** @file
- *
- *  Multiple APIC Description Table (MADT)
- *
- *  Copyright (c) 2018, Andrey Warkentin <andrey.warkentin@gmail.com>
- *  Copyright (c) Microsoft Corporation. All rights reserved.
- *
- *  SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
+*  Multiple APIC Description Table (MADT)
+*
+*  Copyright (c) 2016 Linaro Ltd. All rights reserved.
+*  Copyright (c) 2012 - 2015, ARM Limited. All rights reserved.
+*
+*  SPDX-License-Identifier: BSD-2-Clause-Patent
+*
+**/
 
-/*
- * Even though the BCM283x don't contain a GIC, these
- * GICC definitions enable multi-core support (with PSCI).
- *
- * Mind the signatures in the header, they must be kept.
- */
-UINT8 Madt[] = {
-  0x41, 0x50, 0x49, 0x43, 0x6c, 0x01, 0x00, 0x00, 0x03, 0xaf, 0x42, 0x43,
-  0x32, 0x38, 0x33, 0x36, 0x45, 0x44, 0x4b, 0x32, 0x20, 0x20, 0x20, 0x20,
-  0x01, 0x00, 0x00, 0x00, 0x4d, 0x53, 0x46, 0x54, 0x01, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x50, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x01, 0x00, 0x00, 0x00, 0x0b, 0x50, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
-  0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
-  0x0b, 0x50, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
-  0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x50, 0x00, 0x00,
-  0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x01, 0x00, 0x00, 0x00
+#include <IndustryStandard/Acpi.h>
+#include <Library/AcpiLib.h>
+#include <Library/ArmLib.h>
+#include <Library/PcdLib.h>
+
+#include "AcpiTables.h"
+
+//
+// Multiple APIC Description Table
+//
+#pragma pack (1)
+
+typedef struct {
+  EFI_ACPI_5_1_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER   Header;
+  EFI_ACPI_5_1_GIC_STRUCTURE                            GicInterfaces[4];
+  // Do *NOT* add a GIC Distributor on the Pi 3 or Windows 10 won't boot!
+} PI_MULTIPLE_APIC_DESCRIPTION_TABLE;
+
+#pragma pack ()
+
+PI_MULTIPLE_APIC_DESCRIPTION_TABLE Madt = {
+  {
+    ACPI_HEADER (
+      EFI_ACPI_5_1_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE,
+      PI_MULTIPLE_APIC_DESCRIPTION_TABLE,
+      EFI_ACPI_5_1_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION
+    ),
+    //
+    // MADT specific fields
+    //
+    0, // LocalApicAddress
+    0, // Flags
+  },
+  {
+    EFI_ACPI_5_1_GICC_STRUCTURE_INIT(
+        0, 0, GET_MPID(0, 0), EFI_ACPI_5_1_GIC_ENABLED, 0x09, 0x40000000, 0, 0, 0, 0),
+    EFI_ACPI_5_1_GICC_STRUCTURE_INIT(
+        1, 1, GET_MPID(0, 1), EFI_ACPI_5_1_GIC_ENABLED, 0x09, 0x40000000, 0, 0, 0, 0),
+    EFI_ACPI_5_1_GICC_STRUCTURE_INIT(
+        2, 2, GET_MPID(0, 2), EFI_ACPI_5_1_GIC_ENABLED, 0x09, 0x40000000, 0, 0, 0, 0),
+    EFI_ACPI_5_1_GICC_STRUCTURE_INIT(
+        3, 3, GET_MPID(0, 3), EFI_ACPI_5_1_GIC_ENABLED, 0x09, 0x40000000, 0, 0, 0, 0),
+  },
 };
 
 //
diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc b/Platform/RaspberryPi/RPi3/RPi3.dsc
index 40fb0879c2ed..94d1e5b1c45b 100644
--- a/Platform/RaspberryPi/RPi3/RPi3.dsc
+++ b/Platform/RaspberryPi/RPi3/RPi3.dsc
@@ -328,8 +328,8 @@ [PcdsFixedAtBuild.common]
   gEmbeddedTokenSpaceGuid.PcdInterruptBaseAddress|0x40000000
   gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum|0x0
   gArmTokenSpaceGuid.PcdArmArchTimerIntrNum|0x1
-  gArmTokenSpaceGuid.PcdArmArchTimerVirtIntrNum|0x2
-  gArmTokenSpaceGuid.PcdArmArchTimerHypIntrNum|0x3
+  gArmTokenSpaceGuid.PcdArmArchTimerVirtIntrNum|0x3
+  gArmTokenSpaceGuid.PcdArmArchTimerHypIntrNum|0x2
 
 [LibraryClasses.common]
   ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
-- 
2.21.0.windows.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [edk2-platforms][PATCH 10/15] Platform/RPi4: Add RPI_MODEL constant and replace PL011_ENABLE
  2020-02-28 10:38 [edk2-platforms][PATCH 00/15] Platform/RPi: Clean up and factorize ACPI Pete Batard
                   ` (8 preceding siblings ...)
  2020-02-28 10:38 ` [edk2-platforms][PATCH 09/15] Platform/RPi3: Use proper aslc for FADT, GTDT and MADT tables generation Pete Batard
@ 2020-02-28 10:38 ` Pete Batard
  2020-02-28 10:38 ` [edk2-platforms][PATCH 11/15] Platform/RPi4: Move ACPI interrupts definitions to AcpiTables.h Pete Batard
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 23+ messages in thread
From: Pete Batard @ 2020-02-28 10:38 UTC (permalink / raw)
  To: devel; +Cc: ard.biesheuvel, leif, philmd

Since there are multiple Raspberry Pi Models and a lot of the code we use
can be factorized, it is useful to have an RPI_MODEL build time constant,
set to the platform model number, that can be referenced in the source.

Make use this new constant to replace the PL011_ENABLE feature check.

Signed-off-by: Pete Batard <pete@akeo.ie>
---
 Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf | 7 -------
 Platform/RaspberryPi/RPi4/AcpiTables/Dbg2.aslc      | 2 +-
 Platform/RaspberryPi/RPi4/AcpiTables/Spcr.aslc      | 3 ++-
 Platform/RaspberryPi/RPi4/AcpiTables/Uart.asl       | 2 +-
 Platform/RaspberryPi/RPi4/RPi4.dsc                  | 4 ++++
 5 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf b/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf
index 358c315b6da1..c95d75ed01bb 100644
--- a/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf
+++ b/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf
@@ -56,10 +56,3 @@ [FixedPcd]
   gBcmNetTokenSpaceGuid.PcdBcmGenetRegistersAddress
   gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate
   gEmbeddedTokenSpaceGuid.PcdInterruptBaseAddress
-
-# The following is a stopgap solution to default to PL011
-# usage in ACPI (most common case), until we can switch
-# to using DynamicTablesPkg/ConfigurationManagerDxe.
-[BuildOptions]
-  GCC:*_*_*_ASLPP_FLAGS       = -DPL011_ENABLE
-  GCC:*_*_*_ASLCC_FLAGS       = -DPL011_ENABLE
diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Dbg2.aslc b/Platform/RaspberryPi/RPi4/AcpiTables/Dbg2.aslc
index dcad8e205596..c3d5994f8e97 100644
--- a/Platform/RaspberryPi/RPi4/AcpiTables/Dbg2.aslc
+++ b/Platform/RaspberryPi/RPi4/AcpiTables/Dbg2.aslc
@@ -23,7 +23,7 @@
 #define RPI_DBG2_NUMBER_OF_GENERIC_ADDRESS_REGISTERS    1
 #define RPI_DBG2_NAMESPACESTRING_FIELD_SIZE             10
 
-#ifdef PL011_ENABLE
+#if (RPI_MODEL == 4)
 #define RPI_UART_INTERFACE_TYPE                         EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_ARM_PL011_UART
 #define RPI_UART_BASE_ADDRESS                           BCM2836_PL011_UART_BASE_ADDRESS
 #define RPI_UART_LENGTH                                 BCM2836_PL011_UART_LENGTH
diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Spcr.aslc b/Platform/RaspberryPi/RPi4/AcpiTables/Spcr.aslc
index cb17fbe0ff2f..bec4ad660ec9 100644
--- a/Platform/RaspberryPi/RPi4/AcpiTables/Spcr.aslc
+++ b/Platform/RaspberryPi/RPi4/AcpiTables/Spcr.aslc
@@ -18,7 +18,8 @@
 
 #define RPI_UART_FLOW_CONTROL_NONE           0
 
-#ifdef PL011_ENABLE
+// Prefer PL011 serial output on the Raspberry Pi 4
+#if (RPI_MODEL == 4)
 #define RPI_UART_INTERFACE_TYPE              EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_INTERFACE_TYPE_ARM_PL011_UART
 #define RPI_UART_BASE_ADDRESS                BCM2836_PL011_UART_BASE_ADDRESS
 #define RPI_UART_INTERRUPT                   BCM2836_PL011_UART_INTERRUPT
diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Uart.asl b/Platform/RaspberryPi/RPi4/AcpiTables/Uart.asl
index ad9d21e6272d..1be285220ad7 100644
--- a/Platform/RaspberryPi/RPi4/AcpiTables/Uart.asl
+++ b/Platform/RaspberryPi/RPi4/AcpiTables/Uart.asl
@@ -140,7 +140,7 @@ Device(BTH0)
                        //   no flow control.
         16,            // ReceiveBufferSize
         16,            // TransmitBufferSize
-#ifdef PL011_ENABLE
+#if (RPI_MODEL == 4)
         "\\_SB.URTM",  // ResourceSource:
 #else
         "\\_SB.URT0",  // ResourceSource:
diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc b/Platform/RaspberryPi/RPi4/RPi4.dsc
index 7c1937672597..09bd19e3b724 100644
--- a/Platform/RaspberryPi/RPi4/RPi4.dsc
+++ b/Platform/RaspberryPi/RPi4/RPi4.dsc
@@ -229,6 +229,10 @@ [LibraryClasses.common.DXE_RUNTIME_DRIVER]
 ###################################################################################################
 
 [BuildOptions]
+  GCC:*_*_*_CC_FLAGS          = -DRPI_MODEL=4
+  GCC:*_*_*_ASLPP_FLAGS       = -DRPI_MODEL=4
+  GCC:*_*_*_ASLCC_FLAGS       = -DRPI_MODEL=4
+  GCC:*_*_*_VFRPP_FLAGS       = -DRPI_MODEL=4
   GCC:*_*_AARCH64_DLINK_FLAGS = -Wl,--fix-cortex-a53-843419
   GCC:RELEASE_*_*_CC_FLAGS    = -DMDEPKG_NDEBUG -DNDEBUG
 
-- 
2.21.0.windows.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [edk2-platforms][PATCH 11/15] Platform/RPi4: Move ACPI interrupts definitions to AcpiTables.h
  2020-02-28 10:38 [edk2-platforms][PATCH 00/15] Platform/RPi: Clean up and factorize ACPI Pete Batard
                   ` (9 preceding siblings ...)
  2020-02-28 10:38 ` [edk2-platforms][PATCH 10/15] Platform/RPi4: Add RPI_MODEL constant and replace PL011_ENABLE Pete Batard
@ 2020-02-28 10:38 ` Pete Batard
  2020-02-28 10:38 ` [edk2-platforms][PATCH 12/15] Platform/RPi3: " Pete Batard
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 23+ messages in thread
From: Pete Batard @ 2020-02-28 10:38 UTC (permalink / raw)
  To: devel; +Cc: ard.biesheuvel, leif, philmd

The ACPI interrupts are not the same across different Raspberry Pi
platforms therefore moving them into AcpiTables.h will help with ACPI
code factorization.

We also take this opportunity to move the serial interrupt definitions
away from Silicon, since the ones defined in Bcm2836.h only applied to
the Raspberry Pi 4.

Signed-off-by: Pete Batard <pete@akeo.ie>
---
 Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.h           | 28 +++++++++++++++
 Platform/RaspberryPi/RPi4/AcpiTables/Dsdt.asl               | 36 ++++++++++----------
 Platform/RaspberryPi/RPi4/AcpiTables/Sdhc.asl               |  4 +--
 Platform/RaspberryPi/RPi4/AcpiTables/Uart.asl               |  4 +--
 Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h |  2 --
 5 files changed, 50 insertions(+), 24 deletions(-)

diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.h b/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.h
index fcfad3b5d93b..3d1737aed41a 100644
--- a/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.h
+++ b/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.h
@@ -97,4 +97,32 @@ typedef struct
   UINT32 UID;                     // 4 bytes
 } EFI_ACPI_5_1_CSRT_RESOURCE_DESCRIPTOR_HEADER;
 
+//------------------------------------------------------------------------
+// Interrupts. These are specific to each platform
+//------------------------------------------------------------------------
+#define BCM2836_V3D_BUS_INTERRUPT               0x2A
+#define BCM2836_DMA_INTERRUPT                   0x3B
+#define BCM2836_SPI1_INTERRUPT                  0x3D
+#define BCM2836_SPI2_INTERRUPT                  0x3D
+#define BCM2836_HVS_INTERRUPT                   0x41
+#define BCM2836_HDMI0_INTERRUPT                 0x48
+#define BCM2836_HDMI1_INTERRUPT                 0x49
+#define BCM2836_PV2_INTERRUPT                   0x4A
+#define BCM2836_PV0_INTERRUPT                   0x4D
+#define BCM2836_PV1_INTERRUPT                   0x4E
+#define BCM2836_MBOX_INTERRUPT                  0x61
+#define BCM2836_VCHIQ_INTERRUPT                 0x62
+#define BCM2386_GPIO_INTERRUPT0                 0x51
+#define BCM2386_GPIO_INTERRUPT1                 0x53
+#define BCM2836_I2C1_INTERRUPT                  0x55
+#define BCM2836_I2C2_INTERRUPT                  0x55
+#define BCM2836_SPI0_INTERRUPT                  0x56
+#define BCM2836_USB_INTERRUPT                   0x69
+#define BCM2836_SDHOST_INTERRUPT                0x98
+#define BCM2836_MMCHS1_INTERRUPT                0x9E
+#define BCM2836_MINI_UART_INTERRUPT             0x7D
+#define BCM2836_PL011_UART_INTERRUPT            0x99
+#define GENET_INTERRUPT0                        0xBD
+#define GENET_INTERRUPT1                        0xBE
+
 #endif // __ACPITABLES_H__
diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Dsdt.asl b/Platform/RaspberryPi/RPi4/AcpiTables/Dsdt.asl
index c505413bcba2..e1ddb742376a 100644
--- a/Platform/RaspberryPi/RPi4/AcpiTables/Dsdt.asl
+++ b/Platform/RaspberryPi/RPi4/AcpiTables/Dsdt.asl
@@ -87,7 +87,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       Name (RBUF, ResourceTemplate ()
       {
         MEMORY32FIXED (ReadWrite, 0, BCM2836_USB_LENGTH, RMEM)
-        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x69 }
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_USB_INTERRUPT }
       })
       Method (_CRS, 0x0, Serialized)
       {
@@ -111,32 +111,32 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       {
         // Memory and interrupt for the GPU
         MEMORY32FIXED (ReadWrite, 0, BCM2836_V3D_BUS_LENGTH, RM01)
-        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x2A }
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_V3D_BUS_INTERRUPT }
 
         // HVS - Hardware Video Scalar
         MEMORY32FIXED (ReadWrite, 0, BCM2836_HVS_LENGTH, RM02)
         // The HVS interrupt is reserved by the VPU
-        // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x41 }
+        // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_HVS_INTERRUPT }
 
         // PixelValve0 - DSI0 or DPI
         // MEMORY32FIXED (ReadWrite, BCM2836_PV0_BASE_ADDRESS, BCM2836_PV0_LENGTH, RM03)
-        // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x4D }
+        // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_PV0_INTERRUPT }
 
         // PixelValve1 - DS1 or SMI
         // MEMORY32FIXED (ReadWrite, BCM2836_PV1_BASE_ADDRESS, BCM2836_PV1_LENGTH, RM04)
-        // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x4E }
+        // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_PV1_INTERRUPT }
 
         // PixelValve2 - HDMI output - connected to HVS display FIFO 1
         MEMORY32FIXED (ReadWrite, 0, BCM2836_PV2_LENGTH, RM05)
-        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x4A }
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_PV2_INTERRUPT }
 
         // HDMI registers
         MEMORY32FIXED (ReadWrite, 0, BCM2836_HDMI0_LENGTH, RM06)
         MEMORY32FIXED (ReadWrite, 0, BCM2836_HDMI1_LENGTH, RM07)
         // hdmi_int[0]
-        // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x48 }
+        // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_HDMI0_INTERRUPT }
         // hdmi_int[1]
-        // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x49 }
+        // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_HDMI1_INTERRUPT }
 
         // HDMI DDC connection
         I2CSerialBus (0x50,, 100000,, "\\_SB.I2C2",,,,)  // EDID
@@ -214,7 +214,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       Name (RBUF, ResourceTemplate ()
       {
         MEMORY32FIXED (ReadWrite, 0, BCM2836_MBOX_LENGTH, RMEM)
-        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x61 }
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_MBOX_INTERRUPT }
       })
 
       Method (_CRS, 0x0, Serialized)
@@ -239,7 +239,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       Name (RBUF, ResourceTemplate ()
       {
         MEMORY32FIXED (ReadWrite, 0, BCM2836_VCHIQ_LENGTH, RMEM)
-        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x62 }
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_VCHIQ_INTERRUPT }
       })
 
       Method (_CRS, 0x0, Serialized)
@@ -277,7 +277,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       Name (RBUF, ResourceTemplate ()
       {
         MEMORY32FIXED (ReadWrite, 0, GPIO_LENGTH, RMEM)
-        Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { 0x51, 0x53 }
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { BCM2386_GPIO_INTERRUPT0, BCM2386_GPIO_INTERRUPT1 }
       })
       Method (_CRS, 0x0, Serialized)
       {
@@ -302,7 +302,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
         {
           // No need for MEMORY32SETBASE on Genet as we have a straight base address constant
           MEMORY32FIXED (ReadWrite, GENET_BASE_ADDRESS, GENET_LENGTH, )
-          Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0xBD, 0xBE }
+          Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { GENET_INTERRUPT0, GENET_INTERRUPT1 }
         })
         Return (RBUF)
       }
@@ -329,7 +329,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       Name (RBUF, ResourceTemplate ()
       {
         MEMORY32FIXED (ReadWrite, 0, BCM2836_I2C1_LENGTH, RMEM)
-        Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { 0x55 }
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { BCM2836_I2C1_INTERRUPT }
 
         //
         // MsftFunctionConfig is encoded as the VendorLong.
@@ -368,7 +368,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       Name (RBUF, ResourceTemplate()
       {
         MEMORY32FIXED (ReadWrite, 0, BCM2836_I2C2_LENGTH, RMEM)
-        Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { 0x55 }
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { BCM2836_I2C2_INTERRUPT }
       })
 
       Method (_CRS, 0x0, Serialized)
@@ -392,7 +392,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       Name (RBUF, ResourceTemplate ()
       {
         MEMORY32FIXED (ReadWrite, 0, BCM2836_SPI0_LENGTH, RMEM)
-        Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { 0x56 }
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { BCM2836_SPI0_INTERRUPT }
 
         //
         // MsftFunctionConfig is encoded as the VendorLong.
@@ -459,7 +459,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       Name (RBUF, ResourceTemplate ()
       {
         MEMORY32FIXED (ReadWrite, 0, BCM2836_SPI1_LENGTH, RMEM)
-        Interrupt (ResourceConsumer, Level, ActiveHigh, Shared,) { 0x3D }
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Shared,) { BCM2836_SPI1_INTERRUPT }
 
         //
         // MsftFunctionConfig is encoded as the VendorLong.
@@ -515,7 +515,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
     //     Name (RBUF, ResourceTemplate ()
     //     {
     //       MEMORY32FIXED (ReadWrite, BCM2836_SPI2_BASE_ADDRESS, BCM2836_SPI2_LENGTH, RMEM)
-    //       Interrupt (ResourceConsumer, Level, ActiveHigh, Shared,) { 0x3D }
+    //       Interrupt (ResourceConsumer, Level, ActiveHigh, Shared,) { BCM2836_SPI2_INTERRUPT }
     //     })
     //     Return (RBUF)
     //   }
@@ -545,7 +545,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
         // PWM clock control
         MEMORY32FIXED (ReadWrite, 0, BCM2836_PWM_CLK_LENGTH, RM03)
         // Interrupt DMA channel 11
-        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x3B }
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_DMA_INTERRUPT }
         // DMA channel 11, DREQ 5 for PWM
         FixedDMA (5, 11, Width32Bit, )
       })
diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Sdhc.asl b/Platform/RaspberryPi/RPi4/AcpiTables/Sdhc.asl
index 590c71edd484..0ab1ba27f2cf 100644
--- a/Platform/RaspberryPi/RPi4/AcpiTables/Sdhc.asl
+++ b/Platform/RaspberryPi/RPi4/AcpiTables/Sdhc.asl
@@ -37,7 +37,7 @@ Device (SDC1)
   Name (RBUF, ResourceTemplate ()
   {
     MEMORY32FIXED (ReadWrite, 0, MMCHS1_LENGTH, RMEM)
-    Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x9E }
+    Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_MMCHS1_INTERRUPT }
   })
   Method (_CRS, 0x0, Serialized)
   {
@@ -81,7 +81,7 @@ Device (SDC2)
   Name (RBUF, ResourceTemplate ()
   {
     MEMORY32FIXED (ReadWrite, 0, SDHOST_LENGTH, RMEM)
-    Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x98 }
+    Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_SDHOST_INTERRUPT }
   })
   Method (_CRS, 0x0, Serialized)
   {
diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Uart.asl b/Platform/RaspberryPi/RPi4/AcpiTables/Uart.asl
index 1be285220ad7..c466247bb33b 100644
--- a/Platform/RaspberryPi/RPi4/AcpiTables/Uart.asl
+++ b/Platform/RaspberryPi/RPi4/AcpiTables/Uart.asl
@@ -28,7 +28,7 @@ Device (URT0)
   Name (RBUF, ResourceTemplate ()
   {
     MEMORY32FIXED (ReadWrite, 0, BCM2836_PL011_UART_LENGTH, RMEM)
-    Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x99 }
+    Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_PL011_UART_INTERRUPT }
   })
   Method (_CRS, 0x0, Serialized)
   {
@@ -68,7 +68,7 @@ Device (URTM)
   Name (RBUF, ResourceTemplate ()
   {
     MEMORY32FIXED (ReadWrite, 0, BCM2836_MINI_UART_LENGTH, RMEM)
-    Interrupt(ResourceConsumer, Level, ActiveHigh, Shared) { 0x7D }
+    Interrupt(ResourceConsumer, Level, ActiveHigh, Shared) { BCM2836_MINI_UART_INTERRUPT }
 
     // NTRAID#MSFT-7141401-2016/04/7-jordanrh - disable UART muxing
     // until a proper solution can be created for the dmap conflict.
diff --git a/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h b/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h
index 0b402e9ac56e..a930c64af379 100644
--- a/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h
+++ b/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h
@@ -80,12 +80,10 @@
 #define BCM2836_PL011_UART_OFFSET                           0x00201000
 #define BCM2836_PL011_UART_BASE_ADDRESS                     (BCM2836_SOC_REGISTERS + BCM2836_PL011_UART_OFFSET)
 #define BCM2836_PL011_UART_LENGTH                           0x00001000
-#define BCM2836_PL011_UART_INTERRUPT                        0x99
 
 #define BCM2836_MINI_UART_OFFSET                            0x00215000
 #define BCM2836_MINI_UART_BASE_ADDRESS                      (BCM2836_SOC_REGISTERS + BCM2836_MINI_UART_OFFSET)
 #define BCM2836_MINI_UART_LENGTH                            0x00000070
-#define BCM2836_MINI_UART_INTERRUPT                         0x7D
 
 #define BCM2836_I2C0_OFFSET                                 0x00205000
 #define BCM2836_I2C0_BASE_ADDRESS                           (BCM2836_SOC_REGISTERS + BCM2836_I2C0_OFFSET)
-- 
2.21.0.windows.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [edk2-platforms][PATCH 12/15] Platform/RPi3: Move ACPI interrupts definitions to AcpiTables.h
  2020-02-28 10:38 [edk2-platforms][PATCH 00/15] Platform/RPi: Clean up and factorize ACPI Pete Batard
                   ` (10 preceding siblings ...)
  2020-02-28 10:38 ` [edk2-platforms][PATCH 11/15] Platform/RPi4: Move ACPI interrupts definitions to AcpiTables.h Pete Batard
@ 2020-02-28 10:38 ` Pete Batard
  2020-02-28 10:38 ` [edk2-platforms][PATCH 13/15] Platform/RPi4: Prepare ACPI code for factorization Pete Batard
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 23+ messages in thread
From: Pete Batard @ 2020-02-28 10:38 UTC (permalink / raw)
  To: devel; +Cc: ard.biesheuvel, leif, philmd

The ACPI interrupts are not the same across different Raspberry Pi
platforms therefore moving them into AcpiTables.h will help with ACPI
code factorization.

Signed-off-by: Pete Batard <pete@akeo.ie>
---
 Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.h | 26 +++++++++++++++
 Platform/RaspberryPi/RPi3/AcpiTables/Dsdt.asl     | 34 ++++++++++----------
 Platform/RaspberryPi/RPi3/AcpiTables/Sdhc.asl     |  4 +--
 Platform/RaspberryPi/RPi3/AcpiTables/Spcr.aslc    |  4 +--
 Platform/RaspberryPi/RPi3/AcpiTables/Uart.asl     |  4 +--
 5 files changed, 49 insertions(+), 23 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.h b/Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.h
index c860b7881842..be97fc4c1eff 100644
--- a/Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.h
+++ b/Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.h
@@ -97,4 +97,30 @@ typedef struct
   UINT32 UID;                     // 4 bytes
 } EFI_ACPI_5_1_CSRT_RESOURCE_DESCRIPTOR_HEADER;
 
+//------------------------------------------------------------------------
+// Interrupts. These are specific to each platform
+//------------------------------------------------------------------------
+#define BCM2836_USB_INTERRUPT                   0x29
+#define BCM2836_V3D_BUS_INTERRUPT               0x2A
+#define BCM2836_DMA_INTERRUPT                   0x3B
+#define BCM2836_SPI1_INTERRUPT                  0x3D
+#define BCM2836_SPI2_INTERRUPT                  0x3D
+#define BCM2836_HVS_INTERRUPT                   0x41
+#define BCM2836_HDMI0_INTERRUPT                 0x48
+#define BCM2836_HDMI1_INTERRUPT                 0x49
+#define BCM2836_PV2_INTERRUPT                   0x4A
+#define BCM2836_PV0_INTERRUPT                   0x4D
+#define BCM2836_PV1_INTERRUPT                   0x4E
+#define BCM2836_MBOX_INTERRUPT                  0x61
+#define BCM2836_VCHIQ_INTERRUPT                 0x62
+#define BCM2386_GPIO_INTERRUPT0                 0x51
+#define BCM2386_GPIO_INTERRUPT1                 0x53
+#define BCM2836_I2C1_INTERRUPT                  0x55
+#define BCM2836_I2C2_INTERRUPT                  0x55
+#define BCM2836_SPI0_INTERRUPT                  0x56
+#define BCM2836_SDHOST_INTERRUPT                0x58
+#define BCM2836_MMCHS1_INTERRUPT                0x5E
+#define BCM2836_MINI_UART_INTERRUPT             0x3D
+#define BCM2836_PL011_UART_INTERRUPT            0x59
+
 #endif // __ACPITABLES_H__
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Dsdt.asl b/Platform/RaspberryPi/RPi3/AcpiTables/Dsdt.asl
index 693e4b15e985..1e17ec901042 100644
--- a/Platform/RaspberryPi/RPi3/AcpiTables/Dsdt.asl
+++ b/Platform/RaspberryPi/RPi3/AcpiTables/Dsdt.asl
@@ -85,7 +85,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       Name (RBUF, ResourceTemplate ()
       {
         MEMORY32FIXED (ReadWrite, 0, BCM2836_USB_LENGTH, RMEM)
-        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x29 }
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_USB_INTERRUPT }
       })
       Method (_CRS, 0x0, Serialized)
       {
@@ -109,32 +109,32 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       {
         // Memory and interrupt for the GPU
         MEMORY32FIXED (ReadWrite, 0, BCM2836_V3D_BUS_LENGTH, RM01)
-        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x2A }
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_V3D_BUS_INTERRUPT }
 
         // HVS - Hardware Video Scalar
         MEMORY32FIXED (ReadWrite, 0, BCM2836_HVS_LENGTH, RM02)
         // The HVS interrupt is reserved by the VPU
-        // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x41 }
+        // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_HVS_INTERRUPT }
 
         // PixelValve0 - DSI0 or DPI
         // MEMORY32FIXED (ReadWrite, BCM2836_PV0_BASE_ADDRESS, BCM2836_PV0_LENGTH, RM03)
-        // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x4D }
+        // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_PV0_INTERRUPT }
 
         // PixelValve1 - DS1 or SMI
         // MEMORY32FIXED (ReadWrite, BCM2836_PV1_BASE_ADDRESS, BCM2836_PV1_LENGTH, RM04)
-        // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x4E }
+        // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_PV1_INTERRUPT }
 
         // PixelValve2 - HDMI output - connected to HVS display FIFO 1
         MEMORY32FIXED (ReadWrite, 0, BCM2836_PV2_LENGTH, RM05)
-        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x4A }
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_PV2_INTERRUPT }
 
         // HDMI registers
         MEMORY32FIXED (ReadWrite, 0, BCM2836_HDMI0_LENGTH, RM06)
         MEMORY32FIXED (ReadWrite, 0, BCM2836_HDMI1_LENGTH, RM07)
         // hdmi_int[0]
-        // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x48 }
+        // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_HDMI0_INTERRUPT }
         // hdmi_int[1]
-        // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x49 }
+        // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_HDMI1_INTERRUPT }
 
         // HDMI DDC connection
         I2CSerialBus (0x50,, 100000,, "\\_SB.I2C2",,,,)  // EDID
@@ -212,7 +212,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       Name (RBUF, ResourceTemplate ()
       {
         MEMORY32FIXED (ReadWrite, 0, BCM2836_MBOX_LENGTH, RMEM)
-        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x61 }
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_MBOX_INTERRUPT }
       })
 
       Method (_CRS, 0x0, Serialized)
@@ -237,7 +237,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       Name (RBUF, ResourceTemplate ()
       {
         MEMORY32FIXED (ReadWrite, 0, BCM2836_VCHIQ_LENGTH, RMEM)
-        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x62 }
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_VCHIQ_INTERRUPT }
       })
 
       Method (_CRS, 0x0, Serialized)
@@ -275,7 +275,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       Name (RBUF, ResourceTemplate ()
       {
         MEMORY32FIXED (ReadWrite, 0, GPIO_LENGTH, RMEM)
-        Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { 0x51, 0x53 }
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { BCM2386_GPIO_INTERRUPT0, BCM2386_GPIO_INTERRUPT1 }
       })
       Method (_CRS, 0x0, Serialized)
       {
@@ -298,7 +298,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       Name (RBUF, ResourceTemplate ()
       {
         MEMORY32FIXED (ReadWrite, 0, BCM2836_I2C1_LENGTH, RMEM)
-        Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { 0x55 }
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { BCM2836_I2C1_INTERRUPT }
 
         //
         // MsftFunctionConfig is encoded as the VendorLong.
@@ -337,7 +337,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       Name (RBUF, ResourceTemplate()
       {
         MEMORY32FIXED (ReadWrite, 0, BCM2836_I2C2_LENGTH, RMEM)
-        Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { 0x55 }
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { BCM2836_I2C2_INTERRUPT }
       })
 
       Method (_CRS, 0x0, Serialized)
@@ -361,7 +361,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       Name (RBUF, ResourceTemplate ()
       {
         MEMORY32FIXED (ReadWrite, 0, BCM2836_SPI0_LENGTH, RMEM)
-        Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { 0x56 }
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { BCM2836_SPI0_INTERRUPT }
 
         //
         // MsftFunctionConfig is encoded as the VendorLong.
@@ -428,7 +428,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       Name (RBUF, ResourceTemplate ()
       {
         MEMORY32FIXED (ReadWrite, 0, BCM2836_SPI1_LENGTH, RMEM)
-        Interrupt (ResourceConsumer, Level, ActiveHigh, Shared,) { 0x3D }
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Shared,) { BCM2836_SPI1_INTERRUPT }
 
         //
         // MsftFunctionConfig is encoded as the VendorLong.
@@ -484,7 +484,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
     //     Name (RBUF, ResourceTemplate ()
     //     {
     //       MEMORY32FIXED (ReadWrite, BCM2836_SPI2_BASE_ADDRESS, BCM2836_SPI2_LENGTH, RMEM)
-    //       Interrupt (ResourceConsumer, Level, ActiveHigh, Shared,) { 0x3D }
+    //       Interrupt (ResourceConsumer, Level, ActiveHigh, Shared,) { BCM2836_SPI2_INTERRUPT }
     //     })
     //     Return (RBUF)
     //   }
@@ -514,7 +514,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
         // PWM clock control
         MEMORY32FIXED (ReadWrite, 0, BCM2836_PWM_CLK_LENGTH, RM03)
         // Interrupt DMA channel 11
-        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x3B }
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_DMA_INTERRUPT }
         // DMA channel 11, DREQ 5 for PWM
         FixedDMA (5, 11, Width32Bit, )
       })
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Sdhc.asl b/Platform/RaspberryPi/RPi3/AcpiTables/Sdhc.asl
index f7553280b60e..0ab1ba27f2cf 100644
--- a/Platform/RaspberryPi/RPi3/AcpiTables/Sdhc.asl
+++ b/Platform/RaspberryPi/RPi3/AcpiTables/Sdhc.asl
@@ -37,7 +37,7 @@ Device (SDC1)
   Name (RBUF, ResourceTemplate ()
   {
     MEMORY32FIXED (ReadWrite, 0, MMCHS1_LENGTH, RMEM)
-    Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x5E }
+    Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_MMCHS1_INTERRUPT }
   })
   Method (_CRS, 0x0, Serialized)
   {
@@ -81,7 +81,7 @@ Device (SDC2)
   Name (RBUF, ResourceTemplate ()
   {
     MEMORY32FIXED (ReadWrite, 0, SDHOST_LENGTH, RMEM)
-    Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x58 }
+    Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_SDHOST_INTERRUPT }
   })
   Method (_CRS, 0x0, Serialized)
   {
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Spcr.aslc b/Platform/RaspberryPi/RPi3/AcpiTables/Spcr.aslc
index cfa1734a3980..cb17fbe0ff2f 100644
--- a/Platform/RaspberryPi/RPi3/AcpiTables/Spcr.aslc
+++ b/Platform/RaspberryPi/RPi3/AcpiTables/Spcr.aslc
@@ -21,11 +21,11 @@
 #ifdef PL011_ENABLE
 #define RPI_UART_INTERFACE_TYPE              EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_INTERFACE_TYPE_ARM_PL011_UART
 #define RPI_UART_BASE_ADDRESS                BCM2836_PL011_UART_BASE_ADDRESS
-#define RPI_UART_INTERRUPT                   0x59
+#define RPI_UART_INTERRUPT                   BCM2836_PL011_UART_INTERRUPT
 #else
 #define RPI_UART_INTERFACE_TYPE              EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_INTERFACE_TYPE_BCM2835_UART
 #define RPI_UART_BASE_ADDRESS                BCM2836_MINI_UART_BASE_ADDRESS
-#define RPI_UART_INTERRUPT                   0x3D
+#define RPI_UART_INTERRUPT                   BCM2836_MINI_UART_INTERRUPT
 #endif
 STATIC EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE Spcr = {
   ACPI_HEADER (
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Uart.asl b/Platform/RaspberryPi/RPi3/AcpiTables/Uart.asl
index ddab63f15268..edd8bcc3b376 100644
--- a/Platform/RaspberryPi/RPi3/AcpiTables/Uart.asl
+++ b/Platform/RaspberryPi/RPi3/AcpiTables/Uart.asl
@@ -28,7 +28,7 @@ Device (URT0)
   Name (RBUF, ResourceTemplate ()
   {
     MEMORY32FIXED (ReadWrite, 0, BCM2836_PL011_UART_LENGTH, RMEM)
-    Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0x59 }
+    Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_PL011_UART_INTERRUPT }
   })
   Method (_CRS, 0x0, Serialized)
   {
@@ -68,7 +68,7 @@ Device (URTM)
   Name (RBUF, ResourceTemplate ()
   {
     MEMORY32FIXED (ReadWrite, 0, BCM2836_MINI_UART_LENGTH, RMEM)
-    Interrupt(ResourceConsumer, Level, ActiveHigh, Shared) { 0x3D }
+    Interrupt(ResourceConsumer, Level, ActiveHigh, Shared) { BCM2836_MINI_UART_INTERRUPT }
 
     // NTRAID#MSFT-7141401-2016/04/7-jordanrh - disable UART muxing
     // until a proper solution can be created for the dmap conflict.
-- 
2.21.0.windows.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [edk2-platforms][PATCH 13/15] Platform/RPi4: Prepare ACPI code for factorization
  2020-02-28 10:38 [edk2-platforms][PATCH 00/15] Platform/RPi: Clean up and factorize ACPI Pete Batard
                   ` (11 preceding siblings ...)
  2020-02-28 10:38 ` [edk2-platforms][PATCH 12/15] Platform/RPi3: " Pete Batard
@ 2020-02-28 10:38 ` Pete Batard
  2020-02-28 10:38 ` [edk2-platforms][PATCH 14/15] Platform/RPi3: Merge ACPI code from RPi4 Pete Batard
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 23+ messages in thread
From: Pete Batard @ 2020-02-28 10:38 UTC (permalink / raw)
  To: devel; +Cc: ard.biesheuvel, leif, philmd

* Update the OEM IDs and base revision numbers.
* Move RPI_SYSTEM_TIMER_BASE_ADDRESS to AcpiTables.h.
* Add RPi3 constants and conditional blocks according to model.

Signed-off-by: Pete Batard <pete@akeo.ie>
---
 Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.h | 48 +++++++++++++++++---
 Platform/RaspberryPi/RPi4/AcpiTables/Dsdt.asl     |  4 ++
 Platform/RaspberryPi/RPi4/AcpiTables/Gtdt.aslc    |  1 -
 Platform/RaspberryPi/RPi4/AcpiTables/Madt.aslc    | 15 ++++++
 4 files changed, 61 insertions(+), 7 deletions(-)

diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.h b/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.h
index 3d1737aed41a..0b8a8494450c 100644
--- a/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.h
+++ b/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.h
@@ -1,7 +1,8 @@
 /** @file
  *
- *  RPi4 defines for constructing ACPI tables
+ *  RPi defines for constructing ACPI tables
  *
+ *  Copyright (c) 2020, Pete Batard <pete@akeo.ie>
  *  Copyright (c) 2019, ARM Ltd. All rights reserved.
  *  Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
  *  Copyright (c) Microsoft Corporation. All rights reserved.
@@ -23,11 +24,15 @@
     CreateDwordField (^BufName, ^MemName._BAS, VarName)          \
     Add (BCM2836_SOC_REGISTERS, Offset, VarName)
 
-#define EFI_ACPI_OEM_ID                       {'M','C','R','S','F','T'} // OEMID 6 bytes long
-#define EFI_ACPI_OEM_TABLE_ID                 SIGNATURE_64 ('R','P','I','4','E','D','K','2') // OEM table id 8 bytes long
-#define EFI_ACPI_OEM_REVISION                 0x02000820
-#define EFI_ACPI_CREATOR_ID                   SIGNATURE_32 ('R','P','I','4')
-#define EFI_ACPI_CREATOR_REVISION             0x00000097
+#if (RPI_MODEL == 3)
+#define EFI_ACPI_OEM_ID                       {'B','C','2','8','3','6'}
+#else
+#define EFI_ACPI_OEM_ID                       {'M','C','R','S','F','T'}
+#endif
+#define EFI_ACPI_OEM_TABLE_ID                 SIGNATURE_64 ('R','P','I','_','E','D','K','2')
+#define EFI_ACPI_OEM_REVISION                 0x00000100
+#define EFI_ACPI_CREATOR_ID                   SIGNATURE_32 ('E','D','K','2')
+#define EFI_ACPI_CREATOR_REVISION             0x00000100
 
 #define EFI_ACPI_VENDOR_ID                    SIGNATURE_32 ('M','S','F','T')
 
@@ -52,6 +57,12 @@
 #define RPI_DMA_CHANNEL_COUNT                 10 // All 10 DMA channels are listed, including the reserved ones
 #define RPI_DMA_USED_CHANNEL_COUNT            5  // Use 5 DMA channels
 
+#if (RPI_MODEL == 3)
+#define RPI_SYSTEM_TIMER_BASE_ADDRESS         0x4000001C
+#elif (RPI_MODEL == 4)
+#define RPI_SYSTEM_TIMER_BASE_ADDRESS         0xFF80001C
+#endif
+
 #define EFI_ACPI_5_1_CSRT_REVISION            0x00000000
 
 typedef enum
@@ -100,6 +111,30 @@ typedef struct
 //------------------------------------------------------------------------
 // Interrupts. These are specific to each platform
 //------------------------------------------------------------------------
+#if (RPI_MODEL == 3)
+#define BCM2836_V3D_BUS_INTERRUPT               0x2A
+#define BCM2836_DMA_INTERRUPT                   0x3B
+#define BCM2836_SPI1_INTERRUPT                  0x3D
+#define BCM2836_SPI2_INTERRUPT                  0x3D
+#define BCM2836_HVS_INTERRUPT                   0x41
+#define BCM2836_HDMI0_INTERRUPT                 0x48
+#define BCM2836_HDMI1_INTERRUPT                 0x49
+#define BCM2836_PV2_INTERRUPT                   0x4A
+#define BCM2836_PV0_INTERRUPT                   0x4D
+#define BCM2836_PV1_INTERRUPT                   0x4E
+#define BCM2836_MBOX_INTERRUPT                  0x61
+#define BCM2836_VCHIQ_INTERRUPT                 0x62
+#define BCM2386_GPIO_INTERRUPT0                 0x51
+#define BCM2386_GPIO_INTERRUPT1                 0x53
+#define BCM2836_I2C1_INTERRUPT                  0x55
+#define BCM2836_I2C2_INTERRUPT                  0x55
+#define BCM2836_SPI0_INTERRUPT                  0x56
+#define BCM2836_USB_INTERRUPT                   0x29
+#define BCM2836_SDHOST_INTERRUPT                0x58
+#define BCM2836_MMCHS1_INTERRUPT                0x5E
+#define BCM2836_MINI_UART_INTERRUPT             0x3D
+#define BCM2836_PL011_UART_INTERRUPT            0x59
+#elif (RPI_MODEL == 4)
 #define BCM2836_V3D_BUS_INTERRUPT               0x2A
 #define BCM2836_DMA_INTERRUPT                   0x3B
 #define BCM2836_SPI1_INTERRUPT                  0x3D
@@ -124,5 +159,6 @@ typedef struct
 #define BCM2836_PL011_UART_INTERRUPT            0x99
 #define GENET_INTERRUPT0                        0xBD
 #define GENET_INTERRUPT1                        0xBE
+#endif
 
 #endif // __ACPITABLES_H__
diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Dsdt.asl b/Platform/RaspberryPi/RPi4/AcpiTables/Dsdt.asl
index e1ddb742376a..c2775088b5a2 100644
--- a/Platform/RaspberryPi/RPi4/AcpiTables/Dsdt.asl
+++ b/Platform/RaspberryPi/RPi4/AcpiTables/Dsdt.asl
@@ -31,7 +31,9 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
   {
     include ("Sdhc.asl")
     include ("Pep.asl")
+#if (RPI_MODEL == 4)
     include ("Xhci.asl")
+#endif
 
     Device (CPU0)
     {
@@ -286,6 +288,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       }
     }
 
+#if (RPI_MODEL == 4)
     Device (ETH0)
     {
       Name (_HID, "BCM6E4E")
@@ -314,6 +317,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
         }
       })
     }
+#endif
 
     // Description: I2C
     Device (I2C1)
diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Gtdt.aslc b/Platform/RaspberryPi/RPi4/AcpiTables/Gtdt.aslc
index 7c2aa9389456..8453e487fb63 100644
--- a/Platform/RaspberryPi/RPi4/AcpiTables/Gtdt.aslc
+++ b/Platform/RaspberryPi/RPi4/AcpiTables/Gtdt.aslc
@@ -14,7 +14,6 @@
 
 #include "AcpiTables.h"
 
-#define RPI_SYSTEM_TIMER_BASE_ADDRESS   0xFF80001C
 #define RPI_GTDT_GLOBAL_FLAGS           0
 #define RPI_GTDT_GTIMER_FLAGS           EFI_ACPI_5_1_GTDT_TIMER_FLAG_TIMER_INTERRUPT_POLARITY
 
diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Madt.aslc b/Platform/RaspberryPi/RPi4/AcpiTables/Madt.aslc
index f847a9310ff7..4029cd191ab5 100644
--- a/Platform/RaspberryPi/RPi4/AcpiTables/Madt.aslc
+++ b/Platform/RaspberryPi/RPi4/AcpiTables/Madt.aslc
@@ -23,7 +23,9 @@
 typedef struct {
   EFI_ACPI_5_1_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER   Header;
   EFI_ACPI_5_1_GIC_STRUCTURE                            GicInterfaces[4];
+#if (RPI_MODEL != 3)
   EFI_ACPI_5_1_GIC_DISTRIBUTOR_STRUCTURE                GicDistributor;
+#endif
 } PI_MULTIPLE_APIC_DESCRIPTION_TABLE;
 
 #pragma pack ()
@@ -42,6 +44,16 @@ PI_MULTIPLE_APIC_DESCRIPTION_TABLE Madt = {
     0, // Flags
   },
   {
+#if (RPI_MODEL == 3)
+    EFI_ACPI_5_1_GICC_STRUCTURE_INIT(
+        0, 0, GET_MPID(0, 0), EFI_ACPI_5_1_GIC_ENABLED, 0x09, 0x40000000, 0, 0, 0, 0),
+    EFI_ACPI_5_1_GICC_STRUCTURE_INIT(
+        1, 1, GET_MPID(0, 1), EFI_ACPI_5_1_GIC_ENABLED, 0x09, 0x40000000, 0, 0, 0, 0),
+    EFI_ACPI_5_1_GICC_STRUCTURE_INIT(
+        2, 2, GET_MPID(0, 2), EFI_ACPI_5_1_GIC_ENABLED, 0x09, 0x40000000, 0, 0, 0, 0),
+    EFI_ACPI_5_1_GICC_STRUCTURE_INIT(
+        3, 3, GET_MPID(0, 3), EFI_ACPI_5_1_GIC_ENABLED, 0x09, 0x40000000, 0, 0, 0, 0),
+#elif (RPI_MODEL == 4)
     EFI_ACPI_5_1_GICC_STRUCTURE_INIT(
         0, 0, GET_MPID(0, 0), EFI_ACPI_5_1_GIC_ENABLED, 48, FixedPcdGet64 (PcdGicInterruptInterfaceBase),
         0xFF846000, 0xFF844000, 0x19, 0),
@@ -54,8 +66,11 @@ PI_MULTIPLE_APIC_DESCRIPTION_TABLE Madt = {
     EFI_ACPI_5_1_GICC_STRUCTURE_INIT(
         3, 3, GET_MPID(0, 3), EFI_ACPI_5_1_GIC_ENABLED, 51, FixedPcdGet64 (PcdGicInterruptInterfaceBase),
         0xFF846000, 0xFF844000, 0x19, 0),
+#endif
   },
+#if (RPI_MODEL != 3)
   EFI_ACPI_5_0_GIC_DISTRIBUTOR_INIT(0, FixedPcdGet64 (PcdGicDistributorBase), 0)
+#endif
 };
 
 //
-- 
2.21.0.windows.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [edk2-platforms][PATCH 14/15] Platform/RPi3: Merge ACPI code from RPi4
  2020-02-28 10:38 [edk2-platforms][PATCH 00/15] Platform/RPi: Clean up and factorize ACPI Pete Batard
                   ` (12 preceding siblings ...)
  2020-02-28 10:38 ` [edk2-platforms][PATCH 13/15] Platform/RPi4: Prepare ACPI code for factorization Pete Batard
@ 2020-02-28 10:38 ` Pete Batard
  2020-02-28 10:38 ` [edk2-platforms][PATCH 15/15] Platform/RPi: Factorize ACPI tables Pete Batard
  2020-02-28 12:17 ` [edk2-platforms][PATCH 00/15] Platform/RPi: Clean up and factorize ACPI Ard Biesheuvel
  15 siblings, 0 replies; 23+ messages in thread
From: Pete Batard @ 2020-02-28 10:38 UTC (permalink / raw)
  To: devel; +Cc: ard.biesheuvel, leif, philmd

This basically copies all of the RPi4 platform ACPI source into RPi3
since the last commit updates the code to serve both platforms.

No alteration of original ACPI source files were applied.

Whereas this commit is pretty much superfluous (apart from the .dsc
changes), since these files will be removed in the next commit, we apply
it nonetheless so that the minimal alterations to the existing Raspberry
3 tables are made apparent.

Signed-off-by: Pete Batard <pete@akeo.ie>
---
 Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.h   |  88 +++++++++----
 Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.inf |  11 +-
 Platform/RaspberryPi/RPi3/AcpiTables/Csrt.aslc      |  28 ++--
 Platform/RaspberryPi/RPi3/AcpiTables/Dbg2.aslc      |   2 +-
 Platform/RaspberryPi/RPi3/AcpiTables/Dsdt.asl       |  35 +++++
 Platform/RaspberryPi/RPi3/AcpiTables/Gtdt.aslc      |   1 -
 Platform/RaspberryPi/RPi3/AcpiTables/Madt.aslc      |  22 +++-
 Platform/RaspberryPi/RPi3/AcpiTables/Pep.asl        |   5 +-
 Platform/RaspberryPi/RPi3/AcpiTables/Pep.c          |   7 +-
 Platform/RaspberryPi/RPi3/AcpiTables/Pep.h          |   9 +-
 Platform/RaspberryPi/RPi3/AcpiTables/Spcr.aslc      |   3 +-
 Platform/RaspberryPi/RPi3/AcpiTables/Uart.asl       |   2 +-
 Platform/RaspberryPi/RPi3/AcpiTables/Xhci.asl       | 136 ++++++++++++++++++++
 Platform/RaspberryPi/RPi3/RPi3.dsc                  |   4 +
 14 files changed, 300 insertions(+), 53 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.h b/Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.h
index be97fc4c1eff..0b8a8494450c 100644
--- a/Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.h
+++ b/Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.h
@@ -1,7 +1,8 @@
 /** @file
  *
- *  RPi3 defines for constructing ACPI tables
+ *  RPi defines for constructing ACPI tables
  *
+ *  Copyright (c) 2020, Pete Batard <pete@akeo.ie>
  *  Copyright (c) 2019, ARM Ltd. All rights reserved.
  *  Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
  *  Copyright (c) Microsoft Corporation. All rights reserved.
@@ -23,11 +24,15 @@
     CreateDwordField (^BufName, ^MemName._BAS, VarName)          \
     Add (BCM2836_SOC_REGISTERS, Offset, VarName)
 
-#define EFI_ACPI_OEM_ID                       {'B','C','2','8','3','6'} // OEMID 6 bytes long
-#define EFI_ACPI_OEM_TABLE_ID                 SIGNATURE_64 ('R','P','I','3','E','D','K','2') // OEM table id 8 bytes long
-#define EFI_ACPI_OEM_REVISION                 0x02000820
-#define EFI_ACPI_CREATOR_ID                   SIGNATURE_32 ('R','P','I','3')
-#define EFI_ACPI_CREATOR_REVISION             0x00000097
+#if (RPI_MODEL == 3)
+#define EFI_ACPI_OEM_ID                       {'B','C','2','8','3','6'}
+#else
+#define EFI_ACPI_OEM_ID                       {'M','C','R','S','F','T'}
+#endif
+#define EFI_ACPI_OEM_TABLE_ID                 SIGNATURE_64 ('R','P','I','_','E','D','K','2')
+#define EFI_ACPI_OEM_REVISION                 0x00000100
+#define EFI_ACPI_CREATOR_ID                   SIGNATURE_32 ('E','D','K','2')
+#define EFI_ACPI_CREATOR_REVISION             0x00000100
 
 #define EFI_ACPI_VENDOR_ID                    SIGNATURE_32 ('M','S','F','T')
 
@@ -49,8 +54,14 @@
 #define EFI_ACPI_CSRT_DEVICE_ID_DMA           0x00000009 // Fixed id
 #define EFI_ACPI_CSRT_RESOURCE_ID_IN_DMA_GRP  0x0 // Count up from 0
 
-#define RPI3_DMA_CHANNEL_COUNT                10 // All 10 DMA channels are listed, including the reserved ones
-#define RPI3_DMA_USED_CHANNEL_COUNT           5  // Use 5 DMA channels
+#define RPI_DMA_CHANNEL_COUNT                 10 // All 10 DMA channels are listed, including the reserved ones
+#define RPI_DMA_USED_CHANNEL_COUNT            5  // Use 5 DMA channels
+
+#if (RPI_MODEL == 3)
+#define RPI_SYSTEM_TIMER_BASE_ADDRESS         0x4000001C
+#elif (RPI_MODEL == 4)
+#define RPI_SYSTEM_TIMER_BASE_ADDRESS         0xFF80001C
+#endif
 
 #define EFI_ACPI_5_1_CSRT_REVISION            0x00000000
 
@@ -100,27 +111,54 @@ typedef struct
 //------------------------------------------------------------------------
 // Interrupts. These are specific to each platform
 //------------------------------------------------------------------------
+#if (RPI_MODEL == 3)
+#define BCM2836_V3D_BUS_INTERRUPT               0x2A
+#define BCM2836_DMA_INTERRUPT                   0x3B
+#define BCM2836_SPI1_INTERRUPT                  0x3D
+#define BCM2836_SPI2_INTERRUPT                  0x3D
+#define BCM2836_HVS_INTERRUPT                   0x41
+#define BCM2836_HDMI0_INTERRUPT                 0x48
+#define BCM2836_HDMI1_INTERRUPT                 0x49
+#define BCM2836_PV2_INTERRUPT                   0x4A
+#define BCM2836_PV0_INTERRUPT                   0x4D
+#define BCM2836_PV1_INTERRUPT                   0x4E
+#define BCM2836_MBOX_INTERRUPT                  0x61
+#define BCM2836_VCHIQ_INTERRUPT                 0x62
+#define BCM2386_GPIO_INTERRUPT0                 0x51
+#define BCM2386_GPIO_INTERRUPT1                 0x53
+#define BCM2836_I2C1_INTERRUPT                  0x55
+#define BCM2836_I2C2_INTERRUPT                  0x55
+#define BCM2836_SPI0_INTERRUPT                  0x56
 #define BCM2836_USB_INTERRUPT                   0x29
-#define BCM2836_V3D_BUS_INTERRUPT               0x2A
-#define BCM2836_DMA_INTERRUPT                   0x3B
-#define BCM2836_SPI1_INTERRUPT                  0x3D
-#define BCM2836_SPI2_INTERRUPT                  0x3D
-#define BCM2836_HVS_INTERRUPT                   0x41
-#define BCM2836_HDMI0_INTERRUPT                 0x48
-#define BCM2836_HDMI1_INTERRUPT                 0x49
-#define BCM2836_PV2_INTERRUPT                   0x4A
-#define BCM2836_PV0_INTERRUPT                   0x4D
-#define BCM2836_PV1_INTERRUPT                   0x4E
-#define BCM2836_MBOX_INTERRUPT                  0x61
-#define BCM2836_VCHIQ_INTERRUPT                 0x62
-#define BCM2386_GPIO_INTERRUPT0                 0x51
-#define BCM2386_GPIO_INTERRUPT1                 0x53
-#define BCM2836_I2C1_INTERRUPT                  0x55
-#define BCM2836_I2C2_INTERRUPT                  0x55
-#define BCM2836_SPI0_INTERRUPT                  0x56
 #define BCM2836_SDHOST_INTERRUPT                0x58
 #define BCM2836_MMCHS1_INTERRUPT                0x5E
 #define BCM2836_MINI_UART_INTERRUPT             0x3D
 #define BCM2836_PL011_UART_INTERRUPT            0x59
+#elif (RPI_MODEL == 4)
+#define BCM2836_V3D_BUS_INTERRUPT               0x2A
+#define BCM2836_DMA_INTERRUPT                   0x3B
+#define BCM2836_SPI1_INTERRUPT                  0x3D
+#define BCM2836_SPI2_INTERRUPT                  0x3D
+#define BCM2836_HVS_INTERRUPT                   0x41
+#define BCM2836_HDMI0_INTERRUPT                 0x48
+#define BCM2836_HDMI1_INTERRUPT                 0x49
+#define BCM2836_PV2_INTERRUPT                   0x4A
+#define BCM2836_PV0_INTERRUPT                   0x4D
+#define BCM2836_PV1_INTERRUPT                   0x4E
+#define BCM2836_MBOX_INTERRUPT                  0x61
+#define BCM2836_VCHIQ_INTERRUPT                 0x62
+#define BCM2386_GPIO_INTERRUPT0                 0x51
+#define BCM2386_GPIO_INTERRUPT1                 0x53
+#define BCM2836_I2C1_INTERRUPT                  0x55
+#define BCM2836_I2C2_INTERRUPT                  0x55
+#define BCM2836_SPI0_INTERRUPT                  0x56
+#define BCM2836_USB_INTERRUPT                   0x69
+#define BCM2836_SDHOST_INTERRUPT                0x98
+#define BCM2836_MMCHS1_INTERRUPT                0x9E
+#define BCM2836_MINI_UART_INTERRUPT             0x7D
+#define BCM2836_PL011_UART_INTERRUPT            0x99
+#define GENET_INTERRUPT0                        0xBD
+#define GENET_INTERRUPT1                        0xBE
+#endif
 
 #endif // __ACPITABLES_H__
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.inf b/Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.inf
index 9363660b0ef7..c95d75ed01bb 100644
--- a/Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.inf
+++ b/Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.inf
@@ -2,6 +2,7 @@
 #
 #  ACPI table data and ASL sources required to boot the platform.
 #
+#  Copyright (c) 2019, ARM Limited. All rights reserved.
 #  Copyright (c) 2017, Andrey Warkentin <andrey.warkentin@gmail.com>
 #  Copyright (c) Microsoft Corporation. All rights reserved.
 #
@@ -35,15 +36,23 @@ [Sources]
 [Packages]
   ArmPkg/ArmPkg.dec
   ArmPlatformPkg/ArmPlatformPkg.dec
-  MdePkg/MdePkg.dec
   EmbeddedPkg/EmbeddedPkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  MdePkg/MdePkg.dec
+  Silicon/Broadcom/Bcm27xx/Bcm27xx.dec
   Silicon/Broadcom/Bcm283x/Bcm283x.dec
+  Silicon/Broadcom/Drivers/Net/BcmNet.dec
 
 [FixedPcd]
   gArmTokenSpaceGuid.PcdArmArchTimerIntrNum
   gArmTokenSpaceGuid.PcdArmArchTimerHypIntrNum
   gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum
   gArmTokenSpaceGuid.PcdArmArchTimerVirtIntrNum
+  gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase
+  gArmTokenSpaceGuid.PcdGicDistributorBase
+  gBcm27xxTokenSpaceGuid.PcdBcm27xxPciCpuMmioAdr
+  gBcm27xxTokenSpaceGuid.PcdBcm27xxPciRegBase
   gBcm283xTokenSpaceGuid.PcdBcm283xRegistersAddress
+  gBcmNetTokenSpaceGuid.PcdBcmGenetRegistersAddress
   gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate
   gEmbeddedTokenSpaceGuid.PcdInterruptBaseAddress
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Csrt.aslc b/Platform/RaspberryPi/RPi3/AcpiTables/Csrt.aslc
index 0a8393a8076b..03d888fffb8b 100644
--- a/Platform/RaspberryPi/RPi3/AcpiTables/Csrt.aslc
+++ b/Platform/RaspberryPi/RPi3/AcpiTables/Csrt.aslc
@@ -2,22 +2,24 @@
  *
  *  Core System Resource Table (CSRT)
  *
+ *  Copyright (c) 2019, ARM Ltd. All rights reserved.
  *  Copyright (c) Microsoft Corporation. All rights reserved.
  *
  *  SPDX-License-Identifier: BSD-2-Clause-Patent
  *
  **/
 
+#include <IndustryStandard/Acpi.h>
 #include <IndustryStandard/Bcm2836.h>
 
 #include "AcpiTables.h"
 
-#define DMA_MAX_REQ_LINES 32
+#define RPI_DMA_MAX_REQ_LINES 32
 
 #pragma pack (push, 1)
 
 //------------------------------------------------------------------------
-// DMA Controller Vendor Data for RPi3
+// DMA Controller Vendor Data
 //------------------------------------------------------------------------
 typedef struct
 {
@@ -35,7 +37,7 @@ typedef struct
 } DMA_CONTROLLER_VENDOR_DATA;
 
 //------------------------------------------------------------------------
-// DMA Controller on RPi3
+// DMA Controller
 //------------------------------------------------------------------------
 typedef struct
 {
@@ -44,7 +46,7 @@ typedef struct
 } RD_DMA_CONTROLLER;
 
 //------------------------------------------------------------------------
-// DMA Channel Vendor Data for RPi3
+// DMA Channel Vendor Data
 //------------------------------------------------------------------------
 typedef struct
 {
@@ -55,7 +57,7 @@ typedef struct
 } DMA_CHANNEL_VENDOR_DATA;
 
 //------------------------------------------------------------------------
-// DMA Channel on RPi3
+// DMA Channel
 //------------------------------------------------------------------------
 typedef struct
 {
@@ -64,18 +66,18 @@ typedef struct
 } RD_DMA_CHANNEL;
 
 //------------------------------------------------------------------------
-// DMA Resource Group on RPi3
+// DMA Resource Group
 //------------------------------------------------------------------------
 
 typedef struct
 {
   EFI_ACPI_5_1_CSRT_RESOURCE_GROUP_HEADER ResGroupHeader;
   RD_DMA_CONTROLLER DmaController;
-  RD_DMA_CHANNEL DmaChannels[RPI3_DMA_CHANNEL_COUNT];
+  RD_DMA_CHANNEL DmaChannels[RPI_DMA_CHANNEL_COUNT];
 } RG_DMA;
 
 //----------------------------------------------------------------------------
-// CSRT table structure for RPi3 platform - current revision only includes DMA
+// CSRT table structure - current revision only includes DMA
 //----------------------------------------------------------------------------
 typedef struct
 {
@@ -97,8 +99,8 @@ EFI_ACPI_5_1_CSRT_TABLE Csrt =
     sizeof (EFI_ACPI_DESCRIPTION_HEADER) + sizeof (RG_DMA),  // Length
     EFI_ACPI_5_1_CSRT_REVISION,     // Revision
     0x00,                           // Checksum calculated at runtime.
-    EFI_ACPI_OEM_ID,                // OEMID is a 6 bytes long field "BC2836"
-    EFI_ACPI_OEM_TABLE_ID,          // OEM table identification(8 bytes long) "RPI3EDK2"
+    EFI_ACPI_OEM_ID,                // OEMID is a 6 bytes long field
+    EFI_ACPI_OEM_TABLE_ID,          // OEM table identification (8 bytes long)
     EFI_ACPI_OEM_REVISION,          // OEM revision number.
     EFI_ACPI_CREATOR_ID,            // ASL compiler vendor ID.
     EFI_ACPI_CREATOR_REVISION       // ASL compiler revision number.
@@ -137,13 +139,13 @@ EFI_ACPI_5_1_CSRT_TABLE Csrt =
         sizeof (DMA_CONTROLLER_VENDOR_DATA),  // Controller vendor data here
         1,
         BCM2836_DMA0_BASE_ADDRESS,    // Base address for channels
-        RPI3_DMA_CHANNEL_COUNT * BCM2836_DMA_CHANNEL_LENGTH, // Base size = Number of channels x channel size
+        RPI_DMA_CHANNEL_COUNT * BCM2836_DMA_CHANNEL_LENGTH, // Base size = Number of channels x channel size
         BCM2836_DMA_CTRL_BASE_ADDRESS,// Base address for controller
         8,                            // Base size = two registers
-        RPI3_DMA_USED_CHANNEL_COUNT,
+        RPI_DMA_USED_CHANNEL_COUNT,
         0,                            // cannot use controller interrupt
         0,                            // Minimum Request Line
-        DMA_MAX_REQ_LINES - 1,          // Maximum Request Line
+        RPI_DMA_MAX_REQ_LINES - 1,    // Maximum Request Line
         FALSE,
       },
     },
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Dbg2.aslc b/Platform/RaspberryPi/RPi3/AcpiTables/Dbg2.aslc
index dcad8e205596..c3d5994f8e97 100644
--- a/Platform/RaspberryPi/RPi3/AcpiTables/Dbg2.aslc
+++ b/Platform/RaspberryPi/RPi3/AcpiTables/Dbg2.aslc
@@ -23,7 +23,7 @@
 #define RPI_DBG2_NUMBER_OF_GENERIC_ADDRESS_REGISTERS    1
 #define RPI_DBG2_NAMESPACESTRING_FIELD_SIZE             10
 
-#ifdef PL011_ENABLE
+#if (RPI_MODEL == 4)
 #define RPI_UART_INTERFACE_TYPE                         EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_ARM_PL011_UART
 #define RPI_UART_BASE_ADDRESS                           BCM2836_PL011_UART_BASE_ADDRESS
 #define RPI_UART_LENGTH                                 BCM2836_PL011_UART_LENGTH
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Dsdt.asl b/Platform/RaspberryPi/RPi3/AcpiTables/Dsdt.asl
index 1e17ec901042..c2775088b5a2 100644
--- a/Platform/RaspberryPi/RPi3/AcpiTables/Dsdt.asl
+++ b/Platform/RaspberryPi/RPi3/AcpiTables/Dsdt.asl
@@ -10,6 +10,7 @@
  *
  **/
 
+#include <BcmGenetDxe/Genet.h>
 #include <IndustryStandard/Bcm2836.h>
 #include <IndustryStandard/Bcm2836Gpio.h>
 #include <IndustryStandard/Bcm2836Gpu.h>
@@ -30,6 +31,9 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
   {
     include ("Sdhc.asl")
     include ("Pep.asl")
+#if (RPI_MODEL == 4)
+    include ("Xhci.asl")
+#endif
 
     Device (CPU0)
     {
@@ -284,6 +288,37 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
       }
     }
 
+#if (RPI_MODEL == 4)
+    Device (ETH0)
+    {
+      Name (_HID, "BCM6E4E")
+      Name (_CID, "BCM6E4E")
+      Name (_UID, 0x0)
+      Name (_CCA, 0x0)
+      Method (_STA)
+      {
+        Return (0xf)
+      }
+      Method (_CRS, 0x0, Serialized)
+      {
+        Name (RBUF, ResourceTemplate ()
+        {
+          // No need for MEMORY32SETBASE on Genet as we have a straight base address constant
+          MEMORY32FIXED (ReadWrite, GENET_BASE_ADDRESS, GENET_LENGTH, )
+          Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { GENET_INTERRUPT0, GENET_INTERRUPT1 }
+        })
+        Return (RBUF)
+      }
+      Name (_DSD, Package () {
+        ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
+        Package () {
+          Package () { "brcm,max-dma-burst-size", 0x08 },
+          Package () { "phy-mode", "rgmii-rxid" },
+        }
+      })
+    }
+#endif
+
     // Description: I2C
     Device (I2C1)
     {
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Gtdt.aslc b/Platform/RaspberryPi/RPi3/AcpiTables/Gtdt.aslc
index 0cd6be8cadaa..8453e487fb63 100644
--- a/Platform/RaspberryPi/RPi3/AcpiTables/Gtdt.aslc
+++ b/Platform/RaspberryPi/RPi3/AcpiTables/Gtdt.aslc
@@ -14,7 +14,6 @@
 
 #include "AcpiTables.h"
 
-#define RPI_SYSTEM_TIMER_BASE_ADDRESS   0x4000001C
 #define RPI_GTDT_GLOBAL_FLAGS           0
 #define RPI_GTDT_GTIMER_FLAGS           EFI_ACPI_5_1_GTDT_TIMER_FLAG_TIMER_INTERRUPT_POLARITY
 
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Madt.aslc b/Platform/RaspberryPi/RPi3/AcpiTables/Madt.aslc
index a42ddb8954df..4029cd191ab5 100644
--- a/Platform/RaspberryPi/RPi3/AcpiTables/Madt.aslc
+++ b/Platform/RaspberryPi/RPi3/AcpiTables/Madt.aslc
@@ -23,7 +23,9 @@
 typedef struct {
   EFI_ACPI_5_1_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER   Header;
   EFI_ACPI_5_1_GIC_STRUCTURE                            GicInterfaces[4];
-  // Do *NOT* add a GIC Distributor on the Pi 3 or Windows 10 won't boot!
+#if (RPI_MODEL != 3)
+  EFI_ACPI_5_1_GIC_DISTRIBUTOR_STRUCTURE                GicDistributor;
+#endif
 } PI_MULTIPLE_APIC_DESCRIPTION_TABLE;
 
 #pragma pack ()
@@ -42,6 +44,7 @@ PI_MULTIPLE_APIC_DESCRIPTION_TABLE Madt = {
     0, // Flags
   },
   {
+#if (RPI_MODEL == 3)
     EFI_ACPI_5_1_GICC_STRUCTURE_INIT(
         0, 0, GET_MPID(0, 0), EFI_ACPI_5_1_GIC_ENABLED, 0x09, 0x40000000, 0, 0, 0, 0),
     EFI_ACPI_5_1_GICC_STRUCTURE_INIT(
@@ -50,7 +53,24 @@ PI_MULTIPLE_APIC_DESCRIPTION_TABLE Madt = {
         2, 2, GET_MPID(0, 2), EFI_ACPI_5_1_GIC_ENABLED, 0x09, 0x40000000, 0, 0, 0, 0),
     EFI_ACPI_5_1_GICC_STRUCTURE_INIT(
         3, 3, GET_MPID(0, 3), EFI_ACPI_5_1_GIC_ENABLED, 0x09, 0x40000000, 0, 0, 0, 0),
+#elif (RPI_MODEL == 4)
+    EFI_ACPI_5_1_GICC_STRUCTURE_INIT(
+        0, 0, GET_MPID(0, 0), EFI_ACPI_5_1_GIC_ENABLED, 48, FixedPcdGet64 (PcdGicInterruptInterfaceBase),
+        0xFF846000, 0xFF844000, 0x19, 0),
+    EFI_ACPI_5_1_GICC_STRUCTURE_INIT(
+        1, 1, GET_MPID(0, 1), EFI_ACPI_5_1_GIC_ENABLED, 49, FixedPcdGet64 (PcdGicInterruptInterfaceBase),
+        0xFF846000, 0xFF844000, 0x19, 0),
+    EFI_ACPI_5_1_GICC_STRUCTURE_INIT(
+        2, 2, GET_MPID(0, 2), EFI_ACPI_5_1_GIC_ENABLED, 50, FixedPcdGet64 (PcdGicInterruptInterfaceBase),
+        0xFF846000, 0xFF844000, 0x19, 0),
+    EFI_ACPI_5_1_GICC_STRUCTURE_INIT(
+        3, 3, GET_MPID(0, 3), EFI_ACPI_5_1_GIC_ENABLED, 51, FixedPcdGet64 (PcdGicInterruptInterfaceBase),
+        0xFF846000, 0xFF844000, 0x19, 0),
+#endif
   },
+#if (RPI_MODEL != 3)
+  EFI_ACPI_5_0_GIC_DISTRIBUTOR_INIT(0, FixedPcdGet64 (PcdGicDistributorBase), 0)
+#endif
 };
 
 //
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Pep.asl b/Platform/RaspberryPi/RPi3/AcpiTables/Pep.asl
index 2ddb27bcdbb3..8a0a44e1c4c9 100644
--- a/Platform/RaspberryPi/RPi3/AcpiTables/Pep.asl
+++ b/Platform/RaspberryPi/RPi3/AcpiTables/Pep.asl
@@ -2,6 +2,7 @@
  *
  *  Platform Extension Plugin (PEP).
  *
+ *  Copyright (c) 2019, ARM Ltd. All rights reserved.
  *  Copyright (c) 2018, Andrey Warkentin <andrey.warkentin@gmail.com>
  *  Copyright (c) Microsoft Corporation. All rights reserved.
  *
@@ -12,9 +13,9 @@
 Device(PEPD)
 {
   //
-  // RPI3 PEP virtual device.
+  // PEP virtual device.
   //
-  Name (_HID, "BCM2854") // Note: since pep on rpi3 is virtual device,
+  Name (_HID, "BCM2854") // Note: Since PEP on RPi is a virtual device,
   Name (_CID, "BCM2854") // its device id needs to be generated by Microsoft
   Name (_UID, 0x0)
   Name (_CRS, ResourceTemplate ()
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Pep.c b/Platform/RaspberryPi/RPi3/AcpiTables/Pep.c
index 51db779d7976..f452580c703d 100644
--- a/Platform/RaspberryPi/RPi3/AcpiTables/Pep.c
+++ b/Platform/RaspberryPi/RPi3/AcpiTables/Pep.c
@@ -2,6 +2,7 @@
  *
  *  PEP device tables
  *
+ *  Copyright (c) 2019, ARM Ltd. All rights reserved.
  *  Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
  *  Copyright (c) Microsoft Corporation. All rights reserved.
  *
@@ -11,7 +12,7 @@
 
 #include "Pep.h"
 
-PEP_PROCESSOR_TABLE_PLAT RPI3Processors = {
+PEP_PROCESSOR_TABLE_PLAT RpiProcessors = {
   1, // Version
   1, // NumberProcessors
   {  // ProcessorInfo
@@ -29,7 +30,7 @@ PEP_PROCESSOR_TABLE_PLAT RPI3Processors = {
   }
 };
 
-PEP_COORDINATED_STATE_TABLE_PLAT RPI3CoordinatedStates = {
+PEP_COORDINATED_STATE_TABLE_PLAT RpiCoordinatedStates = {
   1, // Version
   1, // CoordinatedStateCount
   { // CordinatedStates[]
@@ -51,7 +52,7 @@ PEP_COORDINATED_STATE_TABLE_PLAT RPI3CoordinatedStates = {
   }
 };
 
-PEP_DEVICE_TABLE_PLAT RPI3Devices = {
+PEP_DEVICE_TABLE_PLAT RpiDevices = {
   1, // Version
   1, // NumberDevices
   { // DeviceInfo
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Pep.h b/Platform/RaspberryPi/RPi3/AcpiTables/Pep.h
index f5f04518dec6..30f6768f12a5 100644
--- a/Platform/RaspberryPi/RPi3/AcpiTables/Pep.h
+++ b/Platform/RaspberryPi/RPi3/AcpiTables/Pep.h
@@ -2,6 +2,7 @@
  *
  *  PEP device defines
  *
+ *  Copyright (c) 2019, ARM Ltd. All rights reserved.
  *  Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
  *  Copyright (c) Microsoft Corporation. All rights reserved.
  *
@@ -13,10 +14,10 @@
  * Note: Not everything is here. At least SOC_STATE_TYPE is missing.
  */
 
-#ifndef _RPI3PEP_H_INCLUDED_
-#define _RPI3PEP_H_INCLUDED_
+#ifndef _RPI_PEP_H_INCLUDED_
+#define _RPI_PEP_H_INCLUDED_
 
-#include <IndustryStandard/Acpi50.h>
+#include <IndustryStandard/Acpi.h>
 
 #define PEP_MAX_DEPENDENCIES_PER_STATE 16
 #define MAX_PROCESSOR_PATH_LENGTH 16
@@ -117,4 +118,4 @@ typedef struct _PEP_DEVICE_TABLE_PLAT {
   PEP_DEVICE_INFO_PLAT DeviceInfo[P_NUMBER_DEVICES];
 } PEP_DEVICE_TABLE_PLAT, *PPEP_DEVICE_TABLE_PLAT;
 
-#endif // _RPI3PEP_H_INCLUDED_
+#endif // _RPI_PEP_H_INCLUDED_
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Spcr.aslc b/Platform/RaspberryPi/RPi3/AcpiTables/Spcr.aslc
index cb17fbe0ff2f..bec4ad660ec9 100644
--- a/Platform/RaspberryPi/RPi3/AcpiTables/Spcr.aslc
+++ b/Platform/RaspberryPi/RPi3/AcpiTables/Spcr.aslc
@@ -18,7 +18,8 @@
 
 #define RPI_UART_FLOW_CONTROL_NONE           0
 
-#ifdef PL011_ENABLE
+// Prefer PL011 serial output on the Raspberry Pi 4
+#if (RPI_MODEL == 4)
 #define RPI_UART_INTERFACE_TYPE              EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_INTERFACE_TYPE_ARM_PL011_UART
 #define RPI_UART_BASE_ADDRESS                BCM2836_PL011_UART_BASE_ADDRESS
 #define RPI_UART_INTERRUPT                   BCM2836_PL011_UART_INTERRUPT
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Uart.asl b/Platform/RaspberryPi/RPi3/AcpiTables/Uart.asl
index edd8bcc3b376..c466247bb33b 100644
--- a/Platform/RaspberryPi/RPi3/AcpiTables/Uart.asl
+++ b/Platform/RaspberryPi/RPi3/AcpiTables/Uart.asl
@@ -140,7 +140,7 @@ Device(BTH0)
                        //   no flow control.
         16,            // ReceiveBufferSize
         16,            // TransmitBufferSize
-#ifdef PL011_ENABLE
+#if (RPI_MODEL == 4)
         "\\_SB.URTM",  // ResourceSource:
 #else
         "\\_SB.URT0",  // ResourceSource:
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Xhci.asl b/Platform/RaspberryPi/RPi3/AcpiTables/Xhci.asl
new file mode 100644
index 000000000000..0083d1992936
--- /dev/null
+++ b/Platform/RaspberryPi/RPi3/AcpiTables/Xhci.asl
@@ -0,0 +1,136 @@
+/** @file
+ *
+ *  Copyright (c) 2019 Linaro, Limited. All rights reserved.
+ *  Copyright (c) 2019 Andrei Warkentin <andrey.warkentin@gmail.com>
+ *
+ *  SPDX-License-Identifier: BSD-2-Clause-Patent
+ *
+ **/
+
+#include <IndustryStandard/Bcm2711.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_WINDOW)
+#define SANITIZED_PCIE_REG_BASE         REMOVE_PARENTHESES(PCIE_REG_BASE)
+
+/*
+ * According to UEFI boot log for the VLI device on Pi 4.
+ */
+#define XHCI_REG_LENGTH                 0x1000
+
+Device (SCB0) {
+    Name (_HID, "ACPI0004")
+    Name (_UID, 0x0)
+    Name (_CCA, 0x0)
+
+    Method (_CRS, 0, Serialized) { // _CRS: Current Resource Settings
+        /*
+         * Container devices with _DMA must have _CRS, meaning SCB0
+         * to provide all resources that XHC0 consumes (except
+         * interrupts).
+         */
+        Name (RBUF, ResourceTemplate () {
+            QWordMemory (ResourceProducer,
+                ,
+                MinFixed,
+                MaxFixed,
+                NonCacheable,
+                ReadWrite,
+                0x0,
+                SANITIZED_PCIE_CPU_MMIO_WINDOW, // MIN
+                SANITIZED_PCIE_CPU_MMIO_WINDOW, // MAX
+                0x0,
+                0x1,                            // LEN
+                ,
+                ,
+                MMIO
+                )
+        })
+        CreateQwordField (RBUF, MMIO._MAX, MMBE)
+        CreateQwordField (RBUF, MMIO._LEN, MMLE)
+        Add (MMBE, XHCI_REG_LENGTH - 1, MMBE)
+        Add (MMLE, XHCI_REG_LENGTH - 1, MMLE)
+        Return (RBUF)
+    }
+
+    Name (_DMA, ResourceTemplate() {
+        /*
+         * XHC0 is limited to DMA to first 3GB. Note this
+         * only applies to PCIe, not GENET or other devices
+         * next to the A72.
+         */
+        QWordMemory (ResourceConsumer,
+            ,
+            MinFixed,
+            MaxFixed,
+            NonCacheable,
+            ReadWrite,
+            0x0,
+            0x0,        // MIN
+            0xbfffffff, // MAX
+            0x0,        // TRA
+            0xc0000000, // LEN
+            ,
+            ,
+            )
+    })
+
+    Device (XHC0)
+    {
+        Name (_HID, "PNP0D10")      // _HID: Hardware ID
+        Name (_UID, 0x0)            // _UID: Unique ID
+        Name (_CCA, 0x0)            // _CCA: Cache Coherency Attribute
+
+        Method (_CRS, 0, Serialized) { // _CRS: Current Resource Settings
+            Name (RBUF, ResourceTemplate () {
+                QWordMemory (ResourceConsumer,
+                    ,
+                    MinFixed,
+                    MaxFixed,
+                    NonCacheable,
+                    ReadWrite,
+                    0x0,
+                    SANITIZED_PCIE_CPU_MMIO_WINDOW, // MIN
+                    SANITIZED_PCIE_CPU_MMIO_WINDOW, // MAX
+                    0x0,
+                    0x1,                            // LEN
+                    ,
+                    ,
+                    MMIO
+                    )
+                Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, ) {
+                    175
+                }
+            })
+            CreateQwordField (RBUF, MMIO._MAX, MMBE)
+            CreateQwordField (RBUF, MMIO._LEN, MMLE)
+            Add (MMBE, XHCI_REG_LENGTH - 1, MMBE)
+            Add (MMLE, XHCI_REG_LENGTH - 1, MMLE)
+            Return (RBUF)
+        }
+
+        Method (_INI, 0, Serialized) {
+            OperationRegion (PCFG, SystemMemory, SANITIZED_PCIE_REG_BASE + PCIE_EXT_CFG_DATA, 0x1000)
+            Field (PCFG, AnyAcc, NoLock, Preserve) {
+                Offset (0),
+                VNID, 16, // Vendor ID
+                DVID, 16, // Device ID
+                CMND, 16, // Command register
+                STAT, 16, // Status register
+            }
+
+            // Set command register to:
+            // 1) decode MMIO (set bit 1)
+            // 2) enable DMA (set bit 2)
+            // 3) enable interrupts (clear bit 10)
+            Debug = "xHCI enable"
+            Store (0x6, CMND)
+        }
+    }
+}
diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc b/Platform/RaspberryPi/RPi3/RPi3.dsc
index 94d1e5b1c45b..10f02737dce1 100644
--- a/Platform/RaspberryPi/RPi3/RPi3.dsc
+++ b/Platform/RaspberryPi/RPi3/RPi3.dsc
@@ -218,6 +218,10 @@ [LibraryClasses.common.DXE_RUNTIME_DRIVER]
 ###################################################################################################
 
 [BuildOptions]
+  GCC:*_*_*_CC_FLAGS          = -DRPI_MODEL=3
+  GCC:*_*_*_ASLPP_FLAGS       = -DRPI_MODEL=3
+  GCC:*_*_*_ASLCC_FLAGS       = -DRPI_MODEL=3
+  GCC:*_*_*_VFRPP_FLAGS       = -DRPI_MODEL=3
   GCC:*_*_AARCH64_DLINK_FLAGS = -Wl,--fix-cortex-a53-843419
   GCC:RELEASE_*_*_CC_FLAGS    = -DMDEPKG_NDEBUG -DNDEBUG
 
-- 
2.21.0.windows.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [edk2-platforms][PATCH 15/15] Platform/RPi: Factorize ACPI tables
  2020-02-28 10:38 [edk2-platforms][PATCH 00/15] Platform/RPi: Clean up and factorize ACPI Pete Batard
                   ` (13 preceding siblings ...)
  2020-02-28 10:38 ` [edk2-platforms][PATCH 14/15] Platform/RPi3: Merge ACPI code from RPi4 Pete Batard
@ 2020-02-28 10:38 ` Pete Batard
  2020-02-28 12:17 ` [edk2-platforms][PATCH 00/15] Platform/RPi: Clean up and factorize ACPI Ard Biesheuvel
  15 siblings, 0 replies; 23+ messages in thread
From: Pete Batard @ 2020-02-28 10:38 UTC (permalink / raw)
  To: devel; +Cc: ard.biesheuvel, leif, philmd

With the ACPI source for the Pi 3 and Pi 4 being identical, we can
finally factorize it.

Signed-off-by: Pete Batard <pete@akeo.ie>
---
 Platform/RaspberryPi/{RPi3 => }/AcpiTables/AcpiTables.h   |   0
 Platform/RaspberryPi/{RPi3 => }/AcpiTables/AcpiTables.inf |   0
 Platform/RaspberryPi/{RPi3 => }/AcpiTables/Csrt.aslc      |   0
 Platform/RaspberryPi/{RPi3 => }/AcpiTables/Dbg2.aslc      |   0
 Platform/RaspberryPi/{RPi3 => }/AcpiTables/Dsdt.asl       |   0
 Platform/RaspberryPi/{RPi3 => }/AcpiTables/Fadt.aslc      |   0
 Platform/RaspberryPi/{RPi3 => }/AcpiTables/Gtdt.aslc      |   0
 Platform/RaspberryPi/{RPi3 => }/AcpiTables/Madt.aslc      |   0
 Platform/RaspberryPi/{RPi3 => }/AcpiTables/Pep.asl        |   0
 Platform/RaspberryPi/{RPi3 => }/AcpiTables/Pep.c          |   0
 Platform/RaspberryPi/{RPi3 => }/AcpiTables/Pep.h          |   0
 Platform/RaspberryPi/{RPi3 => }/AcpiTables/Rhpx.asl       |   0
 Platform/RaspberryPi/{RPi3 => }/AcpiTables/Sdhc.asl       |   0
 Platform/RaspberryPi/{RPi3 => }/AcpiTables/Spcr.aslc      |   0
 Platform/RaspberryPi/{RPi3 => }/AcpiTables/Uart.asl       |   0
 Platform/RaspberryPi/{RPi3 => }/AcpiTables/Xhci.asl       |   0
 Platform/RaspberryPi/RPi3/RPi3.dsc                        |   2 +-
 Platform/RaspberryPi/RPi3/RPi3.fdf                        |   2 +-
 Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.h         | 164 ------
 Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf       |  58 --
 Platform/RaspberryPi/RPi4/AcpiTables/Csrt.aslc            | 330 ------------
 Platform/RaspberryPi/RPi4/AcpiTables/Dbg2.aslc            | 105 ----
 Platform/RaspberryPi/RPi4/AcpiTables/Dsdt.asl             | 569 --------------------
 Platform/RaspberryPi/RPi4/AcpiTables/Fadt.aslc            |  89 ---
 Platform/RaspberryPi/RPi4/AcpiTables/Gtdt.aslc            |  55 --
 Platform/RaspberryPi/RPi4/AcpiTables/Madt.aslc            |  80 ---
 Platform/RaspberryPi/RPi4/AcpiTables/Pep.asl              |  90 ----
 Platform/RaspberryPi/RPi4/AcpiTables/Pep.c                |  79 ---
 Platform/RaspberryPi/RPi4/AcpiTables/Pep.h                | 121 -----
 Platform/RaspberryPi/RPi4/AcpiTables/Rhpx.asl             | 195 -------
 Platform/RaspberryPi/RPi4/AcpiTables/Sdhc.asl             | 107 ----
 Platform/RaspberryPi/RPi4/AcpiTables/Spcr.aslc            |  97 ----
 Platform/RaspberryPi/RPi4/AcpiTables/Uart.asl             | 163 ------
 Platform/RaspberryPi/RPi4/AcpiTables/Xhci.asl             | 136 -----
 Platform/RaspberryPi/RPi4/RPi4.dsc                        |   2 +-
 Platform/RaspberryPi/RPi4/RPi4.fdf                        |   2 +-
 36 files changed, 4 insertions(+), 2442 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.h b/Platform/RaspberryPi/AcpiTables/AcpiTables.h
similarity index 100%
rename from Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.h
rename to Platform/RaspberryPi/AcpiTables/AcpiTables.h
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.inf b/Platform/RaspberryPi/AcpiTables/AcpiTables.inf
similarity index 100%
rename from Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.inf
rename to Platform/RaspberryPi/AcpiTables/AcpiTables.inf
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Csrt.aslc b/Platform/RaspberryPi/AcpiTables/Csrt.aslc
similarity index 100%
rename from Platform/RaspberryPi/RPi3/AcpiTables/Csrt.aslc
rename to Platform/RaspberryPi/AcpiTables/Csrt.aslc
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Dbg2.aslc b/Platform/RaspberryPi/AcpiTables/Dbg2.aslc
similarity index 100%
rename from Platform/RaspberryPi/RPi3/AcpiTables/Dbg2.aslc
rename to Platform/RaspberryPi/AcpiTables/Dbg2.aslc
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Dsdt.asl b/Platform/RaspberryPi/AcpiTables/Dsdt.asl
similarity index 100%
rename from Platform/RaspberryPi/RPi3/AcpiTables/Dsdt.asl
rename to Platform/RaspberryPi/AcpiTables/Dsdt.asl
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Fadt.aslc b/Platform/RaspberryPi/AcpiTables/Fadt.aslc
similarity index 100%
rename from Platform/RaspberryPi/RPi3/AcpiTables/Fadt.aslc
rename to Platform/RaspberryPi/AcpiTables/Fadt.aslc
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Gtdt.aslc b/Platform/RaspberryPi/AcpiTables/Gtdt.aslc
similarity index 100%
rename from Platform/RaspberryPi/RPi3/AcpiTables/Gtdt.aslc
rename to Platform/RaspberryPi/AcpiTables/Gtdt.aslc
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Madt.aslc b/Platform/RaspberryPi/AcpiTables/Madt.aslc
similarity index 100%
rename from Platform/RaspberryPi/RPi3/AcpiTables/Madt.aslc
rename to Platform/RaspberryPi/AcpiTables/Madt.aslc
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Pep.asl b/Platform/RaspberryPi/AcpiTables/Pep.asl
similarity index 100%
rename from Platform/RaspberryPi/RPi3/AcpiTables/Pep.asl
rename to Platform/RaspberryPi/AcpiTables/Pep.asl
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Pep.c b/Platform/RaspberryPi/AcpiTables/Pep.c
similarity index 100%
rename from Platform/RaspberryPi/RPi3/AcpiTables/Pep.c
rename to Platform/RaspberryPi/AcpiTables/Pep.c
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Pep.h b/Platform/RaspberryPi/AcpiTables/Pep.h
similarity index 100%
rename from Platform/RaspberryPi/RPi3/AcpiTables/Pep.h
rename to Platform/RaspberryPi/AcpiTables/Pep.h
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Rhpx.asl b/Platform/RaspberryPi/AcpiTables/Rhpx.asl
similarity index 100%
rename from Platform/RaspberryPi/RPi3/AcpiTables/Rhpx.asl
rename to Platform/RaspberryPi/AcpiTables/Rhpx.asl
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Sdhc.asl b/Platform/RaspberryPi/AcpiTables/Sdhc.asl
similarity index 100%
rename from Platform/RaspberryPi/RPi3/AcpiTables/Sdhc.asl
rename to Platform/RaspberryPi/AcpiTables/Sdhc.asl
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Spcr.aslc b/Platform/RaspberryPi/AcpiTables/Spcr.aslc
similarity index 100%
rename from Platform/RaspberryPi/RPi3/AcpiTables/Spcr.aslc
rename to Platform/RaspberryPi/AcpiTables/Spcr.aslc
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Uart.asl b/Platform/RaspberryPi/AcpiTables/Uart.asl
similarity index 100%
rename from Platform/RaspberryPi/RPi3/AcpiTables/Uart.asl
rename to Platform/RaspberryPi/AcpiTables/Uart.asl
diff --git a/Platform/RaspberryPi/RPi3/AcpiTables/Xhci.asl b/Platform/RaspberryPi/AcpiTables/Xhci.asl
similarity index 100%
rename from Platform/RaspberryPi/RPi3/AcpiTables/Xhci.asl
rename to Platform/RaspberryPi/AcpiTables/Xhci.asl
diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc b/Platform/RaspberryPi/RPi3/RPi3.dsc
index 10f02737dce1..304bc3dfeadf 100644
--- a/Platform/RaspberryPi/RPi3/RPi3.dsc
+++ b/Platform/RaspberryPi/RPi3/RPi3.dsc
@@ -550,7 +550,7 @@ [Components.common]
   MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
   MdeModulePkg/Universal/Acpi/AcpiPlatformDxe/AcpiPlatformDxe.inf
   MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf
-  Platform/RaspberryPi/$(PLATFORM_NAME)/AcpiTables/AcpiTables.inf
+  Platform/RaspberryPi/AcpiTables/AcpiTables.inf
 
   #
   # SMBIOS Support
diff --git a/Platform/RaspberryPi/RPi3/RPi3.fdf b/Platform/RaspberryPi/RPi3/RPi3.fdf
index 31730865601f..ec3742c83729 100644
--- a/Platform/RaspberryPi/RPi3/RPi3.fdf
+++ b/Platform/RaspberryPi/RPi3/RPi3.fdf
@@ -242,7 +242,7 @@ [FV.FvMain]
   INF MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
   INF MdeModulePkg/Universal/Acpi/AcpiPlatformDxe/AcpiPlatformDxe.inf
   INF MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf
-  INF RuleOverride = ACPITABLE Platform/RaspberryPi/$(PLATFORM_NAME)/AcpiTables/AcpiTables.inf
+  INF RuleOverride = ACPITABLE Platform/RaspberryPi/AcpiTables/AcpiTables.inf
 
   #
   # SMBIOS Support
diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.h b/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.h
deleted file mode 100644
index 0b8a8494450c..000000000000
--- a/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.h
+++ /dev/null
@@ -1,164 +0,0 @@
-/** @file
- *
- *  RPi defines for constructing ACPI tables
- *
- *  Copyright (c) 2020, Pete Batard <pete@akeo.ie>
- *  Copyright (c) 2019, ARM Ltd. All rights reserved.
- *  Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
- *  Copyright (c) Microsoft Corporation. All rights reserved.
- *
- *  SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#ifndef __ACPITABLES_H__
-#define __ACPITABLES_H__
-
-#include <IndustryStandard/Acpi.h>
-
-// The ASL compiler can't perform arithmetic on MEMORY32SETBASE ()
-// parameters so you can't pass a constant like BASE + OFFSET (the
-// compiler just silently sets it to zero). So we need a macro that
-// can perform arithmetic base address update with an offset.
-#define MEMORY32SETBASE(BufName, MemName, VarName, Offset)       \
-    CreateDwordField (^BufName, ^MemName._BAS, VarName)          \
-    Add (BCM2836_SOC_REGISTERS, Offset, VarName)
-
-#if (RPI_MODEL == 3)
-#define EFI_ACPI_OEM_ID                       {'B','C','2','8','3','6'}
-#else
-#define EFI_ACPI_OEM_ID                       {'M','C','R','S','F','T'}
-#endif
-#define EFI_ACPI_OEM_TABLE_ID                 SIGNATURE_64 ('R','P','I','_','E','D','K','2')
-#define EFI_ACPI_OEM_REVISION                 0x00000100
-#define EFI_ACPI_CREATOR_ID                   SIGNATURE_32 ('E','D','K','2')
-#define EFI_ACPI_CREATOR_REVISION             0x00000100
-
-#define EFI_ACPI_VENDOR_ID                    SIGNATURE_32 ('M','S','F','T')
-
-// A macro to initialise the common header part of EFI ACPI tables as defined by
-// EFI_ACPI_DESCRIPTION_HEADER structure.
-#define ACPI_HEADER(Signature, Type, Revision) {                  \
-    Signature,                      /* UINT32  Signature */       \
-    sizeof (Type),                  /* UINT32  Length */          \
-    Revision,                       /* UINT8   Revision */        \
-    0,                              /* UINT8   Checksum */        \
-    EFI_ACPI_OEM_ID,                /* UINT8   OemId[6] */        \
-    EFI_ACPI_OEM_TABLE_ID,          /* UINT64  OemTableId */      \
-    EFI_ACPI_OEM_REVISION,          /* UINT32  OemRevision */     \
-    EFI_ACPI_CREATOR_ID,            /* UINT32  CreatorId */       \
-    EFI_ACPI_CREATOR_REVISION       /* UINT32  CreatorRevision */ \
-  }
-
-#define EFI_ACPI_CSRT_REVISION                0x00000005
-#define EFI_ACPI_CSRT_DEVICE_ID_DMA           0x00000009 // Fixed id
-#define EFI_ACPI_CSRT_RESOURCE_ID_IN_DMA_GRP  0x0 // Count up from 0
-
-#define RPI_DMA_CHANNEL_COUNT                 10 // All 10 DMA channels are listed, including the reserved ones
-#define RPI_DMA_USED_CHANNEL_COUNT            5  // Use 5 DMA channels
-
-#if (RPI_MODEL == 3)
-#define RPI_SYSTEM_TIMER_BASE_ADDRESS         0x4000001C
-#elif (RPI_MODEL == 4)
-#define RPI_SYSTEM_TIMER_BASE_ADDRESS         0xFF80001C
-#endif
-
-#define EFI_ACPI_5_1_CSRT_REVISION            0x00000000
-
-typedef enum
-{
-  EFI_ACPI_CSRT_RESOURCE_TYPE_RESERVED,           // 0
-  EFI_ACPI_CSRT_RESOURCE_TYPE_INTERRUPT,          // 1
-  EFI_ACPI_CSRT_RESOURCE_TYPE_TIMER,              // 2
-  EFI_ACPI_CSRT_RESOURCE_TYPE_DMA,                // 3
-  EFI_ACPI_CSRT_RESOURCE_TYPE_CACHE,              // 4
-}
-CSRT_RESOURCE_TYPE;
-
-typedef enum
-{
-  EFI_ACPI_CSRT_RESOURCE_SUBTYPE_DMA_CHANNEL,     // 0
-  EFI_ACPI_CSRT_RESOURCE_SUBTYPE_DMA_CONTROLLER   // 1
-}
-CSRT_DMA_SUBTYPE;
-
-//------------------------------------------------------------------------
-// CSRT Resource Group header 24 bytes long
-//------------------------------------------------------------------------
-typedef struct
-{
-  UINT32 Length;                  // Length
-  UINT32 VendorID;                // 4 bytes
-  UINT32 SubVendorId;             // 4 bytes
-  UINT16 DeviceId;                // 2 bytes
-  UINT16 SubdeviceId;             // 2 bytes
-  UINT16 Revision;                // 2 bytes
-  UINT16 Reserved;                // 2 bytes
-  UINT32 SharedInfoLength;        // 4 bytes
-} EFI_ACPI_5_1_CSRT_RESOURCE_GROUP_HEADER;
-
-//------------------------------------------------------------------------
-// CSRT Resource Descriptor 12 bytes total
-//------------------------------------------------------------------------
-typedef struct
-{
-  UINT32 Length;                  // 4 bytes
-  UINT16 ResourceType;            // 2 bytes
-  UINT16 ResourceSubType;         // 2 bytes
-  UINT32 UID;                     // 4 bytes
-} EFI_ACPI_5_1_CSRT_RESOURCE_DESCRIPTOR_HEADER;
-
-//------------------------------------------------------------------------
-// Interrupts. These are specific to each platform
-//------------------------------------------------------------------------
-#if (RPI_MODEL == 3)
-#define BCM2836_V3D_BUS_INTERRUPT               0x2A
-#define BCM2836_DMA_INTERRUPT                   0x3B
-#define BCM2836_SPI1_INTERRUPT                  0x3D
-#define BCM2836_SPI2_INTERRUPT                  0x3D
-#define BCM2836_HVS_INTERRUPT                   0x41
-#define BCM2836_HDMI0_INTERRUPT                 0x48
-#define BCM2836_HDMI1_INTERRUPT                 0x49
-#define BCM2836_PV2_INTERRUPT                   0x4A
-#define BCM2836_PV0_INTERRUPT                   0x4D
-#define BCM2836_PV1_INTERRUPT                   0x4E
-#define BCM2836_MBOX_INTERRUPT                  0x61
-#define BCM2836_VCHIQ_INTERRUPT                 0x62
-#define BCM2386_GPIO_INTERRUPT0                 0x51
-#define BCM2386_GPIO_INTERRUPT1                 0x53
-#define BCM2836_I2C1_INTERRUPT                  0x55
-#define BCM2836_I2C2_INTERRUPT                  0x55
-#define BCM2836_SPI0_INTERRUPT                  0x56
-#define BCM2836_USB_INTERRUPT                   0x29
-#define BCM2836_SDHOST_INTERRUPT                0x58
-#define BCM2836_MMCHS1_INTERRUPT                0x5E
-#define BCM2836_MINI_UART_INTERRUPT             0x3D
-#define BCM2836_PL011_UART_INTERRUPT            0x59
-#elif (RPI_MODEL == 4)
-#define BCM2836_V3D_BUS_INTERRUPT               0x2A
-#define BCM2836_DMA_INTERRUPT                   0x3B
-#define BCM2836_SPI1_INTERRUPT                  0x3D
-#define BCM2836_SPI2_INTERRUPT                  0x3D
-#define BCM2836_HVS_INTERRUPT                   0x41
-#define BCM2836_HDMI0_INTERRUPT                 0x48
-#define BCM2836_HDMI1_INTERRUPT                 0x49
-#define BCM2836_PV2_INTERRUPT                   0x4A
-#define BCM2836_PV0_INTERRUPT                   0x4D
-#define BCM2836_PV1_INTERRUPT                   0x4E
-#define BCM2836_MBOX_INTERRUPT                  0x61
-#define BCM2836_VCHIQ_INTERRUPT                 0x62
-#define BCM2386_GPIO_INTERRUPT0                 0x51
-#define BCM2386_GPIO_INTERRUPT1                 0x53
-#define BCM2836_I2C1_INTERRUPT                  0x55
-#define BCM2836_I2C2_INTERRUPT                  0x55
-#define BCM2836_SPI0_INTERRUPT                  0x56
-#define BCM2836_USB_INTERRUPT                   0x69
-#define BCM2836_SDHOST_INTERRUPT                0x98
-#define BCM2836_MMCHS1_INTERRUPT                0x9E
-#define BCM2836_MINI_UART_INTERRUPT             0x7D
-#define BCM2836_PL011_UART_INTERRUPT            0x99
-#define GENET_INTERRUPT0                        0xBD
-#define GENET_INTERRUPT1                        0xBE
-#endif
-
-#endif // __ACPITABLES_H__
diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf b/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf
deleted file mode 100644
index c95d75ed01bb..000000000000
--- a/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf
+++ /dev/null
@@ -1,58 +0,0 @@
-#/** @file
-#
-#  ACPI table data and ASL sources required to boot the platform.
-#
-#  Copyright (c) 2019, ARM Limited. All rights reserved.
-#  Copyright (c) 2017, Andrey Warkentin <andrey.warkentin@gmail.com>
-#  Copyright (c) Microsoft Corporation. All rights reserved.
-#
-#  SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-#**/
-
-[Defines]
-  INF_VERSION                    = 0x0001001A
-  BASE_NAME                      = AcpiTables
-  FILE_GUID                      = 7E374E25-8E01-4FEE-87F2-390C23C606CD
-  MODULE_TYPE                    = USER_DEFINED
-  VERSION_STRING                 = 1.0
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-#  VALID_ARCHITECTURES           = AARCH64
-#
-
-[Sources]
-  AcpiTables.h
-  Madt.aslc
-  Fadt.aslc
-  Dbg2.aslc
-  Gtdt.aslc
-  Dsdt.asl
-  Csrt.aslc
-  Spcr.aslc
-
-[Packages]
-  ArmPkg/ArmPkg.dec
-  ArmPlatformPkg/ArmPlatformPkg.dec
-  EmbeddedPkg/EmbeddedPkg.dec
-  MdeModulePkg/MdeModulePkg.dec
-  MdePkg/MdePkg.dec
-  Silicon/Broadcom/Bcm27xx/Bcm27xx.dec
-  Silicon/Broadcom/Bcm283x/Bcm283x.dec
-  Silicon/Broadcom/Drivers/Net/BcmNet.dec
-
-[FixedPcd]
-  gArmTokenSpaceGuid.PcdArmArchTimerIntrNum
-  gArmTokenSpaceGuid.PcdArmArchTimerHypIntrNum
-  gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum
-  gArmTokenSpaceGuid.PcdArmArchTimerVirtIntrNum
-  gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase
-  gArmTokenSpaceGuid.PcdGicDistributorBase
-  gBcm27xxTokenSpaceGuid.PcdBcm27xxPciCpuMmioAdr
-  gBcm27xxTokenSpaceGuid.PcdBcm27xxPciRegBase
-  gBcm283xTokenSpaceGuid.PcdBcm283xRegistersAddress
-  gBcmNetTokenSpaceGuid.PcdBcmGenetRegistersAddress
-  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate
-  gEmbeddedTokenSpaceGuid.PcdInterruptBaseAddress
diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Csrt.aslc b/Platform/RaspberryPi/RPi4/AcpiTables/Csrt.aslc
deleted file mode 100644
index 03d888fffb8b..000000000000
--- a/Platform/RaspberryPi/RPi4/AcpiTables/Csrt.aslc
+++ /dev/null
@@ -1,330 +0,0 @@
-/** @file
- *
- *  Core System Resource Table (CSRT)
- *
- *  Copyright (c) 2019, ARM Ltd. All rights reserved.
- *  Copyright (c) Microsoft Corporation. All rights reserved.
- *
- *  SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include <IndustryStandard/Acpi.h>
-#include <IndustryStandard/Bcm2836.h>
-
-#include "AcpiTables.h"
-
-#define RPI_DMA_MAX_REQ_LINES 32
-
-#pragma pack (push, 1)
-
-//------------------------------------------------------------------------
-// DMA Controller Vendor Data
-//------------------------------------------------------------------------
-typedef struct
-{
-  UINT32 Length;
-  UINT32 Type;
-  UINT64 ChannelsBaseAddress;
-  UINT32 ChannelsBaseSize;
-  UINT64 ControllerBaseAddress;
-  UINT32 ControllerBaseSize;
-  UINT32 ChannelCount;
-  UINT32 ControllerInterrupt;
-  UINT32 MinimumRequestLine;
-  UINT32 MaximumRequestLine;
-  BOOLEAN CacheCoherent;
-} DMA_CONTROLLER_VENDOR_DATA;
-
-//------------------------------------------------------------------------
-// DMA Controller
-//------------------------------------------------------------------------
-typedef struct
-{
-  EFI_ACPI_5_1_CSRT_RESOURCE_DESCRIPTOR_HEADER DmaControllerHeader;
-  DMA_CONTROLLER_VENDOR_DATA ControllerVendorData;
-} RD_DMA_CONTROLLER;
-
-//------------------------------------------------------------------------
-// DMA Channel Vendor Data
-//------------------------------------------------------------------------
-typedef struct
-{
-  UINT32 ChannelNumber;
-  UINT32 ChannelInterrupt;
-  UINT16 IsReservedChannel;
-  UINT16 NoSrcNoDestAddrIncr;
-} DMA_CHANNEL_VENDOR_DATA;
-
-//------------------------------------------------------------------------
-// DMA Channel
-//------------------------------------------------------------------------
-typedef struct
-{
-  EFI_ACPI_5_1_CSRT_RESOURCE_DESCRIPTOR_HEADER DmaChannelHeader;
-  DMA_CHANNEL_VENDOR_DATA ChannelVendorData;
-} RD_DMA_CHANNEL;
-
-//------------------------------------------------------------------------
-// DMA Resource Group
-//------------------------------------------------------------------------
-
-typedef struct
-{
-  EFI_ACPI_5_1_CSRT_RESOURCE_GROUP_HEADER ResGroupHeader;
-  RD_DMA_CONTROLLER DmaController;
-  RD_DMA_CHANNEL DmaChannels[RPI_DMA_CHANNEL_COUNT];
-} RG_DMA;
-
-//----------------------------------------------------------------------------
-// CSRT table structure - current revision only includes DMA
-//----------------------------------------------------------------------------
-typedef struct
-{
-// Standard ACPI Header
-  EFI_ACPI_DESCRIPTION_HEADER CsrtHeader;
-
-// DMA Resource Group
-  RG_DMA DmaResourceGroup;
-
-} EFI_ACPI_5_1_CSRT_TABLE;
-
-EFI_ACPI_5_1_CSRT_TABLE Csrt =
-{
-  //------------------------------------------------------------------------
-  // ACPI Table Header
-  //------------------------------------------------------------------------
-  {
-    EFI_ACPI_5_1_CORE_SYSTEM_RESOURCE_TABLE_SIGNATURE,       // Signature "CSRT"
-    sizeof (EFI_ACPI_DESCRIPTION_HEADER) + sizeof (RG_DMA),  // Length
-    EFI_ACPI_5_1_CSRT_REVISION,     // Revision
-    0x00,                           // Checksum calculated at runtime.
-    EFI_ACPI_OEM_ID,                // OEMID is a 6 bytes long field
-    EFI_ACPI_OEM_TABLE_ID,          // OEM table identification (8 bytes long)
-    EFI_ACPI_OEM_REVISION,          // OEM revision number.
-    EFI_ACPI_CREATOR_ID,            // ASL compiler vendor ID.
-    EFI_ACPI_CREATOR_REVISION       // ASL compiler revision number.
-  },
-
-  //------------------------------------------------------------------------
-  // DMA Resource Group
-  //------------------------------------------------------------------------
-  {
-
-    //------------------------------------------------------------------------
-    // DMA Resource Group Header
-    //------------------------------------------------------------------------
-    {
-      sizeof (RG_DMA),                // Resource Group Length
-      EFI_ACPI_VENDOR_ID,             // VendorId
-      0,                              // SubvendorId
-      EFI_ACPI_CSRT_DEVICE_ID_DMA,    // DeviceId 9
-      0,                              // SubdeviceId
-      0,                              // Revision
-      0,                              // Reserved
-      0                               // SharedInfoLength
-    },
-
-    //-------------------------------------------------------------------------------
-    // Resource Descriptor - DMA Controller
-    //-------------------------------------------------------------------------------
-    {
-      {
-        sizeof (RD_DMA_CONTROLLER),                    // Length of this Resource Descriptor
-        EFI_ACPI_CSRT_RESOURCE_TYPE_DMA,               // Type for this resource 3=DMA
-        EFI_ACPI_CSRT_RESOURCE_SUBTYPE_DMA_CONTROLLER, // Subtype for this resource 1=DMA Controller
-        EFI_ACPI_CSRT_RESOURCE_ID_IN_DMA_GRP + 0,        // ResourceId - 1st DMA controller
-      },
-      {
-        sizeof (DMA_CONTROLLER_VENDOR_DATA),  // Controller vendor data here
-        1,
-        BCM2836_DMA0_BASE_ADDRESS,    // Base address for channels
-        RPI_DMA_CHANNEL_COUNT * BCM2836_DMA_CHANNEL_LENGTH, // Base size = Number of channels x channel size
-        BCM2836_DMA_CTRL_BASE_ADDRESS,// Base address for controller
-        8,                            // Base size = two registers
-        RPI_DMA_USED_CHANNEL_COUNT,
-        0,                            // cannot use controller interrupt
-        0,                            // Minimum Request Line
-        RPI_DMA_MAX_REQ_LINES - 1,    // Maximum Request Line
-        FALSE,
-      },
-    },
-
-    //------------------------------------------------------------------------
-    // Resource Descriptor(s) - DMA Channels 0 to n-1
-    //------------------------------------------------------------------------
-    {
-
-      // Channel 0
-      {
-        {
-          sizeof (RD_DMA_CHANNEL),                    // Length of this Resource Descriptor
-          EFI_ACPI_CSRT_RESOURCE_TYPE_DMA,            // Type for this resource 3=DMA
-          EFI_ACPI_CSRT_RESOURCE_SUBTYPE_DMA_CHANNEL, // Subtype for this resource 0=DMA Channel
-          EFI_ACPI_CSRT_RESOURCE_ID_IN_DMA_GRP + 1,     // ResourceId
-        },
-        {
-          0,        // Channel vendor data here
-          0x30,     // 16+32 dma_int[0]
-          0,
-          0
-        },
-      },
-
-      // Channel 1 reserved
-      {
-        {
-          sizeof (RD_DMA_CHANNEL),
-          EFI_ACPI_CSRT_RESOURCE_TYPE_DMA,
-          EFI_ACPI_CSRT_RESOURCE_SUBTYPE_DMA_CHANNEL,
-          EFI_ACPI_CSRT_RESOURCE_ID_IN_DMA_GRP + 2,     // ResourceId
-        },
-        {
-          1,        // Channel vendor data here
-          0x31,     // 17+32 dma_int[1]
-          1,
-          0
-        },
-      },
-
-      // Channel 2 - VC4 use only
-      {
-        {
-          sizeof (RD_DMA_CHANNEL),
-          EFI_ACPI_CSRT_RESOURCE_TYPE_DMA,
-          EFI_ACPI_CSRT_RESOURCE_SUBTYPE_DMA_CHANNEL,
-          EFI_ACPI_CSRT_RESOURCE_ID_IN_DMA_GRP + 3,        // ResourceId
-        },
-        {
-          2,        // Channel vendor data here
-          0x32,     // 18+32 dma_int[2]
-          1,
-          0
-        },
-      },
-
-      // Channel 3 - VC4 use only
-      {
-        {
-          sizeof (RD_DMA_CHANNEL),
-          EFI_ACPI_CSRT_RESOURCE_TYPE_DMA,
-          EFI_ACPI_CSRT_RESOURCE_SUBTYPE_DMA_CHANNEL,
-          EFI_ACPI_CSRT_RESOURCE_ID_IN_DMA_GRP + 4,
-        },
-        {
-          3,        // Channel vendor data here
-          0x33,     // 19+32 dma_int[3]
-          1,
-          0
-        },
-      },
-
-      // channel 4
-      {
-        {
-          sizeof (RD_DMA_CHANNEL),
-          EFI_ACPI_CSRT_RESOURCE_TYPE_DMA,
-          EFI_ACPI_CSRT_RESOURCE_SUBTYPE_DMA_CHANNEL,
-          EFI_ACPI_CSRT_RESOURCE_ID_IN_DMA_GRP + 5,
-        },
-        {
-          4,        // Channel vendor data here
-          0x34,     // 20+32 dma_int[4]
-          0,
-          1         // SD host controller candidate
-        },
-      },
-
-      // Channel 5
-      {
-        {
-          sizeof (RD_DMA_CHANNEL),
-          EFI_ACPI_CSRT_RESOURCE_TYPE_DMA,
-          EFI_ACPI_CSRT_RESOURCE_SUBTYPE_DMA_CHANNEL,
-          EFI_ACPI_CSRT_RESOURCE_ID_IN_DMA_GRP + 6,
-        },
-        {
-          5,        // Channel vendor data here
-          0x35,     // 21+32 dma_int[5]
-          0,
-          0
-        },
-      },
-
-      // Channel 6 is reserved
-      {
-        {
-          sizeof (RD_DMA_CHANNEL),
-          EFI_ACPI_CSRT_RESOURCE_TYPE_DMA,
-          EFI_ACPI_CSRT_RESOURCE_SUBTYPE_DMA_CHANNEL,
-          EFI_ACPI_CSRT_RESOURCE_ID_IN_DMA_GRP + 7,
-        },
-        {
-          6,        // Channel vendor data here
-          0x36,     // 22+32 dma_int[6]
-          1,
-          0
-        },
-      },
-
-      // Channel 7 is reserved
-      {
-        {
-          sizeof (RD_DMA_CHANNEL),
-          EFI_ACPI_CSRT_RESOURCE_TYPE_DMA,
-          EFI_ACPI_CSRT_RESOURCE_SUBTYPE_DMA_CHANNEL,
-          EFI_ACPI_CSRT_RESOURCE_ID_IN_DMA_GRP + 8,
-        },
-        {
-          7,        // Channel vendor data here
-          0x37,     // 23+32 dma_int[7]
-          1,
-          0
-        },
-      },
-
-      // Channel 8
-      {
-        {
-          sizeof (RD_DMA_CHANNEL),
-          EFI_ACPI_CSRT_RESOURCE_TYPE_DMA,
-          EFI_ACPI_CSRT_RESOURCE_SUBTYPE_DMA_CHANNEL,
-          EFI_ACPI_CSRT_RESOURCE_ID_IN_DMA_GRP + 9,
-        },
-        {
-          8,        // Channel vendor data here
-          0x38,     // 24+32 dma_int[8]
-          0,
-          0
-        },
-      },
-
-      // Channel 9
-      {
-        {
-          sizeof (RD_DMA_CHANNEL),
-          EFI_ACPI_CSRT_RESOURCE_TYPE_DMA,
-          EFI_ACPI_CSRT_RESOURCE_SUBTYPE_DMA_CHANNEL,
-          EFI_ACPI_CSRT_RESOURCE_ID_IN_DMA_GRP + 10,
-        },
-        {
-          9,        // channel vendor data here
-          0x39,     // 25+32 dma_int[9]
-          0,
-          0
-        },
-      }
-
-    } // End DMA Channels 0 to 14
-
-  } // End DMA Resource group
-
-};
-
-#pragma pack(pop)
-
-//
-// Reference the table being generated to prevent the optimizer from removing the
-// data structure from the executable
-//
-VOID* CONST ReferenceAcpiTable = &Csrt;
diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Dbg2.aslc b/Platform/RaspberryPi/RPi4/AcpiTables/Dbg2.aslc
deleted file mode 100644
index c3d5994f8e97..000000000000
--- a/Platform/RaspberryPi/RPi4/AcpiTables/Dbg2.aslc
+++ /dev/null
@@ -1,105 +0,0 @@
-/** @file
- *
- *  Debug Port Table (DBG2)
- *
- *  Copyright (c) 2019, Pete Batard <pete@akeo.ie>
- *  Copyright (c) 2012-2016, ARM Limited. All rights reserved.
- *
- *  SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include <IndustryStandard/Acpi.h>
-#include <IndustryStandard/Bcm2836.h>
-#include <IndustryStandard/DebugPort2Table.h>
-#include <Library/AcpiLib.h>
-#include <Library/PcdLib.h>
-
-#include "AcpiTables.h"
-
-#pragma pack(1)
-
-#define RPI_DBG2_NUM_DEBUG_PORTS                        1
-#define RPI_DBG2_NUMBER_OF_GENERIC_ADDRESS_REGISTERS    1
-#define RPI_DBG2_NAMESPACESTRING_FIELD_SIZE             10
-
-#if (RPI_MODEL == 4)
-#define RPI_UART_INTERFACE_TYPE                         EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_ARM_PL011_UART
-#define RPI_UART_BASE_ADDRESS                           BCM2836_PL011_UART_BASE_ADDRESS
-#define RPI_UART_LENGTH                                 BCM2836_PL011_UART_LENGTH
-#define RPI_UART_STR                                    { '\\', '_', 'S', 'B', '.', 'U', 'R', 'T', '0', 0x00 }
-#else
-#define RPI_UART_INTERFACE_TYPE                         EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_BCM2835_UART
-#define RPI_UART_BASE_ADDRESS                           BCM2836_MINI_UART_BASE_ADDRESS
-#define RPI_UART_LENGTH                                 BCM2836_MINI_UART_LENGTH
-//
-// RPI_UART_STR should match the value used Uart.asl
-//
-#define RPI_UART_STR                                    { '\\', '_', 'S', 'B', '.', 'U', 'R', 'T', 'M', 0x00 }
-#endif
-
-typedef struct {
-  EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT         Dbg2Device;
-  EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE                BaseAddressRegister;
-  UINT32                                                AddressSize;
-  UINT8                                                 NameSpaceString[RPI_DBG2_NAMESPACESTRING_FIELD_SIZE];
-} DBG2_DEBUG_DEVICE_INFORMATION;
-
-typedef struct {
-  EFI_ACPI_DEBUG_PORT_2_DESCRIPTION_TABLE               Description;
-  DBG2_DEBUG_DEVICE_INFORMATION                         Dbg2DeviceInfo[RPI_DBG2_NUM_DEBUG_PORTS];
-} DBG2_TABLE;
-
-
-#define DBG2_DEBUG_PORT_DDI(NumReg, SubType, UartBase, UartAddrLen, UartNameStr) {                                    \
-    {                                                                                                                 \
-      EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT_REVISION,         /* UINT8     Revision */                        \
-      sizeof (DBG2_DEBUG_DEVICE_INFORMATION),                         /* UINT16    Length */                          \
-      NumReg,                                                         /* UINT8     NumberofGenericAddressRegisters */ \
-      RPI_DBG2_NAMESPACESTRING_FIELD_SIZE,                            /* UINT16    NameSpaceStringLength */           \
-      OFFSET_OF (DBG2_DEBUG_DEVICE_INFORMATION, NameSpaceString),     /* UINT16    NameSpaceStringOffset */           \
-      0,                                                              /* UINT16    OemDataLength */                   \
-      0,                                                              /* UINT16    OemDataOffset */                   \
-      EFI_ACPI_DBG2_PORT_TYPE_SERIAL,                                 /* UINT16    Port Type */                       \
-      SubType,                                                        /* UINT16    Port Subtype */                    \
-      {EFI_ACPI_RESERVED_BYTE, EFI_ACPI_RESERVED_BYTE},               /* UINT8     Reserved[2] */                     \
-      OFFSET_OF (DBG2_DEBUG_DEVICE_INFORMATION, BaseAddressRegister), /* UINT16    BaseAddressRegister Offset */      \
-      OFFSET_OF (DBG2_DEBUG_DEVICE_INFORMATION, AddressSize)          /* UINT16    AddressSize Offset */              \
-    },                                                                                                                \
-    ARM_GAS32 (UartBase),                            /* EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE BaseAddressRegister */ \
-    UartAddrLen,                                     /* UINT32  AddressSize */                                        \
-    UartNameStr                                      /* UINT8   NameSpaceString[MAX_DBG2_NAME_LEN] */                 \
-  }
-
-
-STATIC DBG2_TABLE Dbg2 = {
-  {
-    ACPI_HEADER (
-      EFI_ACPI_5_1_DEBUG_PORT_2_TABLE_SIGNATURE,
-      DBG2_TABLE,
-      EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT_REVISION
-    ),
-    OFFSET_OF (DBG2_TABLE, Dbg2DeviceInfo),
-    RPI_DBG2_NUM_DEBUG_PORTS                                          /* UINT32  NumberDbgDeviceInfo */
-  },
-  {
-    /*
-     * Kernel Debug Port
-     */
-    DBG2_DEBUG_PORT_DDI (
-      RPI_DBG2_NUMBER_OF_GENERIC_ADDRESS_REGISTERS,
-      RPI_UART_INTERFACE_TYPE,
-      RPI_UART_BASE_ADDRESS,
-      RPI_UART_LENGTH,
-      RPI_UART_STR
-    ),
-  }
-};
-
-#pragma pack()
-
-//
-// Reference the table being generated to prevent the optimizer from removing
-// the data structure from the executable
-//
-VOID* CONST ReferenceAcpiTable = &Dbg2;
diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Dsdt.asl b/Platform/RaspberryPi/RPi4/AcpiTables/Dsdt.asl
deleted file mode 100644
index c2775088b5a2..000000000000
--- a/Platform/RaspberryPi/RPi4/AcpiTables/Dsdt.asl
+++ /dev/null
@@ -1,569 +0,0 @@
-/** @file
- *
- *  Differentiated System Definition Table (DSDT)
- *
- *  Copyright (c) 2020, Pete Batard <pete@akeo.ie>
- *  Copyright (c) 2018, Andrey Warkentin <andrey.warkentin@gmail.com>
- *  Copyright (c) Microsoft Corporation. All rights reserved.
- *
- *  SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include <BcmGenetDxe/Genet.h>
-#include <IndustryStandard/Bcm2836.h>
-#include <IndustryStandard/Bcm2836Gpio.h>
-#include <IndustryStandard/Bcm2836Gpu.h>
-#include <IndustryStandard/Bcm2836Pwm.h>
-
-#include "AcpiTables.h"
-
-#define BCM_ALT0 0x4
-#define BCM_ALT1 0x5
-#define BCM_ALT2 0x6
-#define BCM_ALT3 0x7
-#define BCM_ALT4 0x3
-#define BCM_ALT5 0x2
-
-DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
-{
-  Scope (\_SB_)
-  {
-    include ("Sdhc.asl")
-    include ("Pep.asl")
-#if (RPI_MODEL == 4)
-    include ("Xhci.asl")
-#endif
-
-    Device (CPU0)
-    {
-      Name (_HID, "ACPI0007")
-      Name (_UID, 0x0)
-      Method (_STA)
-      {
-        Return (0xf)
-      }
-    }
-
-    Device (CPU1)
-    {
-      Name (_HID, "ACPI0007")
-      Name (_UID, 0x1)
-      Method (_STA)
-      {
-        Return (0xf)
-      }
-    }
-
-    Device (CPU2)
-    {
-      Name (_HID, "ACPI0007")
-      Name (_UID, 0x2)
-      Method (_STA)
-      {
-        Return (0xf)
-      }
-    }
-
-    Device (CPU3)
-    {
-      Name (_HID, "ACPI0007")
-      Name (_UID, 0x3)
-      Method (_STA)
-      {
-        Return (0xf)
-      }
-    }
-
-    // DWC OTG Controller
-    Device (USB0)
-    {
-      Name (_HID, "BCM2848")
-      Name (_CID, Package() { "DWC_OTG", "DWC2_OTG"})
-      Name (_UID, 0x0)
-      Name (_CCA, 0x0)
-      Method (_STA)
-      {
-        Return (0xf)
-      }
-      Name (RBUF, ResourceTemplate ()
-      {
-        MEMORY32FIXED (ReadWrite, 0, BCM2836_USB_LENGTH, RMEM)
-        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_USB_INTERRUPT }
-      })
-      Method (_CRS, 0x0, Serialized)
-      {
-        MEMORY32SETBASE (RBUF, RMEM, RBAS, BCM2836_USB_OFFSET)
-        Return (^RBUF)
-      }
-    }
-
-    // Video Core 4 GPU
-    Device (GPU0)
-    {
-      Name (_HID, "BCM2850")
-      Name (_CID, "VC4")
-      Name (_UID, 0x0)
-      Name (_CCA, 0x0)
-      Method (_STA)
-      {
-        Return(0xf)
-      }
-      Name (RBUF, ResourceTemplate ()
-      {
-        // Memory and interrupt for the GPU
-        MEMORY32FIXED (ReadWrite, 0, BCM2836_V3D_BUS_LENGTH, RM01)
-        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_V3D_BUS_INTERRUPT }
-
-        // HVS - Hardware Video Scalar
-        MEMORY32FIXED (ReadWrite, 0, BCM2836_HVS_LENGTH, RM02)
-        // The HVS interrupt is reserved by the VPU
-        // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_HVS_INTERRUPT }
-
-        // PixelValve0 - DSI0 or DPI
-        // MEMORY32FIXED (ReadWrite, BCM2836_PV0_BASE_ADDRESS, BCM2836_PV0_LENGTH, RM03)
-        // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_PV0_INTERRUPT }
-
-        // PixelValve1 - DS1 or SMI
-        // MEMORY32FIXED (ReadWrite, BCM2836_PV1_BASE_ADDRESS, BCM2836_PV1_LENGTH, RM04)
-        // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_PV1_INTERRUPT }
-
-        // PixelValve2 - HDMI output - connected to HVS display FIFO 1
-        MEMORY32FIXED (ReadWrite, 0, BCM2836_PV2_LENGTH, RM05)
-        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_PV2_INTERRUPT }
-
-        // HDMI registers
-        MEMORY32FIXED (ReadWrite, 0, BCM2836_HDMI0_LENGTH, RM06)
-        MEMORY32FIXED (ReadWrite, 0, BCM2836_HDMI1_LENGTH, RM07)
-        // hdmi_int[0]
-        // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_HDMI0_INTERRUPT }
-        // hdmi_int[1]
-        // Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_HDMI1_INTERRUPT }
-
-        // HDMI DDC connection
-        I2CSerialBus (0x50,, 100000,, "\\_SB.I2C2",,,,)  // EDID
-        I2CSerialBus (0x30,, 100000,, "\\_SB.I2C2",,,,)  // E-DDC Segment Pointer
-      })
-      Method (_CRS, 0x0, Serialized)
-      {
-        MEMORY32SETBASE (RBUF, RM01, RB01, BCM2836_V3D_BUS_OFFSET)
-        MEMORY32SETBASE (RBUF, RM02, RB02, BCM2836_HVS_OFFSET)
-        MEMORY32SETBASE (RBUF, RM05, RB05, BCM2836_PV2_OFFSET)
-        MEMORY32SETBASE (RBUF, RM06, RB06, BCM2836_HDMI0_OFFSET)
-        MEMORY32SETBASE (RBUF, RM07, RB07, BCM2836_HDMI1_OFFSET)
-        Return (^RBUF)
-      }
-
-      // GPU Power Management Component Data
-      // Reference : https://github.com/Microsoft/graphics-driver-samples/wiki/Install-Driver-in-a-Windows-VM
-      Method (PMCD, 0, Serialized)
-      {
-        Name (RBUF, Package ()
-        {
-          1,                  // Version
-          1,                  // Number of graphics power components
-          Package ()          // Power components package
-          {
-            Package ()        // GPU component package
-            {
-              0,              // Component Index
-              0,              // DXGK_POWER_COMPONENT_MAPPING.ComponentType (0 = DXGK_POWER_COMPONENT_ENGINE)
-              0,              // DXGK_POWER_COMPONENT_MAPPING.NodeIndex
-
-              Buffer ()       // DXGK_POWER_RUNTIME_COMPONENT.ComponentGuid
-              {               // 9B2D1E26-1575-4747-8FC0-B9EB4BAA2D2B
-                0x26, 0x1E, 0x2D, 0x9B, 0x75, 0x15, 0x47, 0x47,
-                0x8f, 0xc0, 0xb9, 0xeb, 0x4b, 0xaa, 0x2d, 0x2b
-              },
-
-              "VC4_Engine_00",// DXGK_POWER_RUNTIME_COMPONENT.ComponentName
-              2,              // DXGK_POWER_RUNTIME_COMPONENT.StateCount
-
-              Package ()      // DXGK_POWER_RUNTIME_COMPONENT.States[] package
-              {
-                Package ()   // F0
-                {
-                  0,         // DXGK_POWER_RUNTIME_STATE.TransitionLatency
-                  0,         // DXGK_POWER_RUNTIME_STATE.ResidencyRequirement
-                  1210000,   // DXGK_POWER_RUNTIME_STATE.NominalPower (microwatt)
-                },
-
-                Package ()   // F1 - Placeholder
-                {
-                  10000,     // DXGK_POWER_RUNTIME_STATE.TransitionLatency
-                  10000,     // DXGK_POWER_RUNTIME_STATE.ResidencyRequirement
-                  4,         // DXGK_POWER_RUNTIME_STATE.NominalPower
-                },
-              }
-            }
-          }
-        })
-        Return (RBUF)
-      }
-    }
-
-    // PiQ Mailbox Driver
-    Device (RPIQ)
-    {
-      Name (_HID, "BCM2849")
-      Name (_CID, "RPIQ")
-      Name (_UID, 0)
-      Name (_CCA, 0x0)
-      Method (_STA)
-      {
-        Return (0xf)
-      }
-      Name (RBUF, ResourceTemplate ()
-      {
-        MEMORY32FIXED (ReadWrite, 0, BCM2836_MBOX_LENGTH, RMEM)
-        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_MBOX_INTERRUPT }
-      })
-
-      Method (_CRS, 0x0, Serialized)
-      {
-        MEMORY32SETBASE (RBUF, RMEM, RBAS, BCM2836_MBOX_OFFSET)
-        Return (^RBUF)
-      }
-    }
-
-    // VCHIQ Driver
-    Device (VCIQ)
-    {
-      Name (_HID, "BCM2835")
-      Name (_CID, "VCIQ")
-      Name (_UID, 0)
-      Name (_CCA, 0x0)
-      Name (_DEP, Package() { \_SB.RPIQ })
-      Method (_STA)
-      {
-         Return (0xf)
-      }
-      Name (RBUF, ResourceTemplate ()
-      {
-        MEMORY32FIXED (ReadWrite, 0, BCM2836_VCHIQ_LENGTH, RMEM)
-        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_VCHIQ_INTERRUPT }
-      })
-
-      Method (_CRS, 0x0, Serialized)
-      {
-        MEMORY32SETBASE (RBUF, RMEM, RBAS, BCM2836_VCHIQ_OFFSET)
-        Return (^RBUF)
-      }
-    }
-
-    // VC Shared Memory Driver
-    Device (VCSM)
-    {
-      Name (_HID, "BCM2856")
-      Name (_CID, "VCSM")
-      Name (_UID, 0)
-      Name (_CCA, 0x0)
-      Name (_DEP, Package() { \_SB.VCIQ })
-      Method (_STA)
-      {
-        Return (0xf)
-      }
-    }
-
-    // Description: GPIO
-    Device (GPI0)
-    {
-      Name (_HID, "BCM2845")
-      Name (_CID, "BCMGPIO")
-      Name (_UID, 0x0)
-      Name (_CCA, 0x0)
-      Method (_STA)
-      {
-        Return(0xf)
-      }
-      Name (RBUF, ResourceTemplate ()
-      {
-        MEMORY32FIXED (ReadWrite, 0, GPIO_LENGTH, RMEM)
-        Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { BCM2386_GPIO_INTERRUPT0, BCM2386_GPIO_INTERRUPT1 }
-      })
-      Method (_CRS, 0x0, Serialized)
-      {
-        MEMORY32SETBASE (RBUF, RMEM, RBAS, GPIO_OFFSET)
-        Return (^RBUF)
-      }
-    }
-
-#if (RPI_MODEL == 4)
-    Device (ETH0)
-    {
-      Name (_HID, "BCM6E4E")
-      Name (_CID, "BCM6E4E")
-      Name (_UID, 0x0)
-      Name (_CCA, 0x0)
-      Method (_STA)
-      {
-        Return (0xf)
-      }
-      Method (_CRS, 0x0, Serialized)
-      {
-        Name (RBUF, ResourceTemplate ()
-        {
-          // No need for MEMORY32SETBASE on Genet as we have a straight base address constant
-          MEMORY32FIXED (ReadWrite, GENET_BASE_ADDRESS, GENET_LENGTH, )
-          Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { GENET_INTERRUPT0, GENET_INTERRUPT1 }
-        })
-        Return (RBUF)
-      }
-      Name (_DSD, Package () {
-        ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
-        Package () {
-          Package () { "brcm,max-dma-burst-size", 0x08 },
-          Package () { "phy-mode", "rgmii-rxid" },
-        }
-      })
-    }
-#endif
-
-    // Description: I2C
-    Device (I2C1)
-    {
-      Name (_HID, "BCM2841")
-      Name (_CID, "BCMI2C")
-      Name (_UID, 0x1)
-      Name (_CCA, 0x0)
-      Method (_STA)
-      {
-        Return(0xf)
-      }
-      Name (RBUF, ResourceTemplate ()
-      {
-        MEMORY32FIXED (ReadWrite, 0, BCM2836_I2C1_LENGTH, RMEM)
-        Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { BCM2836_I2C1_INTERRUPT }
-
-        //
-        // MsftFunctionConfig is encoded as the VendorLong.
-        //
-        // MsftFunctionConfig (Exclusive, PullUp, BCM_ALT0, "\\_SB.GPI0", 0, ResourceConsumer,) {2, 3}
-        //
-        VendorLong ()      // Length = 0x31
-        {
-          /* 0000 */  0x00, 0x60, 0x44, 0xD5, 0xF3, 0x1F, 0x11, 0x60,  // .`D....`
-          /* 0008 */  0x4A, 0xB8, 0xB0, 0x9C, 0x2D, 0x23, 0x30, 0xDD,  // J...-#0.
-          /* 0010 */  0x2F, 0x8D, 0x1D, 0x00, 0x01, 0x10, 0x00, 0x01,  // /.......
-          /* 0018 */  0x04, 0x00, 0x12, 0x00, 0x00, 0x16, 0x00, 0x20,  // ........
-          /* 0020 */  0x00, 0x00, 0x00, 0x02, 0x00, 0x03, 0x00, 0x5C,  // ........
-          /* 0028 */  0x5F, 0x53, 0x42, 0x2E, 0x47, 0x50, 0x49, 0x30,  // _SB.GPI0
-          /* 0030 */  0x00                                             // .
-        }
-      })
-      Method (_CRS, 0x0, Serialized)
-      {
-        MEMORY32SETBASE (RBUF, RMEM, RBAS, BCM2836_I2C1_OFFSET)
-        Return (^RBUF)
-      }
-    }
-
-    // I2C2 is the HDMI DDC connection
-    Device (I2C2)
-    {
-      Name (_HID, "BCM2841")
-      Name (_CID, "BCMI2C")
-      Name (_UID, 0x2)
-      Name (_CCA, 0x0)
-      Method (_STA)
-      {
-        Return (0xf)
-      }
-      Name (RBUF, ResourceTemplate()
-      {
-        MEMORY32FIXED (ReadWrite, 0, BCM2836_I2C2_LENGTH, RMEM)
-        Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { BCM2836_I2C2_INTERRUPT }
-      })
-
-      Method (_CRS, 0x0, Serialized)
-      {
-        MEMORY32SETBASE (RBUF, RMEM, RBAS, BCM2836_I2C2_OFFSET)
-        Return (^RBUF)
-      }
-    }
-
-    // SPI
-    Device (SPI0)
-    {
-      Name (_HID, "BCM2838")
-      Name (_CID, "BCMSPI0")
-      Name (_UID, 0x0)
-      Name (_CCA, 0x0)
-      Method (_STA)
-      {
-        Return (0xf)
-      }
-      Name (RBUF, ResourceTemplate ()
-      {
-        MEMORY32FIXED (ReadWrite, 0, BCM2836_SPI0_LENGTH, RMEM)
-        Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { BCM2836_SPI0_INTERRUPT }
-
-        //
-        // MsftFunctionConfig is encoded as the VendorLong.
-        //
-        // MsftFunctionConfig (Exclusive, PullDown, BCM_ALT0, "\\_SB.GPI0", 0, ResourceConsumer, ) {9, 10, 11} // MISO, MOSI, SCLK
-        VendorLong ()      // Length = 0x33
-        {
-          /* 0000 */  0x00, 0x60, 0x44, 0xD5, 0xF3, 0x1F, 0x11, 0x60,  // .`D....`
-          /* 0008 */  0x4A, 0xB8, 0xB0, 0x9C, 0x2D, 0x23, 0x30, 0xDD,  // J...-#0.
-          /* 0010 */  0x2F, 0x8D, 0x1F, 0x00, 0x01, 0x10, 0x00, 0x02,  // /.......
-          /* 0018 */  0x04, 0x00, 0x12, 0x00, 0x00, 0x18, 0x00, 0x22,  // ......."
-          /* 0020 */  0x00, 0x00, 0x00, 0x09, 0x00, 0x0A, 0x00, 0x0B,  // ........
-          /* 0028 */  0x00, 0x5C, 0x5F, 0x53, 0x42, 0x2E, 0x47, 0x50,  // .\_SB.GP
-          /* 0030 */  0x49, 0x30, 0x00                                 // I0.
-        }
-
-        //
-        // MsftFunctionConfig is encoded as the VendorLong.
-        //
-        // MsftFunctionConfig (Exclusive, PullUp, BCM_ALT0, "\\_SB.GPI0", 0, ResourceConsumer, ) {8}     // CE0
-        VendorLong ()      // Length = 0x2F
-        {
-          /* 0000 */  0x00, 0x60, 0x44, 0xD5, 0xF3, 0x1F, 0x11, 0x60,  // .`D....`
-          /* 0008 */  0x4A, 0xB8, 0xB0, 0x9C, 0x2D, 0x23, 0x30, 0xDD,  // J...-#0.
-          /* 0010 */  0x2F, 0x8D, 0x1B, 0x00, 0x01, 0x10, 0x00, 0x01,  // /.......
-          /* 0018 */  0x04, 0x00, 0x12, 0x00, 0x00, 0x14, 0x00, 0x1E,  // ........
-          /* 0020 */  0x00, 0x00, 0x00, 0x08, 0x00, 0x5C, 0x5F, 0x53,  // .....\_S
-          /* 0028 */  0x42, 0x2E, 0x47, 0x50, 0x49, 0x30, 0x00         // B.GPI0.
-        }
-
-        //
-        // MsftFunctionConfig is encoded as the VendorLong.
-        //
-        // MsftFunctionConfig (Exclusive, PullUp, BCM_ALT0, "\\_SB.GPI0", 0, ResourceConsumer, ) {7}     // CE1
-        VendorLong ()      // Length = 0x2F
-        {
-          /* 0000 */  0x00, 0x60, 0x44, 0xD5, 0xF3, 0x1F, 0x11, 0x60,  // .`D....`
-          /* 0008 */  0x4A, 0xB8, 0xB0, 0x9C, 0x2D, 0x23, 0x30, 0xDD,  // J...-#0.
-          /* 0010 */  0x2F, 0x8D, 0x1B, 0x00, 0x01, 0x10, 0x00, 0x01,  // /.......
-          /* 0018 */  0x04, 0x00, 0x12, 0x00, 0x00, 0x14, 0x00, 0x1E,  // ........
-          /* 0020 */  0x00, 0x00, 0x00, 0x07, 0x00, 0x5C, 0x5F, 0x53,  // .....\_S
-          /* 0028 */  0x42, 0x2E, 0x47, 0x50, 0x49, 0x30, 0x00         // B.GPI0.
-        }
-      })
-
-      Method (_CRS, 0x0, Serialized)
-      {
-        MEMORY32SETBASE (RBUF, RMEM, RBAS, BCM2836_SPI0_OFFSET)
-        Return (^RBUF)
-      }
-    }
-
-    Device (SPI1)
-    {
-      Name (_HID, "BCM2839")
-      Name (_CID, "BCMAUXSPI")
-      Name (_UID, 0x1)
-      Name (_CCA, 0x0)
-      Name (_DEP, Package() { \_SB.RPIQ })
-      Method (_STA)
-      {
-        Return (0xf)
-      }
-      Name (RBUF, ResourceTemplate ()
-      {
-        MEMORY32FIXED (ReadWrite, 0, BCM2836_SPI1_LENGTH, RMEM)
-        Interrupt (ResourceConsumer, Level, ActiveHigh, Shared,) { BCM2836_SPI1_INTERRUPT }
-
-        //
-        // MsftFunctionConfig is encoded as the VendorLong.
-        //
-        // MsftFunctionConfig(Exclusive, PullDown, BCM_ALT4, "\\_SB.GPI0", 0, ResourceConsumer, ) {19, 20, 21} // MISO, MOSI, SCLK
-        VendorLong ()      // Length = 0x33
-        {
-          /* 0000 */  0x00, 0x60, 0x44, 0xD5, 0xF3, 0x1F, 0x11, 0x60,  // .`D....`
-          /* 0008 */  0x4A, 0xB8, 0xB0, 0x9C, 0x2D, 0x23, 0x30, 0xDD,  // J...-#0.
-          /* 0010 */  0x2F, 0x8D, 0x1F, 0x00, 0x01, 0x10, 0x00, 0x02,  // /.......
-          /* 0018 */  0x03, 0x00, 0x12, 0x00, 0x00, 0x18, 0x00, 0x22,  // ......."
-          /* 0020 */  0x00, 0x00, 0x00, 0x13, 0x00, 0x14, 0x00, 0x15,  // ........
-          /* 0028 */  0x00, 0x5C, 0x5F, 0x53, 0x42, 0x2E, 0x47, 0x50,  // .\_SB.GP
-          /* 0030 */  0x49, 0x30, 0x00                                 // I0.
-        }
-
-        //
-        // MsftFunctionConfig is encoded as the VendorLong.
-        //
-        // MsftFunctionConfig(Exclusive, PullDown, BCM_ALT4, "\\_SB.GPI0", 0, ResourceConsumer, ) {16} // CE2
-        VendorLong ()      // Length = 0x2F
-        {
-          /* 0000 */  0x00, 0x60, 0x44, 0xD5, 0xF3, 0x1F, 0x11, 0x60,  // .`D....`
-          /* 0008 */  0x4A, 0xB8, 0xB0, 0x9C, 0x2D, 0x23, 0x30, 0xDD,  // J...-#0.
-          /* 0010 */  0x2F, 0x8D, 0x1B, 0x00, 0x01, 0x10, 0x00, 0x02,  // /.......
-          /* 0018 */  0x03, 0x00, 0x12, 0x00, 0x00, 0x14, 0x00, 0x1E,  // ........
-          /* 0020 */  0x00, 0x00, 0x00, 0x10, 0x00, 0x5C, 0x5F, 0x53,  // .....\_S
-          /* 0028 */  0x42, 0x2E, 0x47, 0x50, 0x49, 0x30, 0x00         // B.GPI0.
-        }
-      })
-
-      Method (_CRS, 0x0, Serialized)
-      {
-        MEMORY32SETBASE (RBUF, RMEM, RBAS, BCM2836_SPI1_OFFSET)
-        Return (^RBUF)
-      }
-    }
-
-    // SPI2 has no pins on GPIO header
-    // Device (SPI2)
-    // {
-    //   Name (_HID, "BCM2839")
-    //   Name (_CID, "BCMAUXSPI")
-    //   Name (_UID, 0x2)
-    //   Name (_CCA, 0x0)
-    //   Name (_DEP, Package() { \_SB.RPIQ })
-    //   Method (_STA)
-    //   {
-    //     Return (0xf)     // Disabled
-    //   }
-    //   Method (_CRS, 0x0, Serialized)
-    //   {
-    //     Name (RBUF, ResourceTemplate ()
-    //     {
-    //       MEMORY32FIXED (ReadWrite, BCM2836_SPI2_BASE_ADDRESS, BCM2836_SPI2_LENGTH, RMEM)
-    //       Interrupt (ResourceConsumer, Level, ActiveHigh, Shared,) { BCM2836_SPI2_INTERRUPT }
-    //     })
-    //     Return (RBUF)
-    //   }
-    // }
-
-    // PWM Driver
-    Device (PWM0)
-    {
-      Name (_HID, "BCM2844")
-      Name (_CID, "BCM2844")
-      Name (_UID, 0)
-      Name (_CCA, 0x0)
-      Method (_STA)
-      {
-        Return (0xf)
-      }
-      Name (RBUF, ResourceTemplate ()
-      {
-        // DMA channel 11 control
-        MEMORY32FIXED (ReadWrite, 0, BCM2836_PWM_DMA_LENGTH, RM01)
-        // PWM control
-        MEMORY32FIXED (ReadWrite, 0, BCM2836_PWM_CTRL_LENGTH, RM02)
-        // PWM control bus
-        MEMORY32FIXED (ReadWrite, BCM2836_PWM_BUS_BASE_ADDRESS, BCM2836_PWM_BUS_LENGTH, )
-        // PWM control uncached
-        MEMORY32FIXED (ReadWrite, BCM2836_PWM_CTRL_UNCACHED_BASE_ADDRESS, BCM2836_PWM_CTRL_UNCACHED_LENGTH, )
-        // PWM clock control
-        MEMORY32FIXED (ReadWrite, 0, BCM2836_PWM_CLK_LENGTH, RM03)
-        // Interrupt DMA channel 11
-        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_DMA_INTERRUPT }
-        // DMA channel 11, DREQ 5 for PWM
-        FixedDMA (5, 11, Width32Bit, )
-      })
-
-      Method (_CRS, 0x0, Serialized)
-      {
-        MEMORY32SETBASE (RBUF, RM01, RB01, BCM2836_PWM_DMA_OFFSET)
-        MEMORY32SETBASE (RBUF, RM02, RB02, BCM2836_PWM_CTRL_OFFSET)
-        MEMORY32SETBASE (RBUF, RM03, RB03, BCM2836_PWM_CLK_OFFSET)
-        Return (^RBUF)
-      }
-    }
-
-    include ("Uart.asl")
-    include ("Rhpx.asl")
-  }
-}
diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Fadt.aslc b/Platform/RaspberryPi/RPi4/AcpiTables/Fadt.aslc
deleted file mode 100644
index ebf58fb7fc3c..000000000000
--- a/Platform/RaspberryPi/RPi4/AcpiTables/Fadt.aslc
+++ /dev/null
@@ -1,89 +0,0 @@
-/** @file
- *
- *  Fixed ACPI Description Table (FADT)
- *
- *  Copyright (c) 2019, Pete Batard <pete@akeo.ie>
- *  Copyright (c) 2018, Andrey Warkentin <andrey.warkentin@gmail.com>
- *  Copyright (c) Microsoft Corporation. All rights reserved.
- *
- *  SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include <IndustryStandard/Acpi.h>
-#include <Library/AcpiLib.h>
-#include <Library/PcdLib.h>
-
-#include "AcpiTables.h"
-
-/*
- * Note: Use ACPI 5.1 since we need to match MADT ACPI requirements
- */
-EFI_ACPI_5_1_FIXED_ACPI_DESCRIPTION_TABLE Fadt = {
-  ACPI_HEADER (
-    EFI_ACPI_5_1_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE,
-    EFI_ACPI_5_1_FIXED_ACPI_DESCRIPTION_TABLE,
-    EFI_ACPI_5_1_FIXED_ACPI_DESCRIPTION_TABLE_REVISION
-  ),
-  0,                                                                        // UINT32     FirmwareCtrl
-  0,                                                                        // UINT32     Dsdt
-  EFI_ACPI_RESERVED_BYTE,                                                   // UINT8      Reserved0
-  EFI_ACPI_5_1_PM_PROFILE_APPLIANCE_PC,                                     // UINT8      PreferredPmProfile
-  0,                                                                        // UINT16     SciInt
-  0,                                                                        // UINT32     SmiCmd
-  0,                                                                        // UINT8      AcpiEnable
-  0,                                                                        // UINT8      AcpiDisable
-  0,                                                                        // UINT8      S4BiosReq
-  0,                                                                        // UINT8      PstateCnt
-  0,                                                                        // UINT32     Pm1aEvtBlk
-  0,                                                                        // UINT32     Pm1bEvtBlk
-  0,                                                                        // UINT32     Pm1aCntBlk
-  0,                                                                        // UINT32     Pm1bCntBlk
-  0,                                                                        // UINT32     Pm2CntBlk
-  0,                                                                        // UINT32     PmTmrBlk
-  0,                                                                        // UINT32     Gpe0Blk
-  0,                                                                        // UINT32     Gpe1Blk
-  0,                                                                        // UINT8      Pm1EvtLen
-  0,                                                                        // UINT8      Pm1CntLen
-  0,                                                                        // UINT8      Pm2CntLen
-  0,                                                                        // UINT8      PmTmrLen
-  0,                                                                        // UINT8      Gpe0BlkLen
-  0,                                                                        // UINT8      Gpe1BlkLen
-  0,                                                                        // UINT8      Gpe1Base
-  0,                                                                        // UINT8      CstCnt
-  0,                                                                        // UINT16     PLvl2Lat
-  0,                                                                        // UINT16     PLvl3Lat
-  0,                                                                        // UINT16     FlushSize
-  0,                                                                        // UINT16     FlushStride
-  0,                                                                        // UINT8      DutyOffset
-  0,                                                                        // UINT8      DutyWidth
-  0,                                                                        // UINT8      DayAlrm
-  0,                                                                        // UINT8      MonAlrm
-  0,                                                                        // UINT8      Century
-  EFI_ACPI_RESERVED_WORD,                                                   // UINT16     IaPcBootArch (Reserved on ARM)
-  EFI_ACPI_RESERVED_BYTE,                                                   // UINT8      Reserved1
-  EFI_ACPI_5_1_WBINVD | EFI_ACPI_5_1_SLP_BUTTON |                           // UINT32     Flags
-  EFI_ACPI_5_1_HW_REDUCED_ACPI,
-  NULL_GAS,                                                                 // EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE  ResetReg
-  0,                                                                        // UINT8      ResetValue
-  EFI_ACPI_5_1_ARM_PSCI_COMPLIANT,                                          // UINT16     ArmBootArchFlags
-  EFI_ACPI_5_1_FIXED_ACPI_DESCRIPTION_TABLE_MINOR_REVISION,                 // UINT8      MinorRevision
-  0,                                                                        // UINT64     XFirmwareCtrl
-  0,                                                                        // UINT64     XDsdt
-  NULL_GAS,                                                                 // EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE  XPm1aEvtBlk
-  NULL_GAS,                                                                 // EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE  XPm1bEvtBlk
-  NULL_GAS,                                                                 // EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE  XPm1aCntBlk
-  NULL_GAS,                                                                 // EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE  XPm1bCntBlk
-  NULL_GAS,                                                                 // EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE  XPm2CntBlk
-  NULL_GAS,                                                                 // EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE  XPmTmrBlk
-  NULL_GAS,                                                                 // EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE  XGpe0Blk
-  NULL_GAS,                                                                 // EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE  XGpe1Blk
-  NULL_GAS,                                                                 // EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE  SleepControlReg
-  NULL_GAS                                                                  // EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE  SleepStatusReg
-};
-
-//
-// Reference the table being generated to prevent the optimizer from removing the
-// data structure from the executable
-//
-VOID* CONST ReferenceAcpiTable = &Fadt;
diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Gtdt.aslc b/Platform/RaspberryPi/RPi4/AcpiTables/Gtdt.aslc
deleted file mode 100644
index 8453e487fb63..000000000000
--- a/Platform/RaspberryPi/RPi4/AcpiTables/Gtdt.aslc
+++ /dev/null
@@ -1,55 +0,0 @@
-/** @file
-*  Generic Timer Description Table (GTDT)
-*
-*  Copyright (c) 2018, Linaro Limited. All rights reserved.
-*  Copyright (c) 2012 - 2016, ARM Limited. All rights reserved.
-*
-*  SPDX-License-Identifier: BSD-2-Clause-Patent
-*
-**/
-
-#include <IndustryStandard/Acpi.h>
-#include <Library/AcpiLib.h>
-#include <Library/PcdLib.h>
-
-#include "AcpiTables.h"
-
-#define RPI_GTDT_GLOBAL_FLAGS           0
-#define RPI_GTDT_GTIMER_FLAGS           EFI_ACPI_5_1_GTDT_TIMER_FLAG_TIMER_INTERRUPT_POLARITY
-
-#pragma pack (1)
-
-typedef struct {
-  EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLE Gtdt;
-} EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLES;
-
-#pragma pack ()
-
-EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLES Gtdt = {
-  {
-    ACPI_HEADER(
-      EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE,
-      EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLES,
-      EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLE_REVISION
-    ),
-    RPI_SYSTEM_TIMER_BASE_ADDRESS,                // UINT64  PhysicalAddress
-    0,                                            // UINT32  Reserved
-    FixedPcdGet32 (PcdArmArchTimerSecIntrNum),    // UINT32  SecurePL1TimerGSIV
-    RPI_GTDT_GTIMER_FLAGS,                        // UINT32  SecurePL1TimerFlags
-    FixedPcdGet32 (PcdArmArchTimerIntrNum),       // UINT32  NonSecurePL1TimerGSIV
-    RPI_GTDT_GTIMER_FLAGS,                        // UINT32  NonSecurePL1TimerFlags
-    FixedPcdGet32 (PcdArmArchTimerVirtIntrNum),   // UINT32  VirtualTimerGSIV
-    RPI_GTDT_GTIMER_FLAGS,                        // UINT32  VirtualTimerFlags
-    FixedPcdGet32 (PcdArmArchTimerHypIntrNum),    // UINT32  NonSecurePL2TimerGSIV
-    RPI_GTDT_GTIMER_FLAGS,                        // UINT32  NonSecurePL2TimerFlags
-    0xFFFFFFFFFFFFFFFF,                           // UINT64  CntReadBasePhysicalAddress
-    0,                                            // UINT32  PlatformTimerCount
-    0                                             // UINT32 PlatfromTimerOffset
-  },
-};
-
-//
-// Reference the table being generated to prevent the optimizer
-// from removing the data structure from the executable
-//
-VOID* CONST ReferenceAcpiTable = &Gtdt;
diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Madt.aslc b/Platform/RaspberryPi/RPi4/AcpiTables/Madt.aslc
deleted file mode 100644
index 4029cd191ab5..000000000000
--- a/Platform/RaspberryPi/RPi4/AcpiTables/Madt.aslc
+++ /dev/null
@@ -1,80 +0,0 @@
-/** @file
-*  Multiple APIC Description Table (MADT)
-*
-*  Copyright (c) 2016 Linaro Ltd. All rights reserved.
-*  Copyright (c) 2012 - 2015, ARM Limited. All rights reserved.
-*
-*  SPDX-License-Identifier: BSD-2-Clause-Patent
-*
-**/
-
-#include <IndustryStandard/Acpi.h>
-#include <Library/AcpiLib.h>
-#include <Library/ArmLib.h>
-#include <Library/PcdLib.h>
-
-#include "AcpiTables.h"
-
-//
-// Multiple APIC Description Table
-//
-#pragma pack (1)
-
-typedef struct {
-  EFI_ACPI_5_1_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER   Header;
-  EFI_ACPI_5_1_GIC_STRUCTURE                            GicInterfaces[4];
-#if (RPI_MODEL != 3)
-  EFI_ACPI_5_1_GIC_DISTRIBUTOR_STRUCTURE                GicDistributor;
-#endif
-} PI_MULTIPLE_APIC_DESCRIPTION_TABLE;
-
-#pragma pack ()
-
-PI_MULTIPLE_APIC_DESCRIPTION_TABLE Madt = {
-  {
-    ACPI_HEADER (
-      EFI_ACPI_5_1_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE,
-      PI_MULTIPLE_APIC_DESCRIPTION_TABLE,
-      EFI_ACPI_5_1_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION
-    ),
-    //
-    // MADT specific fields
-    //
-    0, // LocalApicAddress
-    0, // Flags
-  },
-  {
-#if (RPI_MODEL == 3)
-    EFI_ACPI_5_1_GICC_STRUCTURE_INIT(
-        0, 0, GET_MPID(0, 0), EFI_ACPI_5_1_GIC_ENABLED, 0x09, 0x40000000, 0, 0, 0, 0),
-    EFI_ACPI_5_1_GICC_STRUCTURE_INIT(
-        1, 1, GET_MPID(0, 1), EFI_ACPI_5_1_GIC_ENABLED, 0x09, 0x40000000, 0, 0, 0, 0),
-    EFI_ACPI_5_1_GICC_STRUCTURE_INIT(
-        2, 2, GET_MPID(0, 2), EFI_ACPI_5_1_GIC_ENABLED, 0x09, 0x40000000, 0, 0, 0, 0),
-    EFI_ACPI_5_1_GICC_STRUCTURE_INIT(
-        3, 3, GET_MPID(0, 3), EFI_ACPI_5_1_GIC_ENABLED, 0x09, 0x40000000, 0, 0, 0, 0),
-#elif (RPI_MODEL == 4)
-    EFI_ACPI_5_1_GICC_STRUCTURE_INIT(
-        0, 0, GET_MPID(0, 0), EFI_ACPI_5_1_GIC_ENABLED, 48, FixedPcdGet64 (PcdGicInterruptInterfaceBase),
-        0xFF846000, 0xFF844000, 0x19, 0),
-    EFI_ACPI_5_1_GICC_STRUCTURE_INIT(
-        1, 1, GET_MPID(0, 1), EFI_ACPI_5_1_GIC_ENABLED, 49, FixedPcdGet64 (PcdGicInterruptInterfaceBase),
-        0xFF846000, 0xFF844000, 0x19, 0),
-    EFI_ACPI_5_1_GICC_STRUCTURE_INIT(
-        2, 2, GET_MPID(0, 2), EFI_ACPI_5_1_GIC_ENABLED, 50, FixedPcdGet64 (PcdGicInterruptInterfaceBase),
-        0xFF846000, 0xFF844000, 0x19, 0),
-    EFI_ACPI_5_1_GICC_STRUCTURE_INIT(
-        3, 3, GET_MPID(0, 3), EFI_ACPI_5_1_GIC_ENABLED, 51, FixedPcdGet64 (PcdGicInterruptInterfaceBase),
-        0xFF846000, 0xFF844000, 0x19, 0),
-#endif
-  },
-#if (RPI_MODEL != 3)
-  EFI_ACPI_5_0_GIC_DISTRIBUTOR_INIT(0, FixedPcdGet64 (PcdGicDistributorBase), 0)
-#endif
-};
-
-//
-// Reference the table being generated to prevent the optimizer from removing the
-// data structure from the executable
-//
-VOID* CONST ReferenceAcpiTable = &Madt;
diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Pep.asl b/Platform/RaspberryPi/RPi4/AcpiTables/Pep.asl
deleted file mode 100644
index 8a0a44e1c4c9..000000000000
--- a/Platform/RaspberryPi/RPi4/AcpiTables/Pep.asl
+++ /dev/null
@@ -1,90 +0,0 @@
-/** @file
- *
- *  Platform Extension Plugin (PEP).
- *
- *  Copyright (c) 2019, ARM Ltd. All rights reserved.
- *  Copyright (c) 2018, Andrey Warkentin <andrey.warkentin@gmail.com>
- *  Copyright (c) Microsoft Corporation. All rights reserved.
- *
- *  SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-Device(PEPD)
-{
-  //
-  // PEP virtual device.
-  //
-  Name (_HID, "BCM2854") // Note: Since PEP on RPi is a virtual device,
-  Name (_CID, "BCM2854") // its device id needs to be generated by Microsoft
-  Name (_UID, 0x0)
-  Name (_CRS, ResourceTemplate ()
-  {
-    // No hardware resources for PEP driver are needed.
-  })
-
-  //
-  // Processor info. PEP proprietary method to return
-  // PEP_PROCESSOR_TABLE_PLAT structure.
-  //
-  // See Pep.h and Pep.c.
-  //
-  Name (_GPI, Buffer()
-  {
-    0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5C, 0x00, 0x5F, 0x00, 0x53,
-    0x00, 0x42, 0x00, 0x2E, 0x00, 0x43, 0x00, 0x50, 0x00, 0x55, 0x00, 0x30,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-  })
-
-  //
-  // Coordinated state info. PEP proprietary method to return
-  // PEP_COORDINATED_STATE_TABLE_PLAT structure.
-  //
-  // See Pep.h and Pep.c.
-  //
-  Name (_GCI, Buffer()
-  {
-    0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
-    0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00
-  })
-
-  //
-  // Device info. PEP proprietary method to return
-  // PEP_DEVICE_TABLE_PLAT structure.
-  //
-  // See Pep.h and Pep.c.
-  //
-  Name (_GDI, Buffer()
-  {
-    0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5C, 0x00, 0x5F, 0x00, 0x53,
-    0x00, 0x42, 0x00, 0x2E, 0x00, 0x49, 0x00, 0x32, 0x00, 0x43, 0x00, 0x30,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09,
-    0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-  })
-}
diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Pep.c b/Platform/RaspberryPi/RPi4/AcpiTables/Pep.c
deleted file mode 100644
index f452580c703d..000000000000
--- a/Platform/RaspberryPi/RPi4/AcpiTables/Pep.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/** @file
- *
- *  PEP device tables
- *
- *  Copyright (c) 2019, ARM Ltd. All rights reserved.
- *  Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
- *  Copyright (c) Microsoft Corporation. All rights reserved.
- *
- *  SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include "Pep.h"
-
-PEP_PROCESSOR_TABLE_PLAT RpiProcessors = {
-  1, // Version
-  1, // NumberProcessors
-  {  // ProcessorInfo
-    { // [0]
-      L"\\_SB.CPU0", // DevicePath, wchar_t[16]
-      0, // FeedbackCounterCount
-      0x00000000, // Flags
-      0, // NumberIdleStates
-      0, // NumberPerfStates
-      { // IdleInfo
-      },
-      { // perfinfo
-      }
-    }
-  }
-};
-
-PEP_COORDINATED_STATE_TABLE_PLAT RpiCoordinatedStates = {
-  1, // Version
-  1, // CoordinatedStateCount
-  { // CordinatedStates[]
-    { // [0]
-      { // DependencyInfo
-        { // [0]
-          1, // ExpectedState
-          0, // TargetProcessor
-          0x0 | 0x2 | 0x4, // LooseDependency = FALSE, InitialState = TRUE, DependentState = TRUE
-        }
-      },
-      SOC_STATE_TYPE, // StateType
-      0x1, // Flags
-      0, // Latency
-      0, // BreakEvenDuration
-      1, // DependencyCount
-      1, // MaximumDependencySize
-    }
-  }
-};
-
-PEP_DEVICE_TABLE_PLAT RpiDevices = {
-  1, // Version
-  1, // NumberDevices
-  { // DeviceInfo
-    { // [1]
-      L"\\_SB.I2C0", // DevicePath, wchar_t[16]
-      0x1 | (1 << 3), // DStateSupportMask (D0 and D3)
-      1, // NumberCompoenents
-      { // DStateRequirement
-        { // [0]
-          PowerDeviceD3 // DState
-        }
-      },
-      { // FStateRequirement
-        { // [0]
-          { // FState
-            { // [0]
-              0
-            }
-          }
-        }
-      }
-    }
-  }
-};
diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Pep.h b/Platform/RaspberryPi/RPi4/AcpiTables/Pep.h
deleted file mode 100644
index 30f6768f12a5..000000000000
--- a/Platform/RaspberryPi/RPi4/AcpiTables/Pep.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/** @file
- *
- *  PEP device defines
- *
- *  Copyright (c) 2019, ARM Ltd. All rights reserved.
- *  Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
- *  Copyright (c) Microsoft Corporation. All rights reserved.
- *
- *  SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-/*
- * Note: Not everything is here. At least SOC_STATE_TYPE is missing.
- */
-
-#ifndef _RPI_PEP_H_INCLUDED_
-#define _RPI_PEP_H_INCLUDED_
-
-#include <IndustryStandard/Acpi.h>
-
-#define PEP_MAX_DEPENDENCIES_PER_STATE 16
-#define MAX_PROCESSOR_PATH_LENGTH 16
-#define MAX_DEVICE_PATH_LENGTH 32
-#define MAX_COMPONENT_COUNT 8
-#define P_NUMBER_PROCESSORS 1
-#define P_NUMBER_IDLE_STATES 1
-#define P_NUMBER_PERF_STATES 0
-#define P_NUMBER_DEVICES 1
-#define P_NUMBER_COORDINATED_STATS 1
-
-typedef struct _PEP_PROCESSOR_IDLE_STATE_INFO {
-  UINT32 Ulong;
-  UINT32 Latency;
-  UINT32 BreakEvenDuration;
-} PEP_PROCESSOR_IDLE_STATE_INFO, *PEP_PROCESSOR_IDLE_STATE_INFO;
-
-typedef struct _PEP_PROCESSOR_IDLE_INFO_PLAT {
-  //
-  // Processor idle states.
-  //
-  PEP_PROCESSOR_IDLE_STATE_INFO IdleStates[P_NUMBER_IDLE_STATES];
-} PEP_PROCESSOR_IDLE_INFO_PLAT, *PPEP_PROCESSOR_IDLE_INFO_PLAT;
-
-typedef struct COORDINATED_DEPENDENCY_INFO {
-  UINT32 ExpectedState;
-  UINT32 TargetProcessor;
-  UINT32 Ulong;
-} COORDINATED_DEPENDENCY_INFO, *PCOORDINATED_DEPENDENCY_INFO;
-
-typedef struct {
-  COORDINATED_DEPENDENCY_INFO DependencyInfo[PEP_MAX_DEPENDENCIES_PER_STATE];
-  UINT32 StateType;
-  UINT32 Ulong;
-  UINT32 Latency;
-  UINT32 BreakEvenDuration;
-  UINT32 DependencyCount;
-  UINT32 MaximumDependencySize;
-} COORDINATED_STATE_INFO;
-
-typedef struct {
-  UINT32 Unused;
-} PEP_PROCESSOR_PERF_INFO;
-
-typedef struct {
-  UINT32 FState[MAX_COMPONENT_COUNT];
-} COORDINATED_FSTATE_REQUIREMENT;
-
-typedef struct {
-  UINT32 DState;
-} COORDINATED_DSTATE_REQUIREMENT;
-
-//
-// Top level device table
-// *N.B. The exact length of the structure is determined by the NumberIdleStates/NumberPerfStates variables.
-//
-
-typedef struct _PEP_PROCESSOR_INFO_PLAT {
-  WCHAR DevicePath[MAX_PROCESSOR_PATH_LENGTH]; // Null-terminated ACPI name
-  ULONG FeedbackCounterCount;
-  ULONG Flags;
-
-  //
-  // We are putting the idle/perf state count here (instead
-  // of the PEP_PROCESSOR_xxx_INFO structure for the ease of parsing.
-  //
-  ULONG NumberIdleStates;
-  ULONG NumberPerfStates;
-
-  PEP_PROCESSOR_IDLE_INFO_PLAT IdleInfo;
-  PEP_PROCESSOR_PERF_INFO PerfInfo;
-} PEP_PROCESSOR_INFO_PLAT, *PPEP_PROCESSOR_INFO_PLAT;
-
-typedef struct _PEP_PROCESSOR_TABLE_PLAT {
-  UINT32 Version;
-  UINT32 NumberProcessors;
-  PEP_PROCESSOR_INFO_PLAT ProcessorInfo[P_NUMBER_PROCESSORS];
-} PEP_PROCESSOR_TABLE_PLAT;
-
-typedef struct _PEP_COORDINATED_STATE_TABLE_PLAT {
-  ULONG Version;
-  ULONG CoordinatedStateCount;
-  COORDINATED_STATE_INFO CoordinatedStates[P_NUMBER_COORDINATED_STATS];
-} PEP_COORDINATED_STATE_TABLE_PLAT, *PPEP_COORDINATED_STATE_TABLE_PLAT;
-
-typedef struct _PEP_DEVICE_INFO_PLAT {
-  WCHAR DevicePath[MAX_DEVICE_PATH_LENGTH]; // Null-terminated ACPI name
-  ULONG DStateSupportMask;
-  ULONG NumberComponents;
-
-  COORDINATED_DSTATE_REQUIREMENT DStateRequirement[P_NUMBER_COORDINATED_STATS];
-  COORDINATED_FSTATE_REQUIREMENT FStateRequirement[P_NUMBER_COORDINATED_STATS];
-} PEP_DEVICE_INFO_PLAT, *PPEP_DEVICE_INFO_PLAT;
-
-typedef struct _PEP_DEVICE_TABLE_PLAT {
-  ULONG Version;
-  ULONG NumberDevices;
-  PEP_DEVICE_INFO_PLAT DeviceInfo[P_NUMBER_DEVICES];
-} PEP_DEVICE_TABLE_PLAT, *PPEP_DEVICE_TABLE_PLAT;
-
-#endif // _RPI_PEP_H_INCLUDED_
diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Rhpx.asl b/Platform/RaspberryPi/RPi4/AcpiTables/Rhpx.asl
deleted file mode 100644
index 0971e13ee013..000000000000
--- a/Platform/RaspberryPi/RPi4/AcpiTables/Rhpx.asl
+++ /dev/null
@@ -1,195 +0,0 @@
-/** @file
- *
- *  [DSDT] RHProxy device to enable WinRT API (RHPX)
- *
- *  Copyright (c) 2018, Andrey Warkentin <andrey.warkentin@gmail.com>
- *  Copyright (c) Microsoft Corporation. All rights reserved.
- *
- *  SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-Device (RHPX)
-{
-  Name (_HID, "MSFT8000")
-  Name (_CID, "MSFT8000")
-  Name (_UID, 1)
-
-  Name(_CRS, ResourceTemplate ()
-  {
-    // Index 0
-    SPISerialBus (           // SCKL - GPIO 11 - Pin 23
-                             // MOSI - GPIO 10 - Pin 19
-                             // MISO - GPIO 9  - Pin 21
-                             // CE0  - GPIO 8  - Pin 24
-      0,                     // Device selection (CE0)
-      PolarityLow,           // Device selection polarity
-      FourWireMode,          // WireMode
-      8,                     // DataBit len
-      ControllerInitiated,   // Slave mode
-      4000000,               // Connection speed
-      ClockPolarityLow,      // Clock polarity
-      ClockPhaseFirst,       // Clock phase
-      "\\_SB.SPI0",          // ResourceSource: SPI bus controller name
-      0,                     // ResourceSourceIndex
-                             // Resource usage
-                             // DescriptorName: creates name for offset of resource descriptor
-    )                        // Vendor Data
-
-    // Index 1
-    SPISerialBus (           // SCKL - GPIO 11 - Pin 23
-                             // MOSI - GPIO 10 - Pin 19
-                             // MISO - GPIO 9  - Pin 21
-                             // CE1  - GPIO 7  - Pin 26
-      1,                     // Device selection (CE1)
-      PolarityLow,           // Device selection polarity
-      FourWireMode,          // WireMode
-      8,                     // DataBit len
-      ControllerInitiated,   // Slave mode
-      4000000,               // Connection speed
-      ClockPolarityLow,      // Clock polarity
-      ClockPhaseFirst,       // Clock phase
-      "\\_SB.SPI0",          // ResourceSource: SPI bus controller name
-      0,                     // ResourceSourceIndex
-                             // Resource usage
-                             // DescriptorName: creates name for offset of resource descriptor
-    )                        // Vendor Data
-
-    // Index 2
-    I2CSerialBus (           // Pin 3 (GPIO2, SDA1), 5 (GPIO3, SCL1)
-      0xFFFF,                // SlaveAddress: placeholder
-      ,                      // SlaveMode: default to ControllerInitiated
-      0,                     // ConnectionSpeed: placeholder
-      ,                      // Addressing Mode: default to 7 bit
-      "\\_SB.I2C1",          // ResourceSource: I2C bus controller name
-      ,
-      ,
-      ,                      // Descriptor Name: creates name for offset of resource descriptor
-    )                        // Vendor Data
-
-    // Index 3
-    SPISerialBus (           // SPI1_SCLK - GPIO21
-                             // SPI1_MOSI - GPIO20
-                             // SPI1_MISO - GPIO19
-                             // SPI1_CE2_N - GPIO16
-      2,                     // Device selection (CE2)
-      PolarityLow,           // Device selection polarity
-      FourWireMode,          // WireMode
-      8,                     // DataBit len
-      ControllerInitiated,   // Slave mode
-      4000000,               // Connection speed
-      ClockPolarityLow,      // Clock polarity
-      ClockPhaseFirst,       // Clock phase
-      "\\_SB.SPI1",          // ResourceSource: SPI bus controller name
-      0,                     // ResourceSourceIndex
-                             // Resource usage
-                             // DescriptorName: creates name for offset of resource descriptor
-    )                        // Vendor Data
-
-    // GPIO 2
-    GpioIO (Shared, PullUp, 0, 0, IoRestrictionNone, "\\_SB.GPI0", 0, ResourceConsumer,,) { 2 }
-    GpioInt (Edge, ActiveBoth, Shared, PullUp, 0, "\\_SB.GPI0",)                          { 2 }
-    // GPIO 3
-    GpioIO (Shared, PullUp, 0, 0, IoRestrictionNone, "\\_SB.GPI0", 0, ResourceConsumer,,) { 3 }
-    GpioInt (Edge, ActiveBoth, Shared, PullUp, 0, "\\_SB.GPI0",)                          { 3 }
-    // GPIO 4
-    GpioIO (Shared, PullUp, 0, 0, IoRestrictionNone, "\\_SB.GPI0", 0, ResourceConsumer,,) { 4 }
-    GpioInt (Edge, ActiveBoth, Shared, PullUp, 0, "\\_SB.GPI0",)                          { 4 }
-    // GPIO 5
-    GpioIO (Shared, PullUp, 0, 0, IoRestrictionNone, "\\_SB.GPI0", 0, ResourceConsumer,,) { 5 }
-    GpioInt (Edge, ActiveBoth, Shared, PullUp, 0, "\\_SB.GPI0",)                          { 5 }
-    // GPIO 6
-    GpioIO (Shared, PullUp, 0, 0, IoRestrictionNone, "\\_SB.GPI0", 0, ResourceConsumer,,) { 6 }
-    GpioInt (Edge, ActiveBoth, Shared, PullUp, 0, "\\_SB.GPI0",)                          { 6 }
-    // GPIO 7
-    GpioIO (Shared, PullUp, 0, 0, IoRestrictionNone, "\\_SB.GPI0", 0, ResourceConsumer,,) { 7 }
-    GpioInt (Edge, ActiveBoth, Shared, PullUp, 0, "\\_SB.GPI0",)                          { 7 }
-    // GPIO 8
-    GpioIO (Shared, PullUp, 0, 0, IoRestrictionNone, "\\_SB.GPI0", 0, ResourceConsumer,,) { 8 }
-    GpioInt (Edge, ActiveBoth, Shared, PullUp, 0, "\\_SB.GPI0",)                          { 8 }
-    // GPIO 9
-    GpioIO (Shared, PullDown, 0, 0, IoRestrictionNone, "\\_SB.GPI0", 0, ResourceConsumer,,) { 9 }
-    GpioInt (Edge, ActiveBoth, Shared, PullDown, 0, "\\_SB.GPI0",)                          { 9 }
-    // GPIO 10
-    GpioIO (Shared, PullDown, 0, 0, IoRestrictionNone, "\\_SB.GPI0", 0, ResourceConsumer,,) { 10 }
-    GpioInt (Edge, ActiveBoth, Shared, PullDown, 0, "\\_SB.GPI0",)                          { 10 }
-    // GPIO 11
-    GpioIO (Shared, PullDown, 0, 0, IoRestrictionNone, "\\_SB.GPI0", 0, ResourceConsumer,,) { 11 }
-    GpioInt (Edge, ActiveBoth, Shared, PullDown, 0, "\\_SB.GPI0",)                          { 11 }
-    // GPIO 12
-    GpioIO (Shared, PullDown, 0, 0, IoRestrictionNone, "\\_SB.GPI0", 0, ResourceConsumer,,) { 12 }
-    GpioInt (Edge, ActiveBoth, Shared, PullDown, 0, "\\_SB.GPI0",)                          { 12 }
-    // GPIO 13
-    GpioIO (Shared, PullDown, 0, 0, IoRestrictionNone, "\\_SB.GPI0", 0, ResourceConsumer,,) { 13 }
-    GpioInt (Edge, ActiveBoth, Shared, PullDown, 0, "\\_SB.GPI0",)                          { 13 }
-    // NTRAID#MSFT-7141401-2016/04/7-jordanrh - disable UART muxing
-    // until a proper solution can be created for the dmap conflict
-    // GPIO 14 - UART TX
-    // GpioIO (Shared, PullDown, 0, 0, IoRestrictionNone, "\\_SB.GPI0", 0, ResourceConsumer,,) { 14 }
-    // GpioInt (Edge, ActiveBoth, Shared, PullDown, 0, "\\_SB.GPI0",)                          { 14 }
-    // GPIO 15 - UART RX
-    // GpioIO (Shared, PullDown, 0, 0, IoRestrictionNone, "\\_SB.GPI0", 0, ResourceConsumer,,) { 15 }
-    // GpioInt (Edge, ActiveBoth, Shared, PullDown, 0, "\\_SB.GPI0",)                          { 15 }
-    // GPIO 16
-    GpioIO (Shared, PullDown, 0, 0, IoRestrictionNone, "\\_SB.GPI0", 0, ResourceConsumer,,) { 16 }
-    GpioInt (Edge, ActiveBoth, Shared, PullDown, 0, "\\_SB.GPI0",)                          { 16 }
-    // GPIO 17
-    GpioIO (Shared, PullDown, 0, 0, IoRestrictionNone, "\\_SB.GPI0", 0, ResourceConsumer,,) { 17 }
-    GpioInt (Edge, ActiveBoth, Shared, PullDown, 0, "\\_SB.GPI0",)                          { 17 }
-    // GPIO 18
-    GpioIO (Shared, PullDown, 0, 0, IoRestrictionNone, "\\_SB.GPI0", 0, ResourceConsumer,,) { 18 }
-    GpioInt (Edge, ActiveBoth, Shared, PullDown, 0, "\\_SB.GPI0",)                          { 18 }
-    // GPIO 19
-    GpioIO (Shared, PullDown, 0, 0, IoRestrictionNone, "\\_SB.GPI0", 0, ResourceConsumer,,) { 19 }
-    GpioInt (Edge, ActiveBoth, Shared, PullDown, 0, "\\_SB.GPI0",)                          { 19 }
-    // GPIO 20
-    GpioIO (Shared, PullDown, 0, 0, IoRestrictionNone, "\\_SB.GPI0", 0, ResourceConsumer,,) { 20 }
-    GpioInt (Edge, ActiveBoth, Shared, PullDown, 0, "\\_SB.GPI0",)                          { 20 }
-    // GPIO 21
-    GpioIO (Shared, PullDown, 0, 0, IoRestrictionNone, "\\_SB.GPI0", 0, ResourceConsumer,,) { 21 }
-    GpioInt (Edge, ActiveBoth, Shared, PullDown, 0, "\\_SB.GPI0",)                          { 21 }
-    // GPIO 22
-    GpioIO (Shared, PullDown, 0, 0, IoRestrictionNone, "\\_SB.GPI0", 0, ResourceConsumer,,) { 22 }
-    GpioInt (Edge, ActiveBoth, Shared, PullDown, 0, "\\_SB.GPI0",)                          { 22 }
-    // GPIO 23
-    GpioIO (Shared, PullDown, 0, 0, IoRestrictionNone, "\\_SB.GPI0", 0, ResourceConsumer,,) { 23 }
-    GpioInt (Edge, ActiveBoth, Shared, PullDown, 0, "\\_SB.GPI0",)                          { 23 }
-    // GPIO 24
-    GpioIO (Shared, PullDown, 0, 0, IoRestrictionNone, "\\_SB.GPI0", 0, ResourceConsumer,,) { 24 }
-    GpioInt (Edge, ActiveBoth, Shared, PullDown, 0, "\\_SB.GPI0",)                          { 24 }
-    // GPIO 25
-    GpioIO (Shared, PullDown, 0, 0, IoRestrictionNone, "\\_SB.GPI0", 0, ResourceConsumer,,) { 25 }
-    GpioInt (Edge, ActiveBoth, Shared, PullDown, 0, "\\_SB.GPI0",)                          { 25 }
-    // GPIO 26
-    GpioIO (Shared, PullDown, 0, 0, IoRestrictionNone, "\\_SB.GPI0", 0, ResourceConsumer,,) { 26 }
-    GpioInt (Edge, ActiveBoth, Shared, PullDown, 0, "\\_SB.GPI0",)                          { 26 }
-    // GPIO 27
-    GpioIO (Shared, PullDown, 0, 0, IoRestrictionNone, "\\_SB.GPI0", 0, ResourceConsumer,,) { 27 }
-    GpioInt (Edge, ActiveBoth, Shared, PullDown, 0, "\\_SB.GPI0",)                          { 27 }
-  })
-
-  Name (_DSD, Package()
-  {
-    ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
-    Package ()
-    {
-      // Reference http://www.raspberrypi.org/documentation/hardware/raspberrypi/spi/README.md
-      // SPI 0
-      Package (2) { "bus-SPI-SPI0", Package() { 0, 1 } },                   // Index 0 & 1
-      Package (2) { "SPI0-MinClockInHz", 7629 },                            // 7629 Hz
-      Package (2) { "SPI0-MaxClockInHz", 125000000 },                       // 125 MHz
-      Package (2) { "SPI0-SupportedDataBitLengths", Package() { 8 } },      // Data Bit Length
-      // I2C1
-      Package (2) { "bus-I2C-I2C1", Package() { 2 } },
-      // GPIO Pin Count and supported drive modes
-      Package (2) { "GPIO-PinCount", 54 },
-      Package (2) { "GPIO-UseDescriptorPinNumbers", 1 },
-      Package (2) { "GPIO-SupportedDriveModes", 0xf },                      // InputHighImpedance, InputPullUp, InputPullDown, OutputCmos
-      // SPI 1
-      Package (2) { "bus-SPI-SPI1", Package() { 3 }},                       // Index 3
-      Package (2) { "SPI1-MinClockInHz", 30511 },                           // 30.5 kHz
-      Package (2) { "SPI1-MaxClockInHz", 20000000 },                        // 20 MHz
-      Package (2) { "SPI1-SupportedDataBitLengths", Package() { 8 } },      // Data Bit Length
-    }
-  })
-}
diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Sdhc.asl b/Platform/RaspberryPi/RPi4/AcpiTables/Sdhc.asl
deleted file mode 100644
index 0ab1ba27f2cf..000000000000
--- a/Platform/RaspberryPi/RPi4/AcpiTables/Sdhc.asl
+++ /dev/null
@@ -1,107 +0,0 @@
-/** @file
- *
- *  [DSDT] SD controller/card definition (SDHC)
- *
- *  Copyright (c) 2020, Pete Batard <pete@akeo.ie>
- *  Copyright (c) 2018, Andrey Warkentin <andrey.warkentin@gmail.com>
- *  Copyright (c) Microsoft Corporation. All rights reserved.
- *
- *  SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include <IndustryStandard/Bcm2836SdHost.h>
-#include <IndustryStandard/Bcm2836Sdio.h>
-
-#include "AcpiTables.h"
-
-//
-// Note: UEFI can use either SDHost or Arasan. We expose both to the OS.
-//
-
-// ArasanSD 3.0 SD Host Controller.
-Device (SDC1)
-{
-  Name (_HID, "BCM2847")
-  Name (_CID, "ARASAN")
-  Name (_UID, 0x0)
-  Name (_CCA, 0x0)
-  Name (_S1D, 0x1)
-  Name (_S2D, 0x1)
-  Name (_S3D, 0x1)
-  Name (_S4D, 0x1)
-  Method (_STA)
-  {
-    Return(0xf)
-  }
-  Name (RBUF, ResourceTemplate ()
-  {
-    MEMORY32FIXED (ReadWrite, 0, MMCHS1_LENGTH, RMEM)
-    Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_MMCHS1_INTERRUPT }
-  })
-  Method (_CRS, 0x0, Serialized)
-  {
-    MEMORY32SETBASE (RBUF, RMEM, RBAS, MMCHS1_OFFSET)
-    Return (^RBUF)
-  }
-
-  //
-  // A child device that represents the
-  // sd card, which is marked as non-removable.
-  //
-  Device (SDMM)
-  {
-    Method (_ADR)
-    {
-      Return (0)
-    }
-    Method (_RMV) // Is removable
-    {
-      Return (0) // 0 - fixed
-    }
-  }
-}
-
-
-// Broadcom SDHost 2.0 SD Host Controller
-Device (SDC2)
-{
-  Name (_HID, "BCM2855")
-  Name (_CID, "SDHST")
-  Name (_UID, 0x0)
-  Name (_CCA, 0x0)
-  Name (_S1D, 0x1)
-  Name (_S2D, 0x1)
-  Name (_S3D, 0x1)
-  Name (_S4D, 0x1)
-  Method (_STA)
-  {
-    Return (0xf)
-  }
-  Name (RBUF, ResourceTemplate ()
-  {
-    MEMORY32FIXED (ReadWrite, 0, SDHOST_LENGTH, RMEM)
-    Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_SDHOST_INTERRUPT }
-  })
-  Method (_CRS, 0x0, Serialized)
-  {
-    MEMORY32SETBASE (RBUF, RMEM, RBAS, SDHOST_OFFSET)
-    Return (^RBUF)
-  }
-
-  //
-  // A child device that represents the
-  // sd card, which is marked as non-removable.
-  //
-  Device (SDMM)
-  {
-    Method (_ADR)
-    {
-      Return (0)
-    }
-    Method (_RMV) // Is removable
-    {
-      Return (0) // 0 - fixed
-    }
-  }
-}
diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Spcr.aslc b/Platform/RaspberryPi/RPi4/AcpiTables/Spcr.aslc
deleted file mode 100644
index bec4ad660ec9..000000000000
--- a/Platform/RaspberryPi/RPi4/AcpiTables/Spcr.aslc
+++ /dev/null
@@ -1,97 +0,0 @@
-/** @file
-* SPCR Table
-*
-* Copyright (c) 2019 Pete Batard <pete@akeo.ie>
-* Copyright (c) 2014-2016, ARM Limited. All rights reserved.
-*
-* SPDX-License-Identifier: BSD-2-Clause-Patent
-*
-**/
-
-#include <IndustryStandard/Acpi.h>
-#include <IndustryStandard/Bcm2836.h>
-#include <IndustryStandard/SerialPortConsoleRedirectionTable.h>
-#include <Library/AcpiLib.h>
-#include <Library/PcdLib.h>
-
-#include "AcpiTables.h"
-
-#define RPI_UART_FLOW_CONTROL_NONE           0
-
-// Prefer PL011 serial output on the Raspberry Pi 4
-#if (RPI_MODEL == 4)
-#define RPI_UART_INTERFACE_TYPE              EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_INTERFACE_TYPE_ARM_PL011_UART
-#define RPI_UART_BASE_ADDRESS                BCM2836_PL011_UART_BASE_ADDRESS
-#define RPI_UART_INTERRUPT                   BCM2836_PL011_UART_INTERRUPT
-#else
-#define RPI_UART_INTERFACE_TYPE              EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_INTERFACE_TYPE_BCM2835_UART
-#define RPI_UART_BASE_ADDRESS                BCM2836_MINI_UART_BASE_ADDRESS
-#define RPI_UART_INTERRUPT                   BCM2836_MINI_UART_INTERRUPT
-#endif
-STATIC EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE Spcr = {
-  ACPI_HEADER (
-    EFI_ACPI_5_1_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE,
-    EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE,
-    EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_REVISION
-  ),
-  // UINT8                                   InterfaceType;
-  RPI_UART_INTERFACE_TYPE,
-  // UINT8                                   Reserved1[3];
-  {
-    EFI_ACPI_RESERVED_BYTE,
-    EFI_ACPI_RESERVED_BYTE,
-    EFI_ACPI_RESERVED_BYTE
-  },
-  // EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE  BaseAddress;
-  ARM_GAS32 (RPI_UART_BASE_ADDRESS),
-  // UINT8                                   InterruptType;
-  EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_INTERRUPT_TYPE_GIC,
-  // UINT8                                   Irq;
-  0,                                         // Not used on ARM
-  // UINT32                                  GlobalSystemInterrupt;
-  RPI_UART_INTERRUPT,
-  // UINT8                                   BaudRate;
-#if (FixedPcdGet64 (PcdUartDefaultBaudRate) == 9600)
-  EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_BAUD_RATE_9600,
-#elif (FixedPcdGet64 (PcdUartDefaultBaudRate) == 19200)
-  EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_BAUD_RATE_19200,
-#elif (FixedPcdGet64 (PcdUartDefaultBaudRate) == 57600)
-  EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_BAUD_RATE_57600,
-#elif (FixedPcdGet64 (PcdUartDefaultBaudRate) == 115200)
-  EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_BAUD_RATE_115200,
-#else
-#error Unsupported SPCR Baud Rate
-#endif
-  // UINT8                                   Parity;
-  EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_PARITY_NO_PARITY,
-  // UINT8                                   StopBits;
-  EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_STOP_BITS_1,
-  // UINT8                                   FlowControl;
-  RPI_UART_FLOW_CONTROL_NONE,
-  // UINT8                                   TerminalType;
-  EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_TERMINAL_TYPE_VT_UTF8,
-  // UINT8                                   Reserved2;
-  EFI_ACPI_RESERVED_BYTE,
-  // UINT16                                  PciDeviceId;
-  0xFFFF,
-  // UINT16                                  PciVendorId;
-  0xFFFF,
-  // UINT8                                   PciBusNumber;
-  0x00,
-  // UINT8                                   PciDeviceNumber;
-  0x00,
-  // UINT8                                   PciFunctionNumber;
-  0x00,
-  // UINT32                                  PciFlags;
-  0x00000000,
-  // UINT8                                   PciSegment;
-  0x00,
-  // UINT32                                  Reserved3;
-  EFI_ACPI_RESERVED_DWORD
-};
-
-//
-// Reference the table being generated to prevent the optimizer from removing the
-// data structure from the executable
-//
-VOID* CONST ReferenceAcpiTable = &Spcr;
diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Uart.asl b/Platform/RaspberryPi/RPi4/AcpiTables/Uart.asl
deleted file mode 100644
index c466247bb33b..000000000000
--- a/Platform/RaspberryPi/RPi4/AcpiTables/Uart.asl
+++ /dev/null
@@ -1,163 +0,0 @@
-/** @file
- *
- *  [DSDT] Serial devices (UART).
- *
- *  Copyright (c) 2020, Pete Batard <pete@akeo.ie>
- *  Copyright (c) 2018, Andrey Warkentin <andrey.warkentin@gmail.com>
- *  Copyright (c) Microsoft Corporation. All rights reserved.
- *
- *  SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include <IndustryStandard/Bcm2836.h>
-
-#include "AcpiTables.h"
-
-// PL011 based UART.
-Device (URT0)
-{
-  Name (_HID, "BCM2837")
-  Name (_CID, "ARMH0011")
-  Name (_UID, 0x4)
-  Name (_CCA, 0x0)
-  Method (_STA)
-  {
-    Return (0xf)
-  }
-  Name (RBUF, ResourceTemplate ()
-  {
-    MEMORY32FIXED (ReadWrite, 0, BCM2836_PL011_UART_LENGTH, RMEM)
-    Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_PL011_UART_INTERRUPT }
-  })
-  Method (_CRS, 0x0, Serialized)
-  {
-    MEMORY32SETBASE (RBUF, RMEM, RBAS, BCM2836_PL011_UART_OFFSET)
-    Return (^RBUF)
-  }
-
-  Name (CLCK, 48000000)
-
-  Name (_DSD, Package ()
-  {
-    ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), Package ()
-    {
-      Package (2) { "clock-frequency", CLCK },
-    }
-  })
-}
-
-//
-// UART Mini.
-//
-// This device is referenced in the DBG2 table, which will cause the system to
-// not start the driver when the debugger is enabled and to mark the device
-// with problem code 53 (CM_PROB_USED_BY_DEBUGGER).
-//
-
-Device (URTM)
-{
-  Name (_HID, "BCM2836")
-  Name (_CID, "MINIUART")
-  Name (_UID, 0x0)
-  Name (_CCA, 0x0)
-  Method (_STA)
-  {
-    Return (0xf)
-  }
-  Name (RBUF, ResourceTemplate ()
-  {
-    MEMORY32FIXED (ReadWrite, 0, BCM2836_MINI_UART_LENGTH, RMEM)
-    Interrupt(ResourceConsumer, Level, ActiveHigh, Shared) { BCM2836_MINI_UART_INTERRUPT }
-
-    // NTRAID#MSFT-7141401-2016/04/7-jordanrh - disable UART muxing
-    // until a proper solution can be created for the dmap conflict.
-    // When muxing is enabled, must consider DBG2 table conflict.
-    // The alternate function resource needs to be reserved when
-    // the kernel debugger is enabled to prevent another client
-    // from muxing the pins away.
-
-    //
-    // MsftFunctionConfig is encoded as the VendorLong.
-    //
-    // MsftFunctionConfig(Exclusive, PullDown, BCM_ALT5, "\\_SB.GPI0", 0, ResourceConsumer, ) {14, 15}
-    // VendorLong  ()      // Length = 0x31
-    // {
-    //   /* 0000 */  0x00, 0x60, 0x44, 0xD5, 0xF3, 0x1F, 0x11, 0x60,  // .`D....`
-    //   /* 0008 */  0x4A, 0xB8, 0xB0, 0x9C, 0x2D, 0x23, 0x30, 0xDD,  // J...-#0.
-    //   /* 0010 */  0x2F, 0x8D, 0x1D, 0x00, 0x01, 0x10, 0x00, 0x02,  // /.......
-    //   /* 0018 */  0x02, 0x00, 0x12, 0x00, 0x00, 0x16, 0x00, 0x20,  // .......
-    //   /* 0020 */  0x00, 0x00, 0x00, 0x0E, 0x00, 0x0F, 0x00, 0x5C,  // .......\
-    //   /* 0028 */  0x5F, 0x53, 0x42, 0x2E, 0x47, 0x50, 0x49, 0x30,  // _SB.GPI0
-    //   /* 0030 */  0x00                                             // .
-    //}
-
-  })
-  Method (_CRS, 0x0, Serialized)
-  {
-    MEMORY32SETBASE (RBUF, RMEM, RBAS, BCM2836_MINI_UART_OFFSET)
-    Return (^RBUF)
-  }
-}
-
-//
-// Multifunction serial bus device to support Bluetooth function.
-//
-Device(BTH0)
-{
-  Name (_HID, "BCM2EA6")
-  Name (_CID, "BCM2EA6")
-  Method (_STA)
-  {
-    Return (0xf)
-  }
-  Method (_CRS, 0x0, Serialized)
-  {
-    Name (RBUF, ResourceTemplate ()
-    {
-      // BT UART: URT0 (PL011) or URTM (miniUART)
-      UARTSerialBus(
-        115200,        // InitialBaudRate: in BPS
-        ,              // BitsPerByte: default to 8 bits
-        ,              // StopBits: Defaults to one bit
-        0x00,          // LinesInUse: 8 1-bit flags to
-                       //   declare enabled control lines.
-                       //   Raspberry Pi does not exposed
-                       //   HW control signals -> not supported.
-                       //   Optional bits:
-                       //   - Bit 7 (0x80) Request To Send (RTS)
-                       //   - Bit 6 (0x40) Clear To Send (CTS)
-                       //   - Bit 5 (0x20) Data Terminal Ready (DTR)
-                       //   - Bit 4 (0x10) Data Set Ready (DSR)
-                       //   - Bit 3 (0x08) Ring Indicator (RI)
-                       //   - Bit 2 (0x04) Data Carrier Detect (DTD)
-                       //   - Bit 1 (0x02) Reserved. Must be 0.
-                       //   - Bit 0 (0x01) Reserved. Must be 0.
-        ,              // IsBigEndian:
-                       //   default to LittleEndian.
-        ,              // Parity: Defaults to no parity
-        ,              // FlowControl: Defaults to
-                       //   no flow control.
-        16,            // ReceiveBufferSize
-        16,            // TransmitBufferSize
-#if (RPI_MODEL == 4)
-        "\\_SB.URTM",  // ResourceSource:
-#else
-        "\\_SB.URT0",  // ResourceSource:
-#endif
-                       //   UART bus controller name
-        ,              // ResourceSourceIndex: assumed to be 0
-        ,              // ResourceUsage: assumed to be
-                       //   ResourceConsumer
-        UAR0,          // DescriptorName: creates name
-                       //   for offset of resource descriptor
-      )                // Vendor data
-
-      //
-      // RPIQ connection for BT_ON/OFF
-      //
-      GpioIO (Shared, PullUp, 0, 0, IoRestrictionNone, "\\_SB.RPIQ", 0, ResourceConsumer, , ) { 128 }
-    })
-    Return (RBUF)
-  }
-}
diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Xhci.asl b/Platform/RaspberryPi/RPi4/AcpiTables/Xhci.asl
deleted file mode 100644
index 0083d1992936..000000000000
--- a/Platform/RaspberryPi/RPi4/AcpiTables/Xhci.asl
+++ /dev/null
@@ -1,136 +0,0 @@
-/** @file
- *
- *  Copyright (c) 2019 Linaro, Limited. All rights reserved.
- *  Copyright (c) 2019 Andrei Warkentin <andrey.warkentin@gmail.com>
- *
- *  SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include <IndustryStandard/Bcm2711.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_WINDOW)
-#define SANITIZED_PCIE_REG_BASE         REMOVE_PARENTHESES(PCIE_REG_BASE)
-
-/*
- * According to UEFI boot log for the VLI device on Pi 4.
- */
-#define XHCI_REG_LENGTH                 0x1000
-
-Device (SCB0) {
-    Name (_HID, "ACPI0004")
-    Name (_UID, 0x0)
-    Name (_CCA, 0x0)
-
-    Method (_CRS, 0, Serialized) { // _CRS: Current Resource Settings
-        /*
-         * Container devices with _DMA must have _CRS, meaning SCB0
-         * to provide all resources that XHC0 consumes (except
-         * interrupts).
-         */
-        Name (RBUF, ResourceTemplate () {
-            QWordMemory (ResourceProducer,
-                ,
-                MinFixed,
-                MaxFixed,
-                NonCacheable,
-                ReadWrite,
-                0x0,
-                SANITIZED_PCIE_CPU_MMIO_WINDOW, // MIN
-                SANITIZED_PCIE_CPU_MMIO_WINDOW, // MAX
-                0x0,
-                0x1,                            // LEN
-                ,
-                ,
-                MMIO
-                )
-        })
-        CreateQwordField (RBUF, MMIO._MAX, MMBE)
-        CreateQwordField (RBUF, MMIO._LEN, MMLE)
-        Add (MMBE, XHCI_REG_LENGTH - 1, MMBE)
-        Add (MMLE, XHCI_REG_LENGTH - 1, MMLE)
-        Return (RBUF)
-    }
-
-    Name (_DMA, ResourceTemplate() {
-        /*
-         * XHC0 is limited to DMA to first 3GB. Note this
-         * only applies to PCIe, not GENET or other devices
-         * next to the A72.
-         */
-        QWordMemory (ResourceConsumer,
-            ,
-            MinFixed,
-            MaxFixed,
-            NonCacheable,
-            ReadWrite,
-            0x0,
-            0x0,        // MIN
-            0xbfffffff, // MAX
-            0x0,        // TRA
-            0xc0000000, // LEN
-            ,
-            ,
-            )
-    })
-
-    Device (XHC0)
-    {
-        Name (_HID, "PNP0D10")      // _HID: Hardware ID
-        Name (_UID, 0x0)            // _UID: Unique ID
-        Name (_CCA, 0x0)            // _CCA: Cache Coherency Attribute
-
-        Method (_CRS, 0, Serialized) { // _CRS: Current Resource Settings
-            Name (RBUF, ResourceTemplate () {
-                QWordMemory (ResourceConsumer,
-                    ,
-                    MinFixed,
-                    MaxFixed,
-                    NonCacheable,
-                    ReadWrite,
-                    0x0,
-                    SANITIZED_PCIE_CPU_MMIO_WINDOW, // MIN
-                    SANITIZED_PCIE_CPU_MMIO_WINDOW, // MAX
-                    0x0,
-                    0x1,                            // LEN
-                    ,
-                    ,
-                    MMIO
-                    )
-                Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, ) {
-                    175
-                }
-            })
-            CreateQwordField (RBUF, MMIO._MAX, MMBE)
-            CreateQwordField (RBUF, MMIO._LEN, MMLE)
-            Add (MMBE, XHCI_REG_LENGTH - 1, MMBE)
-            Add (MMLE, XHCI_REG_LENGTH - 1, MMLE)
-            Return (RBUF)
-        }
-
-        Method (_INI, 0, Serialized) {
-            OperationRegion (PCFG, SystemMemory, SANITIZED_PCIE_REG_BASE + PCIE_EXT_CFG_DATA, 0x1000)
-            Field (PCFG, AnyAcc, NoLock, Preserve) {
-                Offset (0),
-                VNID, 16, // Vendor ID
-                DVID, 16, // Device ID
-                CMND, 16, // Command register
-                STAT, 16, // Status register
-            }
-
-            // Set command register to:
-            // 1) decode MMIO (set bit 1)
-            // 2) enable DMA (set bit 2)
-            // 3) enable interrupts (clear bit 10)
-            Debug = "xHCI enable"
-            Store (0x6, CMND)
-        }
-    }
-}
diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc b/Platform/RaspberryPi/RPi4/RPi4.dsc
index 09bd19e3b724..c039f6df2eb4 100644
--- a/Platform/RaspberryPi/RPi4/RPi4.dsc
+++ b/Platform/RaspberryPi/RPi4/RPi4.dsc
@@ -576,7 +576,7 @@ [Components.common]
   MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
   MdeModulePkg/Universal/Acpi/AcpiPlatformDxe/AcpiPlatformDxe.inf
   MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf
-  Platform/RaspberryPi/$(PLATFORM_NAME)/AcpiTables/AcpiTables.inf
+  Platform/RaspberryPi/AcpiTables/AcpiTables.inf
 
   #
   # SMBIOS Support
diff --git a/Platform/RaspberryPi/RPi4/RPi4.fdf b/Platform/RaspberryPi/RPi4/RPi4.fdf
index 52ae1e5b65cb..b2a6ac9e6c66 100644
--- a/Platform/RaspberryPi/RPi4/RPi4.fdf
+++ b/Platform/RaspberryPi/RPi4/RPi4.fdf
@@ -238,7 +238,7 @@ [FV.FvMain]
   INF MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
   INF MdeModulePkg/Universal/Acpi/AcpiPlatformDxe/AcpiPlatformDxe.inf
   INF MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf
-  INF RuleOverride = ACPITABLE Platform/RaspberryPi/$(PLATFORM_NAME)/AcpiTables/AcpiTables.inf
+  INF RuleOverride = ACPITABLE Platform/RaspberryPi/AcpiTables/AcpiTables.inf
 
   #
   # SMBIOS Support
-- 
2.21.0.windows.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [edk2-platforms][PATCH 04/15] Silicon/BcmGenet: Add missing I/O mapping length and clean up
  2020-02-28 10:38 ` [edk2-platforms][PATCH 04/15] Silicon/BcmGenet: Add missing I/O mapping length and clean up Pete Batard
@ 2020-02-28 10:45   ` Ard Biesheuvel
  2020-02-28 10:51     ` Pete Batard
  0 siblings, 1 reply; 23+ messages in thread
From: Ard Biesheuvel @ 2020-02-28 10:45 UTC (permalink / raw)
  To: Pete Batard
  Cc: edk2-devel-groups-io, Leif Lindholm, Philippe Mathieu-Daudé

On Fri, 28 Feb 2020 at 11:39, Pete Batard <pete@akeo.ie> wrote:
>
> Remove unneeded extra parenthesis on PCD, which can cause problems
> when used with ACPI ASL macros and add an [Includes] section to the
> .inf, so that the Genet.h header can be referenced where required.
>
> Signed-off-by: Pete Batard <pete@akeo.ie>
> ---
>  Silicon/Broadcom/Drivers/Net/BcmGenetDxe/Genet.h | 3 ++-
>  Silicon/Broadcom/Drivers/Net/BcmNet.dec          | 3 +++
>  2 files changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/Genet.h b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/Genet.h
> index 4a3827c0e0d1..f56fb2977422 100644
> --- a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/Genet.h
> +++ b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/Genet.h
> @@ -11,7 +11,8 @@
>
>  #include <Library/PcdLib.h>
>
> -#define GENET_BASE_ADDRESS         (FixedPcdGet64 (PcdBcmGenetRegistersAddress))
> +#define GENET_BASE_ADDRESS         FixedPcdGet64 (PcdBcmGenetRegistersAddress)
> +#define GENET_LENGTH               0x00010000
>
>  #define GENET_SYS_RBUF_FLUSH_CTRL  0x0008
>  #define GENET_UMAC_MAC0            0x080c
> diff --git a/Silicon/Broadcom/Drivers/Net/BcmNet.dec b/Silicon/Broadcom/Drivers/Net/BcmNet.dec
> index 2a8688cb09a7..483b033af51c 100644
> --- a/Silicon/Broadcom/Drivers/Net/BcmNet.dec
> +++ b/Silicon/Broadcom/Drivers/Net/BcmNet.dec
> @@ -12,6 +12,9 @@ [Defines]
>    PACKAGE_GUID                   = 34E19823-D23A-41AB-9C09-ED1225B32DFF
>    PACKAGE_VERSION                = 1.0
>
> +[Includes]
> +  .
> +

This looks fishy. Won't this cause *every* module that incorporates
this .dec to add . to its include path?

>  [Guids]
>    gBcmNetTokenSpaceGuid = {0x12b97d70, 0x9149, 0x4c2f, {0x82, 0xd5, 0xad, 0xa9, 0x1e, 0x92, 0x75, 0xa1}}
>
> --
> 2.21.0.windows.1
>

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [edk2-platforms][PATCH 04/15] Silicon/BcmGenet: Add missing I/O mapping length and clean up
  2020-02-28 10:45   ` Ard Biesheuvel
@ 2020-02-28 10:51     ` Pete Batard
  2020-02-28 10:58       ` Ard Biesheuvel
  0 siblings, 1 reply; 23+ messages in thread
From: Pete Batard @ 2020-02-28 10:51 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: edk2-devel-groups-io, Leif Lindholm, Philippe Mathieu-Daudé

Hi Ard,

On 2020.02.28 10:45, Ard Biesheuvel wrote:
> On Fri, 28 Feb 2020 at 11:39, Pete Batard <pete@akeo.ie> wrote:
>>
>> Remove unneeded extra parenthesis on PCD, which can cause problems
>> when used with ACPI ASL macros and add an [Includes] section to the
>> .inf, so that the Genet.h header can be referenced where required.
>>
>> Signed-off-by: Pete Batard <pete@akeo.ie>
>> ---
>>   Silicon/Broadcom/Drivers/Net/BcmGenetDxe/Genet.h | 3 ++-
>>   Silicon/Broadcom/Drivers/Net/BcmNet.dec          | 3 +++
>>   2 files changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/Genet.h b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/Genet.h
>> index 4a3827c0e0d1..f56fb2977422 100644
>> --- a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/Genet.h
>> +++ b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/Genet.h
>> @@ -11,7 +11,8 @@
>>
>>   #include <Library/PcdLib.h>
>>
>> -#define GENET_BASE_ADDRESS         (FixedPcdGet64 (PcdBcmGenetRegistersAddress))
>> +#define GENET_BASE_ADDRESS         FixedPcdGet64 (PcdBcmGenetRegistersAddress)
>> +#define GENET_LENGTH               0x00010000
>>
>>   #define GENET_SYS_RBUF_FLUSH_CTRL  0x0008
>>   #define GENET_UMAC_MAC0            0x080c
>> diff --git a/Silicon/Broadcom/Drivers/Net/BcmNet.dec b/Silicon/Broadcom/Drivers/Net/BcmNet.dec
>> index 2a8688cb09a7..483b033af51c 100644
>> --- a/Silicon/Broadcom/Drivers/Net/BcmNet.dec
>> +++ b/Silicon/Broadcom/Drivers/Net/BcmNet.dec
>> @@ -12,6 +12,9 @@ [Defines]
>>     PACKAGE_GUID                   = 34E19823-D23A-41AB-9C09-ED1225B32DFF
>>     PACKAGE_VERSION                = 1.0
>>
>> +[Includes]
>> +  .
>> +
> 
> This looks fishy. Won't this cause *every* module that incorporates
> this .dec to add . to its include path?

Yeah, I don't like it either. I kind of expected you guys to comment on 
it, so that we can discuss what you think the better approach should be.

Do you think it'd make sense to create a Drivers/Include/ section in 
Silicon/Broadcom/ and move the header there?

And if we do that, do you think the header should go to something like 
Include/Net or just reside at the top level of Include/?

What would be your preferred approach?

Regards,

/Pete

> 
>>   [Guids]
>>     gBcmNetTokenSpaceGuid = {0x12b97d70, 0x9149, 0x4c2f, {0x82, 0xd5, 0xad, 0xa9, 0x1e, 0x92, 0x75, 0xa1}}
>>
>> --
>> 2.21.0.windows.1
>>


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [edk2-platforms][PATCH 04/15] Silicon/BcmGenet: Add missing I/O mapping length and clean up
  2020-02-28 10:51     ` Pete Batard
@ 2020-02-28 10:58       ` Ard Biesheuvel
  2020-02-28 11:01         ` Pete Batard
  0 siblings, 1 reply; 23+ messages in thread
From: Ard Biesheuvel @ 2020-02-28 10:58 UTC (permalink / raw)
  To: Pete Batard
  Cc: edk2-devel-groups-io, Leif Lindholm, Philippe Mathieu-Daudé

On Fri, 28 Feb 2020 at 11:51, Pete Batard <pete@akeo.ie> wrote:
>
> Hi Ard,
>
> On 2020.02.28 10:45, Ard Biesheuvel wrote:
> > On Fri, 28 Feb 2020 at 11:39, Pete Batard <pete@akeo.ie> wrote:
> >>
> >> Remove unneeded extra parenthesis on PCD, which can cause problems
> >> when used with ACPI ASL macros and add an [Includes] section to the
> >> .inf, so that the Genet.h header can be referenced where required.
> >>
> >> Signed-off-by: Pete Batard <pete@akeo.ie>
> >> ---
> >>   Silicon/Broadcom/Drivers/Net/BcmGenetDxe/Genet.h | 3 ++-
> >>   Silicon/Broadcom/Drivers/Net/BcmNet.dec          | 3 +++
> >>   2 files changed, 5 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/Genet.h b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/Genet.h
> >> index 4a3827c0e0d1..f56fb2977422 100644
> >> --- a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/Genet.h
> >> +++ b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/Genet.h
> >> @@ -11,7 +11,8 @@
> >>
> >>   #include <Library/PcdLib.h>
> >>
> >> -#define GENET_BASE_ADDRESS         (FixedPcdGet64 (PcdBcmGenetRegistersAddress))
> >> +#define GENET_BASE_ADDRESS         FixedPcdGet64 (PcdBcmGenetRegistersAddress)
> >> +#define GENET_LENGTH               0x00010000
> >>
> >>   #define GENET_SYS_RBUF_FLUSH_CTRL  0x0008
> >>   #define GENET_UMAC_MAC0            0x080c
> >> diff --git a/Silicon/Broadcom/Drivers/Net/BcmNet.dec b/Silicon/Broadcom/Drivers/Net/BcmNet.dec
> >> index 2a8688cb09a7..483b033af51c 100644
> >> --- a/Silicon/Broadcom/Drivers/Net/BcmNet.dec
> >> +++ b/Silicon/Broadcom/Drivers/Net/BcmNet.dec
> >> @@ -12,6 +12,9 @@ [Defines]
> >>     PACKAGE_GUID                   = 34E19823-D23A-41AB-9C09-ED1225B32DFF
> >>     PACKAGE_VERSION                = 1.0
> >>
> >> +[Includes]
> >> +  .
> >> +
> >
> > This looks fishy. Won't this cause *every* module that incorporates
> > this .dec to add . to its include path?
>
> Yeah, I don't like it either. I kind of expected you guys to comment on
> it, so that we can discuss what you think the better approach should be.
>
> Do you think it'd make sense to create a Drivers/Include/ section in
> Silicon/Broadcom/ and move the header there?
>
> And if we do that, do you think the header should go to something like
> Include/Net or just reside at the top level of Include/?
>
> What would be your preferred approach?
>

If the contents of the header need to be visible outside of the
module, then the header needs to be moved outside of the module.

So move the header to

Silicon/Broadcom/Drivers/Include/Net/

and add Include under the [Includes] section

Then, any component that includes the .dec can access the header via

#include <Net/Genet.h>

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [edk2-platforms][PATCH 04/15] Silicon/BcmGenet: Add missing I/O mapping length and clean up
  2020-02-28 10:58       ` Ard Biesheuvel
@ 2020-02-28 11:01         ` Pete Batard
  0 siblings, 0 replies; 23+ messages in thread
From: Pete Batard @ 2020-02-28 11:01 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: edk2-devel-groups-io, Leif Lindholm, Philippe Mathieu-Daudé

On 2020.02.28 10:58, Ard Biesheuvel wrote:
> On Fri, 28 Feb 2020 at 11:51, Pete Batard <pete@akeo.ie> wrote:
>>
>> Hi Ard,
>>
>> On 2020.02.28 10:45, Ard Biesheuvel wrote:
>>> On Fri, 28 Feb 2020 at 11:39, Pete Batard <pete@akeo.ie> wrote:
>>>>
>>>> Remove unneeded extra parenthesis on PCD, which can cause problems
>>>> when used with ACPI ASL macros and add an [Includes] section to the
>>>> .inf, so that the Genet.h header can be referenced where required.
>>>>
>>>> Signed-off-by: Pete Batard <pete@akeo.ie>
>>>> ---
>>>>    Silicon/Broadcom/Drivers/Net/BcmGenetDxe/Genet.h | 3 ++-
>>>>    Silicon/Broadcom/Drivers/Net/BcmNet.dec          | 3 +++
>>>>    2 files changed, 5 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/Genet.h b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/Genet.h
>>>> index 4a3827c0e0d1..f56fb2977422 100644
>>>> --- a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/Genet.h
>>>> +++ b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/Genet.h
>>>> @@ -11,7 +11,8 @@
>>>>
>>>>    #include <Library/PcdLib.h>
>>>>
>>>> -#define GENET_BASE_ADDRESS         (FixedPcdGet64 (PcdBcmGenetRegistersAddress))
>>>> +#define GENET_BASE_ADDRESS         FixedPcdGet64 (PcdBcmGenetRegistersAddress)
>>>> +#define GENET_LENGTH               0x00010000
>>>>
>>>>    #define GENET_SYS_RBUF_FLUSH_CTRL  0x0008
>>>>    #define GENET_UMAC_MAC0            0x080c
>>>> diff --git a/Silicon/Broadcom/Drivers/Net/BcmNet.dec b/Silicon/Broadcom/Drivers/Net/BcmNet.dec
>>>> index 2a8688cb09a7..483b033af51c 100644
>>>> --- a/Silicon/Broadcom/Drivers/Net/BcmNet.dec
>>>> +++ b/Silicon/Broadcom/Drivers/Net/BcmNet.dec
>>>> @@ -12,6 +12,9 @@ [Defines]
>>>>      PACKAGE_GUID                   = 34E19823-D23A-41AB-9C09-ED1225B32DFF
>>>>      PACKAGE_VERSION                = 1.0
>>>>
>>>> +[Includes]
>>>> +  .
>>>> +
>>>
>>> This looks fishy. Won't this cause *every* module that incorporates
>>> this .dec to add . to its include path?
>>
>> Yeah, I don't like it either. I kind of expected you guys to comment on
>> it, so that we can discuss what you think the better approach should be.
>>
>> Do you think it'd make sense to create a Drivers/Include/ section in
>> Silicon/Broadcom/ and move the header there?
>>
>> And if we do that, do you think the header should go to something like
>> Include/Net or just reside at the top level of Include/?
>>
>> What would be your preferred approach?
>>
> 
> If the contents of the header need to be visible outside of the
> module, then the header needs to be moved outside of the module.
> 
> So move the header to
> 
> Silicon/Broadcom/Drivers/Include/Net/
> 
> and add Include under the [Includes] section
> 
> Then, any component that includes the .dec can access the header via
> 
> #include <Net/Genet.h>
> 

OK. I'll do that for v2.

/Pete


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [edk2-platforms][PATCH 00/15] Platform/RPi: Clean up and factorize ACPI
  2020-02-28 10:38 [edk2-platforms][PATCH 00/15] Platform/RPi: Clean up and factorize ACPI Pete Batard
                   ` (14 preceding siblings ...)
  2020-02-28 10:38 ` [edk2-platforms][PATCH 15/15] Platform/RPi: Factorize ACPI tables Pete Batard
@ 2020-02-28 12:17 ` Ard Biesheuvel
  2020-03-02 11:14   ` Ard Biesheuvel
  15 siblings, 1 reply; 23+ messages in thread
From: Ard Biesheuvel @ 2020-02-28 12:17 UTC (permalink / raw)
  To: Pete Batard
  Cc: edk2-devel-groups-io, Leif Lindholm, Philippe Mathieu-Daudé

Hi Pete,

On Fri, 28 Feb 2020 at 11:39, Pete Batard <pete@akeo.ie> wrote:
>

TL;DR:

>  47 files changed, 1000 insertions(+), 2611 deletions(-)

\o/

Thanks for doing this cleanup. I'll go through these more carefully
early next week, no need to send a v2 before that.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [edk2-platforms][PATCH 00/15] Platform/RPi: Clean up and factorize ACPI
  2020-02-28 12:17 ` [edk2-platforms][PATCH 00/15] Platform/RPi: Clean up and factorize ACPI Ard Biesheuvel
@ 2020-03-02 11:14   ` Ard Biesheuvel
  0 siblings, 0 replies; 23+ messages in thread
From: Ard Biesheuvel @ 2020-03-02 11:14 UTC (permalink / raw)
  To: Pete Batard
  Cc: edk2-devel-groups-io, Leif Lindholm, Philippe Mathieu-Daudé

On Fri, 28 Feb 2020 at 13:17, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
>
> Hi Pete,
>
> On Fri, 28 Feb 2020 at 11:39, Pete Batard <pete@akeo.ie> wrote:
> >
>
> TL;DR:
>
> >  47 files changed, 1000 insertions(+), 2611 deletions(-)
>
> \o/
>
> Thanks for doing this cleanup. I'll go through these more carefully
> early next week, no need to send a v2 before that.

For the series,

Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

Pushed as a8c0a75ea748..e168252531c7 (with the 'Include' change
applied as discussed)

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [edk2-platforms][PATCH 01/15] Platform/RPi: Move DW USB base address to Silicon
  2020-02-28 10:38 ` [edk2-platforms][PATCH 01/15] Platform/RPi: Move DW USB base address to Silicon Pete Batard
@ 2020-03-02 11:21   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-02 11:21 UTC (permalink / raw)
  To: Pete Batard, devel; +Cc: ard.biesheuvel, leif

On 2/28/20 11:38 AM, Pete Batard wrote:
> The official BCM2835 ARM Peripherals guide lists the DW USB
> controller as standard SoC device.
> Treat is as such by adding its base address to Silicon.
> 
> Signed-off-by: Pete Batard <pete@akeo.ie>
> ---
>   Platform/RaspberryPi/Drivers/DwUsbHostDxe/DwUsbHostDxe.c    | 3 ++-
>   Platform/RaspberryPi/Drivers/DwUsbHostDxe/DwcHw.h           | 6 +-----
>   Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h | 5 +++++
>   3 files changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/Platform/RaspberryPi/Drivers/DwUsbHostDxe/DwUsbHostDxe.c b/Platform/RaspberryPi/Drivers/DwUsbHostDxe/DwUsbHostDxe.c
> index 37ebf503fd60..4f6f60b1eb5f 100644
> --- a/Platform/RaspberryPi/Drivers/DwUsbHostDxe/DwUsbHostDxe.c
> +++ b/Platform/RaspberryPi/Drivers/DwUsbHostDxe/DwUsbHostDxe.c
> @@ -7,6 +7,7 @@
>    *
>    **/
>   
> +#include <IndustryStandard/Bcm2836.h>
>   #include "DwUsbHostDxe.h"
>   #include "DwcHw.h"
>   
> @@ -1548,7 +1549,7 @@ CreateDwUsbHc (
>     DwHc->DwUsbOtgHc.ClearRootHubPortFeature        = DwHcClearRootHubPortFeature;
>     DwHc->DwUsbOtgHc.MajorRevision                  = 0x02;
>     DwHc->DwUsbOtgHc.MinorRevision                  = 0x00;
> -  DwHc->DwUsbBase                                 = DW2_USB_BASE_ADDRESS;
> +  DwHc->DwUsbBase                                 = BCM2836_USB_BASE_ADDRESS;
>   
>     Pages = EFI_SIZE_TO_PAGES (DWC2_STATUS_BUF_SIZE);
>     DwHc->StatusBuffer = AllocatePages (Pages);
> diff --git a/Platform/RaspberryPi/Drivers/DwUsbHostDxe/DwcHw.h b/Platform/RaspberryPi/Drivers/DwUsbHostDxe/DwcHw.h
> index ddbf69a1d608..12fbde9ff6f2 100644
> --- a/Platform/RaspberryPi/Drivers/DwUsbHostDxe/DwcHw.h
> +++ b/Platform/RaspberryPi/Drivers/DwUsbHostDxe/DwcHw.h
> @@ -10,11 +10,7 @@
>   #ifndef __DWCHW_H__
>   #define __DWCHW_H__
>   
> -#define DW2_USB_OFFSET                  0x00980000
> -#define DW2_USB_BASE_ADDRESS            (FixedPcdGet64 (PcdBcm283xRegistersAddress) \
> -                                        + DW2_USB_OFFSET)
> -
> -#define HSOTG_REG(x)    (x)
> +#define HSOTG_REG(x)                    (x)
>   
>   #define HCCHAR(_ch)                     HSOTG_REG(0x0500 + 0x20 * (_ch))
>   #define HCSPLT(_ch)                     HSOTG_REG(0x0504 + 0x20 * (_ch))
> diff --git a/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h b/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h
> index 7ba4877337a8..cee5fb6a4e15 100644
> --- a/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h
> +++ b/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h
> @@ -70,6 +70,11 @@
>   #define BCM2836_INTC_TIMER_CONTROL_OFFSET                   0x00000040
>   #define BCM2836_INTC_TIMER_PENDING_OFFSET                   0x00000060
>   
> +/* usb constants */
> +#define BCM2836_USB_OFFSET                                  0x00980000
> +#define BCM2836_USB_BASE_ADDRESS                            (BCM2836_SOC_REGISTERS + BCM2836_USB_OFFSET)
> +#define BCM2836_USB_LENGTH                                  0x00010000
> +
>   /* uart constants */
>   #define BCM2836_PL011_UART_OFFSET                           0x00201000
>   #define BCM2836_PL011_UART_BASE_ADDRESS                     (BCM2836_SOC_REGISTERS + BCM2836_PL011_UART_OFFSET)
> 

Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>


^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2020-03-02 11:21 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-28 10:38 [edk2-platforms][PATCH 00/15] Platform/RPi: Clean up and factorize ACPI Pete Batard
2020-02-28 10:38 ` [edk2-platforms][PATCH 01/15] Platform/RPi: Move DW USB base address to Silicon Pete Batard
2020-03-02 11:21   ` Philippe Mathieu-Daudé
2020-02-28 10:38 ` [edk2-platforms][PATCH 02/15] Silicon/Bcm283x: Add missing peripherals constants Pete Batard
2020-02-28 10:38 ` [edk2-platforms][PATCH 03/15] Silicon/Bcm283x: Add GPU/VideoCore and Power Management constants Pete Batard
2020-02-28 10:38 ` [edk2-platforms][PATCH 04/15] Silicon/BcmGenet: Add missing I/O mapping length and clean up Pete Batard
2020-02-28 10:45   ` Ard Biesheuvel
2020-02-28 10:51     ` Pete Batard
2020-02-28 10:58       ` Ard Biesheuvel
2020-02-28 11:01         ` Pete Batard
2020-02-28 10:38 ` [edk2-platforms][PATCH 05/15] Platform/RPi4: Use Silicon constants in ACPI headers Pete Batard
2020-02-28 10:38 ` [edk2-platforms][PATCH 06/15] Platform/RPi3: " Pete Batard
2020-02-28 10:38 ` [edk2-platforms][PATCH 07/15] Platform/RPi3: Switch to .aslc for serial related ACPI tables Pete Batard
2020-02-28 10:38 ` [edk2-platforms][PATCH 08/15] Platform/RPi3: Update CSRT table to ACPI 5.1 Pete Batard
2020-02-28 10:38 ` [edk2-platforms][PATCH 09/15] Platform/RPi3: Use proper aslc for FADT, GTDT and MADT tables generation Pete Batard
2020-02-28 10:38 ` [edk2-platforms][PATCH 10/15] Platform/RPi4: Add RPI_MODEL constant and replace PL011_ENABLE Pete Batard
2020-02-28 10:38 ` [edk2-platforms][PATCH 11/15] Platform/RPi4: Move ACPI interrupts definitions to AcpiTables.h Pete Batard
2020-02-28 10:38 ` [edk2-platforms][PATCH 12/15] Platform/RPi3: " Pete Batard
2020-02-28 10:38 ` [edk2-platforms][PATCH 13/15] Platform/RPi4: Prepare ACPI code for factorization Pete Batard
2020-02-28 10:38 ` [edk2-platforms][PATCH 14/15] Platform/RPi3: Merge ACPI code from RPi4 Pete Batard
2020-02-28 10:38 ` [edk2-platforms][PATCH 15/15] Platform/RPi: Factorize ACPI tables Pete Batard
2020-02-28 12:17 ` [edk2-platforms][PATCH 00/15] Platform/RPi: Clean up and factorize ACPI Ard Biesheuvel
2020-03-02 11:14   ` Ard Biesheuvel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox