devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5 0/4] mmc: usdhi6rol0: UHS support
@ 2016-04-27 15:21 Lars Persson
       [not found] ` <cover.1461770066.git.larper-VrBV9hrLPhE@public.gmane.org>
  2016-04-28 10:38 ` [PATCH v5 0/4] mmc: usdhi6rol0: UHS support Ulf Hansson
  0 siblings, 2 replies; 7+ messages in thread
From: Lars Persson @ 2016-04-27 15:21 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.

Changes since v4:
- Add a fix patch to remove UHS capabilities that were announced without
  actual driver support.

Changes since v3:
- No error print for failure of mmc_regulator_set_vqmmc().
- Do not set UHS caps if the vqmmc regulator is missing.
- No not set UHS caps if the no-1-8-v property is set.

Changes since v2:
- dt: renamed pins_uhs to state_uhs.
- dt: made default optional in pinctrl-names.
- dt: document that use of state_uhs also requires a default pin state.
- add error handling for missing pin states.

Changes since v1:
- Use mmc_regulator_set_vqmmc().

Lars Persson (4):
  mmc: dt: usdhi6rol0: add optional pinctrl binding
  mmc: usdhi6rol0: do not announce UHS capabilities
  mmc: usdhi6rol0: add support for UHS modes
  mmc: usdhi6rol0: add pinctrl to set pin drive strength

 .../devicetree/bindings/mmc/usdhi6rol0.txt         |  6 +++
 drivers/mmc/host/usdhi6rol0.c                      | 60 +++++++++++++++++++++-
 2 files changed, 65 insertions(+), 1 deletion(-)

-- 
2.1.4


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

* [PATCH v5 1/4] mmc: dt: usdhi6rol0: add optional pinctrl binding
       [not found] ` <cover.1461770066.git.larper-VrBV9hrLPhE@public.gmane.org>
@ 2016-04-27 15:21   ` Lars Persson
  2016-04-28 21:40     ` Rob Herring
  2016-04-27 15:21   ` [PATCH v5 2/4] mmc: usdhi6rol0: do not announce UHS capabilities Lars Persson
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Lars Persson @ 2016-04-27 15:21 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, Lars Persson

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

Signed-off-by: Lars Persson <larper-VrBV9hrLPhE@public.gmane.org>
---
 Documentation/devicetree/bindings/mmc/usdhi6rol0.txt | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/mmc/usdhi6rol0.txt b/Documentation/devicetree/bindings/mmc/usdhi6rol0.txt
index 8babdaa..6d1b797 100644
--- a/Documentation/devicetree/bindings/mmc/usdhi6rol0.txt
+++ b/Documentation/devicetree/bindings/mmc/usdhi6rol0.txt
@@ -12,6 +12,12 @@ 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: Can contain a "default" entry and a "state_uhs"
+                 entry. The state_uhs entry is used together with the default
+                 entry when the board requires distinct settings for UHS speeds.
+
+- 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

--
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] 7+ messages in thread

* [PATCH v5 2/4] mmc: usdhi6rol0: do not announce UHS capabilities
       [not found] ` <cover.1461770066.git.larper-VrBV9hrLPhE@public.gmane.org>
  2016-04-27 15:21   ` [PATCH v5 1/4] mmc: dt: usdhi6rol0: add optional pinctrl binding Lars Persson
