From patchwork Thu Aug 29 10:52:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajeshwari Shinde X-Patchwork-Id: 19611 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f69.google.com (mail-yh0-f69.google.com [209.85.213.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 88BB125E4D for ; Thu, 29 Aug 2013 10:50:50 +0000 (UTC) Received: by mail-yh0-f69.google.com with SMTP id f10sf258770yha.0 for ; Thu, 29 Aug 2013 03:50:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:dlp-filter:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=8IP8opfVoQxCyfZPK8hio5ACan2g/M12HwQGP8PRSF8=; b=IbPrjDQhXE0zcMS5BnMzW8YO/Y5LxjFOzR0FrRbL+R2ckih+mXlj54QmSYn0xRlr+Y LTmWyAOPLTFgyGLwHFS1pHjW3ZE37tpbV9aXdIw+qeCQR0tpEdGDgkuWVfiMrrhPcEFE ZDM4B5/NOzSebIu2aEEbrad7B4ToOo281YunX6x24zpr+0wSW66Drm44YucJUSTstVDt Np9HY+yctxiHMCmR6Zr0Fh7tF+q8amUw2Fsv1uqJ/Le5NBPV2jCBJkjdHyCXV4mHPpmn FpdWPr5aGFq9Pn+5JU/fO4LsYagatR+kUbTQZ31EaLnrUrc5TDtd/d+zX1dfuGEuNZQ2 fIbA== X-Received: by 10.236.172.34 with SMTP id s22mr946500yhl.25.1377773449870; Thu, 29 Aug 2013 03:50:49 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.99.106 with SMTP id ep10ls755061qeb.59.gmail; Thu, 29 Aug 2013 03:50:49 -0700 (PDT) X-Received: by 10.52.36.204 with SMTP id s12mr170431vdj.36.1377773449754; Thu, 29 Aug 2013 03:50:49 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id b6si7932488veo.98.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 29 Aug 2013 03:50:49 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id hf12so176203vcb.13 for ; Thu, 29 Aug 2013 03:50:49 -0700 (PDT) X-Gm-Message-State: ALoCoQmMy9NYkva8OyrT2ALuyN49EwrvcL5wPrUC/uCrkxu3GY4b4kEqbSFJ7AdX0o+bWorPMFws X-Received: by 10.52.92.73 with SMTP id ck9mr1462756vdb.2.1377773449662; Thu, 29 Aug 2013 03:50:49 -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.220.174.196 with SMTP id u4csp14512vcz; Thu, 29 Aug 2013 03:50:49 -0700 (PDT) X-Received: by 10.68.254.138 with SMTP id ai10mr2854066pbd.151.1377773448586; Thu, 29 Aug 2013 03:50:48 -0700 (PDT) Received: from mailout3.samsung.com (mailout3.samsung.com. [203.254.224.33]) by mx.google.com with ESMTP id j3si19064773pbw.69.1969.12.31.16.00.00; Thu, 29 Aug 2013 03:50:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of rajeshwari.s@samsung.com designates 203.254.224.33 as permitted sender) client-ip=203.254.224.33; Received: from epcpsbgr1.samsung.com (u141.gpu120.samsung.co.kr [203.254.230.141]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MSA007MMGSLO5R0@mailout3.samsung.com>; Thu, 29 Aug 2013 19:50:47 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.125]) by epcpsbgr1.samsung.com (EPCPMTA) with SMTP id CB.CB.30629.6872F125; Thu, 29 Aug 2013 19:50:46 +0900 (KST) X-AuditID: cbfee68d-b7fe86d0000077a5-bd-521f278675c8 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id A2.6F.09055.6872F125; Thu, 29 Aug 2013 19:50:46 +0900 (KST) Received: from localhost.localdomain.com ([107.108.73.95]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MSA0009BGSF2R30@mmp2.samsung.com>; Thu, 29 Aug 2013 19:50:46 +0900 (KST) From: Rajeshwari S Shinde 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] MMC: DWMMC: Correct the CLKDIV register value Date: Thu, 29 Aug 2013 16:22:24 +0530 Message-id: <1377773544-306-1-git-send-email-rajeshwari.s@samsung.com> X-Mailer: git-send-email 1.7.11.7 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrPLMWRmVeSWpSXmKPExsWyRsSkVrdNXT7IoOGJjcWN6z/ZLB6uv8li ceNXG6tFx5EWRosph7+wWHzbso3R4u3eTnYHdo/ZDRdZPHbOusvucefaHjaPs3d2MHr0bVnF GMAaxWWTkpqTWZZapG+XwJXR8m8dc8EaiYrVF5wbGJ8KdzFyckgImEj8uHKIEcIWk7hwbz1b FyMXh5DAUkaJdb0XmGGKFm7oZ4JITGeUeLytgx3C6WKSePL/OWsXIwcHG1DVxhMJIA0iAhIS v/qvMoLUMAt0MErsmLgZbIWwgJ3Exh3nWEFsFgFViWv7H4Bt4BVwk1h85Ss7xDZFiRlLnoE1 Swi0s0scPLGbEaJBQOLb5EM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astb+PrD5ksW76+2FDkoo725Pi10mxHVMvFj80PU+1SeaMR 2Xtr8t/i24sTZHm33Envzm6bslflmWVx/JrCW/LMO3YGLnxr+HPJt9rJT6sz/j09+q+/59RM 4Vsn7eIN1/9Ke35go2BCfdiisrnrlFiKMxINtZiLihMBygZfXc8CAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: rajeshwari.s@samsung.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.182 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 corrects the divider value written to CLKDIV register. Since SDCLKIN is divided inside controller by the DIVRATIO value set in the CLKSEL register, we need to use the same output clock value to calculate the CLKDIV value. as per user manual: cclk_in = SDCLKIN / (DIVRATIO + 1) Input parameter to mmc_clk is changed to dwmci_host, since we need the same to read DWMCI_CLKSEL register. This improves the read timing values for channel 0 on SMDK5250 from 0.288sec to 0.144sec Signed-off-by: Rajeshwari S Shinde --- arch/arm/include/asm/arch-exynos/dwmmc.h | 4 ++++ drivers/mmc/dw_mmc.c | 2 +- drivers/mmc/exynos_dw_mmc.c | 17 +++++++++++++++-- include/dwmmc.h | 2 +- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/arch/arm/include/asm/arch-exynos/dwmmc.h b/arch/arm/include/asm/arch-exynos/dwmmc.h index b9eca76..f1c8d8a 100644 --- a/arch/arm/include/asm/arch-exynos/dwmmc.h +++ b/arch/arm/include/asm/arch-exynos/dwmmc.h @@ -14,6 +14,10 @@ #define DWMCI_SET_DRV_CLK(x) ((x) << 16) #define DWMCI_SET_DIV_RATIO(x) ((x) << 24) +/* CLKSEL Register */ +#define DWMCI_DIVRATIO_BIT 24 +#define DWMCI_DIVRATIO_MASK 0x7 + #ifdef CONFIG_OF_CONTROL int exynos_dwmmc_init(const void *blob); #endif diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c index a82ee17..3406bdd 100644 --- a/drivers/mmc/dw_mmc.c +++ b/drivers/mmc/dw_mmc.c @@ -224,7 +224,7 @@ static int dwmci_setup_bus(struct dwmci_host *host, u32 freq) * host->bus_hz should be set from user. */ if (host->mmc_clk) - sclk = host->mmc_clk(host->dev_index); + sclk = host->mmc_clk(host); else if (host->bus_hz) sclk = host->bus_hz; else { diff --git a/drivers/mmc/exynos_dw_mmc.c b/drivers/mmc/exynos_dw_mmc.c index 4ef9fec..1ed4afe 100644 --- a/drivers/mmc/exynos_dw_mmc.c +++ b/drivers/mmc/exynos_dw_mmc.c @@ -29,9 +29,22 @@ static void exynos_dwmci_clksel(struct dwmci_host *host) dwmci_writel(host, DWMCI_CLKSEL, host->clksel_val); } -unsigned int exynos_dwmci_get_clk(int dev_index) +unsigned int exynos_dwmci_get_clk(struct dwmci_host *host) { - return get_mmc_clk(dev_index); + unsigned long sclk; + int8_t clk_div; + + /* + * Since SDCLKIN is divided inside controller by the DIVRATIO + * value set in the CLKSEL register, we need to use the same output + * clock value to calculate the CLKDIV value. + * as per user manual:cclk_in = SDCLKIN / (DIVRATIO + 1) + */ + clk_div = ((dwmci_readl(host, DWMCI_CLKSEL) >> DWMCI_DIVRATIO_BIT) + & DWMCI_DIVRATIO_MASK) + 1; + sclk = get_mmc_clk(host->dev_index); + + return sclk / clk_div; } /* diff --git a/include/dwmmc.h b/include/dwmmc.h index 08ced0b..26b53af 100644 --- a/include/dwmmc.h +++ b/include/dwmmc.h @@ -138,7 +138,7 @@ struct dwmci_host { struct mmc *mmc; void (*clksel)(struct dwmci_host *host); - unsigned int (*mmc_clk)(int dev_index); + unsigned int (*mmc_clk)(struct dwmci_host *host); }; struct dwmci_idmac {