From patchwork Thu Feb 26 13:10:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Griffin X-Patchwork-Id: 45166 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C833B2043C for ; Thu, 26 Feb 2015 13:11:14 +0000 (UTC) Received: by lbdu10 with SMTP id u10sf8129056lbd.3 for ; Thu, 26 Feb 2015 05:11:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=i0qwrOC3tUiCAy6Bdgtl46zucevErRSJP6hFibg8sJQ=; b=JjqRMdRH+8SFU0D8/P+8Yfh6fBEsQOJc7IHhvEmmmduXFL38Of20e2VL3XgyymaBUT 5cAHnjKwMtKBA4ByDNwYonrnFLJI9HPmvwZtN90Wmi+ZRmS5wx6gMELckO+0Mk1lIsLh jo+SXD79SuEFw8sJ/NHj6UpVxogegkWYHJx43IEfZ+7lE9FhILvw4R8xWz10925mn2Hh fzEwued/Na4XdE5fTeFi05Pez0Zfx+nfmK2wWjm/v9KrOm4YBptk2FlmOIPgO/tRm34A MjLikrRLZOHEDHPR4nHR8EJnSX0S992BragHPnVtjOWKOjWTIymzGSbcpQLybNiZwlNW 4wzw== X-Gm-Message-State: ALoCoQmkSDgcqiO47lAs4dS//xRr5U11WvNIH1jlSXESJWgzs2M0Gvgs7ok3ZlYS1I7wqSrs8LJb X-Received: by 10.112.219.102 with SMTP id pn6mr1265394lbc.12.1424956273663; Thu, 26 Feb 2015 05:11:13 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.7.72 with SMTP id h8ls30658laa.46.gmail; Thu, 26 Feb 2015 05:11:13 -0800 (PST) X-Received: by 10.152.179.172 with SMTP id dh12mr7260274lac.76.1424956273298; Thu, 26 Feb 2015 05:11:13 -0800 (PST) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id z15si548097lbg.107.2015.02.26.05.11.13 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Feb 2015 05:11:13 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by lams18 with SMTP id s18so10780842lam.13 for ; Thu, 26 Feb 2015 05:11:13 -0800 (PST) X-Received: by 10.112.162.232 with SMTP id yd8mr2344551lbb.41.1424956273220; Thu, 26 Feb 2015 05:11:13 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp3289085lbj; Thu, 26 Feb 2015 05:11:12 -0800 (PST) X-Received: by 10.69.2.36 with SMTP id bl4mr14865725pbd.32.1424956271359; Thu, 26 Feb 2015 05:11:11 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n3si1070240pap.109.2015.02.26.05.11.09; Thu, 26 Feb 2015 05:11:11 -0800 (PST) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932270AbbBZNKo (ORCPT + 28 others); Thu, 26 Feb 2015 08:10:44 -0500 Received: from mail-we0-f182.google.com ([74.125.82.182]:38900 "EHLO mail-we0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753821AbbBZNKk (ORCPT ); Thu, 26 Feb 2015 08:10:40 -0500 Received: by wesw55 with SMTP id w55so10529381wes.5 for ; Thu, 26 Feb 2015 05:10:39 -0800 (PST) X-Received: by 10.194.201.164 with SMTP id kb4mr5449068wjc.32.1424956239308; Thu, 26 Feb 2015 05:10:39 -0800 (PST) Received: from localhost.localdomain (cpc14-aztw22-2-0-cust189.18-1.cable.virginm.net. [82.45.1.190]) by mx.google.com with ESMTPSA id dz6sm23075747wib.0.2015.02.26.05.10.37 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 Feb 2015 05:10:38 -0800 (PST) From: Peter Griffin To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, maxime.coquelin@st.com, patrice.chotard@st.com, srinivas.kandagatla@gmail.com, chris@printf.net, ulf.hansson@linaro.org Cc: peter.griffin@linaro.org, lee.jones@linaro.org, devicetree@vger.kernel.org, linux-mmc@vger.kernel.org, peppe.cavallaro@st.com Subject: [PATCH v2 3/8] mmc: sdhci-st: Add delay management functions for top registers (eMMC). Date: Thu, 26 Feb 2015 13:10:22 +0000 Message-Id: <1424956227-18258-4-git-send-email-peter.griffin@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1424956227-18258-1-git-send-email-peter.griffin@linaro.org> References: <1424956227-18258-1-git-send-email-peter.griffin@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.griffin@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Due to the tight timing constriants in some UHS modes, it is required to have some delay management in the design. Two types of delay management are supported in the HW: - 1) Static delay management 2) Dynamic delay management NB: The delay management is only there when eMMC interface is selected. 1: Static delay management: is used to provide PVT dependent static delay on the clock/data lines to manage setup/hold requirements of the interface. The maximum delay possible is 3.25ns. These delays are PVT dependent, and thus delay values applied are not accurate and vary across provcess voltage and temperature range. Due to this these delays must not be used on the very time critical paths. 2. Dynamic delay locked loop (DLL): is used to provide dynamic delay management. The advantage of DLL is that it provides accurate & PVT indepedent delay. The DLL is used to provide delay on the loopback clock on "Read Path" to capture read data reliably. On TX path the clock on which output data is transmitted is delayed, resulting in delay of TX data. Signed-off-by: Peter Griffin Signed-off-by: Giuseppe Cavallaro --- drivers/mmc/host/sdhci-st.c | 58 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/drivers/mmc/host/sdhci-st.c b/drivers/mmc/host/sdhci-st.c index 0101ae9..3443cc0 100644 --- a/drivers/mmc/host/sdhci-st.c +++ b/drivers/mmc/host/sdhci-st.c @@ -122,6 +122,64 @@ struct st_mmc_platform_data { ST_TOP_MMC_DLY_CTRL_ATUNE_NOT_CFG_DLY | \ ST_TOP_MMC_START_DLL_LOCK) +/* + * For clock speeds greater than 90MHz, we need to check that the + * DLL procedure has finished before switching to ultra-speed modes. + */ +#define CLK_TO_CHECK_DLL_LOCK 90000000 + +static inline void st_mmcss_set_static_delay(void __iomem *ioaddr) +{ + if (ioaddr) { + writel_relaxed(0x0, ioaddr + ST_TOP_MMC_DLY_CTRL); + writel_relaxed(ST_TOP_MMC_DLY_MAX, + ioaddr + ST_TOP_MMC_TX_CLK_DLY); + } +} + +static inline void st_mmcss_set_dll(void __iomem *ioaddr) +{ + if (ioaddr) { + writel_relaxed(ST_TOP_MMC_DYN_DLY_CONF, + ioaddr + ST_TOP_MMC_DLY_CTRL); + writel_relaxed(ST_TOP_MMC_TX_DLL_STEP_DLY_VALID, + ioaddr + ST_TOP_MMC_TX_DLL_STEP_DLY); + } +} + +static int st_mmcss_lock_dll(void __iomem *ioaddr) +{ + unsigned long curr, value; + unsigned long finish = jiffies + HZ; + + /* Checks if the DLL procedure is finished */ + do { + curr = jiffies; + value = readl(ioaddr + ST_MMC_STATUS_R); + if (value & 0x1) + return 0; + + cpu_relax(); + } while (!time_after_eq(curr, finish)); + + return -EBUSY; +} + +static int sdhci_st_set_dll_for_clock(struct sdhci_host *host) +{ + int ret = 0; + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + struct st_mmc_platform_data *pdata = pltfm_host->priv; + + if (host->clock > CLK_TO_CHECK_DLL_LOCK) { + st_mmcss_set_dll(pdata->top_ioaddr); + ret = st_mmcss_lock_dll(host->ioaddr); + } + + return ret; +} + + static u32 sdhci_st_readl(struct sdhci_host *host, int reg) { u32 ret;