From patchwork Wed Nov 7 21:46:03 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mela Custodio X-Patchwork-Id: 197730 X-Patchwork-Delegate: afleming@freescale.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id B44492C00C6 for ; Thu, 8 Nov 2012 08:46:18 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0C6644A793; Wed, 7 Nov 2012 22:46:17 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 53BXT-cB175q; Wed, 7 Nov 2012 22:46:16 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 858974A784; Wed, 7 Nov 2012 22:46:15 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 948924A784 for ; Wed, 7 Nov 2012 22:46:12 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id p5kTuikwuOkh for ; Wed, 7 Nov 2012 22:46:11 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-pb0-f44.google.com (mail-pb0-f44.google.com [209.85.160.44]) by theia.denx.de (Postfix) with ESMTPS id 080A04A783 for ; Wed, 7 Nov 2012 22:46:09 +0100 (CET) Received: by mail-pb0-f44.google.com with SMTP id ro8so1497262pbb.3 for ; Wed, 07 Nov 2012 13:46:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=frs71jKXaXYqeAma3b58HrNIBJELDEElnxUOVYBclkk=; b=i8IltfyLWUKZXKouaUp7WHCiM3wrYPY8J8sjEQJZdZj7RNf2R0cKufDHsCNbdlLLlY 2wz6RPnahRdPitgsGaV5ztTUpuQzqNZZu0GDICXy7hniR8oFjupepU19tNnYgn5+yADs Zt5BCrR4atnkC4G7uVBTfC8QKHCjUbgpsRIXvcIS1aXCP3RPkMO1LpAfMRKnb9KSfn61 jY0beN3zthWwgYaHK/vaRdX9D9S1h/GdDnbRDwzYrm446awoJ5hGuhYezGzVG1yyn7nL YjDHYrUXMvOAlvaBWqK0wbH7ZjYPN96o04mVHn1DfGSVq237TE0//uOgT6GMK4CljQYp Ge9Q== Received: by 10.68.136.135 with SMTP id qa7mr17380324pbb.157.1352324766736; Wed, 07 Nov 2012 13:46:06 -0800 (PST) Received: from localhost (softbank126017003184.bbtec.net. [126.17.3.184]) by mx.google.com with ESMTPS id j8sm14866320paz.30.2012.11.07.13.46.03 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 07 Nov 2012 13:46:05 -0800 (PST) Date: Thu, 8 Nov 2012 06:46:03 +0900 From: Rommel G Custodio To: u-boot@lists.denx.de, Jaehoon Chung Message-ID: <20121107214603.GA74000@crg> MIME-Version: 1.0 User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Andy Fleming Subject: [U-Boot] [RFC, PATCH] mmc: prepare SDHCI_HOST_CONTROL for SDMA operation X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de modification for commit 804c7f422169212e92530e1ddaf74bf1ca9ebfa1 The original patch contained a bug. Using a char with sdhci_readl/sdhci_writel operation. The adjacent bytes to SDHCI_HOST_CONTROL (specially SDHCI_POWER_CONTROL) get mangled and can result in the controller entering an unstable state. This patch also moves the process inside sdhci_init(). Signed-off-by: Rommel G Custodio Acked-by: Jaehoon Chung --- drivers/mmc/sdhci.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c index 7845f87..fae2169 100644 --- a/drivers/mmc/sdhci.c +++ b/drivers/mmc/sdhci.c @@ -82,13 +82,6 @@ static int sdhci_transfer_data(struct sdhci_host *host, struct mmc_data *data, unsigned int start_addr) { unsigned int stat, rdy, mask, timeout, block = 0; -#ifdef CONFIG_MMC_SDMA - unsigned char ctrl; - ctrl = sdhci_readl(host, SDHCI_HOST_CONTROL); - ctrl &= ~SDHCI_CTRL_DMA_MASK; - ctrl |= SDHCI_CTRL_SDMA; - sdhci_writel(host, ctrl, SDHCI_HOST_CONTROL); -#endif timeout = 1000000; rdy = SDHCI_INT_SPACE_AVAIL | SDHCI_INT_DATA_AVAIL; @@ -386,6 +379,14 @@ int sdhci_init(struct mmc *mmc) { struct sdhci_host *host = (struct sdhci_host *)mmc->priv; +#ifdef CONFIG_MMC_SDMA + unsigned int ctrl; + ctrl = sdhci_readl(host, SDHCI_HOST_CONTROL); + ctrl &= ~SDHCI_CTRL_DMA_MASK; + ctrl |= SDHCI_CTRL_SDMA; + sdhci_writel(host, ctrl, SDHCI_HOST_CONTROL); +#endif + if ((host->quirks & SDHCI_QUIRK_32BIT_DMA_ADDR) && !aligned_buffer) { aligned_buffer = memalign(8, 512*1024); if (!aligned_buffer) {