diff mbox series

[edk2,v2,1/2] EmbeddedPkg/DwEmmcDxe: limit max clock for platform

Message ID 1499243228-1225-1-git-send-email-jun.nie@linaro.org
State Accepted
Commit d4102f68dceb36fa8f07af9fa3d24b0da9f173bf
Headers show
Series [edk2,v2,1/2] EmbeddedPkg/DwEmmcDxe: limit max clock for platform | expand

Commit Message

Jun Nie July 5, 2017, 8:27 a.m. UTC
Some boards may have max clock limitation. Add a Pcd to notify
driver.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jun Nie <jun.nie@linaro.org>

---
 EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c   | 4 ++++
 EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.inf | 1 +
 EmbeddedPkg/EmbeddedPkg.dec                 | 1 +
 3 files changed, 6 insertions(+)

-- 
1.9.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Comments

Leif Lindholm July 6, 2017, 3:24 p.m. UTC | #1
On Wed, Jul 05, 2017 at 04:27:07PM +0800, Jun Nie wrote:
> Some boards may have max clock limitation. Add a Pcd to notify

> driver.

> 

> Contributed-under: TianoCore Contribution Agreement 1.0

> Signed-off-by: Jun Nie <jun.nie@linaro.org>


Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>


(I'll hold off on pushing this one until 2/2 is ready. No need to
resend this.)

> ---

>  EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c   | 4 ++++

>  EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.inf | 1 +

>  EmbeddedPkg/EmbeddedPkg.dec                 | 1 +

>  3 files changed, 6 insertions(+)

> 

> diff --git a/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c b/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c

> index fe23d11..bb26b69 100644

> --- a/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c

> +++ b/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c

> @@ -560,6 +560,10 @@ DwEmmcSetIos (

>    EFI_STATUS Status = EFI_SUCCESS;

>    UINT32    Data;

>  

> +  if ((PcdGet32 (PcdDwEmmcDxeMaxClockFreqInHz) != 0) &&

> +      (BusClockFreq > PcdGet32 (PcdDwEmmcDxeMaxClockFreqInHz))) {

> +    return EFI_UNSUPPORTED;

> +  }

>    if (TimingMode != EMMCBACKWARD) {

>      Data = MmioRead32 (DWEMMC_UHSREG);

>      switch (TimingMode) {

> diff --git a/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.inf b/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.inf

> index e3c8313..99b4f99 100644

> --- a/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.inf

> +++ b/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.inf

> @@ -48,6 +48,7 @@

>  [Pcd]

>    gEmbeddedTokenSpaceGuid.PcdDwEmmcDxeBaseAddress

>    gEmbeddedTokenSpaceGuid.PcdDwEmmcDxeClockFrequencyInHz

> +  gEmbeddedTokenSpaceGuid.PcdDwEmmcDxeMaxClockFreqInHz

>  

>  [Depex]

>    TRUE

> diff --git a/EmbeddedPkg/EmbeddedPkg.dec b/EmbeddedPkg/EmbeddedPkg.dec

> index 5ea2f22..2da9b2f 100644

> --- a/EmbeddedPkg/EmbeddedPkg.dec

> +++ b/EmbeddedPkg/EmbeddedPkg.dec

> @@ -169,6 +169,7 @@

>    # DwEmmc Driver PCDs

>    gEmbeddedTokenSpaceGuid.PcdDwEmmcDxeBaseAddress|0x0|UINT32|0x00000035

>    gEmbeddedTokenSpaceGuid.PcdDwEmmcDxeClockFrequencyInHz|0x0|UINT32|0x00000036

> +  gEmbeddedTokenSpaceGuid.PcdDwEmmcDxeMaxClockFreqInHz|0x0|UINT32|0x00000037

>  

>    #

>    # Android FastBoot

> -- 

> 1.9.1

> 

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
diff mbox series

Patch

diff --git a/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c b/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c
index fe23d11..bb26b69 100644
--- a/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c
+++ b/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c
@@ -560,6 +560,10 @@  DwEmmcSetIos (
   EFI_STATUS Status = EFI_SUCCESS;
   UINT32    Data;
 
+  if ((PcdGet32 (PcdDwEmmcDxeMaxClockFreqInHz) != 0) &&
+      (BusClockFreq > PcdGet32 (PcdDwEmmcDxeMaxClockFreqInHz))) {
+    return EFI_UNSUPPORTED;
+  }
   if (TimingMode != EMMCBACKWARD) {
     Data = MmioRead32 (DWEMMC_UHSREG);
     switch (TimingMode) {
diff --git a/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.inf b/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.inf
index e3c8313..99b4f99 100644
--- a/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.inf
+++ b/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.inf
@@ -48,6 +48,7 @@ 
 [Pcd]
   gEmbeddedTokenSpaceGuid.PcdDwEmmcDxeBaseAddress
   gEmbeddedTokenSpaceGuid.PcdDwEmmcDxeClockFrequencyInHz
+  gEmbeddedTokenSpaceGuid.PcdDwEmmcDxeMaxClockFreqInHz
 
 [Depex]
   TRUE
diff --git a/EmbeddedPkg/EmbeddedPkg.dec b/EmbeddedPkg/EmbeddedPkg.dec
index 5ea2f22..2da9b2f 100644
--- a/EmbeddedPkg/EmbeddedPkg.dec
+++ b/EmbeddedPkg/EmbeddedPkg.dec
@@ -169,6 +169,7 @@ 
   # DwEmmc Driver PCDs
   gEmbeddedTokenSpaceGuid.PcdDwEmmcDxeBaseAddress|0x0|UINT32|0x00000035
   gEmbeddedTokenSpaceGuid.PcdDwEmmcDxeClockFrequencyInHz|0x0|UINT32|0x00000036
+  gEmbeddedTokenSpaceGuid.PcdDwEmmcDxeMaxClockFreqInHz|0x0|UINT32|0x00000037
 
   #
   # Android FastBoot