From 64c6466115150ae2fb903992324a0bd512bc45cd Mon Sep 17 00:00:00 2001 From: Ziyuan Xu Date: Tue, 1 Sep 2020 15:41:41 +0800 Subject: [PATCH] mmc: dw_mmc: imporove thunder boot Make the hclk_mmc is available before accessing the registers. Signed-off-by: Ziyuan Xu Change-Id: I2ab1556eb2376c77d8e05a66eb64cb367c7919d3 --- drivers/mmc/host/dw_mmc.c | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 8b4128ee929b..649505c318df 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -3287,28 +3287,6 @@ int dw_mci_probe(struct dw_mci *host) int width, i, ret = 0; u32 fifo_size; -#ifdef CONFIG_ROCKCHIP_THUNDER_BOOT - struct device *dev = host->dev; - u32 intr; - - if (device_property_read_bool(host->dev, "supports-emmc")) { - if (readl_poll_timeout(host->regs + SDMMC_STATUS, - fifo_size, - !(fifo_size & (BIT(10) | GENMASK(7, 4))), - 0, 500 * USEC_PER_MSEC)) - dev_err(dev, "Controller is occupied!\n"); - - if (readl_poll_timeout(host->regs + SDMMC_IDSTS, - fifo_size, !(fifo_size & GENMASK(16, 13)), - 0, 500 * USEC_PER_MSEC)) - dev_err(dev, "DMA is still running!\n"); - - intr = mci_readl(host, RINTSTS); - if (intr & DW_MCI_CMD_ERROR_FLAGS || intr & DW_MCI_DATA_ERROR_FLAGS) - BUG_ON(1); - } -#endif - if (!host->pdata) { host->pdata = dw_mci_parse_dt(host); if (PTR_ERR(host->pdata) == -EPROBE_DEFER) { @@ -3329,6 +3307,22 @@ int dw_mci_probe(struct dw_mci *host) return ret; } } +#ifdef CONFIG_ROCKCHIP_THUNDER_BOOT + if (device_property_read_bool(host->dev, "supports-emmc")) { + if (readl_poll_timeout(host->regs + SDMMC_STATUS, + fifo_size, + !(fifo_size & (BIT(10) | GENMASK(7, 4))), + 0, 500 * USEC_PER_MSEC)) + dev_err(host->dev, "Controller is occupied!\n"); + + if (readl_poll_timeout(host->regs + SDMMC_IDSTS, + fifo_size, !(fifo_size & GENMASK(16, 13)), + 0, 500 * USEC_PER_MSEC)) + dev_err(host->dev, "DMA is still running!\n"); + + BUG_ON(mci_readl(host, RINTSTS) & DW_MCI_ERROR_FLAGS); + } +#endif host->ciu_clk = devm_clk_get(host->dev, "ciu"); if (IS_ERR(host->ciu_clk)) {