mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-06 13:16:22 +00:00
mmc: core: Simplify by adding mmc_execute_tuning()
For each MMC, SD and SDIO there is code that holds the clock, calls ops->execute_tuning, and releases the clock. Simplify the code a bit by providing a separate function to do that. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
This commit is contained in:
parent
fdb9de129e
commit
63e415c640
@ -1077,6 +1077,30 @@ void mmc_set_ungated(struct mmc_host *host)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int mmc_execute_tuning(struct mmc_card *card)
|
||||||
|
{
|
||||||
|
struct mmc_host *host = card->host;
|
||||||
|
u32 opcode;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
if (!host->ops->execute_tuning)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (mmc_card_mmc(card))
|
||||||
|
opcode = MMC_SEND_TUNING_BLOCK_HS200;
|
||||||
|
else
|
||||||
|
opcode = MMC_SEND_TUNING_BLOCK;
|
||||||
|
|
||||||
|
mmc_host_clk_hold(host);
|
||||||
|
err = host->ops->execute_tuning(host, opcode);
|
||||||
|
mmc_host_clk_release(host);
|
||||||
|
|
||||||
|
if (err)
|
||||||
|
pr_err("%s: tuning execution failed\n", mmc_hostname(host));
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Change the bus mode (open drain/push-pull) of a host.
|
* Change the bus mode (open drain/push-pull) of a host.
|
||||||
*/
|
*/
|
||||||
|
@ -86,5 +86,8 @@ void mmc_add_card_debugfs(struct mmc_card *card);
|
|||||||
void mmc_remove_card_debugfs(struct mmc_card *card);
|
void mmc_remove_card_debugfs(struct mmc_card *card);
|
||||||
|
|
||||||
void mmc_init_context_info(struct mmc_host *host);
|
void mmc_init_context_info(struct mmc_host *host);
|
||||||
|
|
||||||
|
int mmc_execute_tuning(struct mmc_card *card);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1162,7 +1162,6 @@ static int mmc_select_timing(struct mmc_card *card)
|
|||||||
static int mmc_hs200_tuning(struct mmc_card *card)
|
static int mmc_hs200_tuning(struct mmc_card *card)
|
||||||
{
|
{
|
||||||
struct mmc_host *host = card->host;
|
struct mmc_host *host = card->host;
|
||||||
int err = 0;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Timing should be adjusted to the HS400 target
|
* Timing should be adjusted to the HS400 target
|
||||||
@ -1173,18 +1172,7 @@ static int mmc_hs200_tuning(struct mmc_card *card)
|
|||||||
if (host->ops->prepare_hs400_tuning)
|
if (host->ops->prepare_hs400_tuning)
|
||||||
host->ops->prepare_hs400_tuning(host, &host->ios);
|
host->ops->prepare_hs400_tuning(host, &host->ios);
|
||||||
|
|
||||||
if (host->ops->execute_tuning) {
|
return mmc_execute_tuning(card);
|
||||||
mmc_host_clk_hold(host);
|
|
||||||
err = host->ops->execute_tuning(host,
|
|
||||||
MMC_SEND_TUNING_BLOCK_HS200);
|
|
||||||
mmc_host_clk_release(host);
|
|
||||||
|
|
||||||
if (err)
|
|
||||||
pr_err("%s: tuning execution failed\n",
|
|
||||||
mmc_hostname(host));
|
|
||||||
}
|
|
||||||
|
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -660,15 +660,10 @@ static int mmc_sd_init_uhs_card(struct mmc_card *card)
|
|||||||
* SPI mode doesn't define CMD19 and tuning is only valid for SDR50 and
|
* SPI mode doesn't define CMD19 and tuning is only valid for SDR50 and
|
||||||
* SDR104 mode SD-cards. Note that tuning is mandatory for SDR104.
|
* SDR104 mode SD-cards. Note that tuning is mandatory for SDR104.
|
||||||
*/
|
*/
|
||||||
if (!mmc_host_is_spi(card->host) && card->host->ops->execute_tuning &&
|
if (!mmc_host_is_spi(card->host) &&
|
||||||
(card->sd_bus_speed == UHS_SDR50_BUS_SPEED ||
|
(card->sd_bus_speed == UHS_SDR50_BUS_SPEED ||
|
||||||
card->sd_bus_speed == UHS_SDR104_BUS_SPEED)) {
|
card->sd_bus_speed == UHS_SDR104_BUS_SPEED))
|
||||||
mmc_host_clk_hold(card->host);
|
err = mmc_execute_tuning(card);
|
||||||
err = card->host->ops->execute_tuning(card->host,
|
|
||||||
MMC_SEND_TUNING_BLOCK);
|
|
||||||
mmc_host_clk_release(card->host);
|
|
||||||
}
|
|
||||||
|
|
||||||
out:
|
out:
|
||||||
kfree(status);
|
kfree(status);
|
||||||
|
|
||||||
|
@ -567,17 +567,11 @@ static int mmc_sdio_init_uhs_card(struct mmc_card *card)
|
|||||||
* SPI mode doesn't define CMD19 and tuning is only valid for SDR50 and
|
* SPI mode doesn't define CMD19 and tuning is only valid for SDR50 and
|
||||||
* SDR104 mode SD-cards. Note that tuning is mandatory for SDR104.
|
* SDR104 mode SD-cards. Note that tuning is mandatory for SDR104.
|
||||||
*/
|
*/
|
||||||
if (!mmc_host_is_spi(card->host) && card->host->ops->execute_tuning &&
|
if (!mmc_host_is_spi(card->host) &&
|
||||||
((card->sw_caps.sd3_bus_mode & SD_MODE_UHS_SDR50) ||
|
((card->sw_caps.sd3_bus_mode & SD_MODE_UHS_SDR50) ||
|
||||||
(card->sw_caps.sd3_bus_mode & SD_MODE_UHS_SDR104))) {
|
(card->sw_caps.sd3_bus_mode & SD_MODE_UHS_SDR104)))
|
||||||
mmc_host_clk_hold(card->host);
|
err = mmc_execute_tuning(card);
|
||||||
err = card->host->ops->execute_tuning(card->host,
|
|
||||||
MMC_SEND_TUNING_BLOCK);
|
|
||||||
mmc_host_clk_release(card->host);
|
|
||||||
}
|
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user