Blame view
drivers/cpufreq/unicore2-cpufreq.c
1.9 KB
649098828
|
1 |
/* |
73cc9c8ca
|
2 |
* clock scaling for the UniCore-II |
649098828
|
3 4 5 6 7 8 9 10 11 12 |
* * Code specific to PKUnity SoC and UniCore ISA * * Maintained by GUAN Xue-tao <gxt@mprc.pku.edu.cn> * Copyright (C) 2001-2010 Guan Xuetao * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ |
652ed95d5
|
13 |
#include <linux/err.h> |
649098828
|
14 15 16 17 18 19 20 21 22 23 24 25 26 |
#include <linux/kernel.h> #include <linux/types.h> #include <linux/init.h> #include <linux/clk.h> #include <linux/cpufreq.h> #include <mach/hardware.h> static struct cpufreq_driver ucv2_driver; /* make sure that only the "userspace" governor is run * -- anything else wouldn't make sense on this platform, anyway. */ |
0e25246fb
|
27 |
static int ucv2_verify_speed(struct cpufreq_policy *policy) |
649098828
|
28 29 30 |
{ if (policy->cpu) return -EINVAL; |
be49e3465
|
31 |
cpufreq_verify_within_cpu_limits(policy); |
649098828
|
32 33 |
return 0; } |
649098828
|
34 35 36 37 |
static int ucv2_target(struct cpufreq_policy *policy, unsigned int target_freq, unsigned int relation) { |
649098828
|
38 |
struct cpufreq_freqs freqs; |
ab1b1c4e8
|
39 |
int ret; |
649098828
|
40 |
|
ab1b1c4e8
|
41 42 |
freqs.old = policy->cur; freqs.new = target_freq; |
649098828
|
43 |
|
8fec051ee
|
44 |
cpufreq_freq_transition_begin(policy, &freqs); |
b4ddad950
|
45 |
ret = clk_set_rate(policy->clk, target_freq * 1000); |
8fec051ee
|
46 |
cpufreq_freq_transition_end(policy, &freqs, ret); |
649098828
|
47 |
|
ab1b1c4e8
|
48 |
return ret; |
649098828
|
49 50 51 52 53 54 |
} static int __init ucv2_cpu_init(struct cpufreq_policy *policy) { if (policy->cpu != 0) return -EINVAL; |
652ed95d5
|
55 |
|
649098828
|
56 57 58 |
policy->min = policy->cpuinfo.min_freq = 250000; policy->max = policy->cpuinfo.max_freq = 1000000; policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; |
652ed95d5
|
59 |
policy->clk = clk_get(NULL, "MAIN_CLK"); |
8ab4e2b30
|
60 |
return PTR_ERR_OR_ZERO(policy->clk); |
649098828
|
61 62 63 64 65 66 |
} static struct cpufreq_driver ucv2_driver = { .flags = CPUFREQ_STICKY, .verify = ucv2_verify_speed, .target = ucv2_target, |
652ed95d5
|
67 |
.get = cpufreq_generic_get, |
649098828
|
68 69 70 71 72 73 74 75 76 77 |
.init = ucv2_cpu_init, .name = "UniCore-II", }; static int __init ucv2_cpufreq_init(void) { return cpufreq_register_driver(&ucv2_driver); } arch_initcall(ucv2_cpufreq_init); |