clock-exynos4212.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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 <mach/sysmmu.h>
  27. #include "common.h"
  28. #include "clock-exynos4.h"
  29. #ifdef CONFIG_PM_SLEEP
  30. static struct sleep_save exynos4212_clock_save[] = {
  31. SAVE_ITEM(EXYNOS4_CLKSRC_IMAGE),
  32. SAVE_ITEM(EXYNOS4_CLKDIV_IMAGE),
  33. SAVE_ITEM(EXYNOS4212_CLKGATE_IP_IMAGE),
  34. SAVE_ITEM(EXYNOS4212_CLKGATE_IP_PERIR),
  35. };
  36. #endif
  37. static int exynos4212_clk_ip_isp0_ctrl(struct clk *clk, int enable)
  38. {
  39. return s5p_gatectrl(EXYNOS4_CLKGATE_IP_ISP0, clk, enable);
  40. }
  41. static int exynos4212_clk_ip_isp1_ctrl(struct clk *clk, int enable)
  42. {
  43. return s5p_gatectrl(EXYNOS4_CLKGATE_IP_ISP1, clk, enable);
  44. }
  45. static struct clk *clk_src_mpll_user_list[] = {
  46. [0] = &clk_fin_mpll,
  47. [1] = &exynos4_clk_mout_mpll.clk,
  48. };
  49. static struct clksrc_sources clk_src_mpll_user = {
  50. .sources = clk_src_mpll_user_list,
  51. .nr_sources = ARRAY_SIZE(clk_src_mpll_user_list),
  52. };
  53. static struct clksrc_clk clk_mout_mpll_user = {
  54. .clk = {
  55. .name = "mout_mpll_user",
  56. },
  57. .sources = &clk_src_mpll_user,
  58. .reg_src = { .reg = EXYNOS4_CLKSRC_CPU, .shift = 24, .size = 1 },
  59. };
  60. static struct clksrc_clk exynos4x12_clk_mout_g2d0 = {
  61. .clk = {
  62. .name = "mout_g2d0",
  63. },
  64. .sources = &exynos4_clkset_mout_g2d0,
  65. .reg_src = { .reg = EXYNOS4_CLKSRC_DMC, .shift = 20, .size = 1 },
  66. };
  67. static struct clksrc_clk exynos4x12_clk_mout_g2d1 = {
  68. .clk = {
  69. .name = "mout_g2d1",
  70. },
  71. .sources = &exynos4_clkset_mout_g2d1,
  72. .reg_src = { .reg = EXYNOS4_CLKSRC_DMC, .shift = 24, .size = 1 },
  73. };
  74. static struct clk *exynos4x12_clkset_mout_g2d_list[] = {
  75. [0] = &exynos4x12_clk_mout_g2d0.clk,
  76. [1] = &exynos4x12_clk_mout_g2d1.clk,
  77. };
  78. static struct clksrc_sources exynos4x12_clkset_mout_g2d = {
  79. .sources = exynos4x12_clkset_mout_g2d_list,
  80. .nr_sources = ARRAY_SIZE(exynos4x12_clkset_mout_g2d_list),
  81. };
  82. static struct clksrc_clk *sysclks[] = {
  83. &clk_mout_mpll_user,
  84. };
  85. static struct clksrc_clk clksrcs[] = {
  86. {
  87. .clk = {
  88. .name = "sclk_fimg2d",
  89. },
  90. .sources = &exynos4x12_clkset_mout_g2d,
  91. .reg_src = { .reg = EXYNOS4_CLKSRC_DMC, .shift = 28, .size = 1 },
  92. .reg_div = { .reg = EXYNOS4_CLKDIV_DMC1, .shift = 0, .size = 4 },
  93. },
  94. };
  95. static struct clk init_clocks_off[] = {
  96. {
  97. .name = SYSMMU_CLOCK_NAME,
  98. .devname = SYSMMU_CLOCK_DEVNAME(2d, 14),
  99. .enable = exynos4_clk_ip_dmc_ctrl,
  100. .ctrlbit = (1 << 24),
  101. }, {
  102. .name = SYSMMU_CLOCK_NAME,
  103. .devname = SYSMMU_CLOCK_DEVNAME(isp, 9),
  104. .enable = exynos4212_clk_ip_isp0_ctrl,
  105. .ctrlbit = (7 << 8),
  106. }, {
  107. .name = SYSMMU_CLOCK_NAME2,
  108. .devname = SYSMMU_CLOCK_DEVNAME(isp, 9),
  109. .enable = exynos4212_clk_ip_isp1_ctrl,
  110. .ctrlbit = (1 << 4),
  111. }, {
  112. .name = "flite",
  113. .devname = "exynos-fimc-lite.0",
  114. .enable = exynos4212_clk_ip_isp0_ctrl,
  115. .ctrlbit = (1 << 4),
  116. }, {
  117. .name = "flite",
  118. .devname = "exynos-fimc-lite.1",
  119. .enable = exynos4212_clk_ip_isp0_ctrl,
  120. .ctrlbit = (1 << 3),
  121. }, {
  122. .name = "fimg2d",
  123. .enable = exynos4_clk_ip_dmc_ctrl,
  124. .ctrlbit = (1 << 23),
  125. },
  126. };
  127. #ifdef CONFIG_PM_SLEEP
  128. static int exynos4212_clock_suspend(void)
  129. {
  130. s3c_pm_do_save(exynos4212_clock_save, ARRAY_SIZE(exynos4212_clock_save));
  131. return 0;
  132. }
  133. static void exynos4212_clock_resume(void)
  134. {
  135. s3c_pm_do_restore_core(exynos4212_clock_save, ARRAY_SIZE(exynos4212_clock_save));
  136. }
  137. #else
  138. #define exynos4212_clock_suspend NULL
  139. #define exynos4212_clock_resume NULL
  140. #endif
  141. static struct syscore_ops exynos4212_clock_syscore_ops = {
  142. .suspend = exynos4212_clock_suspend,
  143. .resume = exynos4212_clock_resume,
  144. };
  145. void __init exynos4212_register_clocks(void)
  146. {
  147. int ptr;
  148. /* usbphy1 is removed */
  149. exynos4_clkset_group_list[4] = NULL;
  150. /* mout_mpll_user is used */
  151. exynos4_clkset_group_list[6] = &clk_mout_mpll_user.clk;
  152. exynos4_clkset_aclk_top_list[0] = &clk_mout_mpll_user.clk;
  153. exynos4_clk_mout_mpll.reg_src.reg = EXYNOS4_CLKSRC_DMC;
  154. exynos4_clk_mout_mpll.reg_src.shift = 12;
  155. exynos4_clk_mout_mpll.reg_src.size = 1;
  156. for (ptr = 0; ptr < ARRAY_SIZE(sysclks); ptr++)
  157. s3c_register_clksrc(sysclks[ptr], 1);
  158. s3c_register_clksrc(clksrcs, ARRAY_SIZE(clksrcs));
  159. s3c_register_clocks(init_clocks_off, ARRAY_SIZE(init_clocks_off));
  160. s3c_disable_clocks(init_clocks_off, ARRAY_SIZE(init_clocks_off));
  161. register_syscore_ops(&exynos4212_clock_syscore_ops);
  162. }