From patchwork Fri Jul 9 17:31:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 471882 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp517284jao; Fri, 9 Jul 2021 10:32:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvh/8IkHsjHhzOWMZEnvpUwyWPTJcv66NF83rbtS0Uq0w7a65sln90vYvvIuFsyiqEXwo5 X-Received: by 2002:a92:cb0b:: with SMTP id s11mr4001806ilo.292.1625851933645; Fri, 09 Jul 2021 10:32:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625851933; cv=none; d=google.com; s=arc-20160816; b=fFZDsiv0bxNSXYrvVMhjusOE/H8O9T4voGonVcxjR61SZI+XmvuvnkliJ24KgK07JY 658xwjHR5kbf+RpYS5mUHk+iHk8dKBKf4aEFbnl6IRGKckIjVTGbPziLi7NgHSfrFRna 8+NRJfD5Jxg7ReN8WXjkaUg5re6j2sK8uVYxm6lU/Ke2ve5wQoT6XKbtvMZcqGtM7IqR RjCzpiP5gaq6wO814tpZThraSKVT3g20lG3Loe0Rp64zlhr/DoAIyGxzIOqCGtUx4WGf 3p0aiQaZJLWn+xpNmXHu11x/fUyXQtFeKX4P9CVB/xHUBr0kFxTiT1sR4ZufFxPUe0ED mpyA== 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=nxb0rTITqHJRawqSXL04SAf8WBgwW80hUq+O1u57DwA=; b=i4dStiwhMPV32nvmYmiCHwsxW7G3e4faDP7nfsaW1qCNMjG5tS8WQKG0l4Q6FNnnOU 4pU3u+hAYsyzDVLN6FU5qQ5NMtrI+31lVd3pPT/9RBzxP3O3WRNNRBBMPIlWxkmQzkpl 2GyzW+fDP/557xRo/+PxlNHFyMh04C+Ge1geZNCDNnAIYnht0OuvdNkt3YMMsuMwp2lk ZdSm1etW5IlAIifZ6JCWz+fNpTfcBeQsY/6RnjqHmbNkGGiJKGvdrGansaRQ+m6lDs1X QGjNq3ECAYzhM8xUBBie6ILBqFRetxp5TE+nPi9kkMpJGx4g2R+u6s2jblGxy85Wtd29 NW1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d5QZUBy6; 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 g12si6886612jas.65.2021.07.09.10.32.13; Fri, 09 Jul 2021 10:32:13 -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=d5QZUBy6; 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 S230116AbhGIRex (ORCPT + 7 others); Fri, 9 Jul 2021 13:34:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230075AbhGIRew (ORCPT ); Fri, 9 Jul 2021 13:34:52 -0400 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E915C0613E5 for ; Fri, 9 Jul 2021 10:32:08 -0700 (PDT) Received: by mail-lj1-x235.google.com with SMTP id a18so9188328ljk.6 for ; Fri, 09 Jul 2021 10:32:08 -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=nxb0rTITqHJRawqSXL04SAf8WBgwW80hUq+O1u57DwA=; b=d5QZUBy6PgE977UqHLcQ5LPYx0MYxAJIp4VNIZ+CLvguQ5qz6KAlf+rcQ9NmgYEb6e iKkEgBTulrlIDQiaP3XlbVfUHYrvxMc8LwRa2u+XX6mY+gPzvIC5DkmnfhyDb53djR+N 02RU24UU+csi+UeTI94IwFq0N6ds3LWTHgkzkWVCs7v6lSBW+oV3g4RLBtwDoN55knO7 2fE7URYaEm5L9CniSPIkNiak/1eQGE3N77AvXfIMlZKydOlioSALlYbH3vbEtloxcRus HAHNUGVo8uf5dLmJjXnGjr6+I4b0F2nJAR/voL5uR7pkAVh+RbUmCoVZHoEfkyRKE7p1 qayw== 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=nxb0rTITqHJRawqSXL04SAf8WBgwW80hUq+O1u57DwA=; b=G+lqtC8IrcMVa3hMPrI/RJnJXuJq3r+p89tCa0RiSew5f2YRpfjS7TFSq/zCrzl3wT eWsKjsaJcX0buO5FwEPBCn/r4L9c3bzlH6C0sTWUJpYWeVLgVE7J6UnglEUDPaBQDMiB NfOEzurZ0D04/Dk1KHlHiCHWfwQsyWMwQozGFe9bHFIjMuQa0pUx4R6JzvW3QRzjEjzO jrjXQE8xp6OLVM1QJid+PdkJDha8R4u3Cpa8bC5Hi/vrvgHpMoNGxRukgJOMvCEdO2Kt zr4DYfPgoiweEZ0Cash3bbZV6ZprZZnls/C1I2SuHGTT7k/e7pw5Ld+ObRHVyWf3ZA0f x+Ug== X-Gm-Message-State: AOAM532HgfY037se/75k8V6P1yf0Z5iPgIwH0V4oNhqaAtMOAKhIevHw 6MkJNab/ISoQzpH8ce4BzZ+QOA== X-Received: by 2002:a2e:97d1:: with SMTP id m17mr17280087ljj.168.1625851926598; Fri, 09 Jul 2021 10:32:06 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id b14sm511129lfb.132.2021.07.09.10.32.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jul 2021 10:32:06 -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 v3 3/7] clk: qcom: gdsc: enable optional power domain support Date: Fri, 9 Jul 2021 20:31:58 +0300 Message-Id: <20210709173202.667820-4-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210709173202.667820-1-dmitry.baryshkov@linaro.org> References: <20210709173202.667820-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org On sm8250 dispcc and videocc registers are powered up by the MMCX power domain. Currently we use 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 runtime PM and using specified for gdsc powerup. Signed-off-by: Dmitry Baryshkov --- drivers/clk/qcom/common.c | 37 +++++++++++++++++++++++++++++++------ drivers/clk/qcom/gdsc.c | 4 ++++ 2 files changed, 35 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..ccd36617d067 100644 --- a/drivers/clk/qcom/gdsc.c +++ b/drivers/clk/qcom/gdsc.c @@ -439,6 +439,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 +459,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); }