mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Shawn Lin <shawn.lin@rock-chips.com>
To: Jaehoon Chung <jh80.chung@samsung.com>,
	Ulf Hansson <ulf.hansson@linaro.org>
Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org,
	Shawn Lin <shawn.lin@rock-chips.com>,
	Heiko Stuebner <heiko@sntech.de>
Subject: [PATCH] mmc: dw_mmc-rockchip: add pinctrl support
Date: Tue, 19 Jan 2016 17:52:45 +0800	[thread overview]
Message-ID: <1453197165-20194-1-git-send-email-shawn.lin@rock-chips.com> (raw)

We find rk3368 fail to enumerate sd card since
the default state is gpio function. Meahwhile, lots of
rockchip platform dts file assign pinctrl to dw_mmc but actually
dw_mmc never use it. Fortunately, those platforms' default io
state is sdmmc function, but no always right for all.

Cc: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/mmc/host/dw_mmc-rockchip.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/mmc/host/dw_mmc-rockchip.c b/drivers/mmc/host/dw_mmc-rockchip.c
index d9c92f3..308b424 100644
--- a/drivers/mmc/host/dw_mmc-rockchip.c
+++ b/drivers/mmc/host/dw_mmc-rockchip.c
@@ -9,6 +9,7 @@
 
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/pinctrl/consumer.h>
 #include <linux/clk.h>
 #include <linux/mmc/host.h>
 #include <linux/mmc/dw_mmc.h>
@@ -21,6 +22,8 @@
 #define RK3288_CLKGEN_DIV       2
 
 struct dw_mci_rockchip_priv_data {
+	struct pinctrl		*pinctrl;
+	struct pinctrl_state	*pins_default;
 	struct clk		*drv_clk;
 	struct clk		*sample_clk;
 	int			default_sample_phase;
@@ -78,6 +81,10 @@ static void dw_mci_rk3288_set_ios(struct dw_mci *host, struct mmc_ios *ios)
 	/* Make sure we use phases which we can enumerate with */
 	if (!IS_ERR(priv->sample_clk))
 		clk_set_phase(priv->sample_clk, priv->default_sample_phase);
+
+	/* Make sure we use correct pinctrl which we can enumerate with */
+	if (!IS_ERR(priv->pinctrl) && !IS_ERR(priv->pins_default))
+		pinctrl_select_state(priv->pinctrl, priv->pins_default);
 }
 
 #define NUM_PHASES			360
@@ -223,6 +230,14 @@ static int dw_mci_rk3288_parse_dt(struct dw_mci *host)
 	if (IS_ERR(priv->sample_clk))
 		dev_dbg(host->dev, "ciu_sample not available\n");
 
+	priv->pinctrl = devm_pinctrl_get(host->dev);
+	if (!IS_ERR(priv->pinctrl)) {
+		priv->pins_default = pinctrl_lookup_state(priv->pinctrl,
+							  "default");
+		if (IS_ERR(priv->pins_default))
+			dev_dbg(host->dev, "pinctrl not available\n");
+	}
+
 	host->priv = priv;
 
 	return 0;
-- 
2.3.7

             reply	other threads:[~2016-01-19  9:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-19  9:52 Shawn Lin [this message]
2016-01-19 10:07 ` Heiko Stuebner
2016-01-19 11:07   ` Shawn Lin
2016-01-19 11:45     ` Caesar Wang
2016-01-20  0:54       ` Shawn Lin

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=1453197165-20194-1-git-send-email-shawn.lin@rock-chips.com \
    --to=shawn.lin@rock-chips.com \
    --cc=heiko@sntech.de \
    --cc=jh80.chung@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --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

all inboxes | Powered by JetHome®