From patchwork Tue Dec 22 10:16:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 58847 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3139615lbb; Tue, 22 Dec 2015 02:16:40 -0800 (PST) X-Received: by 10.98.74.207 with SMTP id c76mr2312026pfj.147.1450779400651; Tue, 22 Dec 2015 02:16:40 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id sw10si3585212pab.55.2015.12.22.02.16.40; Tue, 22 Dec 2015 02:16:40 -0800 (PST) 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; 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; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932657AbbLVKQj (ORCPT + 11 others); Tue, 22 Dec 2015 05:16:39 -0500 Received: from mail-pa0-f53.google.com ([209.85.220.53]:34243 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932181AbbLVKQj (ORCPT ); Tue, 22 Dec 2015 05:16:39 -0500 Received: by mail-pa0-f53.google.com with SMTP id uo6so10383268pac.1 for ; Tue, 22 Dec 2015 02:16:39 -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=8yfdyVfClyOPymPKmC5eOcVpVGQuy9jUsIDvKgluXP0=; b=MJdxwEZ6j/xD3E2ANnqeqZ5hakrui4w0Lz0EUJaYcFskdYkSDDsAcu2Y4dGYG3ImQJ d48c8QLpThUUENTji/7/s9GM4DsVu0chFCibUui5i8G9PzGYMK8QcOIW9hBT1Bwv49YL i8Q/kWthk+gviVZnN73iM5qSEoXAjtAx9CgU8= 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=8yfdyVfClyOPymPKmC5eOcVpVGQuy9jUsIDvKgluXP0=; b=fs0cPQqiEkf7inpkI3XsMRW1/DnJgvZAjSsq5y/lUNOuU5en0uN+Cl6zln8hZ59hTM 5pOMGKnFU9Vd4/l9uyeG6X9SkQhEwP+vb3uGFr9RsC5/ny8ewe89o52jbnlyz5nq5lkb ErvHlH1EGWUvZfr8jt1NrQe0YOYl3iLsV9KkmDTuVfGNM72AmYXuHsguz8VTAjhuKwyq x1wZk7rxyorsM8x3+nPU9Xc9GjpbMNbswMAsiGdsB1d4J7gmoFwxODktTAZlpChQCrMu VMonBBcoxHE3X38EDo+vRKHabqjszOr8iqXqncikxtkxO400gzRm4Ihm5UTCmXiDnMP1 9J6g== X-Gm-Message-State: ALoCoQmIPCiVkOHlQFvVkssCXGjXhZrZnPIFIUWMbpgoyCThCueQdulqtvU4wjL0TAaf0mGTXTR62wC/X8KF+oZU4qLSak5wvA== X-Received: by 10.66.234.226 with SMTP id uh2mr33711286pac.6.1450779398680; Tue, 22 Dec 2015 02:16:38 -0800 (PST) Received: from localhost ([122.171.29.67]) by smtp.gmail.com with ESMTPSA id w66sm3462764pfi.48.2015.12.22.02.16.37 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Tue, 22 Dec 2015 02:16:37 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, Stephen Boyd , nm@ti.com, Viresh Kumar Subject: [PATCH 04/17] PM / OPP: Introduce dev_pm_opp_get_max_volt_latency() Date: Tue, 22 Dec 2015 15:46:05 +0530 Message-Id: <08691b482198b0709fd258d310a5e6ecda2f1a18.1450777582.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.7.0.rc1.186.g94414c4 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 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 | 49 +++++++++++++++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 6 ++++++ 2 files changed, 55 insertions(+) -- 2.7.0.rc1.186.g94414c4 -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c index 12066d3def38..bf296c459e06 100644 --- a/drivers/base/power/opp/core.c +++ b/drivers/base/power/opp/core.c @@ -230,6 +230,55 @@ 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 regulator *reg; + unsigned long latency_ns = 0; + unsigned long min_uV = ~0, max_uV = 0; + int ret; + + rcu_read_lock(); + + dev_opp = _find_device_opp(dev); + if (IS_ERR(dev_opp)) + goto unlock; + + reg = dev_opp->regulator; + /* Regulator may not be available for device */ + if (IS_ERR(reg)) + goto unlock; + + list_for_each_entry_rcu(opp, &dev_opp->opp_list, node) { + if (!opp->available) + continue; + + if (opp->u_volt_min < min_uV) + min_uV = opp->u_volt_min; + if (opp->u_volt_max > max_uV) + max_uV = opp->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 c70a18ac9c8a..5daa43058ac1 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, @@ -88,6 +89,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;