From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-x229.google.com (mail-pf0-x229.google.com [IPv6:2607:f8b0:400e:c00::229]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B852A81DBD for ; Sat, 12 Nov 2016 22:48:09 -0800 (PST) Received: by mail-pf0-x229.google.com with SMTP id d2so22683680pfd.0 for ; Sat, 12 Nov 2016 22:48:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rkBcSU3z58o7vMOHQJiUttc3wfwrOmFyaAo8TMSBxj0=; b=dPDfV0QcgmhUZC9LNblr5NqpTuJ1cikMboMNhfTacLhb4LnlJgv/vuPYz7pJ6iCtRJ FCB6ba+jJNmnzMsqYS3N1BakI5JDZ8v1h4XCrLSw63qC35OoFtqzAY1HyjoVSg0qC041 l9PyDjsWlvSWJuxsu+CMtO4P28oFZ4wOgG1NE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rkBcSU3z58o7vMOHQJiUttc3wfwrOmFyaAo8TMSBxj0=; b=IRrdiT5pmAZ3Eh7uRKbrfiH5ve4nit2pbCGH6pJuSJYHoEzZMn9rZvmpEVvYy9epTl jLFIYvDsi03vr3GN4VF382SqgRYizHt0WdOLQciM2LvQEfMCf6jfhf0cnWAod/goi/8S R+ot6PVwKUBMAE5E0Be+jAUssLtNlQTJz8Y422yySG96c1UidLxwyKO/Shgkap8WRSUm IG0pDnl8XR/7PpUNBSG4c33eqoK3oKHsVUthWfOFpJPzdyVV2ZD15sSDbYTD6aFFb3gx kFiwvygpkVS7lwkhZlbmvv2Zj8hP2J/D8Q09cfsHYDabeVANP22DBe8bbOpf/P/YqJu0 6D8g== X-Gm-Message-State: ABUngvcBzUV0eqNj1vWN0d5cGUKfC4LooqLDG7f6v6mOj/UE3cN4qqJOG6UwMv6f6J61Q68J X-Received: by 10.98.15.206 with SMTP id 75mr23761754pfp.105.1479019693773; Sat, 12 Nov 2016 22:48:13 -0800 (PST) Received: from localhost.localdomain ([45.56.159.75]) by smtp.gmail.com with ESMTPSA id a66sm26198365pfa.64.2016.11.12.22.48.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 12 Nov 2016 22:48:13 -0800 (PST) From: Haojian Zhuang To: ryan.harkin@linaro.org, edk2-devel@lists.01.org, leif.lindholm@linaro.org, ard.biesheuvel@linaro.org Cc: Haojian Zhuang Date: Sun, 13 Nov 2016 14:47:50 +0800 Message-Id: <1479019678-12621-2-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1479019678-12621-1-git-send-email-haojian.zhuang@linaro.org> References: <1479019678-12621-1-git-send-email-haojian.zhuang@linaro.org> Subject: [PATCH v5 1/9] MmcDxe: wait OCR busy bit free X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Nov 2016 06:48:09 -0000 According to eMMC spec, OCR.PowerUp bit is also busy bit. If the busy bit is '0', CMD1 should be sent and OCR should be fetched again. And add a timeout counter on the repeated steps. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Haojian Zhuang Tested-by: Ryan Harkin Reviewed-by: Leif Lindholm --- EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c b/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c index 2d8038f..3f72b7f 100644 --- a/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c +++ b/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c @@ -222,14 +222,19 @@ MmcIdentificationMode ( // Send CMD1 to get OCR (MMC) // This command only valid for MMC and eMMC - Status = MmcHost->SendCommand (MmcHost, MMC_CMD1, EMMC_CMD1_CAPACITY_GREATER_THAN_2GB); - if (Status == EFI_SUCCESS) { + Timeout = MAX_RETRY_COUNT; + do { + Status = MmcHost->SendCommand (MmcHost, MMC_CMD1, EMMC_CMD1_CAPACITY_GREATER_THAN_2GB); + if (EFI_ERROR (Status)) + break; Status = MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_OCR, (UINT32 *)&OcrResponse); if (EFI_ERROR (Status)) { DEBUG ((EFI_D_ERROR, "MmcIdentificationMode() : Failed to receive OCR, Status=%r.\n", Status)); return Status; } - + Timeout--; + } while (!OcrResponse.Ocr.PowerUp && (Timeout > 0)); + if (Status == EFI_SUCCESS) { if (!OcrResponse.Ocr.PowerUp) { DEBUG ((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD1): Card initialisation failure, Status=%r.\n", Status)); return EFI_DEVICE_ERROR; -- 2.7.4