From patchwork Wed Apr 3 14:08:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amar X-Patchwork-Id: 15867 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 8975423E21 for ; Wed, 3 Apr 2013 13:51:20 +0000 (UTC) Received: from mail-we0-f198.google.com (mail-we0-f198.google.com [74.125.82.198]) by fiordland.canonical.com (Postfix) with ESMTP id 51F8CA18751 for ; Wed, 3 Apr 2013 13:51:20 +0000 (UTC) Received: by mail-we0-f198.google.com with SMTP id k14sf2076586wer.5 for ; Wed, 03 Apr 2013 06:51:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-beenthere:x-received:received-spf :x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-auditid:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-brightmail-tracker:x-brightmail-tracker :dlp-filter:x-mtr:x-cfilter-loop:x-gm-message-state :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:x-google-group-id:list-post:list-help :list-archive:list-unsubscribe; bh=zxaq07UUBzd2iQbj04sGtqxPmsrr/yJoBtn9NLfrhJI=; b=UNypt9wNbD6cmuqNtFIATb592md29sAEG6x6vLIJkAKUO6+j37Vt7eStig0IZZd8KO raj/NP75Rp7gXm3NLVOFSm8gNRwxzvQnIjtSTbwlqpOY9LQbtQ1lveL037hITj83AKiP yWD63EG2hLxu8Y1F6rWghHZ5KIjxYNHpnuqG0IB3B1uANY5Dq6o7NzI6CkH/aQiDLphU 7UDkJNGgLKnJjU2H6hYN/J7EmbocDY67K5E4fFXvtPCLVnrWJH239Q9Khb8ybU2MbRMj 9e66tAuMLmtIlo/y8ohwVftnuxek5DJVus+Uxp6Ht0ASVn1EO0CZy9FWj41yqGkwVtEU 1JmA== X-Received: by 10.180.96.225 with SMTP id dv1mr692038wib.6.1364997080244; Wed, 03 Apr 2013 06:51:20 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.180.198.112 with SMTP id jb16ls1325987wic.2.canary; Wed, 03 Apr 2013 06:51:20 -0700 (PDT) X-Received: by 10.180.37.166 with SMTP id z6mr22948108wij.34.1364997080188; Wed, 03 Apr 2013 06:51:20 -0700 (PDT) Received: from mail-ve0-f170.google.com (mail-ve0-f170.google.com [209.85.128.170]) by mx.google.com with ESMTPS id lv6si2508382wjb.70.2013.04.03.06.51.19 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 03 Apr 2013 06:51:20 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.170 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.170; Received: by mail-ve0-f170.google.com with SMTP id 15so1703604vea.1 for ; Wed, 03 Apr 2013 06:51:19 -0700 (PDT) X-Received: by 10.58.224.101 with SMTP id rb5mr1283037vec.17.1364997078943; Wed, 03 Apr 2013 06:51:18 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.59.4.204 with SMTP id cg12csp171225ved; Wed, 3 Apr 2013 06:51:18 -0700 (PDT) X-Received: by 10.68.52.197 with SMTP id v5mr2552011pbo.200.1364997077238; Wed, 03 Apr 2013 06:51:17 -0700 (PDT) Received: from mailout2.samsung.com (mailout2.samsung.com. [203.254.224.25]) by mx.google.com with ESMTP id l6si6836952pav.170.2013.04.03.06.51.16; Wed, 03 Apr 2013 06:51:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of amarendra.xt@samsung.com designates 203.254.224.25 as permitted sender) client-ip=203.254.224.25; Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MKO005M1MHGPTG0@mailout2.samsung.com>; Wed, 03 Apr 2013 22:51:16 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.126]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id D5.9A.05174.3D33C515; Wed, 03 Apr 2013 22:51:15 +0900 (KST) X-AuditID: cbfee68f-b7f4a6d000001436-9a-515c33d3ab66 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id B6.81.13494.3D33C515; Wed, 03 Apr 2013 22:51:15 +0900 (KST) Received: from chrome-ubuntu.sisodomain.com ([107.108.73.106]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MKO00KW6MDEHT20@mmp2.samsung.com>; Wed, 03 Apr 2013 22:51:15 +0900 (KST) From: Amar To: u-boot@lists.denx.de, mk7.kang@samsung.com Cc: patches@linaro.org, sjg@chromium.org, chander.kashyap@linaro.org, afleming@gmail.com, jh80.chung@samsung.com, u-boot-review@google.com Subject: [PATCH V8 3/9] DWMMC: Initialise dwmci and resolve EMMC read write issues Date: Wed, 03 Apr 2013 10:08:27 -0400 Message-id: <1364998113-13428-4-git-send-email-amarendra.xt@samsung.com> X-Mailer: git-send-email 1.8.0 In-reply-to: <1364998113-13428-1-git-send-email-amarendra.xt@samsung.com> References: <1364998113-13428-1-git-send-email-amarendra.xt@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrLLMWRmVeSWpSXmKPExsWyRsSkTveycUygwb3d1hY3rv9ks3i4/iaL xY1fbawWHUdaGC2mHP7CYvFtyzZGi+WvN7JbvN3bye7A4TG74SKLx85Zd9k9Fmwq9bhzbQ+b x9k7Oxg9+rasYgxgi+KySUnNySxLLdK3S+DKaFm8nKngpHT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bwdYqxBQyZ2jD1knMPIuYGRYxSiaWpBcUJyUnmukV5yY W1yal66XnJ+7iREcV8+kdzCuarA4xCjAwajEw3viS1SgEGtiWXFl7iFGCQ5mJRFezuPRgUK8 KYmVValF+fFFpTmpxYcYk4GOmsgsJZqcD4z5vJJ4Q2MTc1NjU0sTCxMzS9KElcR5D7ZaBwoJ pCeWpGanphakFsFsYeLglGpgzFv/4hxf2PmClqJbHzJPtgjKSh+ekBqs/qer94bhgodW7TKm vronxPMt/BiVX5Z8WhMZd6Nv0dEvrwUjV7hfULcLzSxm6ErpvLku7etJgwt/MmbMvGnSeu7G urYFh2IXfv+lntQifTvLd61K1KLP+unBf6J1FxRwL3v1Z++fdUm950p3bTyxSImlOCPRUIu5 qDgRAN2lJ5rvAgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-Gm-Message-State: ALoCoQnP+mG87X/Ft0RzFCfu8OmF4veQ71qNp9c5doFQP535mGdHxJoKGtpdk0xNCswjPHmPTn6K X-Original-Sender: patch@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.170 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This patch enumerates dwmci and set auto stop command during dwmci initialisation. EMMC read/write is not happening in current implementation due to improper fifo size computation. Hence modified the fifo size computation to resolve EMMC read write issues. Signed-off-by: Amar --- Changes since V1: 1)Created the macros RX_WMARK_SHIFT and RX_WMARK_MASK in header file. Changes since V2: 1)Updation of commit message and resubmition of proper patch set. Changes since V3: 1)Updated to use the macro DWMCI_CTRL_SEND_AS_CCSD instead of the hard coded value (1 << 10). Changes since V4: 1)Updated the function dwmci_send_cmd() to use get_timer() instead of using mdelay(1). Changes since V5: 1)Updated in response to review comments. Changes since V6: No change. Changes since V7: 1)Updated the function dwmci_setup_bus() to return 0 if (freq == 0). This is to avoid the run time exception "raise:Signal # 8 caught". drivers/mmc/dw_mmc.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c index 4070d4e..963a515 100644 --- a/drivers/mmc/dw_mmc.c +++ b/drivers/mmc/dw_mmc.c @@ -129,13 +129,13 @@ static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, unsigned int timeout = 100000; u32 retry = 10000; u32 mask, ctrl; + ulong start = get_timer(0); while (dwmci_readl(host, DWMCI_STATUS) & DWMCI_BUSY) { - if (timeout == 0) { + if (get_timer(start) > timeout) { printf("Timeout on data busy\n"); return TIMEOUT; } - timeout--; } dwmci_writel(host, DWMCI_RINTSTS, DWMCI_INTMSK_ALL); @@ -143,7 +143,6 @@ static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, if (data) dwmci_prepare_data(host, data); - dwmci_writel(host, DWMCI_CMDARG, cmd->cmdarg); if (data) @@ -231,9 +230,8 @@ static int dwmci_setup_bus(struct dwmci_host *host, u32 freq) int timeout = 10000; unsigned long sclk; - if (freq == host->clock) + if ((freq == host->clock) || (freq == 0)) return 0; - /* * If host->mmc_clk didn't define, * then assume that host->bus_hz is source clock value. @@ -314,7 +312,7 @@ static void dwmci_set_ios(struct mmc *mmc) static int dwmci_init(struct mmc *mmc) { struct dwmci_host *host = (struct dwmci_host *)mmc->priv; - u32 fifo_size, fifoth_val; + u32 fifo_size, fifoth_val, ier; dwmci_writel(host, DWMCI_PWREN, 1); @@ -323,6 +321,14 @@ static int dwmci_init(struct mmc *mmc) return -1; } + /* Enumerate at 400KHz */ + dwmci_setup_bus(host, mmc->f_min); + + /* Set auto stop command */ + ier = dwmci_readl(host, DWMCI_CTRL); + ier |= DWMCI_CTRL_SEND_AS_CCSD; + dwmci_writel(host, DWMCI_CTRL, ier); + dwmci_writel(host, DWMCI_RINTSTS, 0xFFFFFFFF); dwmci_writel(host, DWMCI_INTMASK, 0); @@ -332,11 +338,13 @@ static int dwmci_init(struct mmc *mmc) dwmci_writel(host, DWMCI_BMOD, 1); fifo_size = dwmci_readl(host, DWMCI_FIFOTH); - if (host->fifoth_val) + fifo_size = ((fifo_size & RX_WMARK_MASK) >> RX_WMARK_SHIFT) + 1; + if (host->fifoth_val) { fifoth_val = host->fifoth_val; - else - fifoth_val = MSIZE(0x2) | RX_WMARK(fifo_size/2 -1) | - TX_WMARK(fifo_size/2); + } else { + fifoth_val = MSIZE(0x2) | RX_WMARK(fifo_size / 2 - 1) | + TX_WMARK(fifo_size / 2); + } dwmci_writel(host, DWMCI_FIFOTH, fifoth_val); dwmci_writel(host, DWMCI_CLKENA, 0);