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: 31154 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f198.google.com (mail-ie0-f198.google.com [209.85.223.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 913A820068 for ; Fri, 30 May 2014 09:01:40 +0000 (UTC) Received: by mail-ie0-f198.google.com with SMTP id tp5sf7693883ieb.1 for ; Fri, 30 May 2014 02:01:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=hPHVvXiNrHDAhQU1cR93EpntYYVXOiIwUHE7gtSadME=; b=kJzHebDKMJrLTsZI87vN/KzFb0XJGJsg6gbTJObv3VdQapYl/OSGiTX4zCZBFhM4Dx P6fidldsJBbhhNmDh/4IEIIjdThTQOsX6asCAEyPiJyA6nFeeLkb+qYGwnJtq9hobZHi D7AEqIbG43VvdVu0t+JvWtUuGGlb3UWX1L6Xzw92t2fMTPqDZHDBbHCX04QLsDHjrhNn FHgAIF4//E51fhFjtFREzTy/JyaeT2zP/GLUOOced1EDYkZhRRPRVd32Z5aW0aCoDz7U cJTNuOIr+LUZ1eAAJrVcr43LZ1BiuyYvhT3nJtPCXbSG0bkskqoeHt81XZXyvXSDRpJZ 2IXA== X-Gm-Message-State: ALoCoQlrVvQKR2p018D4bNoxGH68LGyyRCiTrbSghfFNwtS5euEDL6XkAMU5jnbQDKwI6SbAyOuk X-Received: by 10.43.31.81 with SMTP id sf17mr5220289icb.4.1401440499698; Fri, 30 May 2014 02:01:39 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.90.48 with SMTP id w45ls874972qgd.73.gmail; Fri, 30 May 2014 02:01:39 -0700 (PDT) X-Received: by 10.52.255.65 with SMTP id ao1mr10316283vdd.43.1401440499574; Fri, 30 May 2014 02:01:39 -0700 (PDT) Received: from mail-ve0-x230.google.com (mail-ve0-x230.google.com [2607:f8b0:400c:c01::230]) by mx.google.com with ESMTPS id qc5si2549526vcb.53.2014.05.30.02.01.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 30 May 2014 02:01:39 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c01::230 as permitted sender) client-ip=2607:f8b0:400c:c01::230; Received: by mail-ve0-f176.google.com with SMTP id jz11so1766309veb.35 for ; Fri, 30 May 2014 02:01:39 -0700 (PDT) X-Received: by 10.58.116.1 with SMTP id js1mr11987313veb.29.1401440499499; Fri, 30 May 2014 02:01:39 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp95128vcb; Fri, 30 May 2014 02:01:38 -0700 (PDT) X-Received: by 10.68.253.73 with SMTP id zy9mr16734914pbc.114.1401440498405; Fri, 30 May 2014 02:01:38 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id wx7si4585075pab.235.2014.05.30.02.01.37; Fri, 30 May 2014 02:01:37 -0700 (PDT) Received-SPF: none (google.com: linux-pm-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755337AbaE3JBh (ORCPT + 13 others); Fri, 30 May 2014 05:01:37 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:55235 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752272AbaE3JBf (ORCPT ); Fri, 30 May 2014 05:01:35 -0400 Received: by mail-pb0-f46.google.com with SMTP id rq2so1506366pbb.5 for ; Fri, 30 May 2014 02:01:35 -0700 (PDT) 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 Cc: rjw@rjwysocki.net, linux-samsung-soc@vger.kernel.org, kgene.kim@samsung.com, t.figa@samsung.com, l.majewski@samsung.com, viresh.kumar@linaro.org, thomas.ab@samsung.com, nm@ti.com 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> Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Original-Sender: thomas.ab@samsung.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c01::230 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=neutral (body hash did not verify) header.i=@ Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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)