From patchwork Fri Feb 26 09:27:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 62972 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp608485lbc; Fri, 26 Feb 2016 01:28:17 -0800 (PST) X-Received: by 10.98.80.91 with SMTP id e88mr682860pfb.62.1456478897281; Fri, 26 Feb 2016 01:28:17 -0800 (PST) Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id ff7si10014606pab.184.2016.02.26.01.28.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Feb 2016 01:28:17 -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; 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; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 9CCEB1A1E12; Fri, 26 Feb 2016 01:28:21 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received: from mail-pf0-x22b.google.com (mail-pf0-x22b.google.com [IPv6:2607:f8b0:400e:c00::22b]) (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 DD7E31A1E0D for ; Fri, 26 Feb 2016 01:28:19 -0800 (PST) Received: by mail-pf0-x22b.google.com with SMTP id w128so1652948pfb.2 for ; Fri, 26 Feb 2016 01:28:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=message-id:from:to:cc:subject:date:in-reply-to:references :mime-version; bh=znKsCpZVhoDHU3YwoS9uYPfZSklWBlG7cf9VCV7xMU4=; b=XiU0V7eNubre3aHWOI238xqB640gDbC/ONGQjtju+N6zBR28BWWUnq4auDUnpJaNwV YsRVmAa6vpZsDRmvYSqHesvab2TGwptzF8Ku5bfEXe5HyaLJTosqdZPIc+uIdHZLQKkE j33H/3jLcwL/Ky5XgByXGBwGCq9ADMDPmN73E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:from:to:cc:subject:date:in-reply-to :references:mime-version; bh=znKsCpZVhoDHU3YwoS9uYPfZSklWBlG7cf9VCV7xMU4=; b=YU733cnA3As1inIZI5ptZT+bxcmeg/b2Zt6vpE3ioDbt2yu2a27I6X6PKWQAFxQWtJ vv17sf1/n56BPoAfTgBXEynnEm2frgAqUFqj0Q/qesaJGizFvOqYUSyWJZxddvxTuXvi tEX98M3bys/BEEJFz7j5uTwXKmEwzlrHmF3WrmXbOiAfjLkDg8zgh9j9/UySpyR5xsZK +x7Li4r3mg9UAIXJjfHJcuUVmOmNz9gvMuudpzbb/wG28q1Zddf2FdNqgOaGj9wZT4eJ vK9pOKFa5t0bwfGcamJNlz2ihfKy8CKc3wwjS5pxFunA/m/vePEf1P7C92frtdIbqXRN L9TQ== X-Gm-Message-State: AD7BkJI70RQy6mIi8DUt7B59dHw/K8G/R9MPiXHWKgdD25FXFEEip1rUeBnk/eGwSTTZKVV+ X-Received: by 10.98.14.146 with SMTP id 18mr638796pfo.35.1456478894815; Fri, 26 Feb 2016 01:28:14 -0800 (PST) Received: from mail.hotmail.com (blu004-wss1s5.hotmail.com. [134.170.2.220]) by smtp.gmail.com with ESMTPSA id yx4sm17884930pac.5.2016.02.26.01.28.13 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Feb 2016 01:28:13 -0800 (PST) Received: from BLU437-SMTP102 ([134.170.2.215]) by BLU004-WSS1S5.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.23008); Fri, 26 Feb 2016 01:28:12 -0800 X-TMN: [hFK+LHxY8ROp9OmygV0DJzAZBIosSkhN] Message-ID: From: Haojian Zhuang To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, ard.biesheuvel@linaro.org Date: Fri, 26 Feb 2016 17:27:48 +0800 X-Mailer: git-send-email 1.9.1 In-Reply-To: <1456478876-23434-1-git-send-email-haojian.zhuang@linaro.org> References: <1456478876-23434-1-git-send-email-haojian.zhuang@linaro.org> X-OriginalArrivalTime: 26 Feb 2016 09:28:09.0970 (UTC) FILETIME=[01D6DD20:01D17078] MIME-Version: 1.0 Cc: Haojian Zhuang Subject: [edk2] [PATCH 1/9] MmcDxe: wait OCR busy bit free X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , 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(-) -- 1.9.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c b/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c index 2d8038f..0b0a044 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;