From patchwork Tue Nov 8 15:21:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 81338 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp1603800qge; Tue, 8 Nov 2016 07:21:52 -0800 (PST) X-Received: by 10.99.50.67 with SMTP id y64mr7491532pgy.146.1478618512203; Tue, 08 Nov 2016 07:21:52 -0800 (PST) Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id n22si11491028pfj.253.2016.11.08.07.21.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Nov 2016 07:21:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 88ED981D6C; Tue, 8 Nov 2016 07:21:48 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received: from mail-pf0-x22f.google.com (mail-pf0-x22f.google.com [IPv6:2607:f8b0:400e:c00::22f]) (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 1BC9581D4F for ; Tue, 8 Nov 2016 07:21:47 -0800 (PST) Received: by mail-pf0-x22f.google.com with SMTP id d2so109740245pfd.0 for ; Tue, 08 Nov 2016 07:21:50 -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=aAKHgzQThUrKA0nu5c2By4D2hopWtQlUNB2EIXN97/U=; b=FRhZ4HSgbnlQEUr8JKvrnpIy20UypHm+vgQLJNamPs4sUl+WlEIAGdiwLsv2JL+KR8 kvqnMZ7lfgBUgxuUCxr7pfzLbTVZh+smRTKht4sadHYrnypMW8PAk3h+xVRIWr1Smitv Ewpt4wDqvelzPM2/u2r2ZSaEfhQHiXjrHqtzk= 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=aAKHgzQThUrKA0nu5c2By4D2hopWtQlUNB2EIXN97/U=; b=Ra8+dlkNcKIKmzqni9WiH1Cxxb2zRLISD8nJJoSkIjCLTwgI5He/sjmoY2efsmIDup pe8OveoK1eCa7WHdO829M5p+2+L0Bkq7qgNJeDgHkvYaFK5Uq7b6YaZdYtIZnwlTlpO5 RJI0ah9fxydySfsLjr3LhN0omPqdo8pbNrx9zKSWYGdyvWmtgEzc5ojHZfQGqbsiCgvh RnXz6gK01FhhYoly+W7kzA2SmH1suPqFNdrVF0oTIck2vuYJzVhHgu8x4sf5AWwoMfNq 6VIadFsf14ToXq+WKIu058wVLPaxTup2nTNHqNGmU50xDRcWtxM8vPqSozJ+NbnzDHsi tMUw== X-Gm-Message-State: ABUngvcIboiO18VXDdlD3IJEoNlI5tvy43FChUzYpBybPDbnaTVd5dnsR16L+t12q2zO0NCT X-Received: by 10.98.58.81 with SMTP id h78mr24492990pfa.50.1478618510034; Tue, 08 Nov 2016 07:21:50 -0800 (PST) Received: from localhost.localdomain ([45.56.159.76]) by smtp.gmail.com with ESMTPSA id g10sm7971804pac.14.2016.11.08.07.21.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 08 Nov 2016 07:21:49 -0800 (PST) From: Haojian Zhuang To: ryan.harkin@linaro.org, edk2-devel@lists.01.org, leif.lindholm@linaro.org, ard.biesheuvel@linaro.org Date: Tue, 8 Nov 2016 23:21:06 +0800 Message-Id: <1478618476-12608-2-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1478618476-12608-1-git-send-email-haojian.zhuang@linaro.org> References: <1478618476-12608-1-git-send-email-haojian.zhuang@linaro.org> Subject: [edk2] [PATCH v4 01/11] 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: , Cc: Haojian Zhuang MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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 --- EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) -- 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Leif Lindholm 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;