From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=92.121.34.13; helo=inva020.nxp.com; envelope-from=meenakshi.aggarwal@nxp.com; receiver=edk2-devel@lists.01.org Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 0571E21C8EFB5 for ; Tue, 15 Jan 2019 23:35:50 -0800 (PST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 187F01A012F; Wed, 16 Jan 2019 08:35:49 +0100 (CET) Received: from inv0113.in-blr01.nxp.com (inv0113.in-blr01.nxp.com [165.114.116.118]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id DC8511A0014; Wed, 16 Jan 2019 08:35:48 +0100 (CET) Received: from uefi-OptiPlex-790.ap.freescale.net (uefi-OptiPlex-790.ap.freescale.net [10.232.132.78]) by inv0113.in-blr01.nxp.com (Postfix) with ESMTP id 228BD335; Wed, 16 Jan 2019 13:05:48 +0530 (IST) From: Meenakshi Aggarwal To: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org, edk2-devel@lists.01.org Date: Wed, 16 Jan 2019 18:51:36 +0530 Message-Id: <1547644896-7721-1-git-send-email-meenakshi.aggarwal@nxp.com> X-Mailer: git-send-email 1.9.1 X-Virus-Scanned: ClamAV using ClamSMTP Subject: [PATCH] SD/eMMC : Fix Command Argument for SD/eMMC R/W operation. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Jan 2019 07:35:51 -0000 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 --- 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