diff mbox

[edk2,v5,9/9] PL180: update for indentifying SD

Message ID 1479019678-12621-10-git-send-email-haojian.zhuang@linaro.org
State Superseded
Headers show

Commit Message

Haojian Zhuang Nov. 13, 2016, 6:47 a.m. UTC
When CMD6 & ACMD51 are added into indentifying SD process, PL180
should also support CMD6 & ACMD51. Otherwise, it'll hang when
system tries to read expected data.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>

Tested-by: Ryan Harkin <ryan.harkin@linaro.org>

---
 ArmPlatformPkg/Drivers/PL180MciDxe/PL180Mci.c | 29 ++++++++++++++++++++-------
 1 file changed, 22 insertions(+), 7 deletions(-)

-- 
2.7.4

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

Comments

Leif Lindholm Nov. 14, 2016, 5:27 p.m. UTC | #1
On Sun, Nov 13, 2016 at 02:47:58PM +0800, Haojian Zhuang wrote:
> When CMD6 & ACMD51 are added into indentifying SD process, PL180

> should also support CMD6 & ACMD51. Otherwise, it'll hang when

> system tries to read expected data.

> 

> Contributed-under: TianoCore Contribution Agreement 1.0

> Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>

> Tested-by: Ryan Harkin <ryan.harkin@linaro.org>


The change as such is fine. (More than fine.)

However, should this not be added before the current 6/9, in order to
not leave a gap of commits that fail to boot?
Could I even push it independently of the series?

Regards,

Leif

> ---

>  ArmPlatformPkg/Drivers/PL180MciDxe/PL180Mci.c | 29 ++++++++++++++++++++-------

>  1 file changed, 22 insertions(+), 7 deletions(-)

> 

> diff --git a/ArmPlatformPkg/Drivers/PL180MciDxe/PL180Mci.c b/ArmPlatformPkg/Drivers/PL180MciDxe/PL180Mci.c

> index 5526aac..b2ba4c0 100644

> --- a/ArmPlatformPkg/Drivers/PL180MciDxe/PL180Mci.c

> +++ b/ArmPlatformPkg/Drivers/PL180MciDxe/PL180Mci.c

> @@ -63,11 +63,6 @@ MciIsReadOnly (

>    return (MmioRead32 (FixedPcdGet32 (PcdPL180SysMciRegAddress)) & SYS_MCI_WPROT);

>  }

>  

> -#if 0

> -//Note: This function has been commented out because it is not used yet.

> -//      This function could be used to remove the hardcoded BlockLen used

> -//      in MciPrepareDataPath

> -

>  // Convert block size to 2^n

>  STATIC

>  UINT32

> @@ -87,7 +82,6 @@ GetPow2BlockLen (

>  

>    return Pow2BlockLen;

>  }

> -#endif

>  

>  VOID

