All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Hutchings <ben.hutchings@codethink.co.uk>
To: Ian Molton <ian@mnementh.co.uk>, linux-mmc@vger.kernel.org
Cc: linux-sh@vger.kernel.org, linux-gpio@vger.kernel.org,
	linux-kernel@lists.codethink.co.uk,
	Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>,
	Simon Horman <horms@verge.net.au>,
	Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Subject: [PATCH v2 1/6] mmc: tmio: Add UHS-I mode support
Date: Tue, 09 Jun 2015 23:22:55 +0000	[thread overview]
Message-ID: <1433892175.12074.50.camel@codethink.co.uk> (raw)
In-Reply-To: <1433892104.12074.49.camel@codethink.co.uk>

Based on work by Shinobu Uehara and Ben Dooks.  This adds the voltage
switch operation needed for all UHS-I modes, but not the tuning needed
for SDR-104 which will come later.

The card_busy implementation is a bit of a guess, but works for me on
an R8A7790 chip.

Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
---
 drivers/mmc/host/tmio_mmc.h     |  3 +++
 drivers/mmc/host/tmio_mmc_pio.c | 31 +++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index 4a597f5a53e2..a1a009879946 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -99,6 +99,9 @@ struct tmio_mmc_host {
 	void (*clk_disable)(struct platform_device *pdev);
 	int (*multi_io_quirk)(struct mmc_card *card,
 			      unsigned int direction, int blk_size);
+
+	int (*start_signal_voltage_switch)(struct tmio_mmc_host *host,
+					   unsigned char signal_voltage);
 };
 
 struct tmio_mmc_host *tmio_mmc_host_alloc(struct platform_device *pdev);
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index e3dcf31a8bd6..3c1e0e53c0b1 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -1011,12 +1011,43 @@ static int tmio_multi_io_quirk(struct mmc_card *card,
 	return blk_size;
 }
 
+static int tmio_mmc_start_signal_voltage_switch(struct mmc_host *mmc,
+	struct mmc_ios *ios)
+{
+	struct tmio_mmc_host *host = mmc_priv(mmc);
+
+	if (!host->start_signal_voltage_switch)
+		return 0;
+
+	return host->start_signal_voltage_switch(host, ios->signal_voltage);
+}
+
+static int tmio_mmc_card_busy(struct mmc_host *mmc)
+{
+	struct tmio_mmc_host *host = mmc_priv(mmc);
+	u32 status;
+
+	pm_runtime_get_sync(mmc_dev(mmc));
+	status = sd_ctrl_read32(host, CTL_STATUS);
+	pm_runtime_mark_last_busy(mmc_dev(mmc));
+	pm_runtime_put_autosuspend(mmc_dev(mmc));
+
+	/*
+	 * Card signals busy by pulling down all of DAT[3:0].  This status
+	 * flag appears to reflect DAT3.
+	 */
+	return !(status & TMIO_STAT_SIGSTATE_A);
+}
+
 static const struct mmc_host_ops tmio_mmc_ops = {
 	.request	= tmio_mmc_request,
 	.set_ios	= tmio_mmc_set_ios,
 	.get_ro         = tmio_mmc_get_ro,
 	.get_cd		= mmc_gpio_get_cd,
 	.enable_sdio_irq = tmio_mmc_enable_sdio_irq,
+	.start_signal_voltage_switch
+			= tmio_mmc_start_signal_voltage_switch,
+	.card_busy	= tmio_mmc_card_busy,
 	.multi_io_quirk	= tmio_multi_io_quirk,
 };
 
-- 
2.1.4





WARNING: multiple messages have this Message-ID (diff)
From: Ben Hutchings <ben.hutchings@codethink.co.uk>
To: Ian Molton <ian@mnementh.co.uk>, linux-mmc@vger.kernel.org
Cc: linux-sh@vger.kernel.org, linux-gpio@vger.kernel.org,
	linux-kernel@lists.codethink.co.uk,
	Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>,
	Simon Horman <horms@verge.net.au>,
	Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Subject: [PATCH v2 1/6] mmc: tmio: Add UHS-I mode support
Date: Wed, 10 Jun 2015 00:22:55 +0100	[thread overview]
Message-ID: <1433892175.12074.50.camel@codethink.co.uk> (raw)
In-Reply-To: <1433892104.12074.49.camel@codethink.co.uk>

Based on work by Shinobu Uehara and Ben Dooks.  This adds the voltage
switch operation needed for all UHS-I modes, but not the tuning needed
for SDR-104 which will come later.

The card_busy implementation is a bit of a guess, but works for me on
an R8A7790 chip.

Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
---
 drivers/mmc/host/tmio_mmc.h     |  3 +++
 drivers/mmc/host/tmio_mmc_pio.c | 31 +++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index 4a597f5a53e2..a1a009879946 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -99,6 +99,9 @@ struct tmio_mmc_host {
 	void (*clk_disable)(struct platform_device *pdev);
 	int (*multi_io_quirk)(struct mmc_card *card,
 			      unsigned int direction, int blk_size);
+
+	int (*start_signal_voltage_switch)(struct tmio_mmc_host *host,
+					   unsigned char signal_voltage);
 };
 
 struct tmio_mmc_host *tmio_mmc_host_alloc(struct platform_device *pdev);
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index e3dcf31a8bd6..3c1e0e53c0b1 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -1011,12 +1011,43 @@ static int tmio_multi_io_quirk(struct mmc_card *card,
 	return blk_size;
 }
 
