clock34xx.c 5.1 KB

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