Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 148634d2 authored by Wolfram Sang's avatar Wolfram Sang Committed by Ulf Hansson
Browse files

mmc: tmio: stop clock when 0Hz is requested



Setting frequency to 0 is not enough, the clock explicitly has to be
disabled. Otherwise voltage switching (which needs SDCLK to be quiet)
fails for various cards.

Because we now do the 'new_clock == 0' check right at the beginning,
the indentation level of the rest of the code can be decreased a little.

Signed-off-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent 7fbc030d
Loading
Loading
Loading
Loading
+26 −24
Original line number Diff line number Diff line
@@ -166,12 +166,28 @@ static void tmio_mmc_clk_start(struct tmio_mmc_host *host)
	}
}

static void tmio_mmc_clk_stop(struct tmio_mmc_host *host)
{
	if (host->pdata->flags & TMIO_MMC_HAVE_HIGH_REG) {
		sd_ctrl_write16(host, CTL_CLK_AND_WAIT_CTL, 0x0000);
		msleep(10);
	}

	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 ? 5 : 10);
}

static void tmio_mmc_set_clock(struct tmio_mmc_host *host,
				unsigned int new_clock)
{
	u32 clk = 0, clock;

	if (new_clock) {
	if (new_clock == 0) {
		tmio_mmc_clk_stop(host);
		return;
	}

	if (host->clk_update)
		clock = host->clk_update(host, new_clock) / 512;
	else
@@ -181,10 +197,8 @@ static void tmio_mmc_set_clock(struct tmio_mmc_host *host,
		clock <<= 1;

	/* 1/1 clock is option */
		if ((host->pdata->flags & TMIO_MMC_CLK_ACTUAL) &&
		   ((clk >> 22) & 0x1))
	if ((host->pdata->flags & TMIO_MMC_CLK_ACTUAL) && ((clk >> 22) & 0x1))
		clk |= 0xff;
	}

	if (host->set_clk_div)
		host->set_clk_div(host->pdev, (clk >> 22) & 1);
@@ -198,18 +212,6 @@ static void tmio_mmc_set_clock(struct tmio_mmc_host *host,
	tmio_mmc_clk_start(host);
}

static void tmio_mmc_clk_stop(struct tmio_mmc_host *host)
{
	if (host->pdata->flags & TMIO_MMC_HAVE_HIGH_REG) {
		sd_ctrl_write16(host, CTL_CLK_AND_WAIT_CTL, 0x0000);
		msleep(10);
	}

	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 ? 5 : 10);
}

static void tmio_mmc_reset(struct tmio_mmc_host *host)
{
	/* FIXME - should we set stop clock reg here */