Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp1226685pxy; Thu, 6 May 2021 03:28:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1w14rT0p+Jh0LEXSvVjwjti7ty/uVVOfjrJkq9pr6kyilxevYAaEAChmd9GCoNxJ8BWsV X-Received: by 2002:a17:906:c1c9:: with SMTP id bw9mr3677018ejb.239.1620296909160; Thu, 06 May 2021 03:28:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620296909; cv=none; d=google.com; s=arc-20160816; b=caFGK6AYD/q80Sg8LrtLkm7YyLptp6zPHkIEY29Zg9cV0y2mEpduKZodNUQynWTFuS GZrLbEpvLlKuDEG1xXk8PRZhxX8TZCnYMRTK/LJ1fRJFJ3r+thj0rxIi5jvb5//scDBH MPrknbG/xcT8avS3OFRON2Y5Ddd3jeL3RynZdjWSIoyzASytKks8RfrrPovBpOB/9yXm rlwzNpXxQ/sYpToX3/pOzrWu50WGrmSnUZp2Iw3SEkETiZgW7A+9uGLpfdF0HO6DtXhW PDdAFuNNL5bxzwOyKqPj2N8NboLuHte6VbcQ/vSxA1Ki0JZjW/ZFDx0PWxVBBJel50Ft RcOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=Kliga/zxOEy4nZPGzNcMF2o6kmnQ23lwK9cquy/t+vY=; b=noKnbI5q28Ybp7xZAWx+os3PjkmrIV3a9mMJu59aLVROqacA8rh+6ECbtel+ba+2Vp Q7fGlQoUVZWEKAPeOIsbnlt6j0QyVqkqYm1NPVg/In1psT5BRYKx5/pr0d3dQErcXLqT cdLJ70oCkodRgluB+gK9FLjE/mkW+PneNNNqSGiV3N4ztfUMp/bVUBzLvtloA9OT8/TW 1JdVZCUwx04fP/w+GFQaqvaU43KNrCB1+aZalksLlQe4FXSo8l9ZDzr3Qbgr5T+NZUh5 +6hPovLO/3JsPLwF11yglTMdjdYWXonGiLE3scNgzjJV1xwI6e5AwkZX1zP+Bwrv7Gor iYmw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 10si2075190edx.129.2021.05.06.03.28.04; Thu, 06 May 2021 03:28:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234319AbhEFK03 (ORCPT + 99 others); Thu, 6 May 2021 06:26:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231863AbhEFK03 (ORCPT ); Thu, 6 May 2021 06:26:29 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B300C061574 for ; Thu, 6 May 2021 03:25:31 -0700 (PDT) Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lebBr-0007Y4-Hd; Thu, 06 May 2021 12:25:07 +0200 Received: from pza by ptx.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1lebBi-0006VF-Tg; Thu, 06 May 2021 12:24:58 +0200 Date: Thu, 6 May 2021 12:24:58 +0200 From: Philipp Zabel To: Steven Lee Cc: Andrew Jeffery , Ulf Hansson , Rob Herring , Joel Stanley , Adrian Hunter , Ryan Chen , "moderated list:ASPEED SD/MMC DRIVER" , "moderated list:ASPEED SD/MMC DRIVER" , "open list:ASPEED SD/MMC DRIVER" , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , "moderated list:ARM/ASPEED MACHINE SUPPORT" , open list , Hongweiz@ami.com, ryan_chen@aspeedtech.com, chin-ting_kuo@aspeedtech.com Subject: Re: [PATCH v3 5/5] mmc: sdhci-of-aspeed: Assert/Deassert reset signal before probing eMMC Message-ID: <20210506102458.GA20777@pengutronix.de> References: <20210506100312.1638-1-steven_lee@aspeedtech.com> <20210506100312.1638-6-steven_lee@aspeedtech.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210506100312.1638-6-steven_lee@aspeedtech.com> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 12:10:55 up 77 days, 13:34, 104 users, load average: 0.57, 0.39, 0.37 User-Agent: Mutt/1.10.1 (2018-07-13) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: pza@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Steven, On Thu, May 06, 2021 at 06:03:12PM +0800, Steven Lee wrote: > For cleaning up the AST2600 eMMC controller, the reset signal should be > asserted and deasserted before it is probed. > > Signed-off-by: Steven Lee > --- > drivers/mmc/host/sdhci-of-aspeed.c | 49 ++++++++++++++++++++++++------ > 1 file changed, 40 insertions(+), 9 deletions(-) > > diff --git a/drivers/mmc/host/sdhci-of-aspeed.c b/drivers/mmc/host/sdhci-of-aspeed.c > index 4979f98ffb52..8ef06f32abff 100644 > --- a/drivers/mmc/host/sdhci-of-aspeed.c > +++ b/drivers/mmc/host/sdhci-of-aspeed.c [...] > @@ -533,11 +545,22 @@ static struct platform_driver aspeed_sdhci_driver = { > .remove = aspeed_sdhci_remove, > }; > > +static const struct of_device_id aspeed_sdc_of_match[] = { > + { .compatible = "aspeed,ast2400-sd-controller", }, > + { .compatible = "aspeed,ast2500-sd-controller", }, > + { .compatible = "aspeed,ast2600-sd-controller", .data = &ast2600_sdc_info}, > + { } > +}; > + > +MODULE_DEVICE_TABLE(of, aspeed_sdc_of_match); > + > static int aspeed_sdc_probe(struct platform_device *pdev) > > { > struct device_node *parent, *child; > struct aspeed_sdc *sdc; > + const struct of_device_id *match = NULL; > + const struct aspeed_sdc_info *info = NULL; There is no need to initialize these variables to NULL, see below: > int ret; > > sdc = devm_kzalloc(&pdev->dev, sizeof(*sdc), GFP_KERNEL); > @@ -546,6 +569,23 @@ static int aspeed_sdc_probe(struct platform_device *pdev) > > spin_lock_init(&sdc->lock); > > + match = of_match_device(aspeed_sdc_of_match, &pdev->dev); match is set unconditionally before it is used, > + if (!match) > + return -ENODEV; > + > + if (match->data) > + info = match->data; and info could be set unconditionally as well: info = match->data; > + if (info) { > + if (info->flag & PROBE_AFTER_ASSET_DEASSERT) { > + sdc->rst = devm_reset_control_get(&pdev->dev, NULL); Please use devm_reset_control_get_exclusive() or devm_reset_control_get_optional_exclusive(). > + if (!IS_ERR(sdc->rst)) { Please just return errors here instead of ignoring them. The reset_control_get_optional variants return NULL in case the device node doesn't contain a resets phandle, in case you really consider this reset to be optional even though the flag is set? > + reset_control_assert(sdc->rst); > + reset_control_deassert(sdc->rst); Is there no need for delays between assertion and deassertion or after the reset is deasserted? > + } > + } > + } > + > sdc->clk = devm_clk_get(&pdev->dev, NULL); > if (IS_ERR(sdc->clk)) > return PTR_ERR(sdc->clk); In general, I would assert/deassert the reset only after all resources are successfully acquired. This might avoid unnecessary resets in case of probe deferrals. regards Philipp