From patchwork Fri Feb 15 06:34:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amar X-Patchwork-Id: 14817 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 8650123FC2 for ; Fri, 15 Feb 2013 06:14:05 +0000 (UTC) Received: from mail-ve0-f178.google.com (mail-ve0-f178.google.com [209.85.128.178]) by fiordland.canonical.com (Postfix) with ESMTP id 25793A1879B for ; Fri, 15 Feb 2013 06:14:05 +0000 (UTC) Received: by mail-ve0-f178.google.com with SMTP id db10so2761842veb.37 for ; Thu, 14 Feb 2013 22:14:04 -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=m6BagGw1sHlR1wI0yae4GDYP23LLk6VSjOnvKvrYuJo=; b=DcHaap4jYsqe83lcG2S/yo4AyvhITrKTzcolDH8JE/nzsedvpCtShzjs38Kfge7XEe qNyI9I3cqUpImDqvUQxYrile3Tu3A1v+tBEmAAknoU3T+UcdvNsw+c7wx8cF2K9WU7uD G3IwGnUIgsVuD1kR8G8H4YnSG5AwVzaGj9mPQ+Dncqt/39ySSy2XZ+aMRKEd038sDyWU PTueMV3pQZXUcoSkLgMBjWisaSZxtaYakrlWsfS6Z43VWJOCxeIfL8BmscImVz9mR0Jb Yl8Q4CWKIs75YMYmMu5kleC0sswp5K98OSmwWrtVFy0oQsQ82Yj49lHP7tPay+VOq3Zk tOyQ== X-Received: by 10.58.12.200 with SMTP id a8mr1646819vec.52.1360908844611; Thu, 14 Feb 2013 22:14:04 -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.221.4.5 with SMTP id oa5csp305007vcb; Thu, 14 Feb 2013 22:14:04 -0800 (PST) X-Received: by 10.68.217.202 with SMTP id pa10mr3597673pbc.11.1360908843771; Thu, 14 Feb 2013 22:14:03 -0800 (PST) Received: from mailout1.samsung.com (mailout1.samsung.com. [203.254.224.24]) by mx.google.com with ESMTP id d10si11414251paz.26.2013.02.14.22.14.03; Thu, 14 Feb 2013 22:14:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of amarendra.xt@samsung.com designates 203.254.224.24 as permitted sender) client-ip=203.254.224.24; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of amarendra.xt@samsung.com designates 203.254.224.24 as permitted sender) smtp.mail=amarendra.xt@samsung.com Received: from epcpsbgr1.samsung.com (u141.gpu120.samsung.co.kr [203.254.230.141]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MI800J4GZZ1VHN0@mailout1.samsung.com>; Fri, 15 Feb 2013 15:14:02 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.123]) by epcpsbgr1.samsung.com (EPCPMTA) with SMTP id 0B.AB.16905.A22DD115; Fri, 15 Feb 2013 15:14:02 +0900 (KST) X-AuditID: cbfee68d-b7f4f6d000004209-17-511dd22ad884 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id EC.8A.03918.A22DD115; Fri, 15 Feb 2013 15:14:02 +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 <0MI8005Z0ZYZ7R20@mmp2.samsung.com>; Fri, 15 Feb 2013 15:14:02 +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 V6 03/10] DWMMC: Initialise dwmci and resolve EMMC read write issues Date: Fri, 15 Feb 2013 01:34:44 -0500 Message-id: <1360910091-6285-4-git-send-email-amarendra.xt@samsung.com> X-Mailer: git-send-email 1.8.0 In-reply-to: <1360910091-6285-1-git-send-email-amarendra.xt@samsung.com> References: <1360910091-6285-1-git-send-email-amarendra.xt@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrJLMWRmVeSWpSXmKPExsWyRsSkWlfrkmygwbJzEhYP199ksZhy+AuL A5PHnWt72AIYo7hsUlJzMstSi/TtErgyXv0JLZguUXHp4lqmBsbTwl2MnBwSAiYSB7+uYYKw xSQu3FvP1sXIxSEksJRR4vXkK0wwRVd7YBLTGSWmfzjJBpIQEuhlkni6RbKLkYODTUBV4tdi e5CwiICExK/+q4wg9cwCHYwSOyZuZgRJCAuESby4eATMZgGqP7r/JZjNK+AucW7zVVaIZXIS H/Y8YgexOQU8JM5Nfs0MsctdYuenDrChEgLX2ST+TlrACjFIQOLb5EMsIEdICMhKbDrADDFH UuLgihssExiFFzAyrGIUTS1ILihOSi8y1CtOzC0uzUvXS87P3cQIDMbT/5717mC8fcD6EGMy 0LiJzFKiyfnAYM4riTc0NjE3NTY1M7K0tDQlTVhJnFfukkygkEB6YklqdmpqQWpRfFFpTmrx IUYmDk6pBkbTJ7cb/65es2mBqo32yUM9i7+c/7yn4Vl6583UTfO/nJ/UycInU/rX7kHp1bmb Ht3VK89PKFuoysQv7aKz9mcbV9i0I5nTJyr4JqzYeubYnWXLtev31BlrVOZKL154oFxRwUGC ZdWy3W9iqz/ft3Jh693N/criio/wj2uW7Rw/z3Cpe67esi5EiaU4I9FQi7moOBEAJkhapFwC AAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGIsWRmVeSWpSXmKPExsVy+t9jQV2tS7KBBs/X8Fg8XH+TxWLK4S8s Dkwed67tYQtgjGpgtMlITUxJLVJIzUvOT8nMS7dV8g6Od443NTMw1DW0tDBXUshLzE21VXLx CdB1y8wBmq2kUJaYUwoUCkgsLlbSt8M0ITTETdcCpjFC1zckCK7HyAANJKxhzHj1J7RgukTF pYtrmRoYTwt3MXJySAiYSFztWc8GYYtJXLgHYnNxCAlMZ5SY/uEkWEJIoJdJ4ukWyS5GDg42 AVWJX4vtQcIiAhISv/qvMoLUMwt0MErsmLiZESQhLBAm8eLiETCbBaj+6P6XYDavgLvEuc1X WSGWyUl82POIHcTmFPCQODf5NTPELneJnZ86GCcw8i5gZFjFKJpakFxQnJSea6hXnJhbXJqX rpecn7uJERzqz6R2MK5ssDjEKMDBqMTDKyAhGyjEmlhWXJl7iFGCg1lJhHdNCFCINyWxsiq1 KD++qDQntfgQYzLQVROZpUST84FxmFcSb2hsYm5qbGppYmFiZkmasJI4L+OpJwFCAumJJanZ qakFqUUwW5g4OKUaGNP3WAoY9tvGSE79v91HqVqwa23inGTrG3vzYpm2qu397dY2t4upvGrp Wee29+m/Kq7p+1QrbdVwm/3S/vPEYv0OQ7bq54vNbrPaBkx7aNhSavVjkp37dnW74uN/16wU Wf99o6VLQ+N/w1MbDH4fm7Z0u8zMRd2Gf7+09D1gXTI78cJ5fc+jYUosxRmJhlrMRcWJABPx yTe5AgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-Gm-Message-State: ALoCoQnpzsjNtiqJgfSrWoGvUjgkSP2J6sWGYvWIsZ0TLxzlT4CMEPBWRZsSHiQU72CMq8F8/8v5 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. 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);