From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-x22c.google.com (mail-pf0-x22c.google.com [IPv6:2607:f8b0:400e:c00::22c]) (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 34A8281E5B for ; Mon, 21 Nov 2016 23:50:45 -0800 (PST) Received: by mail-pf0-x22c.google.com with SMTP id d2so2988663pfd.0 for ; Mon, 21 Nov 2016 23:50:45 -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=GS3Gh5LZf1K7iY9gt9YZJ4+9rkFfNllIyUqGUUC+juA=; b=FxM5Wo0ue02YVdGaN4yOK33TnlMNmFRveZkL41pPlqNuNz89Sf0ed4vW1zxBlTbrGo OC9hr/BHB6+FGGoZJB7mhdc20FPSG92fNnBmvAoOO6avJtE9zy+kPNV8HbLnjyVdkDYa AlGdG3Bt4VqFiSj9vPm/RGlIlT9wXEH7e7eNI= 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=GS3Gh5LZf1K7iY9gt9YZJ4+9rkFfNllIyUqGUUC+juA=; b=dXxJntgpxsaQm8sYfDPEeI4JrekSB9nfjZDgZU6oS4degryYyDiBSP7rJRSpMN7wK0 ErfRtv7HduOEALMDKPm9cXig+UR3xIdLVTD4Mip7JgLGCAuBhQuGVuvTsm7YuPZLx5eT gWqOdGNvISCTQZ0/fVzaSGqSUBBtiGlJL7sRqG/ZwVAKOqOp3oSsR7HLoAB4Hb5BFwch +OMraOiBGc3kkkpj4lKFRxdudyYjZcYzLAIHoAv1ewmw85f6+zfaKuCGyqlHhRvgvA0M H2nwPSGPGvBFoxHiNiRkrvjOZWGs0Q2eDc0l5B3ygNtkovauC+ivfQ5s+08pg/RWgKSL F4mw== X-Gm-Message-State: AKaTC01VJmMbRDahM8Lpg5SFN1p64/Ktc8JiO6jwy6SHUJmW2bckven2Z6xI7+IhZNIb2Zva X-Received: by 10.98.91.129 with SMTP id p123mr24112447pfb.0.1479801044899; Mon, 21 Nov 2016 23:50:44 -0800 (PST) Received: from localhost.localdomain ([45.56.159.13]) by smtp.gmail.com with ESMTPSA id f132sm26323216pfa.72.2016.11.21.23.50.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 21 Nov 2016 23:50:44 -0800 (PST) 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: Tue, 22 Nov 2016 15:50:27 +0800 Message-Id: <1479801028-3587-4-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1479801028-3587-1-git-send-email-haojian.zhuang@linaro.org> References: <1479801028-3587-1-git-send-email-haojian.zhuang@linaro.org> Subject: [PATCH v6 3/4] PL180: update for indentifying SD 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, 22 Nov 2016 07:50:45 -0000 When CMD6 & ACMD51 are added into indentifying SD process, PL180 should also support CMD6 & ACMD51. Otherwise, it'll hang when system tries to read expected data. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Haojian Zhuang Tested-by: Ryan Harkin --- ArmPlatformPkg/Drivers/PL180MciDxe/PL180Mci.c | 29 ++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/ArmPlatformPkg/Drivers/PL180MciDxe/PL180Mci.c b/ArmPlatformPkg/Drivers/PL180MciDxe/PL180Mci.c index 5526aac..b2ba4c0 100644 --- a/ArmPlatformPkg/Drivers/PL180MciDxe/PL180Mci.c +++ b/ArmPlatformPkg/Drivers/PL180MciDxe/PL180Mci.c @@ -63,11 +63,6 @@ MciIsReadOnly ( return (MmioRead32 (FixedPcdGet32 (PcdPL180SysMciRegAddress)) & SYS_MCI_WPROT); } -#if 0 -//Note: This function has been commented out because it is not used yet. -// This function could be used to remove the hardcoded BlockLen used -// in MciPrepareDataPath - // Convert block size to 2^n STATIC UINT32 @@ -87,7 +82,6 @@ GetPow2BlockLen ( return Pow2BlockLen; } -#endif VOID MciPrepareDataPath ( @@ -126,6 +120,23 @@ MciSendCommand ( MciPrepareDataPath (MCI_DATACTL_CARD_TO_CONT); } else if ((MmcCmd == MMC_CMD24) || (MmcCmd == MMC_CMD20)) { MciPrepareDataPath (MCI_DATACTL_CONT_TO_CARD); + } else if (MmcCmd == MMC_CMD6) { + MmioWrite32 (MCI_DATA_TIMER_REG, 0xFFFFFFF); + MmioWrite32 (MCI_DATA_LENGTH_REG, 64); +#ifndef USE_STREAM + MmioWrite32 (MCI_DATA_CTL_REG, MCI_DATACTL_ENABLE | MCI_DATACTL_CARD_TO_CONT | GetPow2BlockLen (64)); +#else + MmioWrite32 (MCI_DATA_CTL_REG, MCI_DATACTL_ENABLE | MCI_DATACTL_CARD_TO_CONT | MCI_DATACTL_STREAM_TRANS); +#endif + } else if (MmcCmd == MMC_ACMD51) { + MmioWrite32 (MCI_DATA_TIMER_REG, 0xFFFFFFF); + /* SCR register is 8 bytes long. */ + MmioWrite32 (MCI_DATA_LENGTH_REG, 8); +#ifndef USE_STREAM + MmioWrite32 (MCI_DATA_CTL_REG, MCI_DATACTL_ENABLE | MCI_DATACTL_CARD_TO_CONT | GetPow2BlockLen (8)); +#else + MmioWrite32 (MCI_DATA_CTL_REG, MCI_DATACTL_ENABLE | MCI_DATACTL_CARD_TO_CONT | MCI_DATACTL_STREAM_TRANS); +#endif } // Create Command for PL180 @@ -223,7 +234,11 @@ MciReadBlockData ( // Read data from the RX FIFO Loop = 0; - Finish = MMCI0_BLOCKLEN / 4; + if (Length < MMCI0_BLOCKLEN) { + Finish = Length / 4; + } else { + Finish = MMCI0_BLOCKLEN / 4; + } // Raise the TPL at the highest level to disable Interrupts. Tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL); -- 2.7.4