clk-exynos5410.c 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. /*
  2. * Copyright (c) 2013 Samsung Electronics Co., Ltd.
  3. * Author: Tarek Dakhran <t.dakhran@samsung.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. *
  9. * Common Clock Framework support for Exynos5410 SoC.
  10. */
  11. #include <dt-bindings/clock/exynos5410.h>
  12. #include <linux/clk-provider.h>
  13. #include <linux/of.h>
  14. #include <linux/of_address.h>
  15. #include "clk.h"
  16. #define APLL_LOCK 0x0
  17. #define APLL_CON0 0x100
  18. #define CPLL_LOCK 0x10020
  19. #define CPLL_CON0 0x10120
  20. #define MPLL_LOCK 0x4000
  21. #define MPLL_CON0 0x4100
  22. #define BPLL_LOCK 0x20010
  23. #define BPLL_CON0 0x20110
  24. #define KPLL_LOCK 0x28000
  25. #define KPLL_CON0 0x28100
  26. #define SRC_CPU 0x200
  27. #define DIV_CPU0 0x500
  28. #define SRC_CPERI1 0x4204
  29. #define DIV_TOP0 0x10510
  30. #define DIV_TOP1 0x10514
  31. #define DIV_FSYS1 0x1054c
  32. #define DIV_FSYS2 0x10550
  33. #define DIV_PERIC0 0x10558
  34. #define SRC_TOP0 0x10210
  35. #define SRC_TOP1 0x10214
  36. #define SRC_TOP2 0x10218
  37. #define SRC_FSYS 0x10244
  38. #define SRC_PERIC0 0x10250
  39. #define SRC_MASK_FSYS 0x10340
  40. #define SRC_MASK_PERIC0 0x10350
  41. #define GATE_BUS_FSYS0 0x10740
  42. #define GATE_IP_FSYS 0x10944
  43. #define GATE_IP_PERIC 0x10950
  44. #define GATE_IP_PERIS 0x10960
  45. #define SRC_CDREX 0x20200
  46. #define SRC_KFC 0x28200
  47. #define DIV_KFC0 0x28500
  48. /* list of PLLs */
  49. enum exynos5410_plls {
  50. apll, cpll, mpll,
  51. bpll, kpll,
  52. nr_plls /* number of PLLs */
  53. };
  54. /* list of all parent clocks */
  55. PNAME(apll_p) = { "fin_pll", "fout_apll", };
  56. PNAME(bpll_p) = { "fin_pll", "fout_bpll", };
  57. PNAME(cpll_p) = { "fin_pll", "fout_cpll" };
  58. PNAME(mpll_p) = { "fin_pll", "fout_mpll", };
  59. PNAME(kpll_p) = { "fin_pll", "fout_kpll", };
  60. PNAME(mout_cpu_p) = { "mout_apll", "sclk_mpll", };
  61. PNAME(mout_kfc_p) = { "mout_kpll", "sclk_mpll", };
  62. PNAME(mpll_user_p) = { "fin_pll", "sclk_mpll", };
  63. PNAME(bpll_user_p) = { "fin_pll", "sclk_bpll", };
  64. PNAME(mpll_bpll_p) = { "sclk_mpll_muxed", "sclk_bpll_muxed", };
  65. PNAME(group2_p) = { "fin_pll", "fin_pll", "none", "none",
  66. "none", "none", "sclk_mpll_bpll",
  67. "none", "none", "sclk_cpll" };
  68. static struct samsung_mux_clock exynos5410_mux_clks[] __initdata = {
  69. MUX(0, "mout_apll", apll_p, SRC_CPU, 0, 1),
  70. MUX(0, "mout_cpu", mout_cpu_p, SRC_CPU, 16, 1),
  71. MUX(0, "mout_kpll", kpll_p, SRC_KFC, 0, 1),
  72. MUX(0, "mout_kfc", mout_kfc_p, SRC_KFC, 16, 1),
  73. MUX(0, "sclk_mpll", mpll_p, SRC_CPERI1, 8, 1),
  74. MUX(0, "sclk_mpll_muxed", mpll_user_p, SRC_TOP2, 20, 1),
  75. MUX(0, "sclk_bpll", bpll_p, SRC_CDREX, 0, 1),
  76. MUX(0, "sclk_bpll_muxed", bpll_user_p, SRC_TOP2, 24, 1),
  77. MUX(0, "sclk_cpll", cpll_p, SRC_TOP2, 8, 1),
  78. MUX(0, "sclk_mpll_bpll", mpll_bpll_p, SRC_TOP1, 20, 1),
  79. MUX(0, "mout_mmc0", group2_p, SRC_FSYS, 0, 4),
  80. MUX(0, "mout_mmc1", group2_p, SRC_FSYS, 4, 4),
  81. MUX(0, "mout_mmc2", group2_p, SRC_FSYS, 8, 4),
  82. MUX(0, "mout_uart0", group2_p, SRC_PERIC0, 0, 4),
  83. MUX(0, "mout_uart1", group2_p, SRC_PERIC0, 4, 4),
  84. MUX(0, "mout_uart2", group2_p, SRC_PERIC0, 8, 4),
  85. MUX(0, "mout_aclk200", mpll_bpll_p, SRC_TOP0, 12, 1),
  86. MUX(0, "mout_aclk400", mpll_bpll_p, SRC_TOP0, 20, 1),
  87. };
  88. static struct samsung_div_clock exynos5410_div_clks[] __initdata = {
  89. DIV(0, "div_arm", "mout_cpu", DIV_CPU0, 0, 3),
  90. DIV(0, "div_arm2", "div_arm", DIV_CPU0, 28, 3),
  91. DIV(0, "div_acp", "div_arm2", DIV_CPU0, 8, 3),
  92. DIV(0, "div_cpud", "div_arm2", DIV_CPU0, 4, 3),
  93. DIV(0, "div_atb", "div_arm2", DIV_CPU0, 16, 3),
  94. DIV(0, "pclk_dbg", "div_arm2", DIV_CPU0, 20, 3),
  95. DIV(0, "div_kfc", "mout_kfc", DIV_KFC0, 0, 3),
  96. DIV(0, "div_aclk", "div_kfc", DIV_KFC0, 4, 3),
  97. DIV(0, "div_pclk", "div_kfc", DIV_KFC0, 20, 3),
  98. DIV(0, "aclk66_pre", "sclk_mpll_muxed", DIV_TOP1, 24, 3),
  99. DIV(0, "aclk66", "aclk66_pre", DIV_TOP0, 0, 3),
  100. DIV(0, "div_mmc0", "mout_mmc0", DIV_FSYS1, 0, 4),
  101. DIV(0, "div_mmc1", "mout_mmc1", DIV_FSYS1, 16, 4),
  102. DIV(0, "div_mmc2", "mout_mmc2", DIV_FSYS2, 0, 4),
  103. DIV_F(0, "div_mmc_pre0", "div_mmc0",
  104. DIV_FSYS1, 8, 8, CLK_SET_RATE_PARENT, 0),
  105. DIV_F(0, "div_mmc_pre1", "div_mmc1",
  106. DIV_FSYS1, 24, 8, CLK_SET_RATE_PARENT, 0),
  107. DIV_F(0, "div_mmc_pre2", "div_mmc2",
  108. DIV_FSYS2, 8, 8, CLK_SET_RATE_PARENT, 0),
  109. DIV(0, "div_uart0", "mout_uart0", DIV_PERIC0, 0, 4),
  110. DIV(0, "div_uart1", "mout_uart1", DIV_PERIC0, 4, 4),
  111. DIV(0, "div_uart2", "mout_uart2", DIV_PERIC0, 8, 4),
  112. DIV(0, "div_uart3", "mout_uart3", DIV_PERIC0, 12, 4),
  113. DIV(0, "aclk200", "mout_aclk200", DIV_TOP0, 12, 3),
  114. DIV(0, "aclk400", "mout_aclk400", DIV_TOP0, 24, 3),
  115. };
  116. static struct samsung_gate_clock exynos5410_gate_clks[] __initdata = {
  117. GATE(CLK_MCT, "mct", "aclk66", GATE_IP_PERIS, 18, 0, 0),
  118. GATE(CLK_SCLK_MMC0, "sclk_mmc0", "div_mmc_pre0",
  119. SRC_MASK_FSYS, 0, CLK_SET_RATE_PARENT, 0),
  120. GATE(CLK_SCLK_MMC1, "sclk_mmc1", "div_mmc_pre1",
  121. SRC_MASK_FSYS, 4, CLK_SET_RATE_PARENT, 0),
  122. GATE(CLK_SCLK_MMC2, "sclk_mmc2", "div_mmc_pre2",
  123. SRC_MASK_FSYS, 8, CLK_SET_RATE_PARENT, 0),
  124. GATE(CLK_MMC0, "sdmmc0", "aclk200", GATE_BUS_FSYS0, 12, 0, 0),
  125. GATE(CLK_MMC1, "sdmmc1", "aclk200", GATE_BUS_FSYS0, 13, 0, 0),
  126. GATE(CLK_MMC2, "sdmmc2", "aclk200", GATE_BUS_FSYS0, 14, 0, 0),
  127. GATE(CLK_UART0, "uart0", "aclk66", GATE_IP_PERIC, 0, 0, 0),
  128. GATE(CLK_UART1, "uart1", "aclk66", GATE_IP_PERIC, 1, 0, 0),
  129. GATE(CLK_UART2, "uart2", "aclk66", GATE_IP_PERIC, 2, 0, 0),
  130. GATE(CLK_SCLK_UART0, "sclk_uart0", "div_uart0",
  131. SRC_MASK_PERIC0, 0, CLK_SET_RATE_PARENT, 0),
  132. GATE(CLK_SCLK_UART1, "sclk_uart1", "div_uart1",
  133. SRC_MASK_PERIC0, 4, CLK_SET_RATE_PARENT, 0),
  134. GATE(CLK_SCLK_UART2, "sclk_uart2", "div_uart2",
  135. SRC_MASK_PERIC0, 8, CLK_SET_RATE_PARENT, 0),
  136. };
  137. static struct samsung_pll_clock exynos5410_plls[nr_plls] __initdata = {
  138. [apll] = PLL(pll_35xx, CLK_FOUT_APLL, "fout_apll", "fin_pll", APLL_LOCK,
  139. APLL_CON0, NULL),
  140. [cpll] = PLL(pll_35xx, CLK_FOUT_CPLL, "fout_cpll", "fin_pll", CPLL_LOCK,
  141. CPLL_CON0, NULL),
  142. [mpll] = PLL(pll_35xx, CLK_FOUT_MPLL, "fout_mpll", "fin_pll", MPLL_LOCK,
  143. MPLL_CON0, NULL),
  144. [bpll] = PLL(pll_35xx, CLK_FOUT_BPLL, "fout_bpll", "fin_pll", BPLL_LOCK,
  145. BPLL_CON0, NULL),
  146. [kpll] = PLL(pll_35xx, CLK_FOUT_KPLL, "fout_kpll", "fin_pll", KPLL_LOCK,
  147. KPLL_CON0, NULL),
  148. };
  149. /* register exynos5410 clocks */
  150. static void __init exynos5410_clk_init(struct device_node *np)
  151. {
  152. struct samsung_clk_provider *ctx;
  153. void __iomem *reg_base;
  154. reg_base = of_iomap(np, 0);
  155. if (!reg_base)
  156. panic("%s: failed to map registers\n", __func__);
  157. ctx = samsung_clk_init(np, reg_base, CLK_NR_CLKS);
  158. samsung_clk_register_pll(ctx, exynos5410_plls,
  159. ARRAY_SIZE(exynos5410_plls), reg_base);
  160. samsung_clk_register_mux(ctx, exynos5410_mux_clks,
  161. ARRAY_SIZE(exynos5410_mux_clks));
  162. samsung_clk_register_div(ctx, exynos5410_div_clks,
  163. ARRAY_SIZE(exynos5410_div_clks));
  164. samsung_clk_register_gate(ctx, exynos5410_gate_clks,
  165. ARRAY_SIZE(exynos5410_gate_clks));
  166. samsung_clk_of_add_provider(np, ctx);
  167. pr_debug("Exynos5410: clock setup completed.\n");
  168. }
  169. CLK_OF_DECLARE(exynos5410_clk, "samsung,exynos5410-clock", exynos5410_clk_init);