clock-exynos4210.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. * Copyright (c) 2011-2012 Samsung Electronics Co., Ltd.
  3. * http://www.samsung.com
  4. *
  5. * EXYNOS4210 - 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 exynos4210_clock_save[] = {
  31. SAVE_ITEM(EXYNOS4_CLKSRC_IMAGE),
  32. SAVE_ITEM(EXYNOS4_CLKDIV_IMAGE),
  33. SAVE_ITEM(EXYNOS4210_CLKSRC_LCD1),
  34. SAVE_ITEM(EXYNOS4210_CLKDIV_LCD1),
  35. SAVE_ITEM(EXYNOS4210_CLKSRC_MASK_LCD1),
  36. SAVE_ITEM(EXYNOS4210_CLKGATE_IP_IMAGE),
  37. SAVE_ITEM(EXYNOS4210_CLKGATE_IP_LCD1),
  38. SAVE_ITEM(EXYNOS4210_CLKGATE_IP_PERIR),
  39. };
  40. #endif
  41. static struct clksrc_clk *sysclks[] = {
  42. /* nothing here yet */
  43. };
  44. static int exynos4_clksrc_mask_lcd1_ctrl(struct clk *clk, int enable)
  45. {
  46. return s5p_gatectrl(EXYNOS4210_CLKSRC_MASK_LCD1, clk, enable);
  47. }
  48. static struct clksrc_clk clksrcs[] = {
  49. {
  50. .clk = {
  51. .name = "sclk_sata",
  52. .id = -1,
  53. .enable = exynos4_clksrc_mask_fsys_ctrl,
  54. .ctrlbit = (1 << 24),
  55. },
  56. .sources = &exynos4_clkset_mout_corebus,
  57. .reg_src = { .reg = EXYNOS4_CLKSRC_FSYS, .shift = 24, .size = 1 },
  58. .reg_div = { .reg = EXYNOS4_CLKDIV_FSYS0, .shift = 20, .size = 4 },
  59. }, {
  60. .clk = {
  61. .name = "sclk_fimd",
  62. .devname = "exynos4-fb.1",
  63. .enable = exynos4_clksrc_mask_lcd1_ctrl,
  64. .ctrlbit = (1 << 0),
  65. },
  66. .sources = &exynos4_clkset_group,
  67. .reg_src = { .reg = EXYNOS4210_CLKSRC_LCD1, .shift = 0, .size = 4 },
  68. .reg_div = { .reg = EXYNOS4210_CLKDIV_LCD1, .shift = 0, .size = 4 },
  69. },
  70. };
  71. static struct clk init_clocks_off[] = {
  72. {
  73. .name = "sataphy",
  74. .id = -1,
  75. .parent = &exynos4_clk_aclk_133.clk,
  76. .enable = exynos4_clk_ip_fsys_ctrl,
  77. .ctrlbit = (1 << 3),
  78. }, {
  79. .name = "sata",
  80. .id = -1,
  81. .parent = &exynos4_clk_aclk_133.clk,
  82. .enable = exynos4_clk_ip_fsys_ctrl,
  83. .ctrlbit = (1 << 10),
  84. }, {
  85. .name = "fimd",
  86. .devname = "exynos4-fb.1",
  87. .enable = exynos4_clk_ip_lcd1_ctrl,
  88. .ctrlbit = (1 << 0),
  89. }, {
  90. .name = SYSMMU_CLOCK_NAME,
  91. .devname = SYSMMU_CLOCK_DEVNAME(2d, 14),
  92. .enable = exynos4_clk_ip_image_ctrl,
  93. .ctrlbit = (1 << 3),
  94. }, {
  95. .name = SYSMMU_CLOCK_NAME,
  96. .devname = SYSMMU_CLOCK_DEVNAME(fimd1, 11),
  97. .enable = exynos4_clk_ip_lcd1_ctrl,
  98. .ctrlbit = (1 << 4),
  99. },
  100. };
  101. #ifdef CONFIG_PM_SLEEP
  102. static int exynos4210_clock_suspend(void)
  103. {
  104. s3c_pm_do_save(exynos4210_clock_save, ARRAY_SIZE(exynos4210_clock_save));
  105. return 0;
  106. }
  107. static void exynos4210_clock_resume(void)
  108. {
  109. s3c_pm_do_restore_core(exynos4210_clock_save, ARRAY_SIZE(exynos4210_clock_save));
  110. }
  111. #else
  112. #define exynos4210_clock_suspend NULL
  113. #define exynos4210_clock_resume NULL
  114. #endif
  115. static struct syscore_ops exynos4210_clock_syscore_ops = {
  116. .suspend = exynos4210_clock_suspend,
  117. .resume = exynos4210_clock_resume,
  118. };
  119. void __init exynos4210_register_clocks(void)
  120. {
  121. int ptr;
  122. exynos4_clk_mout_mpll.reg_src.reg = EXYNOS4_CLKSRC_CPU;
  123. exynos4_clk_mout_mpll.reg_src.shift = 8;
  124. exynos4_clk_mout_mpll.reg_src.size = 1;
  125. for (ptr = 0; ptr < ARRAY_SIZE(sysclks); ptr++)
  126. s3c_register_clksrc(sysclks[ptr], 1);
  127. s3c_register_clksrc(clksrcs, ARRAY_SIZE(clksrcs));
  128. s3c_register_clocks(init_clocks_off, ARRAY_SIZE(init_clocks_off));
  129. s3c_disable_clocks(init_clocks_off, ARRAY_SIZE(init_clocks_off));
  130. register_syscore_ops(&exynos4210_clock_syscore_ops);
  131. }