clock.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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.h>
  23. #include <linux/clk-provider.h>
  24. #include <linux/io.h>
  25. #include <linux/bitops.h>
  26. #include <linux/of_address.h>
  27. #include <asm/cpu.h>
  28. #include <trace/events/power.h>
  29. #include "soc.h"
  30. #include "clockdomain.h"
  31. #include "clock.h"
  32. #include "cm.h"
  33. #include "cm2xxx.h"
  34. #include "cm3xxx.h"
  35. #include "cm-regbits-24xx.h"
  36. #include "cm-regbits-34xx.h"
  37. #include "common.h"
  38. u16 cpu_mask;
  39. /* DPLL valid Fint frequency band limits - from 34xx TRM Section 4.7.6.2 */
  40. #define OMAP3430_DPLL_FINT_BAND1_MIN 750000
  41. #define OMAP3430_DPLL_FINT_BAND1_MAX 2100000
  42. #define OMAP3430_DPLL_FINT_BAND2_MIN 7500000
  43. #define OMAP3430_DPLL_FINT_BAND2_MAX 21000000
  44. /*
  45. * DPLL valid Fint frequency range for OMAP36xx and OMAP4xxx.
  46. * From device data manual section 4.3 "DPLL and DLL Specifications".
  47. */
  48. #define OMAP3PLUS_DPLL_FINT_MIN 32000
  49. #define OMAP3PLUS_DPLL_FINT_MAX 52000000
  50. static struct ti_clk_ll_ops omap_clk_ll_ops = {
  51. .clkdm_clk_enable = clkdm_clk_enable,
  52. .clkdm_clk_disable = clkdm_clk_disable,
  53. .cm_wait_module_ready = omap_cm_wait_module_ready,
  54. .cm_split_idlest_reg = cm_split_idlest_reg,
  55. };
  56. /**
  57. * omap2_clk_setup_ll_ops - setup clock driver low-level ops
  58. *
  59. * Sets up clock driver low-level platform ops. These are needed
  60. * for register accesses and various other misc platform operations.
  61. * Returns 0 on success, -EBUSY if low level ops have been registered
  62. * already.
  63. */
  64. int __init omap2_clk_setup_ll_ops(void)
  65. {
  66. return ti_clk_setup_ll_ops(&omap_clk_ll_ops);
  67. }
  68. /*
  69. * OMAP2+ specific clock functions
  70. */
  71. /* Public functions */
  72. /**
  73. * omap2_init_clk_clkdm - look up a clockdomain name, store pointer in clk
  74. * @clk: OMAP clock struct ptr to use
  75. *
  76. * Convert a clockdomain name stored in a struct clk 'clk' into a
  77. * clockdomain pointer, and save it into the struct clk. Intended to be
  78. * called during clk_register(). No return value.
  79. */
  80. void omap2_init_clk_clkdm(struct clk_hw *hw)
  81. {
  82. struct clk_hw_omap *clk = to_clk_hw_omap(hw);
  83. struct clockdomain *clkdm;
  84. const char *clk_name;
  85. if (!clk->clkdm_name)
  86. return;
  87. clk_name = __clk_get_name(hw->clk);
  88. clkdm = clkdm_lookup(clk->clkdm_name);
  89. if (clkdm) {
  90. pr_debug("clock: associated clk %s to clkdm %s\n",
  91. clk_name, clk->clkdm_name);
  92. clk->clkdm = clkdm;
  93. } else {
  94. pr_debug("clock: could not associate clk %s to clkdm %s\n",
  95. clk_name, clk->clkdm_name);
  96. }
  97. }
  98. /**
  99. * ti_clk_init_features - init clock features struct for the SoC
  100. *
  101. * Initializes the clock features struct based on the SoC type.
  102. */
  103. void __init ti_clk_init_features(void)
  104. {
  105. struct ti_clk_features features = { 0 };
  106. /* Fint setup for DPLLs */
  107. if (cpu_is_omap3430()) {
  108. features.fint_min = OMAP3430_DPLL_FINT_BAND1_MIN;
  109. features.fint_max = OMAP3430_DPLL_FINT_BAND2_MAX;
  110. features.fint_band1_max = OMAP3430_DPLL_FINT_BAND1_MAX;
  111. features.fint_band2_min = OMAP3430_DPLL_FINT_BAND2_MIN;
  112. } else {
  113. features.fint_min = OMAP3PLUS_DPLL_FINT_MIN;
  114. features.fint_max = OMAP3PLUS_DPLL_FINT_MAX;
  115. }
  116. /* Bypass value setup for DPLLs */
  117. if (cpu_is_omap24xx()) {
  118. features.dpll_bypass_vals |=
  119. (1 << OMAP2XXX_EN_DPLL_LPBYPASS) |
  120. (1 << OMAP2XXX_EN_DPLL_FRBYPASS);
  121. } else if (cpu_is_omap34xx()) {
  122. features.dpll_bypass_vals |=
  123. (1 << OMAP3XXX_EN_DPLL_LPBYPASS) |
  124. (1 << OMAP3XXX_EN_DPLL_FRBYPASS);
  125. } else if (soc_is_am33xx() || cpu_is_omap44xx() || soc_is_am43xx() ||
  126. soc_is_omap54xx() || soc_is_dra7xx()) {
  127. features.dpll_bypass_vals |=
  128. (1 << OMAP4XXX_EN_DPLL_LPBYPASS) |
  129. (1 << OMAP4XXX_EN_DPLL_FRBYPASS) |
  130. (1 << OMAP4XXX_EN_DPLL_MNBYPASS);
  131. }
  132. /* Jitter correction only available on OMAP343X */
  133. if (cpu_is_omap343x())
  134. features.flags |= TI_CLK_DPLL_HAS_FREQSEL;
  135. /* Idlest value for interface clocks.
  136. * 24xx uses 0 to indicate not ready, and 1 to indicate ready.
  137. * 34xx reverses this, just to keep us on our toes
  138. * AM35xx uses both, depending on the module.
  139. */
  140. if (cpu_is_omap24xx())
  141. features.cm_idlest_val = OMAP24XX_CM_IDLEST_VAL;
  142. else if (cpu_is_omap34xx())
  143. features.cm_idlest_val = OMAP34XX_CM_IDLEST_VAL;
  144. /* On OMAP3430 ES1.0, DPLL4 can't be re-programmed */
  145. if (omap_rev() == OMAP3430_REV_ES1_0)
  146. features.flags |= TI_CLK_DPLL4_DENY_REPROGRAM;
  147. /* Errata I810 for omap5 / dra7 */
  148. if (soc_is_omap54xx() || soc_is_dra7xx())
  149. features.flags |= TI_CLK_ERRATA_I810;
  150. ti_clk_setup_features(&features);
  151. }