Commit 4eee86c3 authored by Heiner Kallweit's avatar Heiner Kallweit Committed by Ulf Hansson

mmc: meson-gx: switch to dynamic timeout values

Currently we use a fixed timeout of 4s for all data transfers. Switch
to dynamic timeout values by making use of data->timeout_ns.
Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: default avatarKevin Hilman <khilman@baylibre.com>
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent f016c676
...@@ -163,6 +163,18 @@ struct sd_emmc_desc { ...@@ -163,6 +163,18 @@ struct sd_emmc_desc {
#define CMD_RESP_MASK GENMASK(31, 1) #define CMD_RESP_MASK GENMASK(31, 1)
#define CMD_RESP_SRAM BIT(0) #define CMD_RESP_SRAM BIT(0)
static unsigned int meson_mmc_get_timeout_msecs(struct mmc_data *data)
{
unsigned int timeout = data->timeout_ns / NSEC_PER_MSEC;
if (!timeout)
return SD_EMMC_CMD_TIMEOUT_DATA;
timeout = roundup_pow_of_two(timeout);
return min(timeout, 32768U); /* max. 2^15 ms */
}
static int meson_mmc_clk_set(struct meson_host *host, unsigned long clk_rate) static int meson_mmc_clk_set(struct meson_host *host, unsigned long clk_rate)
{ {
struct mmc_host *mmc = host->mmc; struct mmc_host *mmc = host->mmc;
...@@ -441,7 +453,7 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd) ...@@ -441,7 +453,7 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd)
if (data) { if (data) {
cmd_cfg |= CMD_CFG_DATA_IO; cmd_cfg |= CMD_CFG_DATA_IO;
cmd_cfg |= FIELD_PREP(CMD_CFG_TIMEOUT_MASK, cmd_cfg |= FIELD_PREP(CMD_CFG_TIMEOUT_MASK,
ilog2(SD_EMMC_CMD_TIMEOUT_DATA)); ilog2(meson_mmc_get_timeout_msecs(data)));
if (data->blocks > 1) { if (data->blocks > 1) {
cmd_cfg |= CMD_CFG_BLOCK_MODE; cmd_cfg |= CMD_CFG_BLOCK_MODE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment