Release 4.7 drivers/cpufreq/sparc-us3-cpufreq.c
/* us3_cpufreq.c: UltraSPARC-III cpu frequency support
*
* Copyright (C) 2003 David S. Miller (davem@redhat.com)
*
* Many thanks to Dominik Brodowski for fixing up the cpufreq
* infrastructure in order to make this driver easier to implement.
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/smp.h>
#include <linux/cpufreq.h>
#include <linux/threads.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <asm/head.h>
#include <asm/timer.h>
static struct cpufreq_driver *cpufreq_us3_driver;
struct us3_freq_percpu_info {
struct cpufreq_frequency_table table[4];
};
/* Indexed by cpu number. */
static struct us3_freq_percpu_info *us3_freq_table;
/* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
* in the Safari config register.
*/
#define SAFARI_CFG_DIV_1 0x0000000000000000UL
#define SAFARI_CFG_DIV_2 0x0000000040000000UL
#define SAFARI_CFG_DIV_32 0x0000000080000000UL
#define SAFARI_CFG_DIV_MASK 0x00000000C0000000UL
static unsigned long read_safari_cfg(void)
{
unsigned long ret;
__asm__ __volatile__("ldxa [%%g0] %1, %0"
: "=&r" (ret)
: "i" (ASI_SAFARI_CONFIG));
return ret;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david s. miller | david s. miller | 19 | 100.00% | 1 | 100.00% |
| Total | 19 | 100.00% | 1 | 100.00% |
static void write_safari_cfg(unsigned long val)
{
__asm__ __volatile__("stxa %0, [%%g0] %1\n\t"
"membar #Sync"
: /* no outputs */
: "r" (val), "i" (ASI_SAFARI_CONFIG)
: "memory");
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david s. miller | david s. miller | 15 | 100.00% | 1 | 100.00% |
| Total | 15 | 100.00% | 1 | 100.00% |
static unsigned long get_current_freq(unsigned int cpu, unsigned long safari_cfg)
{
unsigned long clock_tick = sparc64_get_clock_tick(cpu) / 1000;
unsigned long ret;
switch (safari_cfg & SAFARI_CFG_DIV_MASK) {
case SAFARI_CFG_DIV_1:
ret = clock_tick / 1;
break;
case SAFARI_CFG_DIV_2:
ret = clock_tick / 2;
break;
case SAFARI_CFG_DIV_32:
ret = clock_tick / 32;
break;
default:
BUG();
}
return ret;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david s. miller | david s. miller | 75 | 100.00% | 3 | 100.00% |
| Total | 75 | 100.00% | 3 | 100.00% |
static unsigned int us3_freq_get(unsigned int cpu)
{
cpumask_t cpus_allowed;
unsigned long reg;
unsigned int ret;
cpumask_copy(&cpus_allowed, tsk_cpus_allowed(current));
set_cpus_allowed_ptr(current, cpumask_of(cpu));
reg = read_safari_cfg();
ret = get_current_freq(cpu, reg);
set_cpus_allowed_ptr(current, &cpus_allowed);
return ret;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david s. miller | david s. miller | 56 | 82.35% | 1 | 33.33% |
kosaki motohiro | kosaki motohiro | 8 | 11.76% | 1 | 33.33% |
julia lawall | julia lawall | 4 | 5.88% | 1 | 33.33% |
| Total | 68 | 100.00% | 3 | 100.00% |
static int us3_freq_target(struct cpufreq_policy *policy, unsigned int index)
{
unsigned int cpu = policy->cpu;
unsigned long new_bits, new_freq, reg;
cpumask_t cpus_allowed;
cpumask_copy(&cpus_allowed, tsk_cpus_allowed(current));
set_cpus_allowed_ptr(current, cpumask_of(cpu));
new_freq = sparc64_get_clock_tick(cpu) / 1000;
switch (index) {
case 0:
new_bits = SAFARI_CFG_DIV_1;
new_freq /= 1;
break;
case 1:
new_bits = SAFARI_CFG_DIV_2;
new_freq /= 2;
break;
case 2:
new_bits = SAFARI_CFG_DIV_32;
new_freq /= 32;
break;
default:
BUG();
}
reg = read_safari_cfg();
reg &= ~SAFARI_CFG_DIV_MASK;
reg |= new_bits;
write_safari_cfg(reg);
set_cpus_allowed_ptr(current, &cpus_allowed);
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david s. miller | david s. miller | 110 | 78.57% | 3 | 37.50% |
viresh kumar | viresh kumar | 14 | 10.00% | 2 | 25.00% |
kosaki motohiro | kosaki motohiro | 8 | 5.71% | 1 | 12.50% |
julia lawall | julia lawall | 4 | 2.86% | 1 | 12.50% |
andrew morton | andrew morton | 4 | 2.86% | 1 | 12.50% |
| Total | 140 | 100.00% | 8 | 100.00% |
static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
{
unsigned int cpu = policy->cpu;
unsigned long clock_tick = sparc64_get_clock_tick(cpu) / 1000;
struct cpufreq_frequency_table *table =
&us3_freq_table[cpu].table[0];
table[0].driver_data = 0;
table[0].frequency = clock_tick / 1;
table[1].driver_data = 1;
table[1].frequency = clock_tick / 2;
table[2].driver_data = 2;
table[2].frequency = clock_tick / 32;
table[3].driver_data = 0;
table[3].frequency = CPUFREQ_TABLE_END;
policy->cpuinfo.transition_latency = 0;
policy->cur = clock_tick;
return cpufreq_table_validate_and_show(policy, table);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david s. miller | david s. miller | 135 | 91.84% | 4 | 57.14% |
dominik brodowski | dominik brodowski | 6 | 4.08% | 1 | 14.29% |
viresh kumar | viresh kumar | 6 | 4.08% | 2 | 28.57% |
| Total | 147 | 100.00% | 7 | 100.00% |
static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
{
if (cpufreq_us3_driver)
us3_freq_target(policy, 0);
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david s. miller | david s. miller | 24 | 96.00% | 3 | 75.00% |
viresh kumar | viresh kumar | 1 | 4.00% | 1 | 25.00% |
| Total | 25 | 100.00% | 4 | 100.00% |
static int __init us3_freq_init(void)
{
unsigned long manuf, impl, ver;
int ret;
if (tlb_type != cheetah && tlb_type != cheetah_plus)
return -ENODEV;
__asm__("rdpr %%ver, %0" : "=r" (ver));
manuf = ((ver >> 48) & 0xffff);
impl = ((ver >> 32) & 0xffff);
if (manuf == CHEETAH_MANUF &&
(impl == CHEETAH_IMPL ||
impl == CHEETAH_PLUS_IMPL ||
impl == JAGUAR_IMPL ||
impl == PANTHER_IMPL)) {
struct cpufreq_driver *driver;
ret = -ENOMEM;
driver = kzalloc(sizeof(*driver), GFP_KERNEL);
if (!driver)
goto err_out;
us3_freq_table = kzalloc((NR_CPUS * sizeof(*us3_freq_table)),
GFP_KERNEL);
if (!us3_freq_table)
goto err_out;
driver->init = us3_freq_cpu_init;
driver->verify = cpufreq_generic_frequency_table_verify;
driver->target_index = us3_freq_target;
driver->get = us3_freq_get;
driver->exit = us3_freq_cpu_exit;
strcpy(driver->name, "UltraSPARC-III");
cpufreq_us3_driver = driver;
ret = cpufreq_register_driver(driver);
if (ret)
goto err_out;
return 0;
err_out:
if (driver) {
kfree(driver);
cpufreq_us3_driver = NULL;
}
kfree(us3_freq_table);
us3_freq_table = NULL;
return ret;
}
return -ENODEV;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david s. miller | david s. miller | 226 | 96.58% | 6 | 60.00% |
viresh kumar | viresh kumar | 6 | 2.56% | 3 | 30.00% |
eric sesterhenn | eric sesterhenn | 2 | 0.85% | 1 | 10.00% |
| Total | 234 | 100.00% | 10 | 100.00% |
static void __exit us3_freq_exit(void)
{
if (cpufreq_us3_driver) {
cpufreq_unregister_driver(cpufreq_us3_driver);
kfree(cpufreq_us3_driver);
cpufreq_us3_driver = NULL;
kfree(us3_freq_table);
us3_freq_table = NULL;
}
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david s. miller | david s. miller | 38 | 100.00% | 3 | 100.00% |
| Total | 38 | 100.00% | 3 | 100.00% |
MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
MODULE_DESCRIPTION("cpufreq driver for UltraSPARC-III");
MODULE_LICENSE("GPL");
module_init(us3_freq_init);
module_exit(us3_freq_exit);
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david s. miller | david s. miller | 796 | 92.67% | 6 | 35.29% |
viresh kumar | viresh kumar | 27 | 3.14% | 6 | 35.29% |
kosaki motohiro | kosaki motohiro | 16 | 1.86% | 1 | 5.88% |
julia lawall | julia lawall | 8 | 0.93% | 1 | 5.88% |
dominik brodowski | dominik brodowski | 6 | 0.70% | 1 | 5.88% |
andrew morton | andrew morton | 4 | 0.47% | 1 | 5.88% |
eric sesterhenn | eric sesterhenn | 2 | 0.23% | 1 | 5.88% |
| Total | 859 | 100.00% | 17 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.