@ 2016-04-27 15:21   ` Lars Persson
  2016-04-27 15:21   ` [PATCH v5 3/4] mmc: usdhi6rol0: add support for UHS modes Lars Persson
  2016-04-27 15:21   ` [PATCH v5 4/4] mmc: usdhi6rol0: add pinctrl to set pin drive strength Lars Persson
  3 siblings, 0 replies; 7+ messages in thread
From: Lars Persson @ 2016-04-27 15:21 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, Lars Persson

The driver in its current form does not support UHS at all due to
a missing start_signal_voltage_switch callback.

Also when this callback is added we should let the device tree control
UHS capabilities using the standard mmc bindings.

Signed-off-by: Lars Persson <larper-VrBV9hrLPhE@public.gmane.org>
---
 drivers/mmc/host/usdhi6rol0.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/host/usdhi6rol0.c b/drivers/mmc/host/usdhi6rol0.c
index 807c06e..e9c8dfa 100644
--- a/drivers/mmc/host/usdhi6rol0.c
+++ b/drivers/mmc/host/usdhi6rol0.c
@@ -1785,7 +1785,7 @@ static int usdhi6_probe(struct platform_device *pdev)
 
 	mmc->ops = &usdhi6_ops;
 	mmc->caps |= MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED |
-		MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_DDR50 | MMC_CAP_SDIO_IRQ;
+		     MMC_CAP_SDIO_IRQ;
 	/* Set .max_segs to some random number. Feel free to adjust. */
 	mmc->max_segs = 32;
 	mmc->max_blk_size = 512;
-- 
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] 7+ messages in thread

* [PATCH v5 3/4] mmc: usdhi6rol0: add support for UHS modes
       [not found] ` <cover.1461770066.git.larper-VrBV9hrLPhE@public.gmane.org>
  2016-04-27 15:21   ` [PATCH v5 1/4] mmc: dt: usdhi6rol0: add optional pinctrl binding Lars Persson
  2016-04-27 15:21   ` [PATCH v5 2/4] mmc: usdhi6rol0: do not announce UHS capabilities Lars Persson
@ 2016-04-27 15:21   ` Lars Persson
  2016-04-27 15:21   ` [PATCH v5 4/4] mmc: usdhi6rol0: add pinctrl to set pin drive strength Lars Persson
  3 siblings, 0 replies; 7+ messages in thread
From: Lars Persson @ 2016-04-27 15:21 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, Lars Persson

Add a start_signal_voltage_switch() operation to support enabling of
UHS modes.

Signed-off-by: Lars Persson <larper-VrBV9hrLPhE@public.gmane.org>
---
 drivers/mmc/host/usdhi6rol0.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/mmc/host/usdhi6rol0.c b/drivers/mmc/host/usdhi6rol0.c
index e9c8dfa..743e200 100644
--- a/drivers/mmc/host/usdhi6rol0.c
+++ b/drivers/mmc/host/usdhi6rol0.c
@@ -1147,12 +1147,22 @@ 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;
+
+	ret = mmc_regulator_set_vqmmc(mmc, ios);
+
+	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] 7+ messages in thread

* [PATCH v5 4/4] mmc: usdhi6rol0: add pinctrl to set pin drive strength
       [not found] ` <cover.1461770066.git.larper-VrBV9hrLPhE@public.gmane.org>
                     ` (2 preceding siblings ...)
  2016-04-27 15:21   ` [PATCH v5 3/4] mmc: usdhi6rol0: add support for UHS modes Lars Persson
@ 2016-04-27 15:21   ` Lars Persson
  3 siblings, 0 replies; 7+ messages in thread
From: Lars Persson @ 2016-04-27 15:21 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, 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-VrBV9hrLPhE@public.gmane.org>
---
 drivers/mmc/host/usdhi6rol0.c | 48 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/drivers/mmc/host/usdhi6rol0.c b/drivers/mmc/host/usdhi6rol0.c
index 743e200..1bd5f1a 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/scatterlist.h>
 #include <linux/string.h>
@@ -198,6 +199,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					*/
@@ -1147,12 +1153,35 @@ 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->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;
 
 	ret = mmc_regulator_set_vqmmc(mmc, ios);
+	if (ret < 0)
+		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;
 }
 
@@ -1740,6 +1769,25 @@ static int usdhi6_probe(struct platform_device *pdev)
 	host->wait	= USDHI6_WAIT_FOR_REQUEST;
 	host->timeout	= msecs_to_jiffies(4000);
 
+	host->pinctrl = devm_pinctrl_get(&pdev->dev);
+	if (IS_ERR(host->pinctrl)) {
+		ret = PTR_ERR(host->pinctrl);
+		goto e_free_mmc;
+	}
+
+	host->pins_uhs = pinctrl_lookup_state(host->pinctrl, "state_uhs");
+	if (!IS_ERR(host->pins_uhs)) {
+		host->pins_default = pinctrl_lookup_state(host->pinctrl,
+							  PINCTRL_STATE_DEFAULT);
+
+		if (IS_ERR(host->pins_default)) {
+			dev_err(dev,
+				"UHS pinctrl requires a default pin state.\n");
+			ret = PTR_ERR(host->pins_default);
+			goto e_free_mmc;
+		}
+	}
+
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	host->base = devm_ioremap_resource(dev, res);
 	if (IS_ERR(host->base)) {
-- 
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] 7+ messages in thread

