From patchwork Fri Dec 22 07:26:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 122628 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1908681qgn; Thu, 21 Dec 2017 23:30:23 -0800 (PST) X-Google-Smtp-Source: ACJfBos58296pM5Ke2gIviX3+BpVvtlFrOqdII+c7B0F6ACCPsbuge4dRWnjWATQvCu0iu/fxp8g X-Received: by 10.98.110.193 with SMTP id j184mr13497396pfc.187.1513927823144; Thu, 21 Dec 2017 23:30:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513927823; cv=none; d=google.com; s=arc-20160816; b=FmSr9JinI+dCqAd6AScVN4wjTH6p/jrVG4I+QckrlW5I1X5BWniNlnPIKP+GwYjE+L XHr4ZILiqGMRWyZcrNaabfPUqqS+oiA1Tg6sCYNliCSUGb4qRNNA7D1nh1+Qb9QtHtC5 sDs1NmeUlIfIbWA4PkQe/HGoWDyuTOTuWmhegENGuqXUwrXtQhL/e+hu4bHYu3uY5Iml YGk8Q05QmIY+CHfrzJCoKvXFEtADK0p4A1oJ4s2SOgDXmQX2YrbfgTMJhDl1Prk4pEP6 KOUPBo34qeArzqywJy+z4gVMC+xUGLeH+CbXFX//DxgmhCTu/VGougtAtCZQWPbVZhju jpZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=RP/DgWyS3C/ibejXurkoyuPj6eSBTO3RrBjl+BOQ6Aw=; b=0/tekjIjKwCOSa2JcjButmgIJuE/1ZeWMCv9/bajZtY4iSQCCEnkUpsJ5u04vtoXYO cXkh4zXqvW5CJ0iEZ0MHsgoKUUpXxRPEycZp61Z6YSkPHacYx28dXijctbyAwdhASgA+ k0y/jbTrq4XdDgjfGoqyOzGrGb6BSl8nsLGjYlgkMsf7vQq+bIEIJjPukrrWOM8k2Htg aKLGi42gYFSfblklWLkE14L6ybICkfmo6X7iPsrVzC9zKizZl9V3ZhE+p5QIQNXimTo5 AYd5XGikeCTW4xFBtchSu7AenOtoh4r30wbej51KVvvE9k9/h3RYz4uozz6WEojwGtcQ CDAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AmcQKmr4; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si16075459plw.770.2017.12.21.23.30.22; Thu, 21 Dec 2017 23:30:23 -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; dkim=pass header.i=@linaro.org header.s=google header.b=AmcQKmr4; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753732AbdLVHaT (ORCPT + 28 others); Fri, 22 Dec 2017 02:30:19 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:41385 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753416AbdLVHaO (ORCPT ); Fri, 22 Dec 2017 02:30:14 -0500 Received: by mail-pg0-f68.google.com with SMTP id 77so851643pgd.8 for ; Thu, 21 Dec 2017 23:30:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=RP/DgWyS3C/ibejXurkoyuPj6eSBTO3RrBjl+BOQ6Aw=; b=AmcQKmr4ZDaCr2Kxstn6XgSpYF8b29h6jBEu/2fkS7Mx4/KukBRtC78tfcYpt+kklo w26Fm0kToKKWrI24W1uXvoFBzJD/0RC/q/r0zCL1sRRBI62lSbJsd3xdawEoWGxdqvVN hhd7mn1uun5PJDBb2zIpD0Tzjb47U4NuYdeac= 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:in-reply-to:references; bh=RP/DgWyS3C/ibejXurkoyuPj6eSBTO3RrBjl+BOQ6Aw=; b=jZsQD1OpcC8pxyQWBxwnRQmfpzxXTgYuY/51R9xtAapGnsGFgk4NaASs5ImsSwjQQ9 SYk2Y0NcyLqk/vvpOT0nHx7i65FGeCYsyd/pE5retOJAtc8+sydsvEvFruAuJ/BANrh0 +mxjU07X5yOw/Pbu38cERwfnGaZeh01U48MEDKZBUFFAtug+78qoew0495r+pwjTPgwv OzXHFRX4FbJEfbXtDRamgBNbjOVYkRNxcqCS61xRFhDtLNVqlREkUqbBXPqMZZYrTd7K FFupphNR8flfRsbbCfxAW2MOGt/hTakbCtbrFqC18tda83tQCuSV8dsxC9F2D8zWYZLS FmQA== X-Gm-Message-State: AKGB3mLVkMoFW0cfpjooUl0ufRu7Z8cGKs+piwlc3BSXzSf4zQ+lNEng zpjxeQ0bItVxFM+HVIOUyfU3Gg== X-Received: by 10.101.81.195 with SMTP id i3mr1319668pgq.260.1513927813218; Thu, 21 Dec 2017 23:30:13 -0800 (PST) Received: from localhost ([122.172.139.116]) by smtp.gmail.com with ESMTPSA id g19sm40434571pfb.65.2017.12.21.23.30.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Dec 2017 23:30:12 -0800 (PST) From: Viresh Kumar To: ulf.hansson@linaro.org, Kevin Hilman , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , robh+dt@kernel.org, rnayak@codeaurora.org, sudeep.holla@arm.com, linux-kernel@vger.kernel.org Subject: [PATCH 1/7] PM / OPP: Implement dev_pm_opp_of_add_table_indexed() Date: Fri, 22 Dec 2017 12:56:25 +0530 Message-Id: <627a1c8658a1c0cd4b96ae087c87bb3dfa1ee70a.1513926033.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.15.0.194.g9af6a3dea062 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The "operating-points-v2" property can contain a list of phandles now, specifically for the power domain providers that provide multiple domains. Add support to parse that. Signed-off-by: Viresh Kumar --- drivers/opp/of.c | 50 +++++++++++++++++++++++++++++++++++++++++--------- include/linux/pm_opp.h | 6 ++++++ 2 files changed, 47 insertions(+), 9 deletions(-) -- 2.15.0.194.g9af6a3dea062 diff --git a/drivers/opp/of.c b/drivers/opp/of.c index cb716aa2f44b..22c9bd191f62 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -250,20 +250,17 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_of_remove_table); /* Returns opp descriptor node for a device node, caller must * do of_node_put() */ -static struct device_node *_opp_of_get_opp_desc_node(struct device_node *np) +static struct device_node *_opp_of_get_opp_desc_node(struct device_node *np, + int index) { - /* - * There should be only ONE phandle present in "operating-points-v2" - * property. - */ - - return of_parse_phandle(np, "operating-points-v2", 0); + /* "operating-points-v2" can be an array for power domain providers */ + return of_parse_phandle(np, "operating-points-v2", index); } /* Returns opp descriptor node for a device, caller must do of_node_put() */ struct device_node *dev_pm_opp_of_get_opp_desc_node(struct device *dev) { - return _opp_of_get_opp_desc_node(dev->of_node); + return _opp_of_get_opp_desc_node(dev->of_node, 0); } EXPORT_SYMBOL_GPL(dev_pm_opp_of_get_opp_desc_node); @@ -509,6 +506,41 @@ int dev_pm_opp_of_add_table(struct device *dev) } EXPORT_SYMBOL_GPL(dev_pm_opp_of_add_table); +/** + * dev_pm_opp_of_add_table_indexed() - Initialize indexed opp table from device tree + * @dev: device pointer used to lookup OPP table. + * @index: Index number. + * + * Register the initial OPP table with the OPP library for given device only + * using the "operating-points-v2" property. + * + * Return: + * 0 On success OR + * Duplicate OPPs (both freq and volt are same) and opp->available + * -EEXIST Freq are same and volt are different OR + * Duplicate OPPs (both freq and volt are same) and !opp->available + * -ENOMEM Memory allocation failure + * -ENODEV when 'operating-points' property is not found or is invalid data + * in device node. + * -ENODATA when empty 'operating-points' property is found + * -EINVAL when invalid entries are found in opp-v2 table + */ +int dev_pm_opp_of_add_table_indexed(struct device *dev, int index) +{ + struct device_node *opp_np; + int ret; + + opp_np = _opp_of_get_opp_desc_node(dev->of_node, index); + if (!opp_np) + return -ENODEV; + + ret = _of_add_opp_table_v2(dev, opp_np); + of_node_put(opp_np); + + return ret; +} +EXPORT_SYMBOL_GPL(dev_pm_opp_of_add_table_indexed); + /* CPU device specific helpers */ /** @@ -613,7 +645,7 @@ int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, } /* Get OPP descriptor node */ - tmp_np = _opp_of_get_opp_desc_node(cpu_np); + tmp_np = _opp_of_get_opp_desc_node(cpu_np, 0); of_node_put(cpu_np); if (!tmp_np) { pr_err("%pOF: Couldn't find opp node\n", cpu_np); diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 6c2d2e88f066..f042fdeaaa3c 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -303,6 +303,7 @@ static inline void dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask #if defined(CONFIG_PM_OPP) && defined(CONFIG_OF) int dev_pm_opp_of_add_table(struct device *dev); +int dev_pm_opp_of_add_table_indexed(struct device *dev, int index); void dev_pm_opp_of_remove_table(struct device *dev); int dev_pm_opp_of_cpumask_add_table(const struct cpumask *cpumask); void dev_pm_opp_of_cpumask_remove_table(const struct cpumask *cpumask); @@ -314,6 +315,11 @@ static inline int dev_pm_opp_of_add_table(struct device *dev) return -ENOTSUPP; } +static inline int dev_pm_opp_of_add_table_indexed(struct device *dev, int index) +{ + return -ENOTSUPP; +} + static inline void dev_pm_opp_of_remove_table(struct device *dev) { }