clock-exynos4212.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. };
  84. #ifdef CONFIG_PM_SLEEP
  85. static int exynos4212_clock_suspend(void)
  86. {
  87. s3c_pm_do_save(exynos4212_clock_save, ARRAY_SIZE(exynos4212_clock_save));
  88. return 0;
  89. }
  90. static void exynos4212_clock_resume(void)
  91. {
  92. s3c_pm_do_restore_core(exynos4212_clock_save, ARRAY_SIZE(exynos4212_clock_save));
  93. }
  94. #else
  95. #define exynos4212_clock_suspend NULL
  96. #define exynos4212_clock_resume NULL
  97. #endif
  98. static struct syscore_ops exynos4212_clock_syscore_ops = {
  99. .suspend = exynos4212_clock_suspend,
  100. .resume = exynos4212_clock_resume,
  101. };
  102. void __init exynos4212_register_clocks(void)
  103. {
  104. int ptr;
  105. /* usbphy1 is removed */
  106. exynos4_clkset_group_list[4] = NULL;
  107. /* mout_mpll_user is used */
  108. exynos4_clkset_group_list[6] = &clk_mout_mpll_user.clk;
  109. exynos4_clkset_aclk_top_list[0] = &clk_mout_mpll_user.clk;
  110. exynos4_clk_mout_mpll.reg_src.reg = EXYNOS4_CLKSRC_DMC;
  111. exynos4_clk_mout_mpll.reg_src.shift = 12;
  112. exynos4_clk_mout_mpll.reg_src.size = 1;
  113. for (ptr = 0; ptr < ARRAY_SIZE(sysclks); ptr++)
  114. s3c_register_clksrc(sysclks[ptr], 1);
  115. s3c_register_clksrc(clksrcs, ARRAY_SIZE(clksrcs));
  116. s3c_register_clocks(init_clocks_off, ARRAY_SIZE(init_clocks_off));
  117. s3c_disable_clocks(init_clocks_off, ARRAY_SIZE(init_clocks_off));
  118. register_syscore_ops(&exynos4212_clock_syscore_ops);
  119. }