clock-exynos4212.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. /*
  2. * Copyright (c) 2011-2012 Samsung Electronics Co., Ltd.
  3. * http://www.samsung.com
  4. *
  5. * EXYNOS4212 - Clock support
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/err.h>
  13. #include <linux/clk.h>
  14. #include <linux/io.h>
  15. #include <linux/syscore_ops.h>
  16. #include <plat/cpu-freq.h>
  17. #include <plat/clock.h>
  18. #include <plat/cpu.h>
  19. #include <plat/pll.h>
  20. #include <plat/s5p-clock.h>
  21. #include <plat/clock-clksrc.h>
  22. #include <plat/pm.h>
  23. #include <mach/hardware.h>
  24. #include <mach/map.h>
  25. #include <mach/regs-clock.h>
  26. #include "common.h"
  27. #include "clock-exynos4.h"
  28. #ifdef CONFIG_PM_SLEEP
  29. static struct sleep_save exynos4212_clock_save[] = {
  30. SAVE_ITEM(EXYNOS4_CLKSRC_IMAGE),
  31. SAVE_ITEM(EXYNOS4_CLKDIV_IMAGE),
  32. SAVE_ITEM(EXYNOS4212_CLKGATE_IP_IMAGE),
  33. SAVE_ITEM(EXYNOS4212_CLKGATE_IP_PERIR),
  34. };
  35. #endif
  36. static int exynos4212_clk_ip_isp0_ctrl(struct clk *clk, int enable)
  37. {
  38. return s5p_gatectrl(EXYNOS4_CLKGATE_IP_ISP0, clk, enable);
  39. }
  40. static int exynos4212_clk_ip_isp1_ctrl(struct clk *clk, int enable)
  41. {
  42. return s5p_gatectrl(EXYNOS4_CLKGATE_IP_ISP1, clk, enable);
  43. }
  44. static struct clk *clk_src_mpll_user_list[] = {
  45. [0] = &clk_fin_mpll,
  46. [1] = &exynos4_clk_mout_mpll.clk,
  47. };
  48. static struct clksrc_sources clk_src_mpll_user = {
  49. .sources = clk_src_mpll_user_list,
  50. .nr_sources = ARRAY_SIZE(clk_src_mpll_user_list),
  51. };
  52. static struct clksrc_clk clk_mout_mpll_user = {
  53. .clk = {
  54. .name = "mout_mpll_user",
  55. },
  56. .sources = &clk_src_mpll_user,
  57. .reg_src = { .reg = EXYNOS4_CLKSRC_CPU, .shift = 24, .size = 1 },
  58. };
  59. static struct clksrc_clk exynos4x12_clk_mout_g2d0 = {
  60. .clk = {
  61. .name = "mout_g2d0",
  62. },
  63. .sources = &exynos4_clkset_mout_g2d0,
  64. .reg_src = { .reg = EXYNOS4_CLKSRC_DMC, .shift = 20, .size = 1 },
  65. };
  66. static struct clksrc_clk exynos4x12_clk_mout_g2d1 = {
  67. .clk = {
  68. .name = "mout_g2d1",
  69. },
  70. .sources = &exynos4_clkset_mout_g2d1,
  71. .reg_src = { .reg = EXYNOS4_CLKSRC_DMC, .shift = 24, .size = 1 },
  72. };
  73. static struct clk *exynos4x12_clkset_mout_g2d_list[] = {
  74. [0] = &exynos4x12_clk_mout_g2d0.clk,
  75. [1] = &exynos4x12_clk_mout_g2d1.clk,
  76. };
  77. static struct clksrc_sources exynos4x12_clkset_mout_g2d = {
  78. .sources = exynos4x12_clkset_mout_g2d_list,
  79. .nr_sources = ARRAY_SIZE(exynos4x12_clkset_mout_g2d_list),
  80. };
  81. static struct clksrc_clk *sysclks[] = {
  82. &clk_mout_mpll_user,
  83. };
  84. static struct clksrc_clk clksrcs[] = {
  85. {
  86. .clk = {
  87. .name = "sclk_fimg2d",
  88. },
  89. .sources = &exynos4x12_clkset_mout_g2d,
  90. .reg_src = { .reg = EXYNOS4_CLKSRC_DMC, .shift = 28, .size = 1 },
  91. .reg_div = { .reg = EXYNOS4_CLKDIV_DMC1, .shift = 0, .size = 4 },
  92. },
  93. };
  94. static struct clk init_clocks_off[] = {
  95. {
  96. .name = "sysmmu",
  97. .devname = "exynos-sysmmu.9",
  98. .enable = exynos4_clk_ip_dmc_ctrl,
  99. .ctrlbit = (1 << 24),
  100. }, {
  101. .name = "sysmmu",
  102. .devname = "exynos-sysmmu.12",
  103. .enable = exynos4212_clk_ip_isp0_ctrl,
  104. .ctrlbit = (7 << 8),
  105. }, {
  106. .name = "sysmmu",
  107. .devname = "exynos-sysmmu.13",
  108. .enable = exynos4212_clk_ip_isp1_ctrl,
  109. .ctrlbit = (1 << 4),
  110. }, {
  111. .name = "sysmmu",
  112. .devname = "exynos-sysmmu.14",
  113. .enable = exynos4212_clk_ip_isp0_ctrl,
  114. .ctrlbit = (1 << 11),
  115. }, {
  116. .name = "sysmmu",
  117. .devname = "exynos-sysmmu.15",
  118. .enable = exynos4212_clk_ip_isp0_ctrl,
  119. .ctrlbit = (1 << 12),
  120. }, {
  121. .name = "flite",
  122. .devname = "exynos-fimc-lite.0",
  123. .enable = exynos4212_clk_ip_isp0_ctrl,
  124. .ctrlbit = (1 << 4),
  125. }, {
  126. .name = "flite",
  127. .devname = "exynos-fimc-lite.1",
  128. .enable = exynos4212_clk_ip_isp0_ctrl,
  129. .ctrlbit = (1 << 3),
  130. }, {
  131. .name = "fimg2d",
  132. .enable = exynos4_clk_ip_dmc_ctrl,
  133. .ctrlbit = (1 << 23),
  134. },
  135. };
  136. #ifdef CONFIG_PM_SLEEP
  137. static int exynos4212_clock_suspend(void)
  138. {
  139. s3c_pm_do_save(exynos4212_clock_save, ARRAY_SIZE(exynos4212_clock_save));
  140. return 0;
  141. }
  142. static void exynos4212_clock_resume(void)
  143. {
  144. s3c_pm_do_restore_core(exynos4212_clock_save, ARRAY_SIZE(exynos4212_clock_save));
  145. }
  146. #else
  147. #define exynos4212_clock_suspend NULL
  148. #define exynos4212_clock_resume NULL
  149. #endif
  150. static struct syscore_ops exynos4212_clock_syscore_ops = {
  151. .suspend = exynos4212_clock_suspend,
  152. .resume = exynos4212_clock_resume,
  153. };
  154. void __init exynos4212_register_clocks(void)
  155. {
  156. int ptr;
  157. /* usbphy1 is removed */
  158. exynos4_clkset_group_list[4] = NULL;
  159. /* mout_mpll_user is used */
  160. exynos4_clkset_group_list[6] = &clk_mout_mpll_user.clk;
  161. exynos4_clkset_aclk_top_list[0] = &clk_mout_mpll_user.clk;
  162. exynos4_clk_mout_mpll.reg_src.reg = EXYNOS4_CLKSRC_DMC;
  163. exynos4_clk_mout_mpll.reg_src.shift = 12;
  164. exynos4_clk_mout_mpll.reg_src.size = 1;
  165. for (ptr = 0; ptr < ARRAY_SIZE(sysclks); ptr++)
  166. s3c_register_clksrc(sysclks[ptr], 1);
  167. s3c_register_clksrc(clksrcs, ARRAY_SIZE(clksrcs));
  168. s3c_register_clocks(init_clocks_off, ARRAY_SIZE(init_clocks_off));
  169. s3c_disable_clocks(init_clocks_off, ARRAY_SIZE(init_clocks_off));
  170. register_syscore_ops(&exynos4212_clock_syscore_ops);
  171. }