From patchwork Fri Feb 7 15:19:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Abraham X-Patchwork-Id: 3606081 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 06EF4BF418 for ; Fri, 7 Feb 2014 15:25:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 337A020125 for ; Fri, 7 Feb 2014 15:25:39 +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 A752E20117 for ; Fri, 7 Feb 2014 15:25:37 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WBnIe-0003HD-5p; Fri, 07 Feb 2014 15:25:04 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WBnDl-0004xU-PQ; Fri, 07 Feb 2014 15:20:01 +0000 Received: from mail-pb0-x230.google.com ([2607:f8b0:400e:c01::230]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WBnDb-0004um-1P for linux-arm-kernel@lists.infradead.org; Fri, 07 Feb 2014 15:19:52 +0000 Received: by mail-pb0-f48.google.com with SMTP id rr13so3372375pbb.35 for ; Fri, 07 Feb 2014 07:19:29 -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=snC7VvB8UnIgvZWZgDtxrsNH6Ma0U+kohdAnbhHoRMU=; b=fzHg3inHmLgStWrLfvIGn5XbResdzgKnBXCFruGD3orgdAevKTa+5uHEEQi4vabN+6 MGFhxYH3VXuhzZI+IzLX/rGKqn38LI7ay9SLr4P09q9UJWZ50uesAkO8BFDq7nY8HT5s BU8m3yBDFHmhz5HyvehYDqDE31dtSEl6rGUuElnpVhbt6ddwWjrQe+Il3ojzAS943tg9 QyE2W/Mat4R5gbesGLpJPsTdMLFEaXhjO+oM06lGS3CoogrUWU9e9Av4cF4JSAClOuOk eDQhpQY7avGLoks9rgCAAXWJsKpWVRD28F3/Dtxb3w9nTbWdfrVaCF5q1i4buDltfsff 7sjw== X-Received: by 10.66.240.4 with SMTP id vw4mr8470969pac.26.1391786369359; Fri, 07 Feb 2014 07:19:29 -0800 (PST) Received: from user-ubuntu.sisodomain.com ([115.113.119.130]) by mx.google.com with ESMTPSA id ac5sm14547845pbc.37.2014.02.07.07.19.24 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 07 Feb 2014 07:19:28 -0800 (PST) From: Thomas Abraham To: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 1/2] PM / OPP: Allow boost frequency to be looked up from device tree Date: Fri, 7 Feb 2014 20:49:01 +0530 Message-Id: <1391786342-11812-2-git-send-email-thomas.ab@samsung.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1391786342-11812-1-git-send-email-thomas.ab@samsung.com> References: <1391786342-11812-1-git-send-email-thomas.ab@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140207_101951_229348_631E891B X-CRM114-Status: GOOD ( 13.76 ) 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.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, KHOP_BIG_TO_CC, 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 frequencies 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 | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c index fa41874..b636826 100644 --- a/drivers/base/power/opp.c +++ b/drivers/base/power/opp.c @@ -628,7 +628,8 @@ int dev_pm_opp_init_cpufreq_table(struct device *dev, struct device_opp *dev_opp; struct dev_pm_opp *opp; struct cpufreq_frequency_table *freq_table; - int i = 0; + int i = 0, j, len, ret; + u32 *boost_freqs = NULL; /* Pretend as if I am an updater */ mutex_lock(&dev_opp_list_lock); @@ -650,10 +651,35 @@ int dev_pm_opp_init_cpufreq_table(struct device *dev, return -ENOMEM; } + if (of_find_property(dev->of_node, "boost-frequency", &len)) { + if (len == 0 || (len & (sizeof(u32) - 1)) != 0) { + dev_err(dev, "%s: invalid boost frequency\n", __func__); + ret = -EINVAL; + goto err_boost; + } + + boost_freqs = kzalloc(len, GFP_KERNEL); + if (!boost_freqs) { + dev_warn(dev, "%s: no memory for boost freq table\n", + __func__); + ret = -ENOMEM; + goto err_boost; + } + of_property_read_u32_array(dev->of_node, "boost-frequency", + boost_freqs, len / sizeof(u32)); + } + list_for_each_entry(opp, &dev_opp->opp_list, node) { if (opp->available) { freq_table[i].driver_data = i; freq_table[i].frequency = opp->rate / 1000; + for (j = 0; j < len / sizeof(u32) && boost_freqs; j++) { + if (boost_freqs[j] == freq_table[i].frequency) { + freq_table[i].driver_data = + CPUFREQ_BOOST_FREQ; + break; + } + } i++; } } @@ -663,8 +689,14 @@ int dev_pm_opp_init_cpufreq_table(struct device *dev, freq_table[i].frequency = CPUFREQ_TABLE_END; *table = &freq_table[0]; + kfree(boost_freqs); return 0; + +err_boost: + kfree(freq_table); + mutex_unlock(&dev_opp_list_lock); + return ret; } EXPORT_SYMBOL_GPL(dev_pm_opp_init_cpufreq_table);