From patchwork Fri Jul 9 01:30:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 471761 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp830239jao; Thu, 8 Jul 2021 18:31:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSk1TPbSb19zAdyND03TL82yN9KrM+KtDq8bh6C+97zEVlkzpTgtxaDoDdKotBnsGYsp8v X-Received: by 2002:a17:906:16cd:: with SMTP id t13mr13576684ejd.250.1625794307059; Thu, 08 Jul 2021 18:31:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625794307; cv=none; d=google.com; s=arc-20160816; b=c5RcKxpB+Tmg9eo1Gc6Fe4Ub5DmtqbgHkYlO0k8WQX0xWpGeNXnmsqZRo+yDS3No33 i8n8DmXun60931qRbkDHb1qr3fS8MtzCDJW2dVhhqJ2xWLMJ9j3NAkX6hEivWVR2sRdT hdUjyGB683ggJxM6Z4CDHOMil8pYq7j+kZzBPLkMXER8K0PvpLLP8izANzMbrnKzCt0W G2DQgznVUwnFgvQLO+7dNzFUWAdVlxFVA58p2mvPiOn3D7UtpJs1Xy4M99qNp4MmsZmU dIowZbfhEAkx8qyEAzSt/qefV3cSso5sUISAd53pf0kkz4UUbI7l5NAcRY3q0Vkj5T0i PIpA== 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=89M3kJH8Z+ezz3X5xX4Jb+p6yEZY6o3ZbKwB3aRtLuw=; b=z1ysn+vV77wwFlfibyBdxzbGoi/QzpmuOGmIOE3m5zhH4N9g1E7fVg1SOKhq7kaVN/ 0o/7D7jsFkr9uE7BGPCrUCbh1uezxuBDlec0ob0NWHER5AGQnS/eQXC9UEo3nhacHWfi r79lH+aMeKLYWn4hSqVMDTPJKmDn3loO0VHNYq70V/34JZ6KCwV0Thxci8FNIHWIr7xj GLz0i2Uy9HumtM0zncZVxPX/gmJ90PxrIN1zrN61GKSkaAjdTcnGS/nVNYxQM/F33dZF pC3rvRQEmCRHlWf3+CQOKrkToSQK00+nAkEMZlpxrL1zqFLTw5JAHbKrdjzT4eXz+yml ypEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yoiW7ZFu; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-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 hb19si4810005ejc.597.2021.07.08.18.31.46; Thu, 08 Jul 2021 18:31:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-msm-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=yoiW7ZFu; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-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 S230440AbhGIBdj (ORCPT + 17 others); Thu, 8 Jul 2021 21:33:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230375AbhGIBdf (ORCPT ); Thu, 8 Jul 2021 21:33:35 -0400 Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A754C06175F for ; Thu, 8 Jul 2021 18:30:52 -0700 (PDT) Received: by mail-lj1-x232.google.com with SMTP id q184so4858608ljq.0 for ; Thu, 08 Jul 2021 18:30:52 -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=89M3kJH8Z+ezz3X5xX4Jb+p6yEZY6o3ZbKwB3aRtLuw=; b=yoiW7ZFuSlfNOroLD2nvWqab6XWApbxovd9lF6axBaihMwQRpP5yZvXh1v5FrYjkfu t/EeMmokjrecX5fojZ6cQK1C3ZMr/TpiyNMvsv2M5yEC1xgBnmA3/i7u/2OK+uS6lxDy RiMuy8bhw22etISLo/TvxZmR2qNbjEhQ/urtbT0PAEzLFCYJkFAM9HTmRD/9QFo6yprM CGfwJhVLfDEMgc/WBrtKE2t4lza23imUcUn5ryHko2+KrT5brI4Gd9nRPKGAtxE6WExW g7jnsvWz1Tqe+Ewn0oMyTS/IbqX6jsOg8MBHLAIwIcMNEgjUloPNs8UTReO6ee/8IYhh ByHA== 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=89M3kJH8Z+ezz3X5xX4Jb+p6yEZY6o3ZbKwB3aRtLuw=; b=uIhYxorxL4zqM69O+d7c9I/HFQi86LLUGCHtY9SXtTJ4n3LpAcT6ws222oHtj6uDAZ wtJA8Lx8P2EmJBkDUu48JAEzCRXYeXMIRBkaC+Lue/abXVGRr5GwoBAyuiiGKcoDatsA qw9cERA7OMp2C11O9dQsrHd6D24wauYQs1RP2G+nWI8HxoYJk+TmJzJV4A5DGOUGdyyY xoY04vNfCxcN1s31+KBngd4Ca41Dh0Yg53R6a+F0JvrTpa3sM7ggj5vRtATAKRuPgd1C JpYeho2sDVyntMFafFSxDr0dkQXZMC2/SgE4ZPiJ7jehBvY+cn7HzUQwEzGc+xIg4AIu 5lKw== X-Gm-Message-State: AOAM5331VaP0c4aIJra7ViLEyCxgCF/iZMiGLRcEbkQdwPJHYKe++hRB 5+y5+OxG4dTXUdrtFyRMf2It7Q== X-Received: by 2002:a2e:7302:: with SMTP id o2mr18519317ljc.245.1625794250704; Thu, 08 Jul 2021 18:30:50 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id u16sm405637ljj.113.2021.07.08.18.30.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jul 2021 18:30:50 -0700 (PDT) From: Dmitry Baryshkov To: Andy Gross , Bjorn Andersson , Rob Herring , Stephen Boyd , Taniya Das , Jonathan Marek , Michael Turquette Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-clk@vger.kernel.org, Bryan O'Donoghue , Mark Brown , Ulf Hansson , linux-kernel@vger.kernel.org Subject: [PATCH v2 4/7] clk: qcom: gdsc: enable optional power domain support Date: Fri, 9 Jul 2021 04:30:40 +0300 Message-Id: <20210709013043.495233-5-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210709013043.495233-1-dmitry.baryshkov@linaro.org> References: <20210709013043.495233-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org On sm8250 dispcc and videocc registers are powered up by the MMCX power domain. Currently we used a regulator to enable this domain on demand, however this has some consequences, as genpd code is not reentrant. Teach Qualcomm clock controller code about setting up power domains and using them for gdsc control. Signed-off-by: Dmitry Baryshkov --- drivers/clk/qcom/common.c | 37 +++++++++++++++++++++++++++++++------ drivers/clk/qcom/gdsc.c | 5 +++++ 2 files changed, 36 insertions(+), 6 deletions(-) -- 2.30.2 diff --git a/drivers/clk/qcom/common.c b/drivers/clk/qcom/common.c index 60d2a78d1395..43d8f8feeb3c 100644 --- a/drivers/clk/qcom/common.c +++ b/drivers/clk/qcom/common.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "common.h" #include "clk-rcg.h" @@ -224,6 +225,11 @@ static struct clk_hw *qcom_cc_clk_hw_get(struct of_phandle_args *clkspec, return cc->rclks[idx] ? &cc->rclks[idx]->hw : NULL; } +static void qcom_cc_pm_runtime_disable(void *data) +{ + pm_runtime_disable(data); +} + int qcom_cc_really_probe(struct platform_device *pdev, const struct qcom_cc_desc *desc, struct regmap *regmap) { @@ -241,6 +247,18 @@ int qcom_cc_really_probe(struct platform_device *pdev, if (!cc) return -ENOMEM; + pm_runtime_enable(dev); + ret = pm_runtime_get_sync(dev); + if (ret < 0) { + pm_runtime_put(dev); + pm_runtime_disable(dev); + return ret; + } + + ret = devm_add_action_or_reset(dev, qcom_cc_pm_runtime_disable, dev); + if (ret) + goto err; + reset = &cc->reset; reset->rcdev.of_node = dev->of_node; reset->rcdev.ops = &qcom_reset_ops; @@ -251,7 +269,7 @@ int qcom_cc_really_probe(struct platform_device *pdev, ret = devm_reset_controller_register(dev, &reset->rcdev); if (ret) - return ret; + goto err; if (desc->gdscs && desc->num_gdscs) { scd = devm_kzalloc(dev, sizeof(*scd), GFP_KERNEL); @@ -262,11 +280,11 @@ int qcom_cc_really_probe(struct platform_device *pdev, scd->num = desc->num_gdscs; ret = gdsc_register(scd, &reset->rcdev, regmap); if (ret) - return ret; + goto err; ret = devm_add_action_or_reset(dev, qcom_cc_gdsc_unregister, scd); if (ret) - return ret; + goto err; } cc->rclks = rclks; @@ -277,7 +295,7 @@ int qcom_cc_really_probe(struct platform_device *pdev, for (i = 0; i < num_clk_hws; i++) { ret = devm_clk_hw_register(dev, clk_hws[i]); if (ret) - return ret; + goto err; } for (i = 0; i < num_clks; i++) { @@ -286,14 +304,21 @@ int qcom_cc_really_probe(struct platform_device *pdev, ret = devm_clk_register_regmap(dev, rclks[i]); if (ret) - return ret; + goto err; } ret = devm_of_clk_add_hw_provider(dev, qcom_cc_clk_hw_get, cc); if (ret) - return ret; + goto err; + + pm_runtime_put(dev); return 0; + +err: + pm_runtime_put(dev); + + return ret; } EXPORT_SYMBOL_GPL(qcom_cc_really_probe); diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c index 51ed640e527b..9401d01533c8 100644 --- a/drivers/clk/qcom/gdsc.c +++ b/drivers/clk/qcom/gdsc.c @@ -427,6 +427,7 @@ int gdsc_register(struct gdsc_desc *desc, continue; scs[i]->regmap = regmap; scs[i]->rcdev = rcdev; + scs[i]->pd.dev.parent = desc->dev; ret = gdsc_init(scs[i]); if (ret) return ret; @@ -439,6 +440,8 @@ int gdsc_register(struct gdsc_desc *desc, continue; if (scs[i]->parent) pm_genpd_add_subdomain(scs[i]->parent, &scs[i]->pd); + else if (!IS_ERR_OR_NULL(dev->pm_domain)) + pm_genpd_add_subdomain(pd_to_genpd(dev->pm_domain), &scs[i]->pd); } return of_genpd_add_provider_onecell(dev->of_node, data); @@ -457,6 +460,8 @@ void gdsc_unregister(struct gdsc_desc *desc) continue; if (scs[i]->parent) pm_genpd_remove_subdomain(scs[i]->parent, &scs[i]->pd); + else if (!IS_ERR_OR_NULL(dev->pm_domain)) + pm_genpd_remove_subdomain(pd_to_genpd(dev->pm_domain), &scs[i]->pd); } of_genpd_del_provider(dev->of_node); }