All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] mmc: usdhi6rol0: UHS support
@ 2016-04-18  9:38 Lars Persson
  2016-04-18  9:38 ` [PATCH 1/3] mmc: dt: usdhi6rol0: add optional pinctrl binding Lars Persson
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Lars Persson @ 2016-04-18  9:38 UTC (permalink / raw)
  To: linux-mmc, devicetree
  Cc: g.liakhovetski, ulf.hansson, robh+dt, pawel.moll, mark.rutland,
	ijc+devicetree, galak, Lars Persson

This patch set adds UHS support to the usdhi6rol0 driver, with control of the
regulator and pin state settings.

Guennadi Liakhovetski (1):
  mmc: usdhi6rol0: add support for UHS modes

Lars Persson (2):
  mmc: dt: usdhi6rol0: add optional pinctrl binding
  mmc: usdhi6rol0: add pinctrl to set pin drive strength

 .../devicetree/bindings/mmc/usdhi6rol0.txt         |  4 ++
 drivers/mmc/host/usdhi6rol0.c                      | 70 ++++++++++++++++++++++
 2 files changed, 74 insertions(+)

-- 
2.1.4


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] mmc: dt: usdhi6rol0: add optional pinctrl binding
  2016-04-18  9:38 [PATCH 0/3] mmc: usdhi6rol0: UHS support Lars Persson
@ 2016-04-18  9:38 ` Lars Persson
       [not found] ` <cover.1460971625.git.larper-VrBV9hrLPhE@public.gmane.org>
  2016-04-18  9:38 ` [PATCH 3/3] mmc: usdhi6rol0: add pinctrl to set pin drive strength Lars Persson
  2 siblings, 0 replies; 5+ messages in thread
From: Lars Persson @ 2016-04-18  9:38 UTC (permalink / raw)
  To: linux-mmc, devicetree
  Cc: g.liakhovetski, ulf.hansson, robh+dt, pawel.moll, mark.rutland,
	ijc+devicetree, galak, Lars Persson

Add a pinctrl binding to specify different pin settings for high speed
modes and UHS modes.

Signed-off-by: Lars Persson <larper@axis.com>
---
 Documentation/devicetree/bindings/mmc/usdhi6rol0.txt | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/mmc/usdhi6rol0.txt b/Documentation/devicetree/bindings/mmc/usdhi6rol0.txt
index 8babdaa..9dd9478 100644
--- a/Documentation/devicetree/bindings/mmc/usdhi6rol0.txt
+++ b/Documentation/devicetree/bindings/mmc/usdhi6rol0.txt
@@ -12,6 +12,10 @@ Optional properties:
 
 - vmmc-supply:	a phandle of a regulator, supplying Vcc to the card
 - vqmmc-supply:	a phandle of a regulator, supplying VccQ to the card
