Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2267715pxb; Sun, 17 Oct 2021 10:05:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlLqTPw9TeVgHdQgeca3p8gng000wjxmOi1R0Mlaqy6lLtxYIhI71HMIVDGGVwQYnCHP4r X-Received: by 2002:a17:902:6bc3:b0:13f:8e99:ce74 with SMTP id m3-20020a1709026bc300b0013f8e99ce74mr15967758plt.29.1634490301963; Sun, 17 Oct 2021 10:05:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634490301; cv=none; d=google.com; s=arc-20160816; b=Gu+P5NDOS2Q3yBRAJVUf9Vedx1yMyV4MFwkN32E0WeDEGpNPxkxJSWuI8MiuuLLumF EF8UccLTtQ8vCIc7RcctSGtlreP62a5lqQqt/WhuK500qDBFcbAfStKswVKaLLWGkCyx UfQo+F8/1mx9uN7tyB9jcvox5rc7kvRdX2xOq3WCkHfauKE09o+rUL3FEmSSlY71lqB3 uKJFocqJ2gdJKqsYzssn05+5Hu5qnNckXtO+GkhROrqkBbxnFUbhqqZUap7ODvuL3pds cC2KOx4nTd5Rro80nTavN16BV0ZMkYAaOCm2BYa3UYKUw2CeFG9eMFql946KZ4n00rjK Z1hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=2x4dSD3LhOR5olyf/uwP1t1I+cAfLivFX9u8sZOB+7E=; b=D2iYCn85TFcf5DLSATzkHtviEtOS6+6Li8hfVd5tD/ZqD4JzkaFKfeNwaBLnpBfUB/ 8hYR6G3cf+ec3opyQJeLKX2K+cFkXIlLyZL1Fdrb3dhm8nKf4jZP22YI6Xjk75vNIBel SKoju3QiC10/Pa8/Me6wG7lt5Y6ya4+jPVaXs7/CZF4b88ZHVU/Rvva9wSlR2hy0N5Q4 1cdacQ2Q9meS7efW4xgzgC/gfpKVuyTMrLIBGS3uWnn/4dhcNhXc8ejF0viDcYBxPwVs KDJ2Xi3O79ZflhtqymhrlAFnpmibkUnCa+NRjPmyb5IeQ9XB8nZ+vZKT7qXM7GiBGP+Y 7H/w== 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 h4si375516pfg.350.2021.10.17.10.04.35; Sun, 17 Oct 2021 10:05:01 -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 S242543AbhJOSQE (ORCPT + 99 others); Fri, 15 Oct 2021 14:16:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237653AbhJOSQE (ORCPT ); Fri, 15 Oct 2021 14:16:04 -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 AEDEEC061570 for ; Fri, 15 Oct 2021 11:13:57 -0700 (PDT) Received: from gallifrey.ext.pengutronix.de ([2001:67c:670:201:5054:ff:fe8d:eefb] helo=[IPv6:::1]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mbRiJ-0000MK-T4; Fri, 15 Oct 2021 20:13:51 +0200 Message-ID: Subject: Re: [RESEND v2 1/5] PCI: imx6: Encapsulate the clock enable into one standalone function From: Lucas Stach To: Richard Zhu , bhelgaas@google.com, lorenzo.pieralisi@arm.com Cc: linux-pci@vger.kernel.org, linux-imx@nxp.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@pengutronix.de Date: Fri, 15 Oct 2021 20:13:50 +0200 In-Reply-To: <1634277941-6672-2-git-send-email-hongxing.zhu@nxp.com> References: <1634277941-6672-1-git-send-email-hongxing.zhu@nxp.com> <1634277941-6672-2-git-send-email-hongxing.zhu@nxp.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.40.4 (3.40.4-1.fc34) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 2001:67c:670:201:5054:ff:fe8d:eefb X-SA-Exim-Mail-From: l.stach@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 Am Freitag, dem 15.10.2021 um 14:05 +0800 schrieb Richard Zhu: > No function changes, just encapsulate the i.MX PCIe clocks enable > operations into one standalone function > > Signed-off-by: Richard Zhu Reviewed-by: Lucas Stach > --- > drivers/pci/controller/dwc/pci-imx6.c | 79 ++++++++++++++++----------- > 1 file changed, 48 insertions(+), 31 deletions(-) > > diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c > index 26f49f797b0f..1fa1dba6da81 100644 > --- a/drivers/pci/controller/dwc/pci-imx6.c > +++ b/drivers/pci/controller/dwc/pci-imx6.c > @@ -470,38 +470,16 @@ static int imx6_pcie_enable_ref_clk(struct imx6_pcie *imx6_pcie) > return ret; > } > > -static void imx7d_pcie_wait_for_phy_pll_lock(struct imx6_pcie *imx6_pcie) > -{ > - u32 val; > - struct device *dev = imx6_pcie->pci->dev; > - > - if (regmap_read_poll_timeout(imx6_pcie->iomuxc_gpr, > - IOMUXC_GPR22, val, > - val & IMX7D_GPR22_PCIE_PHY_PLL_LOCKED, > - PHY_PLL_LOCK_WAIT_USLEEP_MAX, > - PHY_PLL_LOCK_WAIT_TIMEOUT)) > - dev_err(dev, "PCIe PLL lock timeout\n"); > -} > - > -static void imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie) > +static int imx6_pcie_clk_enable(struct imx6_pcie *imx6_pcie) > { > struct dw_pcie *pci = imx6_pcie->pci; > struct device *dev = pci->dev; > int ret; > > - if (imx6_pcie->vpcie && !regulator_is_enabled(imx6_pcie->vpcie)) { > - ret = regulator_enable(imx6_pcie->vpcie); > - if (ret) { > - dev_err(dev, "failed to enable vpcie regulator: %d\n", > - ret); > - return; > - } > - } > - > ret = clk_prepare_enable(imx6_pcie->pcie_phy); > if (ret) { > dev_err(dev, "unable to enable pcie_phy clock\n"); > - goto err_pcie_phy; > + return ret; > } > > ret = clk_prepare_enable(imx6_pcie->pcie_bus); > @@ -524,6 +502,51 @@ static void imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie) > > /* allow the clocks to stabilize */ > usleep_range(200, 500); > + return 0; > + > +err_ref_clk: > + clk_disable_unprepare(imx6_pcie->pcie); > +err_pcie: > + clk_disable_unprepare(imx6_pcie->pcie_bus); > +err_pcie_bus: > + clk_disable_unprepare(imx6_pcie->pcie_phy); > + > + return ret; > +} > + > +static void imx7d_pcie_wait_for_phy_pll_lock(struct imx6_pcie *imx6_pcie) > +{ > + u32 val; > + struct device *dev = imx6_pcie->pci->dev; > + > + if (regmap_read_poll_timeout(imx6_pcie->iomuxc_gpr, > + IOMUXC_GPR22, val, > + val & IMX7D_GPR22_PCIE_PHY_PLL_LOCKED, > + PHY_PLL_LOCK_WAIT_USLEEP_MAX, > + PHY_PLL_LOCK_WAIT_TIMEOUT)) > + dev_err(dev, "PCIe PLL lock timeout\n"); > +} > + > +static void imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie) > +{ > + struct dw_pcie *pci = imx6_pcie->pci; > + struct device *dev = pci->dev; > + int ret; > + > + if (imx6_pcie->vpcie && !regulator_is_enabled(imx6_pcie->vpcie)) { > + ret = regulator_enable(imx6_pcie->vpcie); > + if (ret) { > + dev_err(dev, "failed to enable vpcie regulator: %d\n", > + ret); > + return; > + } > + } > + > + ret = imx6_pcie_clk_enable(imx6_pcie); > + if (ret) { > + dev_err(dev, "unable to enable pcie clocks\n"); > + goto err_clks; > + } > > /* Some boards don't have PCIe reset GPIO. */ > if (gpio_is_valid(imx6_pcie->reset_gpio)) { > @@ -578,13 +601,7 @@ static void imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie) > > return; > > -err_ref_clk: > - clk_disable_unprepare(imx6_pcie->pcie); > -err_pcie: > - clk_disable_unprepare(imx6_pcie->pcie_bus); > -err_pcie_bus: > - clk_disable_unprepare(imx6_pcie->pcie_phy); > -err_pcie_phy: > +err_clks: > if (imx6_pcie->vpcie && regulator_is_enabled(imx6_pcie->vpcie) > 0) { > ret = regulator_disable(imx6_pcie->vpcie); > if (ret)