From: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
To: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org,
edk2-devel@lists.01.org
Subject: [PATCH] SD/eMMC : Fix Command Argument for SD/eMMC R/W operation.
Date: Wed, 16 Jan 2019 18:51:36 +0530 [thread overview]
Message-ID: <1547644896-7721-1-git-send-email-meenakshi.aggarwal@nxp.com> (raw)
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
next reply other threads:[~2019-01-16 7:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-16 13:21 Meenakshi Aggarwal [this message]
2019-01-17 11:23 ` [PATCH] SD/eMMC : Fix Command Argument for SD/eMMC R/W operation 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1547644896-7721-1-git-send-email-meenakshi.aggarwal@nxp.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox