From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752654AbcHKKab (ORCPT ); Thu, 11 Aug 2016 06:30:31 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:46196 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752420AbcHKKa2 (ORCPT ); Thu, 11 Aug 2016 06:30:28 -0400 X-AuditID: cbfee68d-f79286d000007a9a-8f-57ac53c1fef0 Subject: Re: [PATCH v4 2/2] mmc: dw_mmc: add reset support to dwmmc host controller To: Shawn Lin , Guodong Xu , heiko@sntech.de, robh+dt@kernel.org, mark.rutland@arm.com, ulf.hansson@linaro.org References: <1470816228-8874-1-git-send-email-guodong.xu@linaro.org> <1470816228-8874-3-git-send-email-guodong.xu@linaro.org> Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mmc@vger.kernel.org, Xinwei Kong , Zhangfei Gao From: Jaehoon Chung Message-id: Date: Thu, 11 Aug 2016 19:30:25 +0900 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-version: 1.0 In-reply-to: Content-type: text/plain; charset=gbk Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrJIsWRmVeSWpSXmKPExsWyRsSkQPdg8Jpwg7mrTC3mHznHavH/Tg+Q ePSa1eLH332sFpseX2O1uLxrDpvFkf/9jBZLr19ksmjde4Td4s6T9awWx9eGW9xcc4Hdgcdj zbw1jB6P525k99i0qpPN4861PWwem5fUe/ydtZ/FY/u1ecwenzfJBXBEcdmkpOZklqUW6dsl cGUceNzDXtCvVHHjmkID43GpLkZODgkBE4mNJx4yQthiEhfurWcDsYUEVjBKnN7oAFPz8vE7 oDgXUHwWo0Trp92MEM4DRok13x6zdDFycAgLhEqsf1QPEhcRWMwocX/WF6iObiaJDX/PMoE4 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4tzCjhJXHiynRXEZgaq3/b1DguELS+xec1b5gmMQIcitMxCUjYLSdkCRuZV jBKpBckFxUnpuYZ5qeV6xYm5xaV56XrJ+bmbGMGp4pnUDsaDu9wPMQpwMCrx8Hpkrg4XYk0s K67MPcQowcGsJMI7LXBNuBBvSmJlVWpRfnxRaU5q8SFGU6BHJjJLiSbnA9NYXkm8obGJmZGl kbmhhZGxuZI47+P/68KEBNITS1KzU1MLUotg+pg4OKUaGDmOanyf4V94KHzLhasfXiq92fHA LoPD8vGlcsYb+XeXlyZZfnBK72eRkBNiNJB6/fSK7uPD93UXsUVnJuzYLlO9Zvv93y9qnmpZ tj/jeHh638Eb/o57S1/cn77l1f8zlo8P/dI2ncvs3vx3qmHCh4r+Kec/yJ7YpjlrXsH9g6Wl ci8DJqTn2p5VYinOSDTUYi4qTgQA0i9oFSsDAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >> Signed-off-by: Xinwei Kong >> Signed-off-by: Zhangfei Gao > > Looks good to me, > > Reviewed-by: Shawn Lin 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 >> #include >> #include >> +#include >> >> #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; >> }; >> > > From mboxrd@z Thu Jan 1 00:00:00 1970 From: jh80.chung@samsung.com (Jaehoon Chung) Date: Thu, 11 Aug 2016 19:30:25 +0900 Subject: [PATCH v4 2/2] mmc: dw_mmc: add reset support to dwmmc host controller In-Reply-To: References: <1470816228-8874-1-git-send-email-guodong.xu@linaro.org> <1470816228-8874-3-git-send-email-guodong.xu@linaro.org> Message-ID: To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org 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 >> Signed-off-by: Xinwei Kong >> Signed-off-by: Zhangfei Gao > > Looks good to me, > > Reviewed-by: Shawn Lin 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 >> #include >> #include >> +#include >> >> #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; >> }; >> > >