diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2013-04-04 08:54:14 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-04-08 07:02:31 -0400 |
commit | b7e614c8bf5c898b172d7dfed9853fdda35be5cc (patch) | |
tree | 24302c56c3f4bbcbc4e22879a9cc3fa42780aeb0 /arch | |
parent | cffc96eb4f91ba0f974b352a28b15f84950bd776 (diff) |
cpufreq: integrator: move cpufreq driver to drivers/cpufreq
This patch moves cpufreq driver of ARM based integrator platform to
drivers/cpufreq.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/Kconfig | 11 | ||||
-rw-r--r-- | arch/arm/mach-integrator/Makefile | 1 | ||||
-rw-r--r-- | arch/arm/mach-integrator/cpu.c | 222 |
3 files changed, 0 insertions, 234 deletions
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 76eb836793a1..c3563f6dc9f2 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig | |||
@@ -2166,17 +2166,6 @@ config CPU_FREQ_SA1100 | |||
2166 | config CPU_FREQ_SA1110 | 2166 | config CPU_FREQ_SA1110 |
2167 | bool | 2167 | bool |
2168 | 2168 | ||
2169 | config CPU_FREQ_INTEGRATOR | ||
2170 | tristate "CPUfreq driver for ARM Integrator CPUs" | ||
2171 | depends on ARCH_INTEGRATOR && CPU_FREQ | ||
2172 | default y | ||
2173 | help | ||
2174 | This enables the CPUfreq driver for ARM Integrator CPUs. | ||
2175 | |||
2176 | For details, take a look at <file:Documentation/cpu-freq>. | ||
2177 | |||
2178 | If in doubt, say Y. | ||
2179 | |||
2180 | config CPU_FREQ_S3C | 2169 | config CPU_FREQ_S3C |
2181 | bool | 2170 | bool |
2182 | help | 2171 | help |
diff --git a/arch/arm/mach-integrator/Makefile b/arch/arm/mach-integrator/Makefile index 5521d18bf19a..d14d6b76f4c2 100644 --- a/arch/arm/mach-integrator/Makefile +++ b/arch/arm/mach-integrator/Makefile | |||
@@ -9,5 +9,4 @@ obj-$(CONFIG_ARCH_INTEGRATOR_AP) += integrator_ap.o | |||
9 | obj-$(CONFIG_ARCH_INTEGRATOR_CP) += integrator_cp.o | 9 | obj-$(CONFIG_ARCH_INTEGRATOR_CP) += integrator_cp.o |
10 | 10 | ||
11 | obj-$(CONFIG_PCI) += pci_v3.o pci.o | 11 | obj-$(CONFIG_PCI) += pci_v3.o pci.o |
12 | obj-$(CONFIG_CPU_FREQ_INTEGRATOR) += cpu.o | ||
13 | obj-$(CONFIG_INTEGRATOR_IMPD1) += impd1.o | 12 | obj-$(CONFIG_INTEGRATOR_IMPD1) += impd1.o |
diff --git a/arch/arm/mach-integrator/cpu.c b/arch/arm/mach-integrator/cpu.c deleted file mode 100644 index df863c30771c..000000000000 --- a/arch/arm/mach-integrator/cpu.c +++ /dev/null | |||
@@ -1,222 +0,0 @@ | |||
1 | /* | ||
2 | * linux/arch/arm/mach-integrator/cpu.c | ||
3 | * | ||
4 | * Copyright (C) 2001-2002 Deep Blue Solutions Ltd. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | * | ||
10 | * CPU support functions | ||
11 | */ | ||
12 | #include <linux/module.h> | ||
13 | #include <linux/types.h> | ||
14 | #include <linux/kernel.h> | ||
15 | #include <linux/cpufreq.h> | ||
16 | #include <linux/sched.h> | ||
17 | #include <linux/smp.h> | ||
18 | #include <linux/init.h> | ||
19 | #include <linux/io.h> | ||
20 | |||
21 | #include <mach/hardware.h> | ||
22 | #include <mach/platform.h> | ||
23 | #include <asm/mach-types.h> | ||
24 | #include <asm/hardware/icst.h> | ||
25 | |||
26 | static struct cpufreq_driver integrator_driver; | ||
27 | |||
28 | #define CM_ID __io_address(INTEGRATOR_HDR_ID) | ||
29 | #define CM_OSC __io_address(INTEGRATOR_HDR_OSC) | ||
30 | #define CM_STAT __io_address(INTEGRATOR_HDR_STAT) | ||
31 | #define CM_LOCK __io_address(INTEGRATOR_HDR_LOCK) | ||
32 | |||
33 | static const struct icst_params lclk_params = { | ||
34 | .ref = 24000000, | ||
35 | .vco_max = ICST525_VCO_MAX_5V, | ||
36 | .vco_min = ICST525_VCO_MIN, | ||
37 | .vd_min = 8, | ||
38 | .vd_max = 132, | ||
39 | .rd_min = 24, | ||
40 | .rd_max = 24, | ||
41 | .s2div = icst525_s2div, | ||
42 | .idx2s = icst525_idx2s, | ||
43 | }; | ||
44 | |||
45 | static const struct icst_params cclk_params = { | ||
46 | .ref = 24000000, | ||
47 | .vco_max = ICST525_VCO_MAX_5V, | ||
48 | .vco_min = ICST525_VCO_MIN, | ||
49 | .vd_min = 12, | ||
50 | .vd_max = 160, | ||
51 | .rd_min = 24, | ||
52 | .rd_max = 24, | ||
53 | .s2div = icst525_s2div, | ||
54 | .idx2s = icst525_idx2s, | ||
55 | }; | ||
56 | |||
57 | /* | ||
58 | * Validate the speed policy. | ||
59 | */ | ||
60 | static int integrator_verify_policy(struct cpufreq_policy *policy) | ||
61 | { | ||
62 | struct icst_vco vco; | ||
63 | |||
64 | cpufreq_verify_within_limits(policy, | ||
65 | policy->cpuinfo.min_freq, | ||
66 | policy->cpuinfo.max_freq); | ||
67 | |||
68 | vco = icst_hz_to_vco(&cclk_params, policy->max * 1000); | ||
69 | policy->max = icst_hz(&cclk_params, vco) / 1000; | ||
70 | |||
71 | vco = icst_hz_to_vco(&cclk_params, policy->min * 1000); | ||
72 | policy->min = icst_hz(&cclk_params, vco) / 1000; | ||
73 | |||
74 | cpufreq_verify_within_limits(policy, | ||
75 | policy->cpuinfo.min_freq, | ||
76 | policy->cpuinfo.max_freq); | ||
77 | |||
78 | return 0; | ||
79 | } | ||
80 | |||
81 | |||
82 | static int integrator_set_target(struct cpufreq_policy *policy, | ||
83 | unsigned int target_freq, | ||
84 | unsigned int relation) | ||
85 | { | ||
86 | cpumask_t cpus_allowed; | ||
87 | int cpu = policy->cpu; | ||
88 | struct icst_vco vco; | ||
89 | struct cpufreq_freqs freqs; | ||
90 | u_int cm_osc; | ||
91 | |||
92 | /* | ||
93 | * Save this threads cpus_allowed mask. | ||
94 | */ | ||
95 | cpus_allowed = current->cpus_allowed; | ||
96 | |||
97 | /* | ||
98 | * Bind to the specified CPU. When this call returns, | ||
99 | * we should be running on the right CPU. | ||
100 | */ | ||
101 | set_cpus_allowed(current, cpumask_of_cpu(cpu)); | ||
102 | BUG_ON(cpu != smp_processor_id()); | ||
103 | |||
104 | /* get current setting */ | ||
105 | cm_osc = __raw_readl(CM_OSC); | ||
106 | |||
107 | if (machine_is_integrator()) { | ||
108 | vco.s = (cm_osc >> 8) & 7; | ||
109 | } else if (machine_is_cintegrator()) { | ||
110 | vco.s = 1; | ||
111 | } | ||
112 | vco.v = cm_osc & 255; | ||
113 | vco.r = 22; | ||
114 | freqs.old = icst_hz(&cclk_params, vco) / 1000; | ||
115 | |||
116 | /* icst_hz_to_vco rounds down -- so we need the next | ||
117 | * larger freq in case of CPUFREQ_RELATION_L. | ||
118 | */ | ||
119 | if (relation == CPUFREQ_RELATION_L) | ||
120 | target_freq += 999; | ||
121 | if (target_freq > policy->max) | ||
122 | target_freq = policy->max; | ||
123 | vco = icst_hz_to_vco(&cclk_params, target_freq * 1000); | ||
124 | freqs.new = icst_hz(&cclk_params, vco) / 1000; | ||
125 | |||
126 | if (freqs.old == freqs.new) { | ||
127 | set_cpus_allowed(current, cpus_allowed); | ||
128 | return 0; | ||
129 | } | ||
130 | |||
131 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); | ||
132 | |||
133 | cm_osc = __raw_readl(CM_OSC); | ||
134 | |||
135 | if (machine_is_integrator()) { | ||
136 | cm_osc &= 0xfffff800; | ||
137 | cm_osc |= vco.s << 8; | ||
138 | } else if (machine_is_cintegrator()) { | ||
139 | cm_osc &= 0xffffff00; | ||
140 | } | ||
141 | cm_osc |= vco.v; | ||
142 | |||
143 | __raw_writel(0xa05f, CM_LOCK); | ||
144 | __raw_writel(cm_osc, CM_OSC); | ||
145 | __raw_writel(0, CM_LOCK); | ||
146 | |||
147 | /* | ||
148 | * Restore the CPUs allowed mask. | ||
149 | */ | ||
150 | set_cpus_allowed(current, cpus_allowed); | ||
151 | |||
152 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); | ||
153 | |||
154 | return 0; | ||
155 | } | ||
156 | |||
157 | static unsigned int integrator_get(unsigned int cpu) | ||
158 | { | ||
159 | cpumask_t cpus_allowed; | ||
160 | unsigned int current_freq; | ||
161 | u_int cm_osc; | ||
162 | struct icst_vco vco; | ||
163 | |||
164 | cpus_allowed = current->cpus_allowed; | ||
165 | |||
166 | set_cpus_allowed(current, cpumask_of_cpu(cpu)); | ||
167 | BUG_ON(cpu != smp_processor_id()); | ||
168 | |||
169 | /* detect memory etc. */ | ||
170 | cm_osc = __raw_readl(CM_OSC); | ||
171 | |||
172 | if (machine_is_integrator()) { | ||
173 | vco.s = (cm_osc >> 8) & 7; | ||
174 | } else { | ||
175 | vco.s = 1; | ||
176 | } | ||
177 | vco.v = cm_osc & 255; | ||
178 | vco.r = 22; | ||
179 | |||
180 | current_freq = icst_hz(&cclk_params, vco) / 1000; /* current freq */ | ||
181 | |||
182 | set_cpus_allowed(current, cpus_allowed); | ||
183 | |||
184 | return current_freq; | ||
185 | } | ||
186 | |||
187 | static int integrator_cpufreq_init(struct cpufreq_policy *policy) | ||
188 | { | ||
189 | |||
190 | /* set default policy and cpuinfo */ | ||
191 | policy->cpuinfo.max_freq = 160000; | ||
192 | policy->cpuinfo.min_freq = 12000; | ||
193 | policy->cpuinfo.transition_latency = 1000000; /* 1 ms, assumed */ | ||
194 | policy->cur = policy->min = policy->max = integrator_get(policy->cpu); | ||
195 | |||
196 | return 0; | ||
197 | } | ||
198 | |||
199 | static struct cpufreq_driver integrator_driver = { | ||
200 | .verify = integrator_verify_policy, | ||
201 | .target = integrator_set_target, | ||
202 | .get = integrator_get, | ||
203 | .init = integrator_cpufreq_init, | ||
204 | .name = "integrator", | ||
205 | }; | ||
206 | |||
207 | static int __init integrator_cpu_init(void) | ||
208 | { | ||
209 | return cpufreq_register_driver(&integrator_driver); | ||
210 | } | ||
211 | |||
212 | static void __exit integrator_cpu_exit(void) | ||
213 | { | ||
214 | cpufreq_unregister_driver(&integrator_driver); | ||
215 | } | ||
216 | |||
217 | MODULE_AUTHOR ("Russell M. King"); | ||
218 | MODULE_DESCRIPTION ("cpufreq driver for ARM Integrator CPUs"); | ||
219 | MODULE_LICENSE ("GPL"); | ||
220 | |||
221 | module_init(integrator_cpu_init); | ||
222 | module_exit(integrator_cpu_exit); | ||