Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1111005rdb; Wed, 6 Dec 2023 08:53:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IHYlYl5BuHXI8ncoLbrYRzMooaGsRRAFBAxJTB+EEgmOmL0LEmBECpRs1wJJ4zh3NAolME3 X-Received: by 2002:a05:6a00:28cd:b0:6ce:3a54:b667 with SMTP id ci13-20020a056a0028cd00b006ce3a54b667mr932985pfb.65.1701881585312; Wed, 06 Dec 2023 08:53:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701881585; cv=none; d=google.com; s=arc-20160816; b=IW5tQu93U6LHQh46xSwFr+f9RSNz6yog9/9VpOr5dR0ZTWDIWXcBzkndn0+2i6yUEi axdGmqYD2oJXYhYylUBbpiz07oGf2DhOcFVbCrjLuljAkR8ni+ozyoN9eriAi4v1r3Nd lIYDcS51WsEmiGiphh8jyidMciQ0PFu2qr5xv7uMAtvXOYS+CBS61NTxn0Ln2lwB78q0 T49fI1AtXTWSUacZ9x8TvmV5I5Ut9zEkYDuMQRgXd0GEet0OFCdGq/tmbOKowkCcVbiL EMi1VpGffLItJXn9kJx7rkTZ6eqagdUO0d8tjxMD8fVCyut3Q+AoRnCcsSXvpLOokIkO VYTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:to:from :subject:message-id; bh=tBco+cdJ9WLtpulPHKUOCFUqsvQdtjQsBVxjqMnIBGA=; fh=XjXghRiX98SHgFjfKzpUgQXcc7Qps8eS7SX3XqaNgAY=; b=BMYHgqLbPooeJBS42Vk/VKOedGx7LeuIgU5hLXbDTqlCznZsQ3Vd6qz6GvSD/wg8rH J2//gymukwDLMzqdavfL0v8TMRsfElOvf6m1J9DH0uy8wFUiyf1+yvYG7tzQJ2q+GBgz ATcokPa+fheWUHTxnM3xIm2G1wcd3CQksN0seq2s3R9WenNnwmlrmHhogYn1TpN9FH0c wasT5DQX+szU2kuJX047NAPSu7lshOnw61AeKqzvZDXwDidMXAvh+qsgrmlmjItJSUQS PF+h+0WF5Pgbqobs3VC/PD5fNrOOHq7stH7RgLsMxg9ElXhZG7AAswSpGg660jhGEa3g 8A5A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id b12-20020a655ccc000000b005b86b35778fsi172366pgt.180.2023.12.06.08.53.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 08:53:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id E6BFC808A940; Wed, 6 Dec 2023 08:53:02 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379716AbjLFQwl convert rfc822-to-8bit (ORCPT + 99 others); Wed, 6 Dec 2023 11:52:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379355AbjLFQwk (ORCPT ); Wed, 6 Dec 2023 11:52:40 -0500 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD190B2 for ; Wed, 6 Dec 2023 08:52:46 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rAv8K-00013G-NQ; Wed, 06 Dec 2023 17:52:24 +0100 Received: from [2a0a:edc0:0:900:1d::4e] (helo=lupine) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rAv8J-00E0DN-VC; Wed, 06 Dec 2023 17:52:23 +0100 Received: from pza by lupine with local (Exim 4.96) (envelope-from ) id 1rAv8J-000J6C-2s; Wed, 06 Dec 2023 17:52:23 +0100 Message-ID: Subject: Re: [PATCH 3/9] PCI: imx6: Simplify reset handling by using by using *_FLAG_HAS_*_RESET From: Philipp Zabel To: Frank Li , imx@lists.linux.dev, Richard Zhu , Lucas Stach , Lorenzo Pieralisi , Krzysztof =?UTF-8?Q?Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , "open list:PCI DRIVER FOR IMX6" , "moderated list:PCI DRIVER FOR IMX6" , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , open list Date: Wed, 06 Dec 2023 17:52:23 +0100 In-Reply-To: <20231206155903.566194-4-Frank.Li@nxp.com> References: <20231206155903.566194-1-Frank.Li@nxp.com> <20231206155903.566194-4-Frank.Li@nxp.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT User-Agent: Evolution 3.46.4-2 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: p.zabel@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 06 Dec 2023 08:53:03 -0800 (PST) Hi Frank, On Mi, 2023-12-06 at 10:58 -0500, Frank Li wrote: > Refactors the reset handling logic in the imx6 PCI driver by adding > IMX6_PCIE_FLAG_HAS_*_RESET bitmask define for drvdata::flags. > > The drvdata::flags and a bitmask ensures a cleaner and more scalable > switch-case structure for handling reset. > > Signed-off-by: Frank Li > --- > drivers/pci/controller/dwc/pci-imx6.c | 115 +++++++++++--------------- > 1 file changed, 47 insertions(+), 68 deletions(-) > > diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c > index bcf52aa86462..62d77fabd82a 100644 > --- a/drivers/pci/controller/dwc/pci-imx6.c > +++ b/drivers/pci/controller/dwc/pci-imx6.c [...] > @@ -696,18 +698,13 @@ static void imx6_pcie_clk_disable(struct imx6_pcie *imx6_pcie) > > static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie) > { > - switch (imx6_pcie->drvdata->variant) { > - case IMX7D: > - case IMX8MQ: > - case IMX8MQ_EP: > + if (imx6_check_flag(imx6_pcie, IMX6_PCIE_FLAG_HAS_PHY_RESET)) This check is not strictly necessary. If the flag is not set, imx6_pcie->pciephy_reset is guaranteed to be NULL, and then reset_control_assert() is a no-op. Same for the other (de)assert calls below. [...] > @@ -1335,36 +1319,24 @@ static int imx6_pcie_probe(struct platform_device *pdev) > "failed to get pcie phy\n"); > } > > - switch (imx6_pcie->drvdata->variant) { > - case IMX7D: > - if (dbi_base->start == IMX8MQ_PCIE2_BASE_ADDR) > - imx6_pcie->controller_id = 1; > - > - imx6_pcie->pciephy_reset = devm_reset_control_get_exclusive(dev, > - "pciephy"); > - if (IS_ERR(imx6_pcie->pciephy_reset)) { > - dev_err(dev, "Failed to get PCIEPHY reset control\n"); > - return PTR_ERR(imx6_pcie->pciephy_reset); > - } > - > - imx6_pcie->apps_reset = devm_reset_control_get_exclusive(dev, > - "apps"); > - if (IS_ERR(imx6_pcie->apps_reset)) { > - dev_err(dev, "Failed to get PCIE APPS reset control\n"); > - return PTR_ERR(imx6_pcie->apps_reset); > - } > - break; > - case IMX8MM: > - case IMX8MM_EP: > - case IMX8MP: > - case IMX8MP_EP: > - imx6_pcie->apps_reset = devm_reset_control_get_exclusive(dev, > - "apps"); > + if (imx6_check_flag(imx6_pcie, IMX6_PCIE_FLAG_HAS_APP_RESET)) { > + imx6_pcie->apps_reset = devm_reset_control_get_exclusive(dev, "apps"); [...] I wonder whether we should just defer the check whether apps/pciephy resets should be used to the device tree validation, and make this an unconditional call to get an optional reset control: imx6_pcie->apps_reset = devm_reset_control_get_optional_exclusive(dev, "apps"); regards Philipp