diff mbox

[2/3] mmc: usdhi6rol0: add support for UHS modes

Message ID ba126adf4953f61ed11ed8b0219608663cfb5fbc.1460971625.git.larper@axis.com (mailing list archive)
State New, archived
Headers show

Commit Message

Lars Persson April 18, 2016, 9:38 a.m. UTC
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(+)

Comments

Ulf Hansson April 18, 2016, 11:18 a.m. UTC | #1
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
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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				*/