17 #define pr_fmt(fmt) "cpufreq: " fmt
19 #include <linux/types.h>
21 #include <linux/kernel.h>
22 #include <linux/module.h>
28 #include <linux/sched.h>
35 static unsigned int sh_cpufreq_get(
unsigned int cpu)
44 unsigned int target_freq,
45 unsigned int relation)
47 unsigned int cpu = policy->
cpu;
57 cpus_allowed =
current->cpus_allowed;
67 if (freq < (policy->
min * 1000) || freq > (policy->
max * 1000))
70 dev_dbg(dev,
"requested frequency %u Hz\n", target_freq * 1000);
73 freqs.old = sh_cpufreq_get(cpu);
74 freqs.new = (freq + 500) / 1000;
78 set_cpus_allowed_ptr(
current, &cpus_allowed);
82 dev_dbg(dev,
"set frequency %lu Hz\n", freq);
96 cpufreq_verify_within_limits(policy, policy->
cpuinfo.min_freq,
102 cpufreq_verify_within_limits(policy, policy->
cpuinfo.min_freq,
110 unsigned int cpu = policy->
cpu;
111 struct clk *cpuclk = &
per_cpu(sh_cpuclk, cpu);
120 cpuclk =
clk_get(dev,
"cpu_clk");
121 if (IS_ERR(cpuclk)) {
122 dev_err(dev,
"couldn't get CPU clk\n");
123 return PTR_ERR(cpuclk);
126 policy->
cur = policy->
min = policy->
max = sh_cpufreq_get(cpu);
136 dev_notice(dev,
"no frequency table found, falling back "
137 "to rate rounding.\n");
150 dev_info(dev,
"CPU Frequencies - Minimum %u.%03u MHz, "
151 "Maximum %u.%03u MHz.\n",
152 policy->
min / 1000, policy->
min % 1000,
153 policy->
max / 1000, policy->
max % 1000);
160 unsigned int cpu = policy->
cpu;
161 struct clk *cpuclk = &
per_cpu(sh_cpuclk, cpu);
169 static struct freq_attr *sh_freq_attr[] = {
177 .get = sh_cpufreq_get,
178 .target = sh_cpufreq_target,
179 .verify = sh_cpufreq_verify,
180 .init = sh_cpufreq_cpu_init,
181 .exit = sh_cpufreq_cpu_exit,
182 .attr = sh_freq_attr,
185 static int __init sh_cpufreq_module_init(
void)
187 pr_notice(
"SuperH CPU frequency driver.\n");
191 static void __exit sh_cpufreq_module_exit(
void)