Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2522481lqo; Tue, 14 May 2024 00:51:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWW70NWYuN/+XoOXYDMUA6mdS+Z4sv9NpGlGX2d468sVj+qObr1SZ+BqS2xHRUtEJapP9EE0sJEl7LqXakQ/zQLMG51Ls39VYtFn70Vnw== X-Google-Smtp-Source: AGHT+IH1glTJ3n22UHDIYaWSz28V6MGysKvzJ72sTV9sW13yb4yeKYiNP8p6OkR9xYedeL9ByBY/ X-Received: by 2002:a05:6359:5a8f:b0:18e:a0ce:a005 with SMTP id e5c5f4694b2df-193bcff1a66mr976527355d.29.1715673081148; Tue, 14 May 2024 00:51:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715673081; cv=pass; d=google.com; s=arc-20160816; b=qzEwgw3aTQfxS6l5FFRpOnRngW6uVoh9UyKh8ooseFDSlUaMExKO2tszFvAClw5t8J tnoC739W9dhZxKmCu52CAemnRwbKzCb0aX5EtBnBsjRMg+yAWsBOZ7eHbY0WwyFXhdTs kYD+Ivf7HqW8+Ywjs1hIzprG6ZNXUIVI9k/pwVYY3dnGz9y3h15NCfvgMrKsgDu/L9kL Kn//02peQi8HwMt7wOlsPuiJZ01vogGxvq+pAe5dfKxNg1zlI4aUmc5LrCuESbxREW4k nYMFTDwbJCOyntgD4LW7jbutYEK34m3QMO1EooZo+5Ag+8drln/TUXCBDFQyZuXtSuoJ ViEA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=8BO15yDmXpBmEarxhd2q42jHVox3qmbWZ3jkNFDgX8g=; fh=5eT1TDb+5MYH87OK1tAy9fLIXy7SeQQaWnKzPdY+qWU=; b=pnqnmPbga73YXxZwMHKyrTlTlWro9pFMIYf1hNr/849tZm0my4z2a9QlWm0lRdNVjK uTK3x5IVx0D0che7yyg5OqgY2t1Lwu/RW7ROOSvE+RbJLGNbdMZ+cCDTuT9IX1to9Z0v j10uujE7ZPEDcc/OR9GouQ4wXHUBk8egGSP+kD5WG3saGxZKf6wm+iFIfhT8lx6EnpTu +3uBHv0VCwZzC3G/yxGvVnH45VH9uLAKetHzTSwvXTP4Cnx3AazrKXEYBxIjkeHOrGJD 5K3oCmtTpb3sOb6ePrq4NM5n845Gs1y++H482i9StBc6vzPSkc0ZUxkleurNTulafyWp RGhQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=n+02EKDX; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-178416-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178416-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-63413d71417si11098245a12.812.2024.05.14.00.51.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 00:51:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-178416-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=n+02EKDX; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-178416-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178416-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id B132C283759 for ; Tue, 14 May 2024 07:51:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4814514A8F; Tue, 14 May 2024 07:51:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="n+02EKDX" Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF36F14A85 for ; Tue, 14 May 2024 07:51:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715673069; cv=none; b=k9HiVkGFMjqxzTg2QV6U9FRC1+bMNp2EoyLUOLgjzYBInwxw2gXQ48ObmbAlYts7L4XcgE6vNKwBYDFLNhUWs2iEoWXcVVeEpnGa5JKSfalX1SiRN+CFcGQj2QYu6O37tE/lfS+8Ou2iERwgpq6Zady38cgJKrTAxJRDn6qs8iM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715673069; c=relaxed/simple; bh=krG1zVaK3l/29Cmol8z1CCc8GFVbvQaFOBN40o6k7w0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=e+k1GLqsYdLCkolBbh83om+UqcxA9ch/e/8hJPLc5AeR4CiKPine1F0YXmtT7BnV7JfSl7SpjgBX/wv3qBzP2lM1glzXA8BlzozBFe5ciFCuZM+DDAW3RpKUpaAZhcEDb/19w5yuHG2honqI58CMJ7e7Dcrilj80FR2YlIMoqzc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=n+02EKDX; arc=none smtp.client-ip=209.85.218.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-a5a88339780so59089166b.0 for ; Tue, 14 May 2024 00:51:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715673066; x=1716277866; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=8BO15yDmXpBmEarxhd2q42jHVox3qmbWZ3jkNFDgX8g=; b=n+02EKDX4aYaz2vVM7OUNUQ+1V7r/lcX/XwTeiBbBKfnCzZE+iA18MGFbt3X3+YGV2 Ywa9AYXw0TUmiQ00NH3nOdM7GiPIzJLf4/uCjUM5OwQ3Oj3WcDVB4Eis62AmX15/oTGy 5DtCfvEcSn+eDxLxxfVHke1yfsbVCe2vFmQkevx7uI0hOd2qDdBKbRTIBhsP3EhZaFnq 5V71v6GI9oZv48tiaHV1918k7LQ8WPLmhKd4rzVjkou7E8ypbhFEbTIfhkJl51Fv5ctA r1BzZ0qLvDEXOBnwfL1KiCLetTIALWIwDHIUdSjevkZJA6GgAhge+iGC1DmQi6gYwNqA +bKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715673066; x=1716277866; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8BO15yDmXpBmEarxhd2q42jHVox3qmbWZ3jkNFDgX8g=; b=I0+jE6rJBQ0ejSMCqwTBTp5j3x6Ttr0QKL3fqbc8UGfbrZ8xEqz/gTIbk0QY6eWV7b 7n7q28swew2S4qLnHMlRWtgj+PWlSLa05Dwemz0Uv7+f2AVIEo9etD0FbVcZnbwxmy+z SyiDepj1kwRCczDCsGcSOznxlSl3o4KbP1343C2JfgJZS1FhwC7ggMu6GoLai/7fDOwN ilgOE7KTWeaEXARInDkxjqLeA8mQMbesUCYh/HnZP4VuZNFZZqPMPTidD5snE3d40vdC 8m7Xf/8yH46+2EWSqhewNq9UHeSMkRnvaiKt9MiLGPBxkAKiBrHMtdRCRWUN2zqsT5LS 8B5g== X-Forwarded-Encrypted: i=1; AJvYcCUTduAICkM+vja5k4v6Jy2ZDNct9eDs5Ek9gILfvu9fCC76Guls+vEofO9dQzAfbXImHd/NOcj6TwpuLsThXaBBH7GSuaFOv904eE0G X-Gm-Message-State: AOJu0Yxkbk3tKyxrkyZ1dAg+bts7cHef57NeA7a/NPCxIRiN4Ka/8Pqd Q4V9HkjSH+RZhVGEPSLb9GSNhXTRzoPfjStFh5cu91z9I8BITccSG+75FTMj8w== X-Received: by 2002:a50:d516:0:b0:56f:e75b:83aa with SMTP id 4fb4d7f45d1cf-5734d5c17b7mr8876915a12.6.1715673065886; Tue, 14 May 2024 00:51:05 -0700 (PDT) Received: from thinkpad ([149.14.240.163]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5733bed000esm7215529a12.54.2024.05.14.00.51.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 00:51:05 -0700 (PDT) Date: Tue, 14 May 2024 09:51:04 +0200 From: Manivannan Sadhasivam To: Alexandru Gagniuc Cc: Bjorn Andersson , Konrad Dybcio , Lorenzo Pieralisi , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Krzysztof Kozlowski , Conor Dooley , Vinod Koul , Kishon Vijay Abraham I , Michael Turquette , Stephen Boyd , linux-arm-msm@vger.kernel.org, linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org, linux-clk@vger.kernel.org Subject: Re: [PATCH v4 RESEND 4/8] PCI: qcom: Switch to devm_clk_bulk_get_all() API to get the clocks from Devicetree Message-ID: <20240514075104.GC2463@thinkpad> References: <20240501042847.1545145-1-mr.nuke.me@gmail.com> <20240501042847.1545145-5-mr.nuke.me@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240501042847.1545145-5-mr.nuke.me@gmail.com> On Tue, Apr 30, 2024 at 11:28:43PM -0500, Alexandru Gagniuc wrote: > From: Manivannan Sadhasivam > > There is no need for the device drivers to validate the clocks defined in > Devicetree. The validation should be performed by the DT schema and the > drivers should just get all the clocks from DT. Right now the driver > hardcodes the clock info and validates them against DT which is redundant. > > So use devm_clk_bulk_get_all() that just gets all the clocks defined in DT > and get rid of all static clocks info from the driver. This simplifies the > driver. > > Signed-off-by: Manivannan Sadhasivam > Signed-off-by: Alexandru Gagniuc > [moved clks to struct qcom_pcie to reduce code duplication] This patch is already applied to pci tree. So hopefully you can just rebase it on top of pci/next for next version (it should get updated soon). - Mani > --- > drivers/pci/controller/dwc/pcie-qcom.c | 163 ++++--------------------- > 1 file changed, 25 insertions(+), 138 deletions(-) > > diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c > index 14772edcf0d3..ea81ff68d433 100644 > --- a/drivers/pci/controller/dwc/pcie-qcom.c > +++ b/drivers/pci/controller/dwc/pcie-qcom.c > @@ -154,58 +154,42 @@ > #define QCOM_PCIE_LINK_SPEED_TO_BW(speed) \ > Mbps_to_icc(PCIE_SPEED2MBS_ENC(pcie_link_speed[speed])) > > -#define QCOM_PCIE_1_0_0_MAX_CLOCKS 4 > struct qcom_pcie_resources_1_0_0 { > - struct clk_bulk_data clks[QCOM_PCIE_1_0_0_MAX_CLOCKS]; > struct reset_control *core; > struct regulator *vdda; > }; > > -#define QCOM_PCIE_2_1_0_MAX_CLOCKS 5 > #define QCOM_PCIE_2_1_0_MAX_RESETS 6 > #define QCOM_PCIE_2_1_0_MAX_SUPPLY 3 > struct qcom_pcie_resources_2_1_0 { > - struct clk_bulk_data clks[QCOM_PCIE_2_1_0_MAX_CLOCKS]; > struct reset_control_bulk_data resets[QCOM_PCIE_2_1_0_MAX_RESETS]; > int num_resets; > struct regulator_bulk_data supplies[QCOM_PCIE_2_1_0_MAX_SUPPLY]; > }; > > -#define QCOM_PCIE_2_3_2_MAX_CLOCKS 4 > #define QCOM_PCIE_2_3_2_MAX_SUPPLY 2 > struct qcom_pcie_resources_2_3_2 { > - struct clk_bulk_data clks[QCOM_PCIE_2_3_2_MAX_CLOCKS]; > struct regulator_bulk_data supplies[QCOM_PCIE_2_3_2_MAX_SUPPLY]; > }; > > -#define QCOM_PCIE_2_3_3_MAX_CLOCKS 5 > #define QCOM_PCIE_2_3_3_MAX_RESETS 7 > struct qcom_pcie_resources_2_3_3 { > - struct clk_bulk_data clks[QCOM_PCIE_2_3_3_MAX_CLOCKS]; > struct reset_control_bulk_data rst[QCOM_PCIE_2_3_3_MAX_RESETS]; > }; > > -#define QCOM_PCIE_2_4_0_MAX_CLOCKS 4 > #define QCOM_PCIE_2_4_0_MAX_RESETS 12 > struct qcom_pcie_resources_2_4_0 { > - struct clk_bulk_data clks[QCOM_PCIE_2_4_0_MAX_CLOCKS]; > - int num_clks; > struct reset_control_bulk_data resets[QCOM_PCIE_2_4_0_MAX_RESETS]; > int num_resets; > }; > > -#define QCOM_PCIE_2_7_0_MAX_CLOCKS 15 > #define QCOM_PCIE_2_7_0_MAX_SUPPLIES 2 > struct qcom_pcie_resources_2_7_0 { > - struct clk_bulk_data clks[QCOM_PCIE_2_7_0_MAX_CLOCKS]; > - int num_clks; > struct regulator_bulk_data supplies[QCOM_PCIE_2_7_0_MAX_SUPPLIES]; > struct reset_control *rst; > }; > > -#define QCOM_PCIE_2_9_0_MAX_CLOCKS 5 > struct qcom_pcie_resources_2_9_0 { > - struct clk_bulk_data clks[QCOM_PCIE_2_9_0_MAX_CLOCKS]; > struct reset_control *rst; > }; > > @@ -247,6 +231,8 @@ struct qcom_pcie { > struct icc_path *icc_mem; > const struct qcom_pcie_cfg *cfg; > struct dentry *debugfs; > + struct clk_bulk_data *clks; > + int num_clks; > bool suspended; > }; > > @@ -337,22 +323,6 @@ static int qcom_pcie_get_resources_2_1_0(struct qcom_pcie *pcie) > if (ret) > return ret; > > - res->clks[0].id = "iface"; > - res->clks[1].id = "core"; > - res->clks[2].id = "phy"; > - res->clks[3].id = "aux"; > - res->clks[4].id = "ref"; > - > - /* iface, core, phy are required */ > - ret = devm_clk_bulk_get(dev, 3, res->clks); > - if (ret < 0) > - return ret; > - > - /* aux, ref are optional */ > - ret = devm_clk_bulk_get_optional(dev, 2, res->clks + 3); > - if (ret < 0) > - return ret; > - > res->resets[0].id = "pci"; > res->resets[1].id = "axi"; > res->resets[2].id = "ahb"; > @@ -373,7 +343,7 @@ static void qcom_pcie_deinit_2_1_0(struct qcom_pcie *pcie) > { > struct qcom_pcie_resources_2_1_0 *res = &pcie->res.v2_1_0; > > - clk_bulk_disable_unprepare(ARRAY_SIZE(res->clks), res->clks); > + clk_bulk_disable_unprepare(pcie->num_clks, pcie->clks); > reset_control_bulk_assert(res->num_resets, res->resets); > > writel(1, pcie->parf + PARF_PHY_CTRL); > @@ -413,7 +383,6 @@ static int qcom_pcie_init_2_1_0(struct qcom_pcie *pcie) > > static int qcom_pcie_post_init_2_1_0(struct qcom_pcie *pcie) > { > - struct qcom_pcie_resources_2_1_0 *res = &pcie->res.v2_1_0; > struct dw_pcie *pci = pcie->pci; > struct device *dev = pci->dev; > struct device_node *node = dev->of_node; > @@ -425,7 +394,7 @@ static int qcom_pcie_post_init_2_1_0(struct qcom_pcie *pcie) > val &= ~PHY_TEST_PWR_DOWN; > writel(val, pcie->parf + PARF_PHY_CTRL); > > - ret = clk_bulk_prepare_enable(ARRAY_SIZE(res->clks), res->clks); > + ret = clk_bulk_prepare_enable(pcie->num_clks, pcie->clks); > if (ret) > return ret; > > @@ -476,21 +445,11 @@ static int qcom_pcie_get_resources_1_0_0(struct qcom_pcie *pcie) > struct qcom_pcie_resources_1_0_0 *res = &pcie->res.v1_0_0; > struct dw_pcie *pci = pcie->pci; > struct device *dev = pci->dev; > - int ret; > > res->vdda = devm_regulator_get(dev, "vdda"); > if (IS_ERR(res->vdda)) > return PTR_ERR(res->vdda); > > - res->clks[0].id = "iface"; > - res->clks[1].id = "aux"; > - res->clks[2].id = "master_bus"; > - res->clks[3].id = "slave_bus"; > - > - ret = devm_clk_bulk_get(dev, ARRAY_SIZE(res->clks), res->clks); > - if (ret < 0) > - return ret; > - > res->core = devm_reset_control_get_exclusive(dev, "core"); > return PTR_ERR_OR_ZERO(res->core); > } > @@ -500,7 +459,7 @@ static void qcom_pcie_deinit_1_0_0(struct qcom_pcie *pcie) > struct qcom_pcie_resources_1_0_0 *res = &pcie->res.v1_0_0; > > reset_control_assert(res->core); > - clk_bulk_disable_unprepare(ARRAY_SIZE(res->clks), res->clks); > + clk_bulk_disable_unprepare(pcie->num_clks, pcie->clks); > regulator_disable(res->vdda); > } > > @@ -517,7 +476,7 @@ static int qcom_pcie_init_1_0_0(struct qcom_pcie *pcie) > return ret; > } > > - ret = clk_bulk_prepare_enable(ARRAY_SIZE(res->clks), res->clks); > + ret = clk_bulk_prepare_enable(pcie->num_clks, pcie->clks); > if (ret) { > dev_err(dev, "cannot prepare/enable clocks\n"); > goto err_assert_reset; > @@ -532,7 +491,7 @@ static int qcom_pcie_init_1_0_0(struct qcom_pcie *pcie) > return 0; > > err_disable_clks: > - clk_bulk_disable_unprepare(ARRAY_SIZE(res->clks), res->clks); > + clk_bulk_disable_unprepare(pcie->num_clks, pcie->clks); > err_assert_reset: > reset_control_assert(res->core); > > @@ -580,15 +539,6 @@ static int qcom_pcie_get_resources_2_3_2(struct qcom_pcie *pcie) > if (ret) > return ret; > > - res->clks[0].id = "aux"; > - res->clks[1].id = "cfg"; > - res->clks[2].id = "bus_master"; > - res->clks[3].id = "bus_slave"; > - > - ret = devm_clk_bulk_get(dev, ARRAY_SIZE(res->clks), res->clks); > - if (ret < 0) > - return ret; > - > return 0; > } > > @@ -596,7 +546,7 @@ static void qcom_pcie_deinit_2_3_2(struct qcom_pcie *pcie) > { > struct qcom_pcie_resources_2_3_2 *res = &pcie->res.v2_3_2; > > - clk_bulk_disable_unprepare(ARRAY_SIZE(res->clks), res->clks); > + clk_bulk_disable_unprepare(pcie->num_clks, pcie->clks); > regulator_bulk_disable(ARRAY_SIZE(res->supplies), res->supplies); > } > > @@ -613,7 +563,7 @@ static int qcom_pcie_init_2_3_2(struct qcom_pcie *pcie) > return ret; > } > > - ret = clk_bulk_prepare_enable(ARRAY_SIZE(res->clks), res->clks); > + ret = clk_bulk_prepare_enable(pcie->num_clks, pcie->clks); > if (ret) { > dev_err(dev, "cannot prepare/enable clocks\n"); > regulator_bulk_disable(ARRAY_SIZE(res->supplies), res->supplies); > @@ -661,18 +611,6 @@ static int qcom_pcie_get_resources_2_4_0(struct qcom_pcie *pcie) > bool is_ipq = of_device_is_compatible(dev->of_node, "qcom,pcie-ipq4019"); > int ret; > > - res->clks[0].id = "aux"; > - res->clks[1].id = "master_bus"; > - res->clks[2].id = "slave_bus"; > - res->clks[3].id = "iface"; > - > - /* qcom,pcie-ipq4019 is defined without "iface" */ > - res->num_clks = is_ipq ? 3 : 4; > - > - ret = devm_clk_bulk_get(dev, res->num_clks, res->clks); > - if (ret < 0) > - return ret; > - > res->resets[0].id = "axi_m"; > res->resets[1].id = "axi_s"; > res->resets[2].id = "axi_m_sticky"; > @@ -700,7 +638,7 @@ static void qcom_pcie_deinit_2_4_0(struct qcom_pcie *pcie) > struct qcom_pcie_resources_2_4_0 *res = &pcie->res.v2_4_0; > > reset_control_bulk_assert(res->num_resets, res->resets); > - clk_bulk_disable_unprepare(res->num_clks, res->clks); > + clk_bulk_disable_unprepare(pcie->num_clks, pcie->clks); > } > > static int qcom_pcie_init_2_4_0(struct qcom_pcie *pcie) > @@ -726,7 +664,7 @@ static int qcom_pcie_init_2_4_0(struct qcom_pcie *pcie) > > usleep_range(10000, 12000); > > - ret = clk_bulk_prepare_enable(res->num_clks, res->clks); > + ret = clk_bulk_prepare_enable(pcie->num_clks, pcie->clks); > if (ret) { > reset_control_bulk_assert(res->num_resets, res->resets); > return ret; > @@ -742,16 +680,6 @@ static int qcom_pcie_get_resources_2_3_3(struct qcom_pcie *pcie) > struct device *dev = pci->dev; > int ret; > > - res->clks[0].id = "iface"; > - res->clks[1].id = "axi_m"; > - res->clks[2].id = "axi_s"; > - res->clks[3].id = "ahb"; > - res->clks[4].id = "aux"; > - > - ret = devm_clk_bulk_get(dev, ARRAY_SIZE(res->clks), res->clks); > - if (ret < 0) > - return ret; > - > res->rst[0].id = "axi_m"; > res->rst[1].id = "axi_s"; > res->rst[2].id = "pipe"; > @@ -769,9 +697,7 @@ static int qcom_pcie_get_resources_2_3_3(struct qcom_pcie *pcie) > > static void qcom_pcie_deinit_2_3_3(struct qcom_pcie *pcie) > { > - struct qcom_pcie_resources_2_3_3 *res = &pcie->res.v2_3_3; > - > - clk_bulk_disable_unprepare(ARRAY_SIZE(res->clks), res->clks); > + clk_bulk_disable_unprepare(pcie->num_clks, pcie->clks); > } > > static int qcom_pcie_init_2_3_3(struct qcom_pcie *pcie) > @@ -801,7 +727,7 @@ static int qcom_pcie_init_2_3_3(struct qcom_pcie *pcie) > */ > usleep_range(2000, 2500); > > - ret = clk_bulk_prepare_enable(ARRAY_SIZE(res->clks), res->clks); > + ret = clk_bulk_prepare_enable(pcie->num_clks, pcie->clks); > if (ret) { > dev_err(dev, "cannot prepare/enable clocks\n"); > goto err_assert_resets; > @@ -862,8 +788,6 @@ static int qcom_pcie_get_resources_2_7_0(struct qcom_pcie *pcie) > struct qcom_pcie_resources_2_7_0 *res = &pcie->res.v2_7_0; > struct dw_pcie *pci = pcie->pci; > struct device *dev = pci->dev; > - unsigned int num_clks, num_opt_clks; > - unsigned int idx; > int ret; > > res->rst = devm_reset_control_array_get_exclusive(dev); > @@ -877,37 +801,6 @@ static int qcom_pcie_get_resources_2_7_0(struct qcom_pcie *pcie) > if (ret) > return ret; > > - idx = 0; > - res->clks[idx++].id = "aux"; > - res->clks[idx++].id = "cfg"; > - res->clks[idx++].id = "bus_master"; > - res->clks[idx++].id = "bus_slave"; > - res->clks[idx++].id = "slave_q2a"; > - > - num_clks = idx; > - > - ret = devm_clk_bulk_get(dev, num_clks, res->clks); > - if (ret < 0) > - return ret; > - > - res->clks[idx++].id = "tbu"; > - res->clks[idx++].id = "ddrss_sf_tbu"; > - res->clks[idx++].id = "aggre0"; > - res->clks[idx++].id = "aggre1"; > - res->clks[idx++].id = "noc_aggr"; > - res->clks[idx++].id = "noc_aggr_4"; > - res->clks[idx++].id = "noc_aggr_south_sf"; > - res->clks[idx++].id = "cnoc_qx"; > - res->clks[idx++].id = "sleep"; > - res->clks[idx++].id = "cnoc_sf_axi"; > - > - num_opt_clks = idx - num_clks; > - res->num_clks = idx; > - > - ret = devm_clk_bulk_get_optional(dev, num_opt_clks, res->clks + num_clks); > - if (ret < 0) > - return ret; > - > return 0; > } > > @@ -925,7 +818,7 @@ static int qcom_pcie_init_2_7_0(struct qcom_pcie *pcie) > return ret; > } > > - ret = clk_bulk_prepare_enable(res->num_clks, res->clks); > + ret = clk_bulk_prepare_enable(pcie->num_clks, pcie->clks); > if (ret < 0) > goto err_disable_regulators; > > @@ -977,7 +870,7 @@ static int qcom_pcie_init_2_7_0(struct qcom_pcie *pcie) > > return 0; > err_disable_clocks: > - clk_bulk_disable_unprepare(res->num_clks, res->clks); > + clk_bulk_disable_unprepare(pcie->num_clks, pcie->clks); > err_disable_regulators: > regulator_bulk_disable(ARRAY_SIZE(res->supplies), res->supplies); > > @@ -1015,7 +908,7 @@ static void qcom_pcie_deinit_2_7_0(struct qcom_pcie *pcie) > { > struct qcom_pcie_resources_2_7_0 *res = &pcie->res.v2_7_0; > > - clk_bulk_disable_unprepare(res->num_clks, res->clks); > + clk_bulk_disable_unprepare(pcie->num_clks, pcie->clks); > > regulator_bulk_disable(ARRAY_SIZE(res->supplies), res->supplies); > } > @@ -1101,17 +994,6 @@ static int qcom_pcie_get_resources_2_9_0(struct qcom_pcie *pcie) > struct qcom_pcie_resources_2_9_0 *res = &pcie->res.v2_9_0; > struct dw_pcie *pci = pcie->pci; > struct device *dev = pci->dev; > - int ret; > - > - res->clks[0].id = "iface"; > - res->clks[1].id = "axi_m"; > - res->clks[2].id = "axi_s"; > - res->clks[3].id = "axi_bridge"; > - res->clks[4].id = "rchng"; > - > - ret = devm_clk_bulk_get(dev, ARRAY_SIZE(res->clks), res->clks); > - if (ret < 0) > - return ret; > > res->rst = devm_reset_control_array_get_exclusive(dev); > if (IS_ERR(res->rst)) > @@ -1122,9 +1004,7 @@ static int qcom_pcie_get_resources_2_9_0(struct qcom_pcie *pcie) > > static void qcom_pcie_deinit_2_9_0(struct qcom_pcie *pcie) > { > - struct qcom_pcie_resources_2_9_0 *res = &pcie->res.v2_9_0; > - > - clk_bulk_disable_unprepare(ARRAY_SIZE(res->clks), res->clks); > + clk_bulk_disable_unprepare(pcie->num_clks, pcie->clks); > } > > static int qcom_pcie_init_2_9_0(struct qcom_pcie *pcie) > @@ -1153,7 +1033,7 @@ static int qcom_pcie_init_2_9_0(struct qcom_pcie *pcie) > > usleep_range(2000, 2500); > > - return clk_bulk_prepare_enable(ARRAY_SIZE(res->clks), res->clks); > + return clk_bulk_prepare_enable(pcie->num_clks, pcie->clks); > } > > static int qcom_pcie_post_init_2_9_0(struct qcom_pcie *pcie) > @@ -1561,6 +1441,13 @@ static int qcom_pcie_probe(struct platform_device *pdev) > goto err_pm_runtime_put; > } > > + pcie->num_clks = devm_clk_bulk_get_all(dev, &pcie->clks); > + if (pcie->num_clks < 0) { > + ret = pcie->num_clks; > + dev_err(dev, "Failed to get clocks\n"); > + goto err_pm_runtime_put; > + } > + > ret = qcom_pcie_icc_init(pcie); > if (ret) > goto err_pm_runtime_put; > -- > 2.40.1 > -- மணிவண்ணன் சதாசிவம்