From patchwork Mon Mar 30 14:39:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Griffin X-Patchwork-Id: 46516 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f197.google.com (mail-ob0-f197.google.com [209.85.214.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3C56B2159A for ; Mon, 30 Mar 2015 14:40:48 +0000 (UTC) Received: by obvd1 with SMTP id d1sf179384271obv.2 for ; Mon, 30 Mar 2015 07:40:47 -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=mfo7kqu+z5Xz4MKIeYr6W2xTzKQo65WII8wBNWOHaCY=; b=e7iMIg08pUw3PJxPCSzKaHmbZ/B+HFl5bPqULH/3x7tcAbp5EhH/4B1ayXwE/TvM78 VzdXpzkgT1KNM8tHmiKcx/+KuTZoHbve11dNin2O6t7NdGfYc01iEcLOkrXmWaTWXYzu LwJQrwSIi1s+52oO4qYHkfd4HXjNKHXHeM8wJRmsqmk7HXlll2EbBCOk9xaU1NRXoyGC 8u2ZY5zU+vrHfSFGVzrqXO21QwbevMmdumeUDHMeYtQbQ0ta/28ixm/qicAuXI7QMT/R /CJR7i2vC9uPTNI4oSJ6IqyvOr4ZKcnBcZ7x4QDnB8qlc5S0BFWdX2FmQpyg119IgH1L NKlQ== X-Gm-Message-State: ALoCoQk7VUijvnQGz3ewAvxZvLsyCLLNs6rid8oJT+zHFMXJKmJCq5dFiUM6OFUNEAkeLEbWQ3KZ X-Received: by 10.182.199.66 with SMTP id ji2mr39571450obc.14.1427726447892; Mon, 30 Mar 2015 07:40:47 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.90.72 with SMTP id w66ls2371489qgd.0.gmail; Mon, 30 Mar 2015 07:40:47 -0700 (PDT) X-Received: by 10.140.89.42 with SMTP id u39mr40547903qgd.20.1427726447791; Mon, 30 Mar 2015 07:40:47 -0700 (PDT) Received: from mail-qc0-f172.google.com (mail-qc0-f172.google.com. [209.85.216.172]) by mx.google.com with ESMTPS id f11si3495364qka.118.2015.03.30.07.40.47 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Mar 2015 07:40:47 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.216.172 as permitted sender) client-ip=209.85.216.172; Received: by qcay5 with SMTP id y5so72566483qca.1 for ; Mon, 30 Mar 2015 07:40:47 -0700 (PDT) X-Received: by 10.140.131.79 with SMTP id 76mr5034707qhd.57.1427726447671; Mon, 30 Mar 2015 07:40:47 -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 vz7csp1519762qdb; Mon, 30 Mar 2015 07:40:46 -0700 (PDT) X-Received: by 10.70.131.107 with SMTP id ol11mr59748421pdb.63.1427726446365; Mon, 30 Mar 2015 07:40:46 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cz8si15078826pdb.85.2015.03.30.07.40.44; Mon, 30 Mar 2015 07:40:46 -0700 (PDT) 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 S1753320AbbC3Ok3 (ORCPT + 27 others); Mon, 30 Mar 2015 10:40:29 -0400 Received: from mail-wi0-f176.google.com ([209.85.212.176]:36522 "EHLO mail-wi0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753182AbbC3OkS (ORCPT ); Mon, 30 Mar 2015 10:40:18 -0400 Received: by wibg7 with SMTP id g7so105741065wib.1 for ; Mon, 30 Mar 2015 07:40:17 -0700 (PDT) X-Received: by 10.180.126.37 with SMTP id mv5mr23229634wib.16.1427726416612; Mon, 30 Mar 2015 07:40:16 -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.15 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 30 Mar 2015 07:40:15 -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 4/9] mmc: sdhci-st: Add st_mmcss_cconfig function to configure mmcss glue registers. Date: Mon, 30 Mar 2015 15:39:57 +0100 Message-Id: <1427726402-7513-5-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-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.216.172 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: , STiH407 family SoC's have glue registers in the flashSS subsystem which are used to configure the Arasan HC. This patch configures these glue registers according to what has been specified in the DT. Signed-off-by: Peter Griffin Signed-off-by: Giuseppe Cavallaro Acked-by: Maxime Coquelin --- drivers/mmc/host/sdhci-st.c | 88 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/drivers/mmc/host/sdhci-st.c b/drivers/mmc/host/sdhci-st.c index 6c4c551..1ce5a01 100644 --- a/drivers/mmc/host/sdhci-st.c +++ b/drivers/mmc/host/sdhci-st.c @@ -138,6 +138,87 @@ static inline void st_mmcss_set_static_delay(void __iomem *ioaddr) ioaddr + ST_TOP_MMC_TX_CLK_DLY); } +/** + * st_mmcss_cconfig: configure the Arasan HC inside the flashSS. + * @np: dt device node. + * @host: sdhci host + * Description: this function is to configure the Arasan host controller. + * On some ST SoCs, i.e. STiH407 family, the MMC devices inside a dedicated + * flashSS sub-system which needs to be configured to be compliant to eMMC 4.5 + * or eMMC4.3. This has to be done before registering the sdhci host. + */ +static void st_mmcss_cconfig(struct device_node *np, struct sdhci_host *host) +{ + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + struct mmc_host *mhost = host->mmc; + u32 cconf2, cconf3, cconf4, cconf5; + + if (!of_device_is_compatible(np, "st,sdhci-stih407")) + return; + + cconf2 = ST_MMC_CCONFIG_2_DEFAULT; + cconf3 = ST_MMC_CCONFIG_3_DEFAULT; + cconf4 = ST_MMC_CCONFIG_4_DEFAULT; + cconf5 = ST_MMC_CCONFIG_5_DEFAULT; + + writel_relaxed(ST_MMC_CCONFIG_1_DEFAULT, + host->ioaddr + ST_MMC_CCONFIG_REG_1); + + /* Set clock frequency, default to 50MHz if max-frequency is not + * provided */ + + switch (mhost->f_max) { + case 200000000: + clk_set_rate(pltfm_host->clk, mhost->f_max); + cconf2 |= BASE_CLK_FREQ_200; + break; + case 100000000: + clk_set_rate(pltfm_host->clk, mhost->f_max); + cconf2 |= BASE_CLK_FREQ_100; + break; + default: + clk_set_rate(pltfm_host->clk, 50000000); + cconf2 |= BASE_CLK_FREQ_50; + } + + writel_relaxed(cconf2, host->ioaddr + ST_MMC_CCONFIG_REG_2); + + if (mhost->caps & MMC_CAP_NONREMOVABLE) + cconf3 |= ST_MMC_CCONFIG_EMMC_SLOT_TYPE; + else + /* CARD _D ET_CTRL */ + writel_relaxed(ST_MMC_GP_OUTPUT_CD, + host->ioaddr + ST_MMC_GP_OUTPUT); + + if (mhost->caps & MMC_CAP_UHS_SDR50) { + /* use 1.8V */ + cconf3 |= ST_MMC_CCONFIG_1P8_VOLT; + cconf4 |= ST_MMC_CCONFIG_SDR50; + /* Use tuning */ + cconf5 |= ST_MMC_CCONFIG_TUNING_FOR_SDR50; + /* Max timeout for retuning */ + cconf5 |= RETUNING_TIMER_CNT_MAX; + } + + if (mhost->caps & MMC_CAP_UHS_SDR104) { + /* + * SDR104 implies the HC can support HS200 mode, so + * it's mandatory to use 1.8V + */ + cconf3 |= ST_MMC_CCONFIG_1P8_VOLT; + cconf4 |= ST_MMC_CCONFIG_SDR104; + /* Max timeout for retuning */ + cconf5 |= RETUNING_TIMER_CNT_MAX; + } + + if (mhost->caps & MMC_CAP_UHS_DDR50) + cconf4 |= ST_MMC_CCONFIG_DDR50; + + writel_relaxed(cconf3, host->ioaddr + ST_MMC_CCONFIG_REG_3); + writel_relaxed(cconf4, host->ioaddr + ST_MMC_CCONFIG_REG_4); + writel_relaxed(cconf5, host->ioaddr + ST_MMC_CCONFIG_REG_5); +} + static inline void st_mmcss_set_dll(void __iomem *ioaddr) { if (!ioaddr) @@ -214,6 +295,7 @@ static const struct sdhci_pltfm_data sdhci_st_pdata = { static int sdhci_st_probe(struct platform_device *pdev) { + struct device_node *np = pdev->dev.of_node; struct sdhci_host *host; struct st_mmc_platform_data *pdata; struct sdhci_pltfm_host *pltfm_host; @@ -266,6 +348,9 @@ static int sdhci_st_probe(struct platform_device *pdev) pltfm_host->priv = pdata; pltfm_host->clk = clk; + /* Configure the Arasan HC inside the flashSS */ + st_mmcss_cconfig(np, host); + ret = sdhci_add_host(host); if (ret) { dev_err(&pdev->dev, "Failed sdhci_add_host\n"); @@ -335,12 +420,15 @@ static int sdhci_st_resume(struct device *dev) struct sdhci_host *host = dev_get_drvdata(dev); struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); struct st_mmc_platform_data *pdata = pltfm_host->priv; + struct device_node *np = dev->of_node; clk_prepare_enable(pltfm_host->clk); if (pdata->rstc) reset_control_deassert(pdata->rstc); + st_mmcss_cconfig(np, host); + return sdhci_resume_host(host); } #endif