net: gre: use icmp_hdr() to get inner ip header
[linux-2.6/btrfs-unstable.git] / drivers / cpufreq / unicore2-cpufreq.c
blob36cc330b8747c70b3430175c6fec28891526688c
1 /*
2 * clock scaling for the UniCore-II
4 * Code specific to PKUnity SoC and UniCore ISA
6 * Maintained by GUAN Xue-tao <gxt@mprc.pku.edu.cn>
7 * Copyright (C) 2001-2010 Guan Xuetao
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
14 #include <linux/err.h>
15 #include <linux/kernel.h>
16 #include <linux/types.h>
17 #include <linux/init.h>
18 #include <linux/clk.h>
19 #include <linux/cpufreq.h>
21 #include <mach/hardware.h>
23 static struct cpufreq_driver ucv2_driver;
25 /* make sure that only the "userspace" governor is run
26 * -- anything else wouldn't make sense on this platform, anyway.
28 static int ucv2_verify_speed(struct cpufreq_policy *policy)
30 if (policy->cpu)
31 return -EINVAL;
33 cpufreq_verify_within_cpu_limits(policy);
34 return 0;
37 static int ucv2_target(struct cpufreq_policy *policy,
38 unsigned int target_freq,
39 unsigned int relation)
41 struct cpufreq_freqs freqs;
42 int ret;
44 freqs.old = policy->cur;
45 freqs.new = target_freq;
47 cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
48 ret = clk_set_rate(policy->mclk, target_freq * 1000);
49 cpufreq_notify_post_transition(policy, &freqs, ret);
51 return ret;
54 static int __init ucv2_cpu_init(struct cpufreq_policy *policy)
56 if (policy->cpu != 0)
57 return -EINVAL;
59 policy->min = policy->cpuinfo.min_freq = 250000;
60 policy->max = policy->cpuinfo.max_freq = 1000000;
61 policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
62 policy->clk = clk_get(NULL, "MAIN_CLK");
63 if (IS_ERR(policy->clk))
64 return PTR_ERR(policy->clk);
65 return 0;
68 static struct cpufreq_driver ucv2_driver = {
69 .flags = CPUFREQ_STICKY,
70 .verify = ucv2_verify_speed,
71 .target = ucv2_target,
72 .get = cpufreq_generic_get,
73 .init = ucv2_cpu_init,
74 .name = "UniCore-II",
77 static int __init ucv2_cpufreq_init(void)
79 return cpufreq_register_driver(&ucv2_driver);
82 arch_initcall(ucv2_cpufreq_init);