>  MciPrepareDataPath (

> @@ -126,6 +120,23 @@ MciSendCommand (

>      MciPrepareDataPath (MCI_DATACTL_CARD_TO_CONT);

>    } else if ((MmcCmd == MMC_CMD24) || (MmcCmd == MMC_CMD20)) {

>      MciPrepareDataPath (MCI_DATACTL_CONT_TO_CARD);

> +  } else if (MmcCmd == MMC_CMD6) {

> +    MmioWrite32 (MCI_DATA_TIMER_REG, 0xFFFFFFF);

> +    MmioWrite32 (MCI_DATA_LENGTH_REG, 64);

> +#ifndef USE_STREAM

> +    MmioWrite32 (MCI_DATA_CTL_REG, MCI_DATACTL_ENABLE | MCI_DATACTL_CARD_TO_CONT | GetPow2BlockLen (64));

> +#else

> +    MmioWrite32 (MCI_DATA_CTL_REG, MCI_DATACTL_ENABLE | MCI_DATACTL_CARD_TO_CONT | MCI_DATACTL_STREAM_TRANS);

> +#endif

> +  } else if (MmcCmd == MMC_ACMD51) {

> +    MmioWrite32 (MCI_DATA_TIMER_REG, 0xFFFFFFF);

> +    /* SCR register is 8 bytes long. */

> +    MmioWrite32 (MCI_DATA_LENGTH_REG, 8);

> +#ifndef USE_STREAM

> +    MmioWrite32 (MCI_DATA_CTL_REG, MCI_DATACTL_ENABLE | MCI_DATACTL_CARD_TO_CONT | GetPow2BlockLen (8));

> +#else

> +    MmioWrite32 (MCI_DATA_CTL_REG, MCI_DATACTL_ENABLE | MCI_DATACTL_CARD_TO_CONT | MCI_DATACTL_STREAM_TRANS);

> +#endif

>    }

>  

>    // Create Command for PL180

> @@ -223,7 +234,11 @@ MciReadBlockData (

>  

>    // Read data from the RX FIFO

>    Loop   = 0;

> -  Finish = MMCI0_BLOCKLEN / 4;

> +  if (Length < MMCI0_BLOCKLEN) {

> +    Finish = Length / 4;

> +  } else {

> +    Finish = MMCI0_BLOCKLEN / 4;

> +  }

>  

>    // Raise the TPL at the highest level to disable Interrupts.

>    Tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);

> -- 

> 2.7.4

> 

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

Patch

diff --git a/ArmPlatformPkg/Drivers/PL180MciDxe/PL180Mci.c b/ArmPlatformPkg/Drivers/PL180MciDxe/PL180Mci.c
index 5526aac..b2ba4c0 100644
--- a/ArmPlatformPkg/Drivers/PL180MciDxe/PL180Mci.c
+++ b/ArmPlatformPkg/Drivers/PL180MciDxe/PL180Mci.c
@@ -63,11 +63,6 @@  MciIsReadOnly (
   return (MmioRead32 (FixedPcdGet32 (PcdPL180SysMciRegAddress)) & SYS_MCI_WPROT);
 }
 
-#if 0
-//Note: This function has been commented out because it is not used yet.
-//      This function could be used to remove the hardcoded BlockLen used
-//      in MciPrepareDataPath
-
 // Convert block size to 2^n
 STATIC
 UINT32
@@ -87,7 +82,6 @@  GetPow2BlockLen (
 
   return Pow2BlockLen;
 }
-#endif
 
 VOID
 MciPrepareDataPath (
@@ -126,6 +120,23 @@  MciSendCommand (
     MciPrepareDataPath (MCI_DATACTL_CARD_TO_CONT);
   } else if ((MmcCmd == MMC_CMD24) || (MmcCmd == MMC_CMD20)) {
     MciPrepareDataPath (MCI_DATACTL_CONT_TO_CARD);
+  } else if (MmcCmd == MMC_CMD6) {
+    MmioWrite32 (MCI_DATA_TIMER_REG, 0xFFFFFFF);
+    MmioWrite32 (MCI_DATA_LENGTH_REG, 64);
+#ifndef USE_STREAM
+    MmioWrite32 (MCI_DATA_CTL_REG, MCI_DATACTL_ENABLE | MCI_DATACTL_CARD_TO_CONT | GetPow2BlockLen (64));
+#else
+    MmioWrite32 (MCI_DATA_CTL_REG, MCI_DATACTL_ENABLE | MCI_DATACTL_CARD_TO_CONT | MCI_DATACTL_STREAM_TRANS);
+#endif
+  } else if (MmcCmd == MMC_ACMD51) {
+    MmioWrite32 (MCI_DATA_TIMER_REG, 0xFFFFFFF);
+    /* SCR register is 8 bytes long. */
+    MmioWrite32 (MCI_DATA_LENGTH_REG, 8);
+#ifndef USE_STREAM
+    MmioWrite32 (MCI_DATA_CTL_REG, MCI_DATACTL_ENABLE | MCI_DATACTL_CARD_TO_CONT | GetPow2BlockLen (8));
+#else
+    MmioWrite32 (MCI_DATA_CTL_REG, MCI_DATACTL_ENABLE | MCI_DATACTL_CARD_TO_CONT | MCI_DATACTL_STREAM_TRANS);
+#endif
   }
 
   // Create Command for PL180
@@ -223,7 +234,11 @@  MciReadBlockData (
 
   // Read data from the RX FIFO
   Loop   = 0;
-  Finish = MMCI0_BLOCKLEN / 4;
+  if (Length < MMCI0_BLOCKLEN) {
+    Finish = Length / 4;
+  } else {
+    Finish = MMCI0_BLOCKLEN / 4;
+  }
 
   // Raise the TPL at the highest level to disable Interrupts.
   Tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);