memoryCall.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * SH7372 clock framework support
  3. *
  4. * Copyright (C) 2010 Magnus Damm
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #include <linux/init.h>
  20. #include <linux/kernel.h>
  21. #include <linux/io.h>
  22. #include <linux/sh_clk.h>
  23. #include <linux/clkdev.h>
  24. #include <mach/common.h>
  25. /* SH7372 registers */
  26. #define FRQCRA IOMEM(0xe6150000)
  27. #define FRQCRB IOMEM(0xe6150004)
  28. #define FRQCRC IOMEM(0xe61500e0)
  29. #define FRQCRD IOMEM(0xe61500e4)
  30. #define VCLKCR1 IOMEM(0xe6150008)
  31. #define VCLKCR2 IOMEM(0xe615000c)
  32. #define VCLKCR3 IOMEM(0xe615001c)
  33. #define FMSICKCR IOMEM(0xe6150010)
  34. #define FMSOCKCR IOMEM(0xe6150014)
  35. #define FSIACKCR IOMEM(0xe6150018)
  36. #define FSIBCKCR IOMEM(0xe6150090)
  37. #define SUBCKCR IOMEM(0xe6150080)
  38. #define SPUCKCR IOMEM(0xe6150084)
  39. #define VOUCKCR IOMEM(0xe6150088)
  40. #define HDMICKCR IOMEM(0xe6150094)
  41. #define DSITCKCR IOMEM(0xe6150060)
  42. #define DSI0PCKCR IOMEM(0xe6150064)
  43. #define DSI1PCKCR IOMEM(0xe6150098)
  44. #define PLLC01CR IOMEM(0xe6150028)
  45. #define PLLC2CR IOMEM(0xe615002c)
  46. #define RMSTPCR0 IOMEM(0xe6150110)
  47. #define RMSTPCR1 IOMEM(0xe6150114)
  48. #define RMSTPCR2 IOMEM(0xe6150118)
  49. #define RMSTPCR3 IOMEM(0xe615011c)
  50. #define RMSTPCR4 IOMEM(0xe6150120)
  51. #define SMSTPCR0 IOMEM(0xe6150130)
  52. #define SMSTPCR1 IOMEM(0xe6150134)
  53. #define SMSTPCR2 IOMEM(0xe6150138)
  54. #define SMSTPCR3 IOMEM(0xe615013c)
  55. #define SMSTPCR4 IOMEM(0xe6150140)
  56. #define FSIDIVA 0xFE1F8000
  57. #define FSIDIVB 0xFE1F8008
  58. /* Platforms must set frequency on their DV_CLKI pin */
  59. struct clk sh7372_dv_clki_clk = {
  60. };
  61. /* Fixed 32 KHz root clock from EXTALR pin */
  62. static struct clk r_clk = {
  63. .rate = 32768,
  64. };
  65. /*
  66. * 26MHz default rate for the EXTAL1 root input clock.
  67. * If needed, reset this with clk_set_rate() from the platform code.
  68. */
  69. struct clk sh7372_extal1_clk = {
  70. .rate = 26000000,
  71. };
  72. /*
  73. * 48MHz default rate for the EXTAL2 root input clock.
  74. * If needed, reset this with clk_set_rate() from the platform code.
  75. */
  76. struct clk sh7372_extal2_clk = {
  77. .rate = 48000000,
  78. };
  79. /* A fixed divide-by-2 block */
  80. static unsigned long div2_recalc(struct clk *clk)
  81. {
  82. return clk->parent->rate / 2;
  83. }
  84. static struct sh_clk_ops div2_clk_ops = {
  85. .recalc = div2_recalc,
  86. };
  87. /* Divide dv_clki by two */
  88. struct clk sh7372_dv_clki_div2_clk = {
  89. .ops = &div2_clk_ops,
  90. .parent = &sh7372_dv_clki_clk,
  91. };
  92. /* Divide extal1 by two */
  93. static struct clk extal1_div2_clk = {
  94. .ops = &div2_clk_ops,
  95. .parent = &sh7372_extal1_clk,
  96. };
  97. /* Divide extal2 by two */
  98. static struct clk extal2_div2_clk = {
  99. .ops = &div2_clk_ops,
  100. .parent = &sh7372_extal2_clk,
  101. };
  102. /* Divide extal2 by four */
  103. static struct clk extal2_div4_clk = {
  104. .ops = &div2_clk_ops,
  105. .parent = &extal2_div2_clk,
  106. };
  107. /* PLLC0 and PLLC1 */
  108. static unsigned long pllc01_recalc(struct clk *clk)
  109. {
  110. unsigned long mult = 1;
  111. if (__raw_readl(PLLC01CR) & (1 << 14))
  112. mult = (((__raw_readl(clk->enable_reg) >> 24) & 0x3f) + 1) * 2;
  113. return clk->parent->rate * mult;
  114. }
  115. static struct sh_clk_ops pllc01_clk_ops = {
  116. .recalc = pllc01_recalc,
  117. };
  118. static struct clk pllc0_clk = {
  119. .ops = &pllc01_clk_ops,
  120. .flags = CLK_ENABLE_ON_INIT,