From patchwork Fri Sep 11 12:02:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 7160301 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3B4269F314 for ; Fri, 11 Sep 2015 12:06:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5D0CC207E4 for ; Fri, 11 Sep 2015 12:06:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6C960207BD for ; Fri, 11 Sep 2015 12:06:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753195AbbIKMDt (ORCPT ); Fri, 11 Sep 2015 08:03:49 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:34240 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753184AbbIKMDq (ORCPT ); Fri, 11 Sep 2015 08:03:46 -0400 Received: by padhy16 with SMTP id hy16so73643042pad.1 for ; Fri, 11 Sep 2015 05:03:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=42J2Cd/wG3Ay4X+F9x+s7yIkftanXuP7VK/OdIx2xnM=; b=LBJWaMQMjdvAGq6/2H+DeyW20V/g1mQgTI+g1+sTtJGdLTFcZxCKjgnjdpgKSBX5Ie Cp6CNb02NxyM1+P2SoZyL0rVuagkJWLwHXyJ+naxpwZqMlRVzG+8az/2VnpoIvIWk4Wi IktgsttHpMKU7TcpkW+w65avXLphzbIooBzLMh1ITGSHjviMzZSveckLRvIcaY4ZLMB7 2uPCnUqrllkgA1pb14KPowusyb30e4ohhxh/KTJAZgj9OvTeyUh853JPQ8KkFrAITNGg T/yh2pWsVYIUPfWE84rZ4JTORUM3r5PKCJisEmwsouHgDjc5mcZGJsP89JOQzeniDPRp rNqQ== X-Gm-Message-State: ALoCoQkeRja1uq8sSZjPVusOZvK+bRbiUsTvCy9Bf5/nNw7nponocqLqcrIwMm9G21XkavVtqE6S X-Received: by 10.68.108.67 with SMTP id hi3mr38456928pbb.36.1441973026424; Fri, 11 Sep 2015 05:03:46 -0700 (PDT) Received: from localhost ([122.171.186.190]) by smtp.gmail.com with ESMTPSA id jd12sm52050pbd.44.2015.09.11.05.03.45 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 11 Sep 2015 05:03:45 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , nm@ti.com, sboyd@codeaurora.org Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, rob.herring@linaro.org, lee.jones@linaro.org, Viresh Kumar , Bartlomiej Zolnierkiewicz , Dmitry Torokhov , Greg Kroah-Hartman , Len Brown , linux-kernel@vger.kernel.org (open list), Pavel Machek Subject: [PATCH 10/16] PM / OPP: Introduce dev_pm_opp_get_max_volt_latency() Date: Fri, 11 Sep 2015 17:32:06 +0530 Message-Id: X-Mailer: git-send-email 2.4.0 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-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In few use cases (like: cpufreq), it is desired to get the maximum voltage latency for changing OPPs. Add support for that. Signed-off-by: Viresh Kumar --- drivers/base/power/opp/core.c | 59 +++++++++++++++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 6 +++++ 2 files changed, 65 insertions(+) diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c index 04fe181b8132..e272e738a8d0 100644 --- a/drivers/base/power/opp/core.c +++ b/drivers/base/power/opp/core.c @@ -226,6 +226,65 @@ unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev) EXPORT_SYMBOL_GPL(dev_pm_opp_get_max_clock_latency); /** + * dev_pm_opp_get_max_volt_latency() - Get max voltage latency in nanoseconds + * @dev: device for which we do this operation + * + * Return: This function returns the max voltage latency in nanoseconds. + * + * Locking: This function takes rcu_read_lock(). + */ +unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev) +{ + struct device_opp *dev_opp; + struct dev_pm_opp *opp; + struct opp_supply *supply; + struct regulator *reg; + unsigned long latency_ns = 0; + unsigned long min_uV, max_uV; + int count, ret; + + rcu_read_lock(); + + dev_opp = _find_device_opp(dev); + if (IS_ERR(dev_opp)) + goto unlock; + + /* Sum max latencies for all supplies */ + for (count = 0; count < dev_opp->supply_count; count++) { + min_uV = ~0; + max_uV = 0; + + reg = dev_opp->regulators[count]; + + /* Regulator may not be available for device */ + if (IS_ERR(reg)) + continue; + + list_for_each_entry_rcu(opp, &dev_opp->opp_list, node) { + if (!opp->available) + continue; + + supply = opp->supplies + count; + + if (supply->u_volt_min < min_uV) + min_uV = supply->u_volt_min; + if (supply->u_volt_max > max_uV) + max_uV = supply->u_volt_max; + } + + ret = regulator_set_voltage_time(reg, min_uV, max_uV); + if (ret > 0) + latency_ns += ret * 1000; + } + +unlock: + rcu_read_unlock(); + + return latency_ns; +} +EXPORT_SYMBOL_GPL(dev_pm_opp_get_max_volt_latency); + +/** * dev_pm_opp_get_suspend_opp() - Get suspend opp * @dev: device for which we do this operation * diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 9a2e50337af9..fd58e2074721 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -34,6 +34,7 @@ bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp); int dev_pm_opp_get_opp_count(struct device *dev); unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev); +unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev); struct dev_pm_opp *dev_pm_opp_get_suspend_opp(struct device *dev); struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, @@ -81,6 +82,11 @@ static inline unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev) return 0; } +static inline unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev) +{ + return 0; +} + static inline struct dev_pm_opp *dev_pm_opp_get_suspend_opp(struct device *dev) { return NULL;