From patchwork Thu May 29 14:38:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Abraham X-Patchwork-Id: 4265651 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 0D944BEEA7 for ; Thu, 29 May 2014 14:41:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 42B8F2018A for ; Thu, 29 May 2014 14:41:46 +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 68FD92010F for ; Thu, 29 May 2014 14:41:44 +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 1Wq1UQ-0005rK-Db; Thu, 29 May 2014 14:39:30 +0000 Received: from mail-pb0-x22b.google.com ([2607:f8b0:400e:c01::22b]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wq1UI-0005oO-RZ for linux-arm-kernel@lists.infradead.org; Thu, 29 May 2014 14:39:24 +0000 Received: by mail-pb0-f43.google.com with SMTP id up15so477514pbc.16 for ; Thu, 29 May 2014 07:39:01 -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=0H3m37UHDazumTHwJnUNwcG8309TJbLy5dmYAaCaMC8=; b=SWQ0+vUtcUBwXmrf+7xC9KE93liNE9GH1vJGWXmm59PO7MLZciiPqnbjtrtAc2OA0I C0szpWxuLXhykyBJn5bnmw1jsKl0Gvdr5PzVtkS3O4xpsptADdKmn46+AVfgrEbDN6H4 NWvEoh233n2MgkfLoDo7OocU2N7ho2I941ogMX/IlfvbJcqHajU9OWXPiOjxpVWBmVpf x6ypPEKU7q6emFHWcGYwZvx8R0cpBAJqX2B0cuIoLRweZvimlo7kxqEalZqp/a7Yxy6V IEg8lMZUHM8eT1v+9ondUpTaMvD62B1zLrrboaRWTHWwlZ6r96EIfc4UPapYKITj5iof cqLQ== X-Received: by 10.68.134.101 with SMTP id pj5mr9628619pbb.62.1401374341782; Thu, 29 May 2014 07:39:01 -0700 (PDT) Received: from user-ubuntu.sisodomain.com ([14.140.216.146]) by mx.google.com with ESMTPSA id nh8sm1602473pbc.25.2014.05.29.07.38.57 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 29 May 2014 07:39:01 -0700 (PDT) From: Thomas Abraham To: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 1/2] cpufreq / OPP: Allow boost frequency to be looked up from device tree Date: Thu, 29 May 2014 20:08:38 +0530 Message-Id: <1401374319-4480-2-git-send-email-thomas.ab@samsung.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1401374319-4480-1-git-send-email-thomas.ab@samsung.com> References: <1401374319-4480-1-git-send-email-thomas.ab@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140529_073922_941532_D59D637F X-CRM114-Status: GOOD ( 15.43 ) X-Spam-Score: 0.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=-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. Cc: Nishanth Menon Cc: Lukasz Majewski 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..05fb115 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)