clock_data.c 27 KB

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