From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-x22e.google.com (mail-pf0-x22e.google.com [IPv6:2607:f8b0:400e:c00::22e]) (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 C5EAF1A1EEA for ; Wed, 21 Sep 2016 08:02:37 -0700 (PDT) Received: by mail-pf0-x22e.google.com with SMTP id 21so20156066pfy.0 for ; Wed, 21 Sep 2016 08:02:37 -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=wis1CktL9zMQnICUzYQg00AjY+1OD7uGz2lGEJ/YNNQ=; b=iNef1+QoBUUZLXKcxuvzNpCQVHwS5wG+ZNvkEFFCrcdNzy2y9yi5BvRxPzz7wPVbd9 u4hbimskUN54z6e4Ect/UwauI3cmguS3K6/m4/y2Uv1N781VldOvz1pAJxFqAoh+UlY2 Ce3F/1MYffnddGRKeYSjFaczcUneeec9FPzls= 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=wis1CktL9zMQnICUzYQg00AjY+1OD7uGz2lGEJ/YNNQ=; b=YI+M2moY7AFna6zYwpUnfRugyM3tWOBix0FOjOCgsl//wMZFOFjvbpZ2axGAZEacCC Rf9CIConf24T8wbgWMQsrDXsZDe3HsU8JZkZx2NhiJS1Eiy1jozIhmZuLz2zm7vnNBUl oQfcHuxKCJLVjz3EVVoZTjqThVynQ9DOYE9EwKOFat54fZnq0i877ZVSCb97gClyId10 yaTDN6Nzf2PK3k0XsUwM1byuf63wXNcdIEQVQPr264DZRwb5Vw9nrAq3JEyu/1Pt47x2 oPqOG91d/Kajsjtz27ehcc/chyhWRZju85Gkhx/EtimCwUW3oV/4j7OzSWWfFmle+sN/ TCPA== X-Gm-Message-State: AE9vXwMhIbDxS99FMcru1RhxY9jnsqQdHJKaHQoqyYOaFWbLnzYHJbrVtvIKfT+KhRuvOulc X-Received: by 10.98.156.81 with SMTP id f78mr33240739pfe.139.1474470157214; Wed, 21 Sep 2016 08:02:37 -0700 (PDT) Received: from localhost.localdomain ([104.237.91.137]) by smtp.gmail.com with ESMTPSA id 85sm28914221pfw.92.2016.09.21.08.02.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Sep 2016 08:02:36 -0700 (PDT) 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: Wed, 21 Sep 2016 23:02:18 +0800 Message-Id: <1474470147-23156-2-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1474470147-23156-1-git-send-email-haojian.zhuang@linaro.org> References: <1474470147-23156-1-git-send-email-haojian.zhuang@linaro.org> Subject: [PATCH v3 01/10] 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: Wed, 21 Sep 2016 15:02:38 -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 --- 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..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; -- 2.7.4