From patchwork Tue Feb 19 06:04:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 10819229 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 40C986CB for ; Tue, 19 Feb 2019 06:04:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3151E2BCCB for ; Tue, 19 Feb 2019 06:04:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2519C2BCCE; Tue, 19 Feb 2019 06:04:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B2C252BCA5 for ; Tue, 19 Feb 2019 06:04:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727073AbfBSGE1 (ORCPT ); Tue, 19 Feb 2019 01:04:27 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:37740 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726520AbfBSGD5 (ORCPT ); Tue, 19 Feb 2019 01:03:57 -0500 Received: by mail-pl1-f194.google.com with SMTP id q3so2495236pll.4 for ; Mon, 18 Feb 2019 22:03:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DS4uNOBDo1WB9KnSrcyr/O/ij9VFYUJ1ooQOz6eplho=; b=MK//UaIe9fvR4Oi7QbwiXf6DH4NUISyH6nuVMXk8obRig92DIgm1Jt5B1XNfT7+++I oUnSCJpYA1mDIkOFbEHgGlT51LF5ZJYpzMznxEjqRLmUOG0HVtGSP1aOSZ1W0WEr/2ab rkjmcObQTWnUeAny72o5PCGK2NlQhEdxoVVYlcr5BQ5ktJfgVIul78OpgzRGeVe0qB4B uRCh7RfWwRG+yTQVB4TKiM4z0awNUQMk0RGvDcFDA1h2T5o+TGLWSWmtcKZ+jiFhY/Iq yP7a1p/rGtFszHO9E5Lk1qTrLpSuHBd/fSHIUd/bCl4Fm9/bxkqbaYpSwzJuuQVAeWXf oKWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DS4uNOBDo1WB9KnSrcyr/O/ij9VFYUJ1ooQOz6eplho=; b=Ud1aHHw7HDi6k90Pw2m8CyDqFAzPHUyQjYnLFEWc5ctVMESkKqb4XxY5L4d8aeSz0E CMQL9oU0AvcxTSdzrzvGVQ6kRk6i+sur7G+oTrQvaa7/WLSGMWZwccYqU4CPGLmorb94 Wt3qqjRgsFuQhry2J7jpduS04v8D3To/aFnKwAJhxrJWHTiF8Tc7CG/ILPL+Oy1Zr1GV iirAcW/HtDFwtSJIaxI3JHB3c/evzQMFdkkanuhA9+6S8KQPfCZb6QrxDkDPTx79pQuw Gap1LR9JlaUSImjyEKdyT+W23z0F0b+IRqdyEgxQ/EeqtFB/mieOCHo6ZLCPlChbTfLb qneA== X-Gm-Message-State: AHQUAuYjTTvHdu+1ZjvjUAEtfENM7R1VvF4RAxD11HwU1Tyn+U8S9O/R 6hbEpfayM1xh1GP2OclQFsnsHw== X-Google-Smtp-Source: AHgI3IZPJjl3Bc6qKv5xONL3tYOXtG9gF2gr4rH6Yg/k7qsN7r/DMCcPVC7hopEjbqjVIJGPX48VGg== X-Received: by 2002:a17:902:20e2:: with SMTP id v31mr29499375plg.307.1550556236482; Mon, 18 Feb 2019 22:03:56 -0800 (PST) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id 86sm31914838pfk.157.2019.02.18.22.03.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Feb 2019 22:03:55 -0800 (PST) From: Bjorn Andersson To: Bjorn Helgaas , Stanimir Varbanov , Lorenzo Pieralisi Cc: Andy Gross , David Brown , Rob Herring , Mark Rutland , 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-clk@vger.kernel.org Subject: [PATCH v2 4/7] PCI: qcom: Use clk_bulk API for 2.4.0 controllers Date: Mon, 18 Feb 2019 22:04:04 -0800 Message-Id: <20190219060407.15263-5-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190219060407.15263-1-bjorn.andersson@linaro.org> References: <20190219060407.15263-1-bjorn.andersson@linaro.org> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Before introducing the QCS404 platform, which uses the same PCIe controller as IPQ4019, migrate this to use the bulk clock API, in order to make the error paths slighly cleaner. Reviewed-by: Niklas Cassel Signed-off-by: Bjorn Andersson Acked-by: Stanimir Varbanov --- drivers/pci/controller/dwc/pcie-qcom.c | 48 +++++++------------------- 1 file changed, 13 insertions(+), 35 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c index d185ea5fe996..b4d8bcf6eb77 100644 --- a/drivers/pci/controller/dwc/pcie-qcom.c +++ b/drivers/pci/controller/dwc/pcie-qcom.c @@ -113,9 +113,8 @@ struct qcom_pcie_resources_2_3_2 { }; struct qcom_pcie_resources_2_4_0 { - struct clk *aux_clk; - struct clk *master_clk; - struct clk *slave_clk; + struct clk_bulk_data clks[3]; + int num_clks; struct reset_control *axi_m_reset; struct reset_control *axi_s_reset; struct reset_control *pipe_reset; @@ -638,18 +637,17 @@ static int qcom_pcie_get_resources_2_4_0(struct qcom_pcie *pcie) struct qcom_pcie_resources_2_4_0 *res = &pcie->res.v2_4_0; struct dw_pcie *pci = pcie->pci; struct device *dev = pci->dev; + int ret; - res->aux_clk = devm_clk_get(dev, "aux"); - if (IS_ERR(res->aux_clk)) - return PTR_ERR(res->aux_clk); + res->clks[0].id = "aux"; + res->clks[1].id = "master_bus"; + res->clks[2].id = "slave_bus"; - res->master_clk = devm_clk_get(dev, "master_bus"); - if (IS_ERR(res->master_clk)) - return PTR_ERR(res->master_clk); + res->num_clks = 3; - res->slave_clk = devm_clk_get(dev, "slave_bus"); - if (IS_ERR(res->slave_clk)) - return PTR_ERR(res->slave_clk); + ret = devm_clk_bulk_get(dev, res->num_clks, res->clks); + if (ret < 0) + return ret; res->axi_m_reset = devm_reset_control_get_exclusive(dev, "axi_m"); if (IS_ERR(res->axi_m_reset)) @@ -719,9 +717,7 @@ static void qcom_pcie_deinit_2_4_0(struct qcom_pcie *pcie) reset_control_assert(res->axi_m_sticky_reset); reset_control_assert(res->pwr_reset); reset_control_assert(res->ahb_reset); - clk_disable_unprepare(res->aux_clk); - clk_disable_unprepare(res->master_clk); - clk_disable_unprepare(res->slave_clk); + clk_bulk_disable_unprepare(res->num_clks, res->clks); } static int qcom_pcie_init_2_4_0(struct qcom_pcie *pcie) @@ -850,23 +846,9 @@ static int qcom_pcie_init_2_4_0(struct qcom_pcie *pcie) usleep_range(10000, 12000); - ret = clk_prepare_enable(res->aux_clk); - if (ret) { - dev_err(dev, "cannot prepare/enable iface clock\n"); + ret = clk_bulk_prepare_enable(res->num_clks, res->clks); + if (ret) goto err_clk_aux; - } - - ret = clk_prepare_enable(res->master_clk); - if (ret) { - dev_err(dev, "cannot prepare/enable core clock\n"); - goto err_clk_axi_m; - } - - ret = clk_prepare_enable(res->slave_clk); - if (ret) { - dev_err(dev, "cannot prepare/enable phy clock\n"); - goto err_clk_axi_s; - } /* enable PCIe clocks and resets */ val = readl(pcie->parf + PCIE20_PARF_PHY_CTRL); @@ -891,10 +873,6 @@ static int qcom_pcie_init_2_4_0(struct qcom_pcie *pcie) return 0; -err_clk_axi_s: - clk_disable_unprepare(res->master_clk); -err_clk_axi_m: - clk_disable_unprepare(res->aux_clk); err_clk_aux: reset_control_assert(res->ahb_reset); err_rst_ahb: