aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-omap2/clock.c85
-rw-r--r--arch/arm/mach-omap2/clock.h4
-rw-r--r--arch/arm/mach-omap2/clock2xxx.c34
-rw-r--r--arch/arm/mach-omap2/clock3xxx.c59
4 files changed, 107 insertions, 75 deletions
diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c
index 426d76f564e7..d1f115d0edad 100644
--- a/arch/arm/mach-omap2/clock.c
+++ b/arch/arm/mach-omap2/clock.c
@@ -17,6 +17,8 @@
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/list.h> 18#include <linux/list.h>
19#include <linux/errno.h> 19#include <linux/errno.h>
20#include <linux/err.h>
21#include <linux/delay.h>
20#include <linux/clk.h> 22#include <linux/clk.h>
21#include <linux/io.h> 23#include <linux/io.h>
22#include <linux/bitops.h> 24#include <linux/bitops.h>
@@ -349,6 +351,89 @@ void omap2_clk_disable_unused(struct clk *clk)
349} 351}
350#endif 352#endif
351 353
354/**
355 * omap2_clk_switch_mpurate_at_boot - switch ARM MPU rate by boot-time argument
356 * @mpurate_ck_name: clk name of the clock to change rate
357 *
358 * Change the ARM MPU clock rate to the rate specified on the command
359 * line, if one was specified. @mpurate_ck_name should be
360 * "virt_prcm_set" on OMAP2xxx and "dpll1_ck" on OMAP34xx/OMAP36xx.
361 * XXX Does not handle voltage scaling - on OMAP2xxx this is currently
362 * handled by the virt_prcm_set clock, but this should be handled by
363 * the OPP layer. XXX This is intended to be handled by the OPP layer
364 * code in the near future and should be removed from the clock code.
365 * Returns -EINVAL if 'mpurate' is zero or if clk_set_rate() rejects
366 * the rate, -ENOENT if the struct clk referred to by @mpurate_ck_name
367 * cannot be found, or 0 upon success.
368 */
369int __init omap2_clk_switch_mpurate_at_boot(const char *mpurate_ck_name)
370{
371 struct clk *mpurate_ck;
372 int r;
373
374 if (!mpurate)
375 return -EINVAL;
376
377 mpurate_ck = clk_get(NULL, mpurate_ck_name);
378 if (WARN(IS_ERR(mpurate_ck), "Failed to get %s.\n", mpurate_ck_name))
379 return -ENOENT;
380
381 r = clk_set_rate(mpurate_ck, mpurate);
382 if (IS_ERR_VALUE(r)) {
383 WARN(1, "clock: %s: unable to set MPU rate to %d: %d\n",
384 mpurate_ck->name, mpurate, r);
385 return -EINVAL;
386 }
387
388 calibrate_delay();
389 recalculate_root_clocks();
390
391 clk_put(mpurate_ck);
392
393 return 0;
394}
395
396/**
397 * omap2_clk_print_new_rates - print summary of current clock tree rates
398 * @hfclkin_ck_name: clk name for the off-chip HF oscillator
399 * @core_ck_name: clk name for the on-chip CORE_CLK
400 * @mpu_ck_name: clk name for the ARM MPU clock
401 *
402 * Prints a short message to the console with the HFCLKIN oscillator
403 * rate, the rate of the CORE clock, and the rate of the ARM MPU clock.
404 * Called by the boot-time MPU rate switching code. XXX This is intended
405 * to be handled by the OPP layer code in the near future and should be
406 * removed from the clock code. No return value.
407 */
408void __init omap2_clk_print_new_rates(const char *hfclkin_ck_name,
409 const char *core_ck_name,
410 const char *mpu_ck_name)
411{
412 struct clk *hfclkin_ck, *core_ck, *mpu_ck;
413 unsigned long hfclkin_rate;
414
415 mpu_ck = clk_get(NULL, mpu_ck_name);
416 if (WARN(IS_ERR(mpu_ck), "clock: failed to get %s.\n", mpu_ck_name))
417 return;
418
419 core_ck = clk_get(NULL, core_ck_name);
420 if (WARN(IS_ERR(core_ck), "clock: failed to get %s.\n", core_ck_name))
421 return;
422
423 hfclkin_ck = clk_get(NULL, hfclkin_ck_name);
424 if (WARN(IS_ERR(hfclkin_ck), "Failed to get %s.\n", hfclkin_ck_name))
425 return;
426
427 hfclkin_rate = clk_get_rate(hfclkin_ck);
428
429 pr_info("Switched to new clocking rate (Crystal/Core/MPU): "
430 "%ld.%01ld/%ld/%ld MHz\n",
431 (hfclkin_rate / 1000000),
432 ((hfclkin_rate / 100000) % 10),
433 (clk_get_rate(core_ck) / 1000000),
434 (clk_get_rate(mpu_ck) / 1000000));
435}
436
352/* Common data */ 437/* Common data */
353 438
354struct clk_functions omap2_clk_functions = { 439struct clk_functions omap2_clk_functions = {
diff --git a/arch/arm/mach-omap2/clock.h b/arch/arm/mach-omap2/clock.h
index 7bf02534a4ff..f77d8af585ae 100644
--- a/arch/arm/mach-omap2/clock.h
+++ b/arch/arm/mach-omap2/clock.h
@@ -119,6 +119,10 @@ void omap2_clk_dflt_find_companion(struct clk *clk, void __iomem **other_reg,
119 u8 *other_bit); 119 u8 *other_bit);
120void omap2_clk_dflt_find_idlest(struct clk *clk, void __iomem **idlest_reg, 120void omap2_clk_dflt_find_idlest(struct clk *clk, void __iomem **idlest_reg,
121 u8 *idlest_bit, u8 *idlest_val); 121 u8 *idlest_bit, u8 *idlest_val);
122int omap2_clk_switch_mpurate_at_boot(const char *mpurate_ck_name);
123void omap2_clk_print_new_rates(const char *hfclkin_ck_name,
124 const char *core_ck_name,
125 const char *mpu_ck_name);
122 126
123extern u8 cpu_mask; 127extern u8 cpu_mask;
124 128
diff --git a/arch/arm/mach-omap2/clock2xxx.c b/arch/arm/mach-omap2/clock2xxx.c
index 7a2f5ad07bab..80bb0f0e92e6 100644
--- a/arch/arm/mach-omap2/clock2xxx.c
+++ b/arch/arm/mach-omap2/clock2xxx.c
@@ -50,40 +50,24 @@ void omap2xxx_clk_prepare_for_reboot(void)
50} 50}
51 51
52/* 52/*
53 * Switch the MPU rate if specified on cmdline. 53 * Switch the MPU rate if specified on cmdline. We cannot do this
54 * We cannot do this early until cmdline is parsed. 54 * early until cmdline is parsed. XXX This should be removed from the
55 * clock code and handled by the OPP layer code in the near future.
55 */ 56 */
56static int __init omap2xxx_clk_arch_init(void) 57static int __init omap2xxx_clk_arch_init(void)
57{ 58{
58 struct clk *virt_prcm_set, *sys_ck, *dpll_ck, *mpu_ck; 59 int ret;
59 unsigned long sys_ck_rate;
60 60
61 if (!cpu_is_omap24xx()) 61 if (!cpu_is_omap24xx())
62 return 0; 62 return 0;
63 63
64 if (!mpurate) 64 ret = omap2_clk_switch_mpurate_at_boot("virt_prcm_set");
65 return -EINVAL; 65 if (!ret)
66 omap2_clk_print_new_rates("sys_ck", "dpll_ck", "mpu_ck");
66 67
67 virt_prcm_set = clk_get(NULL, "virt_prcm_set"); 68 return ret;
68 sys_ck = clk_get(NULL, "sys_ck");
69 dpll_ck = clk_get(NULL, "dpll_ck");
70 mpu_ck = clk_get(NULL, "mpu_ck");
71
72 if (clk_set_rate(virt_prcm_set, mpurate))
73 pr_err("Could not find matching MPU rate\n");
74
75 recalculate_root_clocks();
76
77 sys_ck_rate = clk_get_rate(sys_ck);
78
79 pr_info("Switched to new clocking rate (Crystal/DPLL/MPU): "
80 "%ld.%01ld/%ld/%ld MHz\n",
81 (sys_ck_rate / 1000000), (sys_ck_rate / 100000) % 10,
82 (clk_get_rate(dpll_ck) / 1000000),
83 (clk_get_rate(mpu_ck) / 1000000));
84
85 return 0;
86} 69}
70
87arch_initcall(omap2xxx_clk_arch_init); 71arch_initcall(omap2xxx_clk_arch_init);
88 72
89 73
diff --git a/arch/arm/mach-omap2/clock3xxx.c b/arch/arm/mach-omap2/clock3xxx.c
index d142457cd041..a447c4d2c28a 100644
--- a/arch/arm/mach-omap2/clock3xxx.c
+++ b/arch/arm/mach-omap2/clock3xxx.c
@@ -18,12 +18,9 @@
18 18
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/errno.h> 20#include <linux/errno.h>
21#include <linux/delay.h>
22#include <linux/clk.h> 21#include <linux/clk.h>
23#include <linux/io.h> 22#include <linux/io.h>
24#include <linux/err.h>
25 23
26#include <plat/cpu.h>
27#include <plat/clock.h> 24#include <plat/clock.h>
28 25
29#include "clock.h" 26#include "clock.h"
@@ -83,63 +80,25 @@ void __init omap3_clk_lock_dpll5(void)
83 80
84/* Common clock code */ 81/* Common clock code */
85 82
86/* REVISIT: Move this init stuff out into clock.c */
87
88/* 83/*
89 * Switch the MPU rate if specified on cmdline. 84 * Switch the MPU rate if specified on cmdline. We cannot do this
90 * We cannot do this early until cmdline is parsed. 85 * early until cmdline is parsed. XXX This should be removed from the
86 * clock code and handled by the OPP layer code in the near future.
91 */ 87 */
92static int __init omap3xxx_clk_arch_init(void) 88static int __init omap3xxx_clk_arch_init(void)
93{ 89{
94 struct clk *osc_sys_ck, *dpll1_ck, *arm_fck, *core_ck; 90 int ret;
95 unsigned long osc_sys_rate;
96 bool err = 0;
97 91
98 if (!cpu_is_omap34xx()) 92 if (!cpu_is_omap34xx())
99 return 0; 93 return 0;
100 94
101 if (!mpurate) 95 ret = omap2_clk_switch_mpurate_at_boot("dpll1_ck");
102 return -EINVAL; 96 if (!ret)
103 97 omap2_clk_print_new_rates("osc_sys_ck", "arm_fck", "core_ck");
104 /* XXX test these for success */
105 dpll1_ck = clk_get(NULL, "dpll1_ck");
106 if (WARN(IS_ERR(dpll1_ck), "Failed to get dpll1_ck.\n"))
107 err = 1;
108
109 arm_fck = clk_get(NULL, "arm_fck");
110 if (WARN(IS_ERR(arm_fck), "Failed to get arm_fck.\n"))
111 err = 1;
112
113 core_ck = clk_get(NULL, "core_ck");
114 if (WARN(IS_ERR(core_ck), "Failed to get core_ck.\n"))
115 err = 1;
116
117 osc_sys_ck = clk_get(NULL, "osc_sys_ck");
118 if (WARN(IS_ERR(osc_sys_ck), "Failed to get osc_sys_ck.\n"))
119 err = 1;
120
121 if (err)
122 return -ENOENT;
123 98
124 /* REVISIT: not yet ready for 343x */ 99 return ret;
125 if (clk_set_rate(dpll1_ck, mpurate))
126 printk(KERN_ERR "*** Unable to set MPU rate\n");
127
128 recalculate_root_clocks();
129
130 osc_sys_rate = clk_get_rate(osc_sys_ck);
131
132 pr_info("Switched to new clocking rate (Crystal/Core/MPU): "
133 "%ld.%01ld/%ld/%ld MHz\n",
134 (osc_sys_rate / 1000000),
135 ((osc_sys_rate / 100000) % 10),
136 (clk_get_rate(core_ck) / 1000000),
137 (clk_get_rate(arm_fck) / 1000000));
138
139 calibrate_delay();
140
141 return 0;
142} 100}
101
143arch_initcall(omap3xxx_clk_arch_init); 102arch_initcall(omap3xxx_clk_arch_init);
144 103
145 104