From patchwork Wed Jun 16 14:10:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foss X-Patchwork-Id: 461400 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp680017jae; Wed, 16 Jun 2021 07:11:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqfUNZwkrybYI48Dd8Y37KMIl87bDP1EV6AizoXEzcvJLgLYqlG3QbZwUvrMovtPDQUB+A X-Received: by 2002:a02:ccd8:: with SMTP id k24mr4425196jaq.99.1623852686580; Wed, 16 Jun 2021 07:11:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623852686; cv=none; d=google.com; s=arc-20160816; b=mkC4hBkR0Y9EZFylniSAcLHfp+k9y8f6nOSiq7Nm5ZzHEJzOY8euWSB7OX+UBJURua 3wrzVfSVsNZOil5HNnBUtQQUfIWB4xZhskpPKibsh7iF/Vch28dWr/iQoJwJwJSq1Zzt yBLhcDgPZK9YQg4EMTN6Hy0NgDdzTTiATTPzhb/iI58oPJMkVvujh6gDrIikINfiXwa0 SV48OFzemKNu+lYnDMhch2FXJwiKEzPlTD0dCqO7P2600PDPSmY4kaPAk6j9Q9uwnTxn VBho/oQpCcL3SOhdLrkQ9/XopPVy1G0rgh+zKtzrsSsdUXn8Ey2c88Pp6FEj3aNmE/n4 ayww== 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=HWrm484FRw+CXBsUVTC9kLTPetzFLV6N+ldivPXQSA0=; b=nz8r7nJ2dlhF33B4mW33G1vNPrkZYLnxV9PeyOhUmUVeWNCtMMwPi/jiPbjMPFUmv2 FZQ7ciwSGH3vsp7Y5aPW56YBZhiQ+ei6QC174S/4Ehy4RYhAgRpQZqk3X92pVfzO0KhM B4jiquEgEteWYJiEAq+KoSIOK7LGD63yjSGNz8peAMb5UHmM0yvB+mVie7ym7ddoA7zz o3ofuxZOd5gfhOEjIp97Iu8f7TSJYvQjchGgi5jGxBso4vsLnSKcRe2+l3czbdt5vGRl 6fSL+hnX6DmYTLZt75dXiBx2yGh6ZyXg8l4HASvgivbYjregr0e4JhjnqhPEBmBYsMdI ayKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ivOr+KRe; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id d23si2744800jaq.63.2021.06.16.07.11.26; Wed, 16 Jun 2021 07:11:26 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ivOr+KRe; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 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 S233845AbhFPONa (ORCPT + 7 others); Wed, 16 Jun 2021 10:13:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233831AbhFPONa (ORCPT ); Wed, 16 Jun 2021 10:13:30 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDC58C0617A6 for ; Wed, 16 Jun 2021 07:11:23 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id v9so2868010wrx.6 for ; Wed, 16 Jun 2021 07:11:23 -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 :mime-version:content-transfer-encoding; bh=HWrm484FRw+CXBsUVTC9kLTPetzFLV6N+ldivPXQSA0=; b=ivOr+KReobJtkhuIa7uOD3UErbtxb02cL0h/pdDUfPd2qxzaK7FzKkCpHpjnh4ukwG o1r/pj8GTabRMnFi6VXJW2E7ILfmHvZJQuD2MYwYbaJzrpl5iwksBJNc2NPnZU9xaPe5 zw7wK4KKkEl/563ebuvmF+4iNE3ThvFxMsGfAlK14v59xaNf4afPc0kiud3mZn9yreLZ nJmvDR9Rx5OGjkKA9OtgHD01jt5VmEvEUNsP6iwJNTbyZXG959qJ3EloczxuOECB8UPc MfBoAWyV14dclN1F8gwKDXgrbnOJZm9hn15En+SUGdGSFeDyLT0NFjrrss6xG1qAlizq f/lw== 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:mime-version:content-transfer-encoding; bh=HWrm484FRw+CXBsUVTC9kLTPetzFLV6N+ldivPXQSA0=; b=pUXH1H0715CZY7x9Gw6xXIdk30C2wHYCS2lh9XOA6tx2TBgGmyADKR3gi+GQcyvxIX 6f3rH6kE2oe4EiLgV0XC9IvHCNnSUr7gAnuUdD/7ZYhVsyW42Zlgj28JIv9qAaRATfFg MmYd4iNNu7sYVtt6F9e9Dq00Y5o1ktog7dSr6e1bFun0MeSSW1XLofUBl/w4rgUdHT/Y V2bBlfQmuARNMbvLkQEmoII8ApLDmCN9mDQYw2XpWfVvduN6OGYmmsPFWBoFUyFbLymO /LZEgTTXDhWmrd0FsdC/xPzWgSrwZ4887ZZ5j6NdCi0T4GECrj8hp7CrOmOM/jo1FOUg PYRQ== X-Gm-Message-State: AOAM533qOMH3b3dn3JwQ/v9KPPglUVIginFZ6E9njCMK0OokiFt1hQ+X tsMCe7pm6SWTwkwQdLL5s6d/fQ== X-Received: by 2002:a5d:6b0e:: with SMTP id v14mr5661024wrw.297.1623852682379; Wed, 16 Jun 2021 07:11:22 -0700 (PDT) Received: from xps7590.fritz.box ([2a02:2454:3e5:b700:9df7:76e5:7e94:bf1e]) by smtp.gmail.com with ESMTPSA id g83sm1968375wma.10.2021.06.16.07.11.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jun 2021 07:11:22 -0700 (PDT) From: Robert Foss To: agross@kernel.org, bjorn.andersson@linaro.org, mturquette@baylibre.com, sboyd@kernel.org, robh+dt@kernel.org, jonathan@marek.ca, tdas@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Vinod Koul Cc: Robert Foss Subject: [RFC v1 01/11] clk: qcom: common: Add runtime init/suspend/resume Date: Wed, 16 Jun 2021 16:10:57 +0200 Message-Id: <20210616141107.291430-2-robert.foss@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210616141107.291430-1-robert.foss@linaro.org> References: <20210616141107.291430-1-robert.foss@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Ported over from the downstream driver. Is used by SM8350 DISPCC & VIDEOCC. This patch includes support for initializing interconnect bandwidth voting. Signed-off-by: Robert Foss --- drivers/clk/qcom/common.c | 92 +++++++++++++++++++++++++++++++++++++++ drivers/clk/qcom/common.h | 6 +++ 2 files changed, 98 insertions(+) -- 2.30.2 diff --git a/drivers/clk/qcom/common.c b/drivers/clk/qcom/common.c index 60d2a78d1395..1375c5de1bd1 100644 --- a/drivers/clk/qcom/common.c +++ b/drivers/clk/qcom/common.c @@ -3,13 +3,17 @@ * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. */ +#include #include +#include #include #include #include #include #include #include +#include +#include #include "common.h" #include "clk-rcg.h" @@ -329,4 +333,92 @@ int qcom_cc_probe_by_index(struct platform_device *pdev, int index, } EXPORT_SYMBOL_GPL(qcom_cc_probe_by_index); +int qcom_cc_runtime_init(struct platform_device *pdev, + struct qcom_cc_desc *desc) +{ + struct device *dev = &pdev->dev; + struct clk *clk; + int ret; + + clk = clk_get_optional(dev, "iface"); + if (IS_ERR(clk)) { + if (PTR_ERR(clk) != -EPROBE_DEFER) + dev_err(dev, "unable to get iface clock\n"); + return PTR_ERR(clk); + } + clk_put(clk); + + desc->path = of_icc_get(dev, NULL); + if (IS_ERR(desc->path)) { + if (PTR_ERR(desc->path) != -EPROBE_DEFER) + dev_err(dev, "error getting path\n"); + return PTR_ERR(desc->path); + } + + platform_set_drvdata(pdev, desc); + pm_runtime_enable(dev); + + ret = pm_clk_create(dev); + if (ret) + goto disable_pm_runtime; + + ret = pm_clk_add(dev, "iface"); + if (ret < 0) { + dev_err(dev, "failed to acquire iface clock\n"); + goto destroy_pm_clk; + } + + return 0; + +destroy_pm_clk: + pm_clk_destroy(dev); + +disable_pm_runtime: + pm_runtime_disable(dev); + icc_put(desc->path); + + return ret; +} +EXPORT_SYMBOL(qcom_cc_runtime_init); + +int qcom_cc_runtime_resume(struct device *dev) +{ + struct qcom_cc_desc *desc = dev_get_drvdata(dev); + int ret; + + if (desc->path) { + ret = icc_set_bw(desc->path, 0, 1); + if (ret) { + dev_warn(dev, "%s: failed to vote bw\n", __func__); + return ret; + } + } + + ret = pm_clk_resume(dev); + if (ret) + dev_warn(dev, "%s: failed to enable clocks\n", __func__); + + return ret; +} +EXPORT_SYMBOL(qcom_cc_runtime_resume); + +int qcom_cc_runtime_suspend(struct device *dev) +{ + struct qcom_cc_desc *desc = dev_get_drvdata(dev); + int ret; + + ret = pm_clk_suspend(dev); + if (ret) + dev_warn(dev, "%s: failed to disable clocks\n", __func__); + + if (desc->path) { + ret = icc_set_bw(desc->path, 0, 0); + if (ret) + dev_warn(dev, "%s: failed to unvote bw\n", __func__); + } + + return 0; +} +EXPORT_SYMBOL(qcom_cc_runtime_suspend); + MODULE_LICENSE("GPL v2"); diff --git a/drivers/clk/qcom/common.h b/drivers/clk/qcom/common.h index bb39a7e106d8..e2a9dbd1529d 100644 --- a/drivers/clk/qcom/common.h +++ b/drivers/clk/qcom/common.h @@ -29,6 +29,7 @@ struct qcom_cc_desc { size_t num_gdscs; struct clk_hw **clk_hws; size_t num_clk_hws; + struct icc_path *path; }; /** @@ -64,4 +65,9 @@ extern int qcom_cc_probe(struct platform_device *pdev, extern int qcom_cc_probe_by_index(struct platform_device *pdev, int index, const struct qcom_cc_desc *desc); +int qcom_cc_runtime_init(struct platform_device *pdev, + struct qcom_cc_desc *desc); +int qcom_cc_runtime_suspend(struct device *dev); +int qcom_cc_runtime_resume(struct device *dev); + #endif