diff options
author | Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com> | 2019-01-24 19:35:18 +0530 |
---|---|---|
committer | Leif Lindholm <leif.lindholm@linaro.org> | 2019-01-30 17:47:26 +0000 |
commit | b566259c8a2447cc3db9979d815d955a90431520 (patch) | |
tree | 2c6dbc41e0828237c24ba62067b13062f5ddbe07 | |
parent | d5788777bcc75936cc0e6acb540a5ee6ac77866b (diff) | |
download | edk2-b566259c8a2447cc3db9979d815d955a90431520.tar.gz edk2-b566259c8a2447cc3db9979d815d955a90431520.tar.bz2 edk2-b566259c8a2447cc3db9979d815d955a90431520.zip |
EmbeddedPkg: Fix Command Argument for SD/eMMC R/W operation.
Issue : SD read failure for high capacity cards e.g. 64 GB
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>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
-rw-r--r-- | EmbeddedPkg/Universal/MmcDxe/Mmc.h | 2 | ||||
-rw-r--r-- | EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c | 21 |
2 files changed, 18 insertions, 5 deletions
diff --git a/EmbeddedPkg/Universal/MmcDxe/Mmc.h b/EmbeddedPkg/Universal/MmcDxe/Mmc.h index a77ba41575..62de2c8744 100644 --- a/EmbeddedPkg/Universal/MmcDxe/Mmc.h +++ b/EmbeddedPkg/Universal/MmcDxe/Mmc.h @@ -70,6 +70,8 @@ #define SD_HIGH_SPEED 50000000
#define SWITCH_CMD_SUCCESS_MASK 0x0f000000
+#define SD_CARD_CAPACITY 0x00000002
+
#define BUSWIDTH_4 4
typedef enum {
diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c index a2b923270c..1dea7d35fe 100644 --- a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c +++ b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c @@ -148,12 +148,23 @@ 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
+ //if 0 : SDSC card
+ //if 1 : SDXC/SDHC
+ if (MmcHostInstance->CardInfo.OCRData.AccessMode & SD_CARD_CAPACITY) {
+ 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);
|