From patchwork Tue Feb 9 05:00:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 61491 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp1831144lbl; Mon, 8 Feb 2016 21:02:17 -0800 (PST) X-Received: by 10.98.80.76 with SMTP id e73mr48112421pfb.24.1454994137517; Mon, 08 Feb 2016 21:02:17 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 10si49909379pfk.172.2016.02.08.21.02.17; Mon, 08 Feb 2016 21:02:17 -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 S1750902AbcBIFCD (ORCPT + 11 others); Tue, 9 Feb 2016 00:02:03 -0500 Received: from mail-pa0-f51.google.com ([209.85.220.51]:34942 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751990AbcBIFBV (ORCPT ); Tue, 9 Feb 2016 00:01:21 -0500 Received: by mail-pa0-f51.google.com with SMTP id ho8so85219663pac.2 for ; Mon, 08 Feb 2016 21:01:21 -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=v7zCemMFhaA7zBx8LNE/FRdhbLkbt+RDXNZUFXWCin8=; b=eMnr2SogB95nnaWdJoM703WTpw4vzWSgAY/hLpKsrjUS4tbLcsPsfxvWVUWgmW3GAF zlw0X5j+R74ANt7LxdcWgbZ4r44QCQbbby2yW9aHlWeI6uONUZNQu5bClD4MpabJOv3/ JJGtmvH3xZtQuXrNzgCHd6kc0Qxdc7FsN0fc0= 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=v7zCemMFhaA7zBx8LNE/FRdhbLkbt+RDXNZUFXWCin8=; b=KhuGg3qzkieGaCjWEpH8uV/EkQmYHcX/K/ThghWUslc/r2Tp481VZOCpHvkdlkBDbz 2ZenuevZLOiS3GIN4enHzeRyge//oltyTW7lsWyJObXCacFMbFbYjTgW/AsK17ud1XLi MCfiUU3cPRxAcLuNXVHuQr1+z7eTBl4OsMCnnlhu5tJxstgFw/3tLHWFTNh+/SXV4mty EZeCYuAIv/oeDuzYo3wLQdnElUddnBPWFtgXq+nr/tdHEoue8QmjuzdsyWLIq/K+C5p3 c1mjqb/h8WLNWmsRJ/ZeJOa7XEWIUZk817xbkJylxvV9Th+c6X3l8Mt7/Mq+4KSFH32E V6jA== X-Gm-Message-State: AG10YOQC6o0Kr8YjiAWZejLB+8J1Ig+6BEosKazGRS+RWXZ8V2scAb/XKJYVwBTTaZ9PFI+S X-Received: by 10.66.250.165 with SMTP id zd5mr46771667pac.111.1454994081358; Mon, 08 Feb 2016 21:01:21 -0800 (PST) Received: from localhost ([122.172.22.246]) by smtp.gmail.com with ESMTPSA id m86sm46907287pfi.27.2016.02.08.21.01.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Feb 2016 21:01:20 -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 , Greg Kroah-Hartman , Len Brown , linux-kernel@vger.kernel.org (open list), Pavel Machek , Viresh Kumar Subject: [PATCH V3 03/16] PM / OPP: Introduce dev_pm_opp_get_max_volt_latency() Date: Tue, 9 Feb 2016 10:30:35 +0530 Message-Id: <243345f4534fab598d62e8247b8312c8677fa864.1454992186.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.7.1.370.gb2aa7f8 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 | 59 +++++++++++++++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 6 +++++ 2 files changed, 65 insertions(+) -- 2.7.1.370.gb2aa7f8 -- 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 71545becfca1..ffe2406af882 100644 --- a/drivers/base/power/opp/core.c +++ b/drivers/base/power/opp/core.c @@ -231,6 +231,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 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)) { + rcu_read_unlock(); + return 0; + } + + reg = dev_opp->regulator; + if (IS_ERR_OR_NULL(reg)) { + /* Regulator may not be required for device */ + if (reg) + dev_err(dev, "%s: Invalid regulator (%ld)\n", __func__, + PTR_ERR(reg)); + rcu_read_unlock(); + return 0; + } + + 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; + } + + rcu_read_unlock(); + + /* + * The caller needs to ensure that dev_opp (and hence the regulator) + * isn't freed, while we are executing this routine. + */ + ret = regulator_set_voltage_time(reg, min_uV, max_uV); + if (ret > 0) + latency_ns = ret * 1000; + + 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;