+- pinctrl-names: Must contain a "default" entry and optionally a "pins_uhs"
+                 entry for the UHS pin configuration.
+- pinctrl-N: One property for each name listed in pinctrl-names, see
+             ../pinctrl/pinctrl-bindings.txt.
 
 Additionally any standard mmc bindings from mmc.txt can be used.
 
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] mmc: usdhi6rol0: add support for UHS modes
       [not found] ` <cover.1460971625.git.larper-VrBV9hrLPhE@public.gmane.org>
@ 2016-04-18  9:38   ` Lars Persson
  2016-04-18 11:18     ` Ulf Hansson
  0 siblings, 1 reply; 5+ messages in thread
From: Lars Persson @ 2016-04-18  9:38 UTC (permalink / raw)
  To: linux-mmc-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA
  Cc: g.liakhovetski-Mmb7MZpHnFY, ulf.hansson-QSEj5FYQhm4dnm+yROfE0A,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, pawel.moll-5wv7dgnIgG8,
	mark.rutland-5wv7dgnIgG8, ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
	galak-sgV2jX0FEOL9JmXXK+q4OQ, Phil Edworthy, Lars Persson

From: Guennadi Liakhovetski <g.liakhovetski-Mmb7MZpHnFY@public.gmane.org>

The mmc core will only enable UHS modes if the host supports the
.start_signal_voltage_switch() operation. Add this method to the v08r07
driver even if there's actually nothing to do in it.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski-Mmb7MZpHnFY@public.gmane.org>
Signed-off-by: Phil Edworthy <phil-r1wpeF5ryA4gsBAKwltoeQ@public.gmane.org>
Signed-off-by: Lars Persson <larper-VrBV9hrLPhE@public.gmane.org>
---
 drivers/mmc/host/usdhi6rol0.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/drivers/mmc/host/usdhi6rol0.c b/drivers/mmc/host/usdhi6rol0.c
index 807c06e..5dde31b 100644
--- a/drivers/mmc/host/usdhi6rol0.c
+++ b/drivers/mmc/host/usdhi6rol0.c
@@ -23,6 +23,7 @@
 #include <linux/module.h>
 #include <linux/pagemap.h>
 #include <linux/platform_device.h>
+#include <linux/regulator/consumer.h>
 #include <linux/scatterlist.h>
 #include <linux/string.h>
 #include <linux/time.h>
@@ -1147,12 +1148,43 @@ static void usdhi6_enable_sdio_irq(struct mmc_host *mmc, int enable)
 	}
 }
 
+static int usdhi6_sig_volt_switch(struct mmc_host *mmc, struct mmc_ios *ios)
+{
+	int ret;
+
+	if (IS_ERR(mmc->supply.vqmmc))
+		return 0;
+
+	switch (ios->signal_voltage) {
+	case MMC_SIGNAL_VOLTAGE_330:
+		ret = regulator_set_voltage(mmc->supply.vqmmc,
+					    2700000, 3600000);
+		break;
+	case MMC_SIGNAL_VOLTAGE_180:
+		ret = regulator_set_voltage(mmc->supply.vqmmc,
+					    1700000, 1950000);
+		break;
+	case MMC_SIGNAL_VOLTAGE_120:
+		ret = regulator_set_voltage(mmc->supply.vqmmc,
+					    1100000, 1300000);
+		break;
+	default:
+		return 0;
+	}
+
+	if (ret < 0)
+		dev_warn(mmc_dev(mmc), "Voltage switch failed: %d\n", ret);
+
+	return ret;
+}
+
 static struct mmc_host_ops usdhi6_ops = {
 	.request	= usdhi6_request,
 	.set_ios	= usdhi6_set_ios,
 	.get_cd		= usdhi6_get_cd,
 	.get_ro		= usdhi6_get_ro,
 	.enable_sdio_irq = usdhi6_enable_sdio_irq,
+	.start_signal_voltage_switch = usdhi6_sig_volt_switch,
 };
 
 /*			State machine handlers				*/
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] mmc: usdhi6rol0: add pinctrl to set pin drive strength
  2016-04-18  9:38 [PATCH 0/3] mmc: usdhi6rol0: UHS support Lars Persson
  2016-04-18  9:38 ` [PATCH 1/3] mmc: dt: usdhi6rol0: add optional pinctrl binding Lars Persson
       [not found] ` <cover.1460971625.git.larper-VrBV9hrLPhE@public.gmane.org>
@ 2016-04-18  9:38 ` Lars Persson
  2 siblings, 0 replies; 5+ messages in thread
From: Lars Persson @ 2016-04-18  9:38 UTC (permalink / raw)
  To: linux-mmc, devicetree
  Cc: g.liakhovetski, ulf.hansson, robh+dt, pawel.moll, mark.rutland,
	ijc+devicetree, galak, Lars Persson

Some boards need different pin drive strength for the UHS mode. Add an
optional pinctrl setting with two pin states covering UHS speeds and
other speeds.

