17 #include <linux/kernel.h>
18 #include <linux/list.h>
19 #include <linux/errno.h>
24 #include <linux/bitops.h>
28 #include <plat/clock.h>
48 static bool clkdm_control =
true;
66 static void _omap2_module_wait_ready(
struct clk *
clk)
68 void __iomem *companion_reg, *idlest_reg;
69 u8 other_bit, idlest_bit, idlest_val;
72 if (clk->
ops->find_companion) {
73 clk->
ops->find_companion(clk, &companion_reg, &other_bit);
74 if (!(
__raw_readl(companion_reg) & (1 << other_bit)))
78 clk->
ops->find_idlest(clk, &idlest_reg, &idlest_bit, &idlest_val);
106 pr_debug(
"clock: associated clk %s to clkdm %s\n",
107 clk_name, clk->clkdm_name);
110 pr_debug(
"clock: could not associate clk %s to clkdm %s\n",
111 clk_name, clk->clkdm_name);
125 clkdm_control =
false;
179 u8 *idlest_bit,
u8 *idlest_val)
206 pr_err(
"clock.c: Enable for %s without enable code\n",
219 if (clk->
ops->find_idlest)
220 _omap2_module_wait_ready(clk);
234 pr_err(
"clock: clk_disable called on independent clock %s which has no enable_reg\n", clk->
name);
277 WARN(1,
"clock: %s: omap2_clk_disable() called, but usecount already 0?", clk->
name);
281 pr_debug(
"clock: %s: decrementing usecount\n", clk->
name);
288 pr_debug(
"clock: %s: disabling in hardware\n", clk->
name);
290 if (clk->
ops && clk->
ops->disable) {
292 clk->
ops->disable(clk);
295 if (clkdm_control && clk->clkdm)
317 pr_debug(
"clock: %s: incrementing usecount\n", clk->
name);
324 pr_debug(
"clock: %s: enabling in hardware\n", clk->
name);
329 WARN(1,
"clock: %s: could not enable parent %s: %d\n",
335 if (clkdm_control && clk->clkdm) {
338 WARN(1,
"clock: %s: could not enable clockdomain %s: %d\n",
344 if (clk->
ops && clk->
ops->enable) {
346 ret = clk->
ops->enable(clk);
348 WARN(1,
"clock: %s: could not enable: %d\n",
357 if (clkdm_control && clk->clkdm)
382 pr_debug(
"clock: set_rate for clock %s to rate %ld\n", clk->
name, rate);
398 if (clk->
parent == new_parent)
408 #ifdef CONFIG_OMAP_RESET_CLOCKS
424 clk->
ops->disable(clk);
426 if (clk->clkdm !=
NULL)
448 struct clk *mpurate_ck;
455 if (
WARN(IS_ERR(mpurate_ck),
"Failed to get %s.\n", mpurate_ck_name))
460 WARN(1,
"clock: %s: unable to set MPU rate to %d: %d\n",
487 const char *core_ck_name,
488 const char *mpu_ck_name)
490 struct clk *hfclkin_ck, *core_ck, *mpu_ck;
491 unsigned long hfclkin_rate;
494 if (
WARN(IS_ERR(mpu_ck),
"clock: failed to get %s.\n", mpu_ck_name))
498 if (
WARN(IS_ERR(core_ck),
"clock: failed to get %s.\n", core_ck_name))
502 if (
WARN(IS_ERR(hfclkin_ck),
"Failed to get %s.\n", hfclkin_ck_name))
507 pr_info(
"Switched to new clocking rate (Crystal/Core/MPU): %ld.%01ld/%ld/%ld MHz\n",
508 (hfclkin_rate / 1000000), ((hfclkin_rate / 100000) % 10),