clock34xx.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. static void omap3430es2_clk_ssi_find_idlest(struct clk_hw_omap *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 clk_hw_omap_ops clkhwops_omap3430es2_ssi_wait = {
  49. .find_idlest = omap3430es2_clk_ssi_find_idlest,
  50. .find_companion = omap2_clk_dflt_find_companion,
  51. };
  52. const struct clk_hw_omap_ops clkhwops_omap3430es2_iclk_ssi_wait = {
  53. .allow_idle = omap2_clkt_iclk_allow_idle,
  54. .deny_idle = omap2_clkt_iclk_deny_idle,
  55. .find_idlest = omap3430es2_clk_ssi_find_idlest,
  56. .find_companion = omap2_clk_dflt_find_companion,
  57. };
  58. /**
  59. * omap3430es2_clk_dss_usbhost_find_idlest - CM_IDLEST info for DSS, USBHOST
  60. * @clk: struct clk * being enabled
  61. * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into
  62. * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into
  63. * @idlest_val: pointer to a u8 to store the CM_IDLEST indicator
  64. *
  65. * Some OMAP modules on OMAP3 ES2+ chips have both initiator and
  66. * target IDLEST bits. For our purposes, we are concerned with the
  67. * target IDLEST bits, which exist at a different bit position than
  68. * the *CLKEN bit position for these modules (DSS and USBHOST) (The
  69. * default find_idlest code assumes that they are at the same
  70. * position.) No return value.
  71. */
  72. static void omap3430es2_clk_dss_usbhost_find_idlest(struct clk_hw_omap *clk,
  73. void __iomem **idlest_reg,
  74. u8 *idlest_bit,
  75. u8 *idlest_val)
  76. {
  77. u32 r;
  78. r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20);
  79. *idlest_reg = (__force void __iomem *)r;
  80. /* USBHOST_IDLE has same shift */
  81. *idlest_bit = OMAP3430ES2_ST_DSS_IDLE_SHIFT;
  82. *idlest_val = OMAP34XX_CM_IDLEST_VAL;
  83. }
  84. const struct clk_hw_omap_ops clkhwops_omap3430es2_dss_usbhost_wait = {
  85. .find_idlest = omap3430es2_clk_dss_usbhost_find_idlest,
  86. .find_companion = omap2_clk_dflt_find_companion,
  87. };
  88. const struct clk_hw_omap_ops clkhwops_omap3430es2_iclk_dss_usbhost_wait = {
  89. .allow_idle = omap2_clkt_iclk_allow_idle,
  90. .deny_idle = omap2_clkt_iclk_deny_idle,
  91. .find_idlest = omap3430es2_clk_dss_usbhost_find_idlest,
  92. .find_companion = omap2_clk_dflt_find_companion,
  93. };
  94. /**
  95. * omap3430es2_clk_hsotgusb_find_idlest - return CM_IDLEST info for HSOTGUSB
  96. * @clk: struct clk * being enabled
  97. * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into
  98. * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into
  99. * @idlest_val: pointer to a u8 to store the CM_IDLEST indicator
  100. *
  101. * The OMAP3430ES2 HSOTGUSB target CM_IDLEST bit is at a different
  102. * shift from the CM_{I,F}CLKEN bit. Pass back the correct info via
  103. * @idlest_reg and @idlest_bit. No return value.
  104. */
  105. static void omap3430es2_clk_hsotgusb_find_idlest(struct clk_hw_omap *clk,
  106. void __iomem **idlest_reg,
  107. u8 *idlest_bit,
  108. u8 *idlest_val)
  109. {
  110. u32 r;
  111. r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20);
  112. *idlest_reg = (__force void __iomem *)r;
  113. *idlest_bit = OMAP3430ES2_ST_HSOTGUSB_IDLE_SHIFT;
  114. *idlest_val = OMAP34XX_CM_IDLEST_VAL;
  115. }
  116. const struct clk_hw_omap_ops clkhwops_omap3430es2_iclk_hsotgusb_wait = {
  117. .allow_idle = omap2_clkt_iclk_allow_idle,
  118. .deny_idle = omap2_clkt_iclk_deny_idle,
  119. .find_idlest = omap3430es2_clk_hsotgusb_find_idlest,
  120. .find_companion = omap2_clk_dflt_find_companion,
  121. };
  122. const struct clk_hw_omap_ops clkhwops_omap3430es2_hsotgusb_wait = {
  123. .find_idlest = omap3430es2_clk_hsotgusb_find_idlest,
  124. .find_companion = omap2_clk_dflt_find_companion,
  125. };