Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp435083lqb; Wed, 17 Apr 2024 00:03:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXxDMKEZexTiAdZqbdGAT3ojoCMeqmmEsaRMLtdRVK74mWlat2c0V8IFRqQOhUAzrsZ4WYLJvp23tS2+s+OvGfeYh2umr6ZxQuVqh/ecw== X-Google-Smtp-Source: AGHT+IHtc3qCaN4n/h/x+V3dtDeo6pJCF/qpa+5TjuVbOnCj3ctJZkPo+GUEXjWVYRk6i6liTH/A X-Received: by 2002:a50:d7d8:0:b0:56b:ec47:a846 with SMTP id m24-20020a50d7d8000000b0056bec47a846mr9317354edj.25.1713337406739; Wed, 17 Apr 2024 00:03:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713337406; cv=pass; d=google.com; s=arc-20160816; b=YpDsOD44H+uVu3zfsApxujzylJauWREqEQtaZY7y6LXbnxlhbKoVE0dsAh+UvzLtgd HECCMRx7njNWt5s6ThBjcR59A8GlCrOUqySWf27NTNrb/F2R9WXovxEIGdTx8LADLA+t IyIkGxtRxhnutZV6VakamfpQIRIMolYOl5NTfYCLU0ZlTo6xXyY8Huow6tEVw2P003M0 k8ql2vgZrQbt16nnQR0bqG5s6Ev4acZBRGiJgZRFyo7xSS5m7xSUXaRwIq67j3sHWI5O dORRo87WgVfw5YTeLGTv2xyZHGlkWlzdYpyvsbZNWZegBnJH1JrAouyN9iGulWbsMPRj 4Uww== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:message-id:content-transfer-encoding:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:subject:date :from:dkim-signature; bh=NQWKlRWSEEy/WJ4wVuQ4VDIZfM4ZRFArXby6OLRDTnM=; fh=M7p/ro5s/T2Lnn+dajKefSomVlPjHeWXRh56Co1PTWg=; b=HtVnISxqiiTqf1yt19zDwc7u+YS9VCwKJkGPB1MJar+tGiK8ZiBFD0snxqsKM9q3Yh QA4lQXgx7NHM9FFTeBE1x5rHtk08Ap8CXosVJ7DTc//d5aJ68iKahszPEVVNv+9rmJ+G JhdN8vnWCLHJqkcZg79aj79/s8UvNTwt7HPq08VFq1d/LFGLvcaW6ZR53So3SGBHeQlr 1xYDveXtLlmQw//Bjdz0sewpv2O+6+fEBBwsISLq7F8Bh4+Q8ZvendNkeJzqWLzmfRlJ lQ4Mvh3KwUdoDtk6QS+1/2KAulzzwEenFt/+RHe91p5byEkMltFmdZL46n/rYkdQqtbJ U6BQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="mPp/P2Ax"; 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-148020-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-148020-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id m11-20020a056402430b00b0056e5c0153c1si6784759edc.648.2024.04.17.00.03.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 00:03:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-148020-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="mPp/P2Ax"; 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-148020-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-148020-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 4EB1D1F22372 for ; Wed, 17 Apr 2024 07:03:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 127336A33B; Wed, 17 Apr 2024 07:03:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="mPp/P2Ax" Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (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 DD0DA6A329 for ; Wed, 17 Apr 2024 07:03:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713337398; cv=none; b=WzRKS4FAbssfU3c8x2+xusAWUMCwAmFx6/ZDfZYJnpfl9AqwFd+wG43loE49Uo+wUuKY5wm80zEbXg1H2Cq5OO7HJOHZFE5prlzpqBsjALK07Kdo0sZILYoJ/YOFqWeYdqFn5S7kjjX1HTrZqTsW3x1urmQjF+KJ8CMKdzTZuC8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713337398; c=relaxed/simple; bh=+Szd0m7hc5ADliFv9J2r/gh6GKw8SfbHVeninK/Duxk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=f2wZTODv5KByfKK+nDA94gEZMc69NZIa2+CWef+10n1F4o61voSFZz2Hl6Mdbbk5bPOs0ZZiczUZzlFurmbQtjOpLWDA3ID5FG+Im83H9t8P/fO1iN2PgBV6Af2lPvWF949YaFd2yhSNB1SE5EOmf3pejK+oDbyud22VgVlaExA= 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=mPp/P2Ax; arc=none smtp.client-ip=209.85.210.180 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-pf1-f180.google.com with SMTP id d2e1a72fcca58-6ece8991654so4715067b3a.3 for ; Wed, 17 Apr 2024 00:03:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713337396; x=1713942196; darn=vger.kernel.org; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=NQWKlRWSEEy/WJ4wVuQ4VDIZfM4ZRFArXby6OLRDTnM=; b=mPp/P2AxA1geoMv0L1THoCUjCCa0ZJRgp5VHoPHDW5dKhD4/q3T5T+j9I52ZuXpPN5 +E85TFwAMJP1raHI5nKqSJBimlKBK1Pm9lqIXCo4xb8k24FwgFUdD8A0NqS2PD/n8FpA vg06hMVaJnwxR/D26P8X1QmbPJJ9lWgy5oGEjGhijMOoXmORFJhWaMgHfFruVv3oG3nJ mw+8aL6yCx4IltAVLxYN5Mc84ivUOWA3XrYU/F/iAuuvJmnctHhzDuiLEIa/kc8BzGjG k6y2vhFW/K+KW1M2byQbaxPnV+8xoy4bVLUME9QL76lQwVP5a8s8R4N2+gKRJ0+FYjES v5sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713337396; x=1713942196; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=NQWKlRWSEEy/WJ4wVuQ4VDIZfM4ZRFArXby6OLRDTnM=; b=Mb/b367ycX/dsLAar9q9IUIZ2bbviUxE7ec9d7sYfbFP5CUPIJFawN/jnn/q4ZksPT 3xF7dFFHhHzENaorJpu2BbtAHQlmRpajF1nSSUjmrj+95kuNvBvA7EzvuxVicmNaOQab 31hOKrLiqyzyG4OK5RpbLNLslkYecvSvpvxD8mXHrEkygIwV+avW/vBwDJnjkr5f3kwr wR+54E2XXtbB+xtzB5oc9TaMuFRp3ARtndl5MJR8bFCQOc7iNQ+erxkaVu7LPOoXaGze 2d1Blk0fp5BKA/M69oWN8ygGIfGGAMd1AMYnDySzElYnXCMynptZ+ad4LmlQTxew8kna iLIQ== X-Forwarded-Encrypted: i=1; AJvYcCV/NeOM8RthMuRgPr1u1a3P5IH6TX48mzgcqXdq5VmSWjvERTbpaZVjtxGaw09Sbdn+CzbuM2o9kHOwlYAB/Fg3b0m9Lfu1TGDmiVvH X-Gm-Message-State: AOJu0Yx/DGePCyaECM9bApNcuGwOUe3H1mGowrX2E34LAgJX/NxVRpAe rbfAkkEkFDCHFHRQRmi7TweQyYne+qQbNZwCBcLsemRhU5jB1nZpd3MZh++emQ== X-Received: by 2002:a05:6a00:9285:b0:6ed:416d:f86 with SMTP id jw5-20020a056a00928500b006ed416d0f86mr22646628pfb.15.1713337395276; Wed, 17 Apr 2024 00:03:15 -0700 (PDT) Received: from [127.0.1.1] ([120.60.54.9]) by smtp.gmail.com with ESMTPSA id ga22-20020a056a00621600b006ecf56cb55fsm10349771pfb.96.2024.04.17.00.03.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 00:03:14 -0700 (PDT) From: Manivannan Sadhasivam Date: Wed, 17 Apr 2024 12:32:53 +0530 Subject: [PATCH] PCI: qcom: Switch to devm_clk_bulk_get_all() API to get the clocks from Devicetree 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-Transfer-Encoding: 7bit Message-Id: <20240417-pci-qcom-clk-bulk-v1-1-52ca19b3d6b2@linaro.org> X-B4-Tracking: v=1; b=H4sIABx0H2YC/x2MQQ5AMBAAvyJ7tgklob4iDrUWG7S0IRLxd43LJ HOYeSCwFw7QJA94viSIs1HyNAGajZ0YZYgOKlNlVuYV7iR4kNuQ1gX7M6Ko9agrZVgrA7HbPY9 y/8+2e98P++V/rGMAAAA= To: Bjorn Andersson , Konrad Dybcio , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas Cc: linux-pci@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=12747; i=manivannan.sadhasivam@linaro.org; h=from:subject:message-id; bh=+Szd0m7hc5ADliFv9J2r/gh6GKw8SfbHVeninK/Duxk=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBmH3Qv25M05uztUbVZD0RxoawN8s9Osy/JH3tpw Hr7KxW7bhiJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCZh90LwAKCRBVnxHm/pHO 9TUdB/0T2Il1+zxUpOwNsMnPickdbfCAfszUY6sSonbPDPJTku6Ili0iSGhjYk5sx6W7GdK4zeJ VUmMTI8MKq8Ftw9IhLpduhKJ3LNagqFNBhhs06BXIhbWAES0OIrS/pV+HId6eqInZ0Yu91ueePP O/g06iNvXuCetW+iRh7fMK6XEldnjk/qJTHJnDZy5EUBlxocAIfN98u7uK7CFF/bUqjBQvVgstc w3P0nMR4mmDPNHdOChWVbEw7BOnq1oJIvpbFvTj5UiEbGensFciZ5fSgKVYmY6gVVUhIVAfi0QX TkyuqjomyHtgpxWUERq7/uVK7/vj2TLH1hl4xF4WcPYcwb0X X-Developer-Key: i=manivannan.sadhasivam@linaro.org; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 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 --- drivers/pci/controller/dwc/pcie-qcom.c | 177 +++++++++++---------------------- 1 file changed, 58 insertions(+), 119 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c index 14772edcf0d3..3d2eeff9a876 100644 --- a/drivers/pci/controller/dwc/pcie-qcom.c +++ b/drivers/pci/controller/dwc/pcie-qcom.c @@ -154,58 +154,56 @@ #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 clk_bulk_data *clks; + int num_clks; 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 clk_bulk_data *clks; + int num_clks; 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 clk_bulk_data *clks; + int num_clks; 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 clk_bulk_data *clks; + int num_clks; 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]; + struct clk_bulk_data *clks; 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]; + struct clk_bulk_data *clks; 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 clk_bulk_data *clks; + int num_clks; struct reset_control *rst; }; @@ -337,21 +335,11 @@ 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->num_clks = devm_clk_bulk_get_all(dev, &res->clks); + if (res->num_clks < 0) { + dev_err(dev, "Failed to get clocks\n"); + return res->num_clks; + } res->resets[0].id = "pci"; res->resets[1].id = "axi"; @@ -373,7 +361,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(res->num_clks, res->clks); reset_control_bulk_assert(res->num_resets, res->resets); writel(1, pcie->parf + PARF_PHY_CTRL); @@ -425,7 +413,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(res->num_clks, res->clks); if (ret) return ret; @@ -476,20 +464,16 @@ 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->num_clks = devm_clk_bulk_get_all(dev, &res->clks); + if (res->num_clks < 0) { + dev_err(dev, "Failed to get clocks\n"); + return res->num_clks; + } res->core = devm_reset_control_get_exclusive(dev, "core"); return PTR_ERR_OR_ZERO(res->core); @@ -500,7 +484,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(res->num_clks, res->clks); regulator_disable(res->vdda); } @@ -517,7 +501,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(res->num_clks, res->clks); if (ret) { dev_err(dev, "cannot prepare/enable clocks\n"); goto err_assert_reset; @@ -532,7 +516,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(res->num_clks, res->clks); err_assert_reset: reset_control_assert(res->core); @@ -580,14 +564,11 @@ 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; + res->num_clks = devm_clk_bulk_get_all(dev, &res->clks); + if (res->num_clks < 0) { + dev_err(dev, "Failed to get clocks\n"); + return res->num_clks; + } return 0; } @@ -596,7 +577,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(res->num_clks, res->clks); regulator_bulk_disable(ARRAY_SIZE(res->supplies), res->supplies); } @@ -613,7 +594,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(res->num_clks, res->clks); if (ret) { dev_err(dev, "cannot prepare/enable clocks\n"); regulator_bulk_disable(ARRAY_SIZE(res->supplies), res->supplies); @@ -661,17 +642,11 @@ 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->num_clks = devm_clk_bulk_get_all(dev, &res->clks); + if (res->num_clks < 0) { + dev_err(dev, "Failed to get clocks\n"); + return res->num_clks; + } res->resets[0].id = "axi_m"; res->resets[1].id = "axi_s"; @@ -742,15 +717,11 @@ 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->num_clks = devm_clk_bulk_get_all(dev, &res->clks); + if (res->num_clks < 0) { + dev_err(dev, "Failed to get clocks\n"); + return res->num_clks; + } res->rst[0].id = "axi_m"; res->rst[1].id = "axi_s"; @@ -771,7 +742,7 @@ 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(res->num_clks, res->clks); } static int qcom_pcie_init_2_3_3(struct qcom_pcie *pcie) @@ -801,7 +772,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(res->num_clks, res->clks); if (ret) { dev_err(dev, "cannot prepare/enable clocks\n"); goto err_assert_resets; @@ -862,8 +833,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,36 +846,11 @@ 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; + res->num_clks = devm_clk_bulk_get_all(dev, &res->clks); + if (res->num_clks < 0) { + dev_err(dev, "Failed to get clocks\n"); + return res->num_clks; + } return 0; } @@ -1101,17 +1045,12 @@ 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->num_clks = devm_clk_bulk_get_all(dev, &res->clks); + if (res->num_clks < 0) { + dev_err(dev, "Failed to get clocks\n"); + return res->num_clks; + } res->rst = devm_reset_control_array_get_exclusive(dev); if (IS_ERR(res->rst)) @@ -1124,7 +1063,7 @@ 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(res->num_clks, res->clks); } static int qcom_pcie_init_2_9_0(struct qcom_pcie *pcie) @@ -1153,7 +1092,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(res->num_clks, res->clks); } static int qcom_pcie_post_init_2_9_0(struct qcom_pcie *pcie) --- base-commit: 4cece764965020c22cff7665b18a012006359095 change-id: 20240417-pci-qcom-clk-bulk-389f972ae92a Best regards, -- Manivannan Sadhasivam