From patchwork Wed Apr 26 10:57:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 9701105 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 426FC603F4 for ; Wed, 26 Apr 2017 10:58:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B06427F90 for ; Wed, 26 Apr 2017 10:58:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2FEC028178; Wed, 26 Apr 2017 10:58:24 +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=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C57CB27F90 for ; Wed, 26 Apr 2017 10:58:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2998967AbdDZK6V (ORCPT ); Wed, 26 Apr 2017 06:58:21 -0400 Received: from mail-pg0-f48.google.com ([74.125.83.48]:34232 "EHLO mail-pg0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2998900AbdDZK5o (ORCPT ); Wed, 26 Apr 2017 06:57:44 -0400 Received: by mail-pg0-f48.google.com with SMTP id v1so31218763pgv.1 for ; Wed, 26 Apr 2017 03:57:44 -0700 (PDT) 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=B50qpEdCppdKvHSCFLGRht8u1PFQdSOBZbnakedoE6M=; b=eUkNJNJcahI6OFRQ6vQELGbXGcoXot6GH3qXd2sGbyX9tUI69qE7s7L7Qoxju4oQPW z5ANA2BbWABNwtz+KfoqUM+uizuAX9Hf5+G6Z8x3b6I1V6Hzt5k+RSyo0ykaDjh0x6pj QA1EVsQSh3HoJzHSdJzCh7IjNfWXo4IhsnRWs= 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=B50qpEdCppdKvHSCFLGRht8u1PFQdSOBZbnakedoE6M=; b=iNnHMwNu0lU0/rVEHiXra5EHifrgEReHsT9Yz2YyxZbWwAlwIY6JciUAOryQ18+qvv w8gByQXenVuvLLGrs1/0EMmDPttpA9/JJJGAbMU3d5kTnbrPjpCUoTA6t5VfZ9ebdqO5 L1Ofa22ZRimc/J1S6tXX3VCuQxXJacBV2eKRBXHLWweHscKO5IcPnUtVh9OIorFA50X5 ThKPu4gMBPTjneoHqNHW+ge1fRn1o0HLIOXfAJy+EAGEkYakoc0hunQuW63j+fw5x5fw +u9ZmbUqJd6jZi4wsrGTgv7fIVmz+NoCnoOxHMSfnUHwyTOo3EANK1jwB4ULcCddWEO4 04VQ== X-Gm-Message-State: AN3rC/7+tSGj7zsQl66yZ2Pz4OS/+6Kq/MgCfF/ubGeaf223r9Xj215U fYaQhk5kg6JMXs+L X-Received: by 10.84.230.229 with SMTP id e92mr42379318plk.2.1493204264240; Wed, 26 Apr 2017 03:57:44 -0700 (PDT) Received: from localhost ([122.172.121.5]) by smtp.gmail.com with ESMTPSA id p6sm41912810pgn.9.2017.04.26.03.57.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Apr 2017 03:57:43 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , ulf.hansson@linaro.org, Kevin Hilman , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Guittot , robh+dt@kernel.org, lina.iyer@linaro.org, rnayak@codeaurora.org, sudeep.holla@arm.com, Viresh Kumar Subject: [PATCH V6 6/9] PM / OPP: Implement dev_pm_opp_of_add_table_indexed() Date: Wed, 26 Apr 2017 16:27:10 +0530 Message-Id: <2268452b1c6929fc5b08c34aec9a06ebd0993461.1493203884.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.12.0.432.g71c3a4f4ba37 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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/base/power/opp/of.c | 50 +++++++++++++++++++++++++++++++++++++++------ include/linux/pm_opp.h | 6 ++++++ 2 files changed, 50 insertions(+), 6 deletions(-) diff --git a/drivers/base/power/opp/of.c b/drivers/base/power/opp/of.c index 77693ba3ed55..9cdf3a848e69 100644 --- a/drivers/base/power/opp/of.c +++ b/drivers/base/power/opp/of.c @@ -243,14 +243,17 @@ void dev_pm_opp_of_remove_table(struct device *dev) EXPORT_SYMBOL_GPL(dev_pm_opp_of_remove_table); /* 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) +static struct device_node *_of_get_opp_desc_node_indexed(struct device *dev, + int index) { - /* - * There should be only ONE phandle present in "operating-points-v2" - * property. - */ + /* "operating-points-v2" can be an array for power domain providers */ + return of_parse_phandle(dev->of_node, "operating-points-v2", index); +} - return of_parse_phandle(dev->of_node, "operating-points-v2", 0); +/* 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 _of_get_opp_desc_node_indexed(dev, 0); } EXPORT_SYMBOL_GPL(dev_pm_opp_of_get_opp_desc_node); @@ -572,6 +575,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 = _of_get_opp_desc_node_indexed(dev, 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 */ /** diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index a6685b3dde26..8263d831715c 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -284,6 +284,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); @@ -295,6 +296,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) { }