From: Peter Griffin <peter.griffin@linaro.org>
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, devicetree@vger.kernel.org,
linux-mmc@vger.kernel.org, lee.jones@linaro.org,
peppe.cavallaro@st.com
Subject: [PATCH v2 2/8] mmc: sdhci-st: Add support for de-asserting reset signal and top regs resource
Date: Thu, 26 Feb 2015 13:10:21 +0000 [thread overview]
Message-ID: <1424956227-18258-3-git-send-email-peter.griffin@linaro.org> (raw)
In-Reply-To: <1424956227-18258-1-git-send-email-peter.griffin@linaro.org>
STiH407 family SoC's can have a reset signal for the controller which needs to
be managed. Also the eMMC controller has some additional 'top' memory mapped
registers which are used to manage the dynamic and static delay required for
UHS modes. This patch adds support for creating the mapping, which will be used
by subsequent patches.
Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
---
drivers/mmc/host/sdhci-st.c | 52 ++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 49 insertions(+), 3 deletions(-)
diff --git a/drivers/mmc/host/sdhci-st.c b/drivers/mmc/host/sdhci-st.c
index a3bc3c3..0101ae9 100644
--- a/drivers/mmc/host/sdhci-st.c
+++ b/drivers/mmc/host/sdhci-st.c
@@ -23,9 +23,14 @@
#include <linux/module.h>
#include <linux/err.h>
#include <linux/mmc/host.h>
-
+#include <linux/reset.h>
#include "sdhci-pltfm.h"
+struct st_mmc_platform_data {
+ struct reset_control *rstc;
+ void __iomem *top_ioaddr;
+};
+
/* MMCSS glue logic to setup the HC on some ST SoCs (e.g. STiH407 family) */
#define ST_MMC_CCONFIG_REG_1 0x400
@@ -151,10 +156,16 @@ static const struct sdhci_pltfm_data sdhci_st_pdata = {
static int sdhci_st_probe(struct platform_device *pdev)
{
struct sdhci_host *host;
+ struct st_mmc_platform_data *pdata;
struct sdhci_pltfm_host *pltfm_host;
struct clk *clk;
int ret = 0;
u16 host_version;
+ struct resource *res;
+
+ pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
+ if (!pdata)
+ return -ENOMEM;
clk = devm_clk_get(&pdev->dev, "mmc");
if (IS_ERR(clk)) {
@@ -162,10 +173,17 @@ static int sdhci_st_probe(struct platform_device *pdev)
return PTR_ERR(clk);
}
+ pdata->rstc = devm_reset_control_get(&pdev->dev, NULL);
+ if (IS_ERR(pdata->rstc))
+ pdata->rstc = NULL;
+ else
+ reset_control_deassert(pdata->rstc);
+
host = sdhci_pltfm_init(pdev, &sdhci_st_pdata, 0);
if (IS_ERR(host)) {
dev_err(&pdev->dev, "Failed sdhci_pltfm_init\n");
- return PTR_ERR(host);
+ ret = PTR_ERR(host);
+ goto err_pltfm_init;
}
ret = mmc_of_parse(host->mmc);
@@ -176,7 +194,17 @@ static int sdhci_st_probe(struct platform_device *pdev)
clk_prepare_enable(clk);
+ /* Configure the FlashSS Top registers for setting eMMC TX/RX delay */
+ res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+ "top-mmc-delay");
+ pdata->top_ioaddr = devm_ioremap_resource(&pdev->dev, res);
+ if (IS_ERR(pdata->top_ioaddr)) {
+ dev_warn(&pdev->dev, "FlashSS Top Dly registers not available");
+ pdata->top_ioaddr = NULL;
+ }
+
pltfm_host = sdhci_priv(host);
+ pltfm_host->priv = pdata;
pltfm_host->clk = clk;
ret = sdhci_add_host(host);
@@ -200,6 +228,9 @@ err_out:
clk_disable_unprepare(clk);
err_of:
sdhci_pltfm_free(pdev);
+err_pltfm_init:
+ if (pdata->rstc)
+ reset_control_assert(pdata->rstc);
return ret;
}
@@ -208,10 +239,17 @@ static int sdhci_st_remove(struct platform_device *pdev)
{
struct sdhci_host *host = platform_get_drvdata(pdev);
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+ struct st_mmc_platform_data *pdata = pltfm_host->priv;
+ int ret;
clk_disable_unprepare(pltfm_host->clk);
- return sdhci_pltfm_unregister(pdev);
+ ret = sdhci_pltfm_unregister(pdev);
+
+ if (pdata->rstc)
+ reset_control_assert(pdata->rstc);
+
+ return ret;
}
#ifdef CONFIG_PM_SLEEP
@@ -219,11 +257,15 @@ static int sdhci_st_suspend(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;
int ret = sdhci_suspend_host(host);
if (ret)
goto out;
+ if (pdata->rstc)
+ reset_control_assert(pdata->rstc);
+
clk_disable_unprepare(pltfm_host->clk);
out:
return ret;
@@ -233,9 +275,13 @@ 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;
clk_prepare_enable(pltfm_host->clk);
+ if (pdata->rstc)
+ reset_control_deassert(pdata->rstc);
+
return sdhci_resume_host(host);
}
#endif
--
1.9.1
next prev parent reply other threads:[~2015-02-26 13:10 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-26 13:10 [PATCH v2 0/8] Add sd/emmc support for stih407 family silicon Peter Griffin
2015-02-26 13:10 ` [PATCH v2 1/8] mmc: sdhci-st: Add macros for register offsets and bitfields for mmcss glue regs Peter Griffin
2015-03-03 10:24 ` Maxime Coquelin
[not found] ` <54F58BED.4020900-qxv4g6HH51o@public.gmane.org>
2015-03-30 10:29 ` Peter Griffin
2015-02-26 13:10 ` Peter Griffin [this message]
2015-03-03 10:34 ` [PATCH v2 2/8] mmc: sdhci-st: Add support for de-asserting reset signal and top regs resource Maxime Coquelin
2015-02-26 13:10 ` [PATCH v2 3/8] mmc: sdhci-st: Add delay management functions for top registers (eMMC) Peter Griffin
2015-03-03 10:47 ` Maxime Coquelin
2015-03-30 10:33 ` Peter Griffin
2015-02-26 13:10 ` [PATCH v2 4/8] mmc: sdhci-st: Add st_mmcss_cconfig function to configure mmcss glue registers Peter Griffin
2015-03-03 10:53 ` Maxime Coquelin
2015-02-26 13:10 ` [PATCH v2 5/8] mmc: sdhci-st: Add sdhci_st_set_uhs_signaling function Peter Griffin
2015-03-03 10:56 ` Maxime Coquelin
2015-03-30 10:46 ` Peter Griffin
2015-02-26 13:10 ` [PATCH v2 6/8] mmc: sdhci-st: Update the quirks for this controller Peter Griffin
2015-03-03 10:57 ` Maxime Coquelin
2015-02-26 13:10 ` [PATCH v2 7/8] mmc: sdhci-st: Update ST SDHCI binding documentation Peter Griffin
2015-03-03 11:01 ` Maxime Coquelin
2015-02-26 13:10 ` [PATCH v2 8/8] ARM: STi: DT: STiH407: Add dt nodes for sdhci and emmc Peter Griffin
2015-03-03 11:03 ` Maxime Coquelin
2015-03-30 11:23 ` Peter Griffin
2015-03-30 11:37 ` Lee Jones
2015-03-30 11:43 ` Maxime Coquelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1424956227-18258-3-git-send-email-peter.griffin@linaro.org \
--to=peter.griffin@linaro.org \
--cc=chris@printf.net \
--cc=devicetree@vger.kernel.org \
--cc=lee.jones@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=maxime.coquelin@st.com \
--cc=patrice.chotard@st.com \
--cc=peppe.cavallaro@st.com \
--cc=srinivas.kandagatla@gmail.com \
--cc=ulf.hansson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).