clkt2xxx_apll.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*
  2. * OMAP2xxx APLL clock control functions
  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. * Based on earlier work by Tuukka Tikkanen, Tony Lindgren,
  12. * Gordon McNutt and RidgeRun, Inc.
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License version 2 as
  16. * published by the Free Software Foundation.
  17. */
  18. #undef DEBUG
  19. #include <linux/kernel.h>
  20. #include <linux/clk.h>
  21. #include <linux/io.h>
  22. #include "clock.h"
  23. #include "clock2xxx.h"
  24. #include "cm2xxx.h"
  25. #include "cm-regbits-24xx.h"
  26. /* CM_CLKEN_PLL.EN_{54,96}M_PLL options (24XX) */
  27. #define EN_APLL_STOPPED 0
  28. #define EN_APLL_LOCKED 3
  29. /* CM_CLKSEL1_PLL.APLLS_CLKIN options (24XX) */
  30. #define APLLS_CLKIN_19_2MHZ 0
  31. #define APLLS_CLKIN_13MHZ 2
  32. #define APLLS_CLKIN_12MHZ 3
  33. /* Private functions */
  34. #ifdef CONFIG_COMMON_CLK
  35. int omap2_clk_apll96_enable(struct clk_hw *hw)
  36. #else
  37. static int _apll96_enable(struct clk *clk)
  38. #endif
  39. {
  40. return omap2xxx_cm_apll96_enable();
  41. }
  42. #ifdef CONFIG_COMMON_CLK
  43. int omap2_clk_apll54_enable(struct clk_hw *hw)
  44. #else
  45. static int _apll54_enable(struct clk *clk)
  46. #endif
  47. {
  48. return omap2xxx_cm_apll54_enable();
  49. }
  50. #ifdef CONFIG_COMMON_CLK
  51. static void _apll96_allow_idle(struct clk_hw_omap *clk)
  52. #else
  53. static void _apll96_allow_idle(struct clk *clk)
  54. #endif
  55. {
  56. omap2xxx_cm_set_apll96_auto_low_power_stop();
  57. }
  58. #ifdef CONFIG_COMMON_CLK
  59. static void _apll96_deny_idle(struct clk_hw_omap *clk)
  60. #else
  61. static void _apll96_deny_idle(struct clk *clk)
  62. #endif
  63. {
  64. omap2xxx_cm_set_apll96_disable_autoidle();
  65. }
  66. #ifdef CONFIG_COMMON_CLK
  67. static void _apll54_allow_idle(struct clk_hw_omap *clk)
  68. #else
  69. static void _apll54_allow_idle(struct clk *clk)
  70. #endif
  71. {
  72. omap2xxx_cm_set_apll54_auto_low_power_stop();
  73. }
  74. #ifdef CONFIG_COMMON_CLK
  75. static void _apll54_deny_idle(struct clk_hw_omap *clk)
  76. #else
  77. static void _apll54_deny_idle(struct clk *clk)
  78. #endif
  79. {
  80. omap2xxx_cm_set_apll54_disable_autoidle();
  81. }
  82. #ifdef CONFIG_COMMON_CLK
  83. void omap2_clk_apll96_disable(struct clk_hw *hw)
  84. #else
  85. static void _apll96_disable(struct clk *clk)
  86. #endif
  87. {
  88. omap2xxx_cm_apll96_disable();
  89. }
  90. #ifdef CONFIG_COMMON_CLK
  91. void omap2_clk_apll54_disable(struct clk_hw *hw)
  92. #else
  93. static void _apll54_disable(struct clk *clk)
  94. #endif
  95. {
  96. omap2xxx_cm_apll54_disable();
  97. }
  98. /* Public data */
  99. #ifdef CONFIG_COMMON_CLK
  100. const struct clk_hw_omap_ops clkhwops_apll54 = {
  101. .allow_idle = _apll54_allow_idle,
  102. .deny_idle = _apll54_deny_idle,
  103. };
  104. const struct clk_hw_omap_ops clkhwops_apll96 = {
  105. .allow_idle = _apll96_allow_idle,
  106. .deny_idle = _apll96_deny_idle,
  107. };
  108. #else
  109. const struct clkops clkops_apll96 = {
  110. .enable = _apll96_enable,
  111. .disable = _apll96_disable,
  112. .allow_idle = _apll96_allow_idle,
  113. .deny_idle = _apll96_deny_idle,
  114. };
  115. const struct clkops clkops_apll54 = {
  116. .enable = _apll54_enable,
  117. .disable = _apll54_disable,
  118. .allow_idle = _apll54_allow_idle,
  119. .deny_idle = _apll54_deny_idle,
  120. };
  121. #endif
  122. /* Public functions */
  123. u32 omap2xxx_get_apll_clkin(void)
  124. {
  125. u32 aplls, srate = 0;
  126. aplls = omap2_cm_read_mod_reg(PLL_MOD, CM_CLKSEL1);
  127. aplls &= OMAP24XX_APLLS_CLKIN_MASK;
  128. aplls >>= OMAP24XX_APLLS_CLKIN_SHIFT;
  129. if (aplls == APLLS_CLKIN_19_2MHZ)
  130. srate = 19200000;
  131. else if (aplls == APLLS_CLKIN_13MHZ)
  132. srate = 13000000;
  133. else if (aplls == APLLS_CLKIN_12MHZ)
  134. srate = 12000000;
  135. return srate;
  136. }