All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jerome Brunet <jbrunet@baylibre.com>
To: Ulf Hansson <ulf.hansson@linaro.org>,
	Kevin Hilman <khilman@baylibre.com>,
	Carlo Caione <carlo@caione.org>
Cc: Jerome Brunet <jbrunet@baylibre.com>,
	linux-mmc@vger.kernel.org, linux-amlogic@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 14/14] mmc: meson-gx: implement voltage switch callback
Date: Fri,  4 Aug 2017 19:43:53 +0200	[thread overview]
Message-ID: <20170804174353.16486-15-jbrunet@baylibre.com> (raw)
In-Reply-To: <20170804174353.16486-1-jbrunet@baylibre.com>

Implement voltage switch callback (shamelessly copied from sunxi mmc
driver). This allow, with the appropriate tuning function, to use
SD ultra high speed modes.

Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
 drivers/mmc/host/meson-gx-mmc.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c
index e991c9e452ab..de2d7b8a9d97 100644
--- a/drivers/mmc/host/meson-gx-mmc.c
+++ b/drivers/mmc/host/meson-gx-mmc.c
@@ -38,6 +38,8 @@
 #include <linux/interrupt.h>
 #include <linux/bitfield.h>
 
+#include <linux/delay.h>
+
 #define DRIVER_NAME "meson-gx-mmc"
 
 #define SD_EMMC_CLOCK 0x0
@@ -1024,6 +1026,28 @@ static int meson_mmc_card_busy(struct mmc_host *mmc)
 	return !(FIELD_GET(STATUS_DATI, regval) & 0xf);
 }
 
+static int meson_mmc_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios)
+{
+	/* vqmmc regulator is available */
+	if (!IS_ERR(mmc->supply.vqmmc)) {
+		/*
+		 * The usual amlogic setup uses a GPIO to switch from one
+		 * regulator to the other. While the voltage ramp up is
+		 * pretty fast, care must be taken when switching from 3.3v
+		 * to 1.8v. Please make sure the regulator framework is aware
+		 * of your own regulator constraints
+		 */
+		return mmc_regulator_set_vqmmc(mmc, ios);
+
+	}
+
+	/* no vqmmc regulator, assume fixed regulator at 3/3.3V */
+	if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_330)
+		return 0;
+
+	return -EINVAL;
+}
+
 static const struct mmc_host_ops meson_mmc_ops = {
 	.request	= meson_mmc_request,
 	.set_ios	= meson_mmc_set_ios,
@@ -1032,6 +1056,7 @@ static const struct mmc_host_ops meson_mmc_ops = {
 	.post_req	= meson_mmc_post_req,
 	.execute_tuning = meson_mmc_execute_tuning,
 	.card_busy	= meson_mmc_card_busy,
+	.start_signal_voltage_switch = meson_mmc_voltage_switch,
 };
 
 static int meson_mmc_probe(struct platform_device *pdev)
-- 
2.9.4

WARNING: multiple messages have this Message-ID (diff)
From: jbrunet@baylibre.com (Jerome Brunet)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 14/14] mmc: meson-gx: implement voltage switch callback
Date: Fri,  4 Aug 2017 19:43:53 +0200	[thread overview]
Message-ID: <20170804174353.16486-15-jbrunet@baylibre.com> (raw)
In-Reply-To: <20170804174353.16486-1-jbrunet@baylibre.com>

Implement voltage switch callback (shamelessly copied from sunxi mmc
driver). This allow, with the appropriate tuning function, to use
SD ultra high speed modes.

Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
 drivers/mmc/host/meson-gx-mmc.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c
index e991c9e452ab..de2d7b8a9d97 100644
--- a/drivers/mmc/host/meson-gx-mmc.c
+++ b/drivers/mmc/host/meson-gx-mmc.c
@@ -38,6 +38,8 @@
 #include <linux/interrupt.h>
 #include <linux/bitfield.h>
 
+#include <linux/delay.h>
+
 #define DRIVER_NAME "meson-gx-mmc"
 
 #define SD_EMMC_CLOCK 0x0
@@ -1024,6 +1026,28 @@ static int meson_mmc_card_busy(struct mmc_host *mmc)
 	return !(FIELD_GET(STATUS_DATI, regval) & 0xf);
 }
 
