clock.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * linux/arch/arm/mach-omap2/clock.c
  4. *
  5. * Copyright (C) 2005-2008 Texas Instruments, Inc.
  6. * Copyright (C) 2004-2010 Nokia Corporation
  7. *
  8. * Contacts:
  9. * Richard Woodruff <[email protected]>
  10. * Paul Walmsley
  11. */
  12. #undef DEBUG
  13. #include <linux/kernel.h>
  14. #include <linux/export.h>
  15. #include <linux/list.h>
  16. #include <linux/errno.h>
  17. #include <linux/err.h>
  18. #include <linux/delay.h>
  19. #include <linux/clk.h>
  20. #include <linux/clk-provider.h>
  21. #include <linux/io.h>
  22. #include <linux/bitops.h>
  23. #include <linux/of_address.h>
  24. #include <asm/cpu.h>
  25. #include <trace/events/power.h>
  26. #include "soc.h"
  27. #include "clockdomain.h"
  28. #include "clock.h"
  29. #include "cm.h"
  30. #include "cm2xxx.h"
  31. #include "cm3xxx.h"
  32. #include "cm-regbits-24xx.h"
  33. #include "cm-regbits-34xx.h"
  34. #include "common.h"
  35. u16 cpu_mask;
  36. /* DPLL valid Fint frequency band limits - from 34xx TRM Section 4.7.6.2 */
  37. #define OMAP3430_DPLL_FINT_BAND1_MIN 750000
  38. #define OMAP3430_DPLL_FINT_BAND1_MAX 2100000
  39. #define OMAP3430_DPLL_FINT_BAND2_MIN 7500000
  40. #define OMAP3430_DPLL_FINT_BAND2_MAX 21000000
  41. /*
  42. * DPLL valid Fint frequency range for OMAP36xx and OMAP4xxx.
  43. * From device data manual section 4.3 "DPLL and DLL Specifications".
  44. */
  45. #define OMAP3PLUS_DPLL_FINT_MIN 32000
  46. #define OMAP3PLUS_DPLL_FINT_MAX 52000000
  47. struct ti_clk_ll_ops omap_clk_ll_ops = {
  48. .clkdm_clk_enable = clkdm_clk_enable,
  49. .clkdm_clk_disable = clkdm_clk_disable,
  50. .clkdm_lookup = clkdm_lookup,
  51. .cm_wait_module_ready = omap_cm_wait_module_ready,
  52. .cm_split_idlest_reg = cm_split_idlest_reg,
  53. };
  54. /**
  55. * omap2_clk_setup_ll_ops - setup clock driver low-level ops
  56. *
  57. * Sets up clock driver low-level platform ops. These are needed
  58. * for register accesses and various other misc platform operations.
  59. * Returns 0 on success, -EBUSY if low level ops have been registered
  60. * already.
  61. */
  62. int __init omap2_clk_setup_ll_ops(void)
  63. {
  64. return ti_clk_setup_ll_ops(&omap_clk_ll_ops);
  65. }
  66. /*
  67. * OMAP2+ specific clock functions
  68. */
  69. /**
  70. * ti_clk_init_features - init clock features struct for the SoC
  71. *
  72. * Initializes the clock features struct based on the SoC type.
  73. */
  74. void __init ti_clk_init_features(void)
  75. {
  76. struct ti_clk_features features = { 0 };
  77. /* Fint setup for DPLLs */
  78. if (cpu_is_omap3430()) {
  79. features.fint_min = OMAP3430_DPLL_FINT_BAND1_MIN;
  80. features.fint_max = OMAP3430_DPLL_FINT_BAND2_MAX;
  81. features.fint_band1_max = OMAP3430_DPLL_FINT_BAND1_MAX;
  82. features.fint_band2_min = OMAP3430_DPLL_FINT_BAND2_MIN;
  83. } else {
  84. features.fint_min = OMAP3PLUS_DPLL_FINT_MIN;
  85. features.fint_max = OMAP3PLUS_DPLL_FINT_MAX;
  86. }
  87. /* Bypass value setup for DPLLs */
  88. if (cpu_is_omap24xx()) {
  89. features.dpll_bypass_vals |=
  90. (1 << OMAP2XXX_EN_DPLL_LPBYPASS) |
  91. (1 << OMAP2XXX_EN_DPLL_FRBYPASS);
  92. } else if (cpu_is_omap34xx()) {
  93. features.dpll_bypass_vals |=
  94. (1 << OMAP3XXX_EN_DPLL_LPBYPASS) |
  95. (1 << OMAP3XXX_EN_DPLL_FRBYPASS);
  96. } else if (soc_is_am33xx() || cpu_is_omap44xx() || soc_is_am43xx() ||
  97. soc_is_omap54xx() || soc_is_dra7xx()) {
  98. features.dpll_bypass_vals |=
  99. (1 << OMAP4XXX_EN_DPLL_LPBYPASS) |
  100. (1 << OMAP4XXX_EN_DPLL_FRBYPASS) |
  101. (1 << OMAP4XXX_EN_DPLL_MNBYPASS);
  102. }
  103. /* Jitter correction only available on OMAP343X */
  104. if (cpu_is_omap343x())
  105. features.flags |= TI_CLK_DPLL_HAS_FREQSEL;
  106. if (omap_type() == OMAP2_DEVICE_TYPE_GP)
  107. features.flags |= TI_CLK_DEVICE_TYPE_GP;
  108. /* Idlest value for interface clocks.
  109. * 24xx uses 0 to indicate not ready, and 1 to indicate ready.
  110. * 34xx reverses this, just to keep us on our toes
  111. * AM35xx uses both, depending on the module.
  112. */
  113. if (cpu_is_omap24xx())
  114. features.cm_idlest_val = OMAP24XX_CM_IDLEST_VAL;
  115. else if (cpu_is_omap34xx())
  116. features.cm_idlest_val = OMAP34XX_CM_IDLEST_VAL;
  117. /* On OMAP3430 ES1.0, DPLL4 can't be re-programmed */
  118. if (omap_rev() == OMAP3430_REV_ES1_0)
  119. features.flags |= TI_CLK_DPLL4_DENY_REPROGRAM;
  120. /* Errata I810 for omap5 / dra7 */
  121. if (soc_is_omap54xx() || soc_is_dra7xx())
  122. features.flags |= TI_CLK_ERRATA_I810;
  123. ti_clk_setup_features(&features);
  124. }