From patchwork Tue Mar 5 13:11:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amar X-Patchwork-Id: 15232 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 DE7AF23E00 for ; Tue, 5 Mar 2013 12:54:34 +0000 (UTC) Received: from mail-ve0-f180.google.com (mail-ve0-f180.google.com [209.85.128.180]) by fiordland.canonical.com (Postfix) with ESMTP id 6BCBDA190CE for ; Tue, 5 Mar 2013 12:54:34 +0000 (UTC) Received: by mail-ve0-f180.google.com with SMTP id jx10so5571840veb.25 for ; Tue, 05 Mar 2013 04:54:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=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; bh=hdPJaL+tTziWSE+VWbOgHxFqNS0Y9PqBeaV1xANu7H0=; b=o+6l+DXa7mHpa4uvrJWgbSz5R6cIppXlNfoH4oBagabEMS8bS0Zq3B9OwIBIoWEkuB E4urFsoIP0FqwgBoey+y7mx9pN5KCU/aYDt/08r+czdAf2/wJTpGoSpBBDoQrCSW4Qvg Tc/bVKIB/tNuRrHVkHoItQKCtR9Mz+cWN9QuUmUpfwEDPgz4hQiHyOC4UMuTsyi2z8kv o26tBJqLVuW5VGRQkiuHSVFDzLgCdI5SdtajtMi85gxKddlc2SPFUqKtmVjHDbt0nrjg BdTcBbTXH/1XnQ6HvPyrj596FWgNZ6gmIXAKIzCK9jYS9rByP9+uXIBcbTYXq0LoIgrb OJRw== X-Received: by 10.52.18.148 with SMTP id w20mr8320101vdd.8.1362488073920; Tue, 05 Mar 2013 04:54:33 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.127.98 with SMTP id nf2csp109865veb; Tue, 5 Mar 2013 04:54:33 -0800 (PST) X-Received: by 10.68.221.68 with SMTP id qc4mr26844950pbc.152.1362488072452; Tue, 05 Mar 2013 04:54:32 -0800 (PST) Received: from mailout4.samsung.com (mailout4.samsung.com. [203.254.224.34]) by mx.google.com with ESMTP id nq5si27026229pbc.116.2013.03.05.04.54.31; Tue, 05 Mar 2013 04:54:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of amarendra.xt@samsung.com designates 203.254.224.34 as permitted sender) client-ip=203.254.224.34; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of amarendra.xt@samsung.com designates 203.254.224.34 as permitted sender) smtp.mail=amarendra.xt@samsung.com Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MJ6006Q5UIV4B30@mailout4.samsung.com>; Tue, 05 Mar 2013 21:54:31 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.126]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id 64.BE.18793.60BE5315; Tue, 05 Mar 2013 21:54:31 +0900 (KST) X-AuditID: cbfee68f-b7f6a6d000004969-6f-5135eb064dcf Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 5E.41.03880.60BE5315; Tue, 05 Mar 2013 21:54:30 +0900 (KST) Received: from chrome-ubuntu.sisodomain.com ([107.108.73.106]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MJ600GDUUCXH840@mmp1.samsung.com>; Tue, 05 Mar 2013 21:54:30 +0900 (KST) From: Amar To: u-boot@lists.denx.de Cc: patches@linaro.org, sjg@chromium.org, mk7.kang@samsung.com, chander.kashyap@linaro.org, afleming@gmail.com, jh80.chung@samsung.com Subject: [PATCH V7 03/10] DWMMC: Initialise dwmci and resolve EMMC read write issues Date: Tue, 05 Mar 2013 08:11:23 -0500 Message-id: <1362489090-7745-4-git-send-email-amarendra.xt@samsung.com> X-Mailer: git-send-email 1.8.0 In-reply-to: <1362489090-7745-1-git-send-email-amarendra.xt@samsung.com> References: <1362489090-7745-1-git-send-email-amarendra.xt@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrJLMWRmVeSWpSXmKPExsWyRsSkTpf9tWmgwcsTLBYP199ksZhy+AuL A5PHnWt72AIYo7hsUlJzMstSi/TtErgyTnXMZSrYKVHx/NkktgbGx8JdjJwcEgImEt23Z7JD 2GISF+6tZ+ti5OIQEljKKDGz9Q1TFyMHWNHKVnuQGiGBRYwSy9rsIWp6mSSuTVjCBlLDJqAq 8WsxWI2IgITEr/6rjCA1zAIdjBI7Jm5mBEkIC4RJ3G09xgpiswDVX9n/hgXE5hVwl3i4YA0L xBFyEh/2PAI7iFPAQ2LR54XMEIvdJS71LGIBGSohcJ9N4tLshywQgwQkvk0+xAJxqKzEpgPM EHMkJQ6uuMEygVF4ASPDKkbR1ILkguKk9CJjveLE3OLSvHS95PzcTYzAYDz971n/Dsa7B6wP MSYDjZvILCWanA8M5rySeENjE3NTY1MzI0tLS1PShJXEeeUvyQQKCaQnlqRmp6YWpBbFF5Xm pBYfYmTi4JRqYOSRrHwWvXtjw+XGP59Ozrc5x34hfZPawnSR+hvTxJ7u/eavqZI5J9elt9Zy zuvfmqz5Pz+cUL0bdvOtV3JXuZvCpKc2j35/r6q8MG/Tvt7XgRKagUpbw5bcDj42f099dQhn wY7qxI/VhsdfzLvnx+O64OrDWrvTZ9TnRpxWk7UzarzcfXtBWYkSS3FGoqEWc1FxIgC5ad4p XAIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGIsWRmVeSWpSXmKPExsVy+t9jAV2216aBBhP/G1k8XH+TxWLK4S8s Dkwed67tYQtgjGpgtMlITUxJLVJIzUvOT8nMS7dV8g6Od443NTMw1DW0tDBXUshLzE21VXLx CdB1y8wBmq2kUJaYUwoUCkgsLlbSt8M0ITTETdcCpjFC1zckCK7HyAANJKxhzDjVMZepYKdE xfNnk9gaGB8LdzFycEgImEisbLXvYuQEMsUkLtxbzwZiCwksYpRY1gYU5wKye5kkrk1YwgZS zyagKvFrMVi9iICExK/+q4wgNcwCHYwSOyZuZgRJCAuESdxtPcYKYrMA1V/Z/4YFxOYVcJd4 uGANC8QyOYkPex6xg9icAh4Siz4vZIZY7C5xqWcRywRG3gWMDKsYRVMLkguKk9JzjfSKE3OL S/PS9ZLzczcxgkP9mfQOxlUNFocYBTgYlXh4GY6aBAqxJpYVV+YeYpTgYFYS4d351DRQiDcl sbIqtSg/vqg0J7X4EGMy0FUTmaVEk/OBcZhXEm9obGJuamxqaWJhYmZJmrCSOC/jqScBQgLp iSWp2ampBalFMFuYODilGhhXXTzcuVOp5u72lKtbufnCt2T4Gb9x7Tu/8v7jF3tVPnWb/r6V nfEpYOeif1uKgxjZrb4firG/2psQx//Ar+J4f+emF/M5brEG5E925RRbfDL80jGWkv1u1XLX z8U0M0Z+TvuwqpL18fLUxnOXG6zXfhPce5y72e/F5MMZh7fqhE47ypD5bEmjEktxRqKhFnNR cSIA1Yz75rkCAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-Gm-Message-State: ALoCoQnFEPj7wYNNnGN5BkdWqqdTh6KxD4WLJ/R/kBE21Udv2IF6nLVjzR7dp3Y0CcuwJDih+8ZC 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 Acked-by: Jaehoon Chung Acked-by: Simon Glass --- 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. drivers/mmc/dw_mmc.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c index 4070d4e..3bd1af6 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) @@ -314,7 +313,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 +322,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 +339,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);