Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1844076imu; Fri, 14 Dec 2018 01:19:51 -0800 (PST) X-Google-Smtp-Source: AFSGD/Vr4Yxrug5kgqWmMiA2F32WJsXMVDnPcq0NaY7blVVqtQ1E24lFZRzn5S+E8U3zwLybhhZl X-Received: by 2002:a62:7892:: with SMTP id t140mr2066214pfc.237.1544779191662; Fri, 14 Dec 2018 01:19:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544779191; cv=none; d=google.com; s=arc-20160816; b=bSJ0+bMbkbNEqcrFb8mgdkOi8DPx2oEtmBVI91pEmV1SIHsgPOE2WzLg7etHZEWP5a EhPfCUidGKSuCQfwSzfWmr0NINaTio3QD/a5lvNGs6W9MdG7KKl3q5cQaQ5RrbX5xzGy C2OfvHqjic2cqtvMhG6/CgPmqCNkepTGq8mgpLrZXSDDZBJoEzfoEbXSe3F+Gj1zgdR/ 2XFiAvAn8ER/nj8V0tLZvHhJ9upc2GuG0iX/pkdyrt1fIPVHdoAxYbyx6Myaws72L/zf qYMp7rk43gGZCBpskJGlRf9VhvuLSyHGipicLgbaMbf5nckQ0dkisH9ZjV9GzC+Il7wh 1CWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=fxq8pij29WmpAgY4ZiD1TCdq7gk1aZ/0fOzPfnQjvk8=; b=jBL6/Ig0sZEbl/ajQgXRcBa2rdohnvuYFymJjz+P8/3sdY7e6zy7oVOktDJxIcRJb9 OFH43yRP91G25ujWG2sxp1kDJXRiDmgoH6mH8mTBUrwP//V3xyKeEX84bCA4Jwgxy+iB SCjUBsAM52N2c7oBRXfvcV+0+VaL2gm3M8E9vWTY9xlArk9pVoC+7kXIBCB6EyYKe/wB PgG5iUo2SQJU7I7JN9ueOzeXX5yV4ZPiEM1PKXtqCY+Okt8FmBgzrDrbZBmeKsSMm5dp AQ8wUBTmcqwliJ/Pn1QKkQpG0v1zpb4hU7utVKOtd4BkZzL42hAz6nRifcRDCodARTH3 SKaA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f63si3635878pfg.136.2018.12.14.01.19.36; Fri, 14 Dec 2018 01:19:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728613AbeLNJSQ (ORCPT + 99 others); Fri, 14 Dec 2018 04:18:16 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:54166 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727698AbeLNJSP (ORCPT ); Fri, 14 Dec 2018 04:18:15 -0500 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 CC: Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" , Matthias Brugger , , , , , , , , , Nick Fan 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 Content-Type: text/plain X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [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); -- 1.9.1