clock_data.c 26 KB

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