From patchwork Fri May 30 09:01:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Abraham X-Patchwork-Id: 4269191 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 30B9F9F333 for ; Fri, 30 May 2014 09:05:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5E34120381 for ; Fri, 30 May 2014 09:05:17 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (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 7E19B202F8 for ; Fri, 30 May 2014 09:05:16 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WqIhT-0001wx-HP; Fri, 30 May 2014 09:02:07 +0000 Received: from mail-pb0-x234.google.com ([2607:f8b0:400e:c01::234]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WqIhI-0001QG-UJ for linux-arm-kernel@lists.infradead.org; Fri, 30 May 2014 09:01:57 +0000 Received: by mail-pb0-f52.google.com with SMTP id rr13so1515800pbb.39 for ; Fri, 30 May 2014 02:01:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=jQhB3oiq3ibltqTy6HDSwmkfC8kmoWgr63B6f9fqzxI=; b=tgClfY2BA0p5s1actt0EOuVbsFNKaIcD2XC1y9CCzi5x4nFaS6tPdBGPmDVdTLqY9Q 43k1bBL1HJ03TLJv6wU6SFd/w5tZOtI5g7cTvBOar3B96pQvksgL2wTdigcs6SgnzABI aRtLl+NNm9ImV0IW2Xzjd6pjGz4Xs+XKFkekQ+iz+sqDhpn8rdTywOysUSj1NZsVCPuG XeC6WGq+AtG0PWqWVotXgg7jlBqG32Gjqi88TFR34mCoN4d37s4f5Z9uIMicMzj1iZPk iFTa2Sv/HjybK1rVqSUg6o4nMnUiUfHSjAXyUGi4qfkNy8jZ06Y4o5/qUq9d/35SmDti DERQ== X-Received: by 10.68.196.202 with SMTP id io10mr16075588pbc.149.1401440495482; Fri, 30 May 2014 02:01:35 -0700 (PDT) Received: from user-ubuntu.sisodomain.com ([14.140.216.146]) by mx.google.com with ESMTPSA id mt1sm5263225pbb.31.2014.05.30.02.01.31 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 30 May 2014 02:01:34 -0700 (PDT) From: Thomas Abraham To: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v6 1/2] cpufreq / OPP: Allow boost frequency to be looked up from device tree Date: Fri, 30 May 2014 14:31:16 +0530 Message-Id: <1401440477-4328-2-git-send-email-thomas.ab@samsung.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1401440477-4328-1-git-send-email-thomas.ab@samsung.com> References: <1401440477-4328-1-git-send-email-thomas.ab@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140530_020156_993102_13445215 X-CRM114-Status: GOOD ( 15.32 ) X-Spam-Score: 0.0 (/) Cc: nm@ti.com, 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=-2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, 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. Signed-off-by: Thomas Abraham Acked-by: Nishanth Menon Acked-by: Lukasz Majewski --- drivers/cpufreq/cpufreq_opp.c | 45 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/drivers/cpufreq/cpufreq_opp.c b/drivers/cpufreq/cpufreq_opp.c index c0c6f4a..a13019a 100644 --- a/drivers/cpufreq/cpufreq_opp.c +++ b/drivers/cpufreq/cpufreq_opp.c @@ -19,6 +19,7 @@ #include #include #include +#include /** * dev_pm_opp_init_cpufreq_table() - create a cpufreq table for a device @@ -51,6 +52,11 @@ int dev_pm_opp_init_cpufreq_table(struct device *dev, struct cpufreq_frequency_table *freq_table = NULL; int i, max_opps, ret = 0; unsigned long rate; +#ifdef CONFIG_CPU_FREQ_BOOST_SW + struct cpufreq_frequency_table *ft; + int len, count; + u32 *boost_freqs = NULL; +#endif rcu_read_lock(); @@ -82,6 +88,45 @@ int dev_pm_opp_init_cpufreq_table(struct device *dev, *table = &freq_table[0]; +#ifdef CONFIG_CPU_FREQ_BOOST_SW + if (!of_find_property(dev->of_node, "boost-frequencies", &len)) + goto out; + + if (!len || !IS_ALIGNED(len, sizeof(u32))) { + dev_err(dev, "%s: invalid boost frequency\n", __func__); + ret = -EINVAL; + goto out; + } + + boost_freqs = kmalloc(len, GFP_KERNEL); + if (!boost_freqs) { + dev_err(dev, "%s: no memory for boost freq table\n", __func__); + ret = -ENOMEM; + goto out; + } + + count = len / sizeof(u32); + of_property_read_u32_array(dev->of_node, "boost-frequencies", + boost_freqs, count); + + for (i = 0; i < count; i++) { + cpufreq_for_each_valid_entry(ft, *table) { + if (boost_freqs[i] == ft->frequency) { + ft->flags |= CPUFREQ_BOOST_FREQ; + pr_debug("%s: marked %d as boost frequency\n", + __func__, boost_freqs[i]); + break; + } + } + + if (ft->frequency == CPUFREQ_TABLE_END) + dev_err(dev, "%s: invalid boost frequency %d\n", + __func__, boost_freqs[i]); + } + + kfree(boost_freqs); +#endif + out: rcu_read_unlock(); if (ret)