Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1453076pxu; Thu, 17 Dec 2020 10:14:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJwHDCrbBNeQCkkU6n0m7FetYTS24AhMGQ9Wpnv1nYUoWsFAEmxQA65eHbhlqiPWP1N1LOSE X-Received: by 2002:a50:d50a:: with SMTP id u10mr645119edi.58.1608228895437; Thu, 17 Dec 2020 10:14:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608228895; cv=none; d=google.com; s=arc-20160816; b=yk9Xxdw4fpV8sz9ec8Au7JIXvLXVdH7nHEtBdb3NVba5wCd1X3GPpQDu0oVfCgI09l hwEbY9WINUD/N581f2P/xl4HJrmYFwrfQrINbrAqKm29BuNrobJEnpifVgYA7j2cqhxT i/H4SxZw0Mv0oCMVkDBfUZG7z444SQYyp9Qz9/F93J2183oyNlRih9PpOMbkQXvVFl6B GfK0f/KF5+aqzMXiUUbu6KWo4oPewX2AAf2bToMcKBF18LFKO7Eag5WDTgevjJqR2sqb 749o26hE9zbf8/BLxnkAZvdE7+IzIqgMjEAeAJjjW1fsL/mana8XSP62uyUsCONeUYny n5Sw== 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=vPD7hQ8b5N25hcZTdVSAqhZrBeZE9ONbNkTdFW8v87g=; b=iu+4b2OjcXl9qO6BA8AwRtMYNbkjmlApV7C52Rtuc3dXrDh1x63aOgUHt5l/9+hjS8 Za0duKMPL8rYnO7GMW0VS/BDP4hGLl4OZd2CieoyEZx9AFLuR8bjmgnrfJo9Sg1vqQob ZSSCptAvZcmzjPoA+2Vzjz/wHS64C+Wjq2/mlFzYO6Q8sjBOpoczSqbyvgnjWiInQVWU tYAuS/PvDk+WJ9yArmfCyDYynBL2UgOhZa71fnCu5yRHDAWycp6oDEPZIf4vf0HiZ2I6 vy+8fD31CGHF5eLPqgLJiHe2SM+71GBVaRBCcspAOak1LtcI49u9uslleciYSpJBv/hb BEBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ChchZyVr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c22si5017700edj.34.2020.12.17.10.14.32; Thu, 17 Dec 2020 10:14:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=@gmail.com header.s=20161025 header.b=ChchZyVr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731282AbgLQSMu (ORCPT + 99 others); Thu, 17 Dec 2020 13:12:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730216AbgLQSIo (ORCPT ); Thu, 17 Dec 2020 13:08:44 -0500 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B7C4C0611CF; Thu, 17 Dec 2020 10:07:35 -0800 (PST) Received: by mail-lf1-x134.google.com with SMTP id o13so36631787lfr.3; Thu, 17 Dec 2020 10:07:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vPD7hQ8b5N25hcZTdVSAqhZrBeZE9ONbNkTdFW8v87g=; b=ChchZyVri0yi/O25dvPeSHNQEk3sLXfZVskKc7CN57GBdMMTmWURalf2IM6i2rgvhh qfcMtU+PS/OCGaJjeaVHDM2wBUNa8Tg9f7+ONq/dSM6byM/Y8iogLVMrfOj4dNFwy2Xm Ps6rz8w/7z9Mz8vRMGfOZ86sU3M3S0FpRWA4hoISaf7GtzBRBYpB/pOJM78wLmrasMEr /gb3uNc548kJHGE9V2DfBbDDkAnqUyLpzfbxhrKpEumO23OdI8D7by5pViVe1cJ16DXd 4yhnxob5KSGfDuhxWiH1oLSuAV4B7pIQHOcN3N/ZWY1erLsW1JFmbo1HRGSDSIF6T5LI wT3w== 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=vPD7hQ8b5N25hcZTdVSAqhZrBeZE9ONbNkTdFW8v87g=; b=SknprHSEzF813dbEmKVR1JbvWnI34zRa9YWnAE7c0uFxk6I0GkBc24q2CvBtc511J5 WlZ34fOn5+MLmtHiM648i8FkRNBi1axD8aup8S4PUG5fptuol1cSBWmV77hwYAl6eAn9 g3Bznq0myyO0LD2d/DLgJa35rTZSTTS7GC2LYHCHDSHErA0rVou6ZQVAdv+l4gGALfaL +Hrt47Vb1vSHIpWMudUTGAVhDZ2RjqvoSCbvG8scoUJPlkL13STEGhK+Ejela91U85yb wC2/D5aITrX42+Zmvhsu4kZCqPtp4Z4yz0pgS/C249UPgKUr3BsjZxgAaHVzbAZ/KYSL 7bVw== X-Gm-Message-State: AOAM530pXJl6ZcpKPpybxC+WNrHEcx1AT4GSh/og57XtKJpLbjYKmwsQ WqhyPMvakO2BCGUEszECrNQ= X-Received: by 2002:a2e:a404:: with SMTP id p4mr220062ljn.260.1608228453811; Thu, 17 Dec 2020 10:07:33 -0800 (PST) Received: from localhost.localdomain (109-252-192-57.dynamic.spd-mgts.ru. [109.252.192.57]) by smtp.gmail.com with ESMTPSA id u5sm655596lff.78.2020.12.17.10.07.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 10:07:33 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Mark Brown , Liam Girdwood , Ulf Hansson , Mauro Carvalho Chehab , Rob Herring , Peter Geis , Nicolas Chauvet , Krzysztof Kozlowski , "Rafael J. Wysocki" , Kevin Hilman , Peter De Schrijver , Viresh Kumar , Stephen Boyd , Michael Turquette Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, linux-clk@vger.kernel.org Subject: [PATCH v2 12/48] opp: Add dev_pm_opp_get_required_pstate() Date: Thu, 17 Dec 2020 21:06:02 +0300 Message-Id: <20201217180638.22748-13-digetx@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201217180638.22748-1-digetx@gmail.com> References: <20201217180638.22748-1-digetx@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add dev_pm_opp_get_required_pstate() which allows OPP users to retrieve required performance state of a given OPP. Signed-off-by: Dmitry Osipenko --- drivers/opp/core.c | 22 ++++++++++++++++++++++ include/linux/pm_opp.h | 10 ++++++++++ 2 files changed, 32 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 0783a4ac819a..4774701ec82d 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -145,6 +145,28 @@ unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp) } EXPORT_SYMBOL_GPL(dev_pm_opp_get_level); +/** + * dev_pm_opp_get_required_pstate() - Gets the required performance state + * corresponding to an available opp + * @opp: opp for which performance state has to be returned for + * @index: index of the required opp + * + * Return: performance state read from device tree corresponding to the + * required opp, else return 0. + */ +unsigned int dev_pm_opp_get_required_pstate(struct dev_pm_opp *opp, + unsigned int index) +{ + if (IS_ERR_OR_NULL(opp) || !opp->available || + index >= opp->opp_table->required_opp_count) { + pr_err("%s: Invalid parameters\n", __func__); + return 0; + } + + return opp->required_opps[index]->pstate; +} +EXPORT_SYMBOL_GPL(dev_pm_opp_get_required_pstate); + /** * dev_pm_opp_is_turbo() - Returns if opp is turbo OPP or not * @opp: opp for which turbo mode is being verified diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index a17d92d923cc..0298b426fba3 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -98,6 +98,9 @@ unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp); unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp); +unsigned int dev_pm_opp_get_required_pstate(struct dev_pm_opp *opp, + unsigned int index); + bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp); int dev_pm_opp_get_opp_count(struct device *dev); @@ -188,6 +191,13 @@ static inline unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp) return 0; } +static inline +unsigned int dev_pm_opp_get_required_pstate(struct dev_pm_opp *opp, + unsigned int index) +{ + return 0; +} + static inline bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp) { return false; -- 2.29.2