Commit d6786fef authored by Guodong Xu's avatar Guodong Xu Committed by Ulf Hansson

mmc: dw_mmc: add reset support to dwmmc host controller

Dwmmc host controller may in unknown state when entering kernel boot. One
example is when booting from eMMC, bootloader need initialize MMC host
controller into some state so it can read. In order to make sure MMC host
controller in a clean initial state, this reset support is added.

With this patch, a 'resets' property can be added into dw_mmc device
tree node. The hardware logic is: dwmmc host controller IP receives a reset
signal from a 'reset provider' (eg. power management unit). The 'resets'
property points to this reset signal. So, during dwmmc driver probe,
it can use this signal to reset itself.

Refer to [1] for more information.

[1] Documentation/devicetree/bindings/reset/reset.txt
Signed-off-by: default avatarGuodong Xu <guodong.xu@linaro.org>
Signed-off-by: default avatarXinwei Kong <kong.kongxinwei@hisilicon.com>
Signed-off-by: default avatarZhangfei Gao <zhangfei.gao@linaro.org>
Reviewed-by: default avatarShawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: default avatarJaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent fdc22b6b
...@@ -2876,6 +2876,13 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host) ...@@ -2876,6 +2876,13 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host)
if (!pdata) if (!pdata)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
/* find reset controller when exist */
pdata->rstc = devm_reset_control_get_optional(dev, NULL);
if (IS_ERR(pdata->rstc)) {
if (PTR_ERR(pdata->rstc) == -EPROBE_DEFER)
return ERR_PTR(-EPROBE_DEFER);
}
/* find out number of slots supported */ /* find out number of slots supported */
of_property_read_u32(np, "num-slots", &pdata->num_slots); of_property_read_u32(np, "num-slots", &pdata->num_slots);
...@@ -2947,7 +2954,9 @@ int dw_mci_probe(struct dw_mci *host) ...@@ -2947,7 +2954,9 @@ int dw_mci_probe(struct dw_mci *host)
if (!host->pdata) { if (!host->pdata) {
host->pdata = dw_mci_parse_dt(host); host->pdata = dw_mci_parse_dt(host);
if (IS_ERR(host->pdata)) { if (PTR_ERR(host->pdata) == -EPROBE_DEFER) {
return -EPROBE_DEFER;
} else if (IS_ERR(host->pdata)) {
dev_err(host->dev, "platform data not available\n"); dev_err(host->dev, "platform data not available\n");
return -EINVAL; return -EINVAL;
} }
...@@ -3001,6 +3010,12 @@ int dw_mci_probe(struct dw_mci *host) ...@@ -3001,6 +3010,12 @@ int dw_mci_probe(struct dw_mci *host)
} }
} }
if (!IS_ERR(host->pdata->rstc)) {
reset_control_assert(host->pdata->rstc);
usleep_range(10, 50);
reset_control_deassert(host->pdata->rstc);
}
setup_timer(&host->cmd11_timer, setup_timer(&host->cmd11_timer,
dw_mci_cmd11_timer, (unsigned long)host); dw_mci_cmd11_timer, (unsigned long)host);
...@@ -3150,6 +3165,9 @@ int dw_mci_probe(struct dw_mci *host) ...@@ -3150,6 +3165,9 @@ int dw_mci_probe(struct dw_mci *host)
if (host->use_dma && host->dma_ops->exit) if (host->use_dma && host->dma_ops->exit)
host->dma_ops->exit(host); host->dma_ops->exit(host);
if (!IS_ERR(host->pdata->rstc))
reset_control_assert(host->pdata->rstc);
err_clk_ciu: err_clk_ciu:
clk_disable_unprepare(host->ciu_clk); clk_disable_unprepare(host->ciu_clk);
...@@ -3180,6 +3198,9 @@ void dw_mci_remove(struct dw_mci *host) ...@@ -3180,6 +3198,9 @@ void dw_mci_remove(struct dw_mci *host)
if (host->use_dma && host->dma_ops->exit) if (host->use_dma && host->dma_ops->exit)
host->dma_ops->exit(host); host->dma_ops->exit(host);
if (!IS_ERR(host->pdata->rstc))
reset_control_assert(host->pdata->rstc);
clk_disable_unprepare(host->ciu_clk); clk_disable_unprepare(host->ciu_clk);
clk_disable_unprepare(host->biu_clk); clk_disable_unprepare(host->biu_clk);
} }
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <linux/scatterlist.h> #include <linux/scatterlist.h>
#include <linux/mmc/core.h> #include <linux/mmc/core.h>
#include <linux/dmaengine.h> #include <linux/dmaengine.h>
#include <linux/reset.h>
#define MAX_MCI_SLOTS 2 #define MAX_MCI_SLOTS 2
...@@ -259,6 +260,7 @@ struct dw_mci_board { ...@@ -259,6 +260,7 @@ struct dw_mci_board {
/* delay in mS before detecting cards after interrupt */ /* delay in mS before detecting cards after interrupt */
u32 detect_delay_ms; u32 detect_delay_ms;
struct reset_control *rstc;
struct dw_mci_dma_ops *dma_ops; struct dw_mci_dma_ops *dma_ops;
struct dma_pdata *data; struct dma_pdata *data;
}; };
......
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