* [PATCH v4 0/2] mmc: dw_mmc: host controller reset support @ 2016-08-10 8:03 ` Guodong Xu 0 siblings, 0 replies; 19+ messages in thread From: Guodong Xu @ 2016-08-10 8:03 UTC (permalink / raw) To: heiko, shawn.lin, jh80.chung, robh+dt, mark.rutland, ulf.hansson, guodong.xu Cc: devicetree, linux-kernel, linux-arm-kernel, linux-mmc mmc host controller registers may in abnormal state if mmc is used in bootloader, eg. to load kernel from eMMC. Some controllers cann't clear their registers when clk is set. They use dedicated reset logics to do this. In this patch, a 'resets' property is added into dw_mmc dts node. When driver does parse_dt and probe, it calls reset API to triiger 'reset' of dwmmc host controller. When probe error or remove, it calls reset API to assert it. Chip vendor's actual reset logics is implemented in reset driver, not in dw_mmc code. Please also refer to Documentation/devicetree/bindings/reset/reset.txt Changelog: v4: * add reset_control_assert() and usleep() before calling _deassert(). Guodong Xu (2): Documentation: synopsys-dw-mshc: add binding for resets mmc: dw_mmc: add reset support to dwmmc host controller .../devicetree/bindings/mmc/synopsys-dw-mshc.txt | 4 ++++ drivers/mmc/host/dw_mmc.c | 23 +++++++++++++++++++++- include/linux/mmc/dw_mmc.h | 2 ++ 3 files changed, 28 insertions(+), 1 deletion(-) -- 1.9.1 ^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v4 0/2] mmc: dw_mmc: host controller reset support @ 2016-08-10 8:03 ` Guodong Xu 0 siblings, 0 replies; 19+ messages in thread From: Guodong Xu @ 2016-08-10 8:03 UTC (permalink / raw) To: linux-arm-kernel mmc host controller registers may in abnormal state if mmc is used in bootloader, eg. to load kernel from eMMC. Some controllers cann't clear their registers when clk is set. They use dedicated reset logics to do this. In this patch, a 'resets' property is added into dw_mmc dts node. When driver does parse_dt and probe, it calls reset API to triiger 'reset' of dwmmc host controller. When probe error or remove, it calls reset API to assert it. Chip vendor's actual reset logics is implemented in reset driver, not in dw_mmc code. Please also refer to Documentation/devicetree/bindings/reset/reset.txt Changelog: v4: * add reset_control_assert() and usleep() before calling _deassert(). Guodong Xu (2): Documentation: synopsys-dw-mshc: add binding for resets mmc: dw_mmc: add reset support to dwmmc host controller .../devicetree/bindings/mmc/synopsys-dw-mshc.txt | 4 ++++ drivers/mmc/host/dw_mmc.c | 23 +++++++++++++++++++++- include/linux/mmc/dw_mmc.h | 2 ++ 3 files changed, 28 insertions(+), 1 deletion(-) -- 1.9.1 ^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v4 0/2] mmc: dw_mmc: host controller reset support @ 2016-08-10 8:03 ` Guodong Xu 0 siblings, 0 replies; 19+ messages in thread From: Guodong Xu @ 2016-08-10 8:03 UTC (permalink / raw) To: heiko, shawn.lin, jh80.chung, robh+dt, mark.rutland, ulf.hansson, guodong.xu Cc: devicetree, linux-mmc, linux-kernel, linux-arm-kernel mmc host controller registers may in abnormal state if mmc is used in bootloader, eg. to load kernel from eMMC. Some controllers cann't clear their registers when clk is set. They use dedicated reset logics to do this. In this patch, a 'resets' property is added into dw_mmc dts node. When driver does parse_dt and probe, it calls reset API to triiger 'reset' of dwmmc host controller. When probe error or remove, it calls reset API to assert it. Chip vendor's actual reset logics is implemented in reset driver, not in dw_mmc code. Please also refer to Documentation/devicetree/bindings/reset/reset.txt Changelog: v4: * add reset_control_assert() and usleep() before calling _deassert(). Guodong Xu (2): Documentation: synopsys-dw-mshc: add binding for resets mmc: dw_mmc: add reset support to dwmmc host controller .../devicetree/bindings/mmc/synopsys-dw-mshc.txt | 4 ++++ drivers/mmc/host/dw_mmc.c | 23 +++++++++++++++++++++- include/linux/mmc/dw_mmc.h | 2 ++ 3 files changed, 28 insertions(+), 1 deletion(-) -- 1.9.1 ^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v4 1/2] Documentation: synopsys-dw-mshc: add binding for resets 2016-08-10 8:03 ` Guodong Xu (?) @ 2016-08-10 8:03 ` Guodong Xu -1 siblings, 0 replies; 19+ messages in thread From: Guodong Xu @ 2016-08-10 8:03 UTC (permalink / raw) To: heiko, shawn.lin, jh80.chung, robh+dt, mark.rutland, ulf.hansson, guodong.xu Cc: devicetree, linux-kernel, linux-arm-kernel, linux-mmc Add resets property to synopsys-dw-mshc bindings. It is intended to represent the hardware reset signal present internally in some host controller IC designs. See Documentation/devicetree/bindings/reset/reset.txt for details. Signed-off-by: Guodong Xu <guodong.xu@linaro.org> Acked-by: Rob Herring <robh@kernel.org> --- Documentation/devicetree/bindings/mmc/synopsys-dw-mshc.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/mmc/synopsys-dw-mshc.txt b/Documentation/devicetree/bindings/mmc/synopsys-dw-mshc.txt index 8636f5a..4e00e85 100644 --- a/Documentation/devicetree/bindings/mmc/synopsys-dw-mshc.txt +++ b/Documentation/devicetree/bindings/mmc/synopsys-dw-mshc.txt @@ -39,6 +39,10 @@ Required Properties: Optional properties: +* resets: phandle + reset specifier pair, intended to represent hardware + reset signal present internally in some host controller IC designs. + See Documentation/devicetree/bindings/reset/reset.txt for details. + * clocks: from common clock binding: handle to biu and ciu clocks for the bus interface unit clock and the card interface unit clock. -- 1.9.1 ^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v4 1/2] Documentation: synopsys-dw-mshc: add binding for resets @ 2016-08-10 8:03 ` Guodong Xu 0 siblings, 0 replies; 19+ messages in thread From: Guodong Xu @ 2016-08-10 8:03 UTC (permalink / raw) To: linux-arm-kernel Add resets property to synopsys-dw-mshc bindings. It is intended to represent the hardware reset signal present internally in some host controller IC designs. See Documentation/devicetree/bindings/reset/reset.txt for details. Signed-off-by: Guodong Xu <guodong.xu@linaro.org> Acked-by: Rob Herring <robh@kernel.org> --- Documentation/devicetree/bindings/mmc/synopsys-dw-mshc.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/mmc/synopsys-dw-mshc.txt b/Documentation/devicetree/bindings/mmc/synopsys-dw-mshc.txt index 8636f5a..4e00e85 100644 --- a/Documentation/devicetree/bindings/mmc/synopsys-dw-mshc.txt +++ b/Documentation/devicetree/bindings/mmc/synopsys-dw-mshc.txt @@ -39,6 +39,10 @@ Required Properties: Optional properties: +* resets: phandle + reset specifier pair, intended to represent hardware + reset signal present internally in some host controller IC designs. + See Documentation/devicetree/bindings/reset/reset.txt for details. + * clocks: from common clock binding: handle to biu and ciu clocks for the bus interface unit clock and the card interface unit clock. -- 1.9.1 ^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v4 1/2] Documentation: synopsys-dw-mshc: add binding for resets @ 2016-08-10 8:03 ` Guodong Xu 0 siblings, 0 replies; 19+ messages in thread From: Guodong Xu @ 2016-08-10 8:03 UTC (permalink / raw) To: heiko, shawn.lin, jh80.chung, robh+dt, mark.rutland, ulf.hansson, guodong.xu Cc: devicetree, linux-mmc, linux-kernel, linux-arm-kernel Add resets property to synopsys-dw-mshc bindings. It is intended to represent the hardware reset signal present internally in some host controller IC designs. See Documentation/devicetree/bindings/reset/reset.txt for details. Signed-off-by: Guodong Xu <guodong.xu@linaro.org> Acked-by: Rob Herring <robh@kernel.org> --- Documentation/devicetree/bindings/mmc/synopsys-dw-mshc.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/mmc/synopsys-dw-mshc.txt b/Documentation/devicetree/bindings/mmc/synopsys-dw-mshc.txt index 8636f5a..4e00e85 100644 --- a/Documentation/devicetree/bindings/mmc/synopsys-dw-mshc.txt +++ b/Documentation/devicetree/bindings/mmc/synopsys-dw-mshc.txt @@ -39,6 +39,10 @@ Required Properties: Optional properties: +* resets: phandle + reset specifier pair, intended to represent hardware + reset signal present internally in some host controller IC designs. + See Documentation/devicetree/bindings/reset/reset.txt for details. + * clocks: from common clock binding: handle to biu and ciu clocks for the bus interface unit clock and the card interface unit clock. -- 1.9.1 ^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH v4 1/2] Documentation: synopsys-dw-mshc: add binding for resets 2016-08-10 8:03 ` Guodong Xu (?) @ 2016-08-11 2:18 ` Shawn Lin -1 siblings, 0 replies; 19+ messages in thread From: Shawn Lin @ 2016-08-11 2:18 UTC (permalink / raw) To: Guodong Xu, heiko, shawn.lin, jh80.chung, robh+dt, mark.rutland, ulf.hansson Cc: shawn.lin, devicetree, linux-kernel, linux-arm-kernel, linux-mmc 在 2016/8/10 16:03, Guodong Xu 写道: > Add resets property to synopsys-dw-mshc bindings. It is intended to > represent the hardware reset signal present internally in some host > controller IC designs. > > See Documentation/devicetree/bindings/reset/reset.txt for details. > > Signed-off-by: Guodong Xu <guodong.xu@linaro.org> > Acked-by: Rob Herring <robh@kernel.org> > --- > Documentation/devicetree/bindings/mmc/synopsys-dw-mshc.txt | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/Documentation/devicetree/bindings/mmc/synopsys-dw-mshc.txt b/Documentation/devicetree/bindings/mmc/synopsys-dw-mshc.txt > index 8636f5a..4e00e85 100644 > --- a/Documentation/devicetree/bindings/mmc/synopsys-dw-mshc.txt > +++ b/Documentation/devicetree/bindings/mmc/synopsys-dw-mshc.txt > @@ -39,6 +39,10 @@ Required Properties: > > Optional properties: > > +* resets: phandle + reset specifier pair, intended to represent hardware > + reset signal present internally in some host controller IC designs. > + See Documentation/devicetree/bindings/reset/reset.txt for details. > + > * clocks: from common clock binding: handle to biu and ciu clocks for the > bus interface unit clock and the card interface unit clock. > > Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com> -- Best Regards Shawn Lin ^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v4 1/2] Documentation: synopsys-dw-mshc: add binding for resets @ 2016-08-11 2:18 ` Shawn Lin 0 siblings, 0 replies; 19+ messages in thread From: Shawn Lin @ 2016-08-11 2:18 UTC (permalink / raw) To: linux-arm-kernel ? 2016/8/10 16:03, Guodong Xu ??: > Add resets property to synopsys-dw-mshc bindings. It is intended to > represent the hardware reset signal present internally in some host > controller IC designs. > > See Documentation/devicetree/bindings/reset/reset.txt for details. > > Signed-off-by: Guodong Xu <guodong.xu@linaro.org> > Acked-by: Rob Herring <robh@kernel.org> > --- > Documentation/devicetree/bindings/mmc/synopsys-dw-mshc.txt | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/Documentation/devicetree/bindings/mmc/synopsys-dw-mshc.txt b/Documentation/devicetree/bindings/mmc/synopsys-dw-mshc.txt > index 8636f5a..4e00e85 100644 > --- a/Documentation/devicetree/bindings/mmc/synopsys-dw-mshc.txt > +++ b/Documentation/devicetree/bindings/mmc/synopsys-dw-mshc.txt > @@ -39,6 +39,10 @@ Required Properties: > > Optional properties: > > +* resets: phandle + reset specifier pair, intended to represent hardware > + reset signal present internally in some host controller IC designs. > + See Documentation/devicetree/bindings/reset/reset.txt for details. > + > * clocks: from common clock binding: handle to biu and ciu clocks for the > bus interface unit clock and the card interface unit clock. > > Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com> -- Best Regards Shawn Lin ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v4 1/2] Documentation: synopsys-dw-mshc: add binding for resets @ 2016-08-11 2:18 ` Shawn Lin 0 siblings, 0 replies; 19+ messages in thread From: Shawn Lin @ 2016-08-11 2:18 UTC (permalink / raw) To: Guodong Xu, heiko, jh80.chung, robh+dt, mark.rutland, ulf.hansson Cc: shawn.lin, devicetree, linux-kernel, linux-arm-kernel, linux-mmc 在 2016/8/10 16:03, Guodong Xu 写道: > Add resets property to synopsys-dw-mshc bindings. It is intended to > represent the hardware reset signal present internally in some host > controller IC designs. > > See Documentation/devicetree/bindings/reset/reset.txt for details. > > Signed-off-by: Guodong Xu <guodong.xu@linaro.org> > Acked-by: Rob Herring <robh@kernel.org> > --- > Documentation/devicetree/bindings/mmc/synopsys-dw-mshc.txt | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/Documentation/devicetree/bindings/mmc/synopsys-dw-mshc.txt b/Documentation/devicetree/bindings/mmc/synopsys-dw-mshc.txt > index 8636f5a..4e00e85 100644 > --- a/Documentation/devicetree/bindings/mmc/synopsys-dw-mshc.txt > +++ b/Documentation/devicetree/bindings/mmc/synopsys-dw-mshc.txt > @@ -39,6 +39,10 @@ Required Properties: > > Optional properties: > > +* resets: phandle + reset specifier pair, intended to represent hardware > + reset signal present internally in some host controller IC designs. > + See Documentation/devicetree/bindings/reset/reset.txt for details. > + > * clocks: from common clock binding: handle to biu and ciu clocks for the > bus interface unit clock and the card interface unit clock. > > Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com> -- Best Regards Shawn Lin ^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v4 2/2] mmc: dw_mmc: add reset support to dwmmc host controller 2016-08-10 8:03 ` Guodong Xu (?) @ 2016-08-10 8:03 ` Guodong Xu -1 siblings, 0 replies; 19+ messages in thread From: Guodong Xu @ 2016-08-10 8:03 UTC (permalink / raw) To: heiko, shawn.lin, jh80.chung, robh+dt, mark.rutland, ulf.hansson, guodong.xu Cc: devicetree, linux-kernel, linux-arm-kernel, linux-mmc, Xinwei Kong, Zhangfei Gao 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: Guodong Xu <guodong.xu@linaro.org> Signed-off-by: Xinwei Kong <kong.kongxinwei@hisilicon.com> Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org> --- drivers/mmc/host/dw_mmc.c | 23 ++++++++++++++++++++++- include/linux/mmc/dw_mmc.h | 2 ++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 32380d5..481d441 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -2915,6 +2915,13 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host) if (!pdata) 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 */ of_property_read_u32(np, "num-slots", &pdata->num_slots); @@ -2986,7 +2993,9 @@ int dw_mci_probe(struct dw_mci *host) if (!host->pdata) { 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"); return -EINVAL; } @@ -3040,6 +3049,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, dw_mci_cmd11_timer, (unsigned long)host); @@ -3189,6 +3204,9 @@ err_dmaunmap: if (host->use_dma && host->dma_ops->exit) host->dma_ops->exit(host); + if (!IS_ERR(host->pdata->rstc)) + reset_control_assert(host->pdata->rstc); + err_clk_ciu: if (!IS_ERR(host->ciu_clk)) clk_disable_unprepare(host->ciu_clk); @@ -3221,6 +3239,9 @@ void dw_mci_remove(struct dw_mci *host) if (host->use_dma && host->dma_ops->exit) host->dma_ops->exit(host); + if (!IS_ERR(host->pdata->rstc)) + reset_control_assert(host->pdata->rstc); + if (!IS_ERR(host->ciu_clk)) clk_disable_unprepare(host->ciu_clk); diff --git a/include/linux/mmc/dw_mmc.h b/include/linux/mmc/dw_mmc.h index 83b0edfc..f5af2bd 100644 --- a/include/linux/mmc/dw_mmc.h +++ b/include/linux/mmc/dw_mmc.h @@ -17,6 +17,7 @@ #include <linux/scatterlist.h> #include <linux/mmc/core.h> #include <linux/dmaengine.h> +#include <linux/reset.h> #define MAX_MCI_SLOTS 2 @@ -259,6 +260,7 @@ struct dw_mci_board { /* delay in mS before detecting cards after interrupt */ u32 detect_delay_ms; + struct reset_control *rstc; struct dw_mci_dma_ops *dma_ops; struct dma_pdata *data; }; -- 1.9.1 ^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v4 2/2] mmc: dw_mmc: add reset support to dwmmc host controller @ 2016-08-10 8:03 ` Guodong Xu 0 siblings, 0 replies; 19+ messages in thread From: Guodong Xu @ 2016-08-10 8:03 UTC (permalink / raw) To: linux-arm-kernel 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: Guodong Xu <guodong.xu@linaro.org> Signed-off-by: Xinwei Kong <kong.kongxinwei@hisilicon.com> Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org> --- drivers/mmc/host/dw_mmc.c | 23 ++++++++++++++++++++++- include/linux/mmc/dw_mmc.h | 2 ++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 32380d5..481d441 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -2915,6 +2915,13 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host) if (!pdata) 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 */ of_property_read_u32(np, "num-slots", &pdata->num_slots); @@ -2986,7 +2993,9 @@ int dw_mci_probe(struct dw_mci *host) if (!host->pdata) { 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"); return -EINVAL; } @@ -3040,6 +3049,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, dw_mci_cmd11_timer, (unsigned long)host); @@ -3189,6 +3204,9 @@ err_dmaunmap: if (host->use_dma && host->dma_ops->exit) host->dma_ops->exit(host); + if (!IS_ERR(host->pdata->rstc)) + reset_control_assert(host->pdata->rstc); + err_clk_ciu: if (!IS_ERR(host->ciu_clk)) clk_disable_unprepare(host->ciu_clk); @@ -3221,6 +3239,9 @@ void dw_mci_remove(struct dw_mci *host) if (host->use_dma && host->dma_ops->exit) host->dma_ops->exit(host); + if (!IS_ERR(host->pdata->rstc)) + reset_control_assert(host->pdata->rstc); + if (!IS_ERR(host->ciu_clk)) clk_disable_unprepare(host->ciu_clk); diff --git a/include/linux/mmc/dw_mmc.h b/include/linux/mmc/dw_mmc.h index 83b0edfc..f5af2bd 100644 --- a/include/linux/mmc/dw_mmc.h +++ b/include/linux/mmc/dw_mmc.h @@ -17,6 +17,7 @@ #include <linux/scatterlist.h> #include <linux/mmc/core.h> #include <linux/dmaengine.h> +#include <linux/reset.h> #define MAX_MCI_SLOTS 2 @@ -259,6 +260,7 @@ struct dw_mci_board { /* delay in mS before detecting cards after interrupt */ u32 detect_delay_ms; + struct reset_control *rstc; struct dw_mci_dma_ops *dma_ops; struct dma_pdata *data; }; -- 1.9.1 ^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v4 2/2] mmc: dw_mmc: add reset support to dwmmc host controller @ 2016-08-10 8:03 ` Guodong Xu 0 siblings, 0 replies; 19+ messages in thread From: Guodong Xu @ 2016-08-10 8:03 UTC (permalink / raw) To: heiko, shawn.lin, jh80.chung, robh+dt, mark.rutland, ulf.hansson, guodong.xu Cc: devicetree, linux-mmc, linux-kernel, Xinwei Kong, Zhangfei Gao, linux-arm-kernel 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: Guodong Xu <guodong.xu@linaro.org> Signed-off-by: Xinwei Kong <kong.kongxinwei@hisilicon.com> Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org> --- drivers/mmc/host/dw_mmc.c | 23 ++++++++++++++++++++++- include/linux/mmc/dw_mmc.h | 2 ++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 32380d5..481d441 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -2915,6 +2915,13 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host) if (!pdata) 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 */ of_property_read_u32(np, "num-slots", &pdata->num_slots); @@ -2986,7 +2993,9 @@ int dw_mci_probe(struct dw_mci *host) if (!host->pdata) { 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"); return -EINVAL; } @@ -3040,6 +3049,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, dw_mci_cmd11_timer, (unsigned long)host); @@ -3189,6 +3204,9 @@ err_dmaunmap: if (host->use_dma && host->dma_ops->exit) host->dma_ops->exit(host); + if (!IS_ERR(host->pdata->rstc)) + reset_control_assert(host->pdata->rstc); + err_clk_ciu: if (!IS_ERR(host->ciu_clk)) clk_disable_unprepare(host->ciu_clk); @@ -3221,6 +3239,9 @@ void dw_mci_remove(struct dw_mci *host) if (host->use_dma && host->dma_ops->exit) host->dma_ops->exit(host); + if (!IS_ERR(host->pdata->rstc)) + reset_control_assert(host->pdata->rstc); + if (!IS_ERR(host->ciu_clk)) clk_disable_unprepare(host->ciu_clk); diff --git a/include/linux/mmc/dw_mmc.h b/include/linux/mmc/dw_mmc.h index 83b0edfc..f5af2bd 100644 --- a/include/linux/mmc/dw_mmc.h +++ b/include/linux/mmc/dw_mmc.h @@ -17,6 +17,7 @@ #include <linux/scatterlist.h> #include <linux/mmc/core.h> #include <linux/dmaengine.h> +#include <linux/reset.h> #define MAX_MCI_SLOTS 2 @@ -259,6 +260,7 @@ struct dw_mci_board { /* delay in mS before detecting cards after interrupt */ u32 detect_delay_ms; + struct reset_control *rstc; struct dw_mci_dma_ops *dma_ops; struct dma_pdata *data; }; -- 1.9.1 ^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH v4 2/2] mmc: dw_mmc: add reset support to dwmmc host controller 2016-08-10 8:03 ` Guodong Xu (?) @ 2016-08-11 2:23 ` Shawn Lin -1 siblings, 0 replies; 19+ messages in thread From: Shawn Lin @ 2016-08-11 2:23 UTC (permalink / raw) To: Guodong Xu, heiko, shawn.lin, jh80.chung, robh+dt, mark.rutland, ulf.hansson Cc: shawn.lin, devicetree, linux-kernel, linux-arm-kernel, linux-mmc, Xinwei Kong, Zhangfei Gao On 2016/8/10 16:03, Guodong Xu wrote: > 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: Guodong Xu <guodong.xu@linaro.org> > Signed-off-by: Xinwei Kong <kong.kongxinwei@hisilicon.com> > Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org> Looks good to me, Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com> > --- > drivers/mmc/host/dw_mmc.c | 23 ++++++++++++++++++++++- > include/linux/mmc/dw_mmc.h | 2 ++ > 2 files changed, 24 insertions(+), 1 deletion(-) > > diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c > index 32380d5..481d441 100644 > --- a/drivers/mmc/host/dw_mmc.c > +++ b/drivers/mmc/host/dw_mmc.c > @@ -2915,6 +2915,13 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host) > if (!pdata) > 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 */ > of_property_read_u32(np, "num-slots", &pdata->num_slots); > > @@ -2986,7 +2993,9 @@ int dw_mci_probe(struct dw_mci *host) > > if (!host->pdata) { > 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"); > return -EINVAL; > } > @@ -3040,6 +3049,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, > dw_mci_cmd11_timer, (unsigned long)host); > > @@ -3189,6 +3204,9 @@ err_dmaunmap: > if (host->use_dma && host->dma_ops->exit) > host->dma_ops->exit(host); > > + if (!IS_ERR(host->pdata->rstc)) > + reset_control_assert(host->pdata->rstc); > + > err_clk_ciu: > if (!IS_ERR(host->ciu_clk)) > clk_disable_unprepare(host->ciu_clk); > @@ -3221,6 +3239,9 @@ void dw_mci_remove(struct dw_mci *host) > if (host->use_dma && host->dma_ops->exit) > host->dma_ops->exit(host); > > + if (!IS_ERR(host->pdata->rstc)) > + reset_control_assert(host->pdata->rstc); > + > if (!IS_ERR(host->ciu_clk)) > clk_disable_unprepare(host->ciu_clk); > > diff --git a/include/linux/mmc/dw_mmc.h b/include/linux/mmc/dw_mmc.h > index 83b0edfc..f5af2bd 100644 > --- a/include/linux/mmc/dw_mmc.h > +++ b/include/linux/mmc/dw_mmc.h > @@ -17,6 +17,7 @@ > #include <linux/scatterlist.h> > #include <linux/mmc/core.h> > #include <linux/dmaengine.h> > +#include <linux/reset.h> > > #define MAX_MCI_SLOTS 2 > > @@ -259,6 +260,7 @@ struct dw_mci_board { > /* delay in mS before detecting cards after interrupt */ > u32 detect_delay_ms; > > + struct reset_control *rstc; > struct dw_mci_dma_ops *dma_ops; > struct dma_pdata *data; > }; > -- Best Regards Shawn Lin ^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v4 2/2] mmc: dw_mmc: add reset support to dwmmc host controller @ 2016-08-11 2:23 ` Shawn Lin 0 siblings, 0 replies; 19+ messages in thread From: Shawn Lin @ 2016-08-11 2:23 UTC (permalink / raw) To: linux-arm-kernel On 2016/8/10 16:03, Guodong Xu wrote: > 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: Guodong Xu <guodong.xu@linaro.org> > Signed-off-by: Xinwei Kong <kong.kongxinwei@hisilicon.com> > Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org> Looks good to me, Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com> > --- > drivers/mmc/host/dw_mmc.c | 23 ++++++++++++++++++++++- > include/linux/mmc/dw_mmc.h | 2 ++ > 2 files changed, 24 insertions(+), 1 deletion(-) > > diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c > index 32380d5..481d441 100644 > --- a/drivers/mmc/host/dw_mmc.c > +++ b/drivers/mmc/host/dw_mmc.c > @@ -2915,6 +2915,13 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host) > if (!pdata) > 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 */ > of_property_read_u32(np, "num-slots", &pdata->num_slots); > > @@ -2986,7 +2993,9 @@ int dw_mci_probe(struct dw_mci *host) > > if (!host->pdata) { > 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"); > return -EINVAL; > } > @@ -3040,6 +3049,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, > dw_mci_cmd11_timer, (unsigned long)host); > > @@ -3189,6 +3204,9 @@ err_dmaunmap: > if (host->use_dma && host->dma_ops->exit) > host->dma_ops->exit(host); > > + if (!IS_ERR(host->pdata->rstc)) > + reset_control_assert(host->pdata->rstc); > + > err_clk_ciu: > if (!IS_ERR(host->ciu_clk)) > clk_disable_unprepare(host->ciu_clk); > @@ -3221,6 +3239,9 @@ void dw_mci_remove(struct dw_mci *host) > if (host->use_dma && host->dma_ops->exit) > host->dma_ops->exit(host); > > + if (!IS_ERR(host->pdata->rstc)) > + reset_control_assert(host->pdata->rstc); > + > if (!IS_ERR(host->ciu_clk)) > clk_disable_unprepare(host->ciu_clk); > > diff --git a/include/linux/mmc/dw_mmc.h b/include/linux/mmc/dw_mmc.h > index 83b0edfc..f5af2bd 100644 > --- a/include/linux/mmc/dw_mmc.h > +++ b/include/linux/mmc/dw_mmc.h > @@ -17,6 +17,7 @@ > #include <linux/scatterlist.h> > #include <linux/mmc/core.h> > #include <linux/dmaengine.h> > +#include <linux/reset.h> > > #define MAX_MCI_SLOTS 2 > > @@ -259,6 +260,7 @@ struct dw_mci_board { > /* delay in mS before detecting cards after interrupt */ > u32 detect_delay_ms; > > + struct reset_control *rstc; > struct dw_mci_dma_ops *dma_ops; > struct dma_pdata *data; > }; > -- Best Regards Shawn Lin ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v4 2/2] mmc: dw_mmc: add reset support to dwmmc host controller @ 2016-08-11 2:23 ` Shawn Lin 0 siblings, 0 replies; 19+ messages in thread From: Shawn Lin @ 2016-08-11 2:23 UTC (permalink / raw) To: Guodong Xu, heiko, jh80.chung, robh+dt, mark.rutland, ulf.hansson Cc: shawn.lin, devicetree, linux-kernel, linux-arm-kernel, linux-mmc, Xinwei Kong, Zhangfei Gao On 2016/8/10 16:03, Guodong Xu wrote: > 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: Guodong Xu <guodong.xu@linaro.org> > Signed-off-by: Xinwei Kong <kong.kongxinwei@hisilicon.com> > Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org> Looks good to me, Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com> > --- > drivers/mmc/host/dw_mmc.c | 23 ++++++++++++++++++++++- > include/linux/mmc/dw_mmc.h | 2 ++ > 2 files changed, 24 insertions(+), 1 deletion(-) > > diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c > index 32380d5..481d441 100644 > --- a/drivers/mmc/host/dw_mmc.c > +++ b/drivers/mmc/host/dw_mmc.c > @@ -2915,6 +2915,13 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host) > if (!pdata) > 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 */ > of_property_read_u32(np, "num-slots", &pdata->num_slots); > > @@ -2986,7 +2993,9 @@ int dw_mci_probe(struct dw_mci *host) > > if (!host->pdata) { > 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"); > return -EINVAL; > } > @@ -3040,6 +3049,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, > dw_mci_cmd11_timer, (unsigned long)host); > > @@ -3189,6 +3204,9 @@ err_dmaunmap: > if (host->use_dma && host->dma_ops->exit) > host->dma_ops->exit(host); > > + if (!IS_ERR(host->pdata->rstc)) > + reset_control_assert(host->pdata->rstc); > + > err_clk_ciu: > if (!IS_ERR(host->ciu_clk)) > clk_disable_unprepare(host->ciu_clk); > @@ -3221,6 +3239,9 @@ void dw_mci_remove(struct dw_mci *host) > if (host->use_dma && host->dma_ops->exit) > host->dma_ops->exit(host); > > + if (!IS_ERR(host->pdata->rstc)) > + reset_control_assert(host->pdata->rstc); > + > if (!IS_ERR(host->ciu_clk)) > clk_disable_unprepare(host->ciu_clk); > > diff --git a/include/linux/mmc/dw_mmc.h b/include/linux/mmc/dw_mmc.h > index 83b0edfc..f5af2bd 100644 > --- a/include/linux/mmc/dw_mmc.h > +++ b/include/linux/mmc/dw_mmc.h > @@ -17,6 +17,7 @@ > #include <linux/scatterlist.h> > #include <linux/mmc/core.h> > #include <linux/dmaengine.h> > +#include <linux/reset.h> > > #define MAX_MCI_SLOTS 2 > > @@ -259,6 +260,7 @@ struct dw_mci_board { > /* delay in mS before detecting cards after interrupt */ > u32 detect_delay_ms; > > + struct reset_control *rstc; > struct dw_mci_dma_ops *dma_ops; > struct dma_pdata *data; > }; > -- Best Regards Shawn Lin ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v4 2/2] mmc: dw_mmc: add reset support to dwmmc host controller 2016-08-11 2:23 ` Shawn Lin @ 2016-08-11 10:30 ` Jaehoon Chung -1 siblings, 0 replies; 19+ messages in thread From: Jaehoon Chung @ 2016-08-11 10:30 UTC (permalink / raw) To: Shawn Lin, Guodong Xu, heiko, robh+dt, mark.rutland, ulf.hansson Cc: devicetree, linux-kernel, linux-arm-kernel, linux-mmc, Xinwei Kong, Zhangfei Gao Hi Guodong, On 08/11/2016 11:23 AM, Shawn Lin wrote: > On 2016/8/10 16:03, Guodong Xu wrote: >> 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: Guodong Xu <guodong.xu@linaro.org> >> Signed-off-by: Xinwei Kong <kong.kongxinwei@hisilicon.com> >> Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org> > > Looks good to me, > > Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com> Could you rebase on https://github.com/jh80chung/dw-mmc.git? Otherwise, when i apply your patch, i will rebase. Best Regards, Jaehoon Chung > >> --- >> drivers/mmc/host/dw_mmc.c | 23 ++++++++++++++++++++++- >> include/linux/mmc/dw_mmc.h | 2 ++ >> 2 files changed, 24 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c >> index 32380d5..481d441 100644 >> --- a/drivers/mmc/host/dw_mmc.c >> +++ b/drivers/mmc/host/dw_mmc.c >> @@ -2915,6 +2915,13 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host) >> if (!pdata) >> 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 */ >> of_property_read_u32(np, "num-slots", &pdata->num_slots); >> >> @@ -2986,7 +2993,9 @@ int dw_mci_probe(struct dw_mci *host) >> >> if (!host->pdata) { >> 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"); >> return -EINVAL; >> } >> @@ -3040,6 +3049,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, >> dw_mci_cmd11_timer, (unsigned long)host); >> >> @@ -3189,6 +3204,9 @@ err_dmaunmap: >> if (host->use_dma && host->dma_ops->exit) >> host->dma_ops->exit(host); >> >> + if (!IS_ERR(host->pdata->rstc)) >> + reset_control_assert(host->pdata->rstc); >> + >> err_clk_ciu: >> if (!IS_ERR(host->ciu_clk)) >> clk_disable_unprepare(host->ciu_clk); >> @@ -3221,6 +3239,9 @@ void dw_mci_remove(struct dw_mci *host) >> if (host->use_dma && host->dma_ops->exit) >> host->dma_ops->exit(host); >> >> + if (!IS_ERR(host->pdata->rstc)) >> + reset_control_assert(host->pdata->rstc); >> + >> if (!IS_ERR(host->ciu_clk)) >> clk_disable_unprepare(host->ciu_clk); >> >> diff --git a/include/linux/mmc/dw_mmc.h b/include/linux/mmc/dw_mmc.h >> index 83b0edfc..f5af2bd 100644 >> --- a/include/linux/mmc/dw_mmc.h >> +++ b/include/linux/mmc/dw_mmc.h >> @@ -17,6 +17,7 @@ >> #include <linux/scatterlist.h> >> #include <linux/mmc/core.h> >> #include <linux/dmaengine.h> >> +#include <linux/reset.h> >> >> #define MAX_MCI_SLOTS 2 >> >> @@ -259,6 +260,7 @@ struct dw_mci_board { >> /* delay in mS before detecting cards after interrupt */ >> u32 detect_delay_ms; >> >> + struct reset_control *rstc; >> struct dw_mci_dma_ops *dma_ops; >> struct dma_pdata *data; >> }; >> > > ^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v4 2/2] mmc: dw_mmc: add reset support to dwmmc host controller @ 2016-08-11 10:30 ` Jaehoon Chung 0 siblings, 0 replies; 19+ messages in thread From: Jaehoon Chung @ 2016-08-11 10:30 UTC (permalink / raw) To: linux-arm-kernel Hi Guodong, On 08/11/2016 11:23 AM, Shawn Lin wrote: > On 2016/8/10 16:03, Guodong Xu wrote: >> 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: Guodong Xu <guodong.xu@linaro.org> >> Signed-off-by: Xinwei Kong <kong.kongxinwei@hisilicon.com> >> Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org> > > Looks good to me, > > Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com> Could you rebase on https://github.com/jh80chung/dw-mmc.git? Otherwise, when i apply your patch, i will rebase. Best Regards, Jaehoon Chung > >> --- >> drivers/mmc/host/dw_mmc.c | 23 ++++++++++++++++++++++- >> include/linux/mmc/dw_mmc.h | 2 ++ >> 2 files changed, 24 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c >> index 32380d5..481d441 100644 >> --- a/drivers/mmc/host/dw_mmc.c >> +++ b/drivers/mmc/host/dw_mmc.c >> @@ -2915,6 +2915,13 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host) >> if (!pdata) >> 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 */ >> of_property_read_u32(np, "num-slots", &pdata->num_slots); >> >> @@ -2986,7 +2993,9 @@ int dw_mci_probe(struct dw_mci *host) >> >> if (!host->pdata) { >> 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"); >> return -EINVAL; >> } >> @@ -3040,6 +3049,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, >> dw_mci_cmd11_timer, (unsigned long)host); >> >> @@ -3189,6 +3204,9 @@ err_dmaunmap: >> if (host->use_dma && host->dma_ops->exit) >> host->dma_ops->exit(host); >> >> + if (!IS_ERR(host->pdata->rstc)) >> + reset_control_assert(host->pdata->rstc); >> + >> err_clk_ciu: >> if (!IS_ERR(host->ciu_clk)) >> clk_disable_unprepare(host->ciu_clk); >> @@ -3221,6 +3239,9 @@ void dw_mci_remove(struct dw_mci *host) >> if (host->use_dma && host->dma_ops->exit) >> host->dma_ops->exit(host); >> >> + if (!IS_ERR(host->pdata->rstc)) >> + reset_control_assert(host->pdata->rstc); >> + >> if (!IS_ERR(host->ciu_clk)) >> clk_disable_unprepare(host->ciu_clk); >> >> diff --git a/include/linux/mmc/dw_mmc.h b/include/linux/mmc/dw_mmc.h >> index 83b0edfc..f5af2bd 100644 >> --- a/include/linux/mmc/dw_mmc.h >> +++ b/include/linux/mmc/dw_mmc.h >> @@ -17,6 +17,7 @@ >> #include <linux/scatterlist.h> >> #include <linux/mmc/core.h> >> #include <linux/dmaengine.h> >> +#include <linux/reset.h> >> >> #define MAX_MCI_SLOTS 2 >> >> @@ -259,6 +260,7 @@ struct dw_mci_board { >> /* delay in mS before detecting cards after interrupt */ >> u32 detect_delay_ms; >> >> + struct reset_control *rstc; >> struct dw_mci_dma_ops *dma_ops; >> struct dma_pdata *data; >> }; >> > > ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v4 2/2] mmc: dw_mmc: add reset support to dwmmc host controller 2016-08-11 10:30 ` Jaehoon Chung @ 2016-08-12 8:53 ` Guodong Xu -1 siblings, 0 replies; 19+ messages in thread From: Guodong Xu @ 2016-08-12 8:53 UTC (permalink / raw) To: Jaehoon Chung Cc: Shawn Lin, Heiko Stübner, Rob Herring, Mark Rutland, Ulf Hansson, devicetree, linux-kernel, linux-arm-kernel, linux-mmc, Xinwei Kong, Zhangfei Gao On 11 August 2016 at 18:30, Jaehoon Chung <jh80.chung@samsung.com> wrote: > Hi Guodong, > > On 08/11/2016 11:23 AM, Shawn Lin wrote: >> On 2016/8/10 16:03, Guodong Xu wrote: >>> 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: Guodong Xu <guodong.xu@linaro.org> >>> Signed-off-by: Xinwei Kong <kong.kongxinwei@hisilicon.com> >>> Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org> >> >> Looks good to me, >> >> Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com> > > Could you rebase on https://github.com/jh80chung/dw-mmc.git? > Otherwise, when i apply your patch, i will rebase. > Sure, I rebased. Sending v5. -Guodong > Best Regards, > Jaehoon Chung > >> >>> --- >>> drivers/mmc/host/dw_mmc.c | 23 ++++++++++++++++++++++- >>> include/linux/mmc/dw_mmc.h | 2 ++ >>> 2 files changed, 24 insertions(+), 1 deletion(-) >>> >>> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c >>> index 32380d5..481d441 100644 >>> --- a/drivers/mmc/host/dw_mmc.c >>> +++ b/drivers/mmc/host/dw_mmc.c >>> @@ -2915,6 +2915,13 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host) >>> if (!pdata) >>> 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 */ >>> of_property_read_u32(np, "num-slots", &pdata->num_slots); >>> >>> @@ -2986,7 +2993,9 @@ int dw_mci_probe(struct dw_mci *host) >>> >>> if (!host->pdata) { >>> 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"); >>> return -EINVAL; >>> } >>> @@ -3040,6 +3049,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, >>> dw_mci_cmd11_timer, (unsigned long)host); >>> >>> @@ -3189,6 +3204,9 @@ err_dmaunmap: >>> if (host->use_dma && host->dma_ops->exit) >>> host->dma_ops->exit(host); >>> >>> + if (!IS_ERR(host->pdata->rstc)) >>> + reset_control_assert(host->pdata->rstc); >>> + >>> err_clk_ciu: >>> if (!IS_ERR(host->ciu_clk)) >>> clk_disable_unprepare(host->ciu_clk); >>> @@ -3221,6 +3239,9 @@ void dw_mci_remove(struct dw_mci *host) >>> if (host->use_dma && host->dma_ops->exit) >>> host->dma_ops->exit(host); >>> >>> + if (!IS_ERR(host->pdata->rstc)) >>> + reset_control_assert(host->pdata->rstc); >>> + >>> if (!IS_ERR(host->ciu_clk)) >>> clk_disable_unprepare(host->ciu_clk); >>> >>> diff --git a/include/linux/mmc/dw_mmc.h b/include/linux/mmc/dw_mmc.h >>> index 83b0edfc..f5af2bd 100644 >>> --- a/include/linux/mmc/dw_mmc.h >>> +++ b/include/linux/mmc/dw_mmc.h >>> @@ -17,6 +17,7 @@ >>> #include <linux/scatterlist.h> >>> #include <linux/mmc/core.h> >>> #include <linux/dmaengine.h> >>> +#include <linux/reset.h> >>> >>> #define MAX_MCI_SLOTS 2 >>> >>> @@ -259,6 +260,7 @@ struct dw_mci_board { >>> /* delay in mS before detecting cards after interrupt */ >>> u32 detect_delay_ms; >>> >>> + struct reset_control *rstc; >>> struct dw_mci_dma_ops *dma_ops; >>> struct dma_pdata *data; >>> }; >>> >> >> > ^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v4 2/2] mmc: dw_mmc: add reset support to dwmmc host controller @ 2016-08-12 8:53 ` Guodong Xu 0 siblings, 0 replies; 19+ messages in thread From: Guodong Xu @ 2016-08-12 8:53 UTC (permalink / raw) To: linux-arm-kernel On 11 August 2016 at 18:30, Jaehoon Chung <jh80.chung@samsung.com> wrote: > Hi Guodong, > > On 08/11/2016 11:23 AM, Shawn Lin wrote: >> On 2016/8/10 16:03, Guodong Xu wrote: >>> 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: Guodong Xu <guodong.xu@linaro.org> >>> Signed-off-by: Xinwei Kong <kong.kongxinwei@hisilicon.com> >>> Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org> >> >> Looks good to me, >> >> Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com> > > Could you rebase on https://github.com/jh80chung/dw-mmc.git? > Otherwise, when i apply your patch, i will rebase. > Sure, I rebased. Sending v5. -Guodong > Best Regards, > Jaehoon Chung > >> >>> --- >>> drivers/mmc/host/dw_mmc.c | 23 ++++++++++++++++++++++- >>> include/linux/mmc/dw_mmc.h | 2 ++ >>> 2 files changed, 24 insertions(+), 1 deletion(-) >>> >>> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c >>> index 32380d5..481d441 100644 >>> --- a/drivers/mmc/host/dw_mmc.c >>> +++ b/drivers/mmc/host/dw_mmc.c >>> @@ -2915,6 +2915,13 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host) >>> if (!pdata) >>> 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 */ >>> of_property_read_u32(np, "num-slots", &pdata->num_slots); >>> >>> @@ -2986,7 +2993,9 @@ int dw_mci_probe(struct dw_mci *host) >>> >>> if (!host->pdata) { >>> 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"); >>> return -EINVAL; >>> } >>> @@ -3040,6 +3049,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, >>> dw_mci_cmd11_timer, (unsigned long)host); >>> >>> @@ -3189,6 +3204,9 @@ err_dmaunmap: >>> if (host->use_dma && host->dma_ops->exit) >>> host->dma_ops->exit(host); >>> >>> + if (!IS_ERR(host->pdata->rstc)) >>> + reset_control_assert(host->pdata->rstc); >>> + >>> err_clk_ciu: >>> if (!IS_ERR(host->ciu_clk)) >>> clk_disable_unprepare(host->ciu_clk); >>> @@ -3221,6 +3239,9 @@ void dw_mci_remove(struct dw_mci *host) >>> if (host->use_dma && host->dma_ops->exit) >>> host->dma_ops->exit(host); >>> >>> + if (!IS_ERR(host->pdata->rstc)) >>> + reset_control_assert(host->pdata->rstc); >>> + >>> if (!IS_ERR(host->ciu_clk)) >>> clk_disable_unprepare(host->ciu_clk); >>> >>> diff --git a/include/linux/mmc/dw_mmc.h b/include/linux/mmc/dw_mmc.h >>> index 83b0edfc..f5af2bd 100644 >>> --- a/include/linux/mmc/dw_mmc.h >>> +++ b/include/linux/mmc/dw_mmc.h >>> @@ -17,6 +17,7 @@ >>> #include <linux/scatterlist.h> >>> #include <linux/mmc/core.h> >>> #include <linux/dmaengine.h> >>> +#include <linux/reset.h> >>> >>> #define MAX_MCI_SLOTS 2 >>> >>> @@ -259,6 +260,7 @@ struct dw_mci_board { >>> /* delay in mS before detecting cards after interrupt */ >>> u32 detect_delay_ms; >>> >>> + struct reset_control *rstc; >>> struct dw_mci_dma_ops *dma_ops; >>> struct dma_pdata *data; >>> }; >>> >> >> > ^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2016-08-12 8:53 UTC | newest] Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2016-08-10 8:03 [PATCH v4 0/2] mmc: dw_mmc: host controller reset support Guodong Xu 2016-08-10 8:03 ` Guodong Xu 2016-08-10 8:03 ` Guodong Xu 2016-08-10 8:03 ` [PATCH v4 1/2] Documentation: synopsys-dw-mshc: add binding for resets Guodong Xu 2016-08-10 8:03 ` Guodong Xu 2016-08-10 8:03 ` Guodong Xu 2016-08-11 2:18 ` Shawn Lin 2016-08-11 2:18 ` Shawn Lin 2016-08-11 2:18 ` Shawn Lin 2016-08-10 8:03 ` [PATCH v4 2/2] mmc: dw_mmc: add reset support to dwmmc host controller Guodong Xu 2016-08-10 8:03 ` Guodong Xu 2016-08-10 8:03 ` Guodong Xu 2016-08-11 2:23 ` Shawn Lin 2016-08-11 2:23 ` Shawn Lin 2016-08-11 2:23 ` Shawn Lin 2016-08-11 10:30 ` Jaehoon Chung 2016-08-11 10:30 ` Jaehoon Chung 2016-08-12 8:53 ` Guodong Xu 2016-08-12 8:53 ` Guodong Xu
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.