diff mbox series

[Linaro-uefi,1/2] Drivers/Mmc/DwEmmc: limit max clock for platform

Message ID 1498791777-16122-1-git-send-email-jun.nie@linaro.org
State New
Headers show
Series [Linaro-uefi,1/2] Drivers/Mmc/DwEmmc: limit max clock for platform | expand

Commit Message

Jun Nie June 30, 2017, 3:02 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>
---
 Drivers/Mmc/DwEmmcDxe/DwEmmcDxe.c   | 3 +++
 Drivers/Mmc/DwEmmcDxe/DwEmmcDxe.dec | 1 +
 Drivers/Mmc/DwEmmcDxe/DwEmmcDxe.inf | 1 +
 3 files changed, 5 insertions(+)

Comments

Jun Nie July 3, 2017, 4:03 a.m. UTC | #1
2017-06-30 11:02 GMT+08:00 Jun Nie <jun.nie@linaro.org>:
> Some boards may have max clock limitation. Add a Pcd to notify
> driver.

Just find that DwEmmc is already merged to mainline. I already post
patches to edk2 mainline in another thread list and please ignore this
thread.
Jun

>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jun Nie <jun.nie@linaro.org>
> ---
>  Drivers/Mmc/DwEmmcDxe/DwEmmcDxe.c   | 3 +++
>  Drivers/Mmc/DwEmmcDxe/DwEmmcDxe.dec | 1 +
>  Drivers/Mmc/DwEmmcDxe/DwEmmcDxe.inf | 1 +
>  3 files changed, 5 insertions(+)
>
> diff --git a/Drivers/Mmc/DwEmmcDxe/DwEmmcDxe.c b/Drivers/Mmc/DwEmmcDxe/DwEmmcDxe.c
> index fe23d11..c67dd0d 100644
> --- a/Drivers/Mmc/DwEmmcDxe/DwEmmcDxe.c
> +++ b/Drivers/Mmc/DwEmmcDxe/DwEmmcDxe.c
> @@ -560,6 +560,9 @@ DwEmmcSetIos (
>    EFI_STATUS Status = EFI_SUCCESS;
>    UINT32    Data;
>
> +  if (BusClockFreq > PcdGet32 (PcdDwEmmcDxeMaxClockFrequencyInHz))
> +    return EFI_UNSUPPORTED;
> +
>    if (TimingMode != EMMCBACKWARD) {
>      Data = MmioRead32 (DWEMMC_UHSREG);
>      switch (TimingMode) {
> diff --git a/Drivers/Mmc/DwEmmcDxe/DwEmmcDxe.dec b/Drivers/Mmc/DwEmmcDxe/DwEmmcDxe.dec
> index c4bf7ed..7b84a9a 100644
> --- a/Drivers/Mmc/DwEmmcDxe/DwEmmcDxe.dec
> +++ b/Drivers/Mmc/DwEmmcDxe/DwEmmcDxe.dec
> @@ -40,3 +40,4 @@
>    # DwEmmc Driver PCDs
>    gDwEmmcDxeTokenSpaceGuid.PcdDwEmmcDxeBaseAddress|0x0|UINT32|0x00000001
>    gDwEmmcDxeTokenSpaceGuid.PcdDwEmmcDxeClockFrequencyInHz|0x0|UINT32|0x00000002
> +  gDwEmmcDxeTokenSpaceGuid.PcdDwEmmcDxeMaxClockFrequencyInHz|0x0|UINT32|52000000
> diff --git a/Drivers/Mmc/DwEmmcDxe/DwEmmcDxe.inf b/Drivers/Mmc/DwEmmcDxe/DwEmmcDxe.inf
> index c0cbba7..99176f1 100644
> --- a/Drivers/Mmc/DwEmmcDxe/DwEmmcDxe.inf
> +++ b/Drivers/Mmc/DwEmmcDxe/DwEmmcDxe.inf
> @@ -49,6 +49,7 @@
>  [Pcd]
>    gDwEmmcDxeTokenSpaceGuid.PcdDwEmmcDxeBaseAddress
>    gDwEmmcDxeTokenSpaceGuid.PcdDwEmmcDxeClockFrequencyInHz
> +  gDwEmmcDxeTokenSpaceGuid.PcdDwEmmcDxeMaxClockFrequencyInHz
>
>  [Depex]
>    TRUE
> --
> 1.9.1
>
diff mbox series

Patch

diff --git a/Drivers/Mmc/DwEmmcDxe/DwEmmcDxe.c b/Drivers/Mmc/DwEmmcDxe/DwEmmcDxe.c
index fe23d11..c67dd0d 100644
--- a/Drivers/Mmc/DwEmmcDxe/DwEmmcDxe.c
+++ b/Drivers/Mmc/DwEmmcDxe/DwEmmcDxe.c
@@ -560,6 +560,9 @@  DwEmmcSetIos (
   EFI_STATUS Status = EFI_SUCCESS;
   UINT32    Data;
 
+  if (BusClockFreq > PcdGet32 (PcdDwEmmcDxeMaxClockFrequencyInHz))
+    return EFI_UNSUPPORTED;
+
   if (TimingMode != EMMCBACKWARD) {
     Data = MmioRead32 (DWEMMC_UHSREG);
     switch (TimingMode) {
diff --git a/Drivers/Mmc/DwEmmcDxe/DwEmmcDxe.dec b/Drivers/Mmc/DwEmmcDxe/DwEmmcDxe.dec
index c4bf7ed..7b84a9a 100644
--- a/Drivers/Mmc/DwEmmcDxe/DwEmmcDxe.dec
+++ b/Drivers/Mmc/DwEmmcDxe/DwEmmcDxe.dec
@@ -40,3 +40,4 @@ 
   # DwEmmc Driver PCDs
   gDwEmmcDxeTokenSpaceGuid.PcdDwEmmcDxeBaseAddress|0x0|UINT32|0x00000001
   gDwEmmcDxeTokenSpaceGuid.PcdDwEmmcDxeClockFrequencyInHz|0x0|UINT32|0x00000002
+  gDwEmmcDxeTokenSpaceGuid.PcdDwEmmcDxeMaxClockFrequencyInHz|0x0|UINT32|52000000
diff --git a/Drivers/Mmc/DwEmmcDxe/DwEmmcDxe.inf b/Drivers/Mmc/DwEmmcDxe/DwEmmcDxe.inf
index c0cbba7..99176f1 100644
--- a/Drivers/Mmc/DwEmmcDxe/DwEmmcDxe.inf
+++ b/Drivers/Mmc/DwEmmcDxe/DwEmmcDxe.inf
@@ -49,6 +49,7 @@ 
 [Pcd]
   gDwEmmcDxeTokenSpaceGuid.PcdDwEmmcDxeBaseAddress
   gDwEmmcDxeTokenSpaceGuid.PcdDwEmmcDxeClockFrequencyInHz
+  gDwEmmcDxeTokenSpaceGuid.PcdDwEmmcDxeMaxClockFrequencyInHz
 
 [Depex]
   TRUE