All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wolfram Sang <wsa@the-dreams.de>
To: linux-renesas-soc@vger.kernel.org
Cc: linux-mmc@vger.kernel.org,
	Ben Hutchings <ben.hutchings@codethink.co.uk>,
	Dirk Behme <dirk.behme@gmail.com>,
	Wolfram Sang <wsa+renesas@sang-engineering.com>
Subject: [RFC 4/7] mmc: tmio: Add UHS-I mode support
Date: Fri, 19 Feb 2016 21:16:40 +0100	[thread overview]
Message-ID: <1455913003-6140-5-git-send-email-wsa@the-dreams.de> (raw)
In-Reply-To: <1455913003-6140-1-git-send-email-wsa@the-dreams.de>

From: Ben Hutchings <ben.hutchings@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>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 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 b44b5890290622..aabd36955e73fb 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -101,6 +101,9 @@ struct tmio_mmc_host {
 	void (*clk_disable)(struct tmio_mmc_host *host);
 	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 ae81b34f17a5a5..081a3def9305c1 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -1012,12 +1012,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.7.0


  parent reply	other threads:[~2016-02-19 20:17 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-19 20:16 [RFC 0/7] r8a7790: add UHS-I (SDR50) support to Lager Wolfram Sang
2016-02-19 20:16 ` [RFC 1/7] pinctrl: sh-pfc: r8a7790: Implement voltage switching for SDHI Wolfram Sang
2016-02-29 10:53   ` Geert Uytterhoeven
2016-02-29 11:37     ` Wolfram Sang
2016-03-01 13:42     ` Wolfram Sang
2016-02-19 20:16 ` [RFC 2/7] mmc: tmio, sh_mobile_sdhi: Pass tmio_mmc_host ptr to clk_{enable,disable} ops Wolfram Sang
2016-02-19 20:16 ` [RFC 3/7] mmc: tmio, sh_mobile_sdhi: Add support for variable input clock frequency Wolfram Sang
2016-02-19 20:16 ` Wolfram Sang [this message]
2016-03-03 14:41   ` [RFC 4/7] mmc: tmio: Add UHS-I mode support Ulf Hansson
2016-03-06 15:25     ` Wolfram Sang
2016-03-09 16:17     ` Wolfram Sang
2016-03-16  8:58       ` Ulf Hansson
2016-03-22 17:21         ` Wolfram Sang
2016-02-19 20:16 ` [RFC 5/7] mmc: sh_mobile_sdhi: " Wolfram Sang
2016-03-03 14:47   ` Ulf Hansson
2016-03-09 16:20     ` Wolfram Sang
2016-02-19 20:16 ` [RFC 6/7] ARM: shmobile: r8a7790: Set maximum frequencies for SDHI clocks Wolfram Sang
2016-02-19 20:16 ` [RFC 7/7] ARM: shmobile: r8a7790: lager: Enable UHS-I SDR-50 Wolfram Sang

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=1455913003-6140-5-git-send-email-wsa@the-dreams.de \
    --to=wsa@the-dreams.de \
    --cc=ben.hutchings@codethink.co.uk \
    --cc=dirk.behme@gmail.com \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=wsa+renesas@sang-engineering.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.