public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] SD/eMMC : Fix Command Argument for SD/eMMC R/W operation.
@ 2019-01-16 13:21 Meenakshi Aggarwal
  2019-01-17 11:23 ` Leif Lindholm
  2019-01-24 14:05 ` [PATCH v2] " Meenakshi Aggarwal
  0 siblings, 2 replies; 8+ messages in thread
From: Meenakshi Aggarwal @ 2019-01-16 13:21 UTC (permalink / raw)
  To: ard.biesheuvel, leif.lindholm, edk2-devel

Issue : SD read failure for high capacity cards e.g. 64 GB
i
Reason : Command argument value exceeds 32 bit for block number 0x3787FFF
and cant be fit into 32 bit wide SD host controller register.

Fix :
AccessMode bits [29:30] of OCR is a valid definition to calculate
data address for eMMC cards.

For SD cards, data address is calculated on the basis of
card capacity status bit[30] of OCR.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
---
 EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
index a2b9232..625a59e 100644
--- a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
+++ b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
@@ -148,12 +148,21 @@ MmcTransferBlock (
   MmcHostInstance = MMC_HOST_INSTANCE_FROM_BLOCK_IO_THIS (This);
   MmcHost = MmcHostInstance->MmcHost;
 
-  //Set command argument based on the card access mode (Byte mode or Block mode)
-  if ((MmcHostInstance->CardInfo.OCRData.AccessMode & MMC_OCR_ACCESS_MASK) ==
-      MMC_OCR_ACCESS_SECTOR) {
-    CmdArg = Lba;
+  if (MmcHostInstance->CardInfo.CardType != EMMC_CARD) {
+    //Set command argument based on the card capacity (SDSC or SDXC/SDHC)
+    if (MmcHostInstance->CardInfo.OCRData.AccessMode & BIT1) {
+      CmdArg = Lba;
+    } else {
+      CmdArg = Lba * This->Media->BlockSize;
+    }
   } else {
-    CmdArg = Lba * This->Media->BlockSize;
+    //Set command argument based on the card access mode (Byte mode or Block mode)
+    if ((MmcHostInstance->CardInfo.OCRData.AccessMode & MMC_OCR_ACCESS_MASK) ==
+        MMC_OCR_ACCESS_SECTOR) {
+      CmdArg = Lba;
+    } else {
+      CmdArg = Lba * This->Media->BlockSize;
+    }
   }
 
   Status = MmcHost->SendCommand (MmcHost, Cmd, CmdArg);
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-01-30 17:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-16 13:21 [PATCH] SD/eMMC : Fix Command Argument for SD/eMMC R/W operation Meenakshi Aggarwal
2019-01-17 11:23 ` Leif Lindholm
2019-01-22  4:29   ` Meenakshi Aggarwal
2019-01-23 15:04     ` Leif Lindholm
2019-01-24 14:05 ` [PATCH v2] " Meenakshi Aggarwal
2019-01-29  4:43   ` Meenakshi Aggarwal
2019-01-30  4:26     ` Meenakshi Aggarwal
2019-01-30 17:49   ` Leif Lindholm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox