All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wolfram Sang <wsa@the-dreams.de>
To: linux-mmc@vger.kernel.org
Cc: Wolfram Sang <wsa@the-dreams.de>,
	linux-renesas-soc@vger.kernel.org,
	Ben Hutchings <ben.hutchings@codethink.co.uk>
Subject: [PATCH v2 4/9] mmc: tmio: always start clock after frequency calculation
Date: Fri,  1 Apr 2016 17:44:34 +0200	[thread overview]
Message-ID: <1459525479-20842-5-git-send-email-wsa@the-dreams.de> (raw)
In-Reply-To: <1459525479-20842-1-git-send-email-wsa@the-dreams.de>

From: Wolfram Sang <wsa+renesas@sang-engineering.com>

Starting the clock is always done after frequency change anyhow, so we can do
it directly after the clock calculation and remove the specific calls. This is
the first part of doing proper clock de-/activation at calculation time.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/mmc/host/tmio_mmc_pio.c | 34 ++++++++++++++++------------------
 1 file changed, 16 insertions(+), 18 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index 53e5ba5a21914c..a05938da049bd6 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -154,6 +154,18 @@ static void tmio_mmc_enable_sdio_irq(struct mmc_host *mmc, int enable)
 	}
 }
 
+static void tmio_mmc_clk_start(struct tmio_mmc_host *host)
+{
+	sd_ctrl_write16(host, CTL_SD_CARD_CLK_CTL, CLK_CTL_SCLKEN |
+		sd_ctrl_read16(host, CTL_SD_CARD_CLK_CTL));
+	msleep(host->pdata->flags & TMIO_MMC_FAST_CLK_CHG ? 1 : 10);
+
+	if (host->pdata->flags & TMIO_MMC_HAVE_HIGH_REG) {
+		sd_ctrl_write16(host, CTL_CLK_AND_WAIT_CTL, 0x0100);
+		msleep(10);
+	}
+}
+
 static void tmio_mmc_set_clock(struct tmio_mmc_host *host,
 				unsigned int new_clock)
 {
@@ -182,6 +194,8 @@ static void tmio_mmc_set_clock(struct tmio_mmc_host *host,
 	sd_ctrl_write16(host, CTL_SD_CARD_CLK_CTL, clk & CLK_CTL_DIV_MASK);
 	if (!(host->pdata->flags & TMIO_MMC_FAST_CLK_CHG))
 		msleep(10);
+
+	tmio_mmc_clk_start(host);
 }
 
 static void tmio_mmc_clk_stop(struct tmio_mmc_host *host)
@@ -196,18 +210,6 @@ static void tmio_mmc_clk_stop(struct tmio_mmc_host *host)
 	msleep(host->pdata->flags & TMIO_MMC_FAST_CLK_CHG ? 5 : 10);
 }
 
-static void tmio_mmc_clk_start(struct tmio_mmc_host *host)
-{
-	sd_ctrl_write16(host, CTL_SD_CARD_CLK_CTL, CLK_CTL_SCLKEN |
-		sd_ctrl_read16(host, CTL_SD_CARD_CLK_CTL));
-	msleep(host->pdata->flags & TMIO_MMC_FAST_CLK_CHG ? 1 : 10);
-
-	if (host->pdata->flags & TMIO_MMC_HAVE_HIGH_REG) {
-		sd_ctrl_write16(host, CTL_CLK_AND_WAIT_CTL, 0x0100);
-		msleep(10);
-	}
-}
-
 static void tmio_mmc_reset(struct tmio_mmc_host *host)
 {
 	/* FIXME - should we set stop clock reg here */
@@ -955,14 +957,12 @@ static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 		tmio_mmc_clk_stop(host);
 		break;
 	case MMC_POWER_UP:
-		tmio_mmc_set_clock(host, ios->clock);
 		tmio_mmc_power_on(host, ios->vdd);
-		tmio_mmc_clk_start(host);
+		tmio_mmc_set_clock(host, ios->clock);
 		tmio_mmc_set_bus_width(host, ios->bus_width);
 		break;
 	case MMC_POWER_ON:
 		tmio_mmc_set_clock(host, ios->clock);
-		tmio_mmc_clk_start(host);
 		tmio_mmc_set_bus_width(host, ios->bus_width);
 		break;
 	}
@@ -1271,10 +1271,8 @@ int tmio_mmc_host_runtime_resume(struct device *dev)
 	tmio_mmc_reset(host);
 	tmio_mmc_clk_enable(host);
 
-	if (host->clk_cache) {
+	if (host->clk_cache)
 		tmio_mmc_set_clock(host, host->clk_cache);
-		tmio_mmc_clk_start(host);
-	}
 
 	tmio_mmc_enable_dma(host, true);
 
-- 
2.7.0

  parent reply	other threads:[~2016-04-01 15:44 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-01 15:44 [PATCH v2 0/9] r8a7790: add UHS-I (SDR50) support to Lager Wolfram Sang
2016-04-01 15:44 ` [PATCH v2 1/9] mmc: tmio, sh_mobile_sdhi: Pass tmio_mmc_host ptr to clk_{enable,disable} ops Wolfram Sang
2016-04-01 15:44 ` [PATCH v2 2/9] mmc: tmio, sh_mobile_sdhi: Add support for variable input clock frequency Wolfram Sang
2016-04-12 12:55   ` Geert Uytterhoeven
2016-04-12 16:19     ` Ben Hutchings
2016-04-15 20:28       ` Wolfram Sang
2016-04-15 20:41         ` Wolfram Sang
2016-04-17 12:49           ` Wolfram Sang
2016-04-18  7:33             ` Geert Uytterhoeven
2016-04-26 10:18           ` Geert Uytterhoeven
2016-04-26 17:00             ` Wolfram Sang
2016-04-01 15:44 ` [PATCH v2 3/9] mmc: tmio: Add UHS-I mode support Wolfram Sang
2016-08-16 18:05   ` Geert Uytterhoeven
2016-08-16 19:55     ` Wolfram Sang
2016-08-16 20:21       ` Geert Uytterhoeven
2016-08-17 19:08     ` Wolfram Sang
2016-08-17 20:17       ` Geert Uytterhoeven
2016-08-18 18:41         ` Wolfram Sang
2016-08-23 12:34       ` Geert Uytterhoeven
2016-04-01 15:44 ` Wolfram Sang [this message]
2016-04-01 15:44 ` [PATCH v2 5/9] mmc: tmio: stop clock when 0Hz is requested Wolfram Sang
2016-04-01 15:44 ` [PATCH v2 6/9] mmc: host: add note that set_ios needs to handle 0Hz properly Wolfram Sang
2016-04-01 15:44 ` [PATCH v2 7/9] mmc: sh_mobile_sdhi: Add UHS-I mode support Wolfram Sang
2016-04-04 15:04   ` Ulf Hansson
2016-04-04 15:17     ` Wolfram Sang
2016-04-04 15:52       ` Ulf Hansson
2016-04-04 15:56         ` Wolfram Sang
2016-04-01 15:44 ` [PATCH v2 8/9] ARM: shmobile: r8a7790: Set maximum frequencies for SDHI clocks Wolfram Sang
2016-04-01 15:44 ` [PATCH v2 9/9] ARM: shmobile: r8a7790: lager: Enable UHS-I SDR-50 Wolfram Sang
2016-04-06  0:56   ` [v2,9/9] " Simon Horman
2016-04-06  6:38     ` Geert Uytterhoeven
2016-04-06  7:13       ` Simon Horman
2016-04-04 15:08 ` [PATCH v2 0/9] r8a7790: add UHS-I (SDR50) support to Lager Ulf Hansson
2016-04-04 15:21   ` Wolfram Sang
2016-04-05 11:12     ` Ulf Hansson
2016-04-05 11:19       ` Wolfram Sang
2016-04-06  0:56         ` Simon Horman

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=1459525479-20842-5-git-send-email-wsa@the-dreams.de \
    --to=wsa@the-dreams.de \
    --cc=ben.hutchings@codethink.co.uk \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.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.