Release 4.11 drivers/cpufreq/ppc_cbe_cpufreq.c
/*
* cpufreq driver for the cell processor
*
* (C) Copyright IBM Deutschland Entwicklung GmbH 2005-2007
*
* Author: Christian Krafft <krafft@de.ibm.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <linux/cpufreq.h>
#include <linux/module.h>
#include <linux/of_platform.h>
#include <asm/machdep.h>
#include <asm/prom.h>
#include <asm/cell-regs.h>
#include "ppc_cbe_cpufreq.h"
/* the CBE supports an 8 step frequency scaling */
static struct cpufreq_frequency_table cbe_freqs[] = {
{0, 1, 0},
{0, 2, 0},
{0, 3, 0},
{0, 4, 0},
{0, 5, 0},
{0, 6, 0},
{0, 8, 0},
{0, 10, 0},
{0, 0, CPUFREQ_TABLE_END},
};
/*
* hardware specific functions
*/
static int set_pmode(unsigned int cpu, unsigned int slow_mode)
{
int rc;
if (cbe_cpufreq_has_pmi)
rc = cbe_cpufreq_set_pmode_pmi(cpu, slow_mode);
else
rc = cbe_cpufreq_set_pmode(cpu, slow_mode);
pr_debug("register contains slow mode %d\n", cbe_cpufreq_get_pmode(cpu));
return rc;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Christian Krafft | 53 | 100.00% | 4 | 100.00% |
Total | 53 | 100.00% | 4 | 100.00% |
/*
* cpufreq functions
*/
static int cbe_cpufreq_cpu_init(struct cpufreq_policy *policy)
{
struct cpufreq_frequency_table *pos;
const u32 *max_freqp;
u32 max_freq;
int cur_pmode;
struct device_node *cpu;
cpu = of_get_cpu_node(policy->cpu, NULL);
if (!cpu)
return -ENODEV;
pr_debug("init cpufreq on CPU %d\n", policy->cpu);
/*
* Let's check we can actually get to the CELL regs
*/
if (!cbe_get_cpu_pmd_regs(policy->cpu) ||
!cbe_get_cpu_mic_tm_regs(policy->cpu)) {
pr_info("invalid CBE regs pointers for cpufreq\n");
return -EINVAL;
}
max_freqp = of_get_property(cpu, "clock-frequency", NULL);
of_node_put(cpu);
if (!max_freqp)
return -EINVAL;
/* we need the freq in kHz */
max_freq = *max_freqp / 1000;
pr_debug("max clock-frequency is at %u kHz\n", max_freq);
pr_debug("initializing frequency table\n");
/* initialize frequency table */
cpufreq_for_each_entry(pos, cbe_freqs) {
pos->frequency = max_freq / pos->driver_data;
pr_debug("%d: %d\n", (int)(pos - cbe_freqs), pos->frequency);
}
/* if DEBUG is enabled set_pmode() measures the latency
* of a transition */
policy->cpuinfo.transition_latency = 25000;
cur_pmode = cbe_cpufreq_get_pmode(policy->cpu);
pr_debug("current pmode is at %d\n",cur_pmode);
policy->cur = cbe_freqs[cur_pmode].frequency;
#ifdef CONFIG_SMP
cpumask_copy(policy->cpus, cpu_sibling_mask(policy->cpu));
#endif
/* this ensures that policy->cpuinfo_min
* and policy->cpuinfo_max are set correctly */
return cpufreq_table_validate_and_show(policy, cbe_freqs);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Christian Krafft | 160 | 67.51% | 3 | 25.00% |
Jean-Christophe Dubois | 30 | 12.66% | 1 | 8.33% |
Stratos Karafotis | 25 | 10.55% | 1 | 8.33% |
Stephen Rothwell | 11 | 4.64% | 1 | 8.33% |
Benjamin Herrenschmidt | 4 | 1.69% | 1 | 8.33% |
Olof Johansson | 2 | 0.84% | 1 | 8.33% |
Mike Travis | 2 | 0.84% | 1 | 8.33% |
Viresh Kumar | 2 | 0.84% | 2 | 16.67% |
Anton Blanchard | 1 | 0.42% | 1 | 8.33% |
Total | 237 | 100.00% | 12 | 100.00% |
static int cbe_cpufreq_target(struct cpufreq_policy *policy,
unsigned int cbe_pmode_new)
{
pr_debug("setting frequency for cpu %d to %d kHz, " \
"1/%d of max frequency\n",
policy->cpu,
cbe_freqs[cbe_pmode_new].frequency,
cbe_freqs[cbe_pmode_new].driver_data);
return set_pmode(policy->cpu, cbe_pmode_new);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Christian Krafft | 47 | 94.00% | 2 | 40.00% |
Viresh Kumar | 3 | 6.00% | 3 | 60.00% |
Total | 50 | 100.00% | 5 | 100.00% |
static struct cpufreq_driver cbe_cpufreq_driver = {
.verify = cpufreq_generic_frequency_table_verify,
.target_index = cbe_cpufreq_target,
.init = cbe_cpufreq_cpu_init,
.name = "cbe-cpufreq",
.flags = CPUFREQ_CONST_LOOPS,
};
/*
* module init and destoy
*/
static int __init cbe_cpufreq_init(void)
{
if (!machine_is(cell))
return -ENODEV;
return cpufreq_register_driver(&cbe_cpufreq_driver);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Christian Krafft | 16 | 57.14% | 1 | 50.00% |
Olof Johansson | 12 | 42.86% | 1 | 50.00% |
Total | 28 | 100.00% | 2 | 100.00% |
static void __exit cbe_cpufreq_exit(void)
{
cpufreq_unregister_driver(&cbe_cpufreq_driver);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Christian Krafft | 15 | 100.00% | 3 | 100.00% |
Total | 15 | 100.00% | 3 | 100.00% |
module_init(cbe_cpufreq_init);
module_exit(cbe_cpufreq_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Christian Krafft <krafft@de.ibm.com>");
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Christian Krafft | 418 | 77.26% | 6 | 26.09% |
Jean-Christophe Dubois | 32 | 5.91% | 1 | 4.35% |
Viresh Kumar | 26 | 4.81% | 7 | 30.43% |
Stratos Karafotis | 25 | 4.62% | 1 | 4.35% |
Olof Johansson | 16 | 2.96% | 1 | 4.35% |
Stephen Rothwell | 11 | 2.03% | 1 | 4.35% |
Benjamin Herrenschmidt | 5 | 0.92% | 2 | 8.70% |
Paul Gortmaker | 3 | 0.55% | 1 | 4.35% |
Jon Loeliger | 2 | 0.37% | 1 | 4.35% |
Mike Travis | 2 | 0.37% | 1 | 4.35% |
Anton Blanchard | 1 | 0.18% | 1 | 4.35% |
Total | 541 | 100.00% | 23 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.