Skip to content

Commit

Permalink
mmc: sdhi: fill in actual_clock
Browse files Browse the repository at this point in the history
Save set clock in mmc_host actual_clock enabling exporting it via debugfs.
This will indicate the precise SD clock in I/O settings rather than only the
sometimes misleading requested clock.

Signed-off-by: Tamás Szűcs <tszucs@protonmail.ch>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
  • Loading branch information
Tamás Szűcs authored and Ulf Hansson committed Sep 11, 2019
1 parent 38eee2e commit 75eaf49
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions drivers/mmc/host/renesas_sdhi_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ static unsigned int renesas_sdhi_clk_update(struct tmio_mmc_host *host,
{
struct renesas_sdhi *priv = host_to_priv(host);
unsigned int freq, diff, best_freq = 0, diff_min = ~0;
int i, ret;
int i;

/* tested only on R-Car Gen2+ currently; may work for others */
if (!(host->pdata->flags & TMIO_MMC_MIN_RCAR2))
Expand Down Expand Up @@ -153,9 +153,9 @@ static unsigned int renesas_sdhi_clk_update(struct tmio_mmc_host *host,
}
}

ret = clk_set_rate(priv->clk, best_freq);
clk_set_rate(priv->clk, best_freq);

return ret == 0 ? best_freq : clk_get_rate(priv->clk);
return clk_get_rate(priv->clk);
}

static void renesas_sdhi_set_clock(struct tmio_mmc_host *host,
Expand All @@ -166,10 +166,13 @@ static void renesas_sdhi_set_clock(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));

if (new_clock == 0)
if (new_clock == 0) {
host->mmc->actual_clock = 0;
goto out;
}

clock = renesas_sdhi_clk_update(host, new_clock) / 512;
host->mmc->actual_clock = renesas_sdhi_clk_update(host, new_clock);
clock = host->mmc->actual_clock / 512;

for (clk = 0x80000080; new_clock >= (clock << 1); clk >>= 1)
clock <<= 1;
Expand Down

0 comments on commit 75eaf49

Please sign in to comment.