clock.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. /*
  2. * linux/arch/arm/mach-omap2/clock.c
  3. *
  4. * Copyright (C) 2005-2008 Texas Instruments, Inc.
  5. * Copyright (C) 2004-2010 Nokia Corporation
  6. *
  7. * Contacts:
  8. * Richard Woodruff <r-woodruff2@ti.com>
  9. * Paul Walmsley
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License version 2 as
  13. * published by the Free Software Foundation.
  14. */
  15. #undef DEBUG
  16. #include <linux/kernel.h>
  17. #include <linux/export.h>
  18. #include <linux/list.h>
  19. #include <linux/errno.h>
  20. #include <linux/err.h>
  21. #include <linux/delay.h>
  22. #include <linux/clk-provider.h>
  23. #include <linux/io.h>
  24. #include <linux/bitops.h>
  25. #include <asm/cpu.h>
  26. #include <trace/events/power.h>
  27. #include "soc.h"
  28. #include "clockdomain.h"
  29. #include "clock.h"
  30. #include "cm.h"
  31. #include "cm2xxx.h"
  32. #include "cm3xxx.h"
  33. #include "cm-regbits-24xx.h"
  34. #include "cm-regbits-34xx.h"
  35. #include "common.h"
  36. /*
  37. * MAX_MODULE_ENABLE_WAIT: maximum of number of microseconds to wait
  38. * for a module to indicate that it is no longer in idle
  39. */
  40. #define MAX_MODULE_ENABLE_WAIT 100000
  41. u16 cpu_mask;
  42. /*
  43. * clkdm_control: if true, then when a clock is enabled in the
  44. * hardware, its clockdomain will first be enabled; and when a clock
  45. * is disabled in the hardware, its clockdomain will be disabled
  46. * afterwards.
  47. */
  48. static bool clkdm_control = true;
  49. static LIST_HEAD(clk_hw_omap_clocks);
  50. /*
  51. * Used for clocks that have the same value as the parent clock,
  52. * divided by some factor
  53. */
  54. unsigned long omap_fixed_divisor_recalc(struct clk_hw *hw,
  55. unsigned long parent_rate)
  56. {
  57. struct clk_hw_omap *oclk;
  58. if (!hw) {
  59. pr_warn("%s: hw is NULL\n", __func__);
  60. return -EINVAL;
  61. }
  62. oclk = to_clk_hw_omap(hw);
  63. WARN_ON(!oclk->fixed_div);
  64. return parent_rate / oclk->fixed_div;
  65. }
  66. /*
  67. * OMAP2+ specific clock functions
  68. */
  69. /* Private functions */
  70. /**
  71. * _wait_idlest_generic - wait for a module to leave the idle state
  72. * @reg: virtual address of module IDLEST register
  73. * @mask: value to mask against to determine if the module is active
  74. * @idlest: idle state indicator (0 or 1) for the clock
  75. * @name: name of the clock (for printk)
  76. *
  77. * Wait for a module to leave idle, where its idle-status register is
  78. * not inside the CM module. Returns 1 if the module left idle
  79. * promptly, or 0 if the module did not leave idle before the timeout
  80. * elapsed. XXX Deprecated - should be moved into drivers for the
  81. * individual IP block that the IDLEST register exists in.
  82. */
  83. static int _wait_idlest_generic(void __iomem *reg, u32 mask, u8 idlest,
  84. const char *name)
  85. {
  86. int i = 0, ena = 0;
  87. ena = (idlest) ? 0 : mask;
  88. omap_test_timeout(((__raw_readl(reg) & mask) == ena),
  89. MAX_MODULE_ENABLE_WAIT, i);
  90. if (i < MAX_MODULE_ENABLE_WAIT)
  91. pr_debug("omap clock: module associated with clock %s ready after %d loops\n",
  92. name, i);
  93. else
  94. pr_err("omap clock: module associated with clock %s didn't enable in %d tries\n",
  95. name, MAX_MODULE_ENABLE_WAIT);
  96. return (i < MAX_MODULE_ENABLE_WAIT) ? 1 : 0;
  97. };
  98. /**
  99. * _omap2_module_wait_ready - wait for an OMAP module to leave IDLE
  100. * @clk: struct clk * belonging to the module
  101. *
  102. * If the necessary clocks for the OMAP hardware IP block that
  103. * corresponds to clock @clk are enabled, then wait for the module to
  104. * indicate readiness (i.e., to leave IDLE). This code does not
  105. * belong in the clock code and will be moved in the medium term to
  106. * module-dependent code. No return value.
  107. */
  108. static void _omap2_module_wait_ready(struct clk_hw_omap *clk)
  109. {
  110. void __iomem *companion_reg, *idlest_reg;
  111. u8 other_bit, idlest_bit, idlest_val, idlest_reg_id;
  112. s16 prcm_mod;
  113. int r;
  114. /* Not all modules have multiple clocks that their IDLEST depends on */
  115. if (clk->ops->find_companion) {
  116. clk->ops->find_companion(clk, &companion_reg, &other_bit);
  117. if (!(__raw_readl(companion_reg) & (1 << other_bit)))
  118. return;
  119. }
  120. clk->ops->find_idlest(clk, &idlest_reg, &idlest_bit, &idlest_val);
  121. r = cm_split_idlest_reg(idlest_reg, &prcm_mod, &idlest_reg_id);
  122. if (r) {
  123. /* IDLEST register not in the CM module */
  124. _wait_idlest_generic(idlest_reg, (1 << idlest_bit), idlest_val,
  125. __clk_get_name(clk->hw.clk));
  126. } else {
  127. cm_wait_module_ready(prcm_mod, idlest_reg_id, idlest_bit);
  128. };
  129. }
  130. /* Public functions */
  131. /**
  132. * omap2_init_clk_clkdm - look up a clockdomain name, store pointer in clk
  133. * @clk: OMAP clock struct ptr to use
  134. *
  135. * Convert a clockdomain name stored in a struct clk 'clk' into a
  136. * clockdomain pointer, and save it into the struct clk. Intended to be
  137. * called during clk_register(). No return value.
  138. */
  139. void omap2_init_clk_clkdm(struct clk_hw *hw)
  140. {
  141. struct clk_hw_omap *clk = to_clk_hw_omap(hw);
  142. struct clockdomain *clkdm;
  143. const char *clk_name;
  144. if (!clk->clkdm_name)
  145. return;
  146. clk_name = __clk_get_name(hw->clk);
  147. clkdm = clkdm_lookup(clk->clkdm_name);
  148. if (clkdm) {
  149. pr_debug("clock: associated clk %s to clkdm %s\n",
  150. clk_name, clk->clkdm_name);
  151. clk->clkdm = clkdm;
  152. } else {
  153. pr_debug("clock: could not associate clk %s to clkdm %s\n",
  154. clk_name, clk->clkdm_name);
  155. }
  156. }
  157. /**
  158. * omap2_clk_disable_clkdm_control - disable clkdm control on clk enable/disable
  159. *
  160. * Prevent the OMAP clock code from calling into the clockdomain code
  161. * when a hardware clock in that clockdomain is enabled or disabled.
  162. * Intended to be called at init time from omap*_clk_init(). No
  163. * return value.
  164. */
  165. void __init omap2_clk_disable_clkdm_control(void)
  166. {
  167. clkdm_control = false;
  168. }
  169. /**
  170. * omap2_clk_dflt_find_companion - find companion clock to @clk
  171. * @clk: struct clk * to find the companion clock of
  172. * @other_reg: void __iomem ** to return the companion clock CM_*CLKEN va in
  173. * @other_bit: u8 ** to return the companion clock bit shift in
  174. *
  175. * Note: We don't need special code here for INVERT_ENABLE for the
  176. * time being since INVERT_ENABLE only applies to clocks enabled by
  177. * CM_CLKEN_PLL
  178. *
  179. * Convert CM_ICLKEN* <-> CM_FCLKEN*. This conversion assumes it's
  180. * just a matter of XORing the bits.
  181. *
  182. * Some clocks don't have companion clocks. For example, modules with
  183. * only an interface clock (such as MAILBOXES) don't have a companion
  184. * clock. Right now, this code relies on the hardware exporting a bit
  185. * in the correct companion register that indicates that the
  186. * nonexistent 'companion clock' is active. Future patches will
  187. * associate this type of code with per-module data structures to
  188. * avoid this issue, and remove the casts. No return value.
  189. */
  190. void omap2_clk_dflt_find_companion(struct clk_hw_omap *clk,
  191. void __iomem **other_reg, u8 *other_bit)
  192. {
  193. u32 r;
  194. /*
  195. * Convert CM_ICLKEN* <-> CM_FCLKEN*. This conversion assumes
  196. * it's just a matter of XORing the bits.
  197. */
  198. r = ((__force u32)clk->enable_reg ^ (CM_FCLKEN ^ CM_ICLKEN));
  199. *other_reg = (__force void __iomem *)r;
  200. *other_bit = clk->enable_bit;
  201. }
  202. /**
  203. * omap2_clk_dflt_find_idlest - find CM_IDLEST reg va, bit shift for @clk
  204. * @clk: struct clk * to find IDLEST info for
  205. * @idlest_reg: void __iomem ** to return the CM_IDLEST va in
  206. * @idlest_bit: u8 * to return the CM_IDLEST bit shift in
  207. * @idlest_val: u8 * to return the idle status indicator
  208. *
  209. * Return the CM_IDLEST register address and bit shift corresponding
  210. * to the module that "owns" this clock. This default code assumes
  211. * that the CM_IDLEST bit shift is the CM_*CLKEN bit shift, and that
  212. * the IDLEST register address ID corresponds to the CM_*CLKEN
  213. * register address ID (e.g., that CM_FCLKEN2 corresponds to
  214. * CM_IDLEST2). This is not true for all modules. No return value.
  215. */
  216. void omap2_clk_dflt_find_idlest(struct clk_hw_omap *clk,
  217. void __iomem **idlest_reg, u8 *idlest_bit, u8 *idlest_val)
  218. {
  219. u32 r;
  220. r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20);
  221. *idlest_reg = (__force void __iomem *)r;
  222. *idlest_bit = clk->enable_bit;
  223. /*
  224. * 24xx uses 0 to indicate not ready, and 1 to indicate ready.
  225. * 34xx reverses this, just to keep us on our toes
  226. * AM35xx uses both, depending on the module.
  227. */
  228. if (cpu_is_omap24xx())
  229. *idlest_val = OMAP24XX_CM_IDLEST_VAL;
  230. else if (cpu_is_omap34xx())
  231. *idlest_val = OMAP34XX_CM_IDLEST_VAL;
  232. else
  233. BUG();
  234. }
  235. /**
  236. * omap2_dflt_clk_enable - enable a clock in the hardware
  237. * @hw: struct clk_hw * of the clock to enable
  238. *
  239. * Enable the clock @hw in the hardware. We first call into the OMAP
  240. * clockdomain code to "enable" the corresponding clockdomain if this
  241. * is the first enabled user of the clockdomain. Then program the
  242. * hardware to enable the clock. Then wait for the IP block that uses
  243. * this clock to leave idle (if applicable). Returns the error value
  244. * from clkdm_clk_enable() if it terminated with an error, or -EINVAL
  245. * if @hw has a null clock enable_reg, or zero upon success.
  246. */
  247. int omap2_dflt_clk_enable(struct clk_hw *hw)
  248. {
  249. struct clk_hw_omap *clk;
  250. u32 v;
  251. int ret = 0;
  252. clk = to_clk_hw_omap(hw);
  253. if (clkdm_control && clk->clkdm) {
  254. ret = clkdm_clk_enable(clk->clkdm, hw->clk);
  255. if (ret) {
  256. WARN(1, "%s: could not enable %s's clockdomain %s: %d\n",
  257. __func__, __clk_get_name(hw->clk),
  258. clk->clkdm->name, ret);
  259. return ret;
  260. }
  261. }
  262. if (unlikely(clk->enable_reg == NULL)) {
  263. pr_err("%s: %s missing enable_reg\n", __func__,
  264. __clk_get_name(hw->clk));
  265. ret = -EINVAL;
  266. goto err;
  267. }
  268. /* FIXME should not have INVERT_ENABLE bit here */
  269. v = __raw_readl(clk->enable_reg);
  270. if (clk->flags & INVERT_ENABLE)
  271. v &= ~(1 << clk->enable_bit);
  272. else
  273. v |= (1 << clk->enable_bit);
  274. __raw_writel(v, clk->enable_reg);
  275. v = __raw_readl(clk->enable_reg); /* OCP barrier */
  276. if (clk->ops && clk->ops->find_idlest)
  277. _omap2_module_wait_ready(clk);
  278. return 0;
  279. err:
  280. if (clkdm_control && clk->clkdm)
  281. clkdm_clk_disable(clk->clkdm, hw->clk);
  282. return ret;
  283. }
  284. /**
  285. * omap2_dflt_clk_disable - disable a clock in the hardware
  286. * @hw: struct clk_hw * of the clock to disable
  287. *
  288. * Disable the clock @hw in the hardware, and call into the OMAP
  289. * clockdomain code to "disable" the corresponding clockdomain if all
  290. * clocks/hwmods in that clockdomain are now disabled. No return
  291. * value.
  292. */
  293. void omap2_dflt_clk_disable(struct clk_hw *hw)
  294. {
  295. struct clk_hw_omap *clk;
  296. u32 v;
  297. clk = to_clk_hw_omap(hw);
  298. if (!clk->enable_reg) {
  299. /*
  300. * 'independent' here refers to a clock which is not
  301. * controlled by its parent.
  302. */
  303. pr_err("%s: independent clock %s has no enable_reg\n",
  304. __func__, __clk_get_name(hw->clk));
  305. return;
  306. }
  307. v = __raw_readl(clk->enable_reg);
  308. if (clk->flags & INVERT_ENABLE)
  309. v |= (1 << clk->enable_bit);
  310. else
  311. v &= ~(1 << clk->enable_bit);
  312. __raw_writel(v, clk->enable_reg);
  313. /* No OCP barrier needed here since it is a disable operation */
  314. if (clkdm_control && clk->clkdm)
  315. clkdm_clk_disable(clk->clkdm, hw->clk);
  316. }
  317. /**
  318. * omap2_clkops_enable_clkdm - increment usecount on clkdm of @hw
  319. * @hw: struct clk_hw * of the clock being enabled
  320. *
  321. * Increment the usecount of the clockdomain of the clock pointed to
  322. * by @hw; if the usecount is 1, the clockdomain will be "enabled."
  323. * Only needed for clocks that don't use omap2_dflt_clk_enable() as
  324. * their enable function pointer. Passes along the return value of
  325. * clkdm_clk_enable(), -EINVAL if @hw is not associated with a
  326. * clockdomain, or 0 if clock framework-based clockdomain control is
  327. * not implemented.
  328. */
  329. int omap2_clkops_enable_clkdm(struct clk_hw *hw)
  330. {
  331. struct clk_hw_omap *clk;
  332. int ret = 0;
  333. clk = to_clk_hw_omap(hw);
  334. if (unlikely(!clk->clkdm)) {
  335. pr_err("%s: %s: no clkdm set ?!\n", __func__,
  336. __clk_get_name(hw->clk));
  337. return -EINVAL;
  338. }
  339. if (unlikely(clk->enable_reg))
  340. pr_err("%s: %s: should use dflt_clk_enable ?!\n", __func__,
  341. __clk_get_name(hw->clk));
  342. if (!clkdm_control) {
  343. pr_err("%s: %s: clkfw-based clockdomain control disabled ?!\n",
  344. __func__, __clk_get_name(hw->clk));
  345. return 0;
  346. }
  347. ret = clkdm_clk_enable(clk->clkdm, hw->clk);
  348. WARN(ret, "%s: could not enable %s's clockdomain %s: %d\n",
  349. __func__, __clk_get_name(hw->clk), clk->clkdm->name, ret);
  350. return ret;
  351. }
  352. /**
  353. * omap2_clkops_disable_clkdm - decrement usecount on clkdm of @hw
  354. * @hw: struct clk_hw * of the clock being disabled
  355. *
  356. * Decrement the usecount of the clockdomain of the clock pointed to
  357. * by @hw; if the usecount is 0, the clockdomain will be "disabled."
  358. * Only needed for clocks that don't use omap2_dflt_clk_disable() as their
  359. * disable function pointer. No return value.
  360. */
  361. void omap2_clkops_disable_clkdm(struct clk_hw *hw)
  362. {
  363. struct clk_hw_omap *clk;
  364. clk = to_clk_hw_omap(hw);
  365. if (unlikely(!clk->clkdm)) {
  366. pr_err("%s: %s: no clkdm set ?!\n", __func__,
  367. __clk_get_name(hw->clk));
  368. return;
  369. }
  370. if (unlikely(clk->enable_reg))
  371. pr_err("%s: %s: should use dflt_clk_disable ?!\n", __func__,
  372. __clk_get_name(hw->clk));
  373. if (!clkdm_control) {
  374. pr_err("%s: %s: clkfw-based clockdomain control disabled ?!\n",
  375. __func__, __clk_get_name(hw->clk));
  376. return;
  377. }
  378. clkdm_clk_disable(clk->clkdm, hw->clk);
  379. }
  380. /**
  381. * omap2_dflt_clk_is_enabled - is clock enabled in the hardware?
  382. * @hw: struct clk_hw * to check
  383. *
  384. * Return 1 if the clock represented by @hw is enabled in the
  385. * hardware, or 0 otherwise. Intended for use in the struct
  386. * clk_ops.is_enabled function pointer.
  387. */
  388. int omap2_dflt_clk_is_enabled(struct clk_hw *hw)
  389. {
  390. struct clk_hw_omap *clk = to_clk_hw_omap(hw);
  391. u32 v;
  392. v = __raw_readl(clk->enable_reg);
  393. if (clk->flags & INVERT_ENABLE)
  394. v ^= BIT(clk->enable_bit);
  395. v &= BIT(clk->enable_bit);
  396. return v ? 1 : 0;
  397. }
  398. static int __initdata mpurate;
  399. /*
  400. * By default we use the rate set by the bootloader.
  401. * You can override this with mpurate= cmdline option.
  402. */
  403. static int __init omap_clk_setup(char *str)
  404. {
  405. get_option(&str, &mpurate);
  406. if (!mpurate)
  407. return 1;
  408. if (mpurate < 1000)
  409. mpurate *= 1000000;
  410. return 1;
  411. }
  412. __setup("mpurate=", omap_clk_setup);
  413. /**
  414. * omap2_init_clk_hw_omap_clocks - initialize an OMAP clock
  415. * @clk: struct clk * to initialize
  416. *
  417. * Add an OMAP clock @clk to the internal list of OMAP clocks. Used
  418. * temporarily for autoidle handling, until this support can be
  419. * integrated into the common clock framework code in some way. No
  420. * return value.
  421. */
  422. void omap2_init_clk_hw_omap_clocks(struct clk *clk)
  423. {
  424. struct clk_hw_omap *c;
  425. if (__clk_get_flags(clk) & CLK_IS_BASIC)
  426. return;
  427. c = to_clk_hw_omap(__clk_get_hw(clk));
  428. list_add(&c->node, &clk_hw_omap_clocks);
  429. }
  430. /**
  431. * omap2_clk_enable_autoidle_all - enable autoidle on all OMAP clocks that
  432. * support it
  433. *
  434. * Enable clock autoidle on all OMAP clocks that have allow_idle
  435. * function pointers associated with them. This function is intended
  436. * to be temporary until support for this is added to the common clock
  437. * code. Returns 0.
  438. */
  439. int omap2_clk_enable_autoidle_all(void)
  440. {
  441. struct clk_hw_omap *c;
  442. list_for_each_entry(c, &clk_hw_omap_clocks, node)
  443. if (c->ops && c->ops->allow_idle)
  444. c->ops->allow_idle(c);
  445. return 0;
  446. }
  447. /**
  448. * omap2_clk_disable_autoidle_all - disable autoidle on all OMAP clocks that
  449. * support it
  450. *
  451. * Disable clock autoidle on all OMAP clocks that have allow_idle
  452. * function pointers associated with them. This function is intended
  453. * to be temporary until support for this is added to the common clock
  454. * code. Returns 0.
  455. */
  456. int omap2_clk_disable_autoidle_all(void)
  457. {
  458. struct clk_hw_omap *c;
  459. list_for_each_entry(c, &clk_hw_omap_clocks, node)
  460. if (c->ops && c->ops->deny_idle)
  461. c->ops->deny_idle(c);
  462. return 0;
  463. }
  464. /**
  465. * omap2_clk_enable_init_clocks - prepare & enable a list of clocks
  466. * @clk_names: ptr to an array of strings of clock names to enable
  467. * @num_clocks: number of clock names in @clk_names
  468. *
  469. * Prepare and enable a list of clocks, named by @clk_names. No
  470. * return value. XXX Deprecated; only needed until these clocks are
  471. * properly claimed and enabled by the drivers or core code that uses
  472. * them. XXX What code disables & calls clk_put on these clocks?
  473. */
  474. void omap2_clk_enable_init_clocks(const char **clk_names, u8 num_clocks)
  475. {
  476. struct clk *init_clk;
  477. int i;
  478. for (i = 0; i < num_clocks; i++) {
  479. init_clk = clk_get(NULL, clk_names[i]);
  480. clk_prepare_enable(init_clk);
  481. }
  482. }
  483. const struct clk_hw_omap_ops clkhwops_wait = {
  484. .find_idlest = omap2_clk_dflt_find_idlest,
  485. .find_companion = omap2_clk_dflt_find_companion,
  486. };
  487. /**
  488. * omap2_clk_switch_mpurate_at_boot - switch ARM MPU rate by boot-time argument
  489. * @mpurate_ck_name: clk name of the clock to change rate
  490. *
  491. * Change the ARM MPU clock rate to the rate specified on the command
  492. * line, if one was specified. @mpurate_ck_name should be
  493. * "virt_prcm_set" on OMAP2xxx and "dpll1_ck" on OMAP34xx/OMAP36xx.
  494. * XXX Does not handle voltage scaling - on OMAP2xxx this is currently
  495. * handled by the virt_prcm_set clock, but this should be handled by
  496. * the OPP layer. XXX This is intended to be handled by the OPP layer
  497. * code in the near future and should be removed from the clock code.
  498. * Returns -EINVAL if 'mpurate' is zero or if clk_set_rate() rejects
  499. * the rate, -ENOENT if the struct clk referred to by @mpurate_ck_name
  500. * cannot be found, or 0 upon success.
  501. */
  502. int __init omap2_clk_switch_mpurate_at_boot(const char *mpurate_ck_name)
  503. {
  504. struct clk *mpurate_ck;
  505. int r;
  506. if (!mpurate)
  507. return -EINVAL;
  508. mpurate_ck = clk_get(NULL, mpurate_ck_name);
  509. if (WARN(IS_ERR(mpurate_ck), "Failed to get %s.\n", mpurate_ck_name))
  510. return -ENOENT;
  511. r = clk_set_rate(mpurate_ck, mpurate);
  512. if (IS_ERR_VALUE(r)) {
  513. WARN(1, "clock: %s: unable to set MPU rate to %d: %d\n",
  514. mpurate_ck_name, mpurate, r);
  515. clk_put(mpurate_ck);
  516. return -EINVAL;
  517. }
  518. calibrate_delay();
  519. clk_put(mpurate_ck);
  520. return 0;
  521. }
  522. /**
  523. * omap2_clk_print_new_rates - print summary of current clock tree rates
  524. * @hfclkin_ck_name: clk name for the off-chip HF oscillator
  525. * @core_ck_name: clk name for the on-chip CORE_CLK
  526. * @mpu_ck_name: clk name for the ARM MPU clock
  527. *
  528. * Prints a short message to the console with the HFCLKIN oscillator
  529. * rate, the rate of the CORE clock, and the rate of the ARM MPU clock.
  530. * Called by the boot-time MPU rate switching code. XXX This is intended
  531. * to be handled by the OPP layer code in the near future and should be
  532. * removed from the clock code. No return value.
  533. */
  534. void __init omap2_clk_print_new_rates(const char *hfclkin_ck_name,
  535. const char *core_ck_name,
  536. const char *mpu_ck_name)
  537. {
  538. struct clk *hfclkin_ck, *core_ck, *mpu_ck;
  539. unsigned long hfclkin_rate;
  540. mpu_ck = clk_get(NULL, mpu_ck_name);
  541. if (WARN(IS_ERR(mpu_ck), "clock: failed to get %s.\n", mpu_ck_name))
  542. return;
  543. core_ck = clk_get(NULL, core_ck_name);
  544. if (WARN(IS_ERR(core_ck), "clock: failed to get %s.\n", core_ck_name))
  545. return;
  546. hfclkin_ck = clk_get(NULL, hfclkin_ck_name);
  547. if (WARN(IS_ERR(hfclkin_ck), "Failed to get %s.\n", hfclkin_ck_name))
  548. return;
  549. hfclkin_rate = clk_get_rate(hfclkin_ck);
  550. pr_info("Switched to new clocking rate (Crystal/Core/MPU): %ld.%01ld/%ld/%ld MHz\n",
  551. (hfclkin_rate / 1000000), ((hfclkin_rate / 100000) % 10),
  552. (clk_get_rate(core_ck) / 1000000),
  553. (clk_get_rate(mpu_ck) / 1000000));
  554. }