clock-exynos4212.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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 *sysclks[] = {
  61. &clk_mout_mpll_user,
  62. };
  63. static struct clksrc_clk clksrcs[] = {
  64. /* nothing here yet */
  65. };
  66. static struct clk init_clocks_off[] = {
  67. {
  68. .name = SYSMMU_CLOCK_NAME,
  69. .devname = SYSMMU_CLOCK_DEVNAME(2d, 14),
  70. .enable = exynos4_clk_ip_dmc_ctrl,
  71. .ctrlbit = (1 << 24),
  72. }, {
  73. .name = SYSMMU_CLOCK_NAME,
  74. .devname = SYSMMU_CLOCK_DEVNAME(isp, 9),
  75. .enable = exynos4212_clk_ip_isp0_ctrl,
  76. .ctrlbit = (7 << 8),
  77. }, {
  78. .name = SYSMMU_CLOCK_NAME2,
  79. .devname = SYSMMU_CLOCK_DEVNAME(isp, 9),
  80. .enable = exynos4212_clk_ip_isp1_ctrl,
  81. .ctrlbit = (1 << 4),
  82. }, {
  83. .name = "flite",
  84. .devname = "exynos-fimc-lite.0",
  85. .enable = exynos4212_clk_ip_isp0_ctrl,
  86. .ctrlbit = (1 << 4),
  87. }, {
  88. .name = "flite",
  89. .devname = "exynos-fimc-lite.1",
  90. .enable = exynos4212_clk_ip_isp0_ctrl,
  91. .ctrlbit = (1 << 3),
  92. }
  93. };
  94. #ifdef CONFIG_PM_SLEEP
  95. static int exynos4212_clock_suspend(void)
  96. {
  97. s3c_pm_do_save(exynos4212_clock_save, ARRAY_SIZE(exynos4212_clock_save));
  98. return 0;
  99. }
  100. static void exynos4212_clock_resume(void)
  101. {
  102. s3c_pm_do_restore_core(exynos4212_clock_save, ARRAY_SIZE(exynos4212_clock_save));
  103. }
  104. #else
  105. #define exynos4212_clock_suspend NULL
  106. #define exynos4212_clock_resume NULL
  107. #endif
  108. static struct syscore_ops exynos4212_clock_syscore_ops = {
  109. .suspend = exynos4212_clock_suspend,
  110. .resume = exynos4212_clock_resume,
  111. };
  112. void __init exynos4212_register_clocks(void)
  113. {
  114. int ptr;
  115. /* usbphy1 is removed */
  116. exynos4_clkset_group_list[4] = NULL;
  117. /* mout_mpll_user is used */
  118. exynos4_clkset_group_list[6] = &clk_mout_mpll_user.clk;
  119. exynos4_clkset_aclk_top_list[0] = &clk_mout_mpll_user.clk;
  120. exynos4_clk_mout_mpll.reg_src.reg = EXYNOS4_CLKSRC_DMC;
  121. exynos4_clk_mout_mpll.reg_src.shift = 12;
  122. exynos4_clk_mout_mpll.reg_src.size = 1;
  123. for (ptr = 0; ptr < ARRAY_SIZE(sysclks); ptr++)
  124. s3c_register_clksrc(sysclks[ptr], 1);
  125. s3c_register_clksrc(clksrcs, ARRAY_SIZE(clksrcs));
  126. s3c_register_clocks(init_clocks_off, ARRAY_SIZE(init_clocks_off));
  127. s3c_disable_clocks(init_clocks_off, ARRAY_SIZE(init_clocks_off));
  128. register_syscore_ops(&exynos4212_clock_syscore_ops);
  129. }