From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA61DC433ED for ; Thu, 6 May 2021 10:28:15 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3AA156109E for ; Thu, 6 May 2021 10:28:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3AA156109E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=4X2Yfl6bwnXRxNPcizqxtbkyLuaxCbiFeLLjMNENERs=; b=qY1892+5fjNABWX+tD3lICshR rPwM4NbouVCj85ij3b7yYVNiRYPzZZK/d/zjm598yRAR2gEd4A9AGGfDgGRgQtiEpAOLWwHL4ZaNY MFIkOR3WBXBnX6Pv7sn0n87gL1/ku0eNuxgQJoT3ySpLmZ6q4IR6848Auy8bTxvHS7JVFdQM528mM pBJ/nrXYzXqhuOALanNSWgSb+mmQqLbYuOeAWs5yyeJiNJl+oWGCUw/vdXZBQOJElXZJLbqQAIqoH 18btGD651V6uUHVjmxEBt146tUzWOX4K007llat0nWz6GFAO93dYhLMH++CTF1crormUTUvmLNrsX Gx43AbG+Q==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lebCO-003xvI-TW; Thu, 06 May 2021 10:25:41 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lebCF-003xtO-UF for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 10:25:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Kliga/zxOEy4nZPGzNcMF2o6kmnQ23lwK9cquy/t+vY=; b=sbkyATpWiWzuB62sLI1EYrfv2A WrmmYkRdD80hOPFQ3zR4n6tnDlGNLjYgRe+sdpmHuOgz+lw5/nftHGZlGkke5EeTlE1+IvmsjrHEN ng1W032DfcZKDg6RDn5Hd3T1U57MXyshnl2wRqjb514vWLqxevnzOUD3858SaPpf0oQup7oWzIden YrOpu00EHIj5W2bwbd/xIXcu2at07ALXPKntQxQMSasrVftXEz5RDzrKXHcn36WC1gGxnrKe96UFW h4sEhO9+V6FHpqFG98c5JVuxQg6r0RRC71skAdRTidzITKr5xEj6b1y2/xNLsjYlCj04sWeIWHNBz aHA9OaFA==; Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lebCD-005wxF-DB for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 10:25:30 +0000 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-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-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210506_032529_474424_E54693DF X-CRM114-Status: GOOD ( 28.27 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel