Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753382AbcC2F5F (ORCPT ); Tue, 29 Mar 2016 01:57:05 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:60729 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752447AbcC2F5C convert rfc822-to-8bit (ORCPT ); Tue, 29 Mar 2016 01:57:02 -0400 X-AuditID: cbfee690-f79e56d0000012c4-89-56fa192adf67 MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-transfer-encoding: 8BIT Message-id: <56FA192A.9030209@samsung.com> Date: Tue, 29 Mar 2016 14:56:58 +0900 From: Jaehoon Chung User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 To: Shawn Lin , Guodong Xu , Shawn Lin Cc: robh+dt@kernel.org, =?UTF-8?B?UGF3ZcWCIE1vbGw=?= , Mark Rutland , ijc+devicetree@hellion.org.uk, Kumar Gala , Ulf Hansson , devicetree@vger.kernel.org, "linux-kernel@vger.kernel.org" , linux-mmc@vger.kernel.org, Xinwei Kong , Zhangfei Gao Subject: Re: [PATCH 2/2] mmc: dw_mmc: add resets support to dw_mmc References: <1457254062-22677-1-git-send-email-guodong.xu@linaro.org> <1457254062-22677-2-git-send-email-guodong.xu@linaro.org> <56DC3BAD.8020107@rock-chips.com> <56F9E6E5.9000100@kernel-upstream.org> In-reply-to: <56F9E6E5.9000100@kernel-upstream.org> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrPIsWRmVeSWpSXmKPExsWyRsSkWFdL8leYwbplphbzj5xjteh/s5DV 4v+dHlaLc69WMlr8+LuP1eLyrjlsFkf+9zNaLL1+kcliwvS1LBate4+wW9zbfIzJ4s6T9awW x9eGW9xcc4Hdgc9jzbw1jB6X+3qZPFYu/8Lm8XjuRnaPF/NfM3tsWtXJ5nHn2h42j7+z9rN4 fN4kF8AZxWWTkpqTWZZapG+XwJWxcsZp1o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FSxi5GTQ0LAROLighksELaYxIV769lAbCGBWYwSlx8Kg9i8AoISPybfA6rh4GAWkJc4 cikbwlSXmDIlt4uRC6j6AaPExIm3WCDKtSTuXpvEDGKzCKhK/H+xnx3EZhPQkdj+7TgTiC0q ECbxYN1eVhBbRKBS4uOTFSwgg5gF1jJL7Ls0HaxZWMBJYtP084wQG6YySVydsACsg1PAWOLg 5udsExiBrkS4bxbCfbMQ7lvAyLyKUSK1ILmgOCk91ygvtVyvODG3uDQvXS85P3cTIziFPJPe wXh4l/shRgEORiUeXoYFP8OEWBPLiitzDzFKcDArifBWif8KE+JNSaysSi3Kjy8qzUktPsRo CvTgRGYp0eR8YHrLK4k3NDYxM7I0Mje0MDI2VxLnffx/XZiQQHpiSWp2ampBahFMHxMHp1QD o3yl58u9G9g7zuy6U9jgz9/w5JXpvFy9rb5FL2adqHC8/aooceK97Pqijhj7ppsFPYGvm+o/ HTZqPXTjhfX2Nu6sY2WbKnMC/9SG/Dxj+uPd8w+3l/g+vRHrtCdILuXQ7B4Nj/WL+T6xexVn Pu2/oPxEWDp+TqSGvcWd+4IfNTNaN5Z84HVIUGIpzkg01GIuKk4EACKNOIk3AwAA 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 Content-Length: 6408 Lines: 192 On 03/29/2016 11:22 AM, Shawn Lin wrote: > 在 2016/3/25 13:35, Guodong Xu 写道: >> Hi, Shawn >> >> Sorry I replied late. I added comments below. >> >> On 6 March 2016 at 22:16, Shawn Lin > > wrote: >> >> On 2016/3/6 16:47, Guodong Xu wrote: >> >> mmc registers may in abnormal state if mmc is used in bootloader, >> eg. to support booting from eMMC. So we need reset mmc registers >> when kernel boots up, instead of assuming mmc is in clean state. >> >> With this patch, user can add a 'resets' property into dw_mmc dts >> node. When driver parse_dt and probe, it calls reset API to >> deassert the 'reset' of dw_mmc host controller. When probe error or >> remove, it calls reset API to assert it. >> >> Please also refer to >> Documentation/devicetree/bindings/reset/reset.txt >> >> Signed-off-by: Guodong Xu > > >> Signed-off-by: Xinwei Kong > > >> Signed-off-by: Zhangfei Gao > > >> >> >> Really should V2 and add the changelog. >> >> >> Yes, will do. next version I sent will be labelled as V3. >> >> >> >> --- >> drivers/mmc/host/dw_mmc.c | 22 +++++++++++++++++++++- >> 1 file changed, 21 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c >> index 242f9a0..281ea9c 100644 >> --- a/drivers/mmc/host/dw_mmc.c >> +++ b/drivers/mmc/host/dw_mmc.c >> @@ -2878,6 +2878,14 @@ 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); >> + pdata->rstc = NULL; >> >> >> maybe we can remove "pdata->rstc = NULL", and directly >> use IS_ERR(..) for the following "if (host->pdata->rstc != NULL)" >> statement >> >> >> Yes, will do. >> I see your point, other lines in this file are using IS_ERR(!..), I will >> use this style too. >> >> + } >> + >> /* find out number of slots supported */ >> of_property_read_u32(np, "num-slots", &pdata->num_slots); >> >> @@ -2949,7 +2957,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; >> >> >> please fix the coding style here. >> >> >> Do you mean to add additional {} for this 'if' , like this? >> >> + if (PTR_ERR(host->pdata) == -EPROBE_DEFER) { >> + return -EPROBE_DEFER; >> >> + } >> >> I will add {}. >> >> >> >> + else if (IS_ERR(host->pdata)) { >> dev_err(host->dev, "platform data not >> available\n"); >> return -EINVAL; >> } >> @@ -3012,6 +3022,9 @@ int dw_mci_probe(struct dw_mci *host) >> } >> } >> >> + if (host->pdata->rstc != NULL) >> + reset_control_deassert(host->pdata->rstc); >> + >> >> >> sorry, I can't follow your intention here. Shouldn't it be something >> like "assert mmc -> may need delay -> deassert mmc". As your current >> code, nothing happend right? >> >> >> The chip exits from bootloader with this bit asserted. And when entering >> kernel, we only need to deassert. >> >> In my current code, the driver deassert mmc in _probe(), and assert mmc >> in _remove(). > > I catch your point. From the previous discussion, we add it to make sure > dw_mmc in good state after leaving bootloader to kernel. But My real question is that you can assert it in bootloader, so you can also > dessert it in bootloaer to make sure dw_mmc work fine when probing > in kernel. In that way, we don't need this patch? Doesn't dw_mci_hw_reset work fine? I think that card should be reset with MMC_CAP_HW_RESET. Could you check this? Best Regards, Jaehoon Chung > > More to think, Is it ok to match the behaviour of bootloader stage? > My bootloader doesn't assert the reset pin of dw_mmc, so it seams if > I want to fix you issue on kernel stage, I need a new round of > assert->delay->deassert. > > >> >> >> >> setup_timer(&host->cmd11_timer, >> dw_mci_cmd11_timer, (unsigned long)host); >> >> @@ -3164,6 +3177,9 @@ err_dmaunmap: >> if (host->use_dma && host->dma_ops->exit) >> host->dma_ops->exit(host); >> >> + if (host->pdata->rstc != NULL) >> + reset_control_assert(host->pdata->rstc); >> + >> err_clk_ciu: >> if (!IS_ERR(host->ciu_clk)) >> clk_disable_unprepare(host->ciu_clk); >> @@ -3196,11 +3212,15 @@ void dw_mci_remove(struct dw_mci *host) >> if (host->use_dma && host->dma_ops->exit) >> host->dma_ops->exit(host); >> >> + if (host->pdata->rstc != NULL) >> + reset_control_assert(host->pdata->rstc); >> + >> if (!IS_ERR(host->ciu_clk)) >> clk_disable_unprepare(host->ciu_clk); >> >> if (!IS_ERR(host->biu_clk)) >> clk_disable_unprepare(host->biu_clk); >> + >> } >> >> >> unnecessary new line here. >> >> >> Will fix. >> >> -Guodong >> >> >> EXPORT_SYMBOL(dw_mci_remove); >> >> >> >> >> -- >> Best Regards >> Shawn Lin >> >> > > >