clk-s3c2443.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. /*
  2. * Copyright (c) 2013 Heiko Stuebner <heiko@sntech.de>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. *
  8. * Common Clock Framework support for S3C2443 and following SoCs.
  9. */
  10. #include <linux/clk-provider.h>
  11. #include <linux/of.h>
  12. #include <linux/of_address.h>
  13. #include <linux/syscore_ops.h>
  14. #include <linux/reboot.h>
  15. #include <dt-bindings/clock/s3c2443.h>
  16. #include "clk.h"
  17. #include "clk-pll.h"
  18. /* S3C2416 clock controller register offsets */
  19. #define LOCKCON0 0x00
  20. #define LOCKCON1 0x04
  21. #define MPLLCON 0x10
  22. #define EPLLCON 0x18
  23. #define EPLLCON_K 0x1C
  24. #define CLKSRC 0x20
  25. #define CLKDIV0 0x24
  26. #define CLKDIV1 0x28
  27. #define CLKDIV2 0x2C
  28. #define HCLKCON 0x30
  29. #define PCLKCON 0x34
  30. #define SCLKCON 0x38
  31. #define SWRST 0x44
  32. /* the soc types */
  33. enum supported_socs {
  34. S3C2416,
  35. S3C2443,
  36. S3C2450,
  37. };
  38. /* list of PLLs to be registered */
  39. enum s3c2443_plls {
  40. mpll, epll,
  41. };
  42. static void __iomem *reg_base;
  43. #ifdef CONFIG_PM_SLEEP
  44. static struct samsung_clk_reg_dump *s3c2443_save;
  45. /*
  46. * list of controller registers to be saved and restored during a
  47. * suspend/resume cycle.
  48. */
  49. static unsigned long s3c2443_clk_regs[] __initdata = {
  50. LOCKCON0,
  51. LOCKCON1,
  52. MPLLCON,
  53. EPLLCON,
  54. EPLLCON_K,
  55. CLKSRC,
  56. CLKDIV0,
  57. CLKDIV1,
  58. CLKDIV2,
  59. PCLKCON,
  60. HCLKCON,
  61. SCLKCON,
  62. };
  63. static int s3c2443_clk_suspend(void)
  64. {
  65. samsung_clk_save(reg_base, s3c2443_save,
  66. ARRAY_SIZE(s3c2443_clk_regs));
  67. return 0;
  68. }
  69. static void s3c2443_clk_resume(void)
  70. {
  71. samsung_clk_restore(reg_base, s3c2443_save,
  72. ARRAY_SIZE(s3c2443_clk_regs));
  73. }
  74. static struct syscore_ops s3c2443_clk_syscore_ops = {
  75. .suspend = s3c2443_clk_suspend,
  76. .resume = s3c2443_clk_resume,
  77. };
  78. static void __init s3c2443_clk_sleep_init(void)
  79. {
  80. s3c2443_save = samsung_clk_alloc_reg_dump(s3c2443_clk_regs,
  81. ARRAY_SIZE(s3c2443_clk_regs));
  82. if (!s3c2443_save) {
  83. pr_warn("%s: failed to allocate sleep save data, no sleep support!\n",
  84. __func__);
  85. return;
  86. }
  87. register_syscore_ops(&s3c2443_clk_syscore_ops);
  88. return;
  89. }
  90. #else
  91. static void __init s3c2443_clk_sleep_init(void) {}
  92. #endif
  93. PNAME(epllref_p) = { "mpllref", "mpllref", "xti", "ext" };
  94. PNAME(esysclk_p) = { "epllref", "epll" };
  95. PNAME(mpllref_p) = { "xti", "mdivclk" };
  96. PNAME(msysclk_p) = { "mpllref", "mpll" };
  97. PNAME(armclk_p) = { "armdiv" , "hclk" };
  98. PNAME(i2s0_p) = { "div_i2s0", "ext_i2s", "epllref", "epllref" };
  99. struct samsung_mux_clock s3c2443_common_muxes[] __initdata = {
  100. MUX(0, "epllref", epllref_p, CLKSRC, 7, 2),
  101. MUX(ESYSCLK, "esysclk", esysclk_p, CLKSRC, 6, 1),
  102. MUX(0, "mpllref", mpllref_p, CLKSRC, 3, 1),
  103. MUX_A(MSYSCLK, "msysclk", msysclk_p, CLKSRC, 4, 1, "msysclk"),
  104. MUX_A(ARMCLK, "armclk", armclk_p, CLKDIV0, 13, 1, "armclk"),
  105. MUX(0, "mux_i2s0", i2s0_p, CLKSRC, 14, 2),
  106. };
  107. static struct clk_div_table hclk_d[] = {
  108. { .val = 0, .div = 1 },
  109. { .val = 1, .div = 2 },
  110. { .val = 3, .div = 4 },
  111. { /* sentinel */ },
  112. };
  113. static struct clk_div_table mdivclk_d[] = {
  114. { .val = 0, .div = 1 },
  115. { .val = 1, .div = 3 },
  116. { .val = 2, .div = 5 },
  117. { .val = 3, .div = 7 },
  118. { .val = 4, .div = 9 },
  119. { .val = 5, .div = 11 },
  120. { .val = 6, .div = 13 },
  121. { .val = 7, .div = 15 },
  122. { /* sentinel */ },
  123. };
  124. struct samsung_div_clock s3c2443_common_dividers[] __initdata = {
  125. DIV_T(0, "mdivclk", "xti", CLKDIV0, 6, 3, mdivclk_d),
  126. DIV(0, "prediv", "msysclk", CLKDIV0, 4, 2),
  127. DIV_T(HCLK, "hclk", "prediv", CLKDIV0, 0, 2, hclk_d),
  128. DIV(PCLK, "pclk", "hclk", CLKDIV0, 2, 1),
  129. DIV(0, "div_hsspi0_epll", "esysclk", CLKDIV1, 24, 2),
  130. DIV(0, "div_fimd", "esysclk", CLKDIV1, 16, 8),
  131. DIV(0, "div_i2s0", "esysclk", CLKDIV1, 12, 4),
  132. DIV(0, "div_uart", "esysclk", CLKDIV1, 8, 4),
  133. DIV(0, "div_hsmmc1", "esysclk", CLKDIV1, 6, 2),
  134. DIV(0, "div_usbhost", "esysclk", CLKDIV1, 4, 2),
  135. };
  136. struct samsung_gate_clock s3c2443_common_gates[] __initdata = {
  137. GATE(SCLK_HSMMC_EXT, "sclk_hsmmcext", "ext", SCLKCON, 13, 0, 0),
  138. GATE(SCLK_HSMMC1, "sclk_hsmmc1", "div_hsmmc1", SCLKCON, 12, 0, 0),
  139. GATE(SCLK_FIMD, "sclk_fimd", "div_fimd", SCLKCON, 10, 0, 0),
  140. GATE(SCLK_I2S0, "sclk_i2s0", "mux_i2s0", SCLKCON, 9, 0, 0),
  141. GATE(SCLK_UART, "sclk_uart", "div_uart", SCLKCON, 8, 0, 0),
  142. GATE(SCLK_USBH, "sclk_usbhost", "div_usbhost", SCLKCON, 1, 0, 0),
  143. GATE(HCLK_DRAM, "dram", "hclk", HCLKCON, 19, CLK_IGNORE_UNUSED, 0),
  144. GATE(HCLK_SSMC, "ssmc", "hclk", HCLKCON, 18, CLK_IGNORE_UNUSED, 0),
  145. GATE(HCLK_HSMMC1, "hsmmc1", "hclk", HCLKCON, 16, 0, 0),
  146. GATE(HCLK_USBD, "usb-device", "hclk", HCLKCON, 12, 0, 0),
  147. GATE(HCLK_USBH, "usb-host", "hclk", HCLKCON, 11, 0, 0),
  148. GATE(HCLK_LCD, "lcd", "hclk", HCLKCON, 9, 0, 0),
  149. GATE(HCLK_DMA5, "dma5", "hclk", HCLKCON, 5, CLK_IGNORE_UNUSED, 0),
  150. GATE(HCLK_DMA4, "dma4", "hclk", HCLKCON, 4, CLK_IGNORE_UNUSED, 0),
  151. GATE(HCLK_DMA3, "dma3", "hclk", HCLKCON, 3, CLK_IGNORE_UNUSED, 0),
  152. GATE(HCLK_DMA2, "dma2", "hclk", HCLKCON, 2, CLK_IGNORE_UNUSED, 0),
  153. GATE(HCLK_DMA1, "dma1", "hclk", HCLKCON, 1, CLK_IGNORE_UNUSED, 0),
  154. GATE(HCLK_DMA0, "dma0", "hclk", HCLKCON, 0, CLK_IGNORE_UNUSED, 0),
  155. GATE(PCLK_GPIO, "gpio", "pclk", PCLKCON, 13, CLK_IGNORE_UNUSED, 0),
  156. GATE(PCLK_RTC, "rtc", "pclk", PCLKCON, 12, 0, 0),
  157. GATE(PCLK_WDT, "wdt", "pclk", PCLKCON, 11, 0, 0),
  158. GATE(PCLK_PWM, "pwm", "pclk", PCLKCON, 10, 0, 0),
  159. GATE(PCLK_I2S0, "i2s0", "pclk", PCLKCON, 9, 0, 0),
  160. GATE(PCLK_AC97, "ac97", "pclk", PCLKCON, 8, 0, 0),
  161. GATE(PCLK_ADC, "adc", "pclk", PCLKCON, 7, 0, 0),
  162. GATE(PCLK_SPI0, "spi0", "pclk", PCLKCON, 6, 0, 0),
  163. GATE(PCLK_I2C0, "i2c0", "pclk", PCLKCON, 4, 0, 0),
  164. GATE(PCLK_UART3, "uart3", "pclk", PCLKCON, 3, 0, 0),
  165. GATE(PCLK_UART2, "uart2", "pclk", PCLKCON, 2, 0, 0),
  166. GATE(PCLK_UART1, "uart1", "pclk", PCLKCON, 1, 0, 0),
  167. GATE(PCLK_UART0, "uart0", "pclk", PCLKCON, 0, 0, 0),
  168. };
  169. struct samsung_clock_alias s3c2443_common_aliases[] __initdata = {
  170. ALIAS(HCLK, NULL, "hclk"),
  171. ALIAS(HCLK_SSMC, NULL, "nand"),
  172. ALIAS(PCLK_UART0, "s3c2440-uart.0", "uart"),
  173. ALIAS(PCLK_UART1, "s3c2440-uart.1", "uart"),
  174. ALIAS(PCLK_UART2, "s3c2440-uart.2", "uart"),
  175. ALIAS(PCLK_UART3, "s3c2440-uart.3", "uart"),
  176. ALIAS(PCLK_UART0, "s3c2440-uart.0", "clk_uart_baud2"),
  177. ALIAS(PCLK_UART1, "s3c2440-uart.1", "clk_uart_baud2"),
  178. ALIAS(PCLK_UART2, "s3c2440-uart.2", "clk_uart_baud2"),
  179. ALIAS(PCLK_UART3, "s3c2440-uart.3", "clk_uart_baud2"),
  180. ALIAS(SCLK_UART, NULL, "clk_uart_baud3"),
  181. ALIAS(PCLK_PWM, NULL, "timers"),
  182. ALIAS(PCLK_RTC, NULL, "rtc"),
  183. ALIAS(PCLK_WDT, NULL, "watchdog"),
  184. ALIAS(PCLK_ADC, NULL, "adc"),
  185. ALIAS(PCLK_I2C0, "s3c2410-i2c.0", "i2c"),
  186. ALIAS(HCLK_USBD, NULL, "usb-device"),
  187. ALIAS(HCLK_USBH, NULL, "usb-host"),
  188. ALIAS(SCLK_USBH, NULL, "usb-bus-host"),
  189. ALIAS(PCLK_SPI0, "s3c2443-spi.0", "spi"),
  190. ALIAS(PCLK_SPI0, "s3c2443-spi.0", "spi_busclk0"),
  191. ALIAS(HCLK_HSMMC1, "s3c-sdhci.1", "hsmmc"),
  192. ALIAS(HCLK_HSMMC1, "s3c-sdhci.1", "mmc_busclk.0"),
  193. ALIAS(PCLK_I2S0, "samsung-i2s.0", "iis"),
  194. ALIAS(SCLK_I2S0, NULL, "i2s-if"),
  195. ALIAS(HCLK_LCD, NULL, "lcd"),
  196. ALIAS(SCLK_FIMD, NULL, "sclk_fimd"),
  197. };
  198. /* S3C2416 specific clocks */
  199. static struct samsung_pll_clock s3c2416_pll_clks[] __initdata = {
  200. [mpll] = PLL(pll_6552_s3c2416, 0, "mpll", "mpllref",
  201. LOCKCON0, MPLLCON, NULL),
  202. [epll] = PLL(pll_6553, 0, "epll", "epllref",
  203. LOCKCON1, EPLLCON, NULL),
  204. };
  205. PNAME(s3c2416_hsmmc0_p) = { "sclk_hsmmc0", "sclk_hsmmcext" };
  206. PNAME(s3c2416_hsmmc1_p) = { "sclk_hsmmc1", "sclk_hsmmcext" };
  207. PNAME(s3c2416_hsspi0_p) = { "hsspi0_epll", "hsspi0_mpll" };
  208. static struct clk_div_table armdiv_s3c2416_d[] = {
  209. { .val = 0, .div = 1 },
  210. { .val = 1, .div = 2 },
  211. { .val = 2, .div = 3 },
  212. { .val = 3, .div = 4 },
  213. { .val = 5, .div = 6 },
  214. { .val = 7, .div = 8 },
  215. { /* sentinel */ },
  216. };
  217. struct samsung_div_clock s3c2416_dividers[] __initdata = {
  218. DIV_T(ARMDIV, "armdiv", "msysclk", CLKDIV0, 9, 3, armdiv_s3c2416_d),
  219. DIV(0, "div_hsspi0_mpll", "msysclk", CLKDIV2, 0, 4),
  220. DIV(0, "div_hsmmc0", "esysclk", CLKDIV2, 6, 2),
  221. };
  222. struct samsung_mux_clock s3c2416_muxes[] __initdata = {
  223. MUX(MUX_HSMMC0, "mux_hsmmc0", s3c2416_hsmmc0_p, CLKSRC, 16, 1),
  224. MUX(MUX_HSMMC1, "mux_hsmmc1", s3c2416_hsmmc1_p, CLKSRC, 17, 1),
  225. MUX(MUX_HSSPI0, "mux_hsspi0", s3c2416_hsspi0_p, CLKSRC, 18, 1),
  226. };
  227. struct samsung_gate_clock s3c2416_gates[] __initdata = {
  228. GATE(0, "hsspi0_mpll", "div_hsspi0_mpll", SCLKCON, 19, 0, 0),
  229. GATE(0, "hsspi0_epll", "div_hsspi0_epll", SCLKCON, 14, 0, 0),
  230. GATE(0, "sclk_hsmmc0", "div_hsmmc0", SCLKCON, 6, 0, 0),
  231. GATE(HCLK_2D, "2d", "hclk", HCLKCON, 20, 0, 0),
  232. GATE(HCLK_HSMMC0, "hsmmc0", "hclk", HCLKCON, 15, 0, 0),
  233. GATE(HCLK_IROM, "irom", "hclk", HCLKCON, 13, CLK_IGNORE_UNUSED, 0),
  234. GATE(PCLK_PCM, "pcm", "pclk", PCLKCON, 19, 0, 0),
  235. };
  236. struct samsung_clock_alias s3c2416_aliases[] __initdata = {
  237. ALIAS(HCLK_HSMMC0, "s3c-sdhci.0", "hsmmc"),
  238. ALIAS(HCLK_HSMMC0, "s3c-sdhci.0", "mmc_busclk.0"),
  239. ALIAS(MUX_HSMMC0, "s3c-sdhci.0", "mmc_busclk.2"),
  240. ALIAS(MUX_HSMMC1, "s3c-sdhci.1", "mmc_busclk.2"),
  241. ALIAS(MUX_HSSPI0, "s3c2443-spi.0", "spi_busclk2"),
  242. ALIAS(ARMDIV, NULL, "armdiv"),
  243. };
  244. /* S3C2443 specific clocks */
  245. static struct samsung_pll_clock s3c2443_pll_clks[] __initdata = {
  246. [mpll] = PLL(pll_3000, 0, "mpll", "mpllref",
  247. LOCKCON0, MPLLCON, NULL),
  248. [epll] = PLL(pll_2126, 0, "epll", "epllref",
  249. LOCKCON1, EPLLCON, NULL),
  250. };
  251. static struct clk_div_table armdiv_s3c2443_d[] = {
  252. { .val = 0, .div = 1 },
  253. { .val = 8, .div = 2 },
  254. { .val = 2, .div = 3 },
  255. { .val = 9, .div = 4 },
  256. { .val = 10, .div = 6 },
  257. { .val = 11, .div = 8 },
  258. { .val = 13, .div = 12 },
  259. { .val = 15, .div = 16 },
  260. { /* sentinel */ },
  261. };
  262. struct samsung_div_clock s3c2443_dividers[] __initdata = {
  263. DIV_T(ARMDIV, "armdiv", "msysclk", CLKDIV0, 9, 4, armdiv_s3c2443_d),
  264. DIV(0, "div_cam", "esysclk", CLKDIV1, 26, 4),
  265. };
  266. struct samsung_gate_clock s3c2443_gates[] __initdata = {
  267. GATE(SCLK_HSSPI0, "sclk_hsspi0", "div_hsspi0_epll", SCLKCON, 14, 0, 0),
  268. GATE(SCLK_CAM, "sclk_cam", "div_cam", SCLKCON, 11, 0, 0),
  269. GATE(HCLK_CFC, "cfc", "hclk", HCLKCON, 17, CLK_IGNORE_UNUSED, 0),
  270. GATE(HCLK_CAM, "cam", "hclk", HCLKCON, 8, 0, 0),
  271. GATE(PCLK_SPI1, "spi1", "pclk", PCLKCON, 15, 0, 0),
  272. GATE(PCLK_SDI, "sdi", "pclk", PCLKCON, 5, 0, 0),
  273. };
  274. struct samsung_clock_alias s3c2443_aliases[] __initdata = {
  275. ALIAS(SCLK_HSSPI0, "s3c2443-spi.0", "spi_busclk2"),
  276. ALIAS(SCLK_HSMMC1, "s3c-sdhci.1", "mmc_busclk.2"),
  277. ALIAS(SCLK_CAM, NULL, "camif-upll"),
  278. ALIAS(PCLK_SPI1, "s3c2410-spi.0", "spi"),
  279. ALIAS(PCLK_SDI, NULL, "sdi"),
  280. ALIAS(HCLK_CFC, NULL, "cfc"),
  281. ALIAS(ARMDIV, NULL, "armdiv"),
  282. };
  283. /* S3C2450 specific clocks */
  284. PNAME(s3c2450_cam_p) = { "div_cam", "hclk" };
  285. PNAME(s3c2450_hsspi1_p) = { "hsspi1_epll", "hsspi1_mpll" };
  286. PNAME(i2s1_p) = { "div_i2s1", "ext_i2s", "epllref", "epllref" };
  287. struct samsung_div_clock s3c2450_dividers[] __initdata = {
  288. DIV(0, "div_cam", "esysclk", CLKDIV1, 26, 4),
  289. DIV(0, "div_hsspi1_epll", "esysclk", CLKDIV2, 24, 2),
  290. DIV(0, "div_hsspi1_mpll", "msysclk", CLKDIV2, 16, 4),
  291. DIV(0, "div_i2s1", "esysclk", CLKDIV2, 12, 4),
  292. };
  293. struct samsung_mux_clock s3c2450_muxes[] __initdata = {
  294. MUX(0, "mux_cam", s3c2450_cam_p, CLKSRC, 20, 1),
  295. MUX(MUX_HSSPI1, "mux_hsspi1", s3c2450_hsspi1_p, CLKSRC, 19, 1),
  296. MUX(0, "mux_i2s1", i2s1_p, CLKSRC, 12, 2),
  297. };
  298. struct samsung_gate_clock s3c2450_gates[] __initdata = {
  299. GATE(SCLK_I2S1, "sclk_i2s1", "div_i2s1", SCLKCON, 5, 0, 0),
  300. GATE(HCLK_CFC, "cfc", "hclk", HCLKCON, 17, 0, 0),
  301. GATE(HCLK_CAM, "cam", "hclk", HCLKCON, 8, 0, 0),
  302. GATE(HCLK_DMA7, "dma7", "hclk", HCLKCON, 7, CLK_IGNORE_UNUSED, 0),
  303. GATE(HCLK_DMA6, "dma6", "hclk", HCLKCON, 6, CLK_IGNORE_UNUSED, 0),
  304. GATE(PCLK_I2S1, "i2s1", "pclk", PCLKCON, 17, 0, 0),
  305. GATE(PCLK_I2C1, "i2c1", "pclk", PCLKCON, 16, 0, 0),
  306. GATE(PCLK_SPI1, "spi1", "pclk", PCLKCON, 14, 0, 0),
  307. };
  308. struct samsung_clock_alias s3c2450_aliases[] __initdata = {
  309. ALIAS(PCLK_SPI1, "s3c2443-spi.1", "spi"),
  310. ALIAS(PCLK_SPI1, "s3c2443-spi.1", "spi_busclk0"),
  311. ALIAS(MUX_HSSPI1, "s3c2443-spi.1", "spi_busclk2"),
  312. ALIAS(PCLK_I2C1, "s3c2410-i2c.1", "i2c"),
  313. };
  314. static int s3c2443_restart(struct notifier_block *this,
  315. unsigned long mode, void *cmd)
  316. {
  317. __raw_writel(0x533c2443, reg_base + SWRST);
  318. return NOTIFY_DONE;
  319. }
  320. static struct notifier_block s3c2443_restart_handler = {
  321. .notifier_call = s3c2443_restart,
  322. .priority = 129,
  323. };
  324. /*
  325. * fixed rate clocks generated outside the soc
  326. * Only necessary until the devicetree-move is complete
  327. */
  328. struct samsung_fixed_rate_clock s3c2443_common_frate_clks[] __initdata = {
  329. FRATE(0, "xti", NULL, 0, 0),
  330. FRATE(0, "ext", NULL, 0, 0),
  331. FRATE(0, "ext_i2s", NULL, 0, 0),
  332. FRATE(0, "ext_uart", NULL, 0, 0),
  333. };
  334. static void __init s3c2443_common_clk_register_fixed_ext(
  335. struct samsung_clk_provider *ctx, unsigned long xti_f)
  336. {
  337. s3c2443_common_frate_clks[0].fixed_rate = xti_f;
  338. samsung_clk_register_fixed_rate(ctx, s3c2443_common_frate_clks,
  339. ARRAY_SIZE(s3c2443_common_frate_clks));
  340. }
  341. void __init s3c2443_common_clk_init(struct device_node *np, unsigned long xti_f,
  342. int current_soc,
  343. void __iomem *base)
  344. {
  345. struct samsung_clk_provider *ctx;
  346. int ret;
  347. reg_base = base;
  348. if (np) {
  349. reg_base = of_iomap(np, 0);
  350. if (!reg_base)
  351. panic("%s: failed to map registers\n", __func__);
  352. }
  353. ctx = samsung_clk_init(np, reg_base, NR_CLKS);
  354. /* Register external clocks only in non-dt cases */
  355. if (!np)
  356. s3c2443_common_clk_register_fixed_ext(ctx, xti_f);
  357. /* Register PLLs. */
  358. if (current_soc == S3C2416 || current_soc == S3C2450)
  359. samsung_clk_register_pll(ctx, s3c2416_pll_clks,
  360. ARRAY_SIZE(s3c2416_pll_clks), reg_base);
  361. else
  362. samsung_clk_register_pll(ctx, s3c2443_pll_clks,
  363. ARRAY_SIZE(s3c2443_pll_clks), reg_base);
  364. /* Register common internal clocks. */
  365. samsung_clk_register_mux(ctx, s3c2443_common_muxes,
  366. ARRAY_SIZE(s3c2443_common_muxes));
  367. samsung_clk_register_div(ctx, s3c2443_common_dividers,
  368. ARRAY_SIZE(s3c2443_common_dividers));
  369. samsung_clk_register_gate(ctx, s3c2443_common_gates,
  370. ARRAY_SIZE(s3c2443_common_gates));
  371. samsung_clk_register_alias(ctx, s3c2443_common_aliases,
  372. ARRAY_SIZE(s3c2443_common_aliases));
  373. /* Register SoC-specific clocks. */
  374. switch (current_soc) {
  375. case S3C2450:
  376. samsung_clk_register_div(ctx, s3c2450_dividers,
  377. ARRAY_SIZE(s3c2450_dividers));
  378. samsung_clk_register_mux(ctx, s3c2450_muxes,
  379. ARRAY_SIZE(s3c2450_muxes));
  380. samsung_clk_register_gate(ctx, s3c2450_gates,
  381. ARRAY_SIZE(s3c2450_gates));
  382. samsung_clk_register_alias(ctx, s3c2450_aliases,
  383. ARRAY_SIZE(s3c2450_aliases));
  384. /* fall through, as s3c2450 extends the s3c2416 clocks */
  385. case S3C2416:
  386. samsung_clk_register_div(ctx, s3c2416_dividers,
  387. ARRAY_SIZE(s3c2416_dividers));
  388. samsung_clk_register_mux(ctx, s3c2416_muxes,
  389. ARRAY_SIZE(s3c2416_muxes));
  390. samsung_clk_register_gate(ctx, s3c2416_gates,
  391. ARRAY_SIZE(s3c2416_gates));
  392. samsung_clk_register_alias(ctx, s3c2416_aliases,
  393. ARRAY_SIZE(s3c2416_aliases));
  394. break;
  395. case S3C2443:
  396. samsung_clk_register_div(ctx, s3c2443_dividers,
  397. ARRAY_SIZE(s3c2443_dividers));
  398. samsung_clk_register_gate(ctx, s3c2443_gates,
  399. ARRAY_SIZE(s3c2443_gates));
  400. samsung_clk_register_alias(ctx, s3c2443_aliases,
  401. ARRAY_SIZE(s3c2443_aliases));
  402. break;
  403. }
  404. s3c2443_clk_sleep_init();
  405. samsung_clk_of_add_provider(np, ctx);
  406. ret = register_restart_handler(&s3c2443_restart_handler);
  407. if (ret)
  408. pr_warn("cannot register restart handler, %d\n", ret);
  409. }
  410. static void __init s3c2416_clk_init(struct device_node *np)
  411. {
  412. s3c2443_common_clk_init(np, 0, S3C2416, 0);
  413. }
  414. CLK_OF_DECLARE(s3c2416_clk, "samsung,s3c2416-clock", s3c2416_clk_init);
  415. static void __init s3c2443_clk_init(struct device_node *np)
  416. {
  417. s3c2443_common_clk_init(np, 0, S3C2443, 0);
  418. }
  419. CLK_OF_DECLARE(s3c2443_clk, "samsung,s3c2443-clock", s3c2443_clk_init);
  420. static void __init s3c2450_clk_init(struct device_node *np)
  421. {
  422. s3c2443_common_clk_init(np, 0, S3C2450, 0);
  423. }
  424. CLK_OF_DECLARE(s3c2450_clk, "samsung,s3c2450-clock", s3c2450_clk_init);