[edk2-devel] [PATCH 1/2] Platform/Raspberrypi: Update DMA constants based on SOC revision

Jeremy Linton posted 2 patches 4 years, 9 months ago
[edk2-devel] [PATCH 1/2] Platform/Raspberrypi: Update DMA constants based on SOC revision
Posted by Jeremy Linton 4 years, 9 months ago
The newer BCM2711 SoC's don't have a DMA constraint on the emmc2
controller. So we don't need to do the 1G translation. Lets
allow the AML to detect the SoC revision and return a different
_DMA resource.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
---
 Platform/RaspberryPi/AcpiTables/Emmc.asl           | 39 +++++++++++++++++++++-
 .../Bcm27xx/Include/IndustryStandard/Bcm2711.h     |  2 ++
 2 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/Platform/RaspberryPi/AcpiTables/Emmc.asl b/Platform/RaspberryPi/AcpiTables/Emmc.asl
index 23febe37b4..c6691e81dc 100644
--- a/Platform/RaspberryPi/AcpiTables/Emmc.asl
+++ b/Platform/RaspberryPi/AcpiTables/Emmc.asl
@@ -8,6 +8,7 @@
 
 #include <IndustryStandard/Bcm2836SdHost.h>
 #include <IndustryStandard/Bcm2836Sdio.h>
+#include <IndustryStandard/Bcm2711.h>
 
 #include "AcpiTables.h"
 
@@ -31,7 +32,8 @@ DefinitionBlock (__FILE__, "SSDT", 2, "RPIFDN", "RPI4EMMC", 2)
         Return (^RBUF)
       }
 
