From patchwork Thu Mar 9 08:50:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 66705 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp176724wrd; Thu, 9 Mar 2023 00:53:55 -0800 (PST) X-Google-Smtp-Source: AK7set/7NA52BC+lpzUEphgT+eBfFkUAwCrivJzvhSSInHo7MqEioTXv7dKCI4c5cAfDq9qIWvC/ X-Received: by 2002:a17:902:ec8f:b0:19a:972a:7cb3 with SMTP id x15-20020a170902ec8f00b0019a972a7cb3mr26825004plg.60.1678352035107; Thu, 09 Mar 2023 00:53:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678352035; cv=none; d=google.com; s=arc-20160816; b=qGe/ghcmUZIflCbhnKXaB6QTCxcVQ0mUK6ahM13GuWQHG0//HQiemloR1TYvXwmhJ6 TJYr3zpxe/9EFLU/0tTWraxsjGaM2gJJQnIynXFXIOFKCBBEFCjQNqubc2s3o6e2uxiv m+zg65NfJ2N7r5lp7A7PZ/LUrJDUEXe4Qz7HsCASuif/+f7680sfBnJH5vBYELKx/Km5 oIx/AEntpghk89HBoNaX3znEB6dJg/lpiAlb3Q9iR6JpbMOe2Jg5MHWgAu9AwfBB/nhe PIlYO3reBtr70XPuAenHFAH3Q5oOvlP+oUGXKmSl3RZS1MAbWhFn8fEZpLiaG3r+JNqZ 0WHQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=amLlMnvqqV/ACQXsqFtaJlfI0hCQH92ixpD+YcVSgsE=; b=uF8OVB1upjReht0OrZMVPx975Hs4CAwPiW7kiQefuWwzfeE1Xt+1AJa/rG8Y5co9kG SkoO4nSsZz3ERLtQz2KZ02TrJ7e94HcJBQ7054D/6yN1lKECmm1rISaAb3LShjoQ67MD sGoYUcmHqQsZzxhYV+YepGyvksnSY9DqRfYwPn7+OhbIfs86FEUfvUsGd+qqXm+BrUfV UxEUdbqbEaeG4lKK4YQkDOGtEtKhzPXBvWCGcg6TSxaD0gA0COFNYtr+s7v+4pgYjG+X dQSkf8iUW6tt7rN44ln/CVYmTy6l8mzXS1D2IxOXfn97JNF1BC8Ixo5sy50oPm7aOpfn YaYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lPU0O1gS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q16-20020a170902789000b0019e3ffa26bdsi16497259pll.576.2023.03.09.00.53.43; Thu, 09 Mar 2023 00:53:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lPU0O1gS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230380AbjCIIwY (ORCPT + 99 others); Thu, 9 Mar 2023 03:52:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230397AbjCIIwU (ORCPT ); Thu, 9 Mar 2023 03:52:20 -0500 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90B56DF24C for ; Thu, 9 Mar 2023 00:51:49 -0800 (PST) Received: by mail-pl1-x62a.google.com with SMTP id a2so1270300plm.4 for ; Thu, 09 Mar 2023 00:51:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678351908; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=amLlMnvqqV/ACQXsqFtaJlfI0hCQH92ixpD+YcVSgsE=; b=lPU0O1gSI3XQPZSiu5PrFa3Thv5xviQqS3pJTpjNXdfTzQTmhJ6qhPj8FqWiVjS0p9 419fZecD4pZ0csSDp2nyJfdcUta0/XHsRkOKKdcTMDOTNgtpyGlMs+Nayk4EZNLoODR5 e7eRRD5LQysSbllVlVSY5WrGQizg/FntgIDEIAUa69CEtcbsrnd8Uk5+hxnijpzWj3oZ Mv8JY8NQs9NQ8A4OdD4Lb5MKJXwlK3rklcYE0lC9T/281r+RUDqS6P+xcANEmgXKcd4Y LJfg2eCkm+NSMmLShu4lzI9vRFP3PHwJmufql8IwSiXv30TNrXwp9nCUsbY4/nl9qS0E H0bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678351908; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=amLlMnvqqV/ACQXsqFtaJlfI0hCQH92ixpD+YcVSgsE=; b=H2d/UniqT4ilgVgoZvUbF//nsbeXryTTKlBV7gyKLIlmh8K3SmovXdtHHdUBdudroR JJ+Qd+kAi12BW4s8AXFKjc0ZnSj0gwEpi8L70LYbdnVgqU4ss3N8tQXdXDyC3aObGoAJ iLehq8OR+qXi9dcDyUrFHg2CdPf6M0EA8qnzrvrK4/A5wjyWOnPGjRzWeqpLSgGvEN4S q8Ba84zSO+iLotFXEdcrcdwnhIskN6h3KFbH2keKw9jL5xZkGtWKeBMYlCpVXSbT3lCv DWRIMxDAr47wcAXhFJsNPBC7XpsnPwpdF/f6wGYBCMh3nwjxWxKwF1dD+KbCMXQDBQuJ 3IKQ== X-Gm-Message-State: AO0yUKVSBMVdqaeu1K1q+yu0J5fDHaZbQERmenJncrnMzTaQdyjEkMJd EfX3yW5eUS7qqMw3QkuDyAb/ X-Received: by 2002:a05:6a20:7d88:b0:cc:fa4b:3a6a with SMTP id v8-20020a056a207d8800b000ccfa4b3a6amr28376975pzj.58.1678351907950; Thu, 09 Mar 2023 00:51:47 -0800 (PST) Received: from localhost.localdomain ([220.158.158.11]) by smtp.gmail.com with ESMTPSA id u4-20020aa78484000000b005809d382016sm10638604pfn.74.2023.03.09.00.51.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 00:51:47 -0800 (PST) From: Manivannan Sadhasivam To: andersson@kernel.org, lpieralisi@kernel.org, kw@linux.com, krzysztof.kozlowski+dt@linaro.org, robh@kernel.org Cc: konrad.dybcio@linaro.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, quic_srichara@quicinc.com, Manivannan Sadhasivam Subject: [PATCH v2 08/17] PCI: qcom: Use bulk clock APIs for handling clocks for IP rev 2.3.2 Date: Thu, 9 Mar 2023 14:20:53 +0530 Message-Id: <20230309085102.120977-9-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230309085102.120977-1-manivannan.sadhasivam@linaro.org> References: <20230309085102.120977-1-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759879663445688255?= X-GMAIL-MSGID: =?utf-8?q?1759879663445688255?= All the clocks are enabled and disabled at the same time. So the bulk clock APIs can be used to handle them together. This simplifies the code a lot. Signed-off-by: Manivannan Sadhasivam --- drivers/pci/controller/dwc/pcie-qcom.c | 72 ++++++-------------------- 1 file changed, 15 insertions(+), 57 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c index 0bb27d3c95a0..939973733a1e 100644 --- a/drivers/pci/controller/dwc/pcie-qcom.c +++ b/drivers/pci/controller/dwc/pcie-qcom.c @@ -162,12 +162,10 @@ struct qcom_pcie_resources_2_1_0 { struct regulator_bulk_data supplies[QCOM_PCIE_2_1_0_MAX_SUPPLY]; }; -#define QCOM_PCIE_2_3_2_MAX_SUPPLY 2 +#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 *aux_clk; - struct clk *master_clk; - struct clk *slave_clk; - struct clk *cfg_clk; + struct clk_bulk_data clks[QCOM_PCIE_2_3_2_MAX_CLOCKS]; struct regulator_bulk_data supplies[QCOM_PCIE_2_3_2_MAX_SUPPLY]; }; @@ -539,21 +537,14 @@ static int qcom_pcie_get_resources_2_3_2(struct qcom_pcie *pcie) if (ret) return ret; - res->aux_clk = devm_clk_get(dev, "aux"); - if (IS_ERR(res->aux_clk)) - return PTR_ERR(res->aux_clk); - - res->cfg_clk = devm_clk_get(dev, "cfg"); - if (IS_ERR(res->cfg_clk)) - return PTR_ERR(res->cfg_clk); - - res->master_clk = devm_clk_get(dev, "bus_master"); - if (IS_ERR(res->master_clk)) - return PTR_ERR(res->master_clk); + res->clks[0].id = "aux"; + res->clks[1].id = "cfg"; + res->clks[2].id = "bus_master"; + res->clks[3].id = "bus_slave"; - res->slave_clk = devm_clk_get(dev, "bus_slave"); - if (IS_ERR(res->slave_clk)) - return PTR_ERR(res->slave_clk); + ret = devm_clk_bulk_get(dev, ARRAY_SIZE(res->clks), res->clks); + if (ret < 0) + return ret; return 0; } @@ -562,11 +553,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_disable_unprepare(res->slave_clk); - clk_disable_unprepare(res->master_clk); - clk_disable_unprepare(res->cfg_clk); - clk_disable_unprepare(res->aux_clk); - + clk_bulk_disable_unprepare(ARRAY_SIZE(res->clks), res->clks); regulator_bulk_disable(ARRAY_SIZE(res->supplies), res->supplies); } @@ -583,43 +570,14 @@ static int qcom_pcie_init_2_3_2(struct qcom_pcie *pcie) return ret; } - ret = clk_prepare_enable(res->aux_clk); - if (ret) { - dev_err(dev, "cannot prepare/enable aux clock\n"); - goto err_aux_clk; - } - - ret = clk_prepare_enable(res->cfg_clk); - if (ret) { - dev_err(dev, "cannot prepare/enable cfg clock\n"); - goto err_cfg_clk; - } - - ret = clk_prepare_enable(res->master_clk); - if (ret) { - dev_err(dev, "cannot prepare/enable master clock\n"); - goto err_master_clk; - } - - ret = clk_prepare_enable(res->slave_clk); + ret = clk_bulk_prepare_enable(ARRAY_SIZE(res->clks), res->clks); if (ret) { - dev_err(dev, "cannot prepare/enable slave clock\n"); - goto err_slave_clk; + dev_err(dev, "cannot prepare/enable clocks\n"); + regulator_bulk_disable(ARRAY_SIZE(res->supplies), res->supplies); + return ret; } return 0; - -err_slave_clk: - clk_disable_unprepare(res->master_clk); -err_master_clk: - clk_disable_unprepare(res->cfg_clk); -err_cfg_clk: - clk_disable_unprepare(res->aux_clk); - -err_aux_clk: - regulator_bulk_disable(ARRAY_SIZE(res->supplies), res->supplies); - - return ret; } static int qcom_pcie_post_init_2_3_2(struct qcom_pcie *pcie)