From patchwork Wed Jun 19 14:08:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13703857 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A40B0C2BA15 for ; Wed, 19 Jun 2024 14:10:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=CDWaPf7+TN9M1cnbl/7mu5+omOHy+MPUVcUqdXnYMd8=; b=Q5gHRD2FerodRuZecimWq01zUf XZBa9tFiEvulXhN3DArJahYl4b6qxb7HYsYAhCIkGK7Il1CD07oefl54PqQ5fp37dsz5gCmYYCuv2 1TMSaGFQ45wApPfmE3X3QFeiiZUq2QnDfrUR6eR1ddhixnhThHNWA1l++i4TJyZCqz+WG/vulSvCQ YYRYSdkvot5ytKKyXn9mT27FCwFAhwfpCgnFkYUXdKUM7a8lsFcqZb0GSlLTZOUkN/dXkSwQjru+a ZB5Ua8XQkgkV6cvKz/+ZtqymzVVoj8hqwiUXvO1RUNoy6YUgenYVQ9wAXTWF1zyloL97a6dGXbT7f rTWh4tmg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJw0R-00000001RLk-2SNL; Wed, 19 Jun 2024 14:09:47 +0000 Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJvzt-00000001R0d-31Rv for linux-arm-kernel@lists.infradead.org; Wed, 19 Jun 2024 14:09:15 +0000 Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-52bc27cfb14so8015408e87.0 for ; Wed, 19 Jun 2024 07:09:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718806152; x=1719410952; darn=lists.infradead.org; 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=CDWaPf7+TN9M1cnbl/7mu5+omOHy+MPUVcUqdXnYMd8=; b=LkE3QGi1kLpHZOaxxkQwUu35n0LaoNnO8kHeseL4wcO7Xg2tlhMR7INFpfxYBi+ddV +CDLUFaW4A4nXDPKZ/YHm1TXiFGz2wnykNv5sfKr2xuEKxOfl4cwa7VEk6/YkEbDjlau pYoyqlI74Df9XDijWjkknJ747Qcuwfy4G/ZD3ggDZTfT1Z/7sRm57rP75Lzh1ga9x5BP CIgfB8iVBee8mKbuxux/07/+DA8c7Jd/DwPYwlfzWzqZNqMQTBSLFeSlH/dYZrNYF0RO ka2CnyMwovoKWNt/9n4nA8hfV5fUY6l/qqDLLkYHK5iCNxvriYr5uzhZ+HleI85ACwS5 xCDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718806152; x=1719410952; 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=CDWaPf7+TN9M1cnbl/7mu5+omOHy+MPUVcUqdXnYMd8=; b=QhxRKaQ02R8UCNM9CroV4goJN0uZQMMlC8UN+Tx/mB7ca0dUWAO3ViWSwItFKWQT8k zgNcUwC3k7hbYHoXf/+uVo3mP4GFdIazjS9Mi0SBiCfR/6C3EST4iHzwbK17cGGnBx4j QPCzlCdoGomrD5aIvkFfN7gsmFHTCHYUgBYmTQO2nW3gC46w4YHzroUdE66JCP8vjp0H sQVZk9yMdOYf+9KI60LrZak5fg7ouFYN9bKalUTYtCjRVnJyuvo2o6jJy+FeEmigrWDu aztcz6yBJQvQUv/d/+4wKYVOvYl6gm+dW9aHQNHJ9Qxd7uW6OVip1PeJ0JcOlOshLVwt HQVw== X-Forwarded-Encrypted: i=1; AJvYcCUfvNm9+E0BB0LkOl0UzddEdDAY0cc4y+Wl/wjnd1oMBU2peOhiKTg4tCxHMEaeXR6AoVe0oOo08MiVZPJn0lwKI2phPjSfArWonskInfvtdlDcO5Q= X-Gm-Message-State: AOJu0YzsfAHb5Btg7iMEI/2IfDkxQkjMfxztez1NUrbDx14z2p6XUJz6 0X4ZjW/LqI5eT0RP36Hfi+9XuujaJ85neRBuXJqrnnFmZ1MggKN3pLeO8+JsOCU= X-Google-Smtp-Source: AGHT+IFbKCEpIt59r0vwx09Jj3ZBoGPhwAYQUSf6Kkwln2POjh4upJ24OJAsVYPh1tHMRchYqc0ZgA== X-Received: by 2002:a05:6512:e8c:b0:52c:aaa1:977e with SMTP id 2adb3069b0e04-52cca8b0e87mr2662675e87.0.1718806151472; Wed, 19 Jun 2024 07:09:11 -0700 (PDT) Received: from uffe-tuxpro14.. (h-178-174-189-39.A498.priv.bahnhof.se. [178.174.189.39]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-52ca2872241sm1787003e87.124.2024.06.19.07.09.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jun 2024 07:09:11 -0700 (PDT) From: Ulf Hansson To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Bjorn Andersson , Konrad Dybcio , Nikunj Kela , Prasad Sodagudi , Thierry Reding , Jonathan Hunter , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/7] OPP: Introduce an OF helper function to inform if required-opps is used Date: Wed, 19 Jun 2024 16:08:46 +0200 Message-Id: <20240619140849.368580-5-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240619140849.368580-1-ulf.hansson@linaro.org> References: <20240619140849.368580-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240619_070913_799998_9B10BB45 X-CRM114-Status: GOOD ( 14.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org As being shown from a subsequent change to genpd, it's useful to understand if a device's OF node has an OPP-table described and whether it contains OPP nodes that makes use of the required-opps DT property. For this reason, let's introduce an OPP OF helper function called dev_pm_opp_of_has_required_opp(). Signed-off-by: Ulf Hansson --- drivers/opp/of.c | 32 ++++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 6 ++++++ 2 files changed, 38 insertions(+) diff --git a/drivers/opp/of.c b/drivers/opp/of.c index 282eb5966fd0..55c8cfef97d4 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -1443,6 +1443,38 @@ int of_get_required_opp_performance_state(struct device_node *np, int index) } EXPORT_SYMBOL_GPL(of_get_required_opp_performance_state); +/** + * dev_pm_opp_of_has_required_opp - Find out if a required-opps exists. + * @dev: The device to investigate. + * + * Returns true if the device's node has a "operating-points-v2" property and if + * the corresponding node for the opp-table describes opp nodes that uses the + * "required-opps" property. + * + * Return: True if a required-opps is present, else false. + */ +bool dev_pm_opp_of_has_required_opp(struct device *dev) +{ + struct device_node *opp_np, *np; + int count; + + opp_np = _opp_of_get_opp_desc_node(dev->of_node, 0); + if (!opp_np) + return false; + + np = of_get_next_available_child(opp_np, NULL); + of_node_put(opp_np); + if (!np) { + dev_warn(dev, "Empty OPP table\n"); + return false; + } + + count = of_count_phandle_with_args(np, "required-opps", NULL); + of_node_put(np); + + return count > 0; +} + /** * dev_pm_opp_get_of_node() - Gets the DT node corresponding to an opp * @opp: opp for which DT node has to be returned for diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 2b6599f6037d..5fade5c4de40 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -476,6 +476,7 @@ int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpuma struct device_node *dev_pm_opp_of_get_opp_desc_node(struct device *dev); struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp); int of_get_required_opp_performance_state(struct device_node *np, int index); +bool dev_pm_opp_of_has_required_opp(struct device *dev); int dev_pm_opp_of_find_icc_paths(struct device *dev, struct opp_table *opp_table); int dev_pm_opp_of_register_em(struct device *dev, struct cpumask *cpus); int dev_pm_opp_calc_power(struct device *dev, unsigned long *uW, @@ -554,6 +555,11 @@ static inline int of_get_required_opp_performance_state(struct device_node *np, return -EOPNOTSUPP; } +static inline bool dev_pm_opp_of_has_required_opp(struct device *dev) +{ + return false; +} + static inline int dev_pm_opp_of_find_icc_paths(struct device *dev, struct opp_table *opp_table) { return -EOPNOTSUPP;