clock.c 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367
  1. /* linux/arch/arm/mach-s5pv210/clock.c
  2. *
  3. * Copyright (c) 2010 Samsung Electronics Co., Ltd.
  4. * http://www.samsung.com/
  5. *
  6. * S5PV210 - Clock support
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #include <linux/init.h>
  13. #include <linux/module.h>
  14. #include <linux/kernel.h>
  15. #include <linux/list.h>
  16. #include <linux/errno.h>
  17. #include <linux/err.h>
  18. #include <linux/clk.h>
  19. #include <linux/device.h>
  20. #include <linux/io.h>
  21. #include <mach/map.h>
  22. #include <plat/cpu-freq.h>
  23. #include <mach/regs-clock.h>
  24. #include <plat/clock.h>
  25. #include <plat/cpu.h>
  26. #include <plat/pll.h>
  27. #include <plat/s5p-clock.h>
  28. #include <plat/clock-clksrc.h>
  29. #include "common.h"
  30. static unsigned long xtal;
  31. static struct clksrc_clk clk_mout_apll = {
  32. .clk = {
  33. .name = "mout_apll",
  34. },
  35. .sources = &clk_src_apll,
  36. .reg_src = { .reg = S5P_CLK_SRC0, .shift = 0, .size = 1 },
  37. };
  38. static struct clksrc_clk clk_mout_epll = {
  39. .clk = {
  40. .name = "mout_epll",
  41. },
  42. .sources = &clk_src_epll,
  43. .reg_src = { .reg = S5P_CLK_SRC0, .shift = 8, .size = 1 },
  44. };
  45. static struct clksrc_clk clk_mout_mpll = {
  46. .clk = {
  47. .name = "mout_mpll",
  48. },
  49. .sources = &clk_src_mpll,
  50. .reg_src = { .reg = S5P_CLK_SRC0, .shift = 4, .size = 1 },
  51. };
  52. static struct clk *clkset_armclk_list[] = {
  53. [0] = &clk_mout_apll.clk,
  54. [1] = &clk_mout_mpll.clk,
  55. };
  56. static struct clksrc_sources clkset_armclk = {
  57. .sources = clkset_armclk_list,
  58. .nr_sources = ARRAY_SIZE(clkset_armclk_list),
  59. };
  60. static struct clksrc_clk clk_armclk = {
  61. .clk = {
  62. .name = "armclk",
  63. },
  64. .sources = &clkset_armclk,
  65. .reg_src = { .reg = S5P_CLK_SRC0, .shift = 16, .size = 1 },
  66. .reg_div = { .reg = S5P_CLK_DIV0, .shift = 0, .size = 3 },
  67. };
  68. static struct clksrc_clk clk_hclk_msys = {
  69. .clk = {
  70. .name = "hclk_msys",
  71. .parent = &clk_armclk.clk,
  72. },
  73. .reg_div = { .reg = S5P_CLK_DIV0, .shift = 8, .size = 3 },
  74. };
  75. static struct clksrc_clk clk_pclk_msys = {
  76. .clk = {
  77. .name = "pclk_msys",
  78. .parent = &clk_hclk_msys.clk,
  79. },
  80. .reg_div = { .reg = S5P_CLK_DIV0, .shift = 12, .size = 3 },
  81. };
  82. static struct clksrc_clk clk_sclk_a2m = {
  83. .clk = {
  84. .name = "sclk_a2m",
  85. .parent = &clk_mout_apll.clk,
  86. },
  87. .reg_div = { .reg = S5P_CLK_DIV0, .shift = 4, .size = 3 },
  88. };
  89. static struct clk *clkset_hclk_sys_list[] = {
  90. [0] = &clk_mout_mpll.clk,
  91. [1] = &clk_sclk_a2m.clk,
  92. };
  93. static struct clksrc_sources clkset_hclk_sys = {
  94. .sources = clkset_hclk_sys_list,
  95. .nr_sources = ARRAY_SIZE(clkset_hclk_sys_list),
  96. };
  97. static struct clksrc_clk clk_hclk_dsys = {
  98. .clk = {
  99. .name = "hclk_dsys",
  100. },
  101. .sources = &clkset_hclk_sys,
  102. .reg_src = { .reg = S5P_CLK_SRC0, .shift = 20, .size = 1 },
  103. .reg_div = { .reg = S5P_CLK_DIV0, .shift = 16, .size = 4 },
  104. };
  105. static struct clksrc_clk clk_pclk_dsys = {
  106. .clk = {
  107. .name = "pclk_dsys",
  108. .parent = &clk_hclk_dsys.clk,
  109. },
  110. .reg_div = { .reg = S5P_CLK_DIV0, .shift = 20, .size = 3 },
  111. };
  112. static struct clksrc_clk clk_hclk_psys = {
  113. .clk = {
  114. .name = "hclk_psys",
  115. },
  116. .sources = &clkset_hclk_sys,
  117. .reg_src = { .reg = S5P_CLK_SRC0, .shift = 24, .size = 1 },
  118. .reg_div = { .reg = S5P_CLK_DIV0, .shift = 24, .size = 4 },
  119. };
  120. static struct clksrc_clk clk_pclk_psys = {
  121. .clk = {
  122. .name = "pclk_psys",
  123. .parent = &clk_hclk_psys.clk,
  124. },
  125. .reg_div = { .reg = S5P_CLK_DIV0, .shift = 28, .size = 3 },
  126. };
  127. static int s5pv210_clk_ip0_ctrl(struct clk *clk, int enable)
  128. {
  129. return s5p_gatectrl(S5P_CLKGATE_IP0, clk, enable);
  130. }
  131. static int s5pv210_clk_ip1_ctrl(struct clk *clk, int enable)
  132. {
  133. return s5p_gatectrl(S5P_CLKGATE_IP1, clk, enable);
  134. }
  135. static int s5pv210_clk_ip2_ctrl(struct clk *clk, int enable)
  136. {
  137. return s5p_gatectrl(S5P_CLKGATE_IP2, clk, enable);
  138. }
  139. static int s5pv210_clk_ip3_ctrl(struct clk *clk, int enable)
  140. {
  141. return s5p_gatectrl(S5P_CLKGATE_IP3, clk, enable);
  142. }
  143. static int s5pv210_clk_mask0_ctrl(struct clk *clk, int enable)
  144. {
  145. return s5p_gatectrl(S5P_CLK_SRC_MASK0, clk, enable);
  146. }
  147. static int s5pv210_clk_mask1_ctrl(struct clk *clk, int enable)
  148. {
  149. return s5p_gatectrl(S5P_CLK_SRC_MASK1, clk, enable);
  150. }
  151. static int s5pv210_clk_hdmiphy_ctrl(struct clk *clk, int enable)
  152. {
  153. return s5p_gatectrl(S5P_HDMI_PHY_CONTROL, clk, enable);
  154. }
  155. static int exynos4_clk_dac_ctrl(struct clk *clk, int enable)
  156. {
  157. return s5p_gatectrl(S5P_DAC_PHY_CONTROL, clk, enable);
  158. }
  159. static struct clk clk_sclk_hdmi27m = {
  160. .name = "sclk_hdmi27m",
  161. .rate = 27000000,
  162. };
  163. static struct clk clk_sclk_hdmiphy = {
  164. .name = "sclk_hdmiphy",
  165. };
  166. static struct clk clk_sclk_usbphy0 = {
  167. .name = "sclk_usbphy0",
  168. };
  169. static struct clk clk_sclk_usbphy1 = {
  170. .name = "sclk_usbphy1",
  171. };
  172. static struct clk clk_pcmcdclk0 = {
  173. .name = "pcmcdclk",
  174. };
  175. static struct clk clk_pcmcdclk1 = {
  176. .name = "pcmcdclk",
  177. };
  178. static struct clk clk_pcmcdclk2 = {
  179. .name = "pcmcdclk",
  180. };
  181. static struct clk dummy_apb_pclk = {
  182. .name = "apb_pclk",
  183. .id = -1,
  184. };
  185. static struct clk *clkset_vpllsrc_list[] = {
  186. [0] = &clk_fin_vpll,
  187. [1] = &clk_sclk_hdmi27m,
  188. };
  189. static struct clksrc_sources clkset_vpllsrc = {
  190. .sources = clkset_vpllsrc_list,
  191. .nr_sources = ARRAY_SIZE(clkset_vpllsrc_list),
  192. };
  193. static struct clksrc_clk clk_vpllsrc = {
  194. .clk = {
  195. .name = "vpll_src",
  196. .enable = s5pv210_clk_mask0_ctrl,
  197. .ctrlbit = (1 << 7),
  198. },
  199. .sources = &clkset_vpllsrc,
  200. .reg_src = { .reg = S5P_CLK_SRC1, .shift = 28, .size = 1 },
  201. };
  202. static struct clk *clkset_sclk_vpll_list[] = {
  203. [0] = &clk_vpllsrc.clk,
  204. [1] = &clk_fout_vpll,
  205. };
  206. static struct clksrc_sources clkset_sclk_vpll = {
  207. .sources = clkset_sclk_vpll_list,
  208. .nr_sources = ARRAY_SIZE(clkset_sclk_vpll_list),
  209. };
  210. static struct clksrc_clk clk_sclk_vpll = {
  211. .clk = {
  212. .name = "sclk_vpll",
  213. },
  214. .sources = &clkset_sclk_vpll,
  215. .reg_src = { .reg = S5P_CLK_SRC0, .shift = 12, .size = 1 },
  216. };
  217. static struct clk *clkset_moutdmc0src_list[] = {
  218. [0] = &clk_sclk_a2m.clk,
  219. [1] = &clk_mout_mpll.clk,
  220. [2] = NULL,
  221. [3] = NULL,
  222. };
  223. static struct clksrc_sources clkset_moutdmc0src = {
  224. .sources = clkset_moutdmc0src_list,
  225. .nr_sources = ARRAY_SIZE(clkset_moutdmc0src_list),
  226. };
  227. static struct clksrc_clk clk_mout_dmc0 = {
  228. .clk = {
  229. .name = "mout_dmc0",
  230. },
  231. .sources = &clkset_moutdmc0src,
  232. .reg_src = { .reg = S5P_CLK_SRC6, .shift = 24, .size = 2 },
  233. };
  234. static struct clksrc_clk clk_sclk_dmc0 = {
  235. .clk = {
  236. .name = "sclk_dmc0",
  237. .parent = &clk_mout_dmc0.clk,
  238. },
  239. .reg_div = { .reg = S5P_CLK_DIV6, .shift = 28, .size = 4 },
  240. };
  241. static unsigned long s5pv210_clk_imem_get_rate(struct clk *clk)
  242. {
  243. return clk_get_rate(clk->parent) / 2;
  244. }
  245. static struct clk_ops clk_hclk_imem_ops = {
  246. .get_rate = s5pv210_clk_imem_get_rate,
  247. };
  248. static unsigned long s5pv210_clk_fout_apll_get_rate(struct clk *clk)
  249. {
  250. return s5p_get_pll45xx(xtal, __raw_readl(S5P_APLL_CON), pll_4508);
  251. }
  252. static struct clk_ops clk_fout_apll_ops = {
  253. .get_rate = s5pv210_clk_fout_apll_get_rate,
  254. };
  255. static struct clk init_clocks_off[] = {
  256. {
  257. .name = "dma",
  258. .devname = "dma-pl330.0",
  259. .parent = &clk_hclk_psys.clk,
  260. .enable = s5pv210_clk_ip0_ctrl,
  261. .ctrlbit = (1 << 3),
  262. }, {
  263. .name = "dma",
  264. .devname = "dma-pl330.1",
  265. .parent = &clk_hclk_psys.clk,
  266. .enable = s5pv210_clk_ip0_ctrl,
  267. .ctrlbit = (1 << 4),
  268. }, {
  269. .name = "rot",
  270. .parent = &clk_hclk_dsys.clk,
  271. .enable = s5pv210_clk_ip0_ctrl,
  272. .ctrlbit = (1<<29),
  273. }, {
  274. .name = "fimc",
  275. .devname = "s5pv210-fimc.0",
  276. .parent = &clk_hclk_dsys.clk,
  277. .enable = s5pv210_clk_ip0_ctrl,
  278. .ctrlbit = (1 << 24),
  279. }, {
  280. .name = "fimc",
  281. .devname = "s5pv210-fimc.1",
  282. .parent = &clk_hclk_dsys.clk,
  283. .enable = s5pv210_clk_ip0_ctrl,
  284. .ctrlbit = (1 << 25),
  285. }, {
  286. .name = "fimc",
  287. .devname = "s5pv210-fimc.2",
  288. .parent = &clk_hclk_dsys.clk,
  289. .enable = s5pv210_clk_ip0_ctrl,
  290. .ctrlbit = (1 << 26),
  291. }, {
  292. .name = "jpeg",
  293. .parent = &clk_hclk_dsys.clk,
  294. .enable = s5pv210_clk_ip0_ctrl,
  295. .ctrlbit = (1 << 28),
  296. }, {
  297. .name = "mfc",
  298. .devname = "s5p-mfc",
  299. .parent = &clk_pclk_psys.clk,
  300. .enable = s5pv210_clk_ip0_ctrl,
  301. .ctrlbit = (1 << 16),
  302. }, {
  303. .name = "dac",
  304. .devname = "s5p-sdo",
  305. .parent = &clk_hclk_dsys.clk,
  306. .enable = s5pv210_clk_ip1_ctrl,
  307. .ctrlbit = (1 << 10),
  308. }, {
  309. .name = "mixer",
  310. .devname = "s5p-mixer",
  311. .parent = &clk_hclk_dsys.clk,
  312. .enable = s5pv210_clk_ip1_ctrl,
  313. .ctrlbit = (1 << 9),
  314. }, {
  315. .name = "vp",
  316. .devname = "s5p-mixer",
  317. .parent = &clk_hclk_dsys.clk,
  318. .enable = s5pv210_clk_ip1_ctrl,
  319. .ctrlbit = (1 << 8),
  320. }, {
  321. .name = "hdmi",
  322. .devname = "s5pv210-hdmi",
  323. .parent = &clk_hclk_dsys.clk,
  324. .enable = s5pv210_clk_ip1_ctrl,
  325. .ctrlbit = (1 << 11),
  326. }, {
  327. .name = "hdmiphy",
  328. .devname = "s5pv210-hdmi",
  329. .enable = s5pv210_clk_hdmiphy_ctrl,
  330. .ctrlbit = (1 << 0),
  331. }, {
  332. .name = "dacphy",
  333. .devname = "s5p-sdo",
  334. .enable = exynos4_clk_dac_ctrl,
  335. .ctrlbit = (1 << 0),
  336. }, {
  337. .name = "otg",
  338. .parent = &clk_hclk_psys.clk,
  339. .enable = s5pv210_clk_ip1_ctrl,
  340. .ctrlbit = (1<<16),
  341. }, {
  342. .name = "usb-host",
  343. .parent = &clk_hclk_psys.clk,
  344. .enable = s5pv210_clk_ip1_ctrl,
  345. .ctrlbit = (1<<17),
  346. }, {
  347. .name = "lcd",
  348. .parent = &clk_hclk_dsys.clk,
  349. .enable = s5pv210_clk_ip1_ctrl,
  350. .ctrlbit = (1<<0),
  351. }, {
  352. .name = "cfcon",
  353. .parent = &clk_hclk_psys.clk,
  354. .enable = s5pv210_clk_ip1_ctrl,
  355. .ctrlbit = (1<<25),
  356. }, {
  357. .name = "systimer",
  358. .parent = &clk_pclk_psys.clk,
  359. .enable = s5pv210_clk_ip3_ctrl,
  360. .ctrlbit = (1<<16),
  361. }, {
  362. .name = "watchdog",
  363. .parent = &clk_pclk_psys.clk,
  364. .enable = s5pv210_clk_ip3_ctrl,
  365. .ctrlbit = (1<<22),
  366. }, {
  367. .name = "rtc",
  368. .parent = &clk_pclk_psys.clk,
  369. .enable = s5pv210_clk_ip3_ctrl,
  370. .ctrlbit = (1<<15),
  371. }, {
  372. .name = "i2c",
  373. .devname = "s3c2440-i2c.0",
  374. .parent = &clk_pclk_psys.clk,
  375. .enable = s5pv210_clk_ip3_ctrl,
  376. .ctrlbit = (1<<7),
  377. }, {
  378. .name = "i2c",
  379. .devname = "s3c2440-i2c.1",
  380. .parent = &clk_pclk_psys.clk,
  381. .enable = s5pv210_clk_ip3_ctrl,
  382. .ctrlbit = (1 << 10),
  383. }, {
  384. .name = "i2c",
  385. .devname = "s3c2440-i2c.2",
  386. .parent = &clk_pclk_psys.clk,
  387. .enable = s5pv210_clk_ip3_ctrl,
  388. .ctrlbit = (1<<9),
  389. }, {
  390. .name = "i2c",
  391. .devname = "s3c2440-hdmiphy-i2c",
  392. .parent = &clk_pclk_psys.clk,
  393. .enable = s5pv210_clk_ip3_ctrl,
  394. .ctrlbit = (1 << 11),
  395. }, {
  396. .name = "spi",
  397. .devname = "s3c64xx-spi.0",
  398. .parent = &clk_pclk_psys.clk,
  399. .enable = s5pv210_clk_ip3_ctrl,
  400. .ctrlbit = (1<<12),
  401. }, {
  402. .name = "spi",
  403. .devname = "s3c64xx-spi.1",
  404. .parent = &clk_pclk_psys.clk,
  405. .enable = s5pv210_clk_ip3_ctrl,
  406. .ctrlbit = (1<<13),
  407. }, {
  408. .name = "spi",
  409. .devname = "s3c64xx-spi.2",
  410. .parent = &clk_pclk_psys.clk,
  411. .enable = s5pv210_clk_ip3_ctrl,
  412. .ctrlbit = (1<<14),
  413. }, {
  414. .name = "timers",
  415. .parent = &clk_pclk_psys.clk,
  416. .enable = s5pv210_clk_ip3_ctrl,
  417. .ctrlbit = (1<<23),
  418. }, {
  419. .name = "adc",
  420. .parent = &clk_pclk_psys.clk,
  421. .enable = s5pv210_clk_ip3_ctrl,
  422. .ctrlbit = (1<<24),
  423. }, {
  424. .name = "keypad",
  425. .parent = &clk_pclk_psys.clk,
  426. .enable = s5pv210_clk_ip3_ctrl,
  427. .ctrlbit = (1<<21),
  428. }, {
  429. .name = "iis",
  430. .devname = "samsung-i2s.0",
  431. .parent = &clk_p,
  432. .enable = s5pv210_clk_ip3_ctrl,
  433. .ctrlbit = (1<<4),
  434. }, {
  435. .name = "iis",
  436. .devname = "samsung-i2s.1",
  437. .parent = &clk_p,
  438. .enable = s5pv210_clk_ip3_ctrl,
  439. .ctrlbit = (1 << 5),
  440. }, {
  441. .name = "iis",
  442. .devname = "samsung-i2s.2",
  443. .parent = &clk_p,
  444. .enable = s5pv210_clk_ip3_ctrl,
  445. .ctrlbit = (1 << 6),
  446. }, {
  447. .name = "spdif",
  448. .parent = &clk_p,
  449. .enable = s5pv210_clk_ip3_ctrl,
  450. .ctrlbit = (1 << 0),
  451. },
  452. };
  453. static struct clk init_clocks[] = {
  454. {
  455. .name = "hclk_imem",
  456. .parent = &clk_hclk_msys.clk,
  457. .ctrlbit = (1 << 5),
  458. .enable = s5pv210_clk_ip0_ctrl,
  459. .ops = &clk_hclk_imem_ops,
  460. }, {
  461. .name = "uart",
  462. .devname = "s5pv210-uart.0",
  463. .parent = &clk_pclk_psys.clk,
  464. .enable = s5pv210_clk_ip3_ctrl,
  465. .ctrlbit = (1 << 17),
  466. }, {
  467. .name = "uart",
  468. .devname = "s5pv210-uart.1",
  469. .parent = &clk_pclk_psys.clk,
  470. .enable = s5pv210_clk_ip3_ctrl,
  471. .ctrlbit = (1 << 18),
  472. }, {
  473. .name = "uart",
  474. .devname = "s5pv210-uart.2",
  475. .parent = &clk_pclk_psys.clk,
  476. .enable = s5pv210_clk_ip3_ctrl,
  477. .ctrlbit = (1 << 19),
  478. }, {
  479. .name = "uart",
  480. .devname = "s5pv210-uart.3",
  481. .parent = &clk_pclk_psys.clk,
  482. .enable = s5pv210_clk_ip3_ctrl,
  483. .ctrlbit = (1 << 20),
  484. }, {
  485. .name = "sromc",
  486. .parent = &clk_hclk_psys.clk,
  487. .enable = s5pv210_clk_ip1_ctrl,
  488. .ctrlbit = (1 << 26),
  489. },
  490. };
  491. static struct clk clk_hsmmc0 = {
  492. .name = "hsmmc",
  493. .devname = "s3c-sdhci.0",
  494. .parent = &clk_hclk_psys.clk,
  495. .enable = s5pv210_clk_ip2_ctrl,
  496. .ctrlbit = (1<<16),
  497. };
  498. static struct clk clk_hsmmc1 = {
  499. .name = "hsmmc",
  500. .devname = "s3c-sdhci.1",
  501. .parent = &clk_hclk_psys.clk,
  502. .enable = s5pv210_clk_ip2_ctrl,
  503. .ctrlbit = (1<<17),
  504. };
  505. static struct clk clk_hsmmc2 = {
  506. .name = "hsmmc",
  507. .devname = "s3c-sdhci.2",
  508. .parent = &clk_hclk_psys.clk,
  509. .enable = s5pv210_clk_ip2_ctrl,
  510. .ctrlbit = (1<<18),
  511. };
  512. static struct clk clk_hsmmc3 = {
  513. .name = "hsmmc",
  514. .devname = "s3c-sdhci.3",
  515. .parent = &clk_hclk_psys.clk,
  516. .enable = s5pv210_clk_ip2_ctrl,
  517. .ctrlbit = (1<<19),
  518. };
  519. static struct clk *clkset_uart_list[] = {
  520. [6] = &clk_mout_mpll.clk,
  521. [7] = &clk_mout_epll.clk,
  522. };
  523. static struct clksrc_sources clkset_uart = {
  524. .sources = clkset_uart_list,
  525. .nr_sources = ARRAY_SIZE(clkset_uart_list),
  526. };
  527. static struct clk *clkset_group1_list[] = {
  528. [0] = &clk_sclk_a2m.clk,
  529. [1] = &clk_mout_mpll.clk,
  530. [2] = &clk_mout_epll.clk,
  531. [3] = &clk_sclk_vpll.clk,
  532. };
  533. static struct clksrc_sources clkset_group1 = {
  534. .sources = clkset_group1_list,
  535. .nr_sources = ARRAY_SIZE(clkset_group1_list),
  536. };
  537. static struct clk *clkset_sclk_onenand_list[] = {
  538. [0] = &clk_hclk_psys.clk,
  539. [1] = &clk_hclk_dsys.clk,
  540. };
  541. static struct clksrc_sources clkset_sclk_onenand = {
  542. .sources = clkset_sclk_onenand_list,
  543. .nr_sources = ARRAY_SIZE(clkset_sclk_onenand_list),
  544. };
  545. static struct clk *clkset_sclk_dac_list[] = {
  546. [0] = &clk_sclk_vpll.clk,
  547. [1] = &clk_sclk_hdmiphy,
  548. };
  549. static struct clksrc_sources clkset_sclk_dac = {
  550. .sources = clkset_sclk_dac_list,
  551. .nr_sources = ARRAY_SIZE(clkset_sclk_dac_list),
  552. };
  553. static struct clksrc_clk clk_sclk_dac = {
  554. .clk = {
  555. .name = "sclk_dac",
  556. .enable = s5pv210_clk_mask0_ctrl,
  557. .ctrlbit = (1 << 2),
  558. },
  559. .sources = &clkset_sclk_dac,
  560. .reg_src = { .reg = S5P_CLK_SRC1, .shift = 8, .size = 1 },
  561. };
  562. static struct clksrc_clk clk_sclk_pixel = {
  563. .clk = {
  564. .name = "sclk_pixel",
  565. .parent = &clk_sclk_vpll.clk,
  566. },
  567. .reg_div = { .reg = S5P_CLK_DIV1, .shift = 0, .size = 4},
  568. };
  569. static struct clk *clkset_sclk_hdmi_list[] = {
  570. [0] = &clk_sclk_pixel.clk,
  571. [1] = &clk_sclk_hdmiphy,
  572. };
  573. static struct clksrc_sources clkset_sclk_hdmi = {
  574. .sources = clkset_sclk_hdmi_list,
  575. .nr_sources = ARRAY_SIZE(clkset_sclk_hdmi_list),
  576. };
  577. static struct clksrc_clk clk_sclk_hdmi = {
  578. .clk = {
  579. .name = "sclk_hdmi",
  580. .enable = s5pv210_clk_mask0_ctrl,
  581. .ctrlbit = (1 << 0),
  582. },
  583. .sources = &clkset_sclk_hdmi,
  584. .reg_src = { .reg = S5P_CLK_SRC1, .shift = 0, .size = 1 },
  585. };
  586. static struct clk *clkset_sclk_mixer_list[] = {
  587. [0] = &clk_sclk_dac.clk,
  588. [1] = &clk_sclk_hdmi.clk,
  589. };
  590. static struct clksrc_sources clkset_sclk_mixer = {
  591. .sources = clkset_sclk_mixer_list,
  592. .nr_sources = ARRAY_SIZE(clkset_sclk_mixer_list),
  593. };
  594. static struct clksrc_clk clk_sclk_mixer = {
  595. .clk = {
  596. .name = "sclk_mixer",
  597. .enable = s5pv210_clk_mask0_ctrl,
  598. .ctrlbit = (1 << 1),
  599. },
  600. .sources = &clkset_sclk_mixer,
  601. .reg_src = { .reg = S5P_CLK_SRC1, .shift = 4, .size = 1 },
  602. };
  603. static struct clksrc_clk *sclk_tv[] = {
  604. &clk_sclk_dac,
  605. &clk_sclk_pixel,
  606. &clk_sclk_hdmi,
  607. &clk_sclk_mixer,
  608. };
  609. static struct clk *clkset_sclk_audio0_list[] = {
  610. [0] = &clk_ext_xtal_mux,
  611. [1] = &clk_pcmcdclk0,
  612. [2] = &clk_sclk_hdmi27m,
  613. [3] = &clk_sclk_usbphy0,
  614. [4] = &clk_sclk_usbphy1,
  615. [5] = &clk_sclk_hdmiphy,
  616. [6] = &clk_mout_mpll.clk,
  617. [7] = &clk_mout_epll.clk,
  618. [8] = &clk_sclk_vpll.clk,
  619. };
  620. static struct clksrc_sources clkset_sclk_audio0 = {
  621. .sources = clkset_sclk_audio0_list,
  622. .nr_sources = ARRAY_SIZE(clkset_sclk_audio0_list),
  623. };
  624. static struct clksrc_clk clk_sclk_audio0 = {
  625. .clk = {
  626. .name = "sclk_audio",
  627. .devname = "soc-audio.0",
  628. .enable = s5pv210_clk_mask0_ctrl,
  629. .ctrlbit = (1 << 24),
  630. },
  631. .sources = &clkset_sclk_audio0,
  632. .reg_src = { .reg = S5P_CLK_SRC6, .shift = 0, .size = 4 },
  633. .reg_div = { .reg = S5P_CLK_DIV6, .shift = 0, .size = 4 },
  634. };
  635. static struct clk *clkset_sclk_audio1_list[] = {
  636. [0] = &clk_ext_xtal_mux,
  637. [1] = &clk_pcmcdclk1,
  638. [2] = &clk_sclk_hdmi27m,
  639. [3] = &clk_sclk_usbphy0,
  640. [4] = &clk_sclk_usbphy1,
  641. [5] = &clk_sclk_hdmiphy,
  642. [6] = &clk_mout_mpll.clk,
  643. [7] = &clk_mout_epll.clk,
  644. [8] = &clk_sclk_vpll.clk,
  645. };
  646. static struct clksrc_sources clkset_sclk_audio1 = {
  647. .sources = clkset_sclk_audio1_list,
  648. .nr_sources = ARRAY_SIZE(clkset_sclk_audio1_list),
  649. };
  650. static struct clksrc_clk clk_sclk_audio1 = {
  651. .clk = {
  652. .name = "sclk_audio",
  653. .devname = "soc-audio.1",
  654. .enable = s5pv210_clk_mask0_ctrl,
  655. .ctrlbit = (1 << 25),
  656. },
  657. .sources = &clkset_sclk_audio1,
  658. .reg_src = { .reg = S5P_CLK_SRC6, .shift = 4, .size = 4 },
  659. .reg_div = { .reg = S5P_CLK_DIV6, .shift = 4, .size = 4 },
  660. };
  661. static struct clk *clkset_sclk_audio2_list[] = {
  662. [0] = &clk_ext_xtal_mux,
  663. [1] = &clk_pcmcdclk0,
  664. [2] = &clk_sclk_hdmi27m,
  665. [3] = &clk_sclk_usbphy0,
  666. [4] = &clk_sclk_usbphy1,
  667. [5] = &clk_sclk_hdmiphy,
  668. [6] = &clk_mout_mpll.clk,
  669. [7] = &clk_mout_epll.clk,
  670. [8] = &clk_sclk_vpll.clk,
  671. };
  672. static struct clksrc_sources clkset_sclk_audio2 = {
  673. .sources = clkset_sclk_audio2_list,
  674. .nr_sources = ARRAY_SIZE(clkset_sclk_audio2_list),
  675. };
  676. static struct clksrc_clk clk_sclk_audio2 = {
  677. .clk = {
  678. .name = "sclk_audio",
  679. .devname = "soc-audio.2",
  680. .enable = s5pv210_clk_mask0_ctrl,
  681. .ctrlbit = (1 << 26),
  682. },
  683. .sources = &clkset_sclk_audio2,
  684. .reg_src = { .reg = S5P_CLK_SRC6, .shift = 8, .size = 4 },
  685. .reg_div = { .reg = S5P_CLK_DIV6, .shift = 8, .size = 4 },
  686. };
  687. static struct clk *clkset_sclk_spdif_list[] = {
  688. [0] = &clk_sclk_audio0.clk,
  689. [1] = &clk_sclk_audio1.clk,
  690. [2] = &clk_sclk_audio2.clk,
  691. };
  692. static struct clksrc_sources clkset_sclk_spdif = {
  693. .sources = clkset_sclk_spdif_list,
  694. .nr_sources = ARRAY_SIZE(clkset_sclk_spdif_list),
  695. };
  696. static struct clksrc_clk clk_sclk_spdif = {
  697. .clk = {
  698. .name = "sclk_spdif",
  699. .enable = s5pv210_clk_mask0_ctrl,
  700. .ctrlbit = (1 << 27),
  701. .ops = &s5p_sclk_spdif_ops,
  702. },
  703. .sources = &clkset_sclk_spdif,
  704. .reg_src = { .reg = S5P_CLK_SRC6, .shift = 12, .size = 2 },
  705. };
  706. static struct clk *clkset_group2_list[] = {
  707. [0] = &clk_ext_xtal_mux,
  708. [1] = &clk_xusbxti,
  709. [2] = &clk_sclk_hdmi27m,
  710. [3] = &clk_sclk_usbphy0,
  711. [4] = &clk_sclk_usbphy1,
  712. [5] = &clk_sclk_hdmiphy,
  713. [6] = &clk_mout_mpll.clk,
  714. [7] = &clk_mout_epll.clk,
  715. [8] = &clk_sclk_vpll.clk,
  716. };
  717. static struct clksrc_sources clkset_group2 = {
  718. .sources = clkset_group2_list,
  719. .nr_sources = ARRAY_SIZE(clkset_group2_list),
  720. };
  721. static struct clksrc_clk clksrcs[] = {
  722. {
  723. .clk = {
  724. .name = "sclk_dmc",
  725. },
  726. .sources = &clkset_group1,
  727. .reg_src = { .reg = S5P_CLK_SRC6, .shift = 24, .size = 2 },
  728. .reg_div = { .reg = S5P_CLK_DIV6, .shift = 28, .size = 4 },
  729. }, {
  730. .clk = {
  731. .name = "sclk_onenand",
  732. },
  733. .sources = &clkset_sclk_onenand,
  734. .reg_src = { .reg = S5P_CLK_SRC0, .shift = 28, .size = 1 },
  735. .reg_div = { .reg = S5P_CLK_DIV6, .shift = 12, .size = 3 },
  736. }, {
  737. .clk = {
  738. .name = "sclk_fimc",
  739. .devname = "s5pv210-fimc.0",
  740. .enable = s5pv210_clk_mask1_ctrl,
  741. .ctrlbit = (1 << 2),
  742. },
  743. .sources = &clkset_group2,
  744. .reg_src = { .reg = S5P_CLK_SRC3, .shift = 12, .size = 4 },
  745. .reg_div = { .reg = S5P_CLK_DIV3, .shift = 12, .size = 4 },
  746. }, {
  747. .clk = {
  748. .name = "sclk_fimc",
  749. .devname = "s5pv210-fimc.1",
  750. .enable = s5pv210_clk_mask1_ctrl,
  751. .ctrlbit = (1 << 3),
  752. },
  753. .sources = &clkset_group2,
  754. .reg_src = { .reg = S5P_CLK_SRC3, .shift = 16, .size = 4 },
  755. .reg_div = { .reg = S5P_CLK_DIV3, .shift = 16, .size = 4 },
  756. }, {
  757. .clk = {
  758. .name = "sclk_fimc",
  759. .devname = "s5pv210-fimc.2",
  760. .enable = s5pv210_clk_mask1_ctrl,
  761. .ctrlbit = (1 << 4),
  762. },
  763. .sources = &clkset_group2,
  764. .reg_src = { .reg = S5P_CLK_SRC3, .shift = 20, .size = 4 },
  765. .reg_div = { .reg = S5P_CLK_DIV3, .shift = 20, .size = 4 },
  766. }, {
  767. .clk = {
  768. .name = "sclk_cam0",
  769. .enable = s5pv210_clk_mask0_ctrl,
  770. .ctrlbit = (1 << 3),
  771. },
  772. .sources = &clkset_group2,
  773. .reg_src = { .reg = S5P_CLK_SRC1, .shift = 12, .size = 4 },
  774. .reg_div = { .reg = S5P_CLK_DIV1, .shift = 12, .size = 4 },
  775. }, {
  776. .clk = {
  777. .name = "sclk_cam1",
  778. .enable = s5pv210_clk_mask0_ctrl,
  779. .ctrlbit = (1 << 4),
  780. },
  781. .sources = &clkset_group2,
  782. .reg_src = { .reg = S5P_CLK_SRC1, .shift = 16, .size = 4 },
  783. .reg_div = { .reg = S5P_CLK_DIV1, .shift = 16, .size = 4 },
  784. }, {
  785. .clk = {
  786. .name = "sclk_fimd",
  787. .enable = s5pv210_clk_mask0_ctrl,
  788. .ctrlbit = (1 << 5),
  789. },
  790. .sources = &clkset_group2,
  791. .reg_src = { .reg = S5P_CLK_SRC1, .shift = 20, .size = 4 },
  792. .reg_div = { .reg = S5P_CLK_DIV1, .shift = 20, .size = 4 },
  793. }, {
  794. .clk = {
  795. .name = "sclk_mfc",
  796. .devname = "s5p-mfc",
  797. .enable = s5pv210_clk_ip0_ctrl,
  798. .ctrlbit = (1 << 16),
  799. },
  800. .sources = &clkset_group1,
  801. .reg_src = { .reg = S5P_CLK_SRC2, .shift = 4, .size = 2 },
  802. .reg_div = { .reg = S5P_CLK_DIV2, .shift = 4, .size = 4 },
  803. }, {
  804. .clk = {
  805. .name = "sclk_g2d",
  806. .enable = s5pv210_clk_ip0_ctrl,
  807. .ctrlbit = (1 << 12),
  808. },
  809. .sources = &clkset_group1,
  810. .reg_src = { .reg = S5P_CLK_SRC2, .shift = 8, .size = 2 },
  811. .reg_div = { .reg = S5P_CLK_DIV2, .shift = 8, .size = 4 },
  812. }, {
  813. .clk = {
  814. .name = "sclk_g3d",
  815. .enable = s5pv210_clk_ip0_ctrl,
  816. .ctrlbit = (1 << 8),
  817. },
  818. .sources = &clkset_group1,
  819. .reg_src = { .reg = S5P_CLK_SRC2, .shift = 0, .size = 2 },
  820. .reg_div = { .reg = S5P_CLK_DIV2, .shift = 0, .size = 4 },
  821. }, {
  822. .clk = {
  823. .name = "sclk_csis",
  824. .enable = s5pv210_clk_mask0_ctrl,
  825. .ctrlbit = (1 << 6),
  826. },
  827. .sources = &clkset_group2,
  828. .reg_src = { .reg = S5P_CLK_SRC1, .shift = 24, .size = 4 },
  829. .reg_div = { .reg = S5P_CLK_DIV1, .shift = 28, .size = 4 },
  830. }, {
  831. .clk = {
  832. .name = "sclk_pwi",
  833. .enable = s5pv210_clk_mask0_ctrl,
  834. .ctrlbit = (1 << 29),
  835. },
  836. .sources = &clkset_group2,
  837. .reg_src = { .reg = S5P_CLK_SRC6, .shift = 20, .size = 4 },
  838. .reg_div = { .reg = S5P_CLK_DIV6, .shift = 24, .size = 4 },
  839. }, {
  840. .clk = {
  841. .name = "sclk_pwm",
  842. .enable = s5pv210_clk_mask0_ctrl,
  843. .ctrlbit = (1 << 19),
  844. },
  845. .sources = &clkset_group2,
  846. .reg_src = { .reg = S5P_CLK_SRC5, .shift = 12, .size = 4 },
  847. .reg_div = { .reg = S5P_CLK_DIV5, .shift = 12, .size = 4 },
  848. },
  849. };
  850. static struct clksrc_clk clk_sclk_uart0 = {
  851. .clk = {
  852. .name = "uclk1",
  853. .devname = "s5pv210-uart.0",
  854. .enable = s5pv210_clk_mask0_ctrl,
  855. .ctrlbit = (1 << 12),
  856. },
  857. .sources = &clkset_uart,
  858. .reg_src = { .reg = S5P_CLK_SRC4, .shift = 16, .size = 4 },
  859. .reg_div = { .reg = S5P_CLK_DIV4, .shift = 16, .size = 4 },
  860. };
  861. static struct clksrc_clk clk_sclk_uart1 = {
  862. .clk = {
  863. .name = "uclk1",
  864. .devname = "s5pv210-uart.1",
  865. .enable = s5pv210_clk_mask0_ctrl,
  866. .ctrlbit = (1 << 13),
  867. },
  868. .sources = &clkset_uart,
  869. .reg_src = { .reg = S5P_CLK_SRC4, .shift = 20, .size = 4 },
  870. .reg_div = { .reg = S5P_CLK_DIV4, .shift = 20, .size = 4 },
  871. };
  872. static struct clksrc_clk clk_sclk_uart2 = {
  873. .clk = {
  874. .name = "uclk1",
  875. .devname = "s5pv210-uart.2",
  876. .enable = s5pv210_clk_mask0_ctrl,
  877. .ctrlbit = (1 << 14),
  878. },
  879. .sources = &clkset_uart,
  880. .reg_src = { .reg = S5P_CLK_SRC4, .shift = 24, .size = 4 },
  881. .reg_div = { .reg = S5P_CLK_DIV4, .shift = 24, .size = 4 },
  882. };
  883. static struct clksrc_clk clk_sclk_uart3 = {
  884. .clk = {
  885. .name = "uclk1",
  886. .devname = "s5pv210-uart.3",
  887. .enable = s5pv210_clk_mask0_ctrl,
  888. .ctrlbit = (1 << 15),
  889. },
  890. .sources = &clkset_uart,
  891. .reg_src = { .reg = S5P_CLK_SRC4, .shift = 28, .size = 4 },
  892. .reg_div = { .reg = S5P_CLK_DIV4, .shift = 28, .size = 4 },
  893. };
  894. static struct clksrc_clk clk_sclk_mmc0 = {
  895. .clk = {
  896. .name = "sclk_mmc",
  897. .devname = "s3c-sdhci.0",
  898. .enable = s5pv210_clk_mask0_ctrl,
  899. .ctrlbit = (1 << 8),
  900. },
  901. .sources = &clkset_group2,
  902. .reg_src = { .reg = S5P_CLK_SRC4, .shift = 0, .size = 4 },
  903. .reg_div = { .reg = S5P_CLK_DIV4, .shift = 0, .size = 4 },
  904. };
  905. static struct clksrc_clk clk_sclk_mmc1 = {
  906. .clk = {
  907. .name = "sclk_mmc",
  908. .devname = "s3c-sdhci.1",
  909. .enable = s5pv210_clk_mask0_ctrl,
  910. .ctrlbit = (1 << 9),
  911. },
  912. .sources = &clkset_group2,
  913. .reg_src = { .reg = S5P_CLK_SRC4, .shift = 4, .size = 4 },
  914. .reg_div = { .reg = S5P_CLK_DIV4, .shift = 4, .size = 4 },
  915. };
  916. static struct clksrc_clk clk_sclk_mmc2 = {
  917. .clk = {
  918. .name = "sclk_mmc",
  919. .devname = "s3c-sdhci.2",
  920. .enable = s5pv210_clk_mask0_ctrl,
  921. .ctrlbit = (1 << 10),
  922. },
  923. .sources = &clkset_group2,
  924. .reg_src = { .reg = S5P_CLK_SRC4, .shift = 8, .size = 4 },
  925. .reg_div = { .reg = S5P_CLK_DIV4, .shift = 8, .size = 4 },
  926. };
  927. static struct clksrc_clk clk_sclk_mmc3 = {
  928. .clk = {
  929. .name = "sclk_mmc",
  930. .devname = "s3c-sdhci.3",
  931. .enable = s5pv210_clk_mask0_ctrl,
  932. .ctrlbit = (1 << 11),
  933. },
  934. .sources = &clkset_group2,
  935. .reg_src = { .reg = S5P_CLK_SRC4, .shift = 12, .size = 4 },
  936. .reg_div = { .reg = S5P_CLK_DIV4, .shift = 12, .size = 4 },
  937. };
  938. static struct clksrc_clk clk_sclk_spi0 = {
  939. .clk = {
  940. .name = "sclk_spi",
  941. .devname = "s3c64xx-spi.0",
  942. .enable = s5pv210_clk_mask0_ctrl,
  943. .ctrlbit = (1 << 16),
  944. },
  945. .sources = &clkset_group2,
  946. .reg_src = { .reg = S5P_CLK_SRC5, .shift = 0, .size = 4 },
  947. .reg_div = { .reg = S5P_CLK_DIV5, .shift = 0, .size = 4 },
  948. };
  949. static struct clksrc_clk clk_sclk_spi1 = {
  950. .clk = {
  951. .name = "sclk_spi",
  952. .devname = "s3c64xx-spi.1",
  953. .enable = s5pv210_clk_mask0_ctrl,
  954. .ctrlbit = (1 << 17),
  955. },
  956. .sources = &clkset_group2,
  957. .reg_src = { .reg = S5P_CLK_SRC5, .shift = 4, .size = 4 },
  958. .reg_div = { .reg = S5P_CLK_DIV5, .shift = 4, .size = 4 },
  959. };
  960. static struct clksrc_clk *clksrc_cdev[] = {
  961. &clk_sclk_uart0,
  962. &clk_sclk_uart1,
  963. &clk_sclk_uart2,
  964. &clk_sclk_uart3,
  965. &clk_sclk_mmc0,
  966. &clk_sclk_mmc1,
  967. &clk_sclk_mmc2,
  968. &clk_sclk_mmc3,
  969. &clk_sclk_spi0,
  970. &clk_sclk_spi1,
  971. };
  972. static struct clk *clk_cdev[] = {
  973. &clk_hsmmc0,
  974. &clk_hsmmc1,
  975. &clk_hsmmc2,
  976. &clk_hsmmc3,
  977. };
  978. /* Clock initialisation code */
  979. static struct clksrc_clk *sysclks[] = {
  980. &clk_mout_apll,
  981. &clk_mout_epll,
  982. &clk_mout_mpll,
  983. &clk_armclk,
  984. &clk_hclk_msys,
  985. &clk_sclk_a2m,
  986. &clk_hclk_dsys,
  987. &clk_hclk_psys,
  988. &clk_pclk_msys,
  989. &clk_pclk_dsys,
  990. &clk_pclk_psys,
  991. &clk_vpllsrc,
  992. &clk_sclk_vpll,
  993. &clk_mout_dmc0,
  994. &clk_sclk_dmc0,
  995. &clk_sclk_audio0,
  996. &clk_sclk_audio1,
  997. &clk_sclk_audio2,
  998. &clk_sclk_spdif,
  999. };
  1000. static u32 epll_div[][6] = {
  1001. { 48000000, 0, 48, 3, 3, 0 },
  1002. { 96000000, 0, 48, 3, 2, 0 },
  1003. { 144000000, 1, 72, 3, 2, 0 },
  1004. { 192000000, 0, 48, 3, 1, 0 },
  1005. { 288000000, 1, 72, 3, 1, 0 },
  1006. { 32750000, 1, 65, 3, 4, 35127 },
  1007. { 32768000, 1, 65, 3, 4, 35127 },
  1008. { 45158400, 0, 45, 3, 3, 10355 },
  1009. { 45000000, 0, 45, 3, 3, 10355 },
  1010. { 45158000, 0, 45, 3, 3, 10355 },
  1011. { 49125000, 0, 49, 3, 3, 9961 },
  1012. { 49152000, 0, 49, 3, 3, 9961 },
  1013. { 67737600, 1, 67, 3, 3, 48366 },
  1014. { 67738000, 1, 67, 3, 3, 48366 },
  1015. { 73800000, 1, 73, 3, 3, 47710 },
  1016. { 73728000, 1, 73, 3, 3, 47710 },
  1017. { 36000000, 1, 32, 3, 4, 0 },
  1018. { 60000000, 1, 60, 3, 3, 0 },
  1019. { 72000000, 1, 72, 3, 3, 0 },
  1020. { 80000000, 1, 80, 3, 3, 0 },
  1021. { 84000000, 0, 42, 3, 2, 0 },
  1022. { 50000000, 0, 50, 3, 3, 0 },
  1023. };
  1024. static int s5pv210_epll_set_rate(struct clk *clk, unsigned long rate)
  1025. {
  1026. unsigned int epll_con, epll_con_k;
  1027. unsigned int i;
  1028. /* Return if nothing changed */
  1029. if (clk->rate == rate)
  1030. return 0;
  1031. epll_con = __raw_readl(S5P_EPLL_CON);
  1032. epll_con_k = __raw_readl(S5P_EPLL_CON1);
  1033. epll_con_k &= ~PLL46XX_KDIV_MASK;
  1034. epll_con &= ~(1 << 27 |
  1035. PLL46XX_MDIV_MASK << PLL46XX_MDIV_SHIFT |
  1036. PLL46XX_PDIV_MASK << PLL46XX_PDIV_SHIFT |
  1037. PLL46XX_SDIV_MASK << PLL46XX_SDIV_SHIFT);
  1038. for (i = 0; i < ARRAY_SIZE(epll_div); i++) {
  1039. if (epll_div[i][0] == rate) {
  1040. epll_con_k |= epll_div[i][5] << 0;
  1041. epll_con |= (epll_div[i][1] << 27 |
  1042. epll_div[i][2] << PLL46XX_MDIV_SHIFT |
  1043. epll_div[i][3] << PLL46XX_PDIV_SHIFT |
  1044. epll_div[i][4] << PLL46XX_SDIV_SHIFT);
  1045. break;
  1046. }
  1047. }
  1048. if (i == ARRAY_SIZE(epll_div)) {
  1049. printk(KERN_ERR "%s: Invalid Clock EPLL Frequency\n",
  1050. __func__);
  1051. return -EINVAL;
  1052. }
  1053. __raw_writel(epll_con, S5P_EPLL_CON);
  1054. __raw_writel(epll_con_k, S5P_EPLL_CON1);
  1055. printk(KERN_WARNING "EPLL Rate changes from %lu to %lu\n",
  1056. clk->rate, rate);
  1057. clk->rate = rate;
  1058. return 0;
  1059. }
  1060. static struct clk_ops s5pv210_epll_ops = {
  1061. .set_rate = s5pv210_epll_set_rate,
  1062. .get_rate = s5p_epll_get_rate,
  1063. };
  1064. static u32 vpll_div[][5] = {
  1065. { 54000000, 3, 53, 3, 0 },
  1066. { 108000000, 3, 53, 2, 0 },
  1067. };
  1068. static unsigned long s5pv210_vpll_get_rate(struct clk *clk)
  1069. {
  1070. return clk->rate;
  1071. }
  1072. static int s5pv210_vpll_set_rate(struct clk *clk, unsigned long rate)
  1073. {
  1074. unsigned int vpll_con;
  1075. unsigned int i;
  1076. /* Return if nothing changed */
  1077. if (clk->rate == rate)
  1078. return 0;
  1079. vpll_con = __raw_readl(S5P_VPLL_CON);
  1080. vpll_con &= ~(0x1 << 27 | \
  1081. PLL90XX_MDIV_MASK << PLL90XX_MDIV_SHIFT | \
  1082. PLL90XX_PDIV_MASK << PLL90XX_PDIV_SHIFT | \
  1083. PLL90XX_SDIV_MASK << PLL90XX_SDIV_SHIFT);
  1084. for (i = 0; i < ARRAY_SIZE(vpll_div); i++) {
  1085. if (vpll_div[i][0] == rate) {
  1086. vpll_con |= vpll_div[i][1] << PLL90XX_PDIV_SHIFT;
  1087. vpll_con |= vpll_div[i][2] << PLL90XX_MDIV_SHIFT;
  1088. vpll_con |= vpll_div[i][3] << PLL90XX_SDIV_SHIFT;
  1089. vpll_con |= vpll_div[i][4] << 27;
  1090. break;
  1091. }
  1092. }
  1093. if (i == ARRAY_SIZE(vpll_div)) {
  1094. printk(KERN_ERR "%s: Invalid Clock VPLL Frequency\n",
  1095. __func__);
  1096. return -EINVAL;
  1097. }
  1098. __raw_writel(vpll_con, S5P_VPLL_CON);
  1099. /* Wait for VPLL lock */
  1100. while (!(__raw_readl(S5P_VPLL_CON) & (1 << PLL90XX_LOCKED_SHIFT)))
  1101. continue;
  1102. clk->rate = rate;
  1103. return 0;
  1104. }
  1105. static struct clk_ops s5pv210_vpll_ops = {
  1106. .get_rate = s5pv210_vpll_get_rate,
  1107. .set_rate = s5pv210_vpll_set_rate,
  1108. };
  1109. void __init_or_cpufreq s5pv210_setup_clocks(void)
  1110. {
  1111. struct clk *xtal_clk;
  1112. unsigned long vpllsrc;
  1113. unsigned long armclk;
  1114. unsigned long hclk_msys;
  1115. unsigned long hclk_dsys;
  1116. unsigned long hclk_psys;
  1117. unsigned long pclk_msys;
  1118. unsigned long pclk_dsys;
  1119. unsigned long pclk_psys;
  1120. unsigned long apll;
  1121. unsigned long mpll;
  1122. unsigned long epll;
  1123. unsigned long vpll;
  1124. unsigned int ptr;
  1125. u32 clkdiv0, clkdiv1;
  1126. /* Set functions for clk_fout_epll */
  1127. clk_fout_epll.enable = s5p_epll_enable;
  1128. clk_fout_epll.ops = &s5pv210_epll_ops;
  1129. printk(KERN_DEBUG "%s: registering clocks\n", __func__);
  1130. clkdiv0 = __raw_readl(S5P_CLK_DIV0);
  1131. clkdiv1 = __raw_readl(S5P_CLK_DIV1);
  1132. printk(KERN_DEBUG "%s: clkdiv0 = %08x, clkdiv1 = %08x\n",
  1133. __func__, clkdiv0, clkdiv1);
  1134. xtal_clk = clk_get(NULL, "xtal");
  1135. BUG_ON(IS_ERR(xtal_clk));
  1136. xtal = clk_get_rate(xtal_clk);
  1137. clk_put(xtal_clk);
  1138. printk(KERN_DEBUG "%s: xtal is %ld\n", __func__, xtal);
  1139. apll = s5p_get_pll45xx(xtal, __raw_readl(S5P_APLL_CON), pll_4508);
  1140. mpll = s5p_get_pll45xx(xtal, __raw_readl(S5P_MPLL_CON), pll_4502);
  1141. epll = s5p_get_pll46xx(xtal, __raw_readl(S5P_EPLL_CON),
  1142. __raw_readl(S5P_EPLL_CON1), pll_4600);
  1143. vpllsrc = clk_get_rate(&clk_vpllsrc.clk);
  1144. vpll = s5p_get_pll45xx(vpllsrc, __raw_readl(S5P_VPLL_CON), pll_4502);
  1145. clk_fout_apll.ops = &clk_fout_apll_ops;
  1146. clk_fout_mpll.rate = mpll;
  1147. clk_fout_epll.rate = epll;
  1148. clk_fout_vpll.ops = &s5pv210_vpll_ops;
  1149. clk_fout_vpll.rate = vpll;
  1150. printk(KERN_INFO "S5PV210: PLL settings, A=%ld, M=%ld, E=%ld V=%ld",
  1151. apll, mpll, epll, vpll);
  1152. armclk = clk_get_rate(&clk_armclk.clk);
  1153. hclk_msys = clk_get_rate(&clk_hclk_msys.clk);
  1154. hclk_dsys = clk_get_rate(&clk_hclk_dsys.clk);
  1155. hclk_psys = clk_get_rate(&clk_hclk_psys.clk);
  1156. pclk_msys = clk_get_rate(&clk_pclk_msys.clk);
  1157. pclk_dsys = clk_get_rate(&clk_pclk_dsys.clk);
  1158. pclk_psys = clk_get_rate(&clk_pclk_psys.clk);
  1159. printk(KERN_INFO "S5PV210: ARMCLK=%ld, HCLKM=%ld, HCLKD=%ld\n"
  1160. "HCLKP=%ld, PCLKM=%ld, PCLKD=%ld, PCLKP=%ld\n",
  1161. armclk, hclk_msys, hclk_dsys, hclk_psys,
  1162. pclk_msys, pclk_dsys, pclk_psys);
  1163. clk_f.rate = armclk;
  1164. clk_h.rate = hclk_psys;
  1165. clk_p.rate = pclk_psys;
  1166. for (ptr = 0; ptr < ARRAY_SIZE(clksrcs); ptr++)
  1167. s3c_set_clksrc(&clksrcs[ptr], true);
  1168. }
  1169. static struct clk *clks[] __initdata = {
  1170. &clk_sclk_hdmi27m,
  1171. &clk_sclk_hdmiphy,
  1172. &clk_sclk_usbphy0,
  1173. &clk_sclk_usbphy1,
  1174. &clk_pcmcdclk0,
  1175. &clk_pcmcdclk1,
  1176. &clk_pcmcdclk2,
  1177. };
  1178. static struct clk_lookup s5pv210_clk_lookup[] = {
  1179. CLKDEV_INIT(NULL, "clk_uart_baud0", &clk_p),
  1180. CLKDEV_INIT("s5pv210-uart.0", "clk_uart_baud1", &clk_sclk_uart0.clk),
  1181. CLKDEV_INIT("s5pv210-uart.1", "clk_uart_baud1", &clk_sclk_uart1.clk),
  1182. CLKDEV_INIT("s5pv210-uart.2", "clk_uart_baud1", &clk_sclk_uart2.clk),
  1183. CLKDEV_INIT("s5pv210-uart.3", "clk_uart_baud1", &clk_sclk_uart3.clk),
  1184. CLKDEV_INIT("s3c-sdhci.0", "mmc_busclk.0", &clk_hsmmc0),
  1185. CLKDEV_INIT("s3c-sdhci.1", "mmc_busclk.0", &clk_hsmmc1),
  1186. CLKDEV_INIT("s3c-sdhci.2", "mmc_busclk.0", &clk_hsmmc2),
  1187. CLKDEV_INIT("s3c-sdhci.3", "mmc_busclk.0", &clk_hsmmc3),
  1188. CLKDEV_INIT("s3c-sdhci.0", "mmc_busclk.2", &clk_sclk_mmc0.clk),
  1189. CLKDEV_INIT("s3c-sdhci.1", "mmc_busclk.2", &clk_sclk_mmc1.clk),
  1190. CLKDEV_INIT("s3c-sdhci.2", "mmc_busclk.2", &clk_sclk_mmc2.clk),
  1191. CLKDEV_INIT("s3c-sdhci.3", "mmc_busclk.2", &clk_sclk_mmc3.clk),
  1192. CLKDEV_INIT(NULL, "spi_busclk0", &clk_p),
  1193. CLKDEV_INIT("s3c64xx-spi.0", "spi_busclk1", &clk_sclk_spi0.clk),
  1194. CLKDEV_INIT("s3c64xx-spi.1", "spi_busclk1", &clk_sclk_spi1.clk),
  1195. };
  1196. void __init s5pv210_register_clocks(void)
  1197. {
  1198. int ptr;
  1199. s3c24xx_register_clocks(clks, ARRAY_SIZE(clks));
  1200. for (ptr = 0; ptr < ARRAY_SIZE(sysclks); ptr++)
  1201. s3c_register_clksrc(sysclks[ptr], 1);
  1202. for (ptr = 0; ptr < ARRAY_SIZE(sclk_tv); ptr++)
  1203. s3c_register_clksrc(sclk_tv[ptr], 1);
  1204. for (ptr = 0; ptr < ARRAY_SIZE(clksrc_cdev); ptr++)
  1205. s3c_register_clksrc(clksrc_cdev[ptr], 1);
  1206. s3c_register_clksrc(clksrcs, ARRAY_SIZE(clksrcs));
  1207. s3c_register_clocks(init_clocks, ARRAY_SIZE(init_clocks));
  1208. s3c_register_clocks(init_clocks_off, ARRAY_SIZE(init_clocks_off));
  1209. s3c_disable_clocks(init_clocks_off, ARRAY_SIZE(init_clocks_off));
  1210. clkdev_add_table(s5pv210_clk_lookup, ARRAY_SIZE(s5pv210_clk_lookup));
  1211. s3c24xx_register_clocks(clk_cdev, ARRAY_SIZE(clk_cdev));
  1212. for (ptr = 0; ptr < ARRAY_SIZE(clk_cdev); ptr++)
  1213. s3c_disable_clocks(clk_cdev[ptr], 1);
  1214. s3c24xx_register_clock(&dummy_apb_pclk);
  1215. s3c_pwmclk_init();
  1216. }