+static int meson_mmc_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios)
+{
+	/* vqmmc regulator is available */
+	if (!IS_ERR(mmc->supply.vqmmc)) {
+		/*
+		 * The usual amlogic setup uses a GPIO to switch from one
+		 * regulator to the other. While the voltage ramp up is
+		 * pretty fast, care must be taken when switching from 3.3v
+		 * to 1.8v. Please make sure the regulator framework is aware
+		 * of your own regulator constraints
+		 */
+		return mmc_regulator_set_vqmmc(mmc, ios);
+
+	}
+
+	/* no vqmmc regulator, assume fixed regulator at 3/3.3V */
+	if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_330)
+		return 0;
+
+	return -EINVAL;
+}
+
 static const struct mmc_host_ops meson_mmc_ops = {
 	.request	= meson_mmc_request,
 	.set_ios	= meson_mmc_set_ios,
@@ -1032,6 +1056,7 @@ static const struct mmc_host_ops meson_mmc_ops = {
 	.post_req	= meson_mmc_post_req,
 	.execute_tuning = meson_mmc_execute_tuning,
 	.card_busy	= meson_mmc_card_busy,
+	.start_signal_voltage_switch = meson_mmc_voltage_switch,
 };
 
 static int meson_mmc_probe(struct platform_device *pdev)
-- 
2.9.4

WARNING: multiple messages have this Message-ID (diff)
From: jbrunet@baylibre.com (Jerome Brunet)
To: linus-amlogic@lists.infradead.org
Subject: [PATCH 14/14] mmc: meson-gx: implement voltage switch callback
Date: Fri,  4 Aug 2017 19:43:53 +0200	[thread overview]
Message-ID: <20170804174353.16486-15-jbrunet@baylibre.com> (raw)
In-Reply-To: <20170804174353.16486-1-jbrunet@baylibre.com>

Implement voltage switch callback (shamelessly copied from sunxi mmc
driver). This allow, with the appropriate tuning function, to use
SD ultra high speed modes.

Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
 drivers/mmc/host/meson-gx-mmc.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c
index e991c9e452ab..de2d7b8a9d97 100644
--- a/drivers/mmc/host/meson-gx-mmc.c
+++ b/drivers/mmc/host/meson-gx-mmc.c
@@ -38,6 +38,8 @@
 #include <linux/interrupt.h>
 #include <linux/bitfield.h>
 
+#include <linux/delay.h>
+
 #define DRIVER_NAME "meson-gx-mmc"
 
 #define SD_EMMC_CLOCK 0x0
@@ -1024,6 +1026,28 @@ static int meson_mmc_card_busy(struct mmc_host *mmc)
 	return !(FIELD_GET(STATUS_DATI, regval) & 0xf);
 }
 
