From c49f298d28cb90c332f8d495a6dfb355bc4014f0 Mon Sep 17 00:00:00 2001 From: "Loh, Tien Hock" Date: Fri, 22 Feb 2019 15:58:03 +0800 Subject: [PATCH] EmbeddedPkg/MmcDxe: Enable 4-bit mode even if SD_HIGH_SPEED is not supported If SD doesn't support SD_HIGH_SPEED, function should still continue to setup SD to go into 4 bits more if it is supported. Currently, the code inadvertently exits early, but with a EFI_SUCCESS return code, and so execution proceeds without ever attempting to enable 4-bit mode. Since not having SD_HIGH_SPEED support is not an error, downgrade the message that reports this to DEBUG_INFO. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Loh Tien Hock Reviewed-by: Ard Biesheuvel --- .../Universal/MmcDxe/MmcIdentification.c | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c b/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c index f661a0c900..7079fa6406 100755 --- a/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c +++ b/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c @@ -473,28 +473,27 @@ InitializeSdMmcDevice ( } if (!(Buffer[3] & SD_HIGH_SPEED_SUPPORTED)) { - DEBUG ((DEBUG_ERROR, "%a : High Speed not supported by Card %r\n", __FUNCTION__, Status)); - return Status; - } - - Speed = SD_HIGH_SPEED; - - /* SD Switch, Mode:1, Group:0, Value:1 */ - CmdArg = CreateSwitchCmdArgument(1, 0, 1); - Status = MmcHost->SendCommand (MmcHost, MMC_CMD6, CmdArg); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a (MMC_CMD6): Error and Status = %r\n", __FUNCTION__, Status)); - return Status; + DEBUG ((DEBUG_INFO, "%a : High Speed not supported by Card\n", __FUNCTION__)); } else { - Status = MmcHost->ReadBlockData (MmcHost, 0, SWITCH_CMD_DATA_LENGTH, Buffer); + Speed = SD_HIGH_SPEED; + + /* SD Switch, Mode:1, Group:0, Value:1 */ + CmdArg = CreateSwitchCmdArgument(1, 0, 1); + Status = MmcHost->SendCommand (MmcHost, MMC_CMD6, CmdArg); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a (MMC_CMD6): ReadBlockData Error and Status = %r\n", __FUNCTION__, Status)); + DEBUG ((DEBUG_ERROR, "%a (MMC_CMD6): Error and Status = %r\n", __FUNCTION__, Status)); return Status; - } + } else { + Status = MmcHost->ReadBlockData (MmcHost, 0, SWITCH_CMD_DATA_LENGTH, Buffer); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a (MMC_CMD6): ReadBlockData Error and Status = %r\n", __FUNCTION__, Status)); + return Status; + } - if ((Buffer[4] & SWITCH_CMD_SUCCESS_MASK) != 0x01000000) { - DEBUG((DEBUG_ERROR, "Problem switching SD card into high-speed mode\n")); - return Status; + if ((Buffer[4] & SWITCH_CMD_SUCCESS_MASK) != 0x01000000) { + DEBUG((DEBUG_ERROR, "Problem switching SD card into high-speed mode\n")); + return Status; + } } } } -- 2.39.2