clock34xx.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. * OMAP3-specific clock framework functions
  3. *
  4. * Copyright (C) 2007-2008 Texas Instruments, Inc.
  5. * Copyright (C) 2007-2011 Nokia Corporation
  6. *
  7. * Paul Walmsley
  8. * Jouni Högander
  9. *
  10. * Parts of this code are based on code written by
  11. * Richard Woodruff, Tony Lindgren, Tuukka Tikkanen, Karthik Dasu,
  12. * Russell King
  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 "clock34xx.h"
  24. #include "cm2xxx_3xxx.h"
  25. #include "cm-regbits-34xx.h"
  26. /**
  27. * omap3430es2_clk_ssi_find_idlest - return CM_IDLEST info for SSI
  28. * @clk: struct clk * being enabled
  29. * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into
  30. * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into
  31. * @idlest_val: pointer to a u8 to store the CM_IDLEST indicator
  32. *
  33. * The OMAP3430ES2 SSI target CM_IDLEST bit is at a different shift
  34. * from the CM_{I,F}CLKEN bit. Pass back the correct info via
  35. * @idlest_reg and @idlest_bit. No return value.
  36. */
  37. static void omap3430es2_clk_ssi_find_idlest(struct clk *clk,
  38. void __iomem **idlest_reg,
  39. u8 *idlest_bit,
  40. u8 *idlest_val)
  41. {
  42. u32 r;
  43. r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20);
  44. *idlest_reg = (__force void __iomem *)r;
  45. *idlest_bit = OMAP3430ES2_ST_SSI_IDLE_SHIFT;
  46. *idlest_val = OMAP34XX_CM_IDLEST_VAL;
  47. }
  48. const struct clkops clkops_omap3430es2_ssi_wait = {
  49. .enable = omap2_dflt_clk_enable,
  50. .disable = omap2_dflt_clk_disable,
  51. .find_idlest = omap3430es2_clk_ssi_find_idlest,
  52. .find_companion = omap2_clk_dflt_find_companion,
  53. };
  54. const struct clkops clkops_omap3430es2_iclk_ssi_wait = {
  55. .enable = omap2_dflt_clk_enable,
  56. .disable = omap2_dflt_clk_disable,
  57. .find_idlest = omap3430es2_clk_ssi_find_idlest,
  58. .find_companion = omap2_clk_dflt_find_companion,
  59. .allow_idle = omap2_clkt_iclk_allow_idle,
  60. .deny_idle = omap2_clkt_iclk_deny_idle,
  61. };
  62. /**
  63. * omap3430es2_clk_dss_usbhost_find_idlest - CM_IDLEST info for DSS, USBHOST
  64. * @clk: struct clk * being enabled
  65. * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into
  66. * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into
  67. * @idlest_val: pointer to a u8 to store the CM_IDLEST indicator
  68. *
  69. * Some OMAP modules on OMAP3 ES2+ chips have both initiator and
  70. * target IDLEST bits. For our purposes, we are concerned with the
  71. * target IDLEST bits, which exist at a different bit position than
  72. * the *CLKEN bit position for these modules (DSS and USBHOST) (The
  73. * default find_idlest code assumes that they are at the same
  74. * position.) No return value.
  75. */
  76. static void omap3430es2_clk_dss_usbhost_find_idlest(struct clk *clk,
  77. void __iomem **idlest_reg,
  78. u8 *idlest_bit,
  79. u8 *idlest_val)
  80. {
  81. u32 r;
  82. r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20);
  83. *idlest_reg = (__force void __iomem *)r;
  84. /* USBHOST_IDLE has same shift */
  85. *idlest_bit = OMAP3430ES2_ST_DSS_IDLE_SHIFT;
  86. *idlest_val = OMAP34XX_CM_IDLEST_VAL;
  87. }
  88. const struct clkops clkops_omap3430es2_dss_usbhost_wait = {
  89. .enable = omap2_dflt_clk_enable,
  90. .disable = omap2_dflt_clk_disable,
  91. .find_idlest = omap3430es2_clk_dss_usbhost_find_idlest,
  92. .find_companion = omap2_clk_dflt_find_companion,
  93. };
  94. const struct clkops clkops_omap3430es2_iclk_dss_usbhost_wait = {
  95. .enable = omap2_dflt_clk_enable,
  96. .disable = omap2_dflt_clk_disable,
  97. .find_idlest = omap3430es2_clk_dss_usbhost_find_idlest,
  98. .find_companion = omap2_clk_dflt_find_companion,
  99. .allow_idle = omap2_clkt_iclk_allow_idle,
  100. .deny_idle = omap2_clkt_iclk_deny_idle,
  101. };
  102. /**
  103. * omap3430es2_clk_hsotgusb_find_idlest - return CM_IDLEST info for HSOTGUSB
  104. * @clk: struct clk * being enabled
  105. * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into
  106. * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into
  107. * @idlest_val: pointer to a u8 to store the CM_IDLEST indicator
  108. *
  109. * The OMAP3430ES2 HSOTGUSB target CM_IDLEST bit is at a different
  110. * shift from the CM_{I,F}CLKEN bit. Pass back the correct info via
  111. * @idlest_reg and @idlest_bit. No return value.
  112. */
  113. static void omap3430es2_clk_hsotgusb_find_idlest(struct clk *clk,
  114. void __iomem **idlest_reg,
  115. u8 *idlest_bit,
  116. u8 *idlest_val)
  117. {
  118. u32 r;
  119. r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20);
  120. *idlest_reg = (__force void __iomem *)r;
  121. *idlest_bit = OMAP3430ES2_ST_HSOTGUSB_IDLE_SHIFT;
  122. *idlest_val = OMAP34XX_CM_IDLEST_VAL;
  123. }
  124. const struct clkops clkops_omap3430es2_hsotgusb_wait = {
  125. .enable = omap2_dflt_clk_enable,
  126. .disable = omap2_dflt_clk_disable,
  127. .find_idlest = omap3430es2_clk_hsotgusb_find_idlest,
  128. .find_companion = omap2_clk_dflt_find_companion,
  129. };
  130. const struct clkops clkops_omap3430es2_iclk_hsotgusb_wait = {
  131. .enable = omap2_dflt_clk_enable,
  132. .disable = omap2_dflt_clk_disable,
  133. .find_idlest = omap3430es2_clk_hsotgusb_find_idlest,
  134. .find_companion = omap2_clk_dflt_find_companion,
  135. .allow_idle = omap2_clkt_iclk_allow_idle,
  136. .deny_idle = omap2_clkt_iclk_deny_idle,
  137. };