[edk2-devel] [edk2-platforms][PATCH] Platform/RaspberryPi: Fix VPU memory ranges in GPU device container

GH Cao posted 1 patch 3 years, 11 months ago
Failed in applying to current master (apply log)
There is a newer version of this series
Platform/RaspberryPi/AcpiTables/Dsdt.asl | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
[edk2-devel] [edk2-platforms][PATCH] Platform/RaspberryPi: Fix VPU memory ranges in GPU device container
Posted by GH Cao 3 years, 11 months ago
The PWM controller device specifies both CPU and VPU memory ranges.
CPU base addresses are provided as offsets to BCM2836_SOC_REGISTERS,
and VPU base addresses are constants.

But in Dsdt.asl, both offsets and constant addresses are seen as offsets
by QWORDMEMORYSET macro, result in incorrect VPU memory ranges.

This commits adds a new QWORDBUSMEMORYSET macro to handle VPU memory
ranges with constant base addresses.

Signed-off-by: GH Cao <driver1998@foxmail.com>
---
 Platform/RaspberryPi/AcpiTables/Dsdt.asl | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/Platform/RaspberryPi/AcpiTables/Dsdt.asl b/Platform/RaspberryPi/AcpiTables/Dsdt.asl
index 95766b0..ddaf1d4 100644
--- a/Platform/RaspberryPi/AcpiTables/Dsdt.asl
+++ b/Platform/RaspberryPi/AcpiTables/Dsdt.asl
@@ -31,7 +31,11 @@
 // The ASL compiler does not support argument arithmetic in functions
 // like QWordMemory (). So we need to instantiate dummy qword regions
 // that we can then update the Min, Max and Length attributes of.
-// The two macros below help accomplish this.
+// The three macros below help accomplish this.
+//
+// QWORDMEMORYSET specifies a CPU memory range (whose base address is
+// BCM2836_SOC_REGISTERS + Offset), and QWORDBUSMEMORYSET specifies
+// a VPU memory range (whose base address is provided directly).
 //
 #define QWORDMEMORYBUF(Index)                                   \
   QWordMemory (ResourceProducer,,                               \
@@ -46,6 +50,14 @@
   Add (BCM2836_SOC_REGISTERS, Offset, MI ## Index)              \
   Add (MI ## Index, LE ## Index - 1, MA ## Index)
 
+#define QWORDBUSMEMORYSET(Index, Base, Length)                  \
+  CreateQwordField (RBUF, RB ## Index._MIN, MI ## Index)        \
+  CreateQwordField (RBUF, RB ## Index._MAX, MA ## Index)        \
+  CreateQwordField (RBUF, RB ## Index._LEN, LE ## Index)        \
+  Store (Base, MI ## Index)                                     \
+  Store (Length, LE ## Index)                                   \
+  Add (MI ## Index, LE ## Index - 1, MA ## Index)
+
 DefinitionBlock ("Dsdt.aml", "DSDT", 5, "RPIFDN", "RPI", 2)
 {
   Scope (\_SB_)
@@ -173,8 +185,8 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "RPIFDN", "RPI", 2)
         // PWM
         QWORDMEMORYSET(17, BCM2836_PWM_DMA_OFFSET, BCM2836_PWM_DMA_LENGTH)
         QWORDMEMORYSET(18, BCM2836_PWM_CTRL_OFFSET, BCM2836_PWM_CTRL_LENGTH)
-        QWORDMEMORYSET(19, BCM2836_PWM_BUS_BASE_ADDRESS, BCM2836_PWM_BUS_LENGTH)
-        QWORDMEMORYSET(20, BCM2836_PWM_CTRL_UNCACHED_BASE_ADDRESS, BCM2836_PWM_CTRL_UNCACHED_LENGTH)
+        QWORDBUSMEMORYSET(19, BCM2836_PWM_BUS_BASE_ADDRESS, BCM2836_PWM_BUS_LENGTH)
+        QWORDBUSMEMORYSET(20, BCM2836_PWM_CTRL_UNCACHED_BASE_ADDRESS, BCM2836_PWM_CTRL_UNCACHED_LENGTH)
         QWORDMEMORYSET(21, BCM2836_PWM_CLK_OFFSET, BCM2836_PWM_CLK_LENGTH)
 
         // UART
-- 
2.17.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58209): https://edk2.groups.io/g/devel/message/58209
Mute This Topic: https://groups.io/mt/73322163/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-