From patchwork Tue Feb 4 09:41:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Abraham X-Patchwork-Id: 3574611 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AA7BF9F2E9 for ; Tue, 4 Feb 2014 09:43:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BB87B20176 for ; Tue, 4 Feb 2014 09:43:55 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 96FBA20170 for ; Tue, 4 Feb 2014 09:43:54 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WAcXL-0007ew-BN; Tue, 04 Feb 2014 09:43:23 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WAcXD-0001Vu-0h; Tue, 04 Feb 2014 09:43:15 +0000 Received: from mail-pd0-x22e.google.com ([2607:f8b0:400e:c02::22e]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WAcX5-0001TY-3q for linux-arm-kernel@lists.infradead.org; Tue, 04 Feb 2014 09:43:09 +0000 Received: by mail-pd0-f174.google.com with SMTP id z10so7953822pdj.19 for ; Tue, 04 Feb 2014 01:42:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Zhjh31yHt7r2RLL1i+oZp6ESt4yMYiP9c/A9bybF2k8=; b=vyQ0nFIRqfCqMy8XRJZgck7L7pcPcVR9BaPn7+VfMz537vTWnp+mpMFldA61/lHOnY uy2gmPSR5JL8XX6ErSYggBDEh8lXd56XdArgIPqIjxjEoum5nyM9tWgDCxCafGOFBI1D +3rYUoDT1iVLXi8Bd6QjKofTVcoWouWMpRqP99Pkow0+m5gTIWwlOHBZmc/MFaoLlZHj 7MgrgPLU7R5rdP0zgY5G0t5teR0ONW6vGDftmYW8pNX2Mf9fm1XJE1gjpXm/fE6Ey1Wo sZqgLboW95GSybCtTKPv1nZt22aYRlFda96VqgOniC98GmBPdYIdfE5Hdh70jw2Z/syG 3y1Q== X-Received: by 10.68.213.41 with SMTP id np9mr42708572pbc.90.1391506965552; Tue, 04 Feb 2014 01:42:45 -0800 (PST) Received: from user-ubuntu.sisodomain.com ([115.113.119.130]) by mx.google.com with ESMTPSA id lh13sm166533950pab.4.2014.02.04.01.42.40 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 04 Feb 2014 01:42:44 -0800 (PST) From: Thomas Abraham To: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/2] PM / OPP: Add support for 'boost' mode OPP Date: Tue, 4 Feb 2014 15:11:29 +0530 Message-Id: <1391506890-7335-2-git-send-email-thomas.ab@samsung.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1391506890-7335-1-git-send-email-thomas.ab@samsung.com> References: <1391506890-7335-1-git-send-email-thomas.ab@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140204_044307_440914_B7595BDC X-CRM114-Status: GOOD ( 17.56 ) X-Spam-Score: -2.0 (--) Cc: Nishanth Menon , l.majewski@samsung.com, kgene.kim@samsung.com, viresh.kumar@linaro.org, t.figa@samsung.com, rjw@rjwysocki.net, linux-samsung-soc@vger.kernel.org, thomas.ab@samsung.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 From: Thomas Abraham Commit 6f19efc0 ("cpufreq: Add boost frequency support in core") adds support for CPU boost mode. This patch adds support for finding available boost OPPs from device tree and marking them as usable in boost mode. Cc: Nishanth Menon Cc: Lukasz Majewski Signed-off-by: Thomas Abraham --- drivers/base/power/opp.c | 69 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 56 insertions(+), 13 deletions(-) diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c index 2553867..de4d52d 100644 --- a/drivers/base/power/opp.c +++ b/drivers/base/power/opp.c @@ -62,6 +62,7 @@ struct dev_pm_opp { struct list_head node; bool available; + bool boost; unsigned long rate; unsigned long u_volt; @@ -380,10 +381,12 @@ struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev, EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_floor); /** - * dev_pm_opp_add() - Add an OPP table from a table definitions + * dev_pm_opp_add_flags() - Add an OPP to device OPP list with flags * @dev: device for which we do this operation * @freq: Frequency in Hz for this OPP * @u_volt: Voltage in uVolts for this OPP + * @available: initial availability of the OPP with adding it to the list. + * @boost: availability of this opp in controller's boost operating mode. * * This function adds an opp definition to the opp list and returns status. * The opp is made available by default and it can be controlled using @@ -395,7 +398,8 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_floor); * that this function is *NOT* called under RCU protection or in contexts where * mutex cannot be locked. */ -int dev_pm_opp_add(struct device *dev, unsigned long freq, unsigned long u_volt) +static int dev_pm_opp_add_flags(struct device *dev, unsigned long freq, + unsigned long u_volt, bool available, bool boost) { struct device_opp *dev_opp = NULL; struct dev_pm_opp *opp, *new_opp; @@ -441,7 +445,8 @@ int dev_pm_opp_add(struct device *dev, unsigned long freq, unsigned long u_volt) new_opp->dev_opp = dev_opp; new_opp->rate = freq; new_opp->u_volt = u_volt; - new_opp->available = true; + new_opp->available = available; + new_opp->boost = boost; /* Insert new OPP in order of increasing frequency */ head = &dev_opp->opp_list; @@ -462,6 +467,27 @@ int dev_pm_opp_add(struct device *dev, unsigned long freq, unsigned long u_volt) srcu_notifier_call_chain(&dev_opp->head, OPP_EVENT_ADD, new_opp); return 0; } + +/** + * dev_pm_opp_add() - Add an OPP table from a table definitions + * @dev: device for which we do this operation + * @freq: Frequency in Hz for this OPP + * @u_volt: Voltage in uVolts for this OPP + * + * This function adds an opp definition to the opp list and returns status. + * The opp is made available by default and it can be controlled using + * dev_pm_opp_enable/disable functions. + * + * Locking: The internal device_opp and opp structures are RCU protected. + * Hence this function internally uses RCU updater strategy with mutex locks + * to keep the integrity of the internal data structures. Callers should ensure + * that this function is *NOT* called under RCU protection or in contexts where + * mutex cannot be locked. + */ +int dev_pm_opp_add(struct device *dev, unsigned long freq, unsigned long u_volt) +{ + return dev_pm_opp_add_flags(dev, freq, u_volt, true, false); +} EXPORT_SYMBOL_GPL(dev_pm_opp_add); /** @@ -651,7 +677,8 @@ int dev_pm_opp_init_cpufreq_table(struct device *dev, list_for_each_entry(opp, &dev_opp->opp_list, node) { if (opp->available) { - freq_table[i].driver_data = i; + freq_table[i].driver_data = + opp->boost ? CPUFREQ_BOOST_FREQ : i; freq_table[i].frequency = opp->rate / 1000; i++; } @@ -701,19 +728,14 @@ struct srcu_notifier_head *dev_pm_opp_get_notifier(struct device *dev) } #ifdef CONFIG_OF -/** - * of_init_opp_table() - Initialize opp table from device tree - * @dev: device pointer used to lookup device OPPs. - * - * Register the initial OPP table with the OPP library for given device. - */ -int of_init_opp_table(struct device *dev) +static int of_parse_opp_table(struct device *dev, const char *prop_name, + bool boost) { const struct property *prop; const __be32 *val; int nr; - prop = of_find_property(dev->of_node, "operating-points", NULL); + prop = of_find_property(dev->of_node, prop_name, NULL); if (!prop) return -ENODEV; if (!prop->value) @@ -734,7 +756,7 @@ int of_init_opp_table(struct device *dev) unsigned long freq = be32_to_cpup(val++) * 1000; unsigned long volt = be32_to_cpup(val++); - if (dev_pm_opp_add(dev, freq, volt)) { + if (dev_pm_opp_add_flags(dev, freq, volt, true, boost)) { dev_warn(dev, "%s: Failed to add OPP %ld\n", __func__, freq); continue; @@ -744,5 +766,26 @@ int of_init_opp_table(struct device *dev) return 0; } + +/** + * of_init_opp_table() - Initialize opp table from device tree + * @dev: device pointer used to lookup device OPPs. + * + * Register the initial OPP table with the OPP library for given device. + * Additional "boost" operating points of the controller, if any, are + * specified with "boost-opp" property. + */ +int of_init_opp_table(struct device *dev) +{ + int ret; + + ret = of_parse_opp_table(dev, "operating-points", false); + if (!ret) { + ret = of_parse_opp_table(dev, "boost-opp", true); + if (ret == -ENODEV) + ret = 0; + } + return ret; +} EXPORT_SYMBOL_GPL(of_init_opp_table); #endif