clock3517.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * OMAP3517/3505-specific clock framework functions
  3. *
  4. * Copyright (C) 2010 Texas Instruments, Inc.
  5. * Copyright (C) 2010 Nokia Corporation
  6. *
  7. * Ranjith Lohithakshan
  8. * Paul Walmsley
  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 "clock3517.h"
  25. #include "cm.h"
  26. #include "cm-regbits-34xx.h"
  27. /*
  28. * In AM35xx IPSS, the {ICK,FCK} enable bits for modules are exported
  29. * in the same register at a bit offset of 0x8. The EN_ACK for ICK is
  30. * at an offset of 4 from ICK enable bit.
  31. */
  32. #define AM35XX_IPSS_ICK_MASK 0xF
  33. #define AM35XX_IPSS_ICK_EN_ACK_OFFSET 0x4
  34. #define AM35XX_IPSS_ICK_FCK_OFFSET 0x8
  35. #define AM35XX_IPSS_CLK_IDLEST_VAL 0
  36. /**
  37. * am35xx_clk_find_idlest - return clock ACK info for AM35XX IPSS
  38. * @clk: struct clk * being enabled
  39. * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into
  40. * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into
  41. * @idlest_val: pointer to a u8 to store the CM_IDLEST indicator
  42. *
  43. * The interface clocks on AM35xx IPSS reflects the clock idle status
  44. * in the enable register itsel at a bit offset of 4 from the enable
  45. * bit. A value of 1 indicates that clock is enabled.
  46. */
  47. static void am35xx_clk_find_idlest(struct clk *clk,
  48. void __iomem **idlest_reg,
  49. u8 *idlest_bit,
  50. u8 *idlest_val)
  51. {
  52. *idlest_reg = (__force void __iomem *)(clk->enable_reg);
  53. *idlest_bit = clk->enable_bit + AM35XX_IPSS_ICK_EN_ACK_OFFSET;
  54. *idlest_val = AM35XX_IPSS_CLK_IDLEST_VAL;
  55. }
  56. /**
  57. * am35xx_clk_find_companion - find companion clock to @clk
  58. * @clk: struct clk * to find the companion clock of
  59. * @other_reg: void __iomem ** to return the companion clock CM_*CLKEN va in
  60. * @other_bit: u8 ** to return the companion clock bit shift in
  61. *
  62. * Some clocks don't have companion clocks. For example, modules with
  63. * only an interface clock (such as HECC) don't have a companion
  64. * clock. Right now, this code relies on the hardware exporting a bit
  65. * in the correct companion register that indicates that the
  66. * nonexistent 'companion clock' is active. Future patches will
  67. * associate this type of code with per-module data structures to
  68. * avoid this issue, and remove the casts. No return value.
  69. */
  70. static void am35xx_clk_find_companion(struct clk *clk, void __iomem **other_reg,
  71. u8 *other_bit)
  72. {
  73. *other_reg = (__force void __iomem *)(clk->enable_reg);
  74. if (clk->enable_bit & AM35XX_IPSS_ICK_MASK)
  75. *other_bit = clk->enable_bit + AM35XX_IPSS_ICK_FCK_OFFSET;
  76. else
  77. *other_bit = clk->enable_bit - AM35XX_IPSS_ICK_FCK_OFFSET;
  78. }
  79. const struct clkops clkops_am35xx_ipss_module_wait = {
  80. .enable = omap2_dflt_clk_enable,
  81. .disable = omap2_dflt_clk_disable,
  82. .find_idlest = am35xx_clk_find_idlest,
  83. .find_companion = am35xx_clk_find_companion,
  84. };
  85. /**
  86. * am35xx_clk_ipss_find_idlest - return CM_IDLEST info for IPSS
  87. * @clk: struct clk * being enabled
  88. * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into
  89. * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into
  90. * @idlest_val: pointer to a u8 to store the CM_IDLEST indicator
  91. *
  92. * The IPSS target CM_IDLEST bit is at a different shift from the
  93. * CM_{I,F}CLKEN bit. Pass back the correct info via @idlest_reg
  94. * and @idlest_bit. No return value.
  95. */
  96. static void am35xx_clk_ipss_find_idlest(struct clk *clk,
  97. void __iomem **idlest_reg,
  98. u8 *idlest_bit,
  99. u8 *idlest_val)
  100. {
  101. u32 r;
  102. r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20);
  103. *idlest_reg = (__force void __iomem *)r;
  104. *idlest_bit = AM35XX_ST_IPSS_SHIFT;
  105. *idlest_val = OMAP34XX_CM_IDLEST_VAL;
  106. }
  107. const struct clkops clkops_am35xx_ipss_wait = {
  108. .enable = omap2_dflt_clk_enable,
  109. .disable = omap2_dflt_clk_disable,
  110. .find_idlest = am35xx_clk_ipss_find_idlest,
  111. .find_companion = omap2_clk_dflt_find_companion,
  112. };