synchronousMemoryAndDatabase.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /* linux/arch/arm/plat-s3c64xx/clock.c
  2. *
  3. * Copyright 2008 Openmoko, Inc.
  4. * Copyright 2008 Simtec Electronics
  5. * Ben Dooks <ben@simtec.co.uk>
  6. * http://armlinux.simtec.co.uk/
  7. *
  8. * S3C64XX Base clock support
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #include <linux/init.h>
  15. #include <linux/module.h>
  16. #include <linux/interrupt.h>
  17. #include <linux/ioport.h>
  18. #include <linux/clk.h>
  19. #include <linux/err.h>
  20. #include <linux/io.h>
  21. #include <mach/hardware.h>
  22. #include <mach/map.h>
  23. #include <mach/regs-sys.h>
  24. #include <mach/regs-clock.h>
  25. #include <plat/cpu.h>
  26. #include <plat/devs.h>
  27. #include <plat/cpu-freq.h>
  28. #include <plat/clock.h>
  29. #include <plat/clock-clksrc.h>
  30. #include <plat/pll.h>
  31. /* fin_apll, fin_mpll and fin_epll are all the same clock, which we call
  32. * ext_xtal_mux for want of an actual name from the manual.
  33. */
  34. static struct clk clk_ext_xtal_mux = {
  35. .name = "ext_xtal",
  36. };
  37. #define clk_fin_apll clk_ext_xtal_mux
  38. #define clk_fin_mpll clk_ext_xtal_mux
  39. #define clk_fin_epll clk_ext_xtal_mux
  40. #define clk_fout_mpll clk_mpll
  41. #define clk_fout_epll clk_epll
  42. struct clk clk_h2 = {
  43. .name = "hclk2",
  44. .rate = 0,
  45. };
  46. struct clk clk_27m = {
  47. .name = "clk_27m",
  48. .rate = 27000000,
  49. };
  50. static int clk_48m_ctrl(struct clk *clk, int enable)
  51. {
  52. unsigned long flags;
  53. u32 val;
  54. /* can't rely on clock lock, this register has other usages */
  55. local_irq_save(flags);
  56. val = __raw_readl(S3C64XX_OTHERS);
  57. if (enable)
  58. val |= S3C64XX_OTHERS_USBMASK;
  59. else
  60. val &= ~S3C64XX_OTHERS_USBMASK;
  61. __raw_writel(val, S3C64XX_OTHERS);
  62. local_irq_restore(flags);
  63. return 0;
  64. }
  65. struct clk clk_48m = {
  66. .name = "clk_48m",
  67. .rate = 48000000,
  68. .enable = clk_48m_ctrl,
  69. };
  70. struct clk clk_xusbxti = {
  71. .name = "xusbxti",
  72. .rate = 48000000,
  73. };
  74. static int inline s3c64xx_gate(void __iomem *reg,
  75. struct clk *clk,
  76. int enable)
  77. {
  78. unsigned int ctrlbit = clk->ctrlbit;
  79. u32 con;
  80. con = __raw_readl(reg);
  81. if (enable)
  82. con |= ctrlbit;
  83. else
  84. con &= ~ctrlbit;
  85. __raw_writel(con, reg);
  86. return 0;
  87. }
  88. static int s3c64xx_pclk_ctrl(struct clk *clk, int enable)
  89. {
  90. return s3c64xx_gate(S3C_PCLK_GATE, clk, enable);
  91. }
  92. static int s3c64xx_hclk_ctrl(struct clk *clk, int enable)
  93. {
  94. return s3c64xx_gate(S3C_HCLK_GATE, clk, enable);
  95. }
  96. int s3c64xx_sclk_ctrl(struct clk *clk, int enable)
  97. {
  98. return s3c64xx_gate(S3C_SCLK_GATE, clk, enable);
  99. }
  100. static struct clk init_clocks_off[] = {
  101. {
  102. .name = "nand",
  103. .parent = &clk_h,
  104. }, {
  105. .name = "rtc",
  106. .parent = &clk_p,
  107. .enable = s3c64xx_pclk_ctrl,
  108. .ctrlbit = S3C_CLKCON_PCLK_RTC,
  109. }, {
  110. .name = "adc",
  111. .parent = &clk_p,
  112. .enable = s3c64xx_pclk_ctrl,
  113. .ctrlbit = S3C_CLKCON_PCLK_TSADC,
  114. }, {
  115. .name = "i2c",
  116. .devname = "s3c2440-i2c.0",
  117. .parent = &clk_p,
  118. .enable = s3c64xx_pclk_ctrl,
  119. .ctrlbit = S3C_CLKCON_PCLK_IIC,
  120. }, {
  121. .name = "i2c",
  122. .devname = "s3c2440-i2c.1",
  123. .parent = &clk_p,
  124. .enable = s3c64xx_pclk_ctrl,
  125. .ctrlbit = S3C6410_CLKCON_PCLK_I2C1,
  126. }, {
  127. .name = "keypad",
  128. .parent = &clk_p,
  129. .enable = s3c64xx_pclk_ctrl,
  130. .ctrlbit = S3C_CLKCON_PCLK_KEYPAD,
  131. }, {
  132. .name = "spi",
  133. .devname = "s3c6410-spi.0",
  134. .parent = &clk_p,
  135. .enable = s3c64xx_pclk_ctrl,
  136. .ctrlbit = S3C_CLKCON_PCLK_SPI0,
  137. }, {
  138. .name = "spi",
  139. .devname = "s3c6410-spi.1",
  140. .parent = &clk_p,
  141. .enable = s3c64xx_pclk_ctrl,
  142. .ctrlbit = S3C_CLKCON_PCLK_SPI1,
  143. }, {
  144. .name = "48m",
  145. .devname = "s3c-sdhci.0",
  146. .parent = &clk_48m,
  147. .enable = s3c64xx_sclk_ctrl,
  148. .ctrlbit = S3C_CLKCON_SCLK_MMC0_48,
  149. }, {
  150. .name = "48m",
  151. .devname = "s3c-sdhci.1",
  152. .parent = &clk_48m,
  153. .enable = s3c64xx_sclk_ctrl,
  154. .ctrlbit = S3C_CLKCON_SCLK_MMC1_48,
  155. }, {