+static int tmio_mmc_start_signal_voltage_switch(struct mmc_host *mmc,
+	struct mmc_ios *ios)
+{
+	struct tmio_mmc_host *host = mmc_priv(mmc);
+
+	if (!host->start_signal_voltage_switch)
+		return 0;
+
+	return host->start_signal_voltage_switch(host, ios->signal_voltage);
+}
+
+static int tmio_mmc_card_busy(struct mmc_host *mmc)
+{
+	struct tmio_mmc_host *host = mmc_priv(mmc);
+	u32 status;
+
+	pm_runtime_get_sync(mmc_dev(mmc));
+	status = sd_ctrl_read32(host, CTL_STATUS);
+	pm_runtime_mark_last_busy(mmc_dev(mmc));
+	pm_runtime_put_autosuspend(mmc_dev(mmc));
+
+	/*
+	 * Card signals busy by pulling down all of DAT[3:0].  This status
+	 * flag appears to reflect DAT3.
+	 */
+	return !(status & TMIO_STAT_SIGSTATE_A);
+}
+
 static const struct mmc_host_ops tmio_mmc_ops = {
 	.request	= tmio_mmc_request,
 	.set_ios	= tmio_mmc_set_ios,
 	.get_ro         = tmio_mmc_get_ro,
 	.get_cd		= mmc_gpio_get_cd,
 	.enable_sdio_irq = tmio_mmc_enable_sdio_irq,
+	.start_signal_voltage_switch
+			= tmio_mmc_start_signal_voltage_switch,
+	.card_busy	= tmio_mmc_card_busy,
 	.multi_io_quirk	= tmio_multi_io_quirk,
 };
 
-- 
2.1.4





  reply	other threads:[~2015-06-09 23:22 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-09 23:21 [PATCH v2 0/6] UHS-I support for sh_mobile_sdhi Ben Hutchings
2015-06-09 23:21 ` Ben Hutchings
2015-06-09 23:22 ` Ben Hutchings [this message]
2015-06-09 23:22   ` [PATCH v2 1/6] mmc: tmio: Add UHS-I mode support Ben Hutchings
2015-06-09 23:23 ` [PATCH v2 2/6] pinctrl: sh-pfc: Add set_mux operation to struct sh_pfc_function Ben Hutchings
2015-06-09 23:23   ` Ben Hutchings
2015-06-09 23:23 ` [PATCH v2 3/6] pinctrl: sh-pfc: r8a7790: Add separate functions for SDHI 1.8V operation Ben Hutchings
2015-06-09 23:23   ` Ben Hutchings
2015-06-12  7:18   ` Laurent Pinchart
2015-06-12  7:18     ` Laurent Pinchart
2015-06-12 13:23     ` Ben Hutchings
2015-06-12 13:23       ` Ben Hutchings
2015-06-12 19:07       ` Laurent Pinchart
2015-06-12 19:07         ` Laurent Pinchart
2015-06-15  0:40         ` Ben Hutchings
2015-06-15  0:40           ` Ben Hutchings
2015-06-15  2:02           ` Laurent Pinchart
2015-06-15  2:02             ` Laurent Pinchart
2015-06-30  6:05             ` Linus Walleij
2015-06-30  6:05               ` Linus Walleij
2015-06-30  8:30               ` Laurent Pinchart
2015-06-30  8:30                 ` Laurent Pinchart
2015-06-09 23:23 ` [PATCH v2 4/6] mmc: sh_mobile_sdhi: Add UHS-I mode support Ben Hutchings
2015-06-09 23:23   ` Ben Hutchings
2015-06-09 23:24 ` [PATCH v2 5/6] ARM: shmobile: lager: Set clock rates for SDHI Ben Hutchings
2015-06-09 23:24   ` Ben Hutchings
2015-06-11  1:20   ` Kuninori Morimoto
2015-06-11  1:47     ` Ben Hutchings
2015-06-11  1:47       ` Ben Hutchings
2015-06-09 23:24 ` [PATCH v2 6/6] ARM: shmobile: lager: Enable UHS-I SDR-50 Ben Hutchings
2015-06-09 23:24   ` Ben Hutchings
2015-06-10  9:16 ` [PATCH v2 0/6] UHS-I support for sh_mobile_sdhi Ulf Hansson
2015-06-10  9:16   ` Ulf Hansson
2015-06-10 23:57   ` Ben Hutchings
2015-06-10 23:57     ` Ben Hutchings
2015-06-11  2:49     ` Simon Horman
2015-06-11  2:49       ` Simon Horman
2015-06-11 15:02       ` Ben Hutchings
2015-06-11 15:02         ` Ben Hutchings
2015-06-14  7:36         ` Geert Uytterhoeven
2015-06-14  7:36           ` Geert Uytterhoeven
2015-06-15  0:30           ` Ben Hutchings
2015-06-15  0:30             ` Ben Hutchings
2015-06-15  0:30           ` Ben Hutchings
2015-06-15  0:30             ` Ben Hutchings

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=1433892175.12074.50.camel@codethink.co.uk \
    --to=ben.hutchings@codethink.co.uk \
    --cc=horms@verge.net.au \
    --cc=ian@mnementh.co.uk \
    --cc=kuninori.morimoto.gx@renesas.com \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@lists.codethink.co.uk \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=sergei.shtylyov@cogentembedded.com \
    /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.