From patchwork Tue Mar 22 12:48:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 64163 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp2041054lbc; Tue, 22 Mar 2016 05:48:35 -0700 (PDT) X-Received: by 10.66.193.131 with SMTP id ho3mr53281517pac.154.1458650915218; Tue, 22 Mar 2016 05:48:35 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id tr4si2232877pac.222.2016.03.22.05.48.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Mar 2016 05:48:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 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 802D61A1FBE; Tue, 22 Mar 2016 05:48:58 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received: from mail-pf0-x232.google.com (mail-pf0-x232.google.com [IPv6:2607:f8b0:400e:c00::232]) (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 2EAFF1A1FBE for ; Tue, 22 Mar 2016 05:48:57 -0700 (PDT) Received: by mail-pf0-x232.google.com with SMTP id u190so311585899pfb.3 for ; Tue, 22 Mar 2016 05:48:33 -0700 (PDT) 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=znKsCpZVhoDHU3YwoS9uYPfZSklWBlG7cf9VCV7xMU4=; b=H6OCVsQ4T/oupURNrPvr3NWr4F30OygPLcdkEtjD3Ao4XGFCValXBKQoS/kpTqQI6b srGcokpuvbUzK57kSprt6JW+m+5uqkThvs8uBetEXfDr4QDLIw2Zxgk1ahrX5u7qp68n iTZl6JLKuVs2wegasRxWqPgWzKuXKq/pnwtHQ= 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=znKsCpZVhoDHU3YwoS9uYPfZSklWBlG7cf9VCV7xMU4=; b=iX8i+TWvwmXQX/sIMOdD2Vr4xw+lGGXDozeuNeweGE3AzV/d/DDBgVEd99W3EN+5gD oPiFnGPV8ufjMJUEVh63Olpt5TWNtRYkocQZtJz/B8CdDc0w6U1qgF5CI5o2UX7dy4lc mXpvdXNhRYdjy5P5arnZaciKvc9bKXgyXVyJxatEWT57s25aIpwN5SzIDlEF9fYZ6bFp qyK53c4QRWW1jvkN68lgt5YkyFmUaygcvLs56nJhrQeQskUq0AxZPX/eucLGAFr6wL6+ PrnGywVwO7Vs2Fqz0Rwou/8q81n6QJcjqwqfvuH1afj6GXim1fkiJgshU9QzqUPM4mz6 c0sQ== X-Gm-Message-State: AD7BkJJlo44N8Asolkb1Zo5hrPVzXdj4kz+Vt/R4zOcSPX5Na05prz9HPks3ucJ3OC0VaYzM X-Received: by 10.98.67.67 with SMTP id q64mr54087758pfa.44.1458650910106; Tue, 22 Mar 2016 05:48:30 -0700 (PDT) Received: from localhost.localdomain ([104.237.91.127]) by smtp.gmail.com with ESMTPSA id 9sm48245982pft.44.2016.03.22.05.48.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 22 Mar 2016 05:48:29 -0700 (PDT) From: Haojian Zhuang To: ryan.harkin@linaro.org, edk2-devel@lists.01.org, leif.lindholm@linaro.org, ard.biesheuvel@linaro.org Date: Tue, 22 Mar 2016 20:48:13 +0800 Message-Id: <1458650901-7229-2-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1458650901-7229-1-git-send-email-haojian.zhuang@linaro.org> References: <1458650901-7229-1-git-send-email-haojian.zhuang@linaro.org> Subject: [edk2] [PATCH v2 1/9] MmcDxe: wait OCR busy bit free X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: EDK II Development List-Unsubscribe: , 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(-) -- 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;