From patchwork Mon Mar 6 15:32:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 64799 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1921227wrd; Mon, 6 Mar 2023 08:01:44 -0800 (PST) X-Google-Smtp-Source: AK7set/pfg1QV+LVmFtvMaRUt7eUVzrde4LSinTqnHhHNp2HrftjPBmn3BQQ2e5PWrJjAEruup0F X-Received: by 2002:a17:90b:3b90:b0:233:d12f:f43a with SMTP id pc16-20020a17090b3b9000b00233d12ff43amr12354055pjb.1.1678118503697; Mon, 06 Mar 2023 08:01:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678118503; cv=none; d=google.com; s=arc-20160816; b=h2ujYHq3NnSWKVxRKOH/evFNW9L7jC98E46Z9TsZ7ZaiO+Vl1nwdnlF2LFqCUodkYd VsG8jEVZ+WN0aFDWrDJ4Em8vG3u8lNIEkquoY5krn2QpshSZUtS4ZtkxUusMBddetXzF gjPL/S6RYMfsp+9BUjjJYcqkzaqSVvtniuyb1HxhgENYhMrwmFYudpGXDRYRxaZ3UbBC gHbzD3QCgE11RWpxenmKQmrRYKSmgYOwXIWOSr4btp1eER1GqXA8HyimGDhiM8LWojae RAQGEYaqET40Lhb4ZzB0Dlx1QzThj6VWwSzimBpkS+3IzyQjiwcFSjDUaEuGrmFMonk0 0obA== 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=HLaHkNbeR3pTSpm3EckvQkVoLPurUbKikH/yYKtcjD0=; b=G/UUa8b/KF2nUnuzPJg/ZPjiArgTM9UmlCzSDmLozgqXakohU51C/hD5XpjVqhsmiJ uRP57yKWwQRLOykP3UFTRx05cqbwVCewyRu6U0FE0f5v/AqFEkeZeOOJRiYmDi8BaPu1 T6bFyVlC8AtJZgrapI5/04PC7luhun7aQ5PHe2ygWRbcxNZYt9typ3+nNxmRGzedT9Gq c95RvTgxisT6ZJhZucx0S+iQ3fmOXRF18DuikypQEm/Wo2tGjiDfo8dNYR9U9wRqcsRB ZyXHnjvT0bcg81XTVIUG9CscEJ4/PIAHWPnMyYw+yV5yY5ycCetP0RT/xlkdZasW1cpa CTGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=thnWH9V+; 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 q24-20020a17090aa01800b00238aab7e540si9950181pjp.4.2023.03.06.08.00.47; Mon, 06 Mar 2023 08:01:43 -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=thnWH9V+; 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 S230461AbjCFPeT (ORCPT + 99 others); Mon, 6 Mar 2023 10:34:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230274AbjCFPeH (ORCPT ); Mon, 6 Mar 2023 10:34:07 -0500 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0198934C0B for ; Mon, 6 Mar 2023 07:33:24 -0800 (PST) Received: by mail-pj1-x1035.google.com with SMTP id h11-20020a17090a2ecb00b00237c740335cso9145312pjs.3 for ; Mon, 06 Mar 2023 07:33:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678116796; 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=HLaHkNbeR3pTSpm3EckvQkVoLPurUbKikH/yYKtcjD0=; b=thnWH9V+PUlOUgjdtGqI99SmuYfo4Yz63ZHz0BFPBNPEV/bIUh/hIRX/iNVaz4ryVX TkGOanFhVf12pylEudeQNgzqlK1LdHLuvO0x4AhPbRL//L81mUowTCRMKkCyrV/plp4K 6K/a5Ppt0f3gPoSQAHpBe6xNsr5ZW+OUXCq5s+QRqzAUc8L5b8xzMdu6WSUc/uZmYBGf rJ3KWI4LCSQtfQQzQs9ZPJa/W+7SX/aIkCnrO9yqiCZkHF2CInJga1Gk+RIJHKHBc/TC 2wJ+OcYVRKV8dGhQzK78q1xTWjvmcLoO62umVvWboX2pThM+HmLsYkN2/bx0CnyJHB7S r0CA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678116796; 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=HLaHkNbeR3pTSpm3EckvQkVoLPurUbKikH/yYKtcjD0=; b=gVBrONIZ7sEVxhgGg7TNu4nK8RqbP/D2/4A4mjGtr4hRceh4yONOv9SToMDkj+Iqub Q1UiZ5/3adobuasc510N6oX4z4HsH5KgJ5ffrSSd92oCn1nGgynvI0H0oV7ThPtMIMei xizjoj+/+KFvESxfVxWbdjp69Bsn5Fv/59u0Lexmseqb9u4+PxhACBAGgupkeWjhXfcx +DJU40zGelyCXvso50rH+R6OCdZnOCWxkkQZnRUDZmXoQUCR89ekJPkdNrfXZTVM0VIM C73xwfnxNyY8EPAu3fJTR4+3mTIq5lRsWNAZXqnnmBWp5w/suDCGiObmXjuKXJuYGItn 2v4g== X-Gm-Message-State: AO0yUKWZkM0IRmdwFqrRIhAB55rUwY9SwJ4jeGnHNWrURrgWRlJdSXlc 6Evs3+NgijbLuSPo3/O0EPjs X-Received: by 2002:a17:902:e80f:b0:19e:747e:813e with SMTP id u15-20020a170902e80f00b0019e747e813emr12933698plg.23.1678116796557; Mon, 06 Mar 2023 07:33:16 -0800 (PST) Received: from localhost.localdomain ([59.97.52.140]) by smtp.gmail.com with ESMTPSA id kl4-20020a170903074400b0019a7c890c61sm6837430plb.252.2023.03.06.07.33.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 07:33:16 -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 09/19] PCI: qcom: Use bulk clock APIs for handling clocks for IP rev 2.3.3 Date: Mon, 6 Mar 2023 21:02:12 +0530 Message-Id: <20230306153222.157667-10-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230306153222.157667-1-manivannan.sadhasivam@linaro.org> References: <20230306153222.157667-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?1759634787877373176?= X-GMAIL-MSGID: =?utf-8?q?1759634787877373176?= 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 | 88 ++++++-------------------- 1 file changed, 20 insertions(+), 68 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c index 939973733a1e..6b83e3627336 100644 --- a/drivers/pci/controller/dwc/pcie-qcom.c +++ b/drivers/pci/controller/dwc/pcie-qcom.c @@ -169,6 +169,12 @@ struct qcom_pcie_resources_2_3_2 { struct regulator_bulk_data supplies[QCOM_PCIE_2_3_2_MAX_SUPPLY]; }; +#define QCOM_PCIE_2_3_3_MAX_CLOCKS 5 +struct qcom_pcie_resources_2_3_3 { + struct clk_bulk_data clks[QCOM_PCIE_2_3_3_MAX_CLOCKS]; + struct reset_control *rst[7]; +}; + #define QCOM_PCIE_2_4_0_MAX_CLOCKS 4 struct qcom_pcie_resources_2_4_0 { struct clk_bulk_data clks[QCOM_PCIE_2_4_0_MAX_CLOCKS]; @@ -187,15 +193,6 @@ struct qcom_pcie_resources_2_4_0 { struct reset_control *phy_ahb_reset; }; -struct qcom_pcie_resources_2_3_3 { - struct clk *iface; - struct clk *axi_m_clk; - struct clk *axi_s_clk; - struct clk *ahb_clk; - struct clk *aux_clk; - struct reset_control *rst[7]; -}; - /* 6 clocks typically, 7 for sm8250 */ struct qcom_pcie_resources_2_7_0 { struct clk_bulk_data clks[12]; @@ -896,26 +893,17 @@ static int qcom_pcie_get_resources_2_3_3(struct qcom_pcie *pcie) const char *rst_names[] = { "axi_m", "axi_s", "pipe", "axi_m_sticky", "sticky", "ahb", "sleep", }; + int ret; - res->iface = devm_clk_get(dev, "iface"); - if (IS_ERR(res->iface)) - return PTR_ERR(res->iface); - - res->axi_m_clk = devm_clk_get(dev, "axi_m"); - if (IS_ERR(res->axi_m_clk)) - return PTR_ERR(res->axi_m_clk); - - res->axi_s_clk = devm_clk_get(dev, "axi_s"); - if (IS_ERR(res->axi_s_clk)) - return PTR_ERR(res->axi_s_clk); - - res->ahb_clk = devm_clk_get(dev, "ahb"); - if (IS_ERR(res->ahb_clk)) - return PTR_ERR(res->ahb_clk); + 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"; - res->aux_clk = devm_clk_get(dev, "aux"); - if (IS_ERR(res->aux_clk)) - return PTR_ERR(res->aux_clk); + ret = devm_clk_bulk_get(dev, ARRAY_SIZE(res->clks), res->clks); + if (ret < 0) + return ret; for (i = 0; i < ARRAY_SIZE(rst_names); i++) { res->rst[i] = devm_reset_control_get(dev, rst_names[i]); @@ -930,11 +918,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_disable_unprepare(res->iface); - clk_disable_unprepare(res->axi_m_clk); - clk_disable_unprepare(res->axi_s_clk); - clk_disable_unprepare(res->ahb_clk); - clk_disable_unprepare(res->aux_clk); + clk_bulk_disable_unprepare(ARRAY_SIZE(res->clks), res->clks); } static int qcom_pcie_init_2_3_3(struct qcom_pcie *pcie) @@ -969,47 +953,15 @@ static int qcom_pcie_init_2_3_3(struct qcom_pcie *pcie) */ usleep_range(2000, 2500); - ret = clk_prepare_enable(res->iface); - if (ret) { - dev_err(dev, "cannot prepare/enable core clock\n"); - goto err_clk_iface; - } - - ret = clk_prepare_enable(res->axi_m_clk); - if (ret) { - dev_err(dev, "cannot prepare/enable core clock\n"); - goto err_clk_axi_m; - } - - ret = clk_prepare_enable(res->axi_s_clk); - if (ret) { - dev_err(dev, "cannot prepare/enable axi slave clock\n"); - goto err_clk_axi_s; - } - - ret = clk_prepare_enable(res->ahb_clk); - if (ret) { - dev_err(dev, "cannot prepare/enable ahb clock\n"); - goto err_clk_ahb; - } - - ret = clk_prepare_enable(res->aux_clk); + ret = clk_bulk_prepare_enable(ARRAY_SIZE(res->clks), res->clks); if (ret) { - dev_err(dev, "cannot prepare/enable aux clock\n"); - goto err_clk_aux; + dev_err(dev, "cannot prepare/enable clocks\n"); + goto err_assert_resets; } return 0; -err_clk_aux: - clk_disable_unprepare(res->ahb_clk); -err_clk_ahb: - clk_disable_unprepare(res->axi_s_clk); -err_clk_axi_s: - clk_disable_unprepare(res->axi_m_clk); -err_clk_axi_m: - clk_disable_unprepare(res->iface); -err_clk_iface: +err_assert_resets: /* * Not checking for failure, will anyway return * the original failure in 'ret'.