From patchwork Mon Apr 9 11:43:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 133028 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp168208ljb; Mon, 9 Apr 2018 04:44:24 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+h+5x1GRmf8L0797ljTmEpI+mPIVYRPdu4s4cgZgmMoBO8kTatTn9h9RJvWwFBL/iFmDKc X-Received: by 10.99.141.200 with SMTP id z191mr24735565pgd.418.1523274264212; Mon, 09 Apr 2018 04:44:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523274264; cv=none; d=google.com; s=arc-20160816; b=t4kIty/W6cY44XAKW4SktjO/ex+p7bAd5SaqBVu2fepq6Ca/WDp8QIbgw4tEdWm4mk AKn9GSC7X2UNm8CXO78tv329dKXrvwwxttkP3+PT4s8L3BUtTvIJHLVuGtWB2lDlmef7 jgTQChktCz1OLt0iX5uKRY9xHZ/G8a2dQD0wJQJ/q/d9H88vMd0ct3hKuBxowBHQ2+eQ tNIPMVRnCPKObGKNChCXP+F6ofYhZkgyytuvnfCVGbw+Quc1uSYKfbJe7GL8NjucKdPO 1yPxFGPFD6HAf1grJe8uinUfL9HxDJI5BkOm0ygKRRExbz0+bpwNbeMXc2btsulzTUo7 tIzQ== 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=WdS1s08ambvg+/6ENbYIlW1EjELUFM/jas13qlT23FY=; b=1G7Cu+VAnKiUrV6/hTQ/3lMd1grUaUFiCYEsI6Hdfw5hi5Wfk2t1wl+JzUOiZim4v4 NYTY0sHUdDMiRP7lGvwtQj0cAgNVRfIPH09tb6bWCz/61t7CSY6jj0OH1pOZ/WuaDH6d sp3BAXfJYcYQQ8r+T7xf41s2jdzd/1iA0vzQny4q7lssrHmfSHCDdru2Meu/yELq+lp7 F+yTF/W7ReIikY6eqz1nmB8ixsnnsRMurgFFhZXQoM3NBMeNi1q4o751ZiL18lcM+XEw 32JE4pYBdLE4pDQqnVlG675/wijToM/CYO+AkO928gdLGZT6GzXGa6DNc46s0APcDPH2 irwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Rx+aZzAX; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 j188si105815pgc.584.2018.04.09.04.44.23; Mon, 09 Apr 2018 04:44:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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=Rx+aZzAX; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 S1751707AbeDILoX (ORCPT + 11 others); Mon, 9 Apr 2018 07:44:23 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:45372 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751728AbeDILoW (ORCPT ); Mon, 9 Apr 2018 07:44:22 -0400 Received: by mail-pg0-f66.google.com with SMTP id y63so145285pgy.12 for ; Mon, 09 Apr 2018 04:44:22 -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=WdS1s08ambvg+/6ENbYIlW1EjELUFM/jas13qlT23FY=; b=Rx+aZzAX95hH22Jf7U+F/Z183LburqQIvUkShSx9/sIyyZib9sUiJbPeahtx6MP4B3 2dzgd2fSNIpBXl+1bprPlyReyT7ymJyettaV918Tic9/eVb9mYZ6788CySRreD6xUM5t NiRk9JNIJnA93q1Rc8CdzwZvbpNd01fFXtTyU= 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=WdS1s08ambvg+/6ENbYIlW1EjELUFM/jas13qlT23FY=; b=LRtDnJMQQgf8tHHa8otpI4fxdW6fI2oyapVUaBbZ45Hzb0dIRie6ro14or7OEzCVVp 9ozCiYZvqgs5Iz7X5dzjpJroCI3gN3zSjHA46epDeae+KH0sFCUD8is2SmexGJNsobJ1 vXGC8eRIcC+0bLJc6q7pgnWd9M6oBPOiBNnt14R1gBZMDiOqu+xEplYyv5gsEp53nPDT W8UO5mopec1EQWORLXnFnB7lSatTAGzfCx/tcokznKlVWv0DAVBRZQ/TyHBhOfaiyT1y /ad41SlZxybMBeqfn6LfJZnU39t5FBIPMpHYh9h6lnIMwfN9zR/gsE1flVAr/znky1Hg 1QVQ== X-Gm-Message-State: AElRT7H+oPGI9klIurxFPJGjWcmaujn7zhCKpNEON2Kph4BHMjOvLuob CE5iRlqSdTnrkhB3BEcqFKBfAw== X-Received: by 10.98.194.195 with SMTP id w64mr29082692pfk.83.1523274261983; Mon, 09 Apr 2018 04:44:21 -0700 (PDT) Received: from localhost ([122.171.228.188]) by smtp.gmail.com with ESMTPSA id 86sm824818pfh.93.2018.04.09.04.44.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Apr 2018 04:44:21 -0700 (PDT) From: Viresh Kumar To: Ulf Hansson , Stephen Boyd , Viresh Kumar , Nishanth Menon , "Rafael J. Wysocki" Cc: Viresh Kumar , Rajendra Nayak , Vincent Guittot , linux-pm@vger.kernel.org Subject: [PATCH V2 04/11] PM / OPP: Implement dev_pm_opp_of_add_table_indexed() Date: Mon, 9 Apr 2018 17:13:44 +0530 Message-Id: <30a8780632ca0d32dc8cf52ee12cef840a3a032d.1523273291.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-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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 Reviewed-by: Ulf Hansson --- 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 c5c5afcaa2e3..cba669cd00c5 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); @@ -517,6 +514,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 */ /** @@ -621,7 +653,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) { }