From patchwork Mon Jan 21 11:43:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amar X-Patchwork-Id: 14136 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 336CD23E02 for ; Mon, 21 Jan 2013 11:25:55 +0000 (UTC) Received: from mail-vb0-f47.google.com (mail-vb0-f47.google.com [209.85.212.47]) by fiordland.canonical.com (Postfix) with ESMTP id BD75DA189F6 for ; Mon, 21 Jan 2013 11:25:54 +0000 (UTC) Received: by mail-vb0-f47.google.com with SMTP id e21so5561526vbm.20 for ; Mon, 21 Jan 2013 03:25:54 -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=kIs8kT7a2xGJ1mePKp7daQh7uCaJlxpiKC9fptlixIM=; b=OaTF1e8Fk0Nv8PJpfbBbm9EFNdZRNQ3hsC7YVn+aqA1tfx3YdOzSmz3fJOmKoQL73Q OtYpXsmXEfA0BTX33uJNVQeu81C3xWzcTwLJUVRF+RC719Oa9UKJ7/j6av4d5aQC/xnY YfVqZWE3Y3mXIHtKOIwVrJury03XLSoA7FzTHR8rNFLhsYEiGsf54cPjK0KO7517UsXE yGL7AYOvRHnk2M4v8zj95ummCysIadrU3B6G7J83P3aESyRsTSDJzfi7WusMtvAX/uW0 oMEmkAqUDBpNXx3KYQ0PIs02ZOEU3yg+cAJWgWcEKjFvCWt4mjRXSbwWJBpcdnIeejKz dtzg== X-Received: by 10.52.176.6 with SMTP id ce6mr16640549vdc.57.1358767554297; Mon, 21 Jan 2013 03:25:54 -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.145.101 with SMTP id st5csp196376veb; Mon, 21 Jan 2013 03:25:53 -0800 (PST) X-Received: by 10.66.84.10 with SMTP id u10mr46677040pay.24.1358767552800; Mon, 21 Jan 2013 03:25:52 -0800 (PST) Received: from mailout1.samsung.com (mailout1.samsung.com. [203.254.224.24]) by mx.google.com with ESMTP id n8si13798098paw.59.2013.01.21.03.25.52; Mon, 21 Jan 2013 03:25:52 -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 epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MGZ00BQT3R3ZTO0@mailout1.samsung.com>; Mon, 21 Jan 2013 20:25:51 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.123]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id DF.E2.03918.FB52DF05; Mon, 21 Jan 2013 20:25:51 +0900 (KST) X-AuditID: cbfee61a-b7f7d6d000000f4e-18-50fd25bf8894 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id AE.E2.03918.FB52DF05; Mon, 21 Jan 2013 20:25:51 +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 <0MGZ0092C3L1A540@mmp2.samsung.com>; Mon, 21 Jan 2013 20:25:51 +0900 (KST) From: Amar To: u-boot@lists.denx.de, jh80.chung@samsung.com Cc: patches@linaro.org, sjg@chromium.org, mk7.kang@samsung.com, chander.kashyap@linaro.org, afleming@gmail.com, hs@denx.de Subject: [PATCH V5 03/10] DWMMC: Initialise dwmci and resolve EMMC read write issues Date: Mon, 21 Jan 2013 06:43:51 -0500 Message-id: <1358768638-14187-4-git-send-email-amarendra.xt@samsung.com> X-Mailer: git-send-email 1.8.0 In-reply-to: <1358768638-14187-1-git-send-email-amarendra.xt@samsung.com> References: <1358768638-14187-1-git-send-email-amarendra.xt@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrOLMWRmVeSWpSXmKPExsWyRsSkWne/6t8Ag+0bVC0err/JYjHl8BcW ByaPO9f2sAUwRnHZpKTmZJalFunbJXBlfNy7kLGgVbxiy/UPrA2Ma4S6GDk5JARMJA7N28AK YYtJXLi3nq2LkYtDSGApo8T1iz8YYYoO7HzECpGYzijRsHIxE4TTyyTxquU+UBUHB5uAqsSv xfYgDSICBhLTn2wHm8osUCMxef4tJhBbWCBMYsnFJ+wgNgtQ+Z0rJ9lAbF4BD4kX/YdZIJbJ SXzY8wishlPAU2L/3z1gc4SAanYt+A916W02ib2XYyDmCEh8m3yIBeQECQFZiU0HmCFKJCUO rrjBMoFReAEjwypG0dSC5ILipPRcQ73ixNzi0rx0veT83E2MwGA8/e+Z1A7GlQ0WhxgFOBiV eHgzpv4JEGJNLCuuzD3EKMHBrCTC+3MGUIg3JbGyKrUoP76oNCe1+BBjMtDyicxSosn5wEjJ K4k3NDYxNzU2tTQyMjM1JU1YSZyX8dSTACGB9MSS1OzU1ILUIpgtTBycUg2MqvecZCcsD/5o 8aA/W/3YYobU7ieWnVGXnrl9l0tyt1638c7Kxd/fbuG+ymoq+3zOwvOXQl7bnmlxj3pv/8v0 yunbyqIFTzS3PH9Wcknj62yeVMa+n7t6ZT/3TLK4f2iCv+wmnr5SF/2mV/MF1tx/65qlo7JH 5CTX9XLPlH5bnRXKUccdzJqjlViKMxINtZiLihMBH/z5qIoCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOIsWRmVeSWpSXmKPExsVy+t9jQd39qn8DDK5ckLN4uP4mi8WUw19Y HJg87lzbwxbAGNXAaJORmpiSWqSQmpecn5KZl26r5B0c7xxvamZgqGtoaWGupJCXmJtqq+Ti E6DrlpkDNFtJoSwxpxQoFJBYXKykb4dpQmiIm64FTGOErm9IEFyPkQEaSFjDmPFx70LGglbx ii3XP7A2MK4R6mLk5JAQMJE4sPMRK4QtJnHh3nq2LkYuDiGB6YwSDSsXM0E4vUwSr1ruM3Yx cnCwCahK/FpsD9IgImAgMf3JdrBmZoEaicnzbzGB2MICYRJLLj5hB7FZgMrvXDnJBmLzCnhI vOg/zAKxTE7iw55HYDWcAp4S+//uAZsjBFSza8F/1gmMvAsYGVYxiqYWJBcUJ6XnGuoVJ+YW l+al6yXn525iBAf7M6kdjCsbLA4xCnAwKvHwZkz9EyDEmlhWXJl7iFGCg1lJhPfnDKAQb0pi ZVVqUX58UWlOavEhxmSgqyYyS4km5wMjMa8k3tDYxNzU2NTSxMLEzJI0YSVxXsZTTwKEBNIT S1KzU1MLUotgtjBxcEo1MPowhuVOuVryyPTXr2RFSe3DXtwSjkdlzWTcP/TV7OR9ZHV/gXGh 4nuFeztLL3AUTX//8vI2ScGD73ZJno9kr2s5dGHBvNeHb7pa6mRPNbkhMcnAd6OP6+7GTWXL vbawzGSr4WRczD7HTYa10PGDjHt3awWb9qp5Hkv77AMNMy3zFhbwNWs4K7EUZyQaajEXFScC ANR8o/G6AgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-Gm-Message-State: ALoCoQlxmThnHiuAYr2Tk7/VBdmg6yAUBGEG6SgjdHrTDU01MgAQxxPSWYIax//Kj2kMVFmAGl33 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). drivers/mmc/dw_mmc.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c index 4070d4e..391ed93 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); + 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);