* Re: [PATCH v5 0/4] mmc: usdhi6rol0: UHS support
  2016-04-27 15:21 [PATCH v5 0/4] mmc: usdhi6rol0: UHS support Lars Persson
       [not found] ` <cover.1461770066.git.larper-VrBV9hrLPhE@public.gmane.org>
@ 2016-04-28 10:38 ` Ulf Hansson
  1 sibling, 0 replies; 7+ messages in thread
From: Ulf Hansson @ 2016-04-28 10:38 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, Lars Persson

On 27 April 2016 at 17:21, Lars Persson <lars.persson@axis.com> wrote:
> This patch set adds UHS support to the usdhi6rol0 driver, with control of the
> regulator and pin state settings.
>
> Changes since v4:
> - Add a fix patch to remove UHS capabilities that were announced without
>   actual driver support.
>
> Changes since v3:
> - No error print for failure of mmc_regulator_set_vqmmc().
> - Do not set UHS caps if the vqmmc regulator is missing.
> - No not set UHS caps if the no-1-8-v property is set.
>
> Changes since v2:
> - dt: renamed pins_uhs to state_uhs.
> - dt: made default optional in pinctrl-names.
> - dt: document that use of state_uhs also requires a default pin state.
> - add error handling for missing pin states.
>
> Changes since v1:
> - Use mmc_regulator_set_vqmmc().
>
> Lars Persson (4):
>   mmc: dt: usdhi6rol0: add optional pinctrl binding
>   mmc: usdhi6rol0: do not announce UHS capabilities
>   mmc: usdhi6rol0: add support for UHS modes
>   mmc: usdhi6rol0: add pinctrl to set pin drive strength
>
>  .../devicetree/bindings/mmc/usdhi6rol0.txt         |  6 +++
>  drivers/mmc/host/usdhi6rol0.c                      | 60 +++++++++++++++++++++-
>  2 files changed, 65 insertions(+), 1 deletion(-)
>

Thanks, applied for next!

Kind regards
Uffe

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

* Re: [PATCH v5 1/4] mmc: dt: usdhi6rol0: add optional pinctrl binding
  2016-04-27 15:21   ` [PATCH v5 1/4] mmc: dt: usdhi6rol0: add optional pinctrl binding Lars Persson
@ 2016-04-28 21:40     ` Rob Herring
  0 siblings, 0 replies; 7+ messages in thread
From: Rob Herring @ 2016-04-28 21:40 UTC (permalink / raw)
  To: Lars Persson
  Cc: linux-mmc, devicetree, g.liakhovetski, ulf.hansson, pawel.moll,
	mark.rutland, ijc+devicetree, galak, Lars Persson

On Wed, Apr 27, 2016 at 05:21:26PM +0200, Lars Persson wrote:
> 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 | 6 ++++++
>  1 file changed, 6 insertions(+)

Acked-by: Rob Herring <robh@kernel.org>

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

end of thread, other threads:[~2016-04-28 21:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-27 15:21 [PATCH v5 0/4] mmc: usdhi6rol0: UHS support Lars Persson
     [not found] ` <cover.1461770066.git.larper-VrBV9hrLPhE@public.gmane.org>
2016-04-27 15:21   ` [PATCH v5 1/4] mmc: dt: usdhi6rol0: add optional pinctrl binding Lars Persson
2016-04-28 21:40     ` Rob Herring
2016-04-27 15:21   ` [PATCH v5 2/4] mmc: usdhi6rol0: do not announce UHS capabilities Lars Persson
2016-04-27 15:21   ` [PATCH v5 3/4] mmc: usdhi6rol0: add support for UHS modes Lars Persson
2016-04-27 15:21   ` [PATCH v5 4/4] mmc: usdhi6rol0: add pinctrl to set pin drive strength Lars Persson
2016-04-28 10:38 ` [PATCH v5 0/4] mmc: usdhi6rol0: UHS support Ulf Hansson

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).