Signed-off-by: Lars Persson <larper@axis.com>
---
 drivers/mmc/host/usdhi6rol0.c | 40 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 39 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/usdhi6rol0.c b/drivers/mmc/host/usdhi6rol0.c
index 5dde31b..4675ec0 100644
--- a/drivers/mmc/host/usdhi6rol0.c
+++ b/drivers/mmc/host/usdhi6rol0.c
@@ -22,6 +22,7 @@
 #include <linux/mmc/sdio.h>
 #include <linux/module.h>
 #include <linux/pagemap.h>
+#include <linux/pinctrl/consumer.h>
 #include <linux/platform_device.h>
 #include <linux/regulator/consumer.h>
 #include <linux/scatterlist.h>
@@ -199,6 +200,11 @@ struct usdhi6_host {
 	struct dma_chan *chan_rx;
 	struct dma_chan *chan_tx;
 	bool dma_active;
+
+	/* Pin control */
+	struct pinctrl *pinctrl;
+	struct pinctrl_state *pins_default;
+	struct pinctrl_state *pins_uhs;
 };
 
 /*			I/O primitives					*/
@@ -1148,6 +1154,24 @@ static void usdhi6_enable_sdio_irq(struct mmc_host *mmc, int enable)
 	}
 }
 
+static int usdhi6_set_pinstates(struct usdhi6_host *host, int voltage)
+{
+	if (IS_ERR(host->pinctrl) || IS_ERR(host->pins_default) ||
+	    IS_ERR(host->pins_uhs))
+		return 0;
+
+	switch (voltage) {
+	case MMC_SIGNAL_VOLTAGE_180:
+	case MMC_SIGNAL_VOLTAGE_120:
+		return pinctrl_select_state(host->pinctrl,
+					    host->pins_uhs);
+
+	default:
+		return pinctrl_select_state(host->pinctrl,
+					    host->pins_default);
+	}
+}
+
 static int usdhi6_sig_volt_switch(struct mmc_host *mmc, struct mmc_ios *ios)
 {
 	int ret;
@@ -1172,8 +1196,15 @@ static int usdhi6_sig_volt_switch(struct mmc_host *mmc, struct mmc_ios *ios)
 		return 0;
 	}
 
-	if (ret < 0)
+	if (ret < 0) {
 		dev_warn(mmc_dev(mmc), "Voltage switch failed: %d\n", ret);
+		return ret;
+	}
+
+	ret = usdhi6_set_pinstates(mmc_priv(mmc), ios->signal_voltage);
+	if (ret)
+		dev_warn_once(mmc_dev(mmc),
+			      "Failed to set pinstate err=%d\n", ret);
 
 	return ret;
 }
@@ -1836,6 +1867,13 @@ static int usdhi6_probe(struct platform_device *pdev)
 		mmc->f_max = host->imclk;
 	mmc->f_min = host->imclk / 512;
 
+	host->pinctrl = devm_pinctrl_get(&pdev->dev);
+	if (!IS_ERR(host->pinctrl)) {
+		host->pins_default = pinctrl_lookup_state(host->pinctrl,
+							  PINCTRL_STATE_DEFAULT);
+		host->pins_uhs     = pinctrl_lookup_state(host->pinctrl,
+							  "pins_uhs");
+	}
 	platform_set_drvdata(pdev, host);
 
 	ret = mmc_add_host(mmc);
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/3] mmc: usdhi6rol0: add support for UHS modes
  2016-04-18  9:38   ` [PATCH 2/3] mmc: usdhi6rol0: add support for UHS modes Lars Persson
@ 2016-04-18 11:18     ` Ulf Hansson
  0 siblings, 0 replies; 5+ messages in thread
From: Ulf Hansson @ 2016-04-18 11:18 UTC (permalink / raw)
  To: Lars Persson
  Cc: linux-mmc, devicetree@vger.kernel.org, Guennadi Liakhovetski,
	Rob Herring, Paweł Moll, Mark Rutland, Ian Campbell,
	Kumar Gala, Phil Edworthy, Lars Persson

