clock34xx.c 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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 "cm3xxx.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. #ifdef CONFIG_COMMON_CLK
  38. static void omap3430es2_clk_ssi_find_idlest(struct clk_hw_omap *clk,
  39. #else
  40. static void omap3430es2_clk_ssi_find_idlest(struct clk *clk,
  41. #endif
  42. void __iomem **idlest_reg,
  43. u8 *idlest_bit,
  44. u8 *idlest_val)
  45. {
  46. u32 r;
  47. r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20);
  48. *idlest_reg = (__force void __iomem *)r;
  49. *idlest_bit = OMAP3430ES2_ST_SSI_IDLE_SHIFT;
  50. *idlest_val = OMAP34XX_CM_IDLEST_VAL;
  51. }
  52. #ifdef CONFIG_COMMON_CLK
  53. const struct clk_hw_omap_ops clkhwops_omap3430es2_ssi_wait = {
  54. .find_idlest = omap3430es2_clk_ssi_find_idlest,
  55. .find_companion = omap2_clk_dflt_find_companion,
  56. };
  57. const struct clk_hw_omap_ops clkhwops_omap3430es2_iclk_ssi_wait = {
  58. .allow_idle = omap2_clkt_iclk_allow_idle,
  59. .deny_idle = omap2_clkt_iclk_deny_idle,
  60. .find_idlest = omap3430es2_clk_ssi_find_idlest,
  61. .find_companion = omap2_clk_dflt_find_companion,
  62. };
  63. #else
  64. const struct clkops clkops_omap3430es2_ssi_wait = {
  65. .enable = omap2_dflt_clk_enable,
  66. .disable = omap2_dflt_clk_disable,
  67. .find_idlest = omap3430es2_clk_ssi_find_idlest,
  68. .find_companion = omap2_clk_dflt_find_companion,
  69. };
  70. const struct clkops clkops_omap3430es2_iclk_ssi_wait = {
  71. .enable = omap2_dflt_clk_enable,
  72. .disable = omap2_dflt_clk_disable,
  73. .find_idlest = omap3430es2_clk_ssi_find_idlest,
  74. .find_companion = omap2_clk_dflt_find_companion,
  75. .allow_idle = omap2_clkt_iclk_allow_idle,
  76. .deny_idle = omap2_clkt_iclk_deny_idle,
  77. };
  78. #endif
  79. /**
  80. * omap3430es2_clk_dss_usbhost_find_idlest - CM_IDLEST info for DSS, USBHOST
  81. * @clk: struct clk * being enabled
  82. * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into
  83. * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into
  84. * @idlest_val: pointer to a u8 to store the CM_IDLEST indicator
  85. *
  86. * Some OMAP modules on OMAP3 ES2+ chips have both initiator and
  87. * target IDLEST bits. For our purposes, we are concerned with the
  88. * target IDLEST bits, which exist at a different bit position than
  89. * the *CLKEN bit position for these modules (DSS and USBHOST) (The
  90. * default find_idlest code assumes that they are at the same
  91. * position.) No return value.
  92. */
  93. #ifdef CONFIG_COMMON_CLK
  94. static void omap3430es2_clk_dss_usbhost_find_idlest(struct clk_hw_omap *clk,
  95. #else
  96. static void omap3430es2_clk_dss_usbhost_find_idlest(struct clk *clk,
  97. #endif
  98. void __iomem **idlest_reg,
  99. u8 *idlest_bit,
  100. u8 *idlest_val)
  101. {
  102. u32 r;
  103. r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20);
  104. *idlest_reg = (__force void __iomem *)r;
  105. /* USBHOST_IDLE has same shift */
  106. *idlest_bit = OMAP3430ES2_ST_DSS_IDLE_SHIFT;
  107. *idlest_val = OMAP34XX_CM_IDLEST_VAL;
  108. }
  109. #ifdef CONFIG_COMMON_CLK
  110. const struct clk_hw_omap_ops clkhwops_omap3430es2_dss_usbhost_wait = {
  111. .find_idlest = omap3430es2_clk_dss_usbhost_find_idlest,
  112. .find_companion = omap2_clk_dflt_find_companion,
  113. };
  114. const struct clk_hw_omap_ops clkhwops_omap3430es2_iclk_dss_usbhost_wait = {
  115. .allow_idle = omap2_clkt_iclk_allow_idle,
  116. .deny_idle = omap2_clkt_iclk_deny_idle,
  117. .find_idlest = omap3430es2_clk_dss_usbhost_find_idlest,
  118. .find_companion = omap2_clk_dflt_find_companion,
  119. };
  120. #else
  121. const struct clkops clkops_omap3430es2_dss_usbhost_wait = {
  122. .enable = omap2_dflt_clk_enable,
  123. .disable = omap2_dflt_clk_disable,
  124. .find_idlest = omap3430es2_clk_dss_usbhost_find_idlest,
  125. .find_companion = omap2_clk_dflt_find_companion,
  126. };
  127. const struct clkops clkops_omap3430es2_iclk_dss_usbhost_wait = {
  128. .enable = omap2_dflt_clk_enable,
  129. .disable = omap2_dflt_clk_disable,
  130. .find_idlest = omap3430es2_clk_dss_usbhost_find_idlest,
  131. .find_companion = omap2_clk_dflt_find_companion,
  132. .allow_idle = omap2_clkt_iclk_allow_idle,
  133. .deny_idle = omap2_clkt_iclk_deny_idle,
  134. };
  135. #endif
  136. /**
  137. * omap3430es2_clk_hsotgusb_find_idlest - return CM_IDLEST info for HSOTGUSB
  138. * @clk: struct clk * being enabled
  139. * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into
  140. * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into
  141. * @idlest_val: pointer to a u8 to store the CM_IDLEST indicator
  142. *
  143. * The OMAP3430ES2 HSOTGUSB target CM_IDLEST bit is at a different
  144. * shift from the CM_{I,F}CLKEN bit. Pass back the correct info via
  145. * @idlest_reg and @idlest_bit. No return value.
  146. */
  147. #ifdef CONFIG_COMMON_CLK
  148. static void omap3430es2_clk_hsotgusb_find_idlest(struct clk_hw_omap *clk,
  149. #else
  150. static void omap3430es2_clk_hsotgusb_find_idlest(struct clk *clk,
  151. #endif
  152. void __iomem **idlest_reg,
  153. u8 *idlest_bit,
  154. u8 *idlest_val)
  155. {
  156. u32 r;
  157. r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20);
  158. *idlest_reg = (__force void __iomem *)r;
  159. *idlest_bit = OMAP3430ES2_ST_HSOTGUSB_IDLE_SHIFT;
  160. *idlest_val = OMAP34XX_CM_IDLEST_VAL;
  161. }
  162. #ifdef CONFIG_COMMON_CLK
  163. const struct clk_hw_omap_ops clkhwops_omap3430es2_iclk_hsotgusb_wait = {
  164. .allow_idle = omap2_clkt_iclk_allow_idle,
  165. .deny_idle = omap2_clkt_iclk_deny_idle,
  166. .find_idlest = omap3430es2_clk_hsotgusb_find_idlest,
  167. .find_companion = omap2_clk_dflt_find_companion,
  168. };
  169. const struct clk_hw_omap_ops clkhwops_omap3430es2_hsotgusb_wait = {
  170. .find_idlest = omap3430es2_clk_hsotgusb_find_idlest,
  171. .find_companion = omap2_clk_dflt_find_companion,
  172. };
  173. #else
  174. const struct clkops clkops_omap3430es2_hsotgusb_wait = {
  175. .enable = omap2_dflt_clk_enable,
  176. .disable = omap2_dflt_clk_disable,
  177. .find_idlest = omap3430es2_clk_hsotgusb_find_idlest,
  178. .find_companion = omap2_clk_dflt_find_companion,
  179. };
  180. const struct clkops clkops_omap3430es2_iclk_hsotgusb_wait = {
  181. .enable = omap2_dflt_clk_enable,
  182. .disable = omap2_dflt_clk_disable,
  183. .find_idlest = omap3430es2_clk_hsotgusb_find_idlest,
  184. .find_companion = omap2_clk_dflt_find_companion,
  185. .allow_idle = omap2_clkt_iclk_allow_idle,
  186. .deny_idle = omap2_clkt_iclk_deny_idle,
  187. };
  188. #endif