-      Name (_DMA, ResourceTemplate() {
+      // Translated DMA region for < C0
+      Name (DMTR, ResourceTemplate() {
         QWordMemory (ResourceProducer,
           ,
           MinFixed,
@@ -48,6 +50,41 @@ DefinitionBlock (__FILE__, "SSDT", 2, "RPIFDN", "RPI4EMMC", 2)
         )
       })
 
+      // Non translated DMA region for >= C0
+      Name (DMNT, ResourceTemplate() {
+        QWordMemory (ResourceProducer,
+          ,
+          MinFixed,
+          MaxFixed,
+          NonCacheable,
+          ReadWrite,
+          0x0,
+          0x0000000000000000, // MIN
+          0x000000FFFFFFFFFF, // MAX
+          0x0000000000000000, // TRA
+          0x0000010000000000, // LEN
+          ,
+          ,
+        )
+      })
+
+      Method (_DMA, 0x0, Serialized)
+      {
+        OperationRegion (CHPR, SystemMemory, ID_CHIPREV, 0x4)
+          Field (CHPR, DWordAcc, NoLock, Preserve) {
+            SOCI, 32
+        }
+
+        if ((SOCI & 0xFF) >= 0x20)
+        {
+          return (^DMNT);
+        }
+        else
+        {
+          return (^DMTR);
+        }
+      }
+
       // emmc2 Host Controller. (brcm,bcm2711-emmc2)
       Device (SDC3)
       {
diff --git a/Silicon/Broadcom/Bcm27xx/Include/IndustryStandard/Bcm2711.h b/Silicon/Broadcom/Bcm27xx/Include/IndustryStandard/Bcm2711.h
index 86906b2438..8a69128d11 100644
--- a/Silicon/Broadcom/Bcm27xx/Include/IndustryStandard/Bcm2711.h
+++ b/Silicon/Broadcom/Bcm27xx/Include/IndustryStandard/Bcm2711.h
@@ -88,4 +88,6 @@
 
 #define THERM_SENSOR               0xfd5d2200
 
+#define ID_CHIPREV                 0xfc404000
+
 #endif /* BCM2711_H__ */
-- 
2.13.7



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#75042): https://edk2.groups.io/g/devel/message/75042
Mute This Topic: https://groups.io/mt/82759461/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [PATCH 1/2] Platform/Raspberrypi: Update DMA constants based on SOC revision
Posted by Pete Batard 4 years, 9 months ago
Two minor notes below:

On 2021.05.11 23:41, Jeremy Linton wrote:
> The newer BCM2711 SoC's don't have a DMA constraint on the emmc2
> controller. So we don't need to do the 1G translation. Lets
> allow the AML to detect the SoC revision and return a different
> _DMA resource.
> 
> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
> ---
>   Platform/RaspberryPi/AcpiTables/Emmc.asl           | 39 +++++++++++++++++++++-
>   .../Bcm27xx/Include/IndustryStandard/Bcm2711.h     |  2 ++
>   2 files changed, 40 insertions(+), 1 deletion(-)
> 
> diff --git a/Platform/RaspberryPi/AcpiTables/Emmc.asl b/Platform/RaspberryPi/AcpiTables/Emmc.asl
> index 23febe37b4..c6691e81dc 100644
> --- a/Platform/RaspberryPi/AcpiTables/Emmc.asl
> +++ b/Platform/RaspberryPi/AcpiTables/Emmc.asl
> @@ -8,6 +8,7 @@
>   
>   #include <IndustryStandard/Bcm2836SdHost.h>
>   #include <IndustryStandard/Bcm2836Sdio.h>
> +#include <IndustryStandard/Bcm2711.h>
>   
>   #include "AcpiTables.h"
>   
> @@ -31,7 +32,8 @@ DefinitionBlock (__FILE__, "SSDT", 2, "RPIFDN", "RPI4EMMC", 2)
>           Return (^RBUF)
>         }
>   
> -      Name (_DMA, ResourceTemplate() {
> +      // Translated DMA region for < C0

Even if the code makes it clear that we're testing the chip revision to 
decide what region to return, I would prefer if we had "for pre C0 
revisions of the SoC" instead of "for < C0", as I suspect people who 
read this too quickly, and have no idea what C0, refers to may think 
we're talking about a DMA address boundary or something.

> +      Name (DMTR, ResourceTemplate() {
>           QWordMemory (ResourceProducer,
>             ,
>             MinFixed,
> @@ -48,6 +50,41 @@ DefinitionBlock (__FILE__, "SSDT", 2, "RPIFDN", "RPI4EMMC", 2)
>           )
>         })
>   
> +      // Non translated DMA region for >= C0

Same as above: "for post C0 revisions of the SoC"

> +      Name (DMNT, ResourceTemplate() {
> +        QWordMemory (ResourceProducer,
> +          ,
> +          MinFixed,
> +          MaxFixed,
> +          NonCacheable,
> +          ReadWrite,
> +          0x0,
> +          0x0000000000000000, // MIN
> +          0x000000FFFFFFFFFF, // MAX
> +          0x0000000000000000, // TRA
> +          0x0000010000000000, // LEN
> +          ,
> +          ,
> +        )
> +      })
> +
> +      Method (_DMA, 0x0, Serialized)
> +      {
> +        OperationRegion (CHPR, SystemMemory, ID_CHIPREV, 0x4)
> +          Field (CHPR, DWordAcc, NoLock, Preserve) {
> +            SOCI, 32
> +        }
> +
> +        if ((SOCI & 0xFF) >= 0x20)
> +        {
> +          return (^DMNT);
> +        }
> +        else
> +        {
> +          return (^DMTR);
> +        }
> +      }
> +
>         // emmc2 Host Controller. (brcm,bcm2711-emmc2)
>         Device (SDC3)
>         {
> diff --git a/Silicon/Broadcom/Bcm27xx/Include/IndustryStandard/Bcm2711.h b/Silicon/Broadcom/Bcm27xx/Include/IndustryStandard/Bcm2711.h
> index 86906b2438..8a69128d11 100644
> --- a/Silicon/Broadcom/Bcm27xx/Include/IndustryStandard/Bcm2711.h
> +++ b/Silicon/Broadcom/Bcm27xx/Include/IndustryStandard/Bcm2711.h
> @@ -88,4 +88,6 @@
>   
>   #define THERM_SENSOR               0xfd5d2200
>   
> +#define ID_CHIPREV                 0xfc404000
> +
>   #endif /* BCM2711_H__ */
> 

With the comment changes, if agreed, applicable during integration:
Reviewed-by: Pete Batard <pete@akeo.ie>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#75069): https://edk2.groups.io/g/devel/message/75069
Mute This Topic: https://groups.io/mt/82759461/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [PATCH 1/2] Platform/Raspberrypi: Update DMA constants based on SOC revision
Posted by Ard Biesheuvel 4 years, 9 months ago
On Wed, 12 May 2021 at 13:19, Pete Batard <pete@akeo.ie> wrote:
>
> Two minor notes below:
>
> On 2021.05.11 23:41, Jeremy Linton wrote:
> > The newer BCM2711 SoC's don't have a DMA constraint on the emmc2
> > controller. So we don't need to do the 1G translation. Lets
> > allow the AML to detect the SoC revision and return a different
> > _DMA resource.
> >
> > Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
> > ---
> >   Platform/RaspberryPi/AcpiTables/Emmc.asl           | 39 +++++++++++++++++++++-
> >   .../Bcm27xx/Include/IndustryStandard/Bcm2711.h     |  2 ++
> >   2 files changed, 40 insertions(+), 1 deletion(-)
> >
> > diff --git a/Platform/RaspberryPi/AcpiTables/Emmc.asl b/Platform/RaspberryPi/AcpiTables/Emmc.asl
> > index 23febe37b4..c6691e81dc 100644
> > --- a/Platform/RaspberryPi/AcpiTables/Emmc.asl
> > +++ b/Platform/RaspberryPi/AcpiTables/Emmc.asl
> > @@ -8,6 +8,7 @@
> >
> >   #include <IndustryStandard/Bcm2836SdHost.h>
> >   #include <IndustryStandard/Bcm2836Sdio.h>
> > +#include <IndustryStandard/Bcm2711.h>
> >
> >   #include "AcpiTables.h"
> >
> > @@ -31,7 +32,8 @@ DefinitionBlock (__FILE__, "SSDT", 2, "RPIFDN", "RPI4EMMC", 2)
> >           Return (^RBUF)
> >         }
> >
> > -      Name (_DMA, ResourceTemplate() {
> > +      // Translated DMA region for < C0
>
> Even if the code makes it clear that we're testing the chip revision to
> decide what region to return, I would prefer if we had "for pre C0
> revisions of the SoC" instead of "for < C0", as I suspect people who
> read this too quickly, and have no idea what C0, refers to may think
> we're talking about a DMA address boundary or something.
>
> > +      Name (DMTR, ResourceTemplate() {
> >           QWordMemory (ResourceProducer,
> >             ,
> >             MinFixed,
> > @@ -48,6 +50,41 @@ DefinitionBlock (__FILE__, "SSDT", 2, "RPIFDN", "RPI4EMMC", 2)
> >           )
> >         })
> >
> > +      // Non translated DMA region for >= C0
>
> Same as above: "for post C0 revisions of the SoC"
>
> > +      Name (DMNT, ResourceTemplate() {
> > +        QWordMemory (ResourceProducer,
> > +          ,
> > +          MinFixed,
> > +          MaxFixed,
> > +          NonCacheable,
> > +          ReadWrite,
> > +          0x0,
> > +          0x0000000000000000, // MIN
> > +          0x000000FFFFFFFFFF, // MAX
> > +          0x0000000000000000, // TRA
> > +          0x0000010000000000, // LEN
> > +          ,
> > +          ,
> > +        )
> > +      })
> > +
> > +      Method (_DMA, 0x0, Serialized)
> > +      {
> > +        OperationRegion (CHPR, SystemMemory, ID_CHIPREV, 0x4)
> > +          Field (CHPR, DWordAcc, NoLock, Preserve) {
> > +            SOCI, 32
> > +        }
> > +
> > +        if ((SOCI & 0xFF) >= 0x20)
> > +        {
> > +          return (^DMNT);
> > +        }
> > +        else
> > +        {
> > +          return (^DMTR);
> > +        }
> > +      }
> > +
> >         // emmc2 Host Controller. (brcm,bcm2711-emmc2)
> >         Device (SDC3)
> >         {
> > diff --git a/Silicon/Broadcom/Bcm27xx/Include/IndustryStandard/Bcm2711.h b/Silicon/Broadcom/Bcm27xx/Include/IndustryStandard/Bcm2711.h
> > index 86906b2438..8a69128d11 100644
> > --- a/Silicon/Broadcom/Bcm27xx/Include/IndustryStandard/Bcm2711.h
> > +++ b/Silicon/Broadcom/Bcm27xx/Include/IndustryStandard/Bcm2711.h
> > @@ -88,4 +88,6 @@
> >
> >   #define THERM_SENSOR               0xfd5d2200
> >
> > +#define ID_CHIPREV                 0xfc404000
> > +
> >   #endif /* BCM2711_H__ */
> >
>
> With the comment changes, if agreed, applicable during integration:
> Reviewed-by: Pete Batard <pete@akeo.ie>

Thanks Pete. I have pushed these 2 patches as
e1efa61c33f7..09c5ab125b61 with the above suggestion applied.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#75071): https://edk2.groups.io/g/devel/message/75071
Mute This Topic: https://groups.io/mt/82759461/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-