summaryrefslogtreecommitdiffstats
path: root/recipes-kernel/linux/linux-mainline-3.2/omap_cpufreq/0001-cpufreq-OMAP-cleanup-for-multi-SoC-support-move-into.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-kernel/linux/linux-mainline-3.2/omap_cpufreq/0001-cpufreq-OMAP-cleanup-for-multi-SoC-support-move-into.patch')
-rw-r--r--recipes-kernel/linux/linux-mainline-3.2/omap_cpufreq/0001-cpufreq-OMAP-cleanup-for-multi-SoC-support-move-into.patch422
1 files changed, 422 insertions, 0 deletions
diff --git a/recipes-kernel/linux/linux-mainline-3.2/omap_cpufreq/0001-cpufreq-OMAP-cleanup-for-multi-SoC-support-move-into.patch b/recipes-kernel/linux/linux-mainline-3.2/omap_cpufreq/0001-cpufreq-OMAP-cleanup-for-multi-SoC-support-move-into.patch
new file mode 100644
index 00000000..c5aed7f6
--- /dev/null
+++ b/recipes-kernel/linux/linux-mainline-3.2/omap_cpufreq/0001-cpufreq-OMAP-cleanup-for-multi-SoC-support-move-into.patch
@@ -0,0 +1,422 @@
1From 9c613a8ca7cebad1d7fa4376b80a82adcdc7269e Mon Sep 17 00:00:00 2001
2From: Santosh Shilimkar <santosh.shilimkar@ti.com>
3Date: Wed, 11 Aug 2010 17:02:43 -0700
4Subject: [PATCH 01/11] cpufreq: OMAP: cleanup for multi-SoC support, move
5 into drivers/cpufreq
6
7Move OMAP cpufreq driver from arch/arm/mach-omap2 into
8drivers/cpufreq, along with a few cleanups:
9
10- generalize support for better handling of different SoCs in the OMAP
11- use OPP layer instead of OMAP clock internals for frequency table init
12
13Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
14[khilman@ti.com: move to drivers]
15Signed-off-by: Kevin Hilman <khilman@ti.com>
16---
17 arch/arm/plat-omap/Makefile | 1 -
18 arch/arm/plat-omap/cpu-omap.c | 171 ------------------------------------
19 drivers/cpufreq/Makefile | 1 +
20 drivers/cpufreq/omap-cpufreq.c | 188 ++++++++++++++++++++++++++++++++++++++++
21 4 files changed, 189 insertions(+), 172 deletions(-)
22 delete mode 100644 arch/arm/plat-omap/cpu-omap.c
23 create mode 100644 drivers/cpufreq/omap-cpufreq.c
24
25diff --git a/arch/arm/plat-omap/Makefile b/arch/arm/plat-omap/Makefile
26index 9852622..a53eca3 100644
27--- a/arch/arm/plat-omap/Makefile
28+++ b/arch/arm/plat-omap/Makefile
29@@ -19,7 +19,6 @@ obj-$(CONFIG_ARCH_OMAP4) += omap_device.o
30
31 obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o
32
33-obj-$(CONFIG_CPU_FREQ) += cpu-omap.o
34 obj-$(CONFIG_OMAP_DM_TIMER) += dmtimer.o
35 obj-$(CONFIG_OMAP_DEBUG_DEVICES) += debug-devices.o
36 obj-$(CONFIG_OMAP_DEBUG_LEDS) += debug-leds.o
37diff --git a/arch/arm/plat-omap/cpu-omap.c b/arch/arm/plat-omap/cpu-omap.c
38deleted file mode 100644
39index da4f68d..0000000
40--- a/arch/arm/plat-omap/cpu-omap.c
41+++ /dev/null
42@@ -1,171 +0,0 @@
43-/*
44- * linux/arch/arm/plat-omap/cpu-omap.c
45- *
46- * CPU frequency scaling for OMAP
47- *
48- * Copyright (C) 2005 Nokia Corporation
49- * Written by Tony Lindgren <tony@atomide.com>
50- *
51- * Based on cpu-sa1110.c, Copyright (C) 2001 Russell King
52- *
53- * This program is free software; you can redistribute it and/or modify
54- * it under the terms of the GNU General Public License version 2 as
55- * published by the Free Software Foundation.
56- */
57-#include <linux/types.h>
58-#include <linux/kernel.h>
59-#include <linux/sched.h>
60-#include <linux/cpufreq.h>
61-#include <linux/delay.h>
62-#include <linux/init.h>
63-#include <linux/err.h>
64-#include <linux/clk.h>
65-#include <linux/io.h>
66-
67-#include <mach/hardware.h>
68-#include <plat/clock.h>
69-#include <asm/system.h>
70-
71-#define VERY_HI_RATE 900000000
72-
73-static struct cpufreq_frequency_table *freq_table;
74-
75-#ifdef CONFIG_ARCH_OMAP1
76-#define MPU_CLK "mpu"
77-#else
78-#define MPU_CLK "virt_prcm_set"
79-#endif
80-
81-static struct clk *mpu_clk;
82-
83-/* TODO: Add support for SDRAM timing changes */
84-
85-static int omap_verify_speed(struct cpufreq_policy *policy)
86-{
87- if (freq_table)
88- return cpufreq_frequency_table_verify(policy, freq_table);
89-
90- if (policy->cpu)
91- return -EINVAL;
92-
93- cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,
94- policy->cpuinfo.max_freq);
95-
96- policy->min = clk_round_rate(mpu_clk, policy->min * 1000) / 1000;
97- policy->max = clk_round_rate(mpu_clk, policy->max * 1000) / 1000;
98- cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,
99- policy->cpuinfo.max_freq);
100- return 0;
101-}
102-
103-static unsigned int omap_getspeed(unsigned int cpu)
104-{
105- unsigned long rate;
106-
107- if (cpu)
108- return 0;
109-
110- rate = clk_get_rate(mpu_clk) / 1000;
111- return rate;
112-}
113-
114-static int omap_target(struct cpufreq_policy *policy,
115- unsigned int target_freq,
116- unsigned int relation)
117-{
118- struct cpufreq_freqs freqs;
119- int ret = 0;
120-
121- /* Ensure desired rate is within allowed range. Some govenors
122- * (ondemand) will just pass target_freq=0 to get the minimum. */
123- if (target_freq < policy->min)
124- target_freq = policy->min;
125- if (target_freq > policy->max)
126- target_freq = policy->max;
127-
128- freqs.old = omap_getspeed(0);
129- freqs.new = clk_round_rate(mpu_clk, target_freq * 1000) / 1000;
130- freqs.cpu = 0;
131-
132- if (freqs.old == freqs.new)
133- return ret;
134-
135- cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
136-#ifdef CONFIG_CPU_FREQ_DEBUG
137- printk(KERN_DEBUG "cpufreq-omap: transition: %u --> %u\n",
138- freqs.old, freqs.new);
139-#endif
140- ret = clk_set_rate(mpu_clk, freqs.new * 1000);
141- cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
142-
143- return ret;
144-}
145-
146-static int __cpuinit omap_cpu_init(struct cpufreq_policy *policy)
147-{
148- int result = 0;
149-
150- mpu_clk = clk_get(NULL, MPU_CLK);
151- if (IS_ERR(mpu_clk))
152- return PTR_ERR(mpu_clk);
153-
154- if (policy->cpu != 0)
155- return -EINVAL;
156-
157- policy->cur = policy->min = policy->max = omap_getspeed(0);
158-
159- clk_init_cpufreq_table(&freq_table);
160- if (freq_table) {
161- result = cpufreq_frequency_table_cpuinfo(policy, freq_table);
162- if (!result)
163- cpufreq_frequency_table_get_attr(freq_table,
164- policy->cpu);
165- } else {
166- policy->cpuinfo.min_freq = clk_round_rate(mpu_clk, 0) / 1000;
167- policy->cpuinfo.max_freq = clk_round_rate(mpu_clk,
168- VERY_HI_RATE) / 1000;
169- }
170-
171- /* FIXME: what's the actual transition time? */
172- policy->cpuinfo.transition_latency = 300 * 1000;
173-
174- return 0;
175-}
176-
177-static int omap_cpu_exit(struct cpufreq_policy *policy)
178-{
179- clk_exit_cpufreq_table(&freq_table);
180- clk_put(mpu_clk);
181- return 0;
182-}
183-
184-static struct freq_attr *omap_cpufreq_attr[] = {
185- &cpufreq_freq_attr_scaling_available_freqs,
186- NULL,
187-};
188-
189-static struct cpufreq_driver omap_driver = {
190- .flags = CPUFREQ_STICKY,
191- .verify = omap_verify_speed,
192- .target = omap_target,
193- .get = omap_getspeed,
194- .init = omap_cpu_init,
195- .exit = omap_cpu_exit,
196- .name = "omap",
197- .attr = omap_cpufreq_attr,
198-};
199-
200-static int __init omap_cpufreq_init(void)
201-{
202- return cpufreq_register_driver(&omap_driver);
203-}
204-
205-arch_initcall(omap_cpufreq_init);
206-
207-/*
208- * if ever we want to remove this, upon cleanup call:
209- *
210- * cpufreq_unregister_driver()
211- * cpufreq_frequency_table_put_attr()
212- */
213-
214diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile
215index a48bc02..ce75fcb 100644
216--- a/drivers/cpufreq/Makefile
217+++ b/drivers/cpufreq/Makefile
218@@ -43,6 +43,7 @@ obj-$(CONFIG_UX500_SOC_DB8500) += db8500-cpufreq.o
219 obj-$(CONFIG_ARM_S3C64XX_CPUFREQ) += s3c64xx-cpufreq.o
220 obj-$(CONFIG_ARM_S5PV210_CPUFREQ) += s5pv210-cpufreq.o
221 obj-$(CONFIG_ARM_EXYNOS4210_CPUFREQ) += exynos4210-cpufreq.o
222+obj-$(CONFIG_ARCH_OMAP2PLUS) += omap-cpufreq.o
223
224 ##################################################################################
225 # PowerPC platform drivers
226diff --git a/drivers/cpufreq/omap-cpufreq.c b/drivers/cpufreq/omap-cpufreq.c
227new file mode 100644
228index 0000000..a6b2be7
229--- /dev/null
230+++ b/drivers/cpufreq/omap-cpufreq.c
231@@ -0,0 +1,188 @@
232+/*
233+ * CPU frequency scaling for OMAP
234+ *
235+ * Copyright (C) 2005 Nokia Corporation
236+ * Written by Tony Lindgren <tony@atomide.com>
237+ *
238+ * Based on cpu-sa1110.c, Copyright (C) 2001 Russell King
239+ *
240+ * Copyright (C) 2007-2011 Texas Instruments, Inc.
241+ * - OMAP3/4 support by Rajendra Nayak, Santosh Shilimkar
242+ *
243+ * This program is free software; you can redistribute it and/or modify
244+ * it under the terms of the GNU General Public License version 2 as
245+ * published by the Free Software Foundation.
246+ */
247+#include <linux/types.h>
248+#include <linux/kernel.h>
249+#include <linux/sched.h>
250+#include <linux/cpufreq.h>
251+#include <linux/delay.h>
252+#include <linux/init.h>
253+#include <linux/err.h>
254+#include <linux/clk.h>
255+#include <linux/io.h>
256+#include <linux/opp.h>
257+
258+#include <asm/system.h>
259+#include <asm/smp_plat.h>
260+
261+#include <plat/clock.h>
262+#include <plat/omap-pm.h>
263+#include <plat/common.h>
264+
265+#include <mach/hardware.h>
266+
267+#define VERY_HI_RATE 900000000
268+
269+static struct cpufreq_frequency_table *freq_table;
270+static struct clk *mpu_clk;
271+
272+static int omap_verify_speed(struct cpufreq_policy *policy)
273+{
274+ if (freq_table)
275+ return cpufreq_frequency_table_verify(policy, freq_table);
276+
277+ if (policy->cpu)
278+ return -EINVAL;
279+
280+ cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,
281+ policy->cpuinfo.max_freq);
282+
283+ policy->min = clk_round_rate(mpu_clk, policy->min * 1000) / 1000;
284+ policy->max = clk_round_rate(mpu_clk, policy->max * 1000) / 1000;
285+ cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,
286+ policy->cpuinfo.max_freq);
287+ return 0;
288+}
289+
290+static unsigned int omap_getspeed(unsigned int cpu)
291+{
292+ unsigned long rate;
293+
294+ if (cpu)
295+ return 0;
296+
297+ rate = clk_get_rate(mpu_clk) / 1000;
298+ return rate;
299+}
300+
301+static int omap_target(struct cpufreq_policy *policy,
302+ unsigned int target_freq,
303+ unsigned int relation)
304+{
305+ int ret = 0;
306+ struct cpufreq_freqs freqs;
307+
308+ /* Ensure desired rate is within allowed range. Some govenors
309+ * (ondemand) will just pass target_freq=0 to get the minimum. */
310+ if (target_freq < policy->min)
311+ target_freq = policy->min;
312+ if (target_freq > policy->max)
313+ target_freq = policy->max;
314+
315+ freqs.old = omap_getspeed(0);
316+ freqs.new = clk_round_rate(mpu_clk, target_freq * 1000) / 1000;
317+ freqs.cpu = 0;
318+
319+ if (freqs.old == freqs.new)
320+ return ret;
321+
322+ cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
323+
324+#ifdef CONFIG_CPU_FREQ_DEBUG
325+ pr_info("cpufreq-omap: transition: %u --> %u\n", freqs.old, freqs.new);
326+#endif
327+
328+ ret = clk_set_rate(mpu_clk, freqs.new * 1000);
329+
330+ cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
331+
332+ return ret;
333+}
334+
335+static int __cpuinit omap_cpu_init(struct cpufreq_policy *policy)
336+{
337+ int result = 0;
338+ struct device *mpu_dev;
339+
340+ if (cpu_is_omap24xx())
341+ mpu_clk = clk_get(NULL, "virt_prcm_set");
342+ else if (cpu_is_omap34xx())
343+ mpu_clk = clk_get(NULL, "dpll1_ck");
344+ else if (cpu_is_omap44xx())
345+ mpu_clk = clk_get(NULL, "dpll_mpu_ck");
346+
347+ if (IS_ERR(mpu_clk))
348+ return PTR_ERR(mpu_clk);
349+
350+ if (policy->cpu != 0)
351+ return -EINVAL;
352+
353+ policy->cur = policy->min = policy->max = omap_getspeed(0);
354+
355+ mpu_dev = omap2_get_mpuss_device();
356+ if (!mpu_dev) {
357+ pr_warning("%s: unable to get the mpu device\n", __func__);
358+ return -EINVAL;
359+ }
360+ opp_init_cpufreq_table(mpu_dev, &freq_table);
361+
362+ if (freq_table) {
363+ result = cpufreq_frequency_table_cpuinfo(policy, freq_table);
364+ if (!result)
365+ cpufreq_frequency_table_get_attr(freq_table,
366+ policy->cpu);
367+ } else {
368+ policy->cpuinfo.min_freq = clk_round_rate(mpu_clk, 0) / 1000;
369+ policy->cpuinfo.max_freq = clk_round_rate(mpu_clk,
370+ VERY_HI_RATE) / 1000;
371+ }
372+
373+ policy->min = policy->cpuinfo.min_freq;
374+ policy->max = policy->cpuinfo.max_freq;
375+ policy->cur = omap_getspeed(0);
376+
377+ /* FIXME: what's the actual transition time? */
378+ policy->cpuinfo.transition_latency = 300 * 1000;
379+
380+ return 0;
381+}
382+
383+static int omap_cpu_exit(struct cpufreq_policy *policy)
384+{
385+ clk_exit_cpufreq_table(&freq_table);
386+ clk_put(mpu_clk);
387+ return 0;
388+}
389+
390+static struct freq_attr *omap_cpufreq_attr[] = {
391+ &cpufreq_freq_attr_scaling_available_freqs,
392+ NULL,
393+};
394+
395+static struct cpufreq_driver omap_driver = {
396+ .flags = CPUFREQ_STICKY,
397+ .verify = omap_verify_speed,
398+ .target = omap_target,
399+ .get = omap_getspeed,
400+ .init = omap_cpu_init,
401+ .exit = omap_cpu_exit,
402+ .name = "omap",
403+ .attr = omap_cpufreq_attr,
404+};
405+
406+static int __init omap_cpufreq_init(void)
407+{
408+ return cpufreq_register_driver(&omap_driver);
409+}
410+
411+static void __exit omap_cpufreq_exit(void)
412+{
413+ cpufreq_unregister_driver(&omap_driver);
414+}
415+
416+MODULE_DESCRIPTION("cpufreq driver for OMAP SoCs");
417+MODULE_LICENSE("GPL");
418+module_init(omap_cpufreq_init);
419+module_exit(omap_cpufreq_exit);
420--
4211.7.7.4
422