summaryrefslogtreecommitdiffstats
path: root/drivers/mmc/host/meson-gx-mmc.c
diff options
context:
space:
mode:
authorHeiner Kallweit <hkallweit1@gmail.com>2017-03-25 11:26:18 +0100
committerUlf Hansson <ulf.hansson@linaro.org>2017-04-24 21:41:50 +0200
commit4eee86c3d825109ed91555a553fbdb927592f009 (patch)
tree658143fc6807ee7aadbb00ed717e46dc1aa98477 /drivers/mmc/host/meson-gx-mmc.c
parentf016c67629c818ca6a39f4d6e35d85d9e930eacc (diff)
downloadblackbird-op-linux-4eee86c3d825109ed91555a553fbdb927592f009.tar.gz
blackbird-op-linux-4eee86c3d825109ed91555a553fbdb927592f009.zip
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: Heiner Kallweit <hkallweit1@gmail.com> Reviewed-by: Kevin Hilman <khilman@baylibre.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Diffstat (limited to 'drivers/mmc/host/meson-gx-mmc.c')
-rw-r--r--drivers/mmc/host/meson-gx-mmc.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c
index 0a0f5008940b..810b68d5067b 100644
--- a/drivers/mmc/host/meson-gx-mmc.c
+++ b/drivers/mmc/host/meson-gx-mmc.c
@@ -163,6 +163,18 @@ struct sd_emmc_desc {
#define CMD_RESP_MASK GENMASK(31, 1)
#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)
{
struct mmc_host *mmc = host->mmc;
@@ -441,7 +453,7 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd)
if (data) {
cmd_cfg |= CMD_CFG_DATA_IO;
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) {
cmd_cfg |= CMD_CFG_BLOCK_MODE;
OpenPOWER on IntegriCloud