clock_data.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831
  1. /*
  2. * linux/arch/arm/mach-omap1/clock_data.c
  3. *
  4. * Copyright (C) 2004 - 2005, 2009-2010 Nokia Corporation
  5. * Written by Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com>
  6. * Based on clocks.h by Tony Lindgren, Gordon McNutt and RidgeRun, Inc
  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/kernel.h>
  13. #include <linux/clk.h>
  14. #include <linux/io.h>
  15. #include <asm/mach-types.h> /* for machine_is_* */
  16. #include <plat/clock.h>
  17. #include <plat/cpu.h>
  18. #include <plat/clkdev_omap.h>
  19. #include <plat/usb.h> /* for OTG_BASE */
  20. #include "clock.h"
  21. /*------------------------------------------------------------------------
  22. * Omap1 clocks
  23. *-------------------------------------------------------------------------*/
  24. static struct clk ck_ref = {
  25. .name = "ck_ref",
  26. .ops = &clkops_null,
  27. .rate = 12000000,
  28. };
  29. static struct clk ck_dpll1 = {
  30. .name = "ck_dpll1",
  31. .ops = &clkops_null,
  32. .parent = &ck_ref,
  33. };
  34. /*
  35. * FIXME: This clock seems to be necessary but no-one has asked for its
  36. * activation. [ FIX: SoSSI, SSR ]
  37. */
  38. static struct arm_idlect1_clk ck_dpll1out = {
  39. .clk = {
  40. .name = "ck_dpll1out",
  41. .ops = &clkops_generic,
  42. .parent = &ck_dpll1,
  43. .flags = CLOCK_IDLE_CONTROL | ENABLE_REG_32BIT |
  44. ENABLE_ON_INIT,
  45. .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
  46. .enable_bit = EN_CKOUT_ARM,
  47. .recalc = &followparent_recalc,
  48. },
  49. .idlect_shift = 12,
  50. };
  51. static struct clk sossi_ck = {
  52. .name = "ck_sossi",
  53. .ops = &clkops_generic,
  54. .parent = &ck_dpll1out.clk,
  55. .flags = CLOCK_NO_IDLE_PARENT | ENABLE_REG_32BIT,
  56. .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_1),
  57. .enable_bit = 16,
  58. .recalc = &omap1_sossi_recalc,
  59. .set_rate = &omap1_set_sossi_rate,
  60. };
  61. static struct clk arm_ck = {
  62. .name = "arm_ck",
  63. .ops = &clkops_null,
  64. .parent = &ck_dpll1,
  65. .rate_offset = CKCTL_ARMDIV_OFFSET,
  66. .recalc = &omap1_ckctl_recalc,
  67. .round_rate = omap1_clk_round_rate_ckctl_arm,
  68. .set_rate = omap1_clk_set_rate_ckctl_arm,
  69. };
  70. static struct arm_idlect1_clk armper_ck = {
  71. .clk = {
  72. .name = "armper_ck",
  73. .ops = &clkops_generic,
  74. .parent = &ck_dpll1,
  75. .flags = CLOCK_IDLE_CONTROL,
  76. .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
  77. .enable_bit = EN_PERCK,
  78. .rate_offset = CKCTL_PERDIV_OFFSET,
  79. .recalc = &omap1_ckctl_recalc,
  80. .round_rate = omap1_clk_round_rate_ckctl_arm,
  81. .set_rate = omap1_clk_set_rate_ckctl_arm,
  82. },
  83. .idlect_shift = 2,
  84. };
  85. /*
  86. * FIXME: This clock seems to be necessary but no-one has asked for its
  87. * activation. [ GPIO code for 1510 ]
  88. */
  89. static struct clk arm_gpio_ck = {
  90. .name = "arm_gpio_ck",
  91. .ops = &clkops_generic,
  92. .parent = &ck_dpll1,
  93. .flags = ENABLE_ON_INIT,
  94. .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
  95. .enable_bit = EN_GPIOCK,
  96. .recalc = &followparent_recalc,
  97. };
  98. static struct arm_idlect1_clk armxor_ck = {
  99. .clk = {
  100. .name = "armxor_ck",
  101. .ops = &clkops_generic,
  102. .parent = &ck_ref,
  103. .flags = CLOCK_IDLE_CONTROL,
  104. .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
  105. .enable_bit = EN_XORPCK,
  106. .recalc = &followparent_recalc,
  107. },
  108. .idlect_shift = 1,
  109. };
  110. static struct arm_idlect1_clk armtim_ck = {
  111. .clk = {
  112. .name = "armtim_ck",
  113. .ops = &clkops_generic,
  114. .parent = &ck_ref,
  115. .flags = CLOCK_IDLE_CONTROL,
  116. .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
  117. .enable_bit = EN_TIMCK,
  118. .recalc = &followparent_recalc,
  119. },
  120. .idlect_shift = 9,
  121. };
  122. static struct arm_idlect1_clk armwdt_ck = {
  123. .clk = {
  124. .name = "armwdt_ck",
  125. .ops = &clkops_generic,
  126. .parent = &ck_ref,
  127. .flags = CLOCK_IDLE_CONTROL,
  128. .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
  129. .enable_bit = EN_WDTCK,
  130. .fixed_div = 14,
  131. .recalc = &omap_fixed_divisor_recalc,
  132. },
  133. .idlect_shift = 0,
  134. };
  135. static struct clk arminth_ck16xx = {
  136. .name = "arminth_ck",
  137. .ops = &clkops_null,
  138. .parent = &arm_ck,
  139. .recalc = &followparent_recalc,
  140. /* Note: On 16xx the frequency can be divided by 2 by programming
  141. * ARM_CKCTL:ARM_INTHCK_SEL(14) to 1
  142. *
  143. * 1510 version is in TC clocks.
  144. */
  145. };
  146. static struct clk dsp_ck = {
  147. .name = "dsp_ck",
  148. .ops = &clkops_generic,
  149. .parent = &ck_dpll1,
  150. .enable_reg = OMAP1_IO_ADDRESS(ARM_CKCTL),
  151. .enable_bit = EN_DSPCK,
  152. .rate_offset = CKCTL_DSPDIV_OFFSET,
  153. .recalc = &omap1_ckctl_recalc,
  154. .round_rate = omap1_clk_round_rate_ckctl_arm,
  155. .set_rate = omap1_clk_set_rate_ckctl_arm,
  156. };
  157. static struct clk dspmmu_ck = {
  158. .name = "dspmmu_ck",
  159. .ops = &clkops_null,
  160. .parent = &ck_dpll1,
  161. .rate_offset = CKCTL_DSPMMUDIV_OFFSET,
  162. .recalc = &omap1_ckctl_recalc,
  163. .round_rate = omap1_clk_round_rate_ckctl_arm,
  164. .set_rate = omap1_clk_set_rate_ckctl_arm,
  165. };
  166. static struct clk dspper_ck = {
  167. .name = "dspper_ck",
  168. .ops = &clkops_dspck,
  169. .parent = &ck_dpll1,
  170. .enable_reg = DSP_IDLECT2,
  171. .enable_bit = EN_PERCK,
  172. .rate_offset = CKCTL_PERDIV_OFFSET,
  173. .recalc = &omap1_ckctl_recalc_dsp_domain,
  174. .round_rate = omap1_clk_round_rate_ckctl_arm,
  175. .set_rate = &omap1_clk_set_rate_dsp_domain,
  176. };
  177. static struct clk dspxor_ck = {
  178. .name = "dspxor_ck",
  179. .ops = &clkops_dspck,
  180. .parent = &ck_ref,
  181. .enable_reg = DSP_IDLECT2,
  182. .enable_bit = EN_XORPCK,
  183. .recalc = &followparent_recalc,
  184. };
  185. static struct clk dsptim_ck = {
  186. .name = "dsptim_ck",
  187. .ops = &clkops_dspck,
  188. .parent = &ck_ref,
  189. .enable_reg = DSP_IDLECT2,
  190. .enable_bit = EN_DSPTIMCK,
  191. .recalc = &followparent_recalc,
  192. };
  193. /* Tie ARM_IDLECT1:IDLIF_ARM to this logical clock structure */
  194. static struct arm_idlect1_clk tc_ck = {
  195. .clk = {
  196. .name = "tc_ck",
  197. .ops = &clkops_null,
  198. .parent = &ck_dpll1,
  199. .flags = CLOCK_IDLE_CONTROL,
  200. .rate_offset = CKCTL_TCDIV_OFFSET,
  201. .recalc = &omap1_ckctl_recalc,
  202. .round_rate = omap1_clk_round_rate_ckctl_arm,
  203. .set_rate = omap1_clk_set_rate_ckctl_arm,
  204. },
  205. .idlect_shift = 6,
  206. };
  207. static struct clk arminth_ck1510 = {
  208. .name = "arminth_ck",
  209. .ops = &clkops_null,
  210. .parent = &tc_ck.clk,
  211. .recalc = &followparent_recalc,
  212. /* Note: On 1510 the frequency follows TC_CK
  213. *
  214. * 16xx version is in MPU clocks.
  215. */
  216. };
  217. static struct clk tipb_ck = {
  218. /* No-idle controlled by "tc_ck" */
  219. .name = "tipb_ck",
  220. .ops = &clkops_null,
  221. .parent = &tc_ck.clk,
  222. .recalc = &followparent_recalc,
  223. };
  224. static struct clk l3_ocpi_ck = {
  225. /* No-idle controlled by "tc_ck" */
  226. .name = "l3_ocpi_ck",
  227. .ops = &clkops_generic,
  228. .parent = &tc_ck.clk,
  229. .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT3),
  230. .enable_bit = EN_OCPI_CK,
  231. .recalc = &followparent_recalc,
  232. };
  233. static struct clk tc1_ck = {
  234. .name = "tc1_ck",
  235. .ops = &clkops_generic,
  236. .parent = &tc_ck.clk,
  237. .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT3),
  238. .enable_bit = EN_TC1_CK,
  239. .recalc = &followparent_recalc,
  240. };
  241. /*
  242. * FIXME: This clock seems to be necessary but no-one has asked for its
  243. * activation. [ pm.c (SRAM), CCP, Camera ]
  244. */
  245. static struct clk tc2_ck = {
  246. .name = "tc2_ck",
  247. .ops = &clkops_generic,
  248. .parent = &tc_ck.clk,
  249. .flags = ENABLE_ON_INIT,
  250. .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT3),
  251. .enable_bit = EN_TC2_CK,
  252. .recalc = &followparent_recalc,
  253. };
  254. static struct clk dma_ck = {
  255. /* No-idle controlled by "tc_ck" */
  256. .name = "dma_ck",
  257. .ops = &clkops_null,
  258. .parent = &tc_ck.clk,
  259. .recalc = &followparent_recalc,
  260. };
  261. static struct clk dma_lcdfree_ck = {
  262. .name = "dma_lcdfree_ck",
  263. .ops = &clkops_null,
  264. .parent = &tc_ck.clk,
  265. .recalc = &followparent_recalc,
  266. };
  267. static struct arm_idlect1_clk api_ck = {
  268. .clk = {
  269. .name = "api_ck",
  270. .ops = &clkops_generic,
  271. .parent = &tc_ck.clk,
  272. .flags = CLOCK_IDLE_CONTROL,
  273. .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
  274. .enable_bit = EN_APICK,
  275. .recalc = &followparent_recalc,
  276. },
  277. .idlect_shift = 8,
  278. };
  279. static struct arm_idlect1_clk lb_ck = {
  280. .clk = {
  281. .name = "lb_ck",
  282. .ops = &clkops_generic,
  283. .parent = &tc_ck.clk,
  284. .flags = CLOCK_IDLE_CONTROL,
  285. .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
  286. .enable_bit = EN_LBCK,
  287. .recalc = &followparent_recalc,
  288. },
  289. .idlect_shift = 4,
  290. };
  291. static struct clk rhea1_ck = {
  292. .name = "rhea1_ck",
  293. .ops = &clkops_null,
  294. .parent = &tc_ck.clk,
  295. .recalc = &followparent_recalc,
  296. };
  297. static struct clk rhea2_ck = {
  298. .name = "rhea2_ck",
  299. .ops = &clkops_null,
  300. .parent = &tc_ck.clk,
  301. .recalc = &followparent_recalc,
  302. };
  303. static struct clk lcd_ck_16xx = {
  304. .name = "lcd_ck",
  305. .ops = &clkops_generic,
  306. .parent = &ck_dpll1,
  307. .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
  308. .enable_bit = EN_LCDCK,
  309. .rate_offset = CKCTL_LCDDIV_OFFSET,
  310. .recalc = &omap1_ckctl_recalc,
  311. .round_rate = omap1_clk_round_rate_ckctl_arm,
  312. .set_rate = omap1_clk_set_rate_ckctl_arm,
  313. };
  314. static struct arm_idlect1_clk lcd_ck_1510 = {
  315. .clk = {
  316. .name = "lcd_ck",
  317. .ops = &clkops_generic,
  318. .parent = &ck_dpll1,
  319. .flags = CLOCK_IDLE_CONTROL,
  320. .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
  321. .enable_bit = EN_LCDCK,
  322. .rate_offset = CKCTL_LCDDIV_OFFSET,
  323. .recalc = &omap1_ckctl_recalc,
  324. .round_rate = omap1_clk_round_rate_ckctl_arm,
  325. .set_rate = omap1_clk_set_rate_ckctl_arm,
  326. },
  327. .idlect_shift = 3,
  328. };
  329. static struct clk uart1_1510 = {
  330. .name = "uart1_ck",
  331. .ops = &clkops_null,
  332. /* Direct from ULPD, no real parent */
  333. .parent = &armper_ck.clk,
  334. .rate = 12000000,
  335. .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
  336. .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
  337. .enable_bit = 29, /* Chooses between 12MHz and 48MHz */
  338. .set_rate = &omap1_set_uart_rate,
  339. .recalc = &omap1_uart_recalc,
  340. };
  341. static struct uart_clk uart1_16xx = {
  342. .clk = {
  343. .name = "uart1_ck",
  344. .ops = &clkops_uart,
  345. /* Direct from ULPD, no real parent */
  346. .parent = &armper_ck.clk,
  347. .rate = 48000000,
  348. .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
  349. .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
  350. .enable_bit = 29,
  351. },
  352. .sysc_addr = 0xfffb0054,
  353. };
  354. static struct clk uart2_ck = {
  355. .name = "uart2_ck",
  356. .ops = &clkops_null,
  357. /* Direct from ULPD, no real parent */
  358. .parent = &armper_ck.clk,
  359. .rate = 12000000,
  360. .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
  361. .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
  362. .enable_bit = 30, /* Chooses between 12MHz and 48MHz */
  363. .set_rate = &omap1_set_uart_rate,
  364. .recalc = &omap1_uart_recalc,
  365. };
  366. static struct clk uart3_1510 = {
  367. .name = "uart3_ck",
  368. .ops = &clkops_null,
  369. /* Direct from ULPD, no real parent */
  370. .parent = &armper_ck.clk,
  371. .rate = 12000000,
  372. .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
  373. .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
  374. .enable_bit = 31, /* Chooses between 12MHz and 48MHz */
  375. .set_rate = &omap1_set_uart_rate,
  376. .recalc = &omap1_uart_recalc,
  377. };
  378. static struct uart_clk uart3_16xx = {
  379. .clk = {
  380. .name = "uart3_ck",
  381. .ops = &clkops_uart,
  382. /* Direct from ULPD, no real parent */
  383. .parent = &armper_ck.clk,
  384. .rate = 48000000,
  385. .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
  386. .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
  387. .enable_bit = 31,
  388. },
  389. .sysc_addr = 0xfffb9854,
  390. };
  391. static struct clk usb_clko = { /* 6 MHz output on W4_USB_CLKO */
  392. .name = "usb_clko",
  393. .ops = &clkops_generic,
  394. /* Direct from ULPD, no parent */
  395. .rate = 6000000,
  396. .flags = ENABLE_REG_32BIT,
  397. .enable_reg = OMAP1_IO_ADDRESS(ULPD_CLOCK_CTRL),
  398. .enable_bit = USB_MCLK_EN_BIT,
  399. };
  400. static struct clk usb_hhc_ck1510 = {
  401. .name = "usb_hhc_ck",
  402. .ops = &clkops_generic,
  403. /* Direct from ULPD, no parent */
  404. .rate = 48000000, /* Actually 2 clocks, 12MHz and 48MHz */
  405. .flags = ENABLE_REG_32BIT,
  406. .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
  407. .enable_bit = USB_HOST_HHC_UHOST_EN,
  408. };
  409. static struct clk usb_hhc_ck16xx = {
  410. .name = "usb_hhc_ck",
  411. .ops = &clkops_generic,
  412. /* Direct from ULPD, no parent */
  413. .rate = 48000000,
  414. /* OTG_SYSCON_2.OTG_PADEN == 0 (not 1510-compatible) */
  415. .flags = ENABLE_REG_32BIT,
  416. .enable_reg = OMAP1_IO_ADDRESS(OTG_BASE + 0x08), /* OTG_SYSCON_2 */
  417. .enable_bit = 8 /* UHOST_EN */,
  418. };
  419. static struct clk usb_dc_ck = {
  420. .name = "usb_dc_ck",
  421. .ops = &clkops_generic,
  422. /* Direct from ULPD, no parent */
  423. .rate = 48000000,
  424. .enable_reg = OMAP1_IO_ADDRESS(SOFT_REQ_REG),
  425. .enable_bit = 4,
  426. };
  427. static struct clk usb_dc_ck7xx = {
  428. .name = "usb_dc_ck",
  429. .ops = &clkops_generic,
  430. /* Direct from ULPD, no parent */
  431. .rate = 48000000,
  432. .enable_reg = OMAP1_IO_ADDRESS(SOFT_REQ_REG),
  433. .enable_bit = 8,
  434. };
  435. static struct clk mclk_1510 = {
  436. .name = "mclk",
  437. .ops = &clkops_generic,
  438. /* Direct from ULPD, no parent. May be enabled by ext hardware. */
  439. .rate = 12000000,
  440. .enable_reg = OMAP1_IO_ADDRESS(SOFT_REQ_REG),
  441. .enable_bit = 6,
  442. };
  443. static struct clk mclk_16xx = {
  444. .name = "mclk",
  445. .ops = &clkops_generic,
  446. /* Direct from ULPD, no parent. May be enabled by ext hardware. */
  447. .enable_reg = OMAP1_IO_ADDRESS(COM_CLK_DIV_CTRL_SEL),
  448. .enable_bit = COM_ULPD_PLL_CLK_REQ,
  449. .set_rate = &omap1_set_ext_clk_rate,
  450. .round_rate = &omap1_round_ext_clk_rate,
  451. .init = &omap1_init_ext_clk,
  452. };
  453. static struct clk bclk_1510 = {
  454. .name = "bclk",
  455. .ops = &clkops_generic,
  456. /* Direct from ULPD, no parent. May be enabled by ext hardware. */
  457. .rate = 12000000,
  458. };
  459. static struct clk bclk_16xx = {
  460. .name = "bclk",
  461. .ops = &clkops_generic,
  462. /* Direct from ULPD, no parent. May be enabled by ext hardware. */
  463. .enable_reg = OMAP1_IO_ADDRESS(SWD_CLK_DIV_CTRL_SEL),
  464. .enable_bit = SWD_ULPD_PLL_CLK_REQ,
  465. .set_rate = &omap1_set_ext_clk_rate,
  466. .round_rate = &omap1_round_ext_clk_rate,
  467. .init = &omap1_init_ext_clk,
  468. };
  469. static struct clk mmc1_ck = {
  470. .name = "mmc1_ck",
  471. .ops = &clkops_generic,
  472. /* Functional clock is direct from ULPD, interface clock is ARMPER */
  473. .parent = &armper_ck.clk,
  474. .rate = 48000000,
  475. .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
  476. .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
  477. .enable_bit = 23,
  478. };
  479. static struct clk mmc2_ck = {
  480. .name = "mmc2_ck",
  481. .ops = &clkops_generic,
  482. /* Functional clock is direct from ULPD, interface clock is ARMPER */
  483. .parent = &armper_ck.clk,
  484. .rate = 48000000,
  485. .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
  486. .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
  487. .enable_bit = 20,
  488. };
  489. static struct clk mmc3_ck = {
  490. .name = "mmc3_ck",
  491. .ops = &clkops_generic,
  492. /* Functional clock is direct from ULPD, interface clock is ARMPER */
  493. .parent = &armper_ck.clk,
  494. .rate = 48000000,
  495. .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
  496. .enable_reg = OMAP1_IO_ADDRESS(SOFT_REQ_REG),
  497. .enable_bit = 12,
  498. };
  499. static struct clk virtual_ck_mpu = {
  500. .name = "mpu",
  501. .ops = &clkops_null,
  502. .parent = &arm_ck, /* Is smarter alias for */
  503. .recalc = &followparent_recalc,
  504. .set_rate = &omap1_select_table_rate,
  505. .round_rate = &omap1_round_to_table_rate,
  506. };
  507. /* virtual functional clock domain for I2C. Just for making sure that ARMXOR_CK
  508. remains active during MPU idle whenever this is enabled */
  509. static struct clk i2c_fck = {
  510. .name = "i2c_fck",
  511. .ops = &clkops_null,
  512. .flags = CLOCK_NO_IDLE_PARENT,
  513. .parent = &armxor_ck.clk,
  514. .recalc = &followparent_recalc,
  515. };
  516. static struct clk i2c_ick = {
  517. .name = "i2c_ick",
  518. .ops = &clkops_null,
  519. .flags = CLOCK_NO_IDLE_PARENT,
  520. .parent = &armper_ck.clk,
  521. .recalc = &followparent_recalc,
  522. };
  523. /*
  524. * clkdev integration
  525. */
  526. static struct omap_clk omap_clks[] = {
  527. /* non-ULPD clocks */
  528. CLK(NULL, "ck_ref", &ck_ref, CK_16XX | CK_1510 | CK_310 | CK_7XX),
  529. CLK(NULL, "ck_dpll1", &ck_dpll1, CK_16XX | CK_1510 | CK_310 | CK_7XX),
  530. /* CK_GEN1 clocks */
  531. CLK(NULL, "ck_dpll1out", &ck_dpll1out.clk, CK_16XX),
  532. CLK(NULL, "ck_sossi", &sossi_ck, CK_16XX),
  533. CLK(NULL, "arm_ck", &arm_ck, CK_16XX | CK_1510 | CK_310),
  534. CLK(NULL, "armper_ck", &armper_ck.clk, CK_16XX | CK_1510 | CK_310),
  535. CLK(NULL, "arm_gpio_ck", &arm_gpio_ck, CK_1510 | CK_310),
  536. CLK(NULL, "armxor_ck", &armxor_ck.clk, CK_16XX | CK_1510 | CK_310 | CK_7XX),
  537. CLK(NULL, "armtim_ck", &armtim_ck.clk, CK_16XX | CK_1510 | CK_310),
  538. CLK("omap_wdt", "fck", &armwdt_ck.clk, CK_16XX | CK_1510 | CK_310),
  539. CLK("omap_wdt", "ick", &armper_ck.clk, CK_16XX),
  540. CLK("omap_wdt", "ick", &dummy_ck, CK_1510 | CK_310),
  541. CLK(NULL, "arminth_ck", &arminth_ck1510, CK_1510 | CK_310),
  542. CLK(NULL, "arminth_ck", &arminth_ck16xx, CK_16XX),
  543. /* CK_GEN2 clocks */
  544. CLK(NULL, "dsp_ck", &dsp_ck, CK_16XX | CK_1510 | CK_310),
  545. CLK(NULL, "dspmmu_ck", &dspmmu_ck, CK_16XX | CK_1510 | CK_310),
  546. CLK(NULL, "dspper_ck", &dspper_ck, CK_16XX | CK_1510 | CK_310),
  547. CLK(NULL, "dspxor_ck", &dspxor_ck, CK_16XX | CK_1510 | CK_310),
  548. CLK(NULL, "dsptim_ck", &dsptim_ck, CK_16XX | CK_1510 | CK_310),
  549. /* CK_GEN3 clocks */
  550. CLK(NULL, "tc_ck", &tc_ck.clk, CK_16XX | CK_1510 | CK_310 | CK_7XX),
  551. CLK(NULL, "tipb_ck", &tipb_ck, CK_1510 | CK_310),
  552. CLK(NULL, "l3_ocpi_ck", &l3_ocpi_ck, CK_16XX | CK_7XX),
  553. CLK(NULL, "tc1_ck", &tc1_ck, CK_16XX),
  554. CLK(NULL, "tc2_ck", &tc2_ck, CK_16XX),
  555. CLK(NULL, "dma_ck", &dma_ck, CK_16XX | CK_1510 | CK_310),
  556. CLK(NULL, "dma_lcdfree_ck", &dma_lcdfree_ck, CK_16XX),
  557. CLK(NULL, "api_ck", &api_ck.clk, CK_16XX | CK_1510 | CK_310 | CK_7XX),
  558. CLK(NULL, "lb_ck", &lb_ck.clk, CK_1510 | CK_310),
  559. CLK(NULL, "rhea1_ck", &rhea1_ck, CK_16XX),
  560. CLK(NULL, "rhea2_ck", &rhea2_ck, CK_16XX),
  561. CLK(NULL, "lcd_ck", &lcd_ck_16xx, CK_16XX | CK_7XX),
  562. CLK(NULL, "lcd_ck", &lcd_ck_1510.clk, CK_1510 | CK_310),
  563. /* ULPD clocks */
  564. CLK(NULL, "uart1_ck", &uart1_1510, CK_1510 | CK_310),
  565. CLK(NULL, "uart1_ck", &uart1_16xx.clk, CK_16XX),
  566. CLK(NULL, "uart2_ck", &uart2_ck, CK_16XX | CK_1510 | CK_310),
  567. CLK(NULL, "uart3_ck", &uart3_1510, CK_1510 | CK_310),
  568. CLK(NULL, "uart3_ck", &uart3_16xx.clk, CK_16XX),
  569. CLK(NULL, "usb_clko", &usb_clko, CK_16XX | CK_1510 | CK_310),
  570. CLK(NULL, "usb_hhc_ck", &usb_hhc_ck1510, CK_1510 | CK_310),
  571. CLK(NULL, "usb_hhc_ck", &usb_hhc_ck16xx, CK_16XX),
  572. CLK(NULL, "usb_dc_ck", &usb_dc_ck, CK_16XX),
  573. CLK(NULL, "usb_dc_ck", &usb_dc_ck7xx, CK_7XX),
  574. CLK(NULL, "mclk", &mclk_1510, CK_1510 | CK_310),
  575. CLK(NULL, "mclk", &mclk_16xx, CK_16XX),
  576. CLK(NULL, "bclk", &bclk_1510, CK_1510 | CK_310),
  577. CLK(NULL, "bclk", &bclk_16xx, CK_16XX),
  578. CLK("mmci-omap.0", "fck", &mmc1_ck, CK_16XX | CK_1510 | CK_310),
  579. CLK("mmci-omap.0", "fck", &mmc3_ck, CK_7XX),
  580. CLK("mmci-omap.0", "ick", &armper_ck.clk, CK_16XX | CK_1510 | CK_310 | CK_7XX),
  581. CLK("mmci-omap.1", "fck", &mmc2_ck, CK_16XX),
  582. CLK("mmci-omap.1", "ick", &armper_ck.clk, CK_16XX),
  583. /* Virtual clocks */
  584. CLK(NULL, "mpu", &virtual_ck_mpu, CK_16XX | CK_1510 | CK_310),
  585. CLK("i2c_omap.1", "fck", &i2c_fck, CK_16XX | CK_1510 | CK_310 | CK_7XX),
  586. CLK("i2c_omap.1", "ick", &i2c_ick, CK_16XX),
  587. CLK("i2c_omap.1", "ick", &dummy_ck, CK_1510 | CK_310 | CK_7XX),
  588. CLK("omap1_spi100k.1", "fck", &dummy_ck, CK_7XX),
  589. CLK("omap1_spi100k.1", "ick", &dummy_ck, CK_7XX),
  590. CLK("omap1_spi100k.2", "fck", &dummy_ck, CK_7XX),
  591. CLK("omap1_spi100k.2", "ick", &dummy_ck, CK_7XX),
  592. CLK("omap_uwire", "fck", &armxor_ck.clk, CK_16XX | CK_1510 | CK_310),
  593. CLK("omap-mcbsp.1", "ick", &dspper_ck, CK_16XX),
  594. CLK("omap-mcbsp.1", "ick", &dummy_ck, CK_1510 | CK_310),
  595. CLK("omap-mcbsp.2", "ick", &armper_ck.clk, CK_16XX),
  596. CLK("omap-mcbsp.2", "ick", &dummy_ck, CK_1510 | CK_310),
  597. CLK("omap-mcbsp.3", "ick", &dspper_ck, CK_16XX),
  598. CLK("omap-mcbsp.3", "ick", &dummy_ck, CK_1510 | CK_310),
  599. CLK("omap-mcbsp.1", "fck", &dspxor_ck, CK_16XX | CK_1510 | CK_310),
  600. CLK("omap-mcbsp.2", "fck", &armper_ck.clk, CK_16XX | CK_1510 | CK_310),
  601. CLK("omap-mcbsp.3", "fck", &dspxor_ck, CK_16XX | CK_1510 | CK_310),
  602. };
  603. /*
  604. * init
  605. */
  606. static struct clk_functions omap1_clk_functions = {
  607. .clk_enable = omap1_clk_enable,
  608. .clk_disable = omap1_clk_disable,
  609. .clk_round_rate = omap1_clk_round_rate,
  610. .clk_set_rate = omap1_clk_set_rate,
  611. .clk_disable_unused = omap1_clk_disable_unused,
  612. };
  613. int __init omap1_clk_init(void)
  614. {
  615. struct omap_clk *c;
  616. const struct omap_clock_config *info;
  617. int crystal_type = 0; /* Default 12 MHz */
  618. u32 reg, cpu_mask;
  619. #ifdef CONFIG_DEBUG_LL
  620. /*
  621. * Resets some clocks that may be left on from bootloader,
  622. * but leaves serial clocks on.
  623. */
  624. omap_writel(0x3 << 29, MOD_CONF_CTRL_0);
  625. #endif
  626. /* USB_REQ_EN will be disabled later if necessary (usb_dc_ck) */
  627. reg = omap_readw(SOFT_REQ_REG) & (1 << 4);
  628. omap_writew(reg, SOFT_REQ_REG);
  629. if (!cpu_is_omap15xx())
  630. omap_writew(0, SOFT_REQ_REG2);
  631. clk_init(&omap1_clk_functions);
  632. /* By default all idlect1 clocks are allowed to idle */
  633. arm_idlect1_mask = ~0;
  634. for (c = omap_clks; c < omap_clks + ARRAY_SIZE(omap_clks); c++)
  635. clk_preinit(c->lk.clk);
  636. cpu_mask = 0;
  637. if (cpu_is_omap16xx())
  638. cpu_mask |= CK_16XX;
  639. if (cpu_is_omap1510())
  640. cpu_mask |= CK_1510;
  641. if (cpu_is_omap7xx())
  642. cpu_mask |= CK_7XX;
  643. if (cpu_is_omap310())
  644. cpu_mask |= CK_310;
  645. for (c = omap_clks; c < omap_clks + ARRAY_SIZE(omap_clks); c++)
  646. if (c->cpu & cpu_mask) {
  647. clkdev_add(&c->lk);
  648. clk_register(c->lk.clk);
  649. }
  650. /* Pointers to these clocks are needed by code in clock.c */
  651. api_ck_p = clk_get(NULL, "api_ck");
  652. ck_dpll1_p = clk_get(NULL, "ck_dpll1");
  653. ck_ref_p = clk_get(NULL, "ck_ref");
  654. info = omap_get_config(OMAP_TAG_CLOCK, struct omap_clock_config);
  655. if (info != NULL) {
  656. if (!cpu_is_omap15xx())
  657. crystal_type = info->system_clock_type;
  658. }
  659. #if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850)
  660. ck_ref.rate = 13000000;
  661. #elif defined(CONFIG_ARCH_OMAP16XX)
  662. if (crystal_type == 2)
  663. ck_ref.rate = 19200000;
  664. #endif
  665. pr_info("Clocks: ARM_SYSST: 0x%04x DPLL_CTL: 0x%04x ARM_CKCTL: "
  666. "0x%04x\n", omap_readw(ARM_SYSST), omap_readw(DPLL_CTL),
  667. omap_readw(ARM_CKCTL));
  668. /* We want to be in syncronous scalable mode */
  669. omap_writew(0x1000, ARM_SYSST);
  670. #ifdef CONFIG_OMAP_CLOCKS_SET_BY_BOOTLOADER
  671. /* Use values set by bootloader. Determine PLL rate and recalculate
  672. * dependent clocks as if kernel had changed PLL or divisors.
  673. */
  674. {
  675. unsigned pll_ctl_val = omap_readw(DPLL_CTL);
  676. ck_dpll1.rate = ck_ref.rate; /* Base xtal rate */
  677. if (pll_ctl_val & 0x10) {
  678. /* PLL enabled, apply multiplier and divisor */
  679. if (pll_ctl_val & 0xf80)
  680. ck_dpll1.rate *= (pll_ctl_val & 0xf80) >> 7;
  681. ck_dpll1.rate /= ((pll_ctl_val & 0x60) >> 5) + 1;
  682. } else {
  683. /* PLL disabled, apply bypass divisor */
  684. switch (pll_ctl_val & 0xc) {
  685. case 0:
  686. break;
  687. case 0x4:
  688. ck_dpll1.rate /= 2;
  689. break;
  690. default:
  691. ck_dpll1.rate /= 4;
  692. break;
  693. }
  694. }
  695. }
  696. #else
  697. /* Find the highest supported frequency and enable it */
  698. if (omap1_select_table_rate(&virtual_ck_mpu, ~0)) {
  699. printk(KERN_ERR "System frequencies not set. Check your config.\n");
  700. /* Guess sane values (60MHz) */
  701. omap_writew(0x2290, DPLL_CTL);
  702. omap_writew(cpu_is_omap7xx() ? 0x3005 : 0x1005, ARM_CKCTL);
  703. ck_dpll1.rate = 60000000;
  704. }
  705. #endif
  706. propagate_rate(&ck_dpll1);
  707. /* Cache rates for clocks connected to ck_ref (not dpll1) */
  708. propagate_rate(&ck_ref);
  709. printk(KERN_INFO "Clocking rate (xtal/DPLL1/MPU): "
  710. "%ld.%01ld/%ld.%01ld/%ld.%01ld MHz\n",
  711. ck_ref.rate / 1000000, (ck_ref.rate / 100000) % 10,
  712. ck_dpll1.rate / 1000000, (ck_dpll1.rate / 100000) % 10,
  713. arm_ck.rate / 1000000, (arm_ck.rate / 100000) % 10);
  714. #if defined(CONFIG_MACH_OMAP_PERSEUS2) || defined(CONFIG_MACH_OMAP_FSAMPLE)
  715. /* Select slicer output as OMAP input clock */
  716. omap_writew(omap_readw(OMAP7XX_PCC_UPLD_CTRL) & ~0x1, OMAP7XX_PCC_UPLD_CTRL);
  717. #endif
  718. /* Amstrad Delta wants BCLK high when inactive */
  719. if (machine_is_ams_delta())
  720. omap_writel(omap_readl(ULPD_CLOCK_CTRL) |
  721. (1 << SDW_MCLK_INV_BIT),
  722. ULPD_CLOCK_CTRL);
  723. /* Turn off DSP and ARM_TIMXO. Make sure ARM_INTHCK is not divided */
  724. /* (on 730, bit 13 must not be cleared) */
  725. if (cpu_is_omap7xx())
  726. omap_writew(omap_readw(ARM_CKCTL) & 0x2fff, ARM_CKCTL);
  727. else
  728. omap_writew(omap_readw(ARM_CKCTL) & 0x0fff, ARM_CKCTL);
  729. /* Put DSP/MPUI into reset until needed */
  730. omap_writew(0, ARM_RSTCT1);
  731. omap_writew(1, ARM_RSTCT2);
  732. omap_writew(0x400, ARM_IDLECT1);
  733. /*
  734. * According to OMAP5910 Erratum SYS_DMA_1, bit DMACK_REQ (bit 8)
  735. * of the ARM_IDLECT2 register must be set to zero. The power-on
  736. * default value of this bit is one.
  737. */
  738. omap_writew(0x0000, ARM_IDLECT2); /* Turn LCD clock off also */
  739. /*
  740. * Only enable those clocks we will need, let the drivers
  741. * enable other clocks as necessary
  742. */
  743. clk_enable(&armper_ck.clk);
  744. clk_enable(&armxor_ck.clk);
  745. clk_enable(&armtim_ck.clk); /* This should be done by timer code */
  746. if (cpu_is_omap15xx())
  747. clk_enable(&arm_gpio_ck);
  748. return 0;
  749. }