From patchwork Mon Mar 30 14:39:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Griffin X-Patchwork-Id: 46515 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f71.google.com (mail-yh0-f71.google.com [209.85.213.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 178292159A for ; Mon, 30 Mar 2015 14:40:35 +0000 (UTC) Received: by yhdx24 with SMTP id x24sf150368504yhd.1 for ; Mon, 30 Mar 2015 07:40:34 -0700 (PDT) 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=VzgKHQXL2q1OX1nr/dxuRHEGss01Nqlrc99R/+tNyBo=; b=YQJjb6GbuF4WRBmn9auo8eFlTg5duQYuP3kadXRHgzl18DRihpy4qG2H1+A7CUYc+z tycG/xg+TRsf0OPwKY+Q8Yg40I1L0fazwiM/r3ii11gcm5p6cAuP9bV5Y6Gx2Z/fZpgt /isP0nCzBFh2A9AJcCg4H2XIIf/Tsq5DoCln5Vim78PYa4HGcuJ9zYjtiVBBTaR5yQhS yMMlfIiKebdonJ0QVcl55BN4iWZFHxfaqSdhNTslhXA6emiLL33PNE37ClkVPt0B/J4B JH9NG1dsCkBGzQMGrDAuwOUsJLifdyyvNnBoAm9JWdB5+DvsCCZqfreD2zAv0ZOZvPpW Axpg== X-Gm-Message-State: ALoCoQne6E2wGwVKc/rAKud9Ebcj5I2hT+BQxyWhLO/mIdbwXgU/8mlzb9/YcM8u9oDJGnFTx82x X-Received: by 10.236.46.20 with SMTP id q20mr38890242yhb.13.1427726434938; Mon, 30 Mar 2015 07:40:34 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.18.102 with SMTP id 93ls2452713qge.54.gmail; Mon, 30 Mar 2015 07:40:34 -0700 (PDT) X-Received: by 10.141.28.78 with SMTP id f75mr43817901qhe.18.1427726434809; Mon, 30 Mar 2015 07:40:34 -0700 (PDT) Received: from mail-qc0-f177.google.com (mail-qc0-f177.google.com. [209.85.216.177]) by mx.google.com with ESMTPS id 185si10527078qhs.70.2015.03.30.07.40.34 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Mar 2015 07:40:34 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.216.177 as permitted sender) client-ip=209.85.216.177; Received: by qcbjx9 with SMTP id jx9so72807330qcb.0 for ; Mon, 30 Mar 2015 07:40:34 -0700 (PDT) X-Received: by 10.55.55.85 with SMTP id e82mr68644605qka.2.1427726434652; Mon, 30 Mar 2015 07:40:34 -0700 (PDT) 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.96.155.231 with SMTP id vz7csp1519624qdb; Mon, 30 Mar 2015 07:40:34 -0700 (PDT) X-Received: by 10.66.218.129 with SMTP id pg1mr59242696pac.65.1427726429731; Mon, 30 Mar 2015 07:40:29 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c6si9499835pas.236.2015.03.30.07.40.29; Mon, 30 Mar 2015 07:40:29 -0700 (PDT) Received-SPF: none (google.com: linux-mmc-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 S1753200AbbC3OkU (ORCPT + 3 others); Mon, 30 Mar 2015 10:40:20 -0400 Received: from mail-wi0-f176.google.com ([209.85.212.176]:35251 "EHLO mail-wi0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753149AbbC3OkP (ORCPT ); Mon, 30 Mar 2015 10:40:15 -0400 Received: by wicne17 with SMTP id ne17so34222768wic.0 for ; Mon, 30 Mar 2015 07:40:14 -0700 (PDT) X-Received: by 10.180.101.225 with SMTP id fj1mr23351119wib.56.1427726414528; Mon, 30 Mar 2015 07:40:14 -0700 (PDT) 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 cf12sm16037489wjb.10.2015.03.30.07.40.12 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 30 Mar 2015 07:40:13 -0700 (PDT) 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 v3 3/9] mmc: sdhci-st: Add delay management functions for top registers (eMMC). Date: Mon, 30 Mar 2015 15:39:56 +0100 Message-Id: <1427726402-7513-4-git-send-email-peter.griffin@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1427726402-7513-1-git-send-email-peter.griffin@linaro.org> References: <1427726402-7513-1-git-send-email-peter.griffin@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-mmc@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.216.177 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 constraints 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 | 59 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/drivers/mmc/host/sdhci-st.c b/drivers/mmc/host/sdhci-st.c index 697c609..6c4c551 100644 --- a/drivers/mmc/host/sdhci-st.c +++ b/drivers/mmc/host/sdhci-st.c @@ -122,6 +122,65 @@ 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) + return; + + 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) + return; + + 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;