From patchwork Wed Aug 23 11:45:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 716786 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2542EE49B5 for ; Wed, 23 Aug 2023 11:45:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234480AbjHWLpu (ORCPT ); Wed, 23 Aug 2023 07:45:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234449AbjHWLpt (ORCPT ); Wed, 23 Aug 2023 07:45:49 -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 82F67E65 for ; Wed, 23 Aug 2023 04:45:41 -0700 (PDT) Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2b95d5ee18dso85330341fa.1 for ; Wed, 23 Aug 2023 04:45:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692791140; x=1693395940; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=O7tHqCtCBwrBi+V5VhXtnXcNtgviyB9B8EoBzfXwamQ=; b=E8GWGehguy7PP4MX5+Ef/QMUDP9jO042Djy0QuWaaJ8WBLX960EVJOJ5JAdzm6aXxS iFAsnk0PL4/fdEY9CHQ7JfdtzDW5RJ/ggoQpMcg9306EQ7lr5CZ+NR3RUnunLpQ3budb x+zdO03UVyovdggvHc4COXayuwUhMl67cK8Ne3sKgJhe7lGliC53GDaqz/Nus8BDuI7G gKqssHAGlbvdVCK/mjBJ2tNrRfpWcHTv8acmqxf7g6FXdVcZmUrNXIubaeT7V+70AMId AsNTSLsDHOoqmVD/huyhBJ6+MM/GBvTyBE6u14nvmL6bz2gc0T6OZCWPqvlvU6WS1xHT wzqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692791140; x=1693395940; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=O7tHqCtCBwrBi+V5VhXtnXcNtgviyB9B8EoBzfXwamQ=; b=lgYN1an3ON8RJVFqTgc57ool8p7Kzouwv5681Pp4YnhJrqCR8ywEb4L05poAb4Nfvp vIsilYD6mIg+N0amHsI9VKhbSKDWTAGsBXJjVQ6BlZwilj7RQ6WWMah8JOi4LrpVIsor nttHC49lbrKCvNEFrYOvJcgP60fd9a7m4mMkfrW+NQ0JQXaqYRspnUrZsyiWLPK6ipRN xcxXcyBkuK/bwEv9KNJ+T1+/KbsNI7xP64qphCmCxgT6dOtaoDt2q/u+DKwk4aB9ZvZM ulVxpCHl2L3QDVTCSnSCNu9BIc5XpVPd683sdAjm8RJasNSA7LCvfcorpVGiVdDTHjuk /BiA== X-Gm-Message-State: AOJu0Yx9FHPh+QTFD72T4bSo/9u/Gy6a6E/qFQG7EHERpMY6Z6EOAn0o xgGZkKSYqO4WeFL5muK+DmS1Xg== X-Google-Smtp-Source: AGHT+IHdwziasj0D1MZ9uBcdhByqBC95ew9J9TcFICwlP0Jl9zRXSGXh3Dl8RPw6cWdVo/fTvnM4uQ== X-Received: by 2002:a2e:88d1:0:b0:2b6:cff1:cd1c with SMTP id a17-20020a2e88d1000000b002b6cff1cd1cmr9657741ljk.34.1692791139858; Wed, 23 Aug 2023 04:45:39 -0700 (PDT) Received: from hackbox.lan ([84.232.191.92]) by smtp.gmail.com with ESMTPSA id m18-20020a7bce12000000b003fbc0a49b57sm18503577wmc.6.2023.08.23.04.45.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Aug 2023 04:45:39 -0700 (PDT) From: Abel Vesa To: "Rafael J . Wysocki" , Kevin Hilman , Ulf Hansson , Pavel Machek , Len Brown , Greg Kroah-Hartman , Bjorn Andersson , Andy Gross , Konrad Dybcio , Mike Turquette , Stephen Boyd , Taniya Das Cc: linux-pm@vger.kernel.org, Linux Kernel Mailing List , linux-arm-msm@vger.kernel.org, Taniya Das Subject: [PATCH v3 2/5] PM: domains: Add the domain HW-managed mode to the summary Date: Wed, 23 Aug 2023 14:45:25 +0300 Message-Id: <20230823114528.3677667-3-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230823114528.3677667-1-abel.vesa@linaro.org> References: <20230823114528.3677667-1-abel.vesa@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Now that genpd supports dynamically switching the control for an attached device between hardware- and software-mode, let's add this information to the genpd summary in debugfs. Suggested-by: Taniya Das Signed-off-by: Abel Vesa --- Changes since v2: * Reworded the commit according to Ulf's suggestion * Dropped the _mode suffix from the status * Replaced "mode" with "managed by" in summary show function drivers/base/power/domain.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index dfb4f1de540d..93350e67b0e8 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -3171,6 +3171,15 @@ static void rtpm_status_str(struct seq_file *s, struct device *dev) seq_printf(s, "%-25s ", p); } +static void mode_status_str(struct seq_file *s, struct device *dev) +{ + struct generic_pm_domain_data *gpd_data; + + gpd_data = to_gpd_data(dev->power.subsys_data->domain_data); + + seq_printf(s, "%20s", gpd_data->hw_mode ? "HW" : "SW"); +} + static void perf_status_str(struct seq_file *s, struct device *dev) { struct generic_pm_domain_data *gpd_data; @@ -3229,6 +3238,7 @@ static int genpd_summary_one(struct seq_file *s, seq_printf(s, "\n %-50s ", kobj_path); rtpm_status_str(s, pm_data->dev); perf_status_str(s, pm_data->dev); + mode_status_str(s, pm_data->dev); kfree(kobj_path); } @@ -3245,8 +3255,9 @@ static int summary_show(struct seq_file *s, void *data) int ret = 0; seq_puts(s, "domain status children performance\n"); - seq_puts(s, " /device runtime status\n"); - seq_puts(s, "----------------------------------------------------------------------------------------------\n"); + seq_puts(s, " /device runtime status managed by\n"); + seq_puts(s, "------------------------------------------------------------------------------------------------------------\n"); + ret = mutex_lock_interruptible(&gpd_list_lock); if (ret) From patchwork Wed Aug 23 11:45:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 716785 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05D59EE49B4 for ; Wed, 23 Aug 2023 11:45:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234483AbjHWLpv (ORCPT ); Wed, 23 Aug 2023 07:45:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234467AbjHWLpu (ORCPT ); Wed, 23 Aug 2023 07:45:50 -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 27E32E69 for ; Wed, 23 Aug 2023 04:45:43 -0700 (PDT) Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2b962c226ceso85857611fa.3 for ; Wed, 23 Aug 2023 04:45:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692791141; x=1693395941; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mIFCktYXgfosXvRJrwvf1Hn5zhw2HJrFavQvWXV6mTw=; b=FdRXZNWCys86ONbUfYvQt0vxbvSb4HIgklznVQGdtN+rWYFQDHN5vkpve/5CJnNfn0 5s3VZrvsls5p+XGkTBmmmRvnisaiCbLVuu6WfI0LmwzJSHFlQGrxqLlb94eSRvdV89CH loGY5WrubIPPZJFot0gctKFAddpdRDYdQFoJ8O9IMyntHzizVbRSShqJ13RIOVWaaU/P H3fL9VZZ6ojindXZV0JU6IVQMgsegNpiMBwb/8ZOZ1R0DKhNj9dhlXnhzJjQ6SuHnVgS AUW6q+ue5ZhZhqD8S56ehtCFHqUVKhKt3CQ65kViyjmuobxfaM5uvejp3PI0Lg8wB7JX Mqlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692791141; x=1693395941; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mIFCktYXgfosXvRJrwvf1Hn5zhw2HJrFavQvWXV6mTw=; b=CF3iaiRNSArDalEQCbXnL6H4KABqT2c+ZZWRb1ppJmAsOZKNam3SItjXHbBNWFLj7v Z1GQlFltArFij8jJV6fCECG07MQu6sFPrMMMs9V/8XkrzVYUB6S3qdq6gdIH3QGXzzRa Yv4TCyInQcQcbIHRcTe499czQmCubbSn7QHSpZRsUfPglQ3HehfNPoZyZd/j+v5732gI s95+HJtQ3g0gpme4czo49U3D6CGjucfX+GiGfjK9QtQYmUklrUL4N6EWeHjLMVCM52VU A0GasJ8UIt9NeiS8WxJ4qSYMCMNPGB+ddImzhO4BcQdMSxBupnBdRX6B/Xr2sKELBHOH ILoQ== X-Gm-Message-State: AOJu0Ywfsm/YFcd/wg9Xch95cdGyqtsq9h+KDbSdZeA5YhiFIks8C0Ch zlyUnv5RGlQyT9AMvUV1bstL5g== X-Google-Smtp-Source: AGHT+IGfHdql2lUUitqm6RYx89C3kDrLaaP4sDPXsex/N/CCvhLQQH+Cc4IngnkpCXY+EGU9voq4uA== X-Received: by 2002:a2e:9546:0:b0:2b9:ed84:b2bf with SMTP id t6-20020a2e9546000000b002b9ed84b2bfmr8931106ljh.33.1692791141363; Wed, 23 Aug 2023 04:45:41 -0700 (PDT) Received: from hackbox.lan ([84.232.191.92]) by smtp.gmail.com with ESMTPSA id m18-20020a7bce12000000b003fbc0a49b57sm18503577wmc.6.2023.08.23.04.45.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Aug 2023 04:45:40 -0700 (PDT) From: Abel Vesa To: "Rafael J . Wysocki" , Kevin Hilman , Ulf Hansson , Pavel Machek , Len Brown , Greg Kroah-Hartman , Bjorn Andersson , Andy Gross , Konrad Dybcio , Mike Turquette , Stephen Boyd , Taniya Das Cc: linux-pm@vger.kernel.org, Linux Kernel Mailing List , linux-arm-msm@vger.kernel.org, Jagadeesh Kona Subject: [PATCH v3 3/5] clk: qcom: gdsc: Add set and get hwmode callbacks to switch GDSC mode Date: Wed, 23 Aug 2023 14:45:26 +0300 Message-Id: <20230823114528.3677667-4-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230823114528.3677667-1-abel.vesa@linaro.org> References: <20230823114528.3677667-1-abel.vesa@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Jagadeesh Kona Add support for set and get hwmode callbacks to switch the GDSC between SW and HW modes. Currently, the GDSC is moved to HW control mode using HW_CTRL flag and if this flag is present, GDSC is moved to HW mode as part of GDSC enable itself. The intention is to keep the HW_CTRL flag functionality as is, since many older chipsets still use this flag. Introduce a new HW_CTRL_TRIGGER flag to switch the GDSC back and forth between HW/SW modes dynamically at runtime. If HW_CTRL_TRIGGER flag is present, register set_hwmode_dev callback to switch the GDSC mode which can be invoked from consumer drivers using dev_pm_genpd_set_hwmode function. Unlike HW_CTRL flag, HW_CTRL_TRIGGER won't move the GDSC to HW control mode as part of GDSC enable itself, GDSC will be moved to HW control mode only when consumer driver explicity calls dev_pm_genpd_set_hwmode to switch to HW mode. Also add the dev_pm_genpd_get_hwmode to allow the consumers to read the actual HW/SW mode from hardware. Signed-off-by: Jagadeesh Kona Signed-off-by: Abel Vesa --- Changes since v2: * Renamed gdsc_[set|get]_mode to have the hwmode suffix drivers/clk/qcom/gdsc.c | 32 ++++++++++++++++++++++++++++++++ drivers/clk/qcom/gdsc.h | 1 + 2 files changed, 33 insertions(+) diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c index 5358e28122ab..c763524cd5da 100644 --- a/drivers/clk/qcom/gdsc.c +++ b/drivers/clk/qcom/gdsc.c @@ -363,6 +363,34 @@ static int gdsc_disable(struct generic_pm_domain *domain) return 0; } +static int gdsc_set_hwmode(struct generic_pm_domain *domain, struct device *dev, bool mode) +{ + struct gdsc *sc = domain_to_gdsc(domain); + + if (sc->rsupply && !regulator_is_enabled(sc->rsupply)) { + pr_err("Cannot set mode while parent is disabled\n"); + return -EIO; + } + + return gdsc_hwctrl(sc, mode); +} + +static bool gdsc_get_hwmode(struct generic_pm_domain *domain, struct device *dev) +{ + struct gdsc *sc = domain_to_gdsc(domain); + u32 val; + int ret; + + ret = regmap_read(sc->regmap, sc->gdscr, &val); + if (ret) + return ret; + + if (val & HW_CONTROL_MASK) + return true; + + return false; +} + static int gdsc_init(struct gdsc *sc) { u32 mask, val; @@ -451,6 +479,10 @@ static int gdsc_init(struct gdsc *sc) sc->pd.power_off = gdsc_disable; if (!sc->pd.power_on) sc->pd.power_on = gdsc_enable; + if (sc->flags & HW_CTRL_TRIGGER) { + sc->pd.set_hwmode_dev = gdsc_set_hwmode; + sc->pd.get_hwmode_dev = gdsc_get_hwmode; + } ret = pm_genpd_init(&sc->pd, NULL, !on); if (ret) diff --git a/drivers/clk/qcom/gdsc.h b/drivers/clk/qcom/gdsc.h index 803512688336..1e2779b823d1 100644 --- a/drivers/clk/qcom/gdsc.h +++ b/drivers/clk/qcom/gdsc.h @@ -67,6 +67,7 @@ struct gdsc { #define ALWAYS_ON BIT(6) #define RETAIN_FF_ENABLE BIT(7) #define NO_RET_PERIPH BIT(8) +#define HW_CTRL_TRIGGER BIT(9) struct reset_controller_dev *rcdev; unsigned int *resets; unsigned int reset_count; From patchwork Wed Aug 23 11:45:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 716784 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2C2EEE49BC for ; Wed, 23 Aug 2023 11:45:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234476AbjHWLpw (ORCPT ); Wed, 23 Aug 2023 07:45:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234477AbjHWLpu (ORCPT ); Wed, 23 Aug 2023 07:45:50 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 663A3E70 for ; Wed, 23 Aug 2023 04:45:46 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2bccda76fb1so30479221fa.2 for ; Wed, 23 Aug 2023 04:45:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692791144; x=1693395944; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mj2meqHj1uQ8ycW47wSLw+vGt1Gkm3UaWY3FGRdov4I=; b=LxvOihteykPsbq0ELFTsjunH9/Ll/sHYoF0bL2a2KmEegWSK8l3PyI9a5mqt/x1VYu YBppL1uMhdjmPARq5c7mFKF0ek45ULf1vCjrkQRwiRGQBW68DfWSattIGoViHoWRHImk pRC6/mClZ+V8jq7/nxnYcEGU241WIaqTkuzwykfJDWGrzIDEGLMWw0e0ClhnX7st4rpE x4FJAxwrWpuJXQ/DWzKFQYq6TqCJsu/HnQaZHI/ZKuekcveLchxOJnU/ATtJRoUyNwrV vb7PglOWtDhHcnC1IRbAd4AOVBd29xdbxDwIzif9js0jEWQcj6akAa3xt4+Sp3rvZUOW I1Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692791144; x=1693395944; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mj2meqHj1uQ8ycW47wSLw+vGt1Gkm3UaWY3FGRdov4I=; b=ChydoNCqBoj2jhMKHKIlObMTVDJWVJC1evjVeiG00kf1/CJut++s6O+dauABxvSGXb N1qvPY6p3oW1Iz2fvxh1v9vI6Tewq+3shHHWIlqoqQS7Q2BSyYIiERpkFNCtDpS+2yD+ odNLT4lL2shwmJWE73Llwy8yY6lCFq8/1EHk7rrKByjfmgp9a9BhYBKNbq1/ce970ikt QrBSwmi/cQX2mfmCotl6Dar+p9BRvEzKpWQ8gf+eOXovpBNQShHYcndTN43emmr74sof 0cULVIdlKtqC2s/wjTYEPBc1fJ0xH4DiuZ9ToruSlo7hKxXoswEFe+IgchU6TGDdwwek Gtjw== X-Gm-Message-State: AOJu0YzKmNP/dLJ7ix0TpHzX7u+H2ZToZW9zDINfTndikUufD9HlZwr8 cwT9g2fW3V5kuOhpwAJm13xzqg== X-Google-Smtp-Source: AGHT+IHcRniuOaTwNb3qeIRnIhh7FLNsaHEOk7sAt8OJGcjm/DL1E6rAHN1GjxntF7AtC9iXjIu26g== X-Received: by 2002:a2e:908a:0:b0:2bc:b0c3:9e8d with SMTP id l10-20020a2e908a000000b002bcb0c39e8dmr8678383ljg.41.1692791144651; Wed, 23 Aug 2023 04:45:44 -0700 (PDT) Received: from hackbox.lan ([84.232.191.92]) by smtp.gmail.com with ESMTPSA id m18-20020a7bce12000000b003fbc0a49b57sm18503577wmc.6.2023.08.23.04.45.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Aug 2023 04:45:44 -0700 (PDT) From: Abel Vesa To: "Rafael J . Wysocki" , Kevin Hilman , Ulf Hansson , Pavel Machek , Len Brown , Greg Kroah-Hartman , Bjorn Andersson , Andy Gross , Konrad Dybcio , Mike Turquette , Stephen Boyd , Taniya Das Cc: linux-pm@vger.kernel.org, Linux Kernel Mailing List , linux-arm-msm@vger.kernel.org, Jagadeesh Kona Subject: [PATCH v3 5/5] venus: pm_helpers: Use dev_pm_genpd_set_hwmode to switch GDSC mode Date: Wed, 23 Aug 2023 14:45:28 +0300 Message-Id: <20230823114528.3677667-6-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230823114528.3677667-1-abel.vesa@linaro.org> References: <20230823114528.3677667-1-abel.vesa@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Jagadeesh Kona This change demonstrates the use of dev_pm_genpd_set_hwmode API from video driver to switch the video mvs0 gdsc to SW/HW modes at runtime based on requirement. This change adds a new boolean array member vcodec_pmdomains_hwctrl in venus_resources structure to indicate if GDSC's have HW control support or not. This data is used in vcodec_control_v4() to check if GDSC has support to switch to HW control mode and then call dev_pm_genpd_set_hwmode to switch the GDSC mode. Before the GDSC HWCTL was available to the consumer, the venus driver needed to somehow keep the power from collapsing while under the driver control. The only way to do that was to clear the CORE_PWR_DISABLE bit (in wrapper POWER_CONTROL register) and, respectively, set it back after the driver control was completed. Now, that there is a way to switch the GDSC HW/SW control back and forth, the CORE_PWR_DISABLE toggling can be dropped. Signed-off-by: Jagadeesh Kona Signed-off-by: Abel Vesa --- Changes since v2: * Explained the removal of the POWER_CONTROL register toggle and why the fact the GDSC HW control knob availability to the consumer renders that useless. drivers/media/platform/qcom/venus/core.c | 4 ++ drivers/media/platform/qcom/venus/core.h | 1 + .../media/platform/qcom/venus/pm_helpers.c | 47 ++++++++----------- 3 files changed, 25 insertions(+), 27 deletions(-) diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c index 054b8e74ba4f..8145062ab6f7 100644 --- a/drivers/media/platform/qcom/venus/core.c +++ b/drivers/media/platform/qcom/venus/core.c @@ -706,6 +706,7 @@ static const struct venus_resources sdm845_res_v2 = { .vcodec1_clks = { "vcodec1_core", "vcodec1_bus" }, .vcodec_clks_num = 2, .vcodec_pmdomains = { "venus", "vcodec0", "vcodec1" }, + .vcodec_pmdomains_hwctrl = { false, true, true }, .vcodec_pmdomains_num = 3, .opp_pmdomain = (const char *[]) { "cx", NULL }, .vcodec_num = 2, @@ -755,6 +756,7 @@ static const struct venus_resources sc7180_res = { .vcodec0_clks = { "vcodec0_core", "vcodec0_bus" }, .vcodec_clks_num = 2, .vcodec_pmdomains = { "venus", "vcodec0" }, + .vcodec_pmdomains_hwctrl = { false, true }, .vcodec_pmdomains_num = 2, .opp_pmdomain = (const char *[]) { "cx", NULL }, .vcodec_num = 1, @@ -812,6 +814,7 @@ static const struct venus_resources sm8250_res = { .vcodec0_clks = { "vcodec0_core" }, .vcodec_clks_num = 1, .vcodec_pmdomains = { "venus", "vcodec0" }, + .vcodec_pmdomains_hwctrl = { false, true }, .vcodec_pmdomains_num = 2, .opp_pmdomain = (const char *[]) { "mx", NULL }, .vcodec_num = 1, @@ -871,6 +874,7 @@ static const struct venus_resources sc7280_res = { .vcodec0_clks = {"vcodec_core", "vcodec_bus"}, .vcodec_clks_num = 2, .vcodec_pmdomains = { "venus", "vcodec0" }, + .vcodec_pmdomains_hwctrl = { false, true }, .vcodec_pmdomains_num = 2, .opp_pmdomain = (const char *[]) { "cx", NULL }, .vcodec_num = 1, diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index 4a633261ece4..6d591ecad482 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -73,6 +73,7 @@ struct venus_resources { const char * const vcodec1_clks[VIDC_VCODEC_CLKS_NUM_MAX]; unsigned int vcodec_clks_num; const char * const vcodec_pmdomains[VIDC_PMDOMAINS_NUM_MAX]; + bool vcodec_pmdomains_hwctrl[VIDC_PMDOMAINS_NUM_MAX]; unsigned int vcodec_pmdomains_num; const char **opp_pmdomain; unsigned int vcodec_num; diff --git a/drivers/media/platform/qcom/venus/pm_helpers.c b/drivers/media/platform/qcom/venus/pm_helpers.c index 48c9084bb4db..c53eef23c793 100644 --- a/drivers/media/platform/qcom/venus/pm_helpers.c +++ b/drivers/media/platform/qcom/venus/pm_helpers.c @@ -408,35 +408,28 @@ static const struct venus_pm_ops pm_ops_v3 = { static int vcodec_control_v4(struct venus_core *core, u32 coreid, bool enable) { - void __iomem *ctrl, *stat; - u32 val; - int ret; - - if (IS_V6(core)) { - ctrl = core->wrapper_base + WRAPPER_CORE_POWER_CONTROL_V6; - stat = core->wrapper_base + WRAPPER_CORE_POWER_STATUS_V6; - } else if (coreid == VIDC_CORE_ID_1) { - ctrl = core->wrapper_base + WRAPPER_VCODEC0_MMCC_POWER_CONTROL; - stat = core->wrapper_base + WRAPPER_VCODEC0_MMCC_POWER_STATUS; - } else { - ctrl = core->wrapper_base + WRAPPER_VCODEC1_MMCC_POWER_CONTROL; - stat = core->wrapper_base + WRAPPER_VCODEC1_MMCC_POWER_STATUS; - } - - if (enable) { - writel(0, ctrl); - - ret = readl_poll_timeout(stat, val, val & BIT(1), 1, 100); - if (ret) - return ret; - } else { - writel(1, ctrl); + int i, ret = 0; + struct device *dev = core->dev; + const struct venus_resources *res = core->res; - ret = readl_poll_timeout(stat, val, !(val & BIT(1)), 1, 100); - if (ret) - return ret; + for (i = 0; i < res->vcodec_pmdomains_num; i++) { + if (res->vcodec_pmdomains_hwctrl[i]) { + + if (!core->pmdomains[i]) + return -ENODEV; + + /* + * enable( true ), switch the gdsc to SW mode + * enable( false), switch the gdsc to HW mode + */ + ret = dev_pm_genpd_set_hwmode(core->pmdomains[i], !enable); + if (ret) { + dev_err(dev, "Failed to switch power-domain:%d to %s mode\n", + i, enable ? "SW" : "HW"); + return ret; + } + } } - return 0; }