From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-x235.google.com (mail-wm0-x235.google.com [IPv6:2a00:1450:400c:c09::235]) (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 E5D0A81D27 for ; Tue, 8 Nov 2016 11:27:42 -0800 (PST) Received: by mail-wm0-x235.google.com with SMTP id a197so265747094wmd.0 for ; Tue, 08 Nov 2016 11:27:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=ycFWJs2Qmn8AF4MRkGKnvfPSlpF9KG2Im7JgjtucTs8=; b=Rq030Y95TOXWYuoduyaVEV0rUj5G6ZKkGidkAgPrQmdFvY6Hz6VlPVER9I3zwKxsg9 4teYlYk8oR3B/AF4/3+Smr/jzc7j7AgqO46dC8biBclbeJ4NGarw+G8IiSgKsGobckzT hNFBc4wc6Dd38K6sXIwtMRowVQsMIPq5rrMXo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ycFWJs2Qmn8AF4MRkGKnvfPSlpF9KG2Im7JgjtucTs8=; b=bAIPkHPIG4RZTP4/cDsIrGXDYvyKJvncBR0V3FiJrQXMA/71ALV2gCDrKn+JA1R30R xm5/fB9Qx7K+jjueL91AiI3Dha/dyF9wuEV3+0QUpMqo2QJ6ksIwzonQlm+q3CzbEGjA 71OA9ZUM1hZ8AuWVM3hKkLEOZ63zx4U6wH6RlkzKR8c0by2QmZdKYrQINX/jJWGZHgR9 4YcycA56oBt0JkmRVnrxk1a1ubR0XuFtIxPQ8WnDQbzSIjM7vwAYMGLiy6RORSf8k5ps G++Ql2joloVlaDEAkq6L3qtK/EJmosi8zWGheRcqPv2pmLq8esXSF/RREIBhkZN91acF /dMg== X-Gm-Message-State: ABUngveWSh4hFKUP/eCqd2S71NXACv9RW9EgVgsN8alALgOCpSq5711xaUFdduf6dqMWcgQW X-Received: by 10.194.129.130 with SMTP id nw2mr14088733wjb.100.1478633264086; Tue, 08 Nov 2016 11:27:44 -0800 (PST) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id 70sm2691715wmv.1.2016.11.08.11.27.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Nov 2016 11:27:43 -0800 (PST) Date: Tue, 8 Nov 2016 19:27:41 +0000 From: Leif Lindholm To: Haojian Zhuang Cc: ryan.harkin@linaro.org, edk2-devel@lists.01.org, ard.biesheuvel@linaro.org Message-ID: <20161108192741.GI27644@bivouac.eciton.net> References: <1478618476-12608-1-git-send-email-haojian.zhuang@linaro.org> <1478618476-12608-2-git-send-email-haojian.zhuang@linaro.org> MIME-Version: 1.0 In-Reply-To: <1478618476-12608-2-git-send-email-haojian.zhuang@linaro.org> User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [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: , X-List-Received-Date: Tue, 08 Nov 2016 19:27:43 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Nov 08, 2016 at 11:21:06PM +0800, Haojian Zhuang wrote: > 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 I will wait for a final Tested-by: from Ryan, but from a code point of view: 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 >