Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3592060imu; Mon, 10 Dec 2018 04:54:51 -0800 (PST) X-Google-Smtp-Source: AFSGD/WzKr4XCEOU6W16Vm/n3APdD8IUwnohmGGdknoZd1w6VbsvkjSustWL9Q7oDSMlqPayPFd2 X-Received: by 2002:a62:2606:: with SMTP id m6mr11964771pfm.133.1544446491256; Mon, 10 Dec 2018 04:54:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544446491; cv=none; d=google.com; s=arc-20160816; b=JTVE9GpxZ5sIR+7dtCle+Yz36DTlAxEN5EGI2V7CHhfBR/JiT1a9NPcqrqt+G0SlEc 4W4oBvgjkwaSsBieAIBbNTeAC+z7c7Q5R2x1KIm7XCMUeRzEuEWEScMAyM+/7pCcW21w Je3xJM5srjbmvSVsFF6iPhOdI2okbbAv+7BbfYT+X7zor/GDEiKplhv+9YXPaL0s9lyM 9M/qpC6vc//hEmbUlAmpdERN5Wm3p0Za9fXvagIEV9M0UVWA9SV15wxj2PqEg1TxnGMH /wrmIZMyfQgVXx4wZVIElGrnpcGJmVUqhm3jOCQclWLV+OZCfDHyGn+efHfxGLwucizk iLYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id; bh=XbGc5WhjRu8g0dQh14GUNA385AB4dspuGKL/INDqalI=; b=LolLQFB3rkmyllqPvZSyz2sB9CfFrJ96Q//w4PLM4ZcBEf5Lp4D2yzi2V8/1vbJOBs 5hVpKPlcn6Bz7GsSNb3471SfJi4Om8KcAZ4Pt9wy4oMvPHeo8MPwYS9LlopsCPMvDPb1 vCwkkLJFNaV8Viw9XBtegwidkHm6EmJFIZ9yCnHcQQW/aIWWcVhw/NASSDaIe2D/gL4G dgloDhQUem/RtVY6o9cTgHC9hhJh9XnBppdkARAiGD3u3Zz1NUCcPQXZfvJZ/E99VTvX fUFGwY2v3jXbCADiGA3EKb+qe8NKCkgQOcWaV76L+9ozdFpztxuW2tB0NsamAUf58ciU MJSA== 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 y11si9461709pgj.442.2018.12.10.04.54.36; Mon, 10 Dec 2018 04:54: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 S1727121AbeLJMgT (ORCPT + 99 others); Mon, 10 Dec 2018 07:36:19 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:8571 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726475AbeLJMgT (ORCPT ); Mon, 10 Dec 2018 07:36:19 -0500 X-UUID: f4a494469f034bea8d765f5be211ffc5-20181210 X-UUID: f4a494469f034bea8d765f5be211ffc5-20181210 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 82825730; Mon, 10 Dec 2018 20:36:13 +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; Mon, 10 Dec 2018 20:36:12 +0800 Received: from [172.21.77.4] (172.21.77.4) by mtkcas09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Mon, 10 Dec 2018 20:36:12 +0800 Message-ID: <1544445372.3502.42.camel@mtksdaap41> Subject: Re: [PATCH] opp: Add API for getting voltage from supplies From: Nick Fan To: Viresh Kumar CC: Viresh Kumar , Nishanth Menon , "Stephen Boyd" , "Rafael J. Wysocki" , "Matthias Brugger" , , , , , , , , Date: Mon, 10 Dec 2018 20:36:12 +0800 In-Reply-To: <20181204082158.rb7uzdiwmcotwoxh@vireshk-i7> References: <1543906760-15631-1-git-send-email-Nick.Fan@mediatek.com> <20181204082158.rb7uzdiwmcotwoxh@vireshk-i7> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4-0ubuntu2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2018-12-04 at 13:51 +0530, Viresh Kumar wrote: > On 04-12-18, 14:59, Nick Fan wrote: > > Add API to get voltage for multiple supplies from opp table > > And who needs to use this new API ? It would be better to add the user in the > same series to make sure this really gets used. This new API would be required when handling multiple regulators. You can check the example 4 in Documentation/devicetree/bindings/opp/opp.txt for multiple regulators. When we specify multiple regulator voltages in device tree, we are not able to access the secondary supply voltages. Because the dev_pm_opp_get_voltage only returns the first supply voltages, this new API is required to get the specific supply. > > > 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) > > How will the users of this API get the index ? For the users who only use one supply, they can use dev_pm_opp_get_voltage to get the voltage data from an opp. But if the users who use more than one supply, they will need this API to get their voltage data from OPP. The users should know about the supply count while creating opp table by using dev_pm_opp_set_regulators function. By using this API, the users can get the voltages by using index to specify which supplies they want. The following is a simple example to get multiple regulators by this API. for (i = 0; i < regulator_num; i++) target_volt[i] = dev_pm_opp_get_voltage_supply(opp, i); > > > +{ > > + 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; > Nick Fan