+static int meson_mmc_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios)
+{
+	/* vqmmc regulator is available */
+	if (!IS_ERR(mmc->supply.vqmmc)) {
+		/*
+		 * The usual amlogic setup uses a GPIO to switch from one
+		 * regulator to the other. While the voltage ramp up is
+		 * pretty fast, care must be taken when switching from 3.3v
+		 * to 1.8v. Please make sure the regulator framework is aware
+		 * of your own regulator constraints
+		 */
+		return mmc_regulator_set_vqmmc(mmc, ios);
+
+	}
+
+	/* no vqmmc regulator, assume fixed regulator at 3/3.3V */
+	if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_330)
+		return 0;
+
+	return -EINVAL;
+}
+
 static const struct mmc_host_ops meson_mmc_ops = {
 	.request	= meson_mmc_request,
 	.set_ios	= meson_mmc_set_ios,
@@ -1032,6 +1056,7 @@ static const struct mmc_host_ops meson_mmc_ops = {
 	.post_req	= meson_mmc_post_req,
 	.execute_tuning = meson_mmc_execute_tuning,
 	.card_busy	= meson_mmc_card_busy,
+	.start_signal_voltage_switch = meson_mmc_voltage_switch,
 };
 
 static int meson_mmc_probe(struct platform_device *pdev)
-- 
2.9.4

  parent reply	other threads:[~2017-08-04 17:44 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-04 17:43 [PATCH 00/14] mmc: meson-gx: driver fixups and upgrade Jerome Brunet
2017-08-04 17:43 ` Jerome Brunet
2017-08-04 17:43 ` Jerome Brunet
2017-08-04 17:43 ` [PATCH 01/14] mmc: meson-gx: fix mux mask definition Jerome Brunet
2017-08-04 17:43   ` Jerome Brunet
2017-08-04 17:43   ` Jerome Brunet
2017-08-04 17:43   ` Jerome Brunet
2017-08-04 17:43 ` [PATCH 02/14] mmc: meson-gx: remove CLK_DIVIDER_ALLOW_ZERO clock flag Jerome Brunet
2017-08-04 17:43   ` Jerome Brunet
2017-08-04 17:43   ` Jerome Brunet
2017-08-04 17:43 ` [PATCH 03/14] mmc: meson-gx: clean up some constants Jerome Brunet
2017-08-04 17:43   ` Jerome Brunet
2017-08-04 17:43   ` Jerome Brunet
2017-08-04 17:43   ` Jerome Brunet
2017-08-07 21:06   ` Kevin Hilman
2017-08-07 21:06     ` Kevin Hilman
2017-08-07 21:06     ` Kevin Hilman
2017-08-21 11:54     ` Jerome Brunet
2017-08-21 11:54       ` Jerome Brunet
2017-08-21 11:54       ` Jerome Brunet
2017-08-04 17:43 ` [PATCH 04/14] mmc: meson-gx: use _irqsave variant of spinlock Jerome Brunet
2017-08-04 17:43   ` Jerome Brunet
2017-08-04 17:43   ` Jerome Brunet
2017-08-04 17:43 ` [PATCH 05/14] mmc: meson-gx: cfg init overwrite values Jerome Brunet
2017-08-04 17:43   ` Jerome Brunet
2017-08-04 17:43   ` Jerome Brunet
2017-08-04 17:43 ` [PATCH 06/14] mmc: meson-gx: rework set_ios function Jerome Brunet
2017-08-04 17:43   ` Jerome Brunet
2017-08-04 17:43   ` Jerome Brunet
2017-08-04 17:43 ` [PATCH 07/14] mmc: meson-gx: rework clk_set function Jerome Brunet
2017-08-04 17:43   ` Jerome Brunet
2017-08-04 17:43   ` Jerome Brunet
2017-08-04 17:43 ` [PATCH 08/14] mmc: meson-gx: rework clock init function Jerome Brunet
2017-08-04 17:43   ` Jerome Brunet
2017-08-04 17:43   ` Jerome Brunet
2017-08-07 21:34   ` Kevin Hilman
2017-08-07 21:34     ` Kevin Hilman
2017-08-07 21:34     ` Kevin Hilman
2017-08-21 12:05     ` Jerome Brunet
2017-08-21 12:05       ` Jerome Brunet
2017-08-21 12:05       ` Jerome Brunet
2017-08-04 17:43 ` [PATCH 09/14] mmc: meson-gx: simplify interrupt handler Jerome Brunet
2017-08-04 17:43   ` Jerome Brunet
2017-08-04 17:43   ` Jerome Brunet
2017-08-04 17:43 ` [PATCH 10/14] mmc: meson-gx: implement card_busy callback Jerome Brunet
2017-08-04 17:43   ` Jerome Brunet
2017-08-04 17:43   ` Jerome Brunet
2017-08-04 17:43 ` [PATCH 11/14] mmc: meson-gx: rework tuning function Jerome Brunet
2017-08-04 17:43   ` Jerome Brunet
2017-08-04 17:43   ` Jerome Brunet
2017-08-04 17:43 ` [PATCH 12/14] mmc: meson-gx: fix dual data rate mode frequencies Jerome Brunet
2017-08-04 17:43   ` Jerome Brunet
2017-08-04 17:43   ` Jerome Brunet
2017-08-04 17:43 ` [PATCH 13/14] mmc: meson-gx: work around clk-stop issue Jerome Brunet
2017-08-04 17:43   ` Jerome Brunet
2017-08-04 17:43   ` Jerome Brunet
2017-08-07 21:41   ` Kevin Hilman
2017-08-07 21:41     ` Kevin Hilman
2017-08-07 21:41     ` Kevin Hilman
2017-08-04 17:43 ` Jerome Brunet [this message]
2017-08-04 17:43   ` [PATCH 14/14] mmc: meson-gx: implement voltage switch callback Jerome Brunet
2017-08-04 17:43   ` Jerome Brunet
2017-08-07 16:48 ` [PATCH 00/14] mmc: meson-gx: driver fixups and upgrade Jerome Brunet
2017-08-07 16:48   ` Jerome Brunet
2017-08-07 16:48   ` Jerome Brunet
2017-08-07 21:44   ` Kevin Hilman
2017-08-07 21:44     ` Kevin Hilman
2017-08-07 21:44     ` Kevin Hilman

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=20170804174353.16486-15-jbrunet@baylibre.com \
    --to=jbrunet@baylibre.com \
    --cc=carlo@caione.org \
    --cc=khilman@baylibre.com \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --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 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.