On 18 April 2016 at 11:38, Lars Persson <lars.persson@axis.com> wrote:
> From: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
>
> The mmc core will only enable UHS modes if the host supports the
> .start_signal_voltage_switch() operation. Add this method to the v08r07
> driver even if there's actually nothing to do in it.
>
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> Signed-off-by: Phil Edworthy <phil@edworthys.org>
> Signed-off-by: Lars Persson <larper@axis.com>
> ---
>  drivers/mmc/host/usdhi6rol0.c | 32 ++++++++++++++++++++++++++++++++
>  1 file changed, 32 insertions(+)
>
> diff --git a/drivers/mmc/host/usdhi6rol0.c b/drivers/mmc/host/usdhi6rol0.c
> index 807c06e..5dde31b 100644
> --- a/drivers/mmc/host/usdhi6rol0.c
> +++ b/drivers/mmc/host/usdhi6rol0.c
> @@ -23,6 +23,7 @@
>  #include <linux/module.h>
>  #include <linux/pagemap.h>
>  #include <linux/platform_device.h>
> +#include <linux/regulator/consumer.h>
>  #include <linux/scatterlist.h>
>  #include <linux/string.h>
>  #include <linux/time.h>
> @@ -1147,12 +1148,43 @@ static void usdhi6_enable_sdio_irq(struct mmc_host *mmc, int enable)
>         }
>  }
>
> +static int usdhi6_sig_volt_switch(struct mmc_host *mmc, struct mmc_ios *ios)
> +{
> +       int ret;
> +
> +       if (IS_ERR(mmc->supply.vqmmc))
> +               return 0;
> +
> +       switch (ios->signal_voltage) {
> +       case MMC_SIGNAL_VOLTAGE_330:
> +               ret = regulator_set_voltage(mmc->supply.vqmmc,
> +                                           2700000, 3600000);
> +               break;
> +       case MMC_SIGNAL_VOLTAGE_180:
> +               ret = regulator_set_voltage(mmc->supply.vqmmc,
> +                                           1700000, 1950000);
> +               break;
> +       case MMC_SIGNAL_VOLTAGE_120:
> +               ret = regulator_set_voltage(mmc->supply.vqmmc,
> +                                           1100000, 1300000);
> +               break;
> +       default:
> +               return 0;
> +       }

Please replace this switch statement with a call to
mmc_regulator_set_vqmmc() instead.

> +
> +       if (ret < 0)
> +               dev_warn(mmc_dev(mmc), "Voltage switch failed: %d\n", ret);
> +
> +       return ret;
> +}
> +
>  static struct mmc_host_ops usdhi6_ops = {
>         .request        = usdhi6_request,
>         .set_ios        = usdhi6_set_ios,
>         .get_cd         = usdhi6_get_cd,
>         .get_ro         = usdhi6_get_ro,
>         .enable_sdio_irq = usdhi6_enable_sdio_irq,
> +       .start_signal_voltage_switch = usdhi6_sig_volt_switch,
>  };
>
>  /*                     State machine handlers                          */
> --
> 2.1.4
>

Kind regards
Uffe

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-04-18 11:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-18  9:38 [PATCH 0/3] mmc: usdhi6rol0: UHS support Lars Persson
2016-04-18  9:38 ` [PATCH 1/3] mmc: dt: usdhi6rol0: add optional pinctrl binding Lars Persson
     [not found] ` <cover.1460971625.git.larper-VrBV9hrLPhE@public.gmane.org>
2016-04-18  9:38   ` [PATCH 2/3] mmc: usdhi6rol0: add support for UHS modes Lars Persson
2016-04-18 11:18     ` Ulf Hansson
2016-04-18  9:38 ` [PATCH 3/3] mmc: usdhi6rol0: add pinctrl to set pin drive strength Lars Persson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.