From patchwork Wed May 29 00:57:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 165317 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp9198397ili; Tue, 28 May 2019 17:57:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqyS5sv91B+xWQXv9NcMKQzAEQoqWGGnUofwR0hgHPqF8vm+kaWvU4znH4vvHbakq9n7qrf2 X-Received: by 2002:a17:90a:af8a:: with SMTP id w10mr9253785pjq.132.1559091446420; Tue, 28 May 2019 17:57:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559091446; cv=none; d=google.com; s=arc-20160816; b=Oriao6dp3UbfCw2P+EkxzrbIoZYD8uCUZ6MJt5ow0PsV8ZEqRPrdoepzOZLU3vCq8s bhRynGeAacMh/4OCZ6S/xR0BWDgFcdyPLpRQvpFAONYIIeIXX3DZpdozjDDAZeywU9b+ vwaJSYWBwBuOnIn2yXCFU9B/TkfdiEYCB2vTO4HbbjKzhZbbl16YdycCx9dqUz4l/jJB sRpWUyD/CEYCOb3FXRlcI9Hie6TpKVL5vQgz7mkeGEkoQMCF6mfl/NUC7V271wfKvUU4 yHZiep1woLZdym+SCE4nepaCZQWth2GH+JorR4BSCudyrLSANu7QjQKDqZX7j0JMpe2u Hd0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=qKmxeHO6kgs7ja9Kl572pImWPI/Cnkb8PM2C6xIty7g=; b=lEbzVDhLc2CCUJ7DQAWeft2GEvtsZC1VSWXB5fwCDto/RzHR4FpemWv/4AhHiAcMEo +jvPOTCjuAkGtkzrvbvASgacCVAvlQzdTSKko8MZC+XzVTl/GBc4ugB8+dr85wovyPrX UvB8U8auS+U72XsMnB4PC67xATiK4PtHib2NMyn5ZOEak6kVe1eT1AWl3p0xuekO1Fyb jBLK85kaKi1dExNl7pdMo6pRVWuoAAGWj3ButDL2CmB4t5z/05JeVGM5PTiS9KrQ2hAu 54esSQkxRHc2w3chQ/iEWNrVKecPTK/y0qlZCJdLyiJFIWJhwBtreoqaurntEJE/49ug 3xyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="WVfX/C3/"; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j1si25090033pfn.53.2019.05.28.17.57.26; Tue, 28 May 2019 17:57:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="WVfX/C3/"; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-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 S1726131AbfE2A5R (ORCPT + 7 others); Tue, 28 May 2019 20:57:17 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:40054 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726054AbfE2A5Q (ORCPT ); Tue, 28 May 2019 20:57:16 -0400 Received: by mail-pl1-f194.google.com with SMTP id g69so267408plb.7 for ; Tue, 28 May 2019 17:57:15 -0700 (PDT) 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=qKmxeHO6kgs7ja9Kl572pImWPI/Cnkb8PM2C6xIty7g=; b=WVfX/C3/sIS/rh3FVUl6wzgQdMZN+745ZvFCHHxAsBa9jO2sCyQGiYqvwevcEuJrSi Z23zwYlCvKPN3Bwa+McNC++rBfMY7Y2M7wMefeoFsJx+LFIR5uZ7e03BtcPlQuxGOWg7 pYH4H2Ey90HeRs08nhocHivRg/sX6YHKqVDjkEKSdlYClxhtAZmjFo6NbfmR034dKoLr pnugWOqyfsY0JGCCwsMoEalSEwcuF6F5QgPUBxA2QJ8vjAQ66OtGFAAseQtIDt0xrpXk 3JLzJGbuKjZ2wllIWH5akr7bFMeQ3qvNDEVZxC2Rr1p/2G2j28ZiEXVtCoDsPKXXSsFI 5ZTg== 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=qKmxeHO6kgs7ja9Kl572pImWPI/Cnkb8PM2C6xIty7g=; b=f6ymwSAlEPdRsMsSbm2yzMAz3vNLUlBJhilDP7ihBztfnlk1gIqVOkvLRMEkLz6lu7 liCLcXGULnXqDOLkw0Zouptd4mIVnZEl4ffO9EoUfg+gDlkrCmV1i8yseMQGMf0fNk/P EiUKeMtfEXSgHOqw6SzBQty5GoKwQlTFGx96bCxzxG4vNDVJLnfwYEHyMsqB5pAzWLMi aYVIl8FJra4meK7Wrf1cqcQeBnMCm2swAD/ihcIqYbGVk85TsbvdZU3jIsN/D24oU1He n9wjJciirnGmLssqjEoqNQI1qWMVt4hqtRFap4wMyf7ClYKf/ZvBfilw7/oihZv/MwM9 6egA== X-Gm-Message-State: APjAAAX54ehrGOA1D4l5f5TRQEGC/DxZJGtCzD9vHhSJ8cANrRe1IDYL KUP3krOp6FdEt3msR1ieOAhvGQ== X-Received: by 2002:a17:902:7581:: with SMTP id j1mr54339571pll.23.1559091434951; Tue, 28 May 2019 17:57:14 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id p16sm15434824pff.35.2019.05.28.17.57.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 May 2019 17:57:14 -0700 (PDT) From: Bjorn Andersson To: Lorenzo Pieralisi Cc: Bjorn Helgaas , Rob Herring , Mark Rutland , Stanimir Varbanov , linux-arm-msm@vger.kernel.org, linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 1/3] PCI: qcom: Use clk_bulk API for 2.4.0 controllers Date: Tue, 28 May 2019 17:57:08 -0700 Message-Id: <20190529005710.23950-2-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190529005710.23950-1-bjorn.andersson@linaro.org> References: <20190529005710.23950-1-bjorn.andersson@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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. Acked-by: Stanimir Varbanov Reviewed-by: Niklas Cassel Reviewed-by: Vinod Koul Signed-off-by: Bjorn Andersson --- Changes since v4: - Renamed "err_clks" label - Picked up Vinod's r-b and Stanimir's a-b drivers/pci/controller/dwc/pcie-qcom.c | 53 ++++++++------------------ 1 file changed, 16 insertions(+), 37 deletions(-) -- 2.18.0 diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c index 0ed235d560e3..23dc01212508 100644 --- a/drivers/pci/controller/dwc/pcie-qcom.c +++ b/drivers/pci/controller/dwc/pcie-qcom.c @@ -112,10 +112,10 @@ struct qcom_pcie_resources_2_3_2 { struct regulator_bulk_data supplies[QCOM_PCIE_2_3_2_MAX_SUPPLY]; }; +#define QCOM_PCIE_2_4_0_MAX_CLOCKS 3 struct qcom_pcie_resources_2_4_0 { - struct clk *aux_clk; - struct clk *master_clk; - struct clk *slave_clk; + struct clk_bulk_data clks[QCOM_PCIE_2_4_0_MAX_CLOCKS]; + int num_clks; struct reset_control *axi_m_reset; struct reset_control *axi_s_reset; struct reset_control *pipe_reset; @@ -638,18 +638,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 +718,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 +847,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"); - 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; - } + ret = clk_bulk_prepare_enable(res->num_clks, res->clks); + if (ret) + goto err_clks; /* enable PCIe clocks and resets */ val = readl(pcie->parf + PCIE20_PARF_PHY_CTRL); @@ -891,11 +874,7 @@ 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: +err_clks: reset_control_assert(res->ahb_reset); err_rst_ahb: reset_control_assert(res->pwr_reset);