clock-s3c2416.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /* linux/arch/arm/mach-s3c2416/clock.c
  2. *
  3. * Copyright (c) 2010 Simtec Electronics
  4. * Copyright (c) 2010 Ben Dooks <ben-linux@fluff.org>
  5. *
  6. * S3C2416 Clock control support
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. */
  13. #include <linux/init.h>
  14. #include <linux/clk.h>
  15. #include <plat/clock.h>
  16. #include <plat/clock-clksrc.h>
  17. #include <plat/cpu.h>
  18. #include <plat/cpu-freq.h>
  19. #include <plat/pll.h>
  20. #include <asm/mach/map.h>
  21. #include <mach/regs-clock.h>
  22. #include <mach/regs-s3c2443-clock.h>
  23. /* armdiv
  24. *
  25. * this clock is sourced from msysclk and can have a number of
  26. * divider values applied to it to then be fed into armclk.
  27. * The real clock definition is done in s3c2443-clock.c,
  28. * only the armdiv divisor table must be defined here.
  29. */
  30. static unsigned int armdiv[8] = {
  31. [0] = 1,
  32. [1] = 2,
  33. [2] = 3,
  34. [3] = 4,
  35. [5] = 6,
  36. [7] = 8,
  37. };
  38. static struct clksrc_clk hsspi_eplldiv = {
  39. .clk = {
  40. .name = "hsspi-eplldiv",
  41. .parent = &clk_esysclk.clk,
  42. .ctrlbit = (1 << 14),
  43. .enable = s3c2443_clkcon_enable_s,
  44. },
  45. .reg_div = { .reg = S3C2443_CLKDIV1, .size = 2, .shift = 24 },
  46. };
  47. static struct clk *hsspi_sources[] = {
  48. [0] = &hsspi_eplldiv.clk,
  49. [1] = NULL, /* to fix */
  50. };
  51. static struct clksrc_clk hsspi_mux = {
  52. .clk = {
  53. .name = "hsspi-if",
  54. },
  55. .sources = &(struct clksrc_sources) {
  56. .sources = hsspi_sources,
  57. .nr_sources = ARRAY_SIZE(hsspi_sources),
  58. },
  59. .reg_src = { .reg = S3C2443_CLKSRC, .size = 1, .shift = 18 },
  60. };
  61. static struct clksrc_clk hsmmc_div[] = {
  62. [0] = {
  63. .clk = {
  64. .name = "hsmmc-div",
  65. .devname = "s3c-sdhci.0",
  66. .parent = &clk_esysclk.clk,
  67. },
  68. .reg_div = { .reg = S3C2416_CLKDIV2, .size = 2, .shift = 6 },
  69. },
  70. [1] = {
  71. .clk = {
  72. .name = "hsmmc-div",
  73. .devname = "s3c-sdhci.1",
  74. .parent = &clk_esysclk.clk,
  75. },
  76. .reg_div = { .reg = S3C2443_CLKDIV1, .size = 2, .shift = 6 },
  77. },
  78. };
  79. static struct clksrc_clk hsmmc_mux0 = {
  80. .clk = {
  81. .name = "hsmmc-if",
  82. .devname = "s3c-sdhci.0",
  83. .ctrlbit = (1 << 6),
  84. .enable = s3c2443_clkcon_enable_s,
  85. },
  86. .sources = &(struct clksrc_sources) {
  87. .nr_sources = 2,
  88. .sources = (struct clk * []) {
  89. [0] = &hsmmc_div[0].clk,
  90. [1] = NULL, /* to fix */
  91. },
  92. },
  93. .reg_src = { .reg = S3C2443_CLKSRC, .size = 1, .shift = 16 },
  94. };
  95. static struct clksrc_clk hsmmc_mux1 = {
  96. .clk = {
  97. .name = "hsmmc-if",
  98. .devname = "s3c-sdhci.1",
  99. .ctrlbit = (1 << 12),
  100. .enable = s3c2443_clkcon_enable_s,
  101. },
  102. .sources = &(struct clksrc_sources) {
  103. .nr_sources = 2,
  104. .sources = (struct clk * []) {
  105. [0] = &hsmmc_div[1].clk,
  106. [1] = NULL, /* to fix */
  107. },
  108. },
  109. .reg_src = { .reg = S3C2443_CLKSRC, .size = 1, .shift = 17 },
  110. };
  111. static struct clk hsmmc0_clk = {
  112. .name = "hsmmc",
  113. .devname = "s3c-sdhci.0",
  114. .parent = &clk_h,
  115. .enable = s3c2443_clkcon_enable_h,
  116. .ctrlbit = S3C2416_HCLKCON_HSMMC0,
  117. };
  118. static struct clksrc_clk *clksrcs[] __initdata = {
  119. &hsspi_eplldiv,
  120. &hsspi_mux,
  121. &hsmmc_div[0],
  122. &hsmmc_div[1],
  123. &hsmmc_mux0,
  124. &hsmmc_mux1,
  125. };
  126. static struct clk_lookup s3c2416_clk_lookup[] = {
  127. CLKDEV_INIT("s3c-sdhci.0", "mmc_busclk.0", &hsmmc0_clk),
  128. CLKDEV_INIT("s3c-sdhci.0", "mmc_busclk.2", &hsmmc_mux0.clk),
  129. CLKDEV_INIT("s3c-sdhci.1", "mmc_busclk.2", &hsmmc_mux1.clk),
  130. /* s3c2443-spi.0 is used on s3c2416 and s3c2450 as well */
  131. CLKDEV_INIT("s3c2443-spi.0", "spi_busclk2", &hsspi_mux.clk),
  132. };
  133. void __init s3c2416_init_clocks(int xtal)
  134. {
  135. u32 epllcon = __raw_readl(S3C2443_EPLLCON);
  136. u32 epllcon1 = __raw_readl(S3C2443_EPLLCON+4);
  137. int ptr;
  138. /* s3c2416 EPLL compatible with s3c64xx */
  139. clk_epll.rate = s3c_get_pll6553x(xtal, epllcon, epllcon1);
  140. clk_epll.parent = &clk_epllref.clk;
  141. s3c2443_common_init_clocks(xtal, s3c2416_get_pll,
  142. armdiv, ARRAY_SIZE(armdiv),
  143. S3C2416_CLKDIV0_ARMDIV_MASK);
  144. for (ptr = 0; ptr < ARRAY_SIZE(clksrcs); ptr++)
  145. s3c_register_clksrc(clksrcs[ptr], 1);
  146. s3c24xx_register_clock(&hsmmc0_clk);
  147. clkdev_add_table(s3c2416_clk_lookup, ARRAY_SIZE(s3c2416_clk_lookup));
  148. s3c_pwmclk_init();
  149. }