clk-exynos5410.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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 <linux/clk.h>
  16. #include "clk.h"
  17. #define APLL_LOCK 0x0
  18. #define APLL_CON0 0x100
  19. #define CPLL_LOCK 0x10020
  20. #define CPLL_CON0 0x10120
  21. #define EPLL_LOCK 0x10040
  22. #define EPLL_CON0 0x10130
  23. #define MPLL_LOCK 0x4000
  24. #define MPLL_CON0 0x4100
  25. #define BPLL_LOCK 0x20010
  26. #define BPLL_CON0 0x20110
  27. #define KPLL_LOCK 0x28000
  28. #define KPLL_CON0 0x28100
  29. #define SRC_CPU 0x200
  30. #define DIV_CPU0 0x500
  31. #define SRC_CPERI1 0x4204
  32. #define GATE_IP_G2D 0x8800
  33. #define DIV_TOP0 0x10510
  34. #define DIV_TOP1 0x10514
  35. #define DIV_FSYS0 0x10548
  36. #define DIV_FSYS1 0x1054c
  37. #define DIV_FSYS2 0x10550
  38. #define DIV_PERIC0 0x10558
  39. #define DIV_PERIC3 0x10564
  40. #define SRC_TOP0 0x10210
  41. #define SRC_TOP1 0x10214
  42. #define SRC_TOP2 0x10218
  43. #define SRC_FSYS 0x10244
  44. #define SRC_PERIC0 0x10250
  45. #define SRC_MASK_FSYS 0x10340
  46. #define SRC_MASK_PERIC0 0x10350
  47. #define GATE_BUS_FSYS0 0x10740
  48. #define GATE_TOP_SCLK_FSYS 0x10840
  49. #define GATE_TOP_SCLK_PERIC 0x10850
  50. #define GATE_IP_FSYS 0x10944
  51. #define GATE_IP_PERIC 0x10950
  52. #define GATE_IP_PERIS 0x10960
  53. #define SRC_CDREX 0x20200
  54. #define SRC_KFC 0x28200
  55. #define DIV_KFC0 0x28500
  56. /* list of PLLs */
  57. enum exynos5410_plls {
  58. apll, cpll, epll, mpll,
  59. bpll, kpll,
  60. nr_plls /* number of PLLs */
  61. };
  62. /* list of all parent clocks */
  63. PNAME(apll_p) = { "fin_pll", "fout_apll", };
  64. PNAME(bpll_p) = { "fin_pll", "fout_bpll", };
  65. PNAME(cpll_p) = { "fin_pll", "fout_cpll" };
  66. PNAME(epll_p) = { "fin_pll", "fout_epll" };
  67. PNAME(mpll_p) = { "fin_pll", "fout_mpll", };
  68. PNAME(kpll_p) = { "fin_pll", "fout_kpll", };
  69. PNAME(mout_cpu_p) = { "mout_apll", "sclk_mpll", };
  70. PNAME(mout_kfc_p) = { "mout_kpll", "sclk_mpll", };
  71. PNAME(mpll_user_p) = { "fin_pll", "sclk_mpll", };
  72. PNAME(bpll_user_p) = { "fin_pll", "sclk_bpll", };
  73. PNAME(mpll_bpll_p) = { "sclk_mpll_muxed", "sclk_bpll_muxed", };
  74. PNAME(sclk_mpll_bpll_p) = { "sclk_mpll_bpll", "fin_pll", };
  75. PNAME(group2_p) = { "fin_pll", "fin_pll", "none", "none",
  76. "none", "none", "sclk_mpll_bpll",
  77. "none", "none", "sclk_cpll" };
  78. static const struct samsung_mux_clock exynos5410_mux_clks[] __initconst = {
  79. MUX(0, "mout_apll", apll_p, SRC_CPU, 0, 1),
  80. MUX(0, "mout_cpu", mout_cpu_p, SRC_CPU, 16, 1),
  81. MUX(0, "mout_kpll", kpll_p, SRC_KFC, 0, 1),
  82. MUX(0, "mout_kfc", mout_kfc_p, SRC_KFC, 16, 1),
  83. MUX(0, "sclk_mpll", mpll_p, SRC_CPERI1, 8, 1),
  84. MUX(0, "sclk_mpll_muxed", mpll_user_p, SRC_TOP2, 20, 1),
  85. MUX(0, "sclk_bpll", bpll_p, SRC_CDREX, 0, 1),
  86. MUX(0, "sclk_bpll_muxed", bpll_user_p, SRC_TOP2, 24, 1),
  87. MUX(0, "sclk_epll", epll_p, SRC_TOP2, 12, 1),
  88. MUX(0, "sclk_cpll", cpll_p, SRC_TOP2, 8, 1),
  89. MUX(0, "sclk_mpll_bpll", mpll_bpll_p, SRC_TOP1, 20, 1),
  90. MUX(0, "mout_mmc0", group2_p, SRC_FSYS, 0, 4),
  91. MUX(0, "mout_mmc1", group2_p, SRC_FSYS, 4, 4),
  92. MUX(0, "mout_mmc2", group2_p, SRC_FSYS, 8, 4),
  93. MUX(0, "mout_usbd300", sclk_mpll_bpll_p, SRC_FSYS, 28, 1),
  94. MUX(0, "mout_usbd301", sclk_mpll_bpll_p, SRC_FSYS, 29, 1),
  95. MUX(0, "mout_uart0", group2_p, SRC_PERIC0, 0, 4),
  96. MUX(0, "mout_uart1", group2_p, SRC_PERIC0, 4, 4),
  97. MUX(0, "mout_uart2", group2_p, SRC_PERIC0, 8, 4),
  98. MUX(0, "mout_uart3", group2_p, SRC_PERIC0, 12, 4),
  99. MUX(0, "mout_pwm", group2_p, SRC_PERIC0, 24, 4),
  100. MUX(0, "mout_aclk200", mpll_bpll_p, SRC_TOP0, 12, 1),
  101. MUX(0, "mout_aclk400", mpll_bpll_p, SRC_TOP0, 20, 1),
  102. };
  103. static const struct samsung_div_clock exynos5410_div_clks[] __initconst = {
  104. DIV(0, "div_arm", "mout_cpu", DIV_CPU0, 0, 3),
  105. DIV(0, "div_arm2", "div_arm", DIV_CPU0, 28, 3),
  106. DIV(0, "div_acp", "div_arm2", DIV_CPU0, 8, 3),
  107. DIV(0, "div_cpud", "div_arm2", DIV_CPU0, 4, 3),
  108. DIV(0, "div_atb", "div_arm2", DIV_CPU0, 16, 3),
  109. DIV(0, "pclk_dbg", "div_arm2", DIV_CPU0, 20, 3),
  110. DIV(0, "div_kfc", "mout_kfc", DIV_KFC0, 0, 3),
  111. DIV(0, "div_aclk", "div_kfc", DIV_KFC0, 4, 3),
  112. DIV(0, "div_pclk", "div_kfc", DIV_KFC0, 20, 3),
  113. DIV(0, "aclk66_pre", "sclk_mpll_muxed", DIV_TOP1, 24, 3),
  114. DIV(0, "aclk66", "aclk66_pre", DIV_TOP0, 0, 3),
  115. DIV(0, "dout_usbphy300", "mout_usbd300", DIV_FSYS0, 16, 4),
  116. DIV(0, "dout_usbphy301", "mout_usbd301", DIV_FSYS0, 20, 4),
  117. DIV(0, "dout_usbd300", "mout_usbd300", DIV_FSYS0, 24, 4),
  118. DIV(0, "dout_usbd301", "mout_usbd301", DIV_FSYS0, 28, 4),
  119. DIV(0, "div_mmc0", "mout_mmc0", DIV_FSYS1, 0, 4),
  120. DIV(0, "div_mmc1", "mout_mmc1", DIV_FSYS1, 16, 4),
  121. DIV(0, "div_mmc2", "mout_mmc2", DIV_FSYS2, 0, 4),
  122. DIV_F(0, "div_mmc_pre0", "div_mmc0",
  123. DIV_FSYS1, 8, 8, CLK_SET_RATE_PARENT, 0),
  124. DIV_F(0, "div_mmc_pre1", "div_mmc1",
  125. DIV_FSYS1, 24, 8, CLK_SET_RATE_PARENT, 0),
  126. DIV_F(0, "div_mmc_pre2", "div_mmc2",
  127. DIV_FSYS2, 8, 8, CLK_SET_RATE_PARENT, 0),
  128. DIV(0, "div_uart0", "mout_uart0", DIV_PERIC0, 0, 4),
  129. DIV(0, "div_uart1", "mout_uart1", DIV_PERIC0, 4, 4),
  130. DIV(0, "div_uart2", "mout_uart2", DIV_PERIC0, 8, 4),
  131. DIV(0, "div_uart3", "mout_uart3", DIV_PERIC0, 12, 4),
  132. DIV(0, "dout_pwm", "mout_pwm", DIV_PERIC3, 0, 4),
  133. DIV(0, "aclk200", "mout_aclk200", DIV_TOP0, 12, 3),
  134. DIV(0, "aclk266", "mpll_user_p", DIV_TOP0, 16, 3),
  135. DIV(0, "aclk400", "mout_aclk400", DIV_TOP0, 24, 3),
  136. };
  137. static const struct samsung_gate_clock exynos5410_gate_clks[] __initconst = {
  138. GATE(CLK_SSS, "sss", "aclk266", GATE_IP_G2D, 2, 0, 0),
  139. GATE(CLK_MCT, "mct", "aclk66", GATE_IP_PERIS, 18, 0, 0),
  140. GATE(CLK_WDT, "wdt", "aclk66", GATE_IP_PERIS, 19, 0, 0),
  141. GATE(CLK_RTC, "rtc", "aclk66", GATE_IP_PERIS, 20, 0, 0),
  142. GATE(CLK_TMU, "tmu", "aclk66", GATE_IP_PERIS, 21, 0, 0),
  143. GATE(CLK_SCLK_MMC0, "sclk_mmc0", "div_mmc_pre0",
  144. SRC_MASK_FSYS, 0, CLK_SET_RATE_PARENT, 0),
  145. GATE(CLK_SCLK_MMC1, "sclk_mmc1", "div_mmc_pre1",
  146. SRC_MASK_FSYS, 4, CLK_SET_RATE_PARENT, 0),
  147. GATE(CLK_SCLK_MMC2, "sclk_mmc2", "div_mmc_pre2",
  148. SRC_MASK_FSYS, 8, CLK_SET_RATE_PARENT, 0),
  149. GATE(CLK_MMC0, "sdmmc0", "aclk200", GATE_BUS_FSYS0, 12, 0, 0),
  150. GATE(CLK_MMC1, "sdmmc1", "aclk200", GATE_BUS_FSYS0, 13, 0, 0),
  151. GATE(CLK_MMC2, "sdmmc2", "aclk200", GATE_BUS_FSYS0, 14, 0, 0),
  152. GATE(CLK_PDMA1, "pdma1", "aclk200", GATE_BUS_FSYS0, 2, 0, 0),
  153. GATE(CLK_PDMA0, "pdma0", "aclk200", GATE_BUS_FSYS0, 1, 0, 0),
  154. GATE(CLK_SCLK_USBPHY301, "sclk_usbphy301", "dout_usbphy301",
  155. GATE_TOP_SCLK_FSYS, 7, CLK_SET_RATE_PARENT, 0),
  156. GATE(CLK_SCLK_USBPHY300, "sclk_usbphy300", "dout_usbphy300",
  157. GATE_TOP_SCLK_FSYS, 8, CLK_SET_RATE_PARENT, 0),
  158. GATE(CLK_SCLK_USBD300, "sclk_usbd300", "dout_usbd300",
  159. GATE_TOP_SCLK_FSYS, 9, CLK_SET_RATE_PARENT, 0),
  160. GATE(CLK_SCLK_USBD301, "sclk_usbd301", "dout_usbd301",
  161. GATE_TOP_SCLK_FSYS, 10, CLK_SET_RATE_PARENT, 0),
  162. GATE(CLK_SCLK_PWM, "sclk_pwm", "dout_pwm",
  163. GATE_TOP_SCLK_PERIC, 11, CLK_SET_RATE_PARENT, 0),
  164. GATE(CLK_UART0, "uart0", "aclk66", GATE_IP_PERIC, 0, 0, 0),
  165. GATE(CLK_UART1, "uart1", "aclk66", GATE_IP_PERIC, 1, 0, 0),
  166. GATE(CLK_UART2, "uart2", "aclk66", GATE_IP_PERIC, 2, 0, 0),
  167. GATE(CLK_UART3, "uart3", "aclk66", GATE_IP_PERIC, 3, 0, 0),
  168. GATE(CLK_I2C0, "i2c0", "aclk66", GATE_IP_PERIC, 6, 0, 0),
  169. GATE(CLK_I2C1, "i2c1", "aclk66", GATE_IP_PERIC, 7, 0, 0),
  170. GATE(CLK_I2C2, "i2c2", "aclk66", GATE_IP_PERIC, 8, 0, 0),
  171. GATE(CLK_I2C3, "i2c3", "aclk66", GATE_IP_PERIC, 9, 0, 0),
  172. GATE(CLK_USI0, "usi0", "aclk66", GATE_IP_PERIC, 10, 0, 0),
  173. GATE(CLK_USI1, "usi1", "aclk66", GATE_IP_PERIC, 11, 0, 0),
  174. GATE(CLK_USI2, "usi2", "aclk66", GATE_IP_PERIC, 12, 0, 0),
  175. GATE(CLK_USI3, "usi3", "aclk66", GATE_IP_PERIC, 13, 0, 0),
  176. GATE(CLK_PWM, "pwm", "aclk66", GATE_IP_PERIC, 24, 0, 0),
  177. GATE(CLK_SCLK_UART0, "sclk_uart0", "div_uart0",
  178. SRC_MASK_PERIC0, 0, CLK_SET_RATE_PARENT, 0),
  179. GATE(CLK_SCLK_UART1, "sclk_uart1", "div_uart1",
  180. SRC_MASK_PERIC0, 4, CLK_SET_RATE_PARENT, 0),
  181. GATE(CLK_SCLK_UART2, "sclk_uart2", "div_uart2",
  182. SRC_MASK_PERIC0, 8, CLK_SET_RATE_PARENT, 0),
  183. GATE(CLK_SCLK_UART3, "sclk_uart3", "div_uart3",
  184. SRC_MASK_PERIC0, 12, CLK_SET_RATE_PARENT, 0),
  185. GATE(CLK_USBH20, "usbh20", "aclk200_fsys", GATE_IP_FSYS, 18, 0, 0),
  186. GATE(CLK_USBD300, "usbd300", "aclk200_fsys", GATE_IP_FSYS, 19, 0, 0),
  187. GATE(CLK_USBD301, "usbd301", "aclk200_fsys", GATE_IP_FSYS, 20, 0, 0),
  188. };
  189. static const struct samsung_pll_rate_table exynos5410_pll2550x_24mhz_tbl[] __initconst = {
  190. PLL_36XX_RATE(400000000U, 200, 3, 2, 0),
  191. PLL_36XX_RATE(333000000U, 111, 2, 2, 0),
  192. PLL_36XX_RATE(300000000U, 100, 2, 2, 0),
  193. PLL_36XX_RATE(266000000U, 266, 3, 3, 0),
  194. PLL_36XX_RATE(200000000U, 200, 3, 3, 0),
  195. PLL_36XX_RATE(192000000U, 192, 3, 3, 0),
  196. PLL_36XX_RATE(166000000U, 166, 3, 3, 0),
  197. PLL_36XX_RATE(133000000U, 266, 3, 4, 0),
  198. PLL_36XX_RATE(100000000U, 200, 3, 4, 0),
  199. PLL_36XX_RATE(66000000U, 176, 2, 5, 0),
  200. };
  201. static struct samsung_pll_clock exynos5410_plls[nr_plls] __initdata = {
  202. [apll] = PLL(pll_35xx, CLK_FOUT_APLL, "fout_apll", "fin_pll", APLL_LOCK,
  203. APLL_CON0, NULL),
  204. [cpll] = PLL(pll_35xx, CLK_FOUT_CPLL, "fout_cpll", "fin_pll", CPLL_LOCK,
  205. CPLL_CON0, NULL),
  206. [epll] = PLL(pll_2650x, CLK_FOUT_EPLL, "fout_epll", "fin_pll", EPLL_LOCK,
  207. EPLL_CON0, NULL),
  208. [mpll] = PLL(pll_35xx, CLK_FOUT_MPLL, "fout_mpll", "fin_pll", MPLL_LOCK,
  209. MPLL_CON0, NULL),
  210. [bpll] = PLL(pll_35xx, CLK_FOUT_BPLL, "fout_bpll", "fin_pll", BPLL_LOCK,
  211. BPLL_CON0, NULL),
  212. [kpll] = PLL(pll_35xx, CLK_FOUT_KPLL, "fout_kpll", "fin_pll", KPLL_LOCK,
  213. KPLL_CON0, NULL),
  214. };
  215. static const struct samsung_cmu_info cmu __initconst = {
  216. .pll_clks = exynos5410_plls,
  217. .nr_pll_clks = ARRAY_SIZE(exynos5410_plls),
  218. .mux_clks = exynos5410_mux_clks,
  219. .nr_mux_clks = ARRAY_SIZE(exynos5410_mux_clks),
  220. .div_clks = exynos5410_div_clks,
  221. .nr_div_clks = ARRAY_SIZE(exynos5410_div_clks),
  222. .gate_clks = exynos5410_gate_clks,
  223. .nr_gate_clks = ARRAY_SIZE(exynos5410_gate_clks),
  224. .nr_clk_ids = CLK_NR_CLKS,
  225. };
  226. /* register exynos5410 clocks */
  227. static void __init exynos5410_clk_init(struct device_node *np)
  228. {
  229. struct clk *xxti = of_clk_get(np, 0);
  230. if (!IS_ERR(xxti) && clk_get_rate(xxti) == 24 * MHZ)
  231. exynos5410_plls[epll].rate_table = exynos5410_pll2550x_24mhz_tbl;
  232. samsung_cmu_register_one(np, &cmu);
  233. pr_debug("Exynos5410: clock setup completed.\n");
  234. }
  235. CLK_OF_DECLARE(exynos5410_clk, "samsung,exynos5410-clock", exynos5410_clk_init);