From patchwork Fri Dec 14 09:17:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Fan X-Patchwork-Id: 10730755 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5ACDB14DE for ; Fri, 14 Dec 2018 09:18:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 488682D31A for ; Fri, 14 Dec 2018 09:18:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3BF562D31B; Fri, 14 Dec 2018 09:18:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E69072D319 for ; Fri, 14 Dec 2018 09:18:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=Ydnh9dApgknYSWO5IKY7fd2OM/WFjVMlCdVD2Zr0/6M=; b=dkVAXIlWNX+XA6 o7nP5mPmZi0kn+o4xH44WSiYu8Olw4kJXvc2ItlUD4Q+dZGtVpTiSofT/cZbnwk0iwCebBaUmE8m/ XUd+G9UeltXEZhVKP1gjsKHKz2fIOYWu62l/o9tLXkdJH1nTERRtNquCNxAEf/NV86n2UjHvyKJYl KxII+56gL5+cDb6M3Inda5vDPEzRYEzs9vhKJQOd8aoTMcXCKewnpcYAt2Vy+wmcCgzKUNUdi1B0V epFPyB2lWw6d3ij31qzbDkW6UgPUSZNW0b7ynpxQ7VASeFhColVIPfd/Bz93VYjfOJQmiAPWZ6FAb YoBNhWUQZrm5O5ReimYA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gXjc5-00057M-FD; Fri, 14 Dec 2018 09:18:29 +0000 Received: from [210.61.82.183] (helo=mailgw01.mediatek.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gXjc1-00055l-BQ; Fri, 14 Dec 2018 09:18:27 +0000 X-UUID: e4c31ede5efa483cbe5fa465c901535a-20181214 X-UUID: e4c31ede5efa483cbe5fa465c901535a-20181214 Received: from mtkcas07.mediatek.inc [(172.21.101.84)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1641462383; Fri, 14 Dec 2018 17:18:06 +0800 Received: from mtkcas09.mediatek.inc (172.21.101.178) by mtkmbs03n1.mediatek.inc (172.21.101.181) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 14 Dec 2018 17:18:05 +0800 Received: from mtksdaap41.mediatek.inc (172.21.77.4) by mtkcas09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Fri, 14 Dec 2018 17:18:05 +0800 From: Nick Fan To: Viresh Kumar Subject: [RFC PATCH] [RESEND] opp: Add API for getting voltage from supplies Date: Fri, 14 Dec 2018 17:17:42 +0800 Message-ID: <1544779062-8276-1-git-send-email-Nick.Fan@mediatek.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181214_011825_528532_C378751F X-CRM114-Status: UNSURE ( 9.97 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nishanth Menon , Chiawen.Lee@mediatek.com, srv_heupstream@mediatek.com, linux-pm@vger.kernel.org, Stephen Boyd , erin.lo@mediatek.com, "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, tfiga@chromium.org, linux-mediatek@lists.infradead.org, Matthias Brugger , Nick Fan , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP [Resending because the previous attempt did not reach the mailing lists.] This new API is needed for a downstream GPU driver, but posting it as an RFC to make sure that we implement it in a potentially upstreamable way or in case someone needs it for an upstream user later. Add API to get voltage for multiple supplies from opp table Signed-off-by: Nick Fan --- drivers/opp/core.c | 28 ++++++++++++++++++++++++++++ include/linux/pm_opp.h | 3 +++ 2 files changed, 31 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 2c2df4e..ee73546 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -113,6 +113,34 @@ unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp) EXPORT_SYMBOL_GPL(dev_pm_opp_get_voltage); /** + * dev_pm_opp_get_voltage_supply() - Gets the voltage corresponding to an opp + * with index + * @opp: opp for which voltage has to be returned for + * @index: index to specify the returned supplies + * + * Return: voltage in micro volt corresponding to the opp with index, else + * return 0 + * + * This is useful for devices with multiple power supplies. + */ +unsigned long dev_pm_opp_get_voltage_supply(struct dev_pm_opp *opp, + unsigned int index) +{ + if (IS_ERR_OR_NULL(opp)) { + pr_err("%s: Invalid parameters\n", __func__); + return 0; + } + + if (index >= opp->opp_table->regulator_count) { + pr_err("%s: Invalid supply index: %u\n", __func__, index); + return 0; + } + + return opp->supplies[index].u_volt; +} +EXPORT_SYMBOL_GPL(dev_pm_opp_get_voltage_supply); + +/** * dev_pm_opp_get_freq() - Gets the frequency corresponding to an available opp * @opp: opp for which frequency has to be returned for * diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 5d399eee..2f1c2a8 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -84,6 +84,9 @@ struct dev_pm_set_opp_data { unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp); +unsigned long dev_pm_opp_get_voltage_supply(struct dev_pm_opp *opp, + unsigned int index); + unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp); bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp);