clk-imx51-imx53.c 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. /*
  2. * Copyright (C) 2011 Sascha Hauer, Pengutronix <s.hauer@pengutronix.de>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. *
  8. */
  9. #include <linux/mm.h>
  10. #include <linux/delay.h>
  11. #include <linux/clk.h>
  12. #include <linux/io.h>
  13. #include <linux/clkdev.h>
  14. #include <linux/of.h>
  15. #include <linux/err.h>
  16. #include "crm-regs-imx5.h"
  17. #include "clk.h"
  18. #include "common.h"
  19. #include "hardware.h"
  20. /* Low-power Audio Playback Mode clock */
  21. static const char *lp_apm_sel[] = { "osc", };
  22. /* This is used multiple times */
  23. static const char *standard_pll_sel[] = { "pll1_sw", "pll2_sw", "pll3_sw", "lp_apm", };
  24. static const char *periph_apm_sel[] = { "pll1_sw", "pll3_sw", "lp_apm", };
  25. static const char *main_bus_sel[] = { "pll2_sw", "periph_apm", };
  26. static const char *per_lp_apm_sel[] = { "main_bus", "lp_apm", };
  27. static const char *per_root_sel[] = { "per_podf", "ipg", };
  28. static const char *esdhc_c_sel[] = { "esdhc_a_podf", "esdhc_b_podf", };
  29. static const char *esdhc_d_sel[] = { "esdhc_a_podf", "esdhc_b_podf", };
  30. static const char *ssi_apm_sels[] = { "ckih1", "lp_amp", "ckih2", };
  31. static const char *ssi_clk_sels[] = { "pll1_sw", "pll2_sw", "pll3_sw", "ssi_apm", };
  32. static const char *ssi3_clk_sels[] = { "ssi1_root_gate", "ssi2_root_gate", };
  33. static const char *ssi_ext1_com_sels[] = { "ssi_ext1_podf", "ssi1_root_gate", };
  34. static const char *ssi_ext2_com_sels[] = { "ssi_ext2_podf", "ssi2_root_gate", };
  35. static const char *emi_slow_sel[] = { "main_bus", "ahb", };
  36. static const char *usb_phy_sel_str[] = { "osc", "usb_phy_podf", };
  37. static const char *mx51_ipu_di0_sel[] = { "di_pred", "osc", "ckih1", "tve_di", };
  38. static const char *mx53_ipu_di0_sel[] = { "di_pred", "osc", "ckih1", "di_pll4_podf", "dummy", "ldb_di0_gate", };
  39. static const char *mx53_ldb_di0_sel[] = { "pll3_sw", "pll4_sw", };
  40. static const char *mx51_ipu_di1_sel[] = { "di_pred", "osc", "ckih1", "tve_di", "ipp_di1", };
  41. static const char *mx53_ipu_di1_sel[] = { "di_pred", "osc", "ckih1", "tve_di", "ipp_di1", "ldb_di1_gate", };
  42. static const char *mx53_ldb_di1_sel[] = { "pll3_sw", "pll4_sw", };
  43. static const char *mx51_tve_ext_sel[] = { "osc", "ckih1", };
  44. static const char *mx53_tve_ext_sel[] = { "pll4_sw", "ckih1", };
  45. static const char *mx51_tve_sel[] = { "tve_pred", "tve_ext_sel", };
  46. static const char *ipu_sel[] = { "axi_a", "axi_b", "emi_slow_gate", "ahb", };
  47. static const char *gpu3d_sel[] = { "axi_a", "axi_b", "emi_slow_gate", "ahb" };
  48. static const char *gpu2d_sel[] = { "axi_a", "axi_b", "emi_slow_gate", "ahb" };
  49. static const char *vpu_sel[] = { "axi_a", "axi_b", "emi_slow_gate", "ahb", };
  50. static const char *mx53_can_sel[] = { "ipg", "ckih1", "ckih2", "lp_apm", };
  51. static const char *mx53_cko1_sel[] = {
  52. "cpu_podf", "pll1_sw", "pll2_sw", "pll3_sw",
  53. "emi_slow_podf", "pll4_sw", "nfc_podf", "dummy",
  54. "di_pred", "dummy", "dummy", "ahb",
  55. "ipg", "per_root", "ckil", "dummy",};
  56. static const char *mx53_cko2_sel[] = {
  57. "dummy"/* dptc_core */, "dummy"/* dptc_perich */,
  58. "dummy", "esdhc_a_podf",
  59. "usboh3_podf", "dummy"/* wrck_clk_root */,
  60. "ecspi_podf", "dummy"/* pll1_ref_clk */,
  61. "esdhc_b_podf", "dummy"/* ddr_clk_root */,
  62. "dummy"/* arm_axi_clk_root */, "dummy"/* usb_phy_out */,
  63. "vpu_sel", "ipu_sel",
  64. "osc", "ckih1",
  65. "dummy", "esdhc_c_sel",
  66. "ssi1_root_podf", "ssi2_root_podf",
  67. "dummy", "dummy",
  68. "dummy"/* lpsr_clk_root */, "dummy"/* pgc_clk_root */,
  69. "dummy"/* tve_out */, "usb_phy_sel",
  70. "tve_sel", "lp_apm",
  71. "uart_root", "dummy"/* spdif0_clk_root */,
  72. "dummy", "dummy", };
  73. static const char *mx51_spdif_xtal_sel[] = { "osc", "ckih", "ckih2", };
  74. static const char *mx53_spdif_xtal_sel[] = { "osc", "ckih", "ckih2", "pll4_sw", };
  75. static const char *spdif_sel[] = { "pll1_sw", "pll2_sw", "pll3_sw", "spdif_xtal_sel", };
  76. static const char *spdif0_com_sel[] = { "spdif0_podf", "ssi1_root_gate", };
  77. static const char *mx51_spdif1_com_sel[] = { "spdif1_podf", "ssi2_root_gate", };
  78. enum imx5_clks {
  79. dummy, ckil, osc, ckih1, ckih2, ahb, ipg, axi_a, axi_b, uart_pred,
  80. uart_root, esdhc_a_pred, esdhc_b_pred, esdhc_c_s, esdhc_d_s,
  81. emi_sel, emi_slow_podf, nfc_podf, ecspi_pred, ecspi_podf, usboh3_pred,
  82. usboh3_podf, usb_phy_pred, usb_phy_podf, cpu_podf, di_pred, tve_di_unused,
  83. tve_s, uart1_ipg_gate, uart1_per_gate, uart2_ipg_gate,
  84. uart2_per_gate, uart3_ipg_gate, uart3_per_gate, i2c1_gate, i2c2_gate,
  85. gpt_ipg_gate, pwm1_ipg_gate, pwm1_hf_gate, pwm2_ipg_gate, pwm2_hf_gate,
  86. gpt_hf_gate, fec_gate, usboh3_per_gate, esdhc1_ipg_gate, esdhc2_ipg_gate,
  87. esdhc3_ipg_gate, esdhc4_ipg_gate, ssi1_ipg_gate, ssi2_ipg_gate,
  88. ssi3_ipg_gate, ecspi1_ipg_gate, ecspi1_per_gate, ecspi2_ipg_gate,
  89. ecspi2_per_gate, cspi_ipg_gate, sdma_gate, emi_slow_gate, ipu_s,
  90. ipu_gate, nfc_gate, ipu_di1_gate, vpu_s, vpu_gate,
  91. vpu_reference_gate, uart4_ipg_gate, uart4_per_gate, uart5_ipg_gate,
  92. uart5_per_gate, tve_gate, tve_pred, esdhc1_per_gate, esdhc2_per_gate,
  93. esdhc3_per_gate, esdhc4_per_gate, usb_phy_gate, hsi2c_gate,
  94. mipi_hsc1_gate, mipi_hsc2_gate, mipi_esc_gate, mipi_hsp_gate,
  95. ldb_di1_div_3_5, ldb_di1_div, ldb_di0_div_3_5, ldb_di0_div,
  96. ldb_di1_gate, can2_serial_gate, can2_ipg_gate, i2c3_gate, lp_apm,
  97. periph_apm, main_bus, ahb_max, aips_tz1, aips_tz2, tmax1, tmax2,
  98. tmax3, spba, uart_sel, esdhc_a_sel, esdhc_b_sel, esdhc_a_podf,
  99. esdhc_b_podf, ecspi_sel, usboh3_sel, usb_phy_sel, iim_gate,
  100. usboh3_gate, emi_fast_gate, ipu_di0_gate,gpc_dvfs, pll1_sw, pll2_sw,
  101. pll3_sw, ipu_di0_sel, ipu_di1_sel, tve_ext_sel, mx51_mipi, pll4_sw,
  102. ldb_di1_sel, di_pll4_podf, ldb_di0_sel, ldb_di0_gate, usb_phy1_gate,
  103. usb_phy2_gate, per_lp_apm, per_pred1, per_pred2, per_podf, per_root,
  104. ssi_apm, ssi1_root_sel, ssi2_root_sel, ssi3_root_sel, ssi_ext1_sel,
  105. ssi_ext2_sel, ssi_ext1_com_sel, ssi_ext2_com_sel, ssi1_root_pred,
  106. ssi1_root_podf, ssi2_root_pred, ssi2_root_podf, ssi_ext1_pred,
  107. ssi_ext1_podf, ssi_ext2_pred, ssi_ext2_podf, ssi1_root_gate,
  108. ssi2_root_gate, ssi3_root_gate, ssi_ext1_gate, ssi_ext2_gate,
  109. epit1_ipg_gate, epit1_hf_gate, epit2_ipg_gate, epit2_hf_gate,
  110. can_sel, can1_serial_gate, can1_ipg_gate,
  111. owire_gate, gpu3d_s, gpu2d_s, gpu3d_gate, gpu2d_gate, garb_gate,
  112. cko1_sel, cko1_podf, cko1,
  113. cko2_sel, cko2_podf, cko2,
  114. srtc_gate, pata_gate, sata_gate, spdif_xtal_sel, spdif0_sel,
  115. spdif1_sel, spdif0_pred, spdif0_podf, spdif1_pred, spdif1_podf,
  116. spdif0_com_s, spdif1_com_sel, spdif0_gate, spdif1_gate, spdif_ipg_gate,
  117. clk_max
  118. };
  119. static struct clk *clk[clk_max];
  120. static struct clk_onecell_data clk_data;
  121. static void __init mx5_clocks_common_init(unsigned long rate_ckil,
  122. unsigned long rate_osc, unsigned long rate_ckih1,
  123. unsigned long rate_ckih2)
  124. {
  125. int i;
  126. of_clk_init(NULL);
  127. clk[dummy] = imx_clk_fixed("dummy", 0);
  128. clk[ckil] = imx_obtain_fixed_clock("ckil", rate_ckil);
  129. clk[osc] = imx_obtain_fixed_clock("osc", rate_osc);
  130. clk[ckih1] = imx_obtain_fixed_clock("ckih1", rate_ckih1);
  131. clk[ckih2] = imx_obtain_fixed_clock("ckih2", rate_ckih2);
  132. clk[lp_apm] = imx_clk_mux("lp_apm", MXC_CCM_CCSR, 9, 1,
  133. lp_apm_sel, ARRAY_SIZE(lp_apm_sel));
  134. clk[periph_apm] = imx_clk_mux("periph_apm", MXC_CCM_CBCMR, 12, 2,
  135. periph_apm_sel, ARRAY_SIZE(periph_apm_sel));
  136. clk[main_bus] = imx_clk_mux("main_bus", MXC_CCM_CBCDR, 25, 1,
  137. main_bus_sel, ARRAY_SIZE(main_bus_sel));
  138. clk[per_lp_apm] = imx_clk_mux("per_lp_apm", MXC_CCM_CBCMR, 1, 1,
  139. per_lp_apm_sel, ARRAY_SIZE(per_lp_apm_sel));
  140. clk[per_pred1] = imx_clk_divider("per_pred1", "per_lp_apm", MXC_CCM_CBCDR, 6, 2);
  141. clk[per_pred2] = imx_clk_divider("per_pred2", "per_pred1", MXC_CCM_CBCDR, 3, 3);
  142. clk[per_podf] = imx_clk_divider("per_podf", "per_pred2", MXC_CCM_CBCDR, 0, 3);
  143. clk[per_root] = imx_clk_mux("per_root", MXC_CCM_CBCMR, 0, 1,
  144. per_root_sel, ARRAY_SIZE(per_root_sel));
  145. clk[ahb] = imx_clk_divider("ahb", "main_bus", MXC_CCM_CBCDR, 10, 3);
  146. clk[ahb_max] = imx_clk_gate2("ahb_max", "ahb", MXC_CCM_CCGR0, 28);
  147. clk[aips_tz1] = imx_clk_gate2("aips_tz1", "ahb", MXC_CCM_CCGR0, 24);
  148. clk[aips_tz2] = imx_clk_gate2("aips_tz2", "ahb", MXC_CCM_CCGR0, 26);
  149. clk[tmax1] = imx_clk_gate2("tmax1", "ahb", MXC_CCM_CCGR1, 0);
  150. clk[tmax2] = imx_clk_gate2("tmax2", "ahb", MXC_CCM_CCGR1, 2);
  151. clk[tmax3] = imx_clk_gate2("tmax3", "ahb", MXC_CCM_CCGR1, 4);
  152. clk[spba] = imx_clk_gate2("spba", "ipg", MXC_CCM_CCGR5, 0);
  153. clk[ipg] = imx_clk_divider("ipg", "ahb", MXC_CCM_CBCDR, 8, 2);
  154. clk[axi_a] = imx_clk_divider("axi_a", "main_bus", MXC_CCM_CBCDR, 16, 3);
  155. clk[axi_b] = imx_clk_divider("axi_b", "main_bus", MXC_CCM_CBCDR, 19, 3);
  156. clk[uart_sel] = imx_clk_mux("uart_sel", MXC_CCM_CSCMR1, 24, 2,
  157. standard_pll_sel, ARRAY_SIZE(standard_pll_sel));
  158. clk[uart_pred] = imx_clk_divider("uart_pred", "uart_sel", MXC_CCM_CSCDR1, 3, 3);
  159. clk[uart_root] = imx_clk_divider("uart_root", "uart_pred", MXC_CCM_CSCDR1, 0, 3);
  160. clk[esdhc_a_sel] = imx_clk_mux("esdhc_a_sel", MXC_CCM_CSCMR1, 20, 2,
  161. standard_pll_sel, ARRAY_SIZE(standard_pll_sel));
  162. clk[esdhc_b_sel] = imx_clk_mux("esdhc_b_sel", MXC_CCM_CSCMR1, 16, 2,
  163. standard_pll_sel, ARRAY_SIZE(standard_pll_sel));
  164. clk[esdhc_a_pred] = imx_clk_divider("esdhc_a_pred", "esdhc_a_sel", MXC_CCM_CSCDR1, 16, 3);
  165. clk[esdhc_a_podf] = imx_clk_divider("esdhc_a_podf", "esdhc_a_pred", MXC_CCM_CSCDR1, 11, 3);
  166. clk[esdhc_b_pred] = imx_clk_divider("esdhc_b_pred", "esdhc_b_sel", MXC_CCM_CSCDR1, 22, 3);
  167. clk[esdhc_b_podf] = imx_clk_divider("esdhc_b_podf", "esdhc_b_pred", MXC_CCM_CSCDR1, 19, 3);
  168. clk[esdhc_c_s] = imx_clk_mux("esdhc_c_sel", MXC_CCM_CSCMR1, 19, 1, esdhc_c_sel, ARRAY_SIZE(esdhc_c_sel));
  169. clk[esdhc_d_s] = imx_clk_mux("esdhc_d_sel", MXC_CCM_CSCMR1, 18, 1, esdhc_d_sel, ARRAY_SIZE(esdhc_d_sel));
  170. clk[emi_sel] = imx_clk_mux("emi_sel", MXC_CCM_CBCDR, 26, 1,
  171. emi_slow_sel, ARRAY_SIZE(emi_slow_sel));
  172. clk[emi_slow_podf] = imx_clk_divider("emi_slow_podf", "emi_sel", MXC_CCM_CBCDR, 22, 3);
  173. clk[nfc_podf] = imx_clk_divider("nfc_podf", "emi_slow_podf", MXC_CCM_CBCDR, 13, 3);
  174. clk[ecspi_sel] = imx_clk_mux("ecspi_sel", MXC_CCM_CSCMR1, 4, 2,
  175. standard_pll_sel, ARRAY_SIZE(standard_pll_sel));
  176. clk[ecspi_pred] = imx_clk_divider("ecspi_pred", "ecspi_sel", MXC_CCM_CSCDR2, 25, 3);
  177. clk[ecspi_podf] = imx_clk_divider("ecspi_podf", "ecspi_pred", MXC_CCM_CSCDR2, 19, 6);
  178. clk[usboh3_sel] = imx_clk_mux("usboh3_sel", MXC_CCM_CSCMR1, 22, 2,
  179. standard_pll_sel, ARRAY_SIZE(standard_pll_sel));
  180. clk[usboh3_pred] = imx_clk_divider("usboh3_pred", "usboh3_sel", MXC_CCM_CSCDR1, 8, 3);
  181. clk[usboh3_podf] = imx_clk_divider("usboh3_podf", "usboh3_pred", MXC_CCM_CSCDR1, 6, 2);
  182. clk[usb_phy_pred] = imx_clk_divider("usb_phy_pred", "pll3_sw", MXC_CCM_CDCDR, 3, 3);
  183. clk[usb_phy_podf] = imx_clk_divider("usb_phy_podf", "usb_phy_pred", MXC_CCM_CDCDR, 0, 3);
  184. clk[usb_phy_sel] = imx_clk_mux("usb_phy_sel", MXC_CCM_CSCMR1, 26, 1,
  185. usb_phy_sel_str, ARRAY_SIZE(usb_phy_sel_str));
  186. clk[cpu_podf] = imx_clk_divider("cpu_podf", "pll1_sw", MXC_CCM_CACRR, 0, 3);
  187. clk[di_pred] = imx_clk_divider("di_pred", "pll3_sw", MXC_CCM_CDCDR, 6, 3);
  188. clk[iim_gate] = imx_clk_gate2("iim_gate", "ipg", MXC_CCM_CCGR0, 30);
  189. clk[uart1_ipg_gate] = imx_clk_gate2("uart1_ipg_gate", "ipg", MXC_CCM_CCGR1, 6);
  190. clk[uart1_per_gate] = imx_clk_gate2("uart1_per_gate", "uart_root", MXC_CCM_CCGR1, 8);
  191. clk[uart2_ipg_gate] = imx_clk_gate2("uart2_ipg_gate", "ipg", MXC_CCM_CCGR1, 10);
  192. clk[uart2_per_gate] = imx_clk_gate2("uart2_per_gate", "uart_root", MXC_CCM_CCGR1, 12);
  193. clk[uart3_ipg_gate] = imx_clk_gate2("uart3_ipg_gate", "ipg", MXC_CCM_CCGR1, 14);
  194. clk[uart3_per_gate] = imx_clk_gate2("uart3_per_gate", "uart_root", MXC_CCM_CCGR1, 16);
  195. clk[i2c1_gate] = imx_clk_gate2("i2c1_gate", "per_root", MXC_CCM_CCGR1, 18);
  196. clk[i2c2_gate] = imx_clk_gate2("i2c2_gate", "per_root", MXC_CCM_CCGR1, 20);
  197. clk[pwm1_ipg_gate] = imx_clk_gate2("pwm1_ipg_gate", "ipg", MXC_CCM_CCGR2, 10);
  198. clk[pwm1_hf_gate] = imx_clk_gate2("pwm1_hf_gate", "per_root", MXC_CCM_CCGR2, 12);
  199. clk[pwm2_ipg_gate] = imx_clk_gate2("pwm2_ipg_gate", "ipg", MXC_CCM_CCGR2, 14);
  200. clk[pwm2_hf_gate] = imx_clk_gate2("pwm2_hf_gate", "per_root", MXC_CCM_CCGR2, 16);
  201. clk[gpt_ipg_gate] = imx_clk_gate2("gpt_ipg_gate", "ipg", MXC_CCM_CCGR2, 18);
  202. clk[gpt_hf_gate] = imx_clk_gate2("gpt_hf_gate", "per_root", MXC_CCM_CCGR2, 20);
  203. clk[fec_gate] = imx_clk_gate2("fec_gate", "ipg", MXC_CCM_CCGR2, 24);
  204. clk[usboh3_gate] = imx_clk_gate2("usboh3_gate", "ipg", MXC_CCM_CCGR2, 26);
  205. clk[usboh3_per_gate] = imx_clk_gate2("usboh3_per_gate", "usboh3_podf", MXC_CCM_CCGR2, 28);
  206. clk[esdhc1_ipg_gate] = imx_clk_gate2("esdhc1_ipg_gate", "ipg", MXC_CCM_CCGR3, 0);
  207. clk[esdhc2_ipg_gate] = imx_clk_gate2("esdhc2_ipg_gate", "ipg", MXC_CCM_CCGR3, 4);
  208. clk[esdhc3_ipg_gate] = imx_clk_gate2("esdhc3_ipg_gate", "ipg", MXC_CCM_CCGR3, 8);
  209. clk[esdhc4_ipg_gate] = imx_clk_gate2("esdhc4_ipg_gate", "ipg", MXC_CCM_CCGR3, 12);
  210. clk[ssi1_ipg_gate] = imx_clk_gate2("ssi1_ipg_gate", "ipg", MXC_CCM_CCGR3, 16);
  211. clk[ssi2_ipg_gate] = imx_clk_gate2("ssi2_ipg_gate", "ipg", MXC_CCM_CCGR3, 20);
  212. clk[ssi3_ipg_gate] = imx_clk_gate2("ssi3_ipg_gate", "ipg", MXC_CCM_CCGR3, 24);
  213. clk[ecspi1_ipg_gate] = imx_clk_gate2("ecspi1_ipg_gate", "ipg", MXC_CCM_CCGR4, 18);
  214. clk[ecspi1_per_gate] = imx_clk_gate2("ecspi1_per_gate", "ecspi_podf", MXC_CCM_CCGR4, 20);
  215. clk[ecspi2_ipg_gate] = imx_clk_gate2("ecspi2_ipg_gate", "ipg", MXC_CCM_CCGR4, 22);
  216. clk[ecspi2_per_gate] = imx_clk_gate2("ecspi2_per_gate", "ecspi_podf", MXC_CCM_CCGR4, 24);
  217. clk[cspi_ipg_gate] = imx_clk_gate2("cspi_ipg_gate", "ipg", MXC_CCM_CCGR4, 26);
  218. clk[sdma_gate] = imx_clk_gate2("sdma_gate", "ipg", MXC_CCM_CCGR4, 30);
  219. clk[emi_fast_gate] = imx_clk_gate2("emi_fast_gate", "dummy", MXC_CCM_CCGR5, 14);
  220. clk[emi_slow_gate] = imx_clk_gate2("emi_slow_gate", "emi_slow_podf", MXC_CCM_CCGR5, 16);
  221. clk[ipu_s] = imx_clk_mux("ipu_sel", MXC_CCM_CBCMR, 6, 2, ipu_sel, ARRAY_SIZE(ipu_sel));
  222. clk[ipu_gate] = imx_clk_gate2("ipu_gate", "ipu_sel", MXC_CCM_CCGR5, 10);
  223. clk[nfc_gate] = imx_clk_gate2("nfc_gate", "nfc_podf", MXC_CCM_CCGR5, 20);
  224. clk[ipu_di0_gate] = imx_clk_gate2("ipu_di0_gate", "ipu_di0_sel", MXC_CCM_CCGR6, 10);
  225. clk[ipu_di1_gate] = imx_clk_gate2("ipu_di1_gate", "ipu_di1_sel", MXC_CCM_CCGR6, 12);
  226. clk[gpu3d_s] = imx_clk_mux("gpu3d_sel", MXC_CCM_CBCMR, 4, 2, gpu3d_sel, ARRAY_SIZE(gpu3d_sel));
  227. clk[gpu2d_s] = imx_clk_mux("gpu2d_sel", MXC_CCM_CBCMR, 16, 2, gpu2d_sel, ARRAY_SIZE(gpu2d_sel));
  228. clk[gpu3d_gate] = imx_clk_gate2("gpu3d_gate", "gpu3d_sel", MXC_CCM_CCGR5, 2);
  229. clk[garb_gate] = imx_clk_gate2("garb_gate", "axi_a", MXC_CCM_CCGR5, 4);
  230. clk[gpu2d_gate] = imx_clk_gate2("gpu2d_gate", "gpu2d_sel", MXC_CCM_CCGR6, 14);
  231. clk[vpu_s] = imx_clk_mux("vpu_sel", MXC_CCM_CBCMR, 14, 2, vpu_sel, ARRAY_SIZE(vpu_sel));
  232. clk[vpu_gate] = imx_clk_gate2("vpu_gate", "vpu_sel", MXC_CCM_CCGR5, 6);
  233. clk[vpu_reference_gate] = imx_clk_gate2("vpu_reference_gate", "osc", MXC_CCM_CCGR5, 8);
  234. clk[uart4_ipg_gate] = imx_clk_gate2("uart4_ipg_gate", "ipg", MXC_CCM_CCGR7, 8);
  235. clk[uart4_per_gate] = imx_clk_gate2("uart4_per_gate", "uart_root", MXC_CCM_CCGR7, 10);
  236. clk[uart5_ipg_gate] = imx_clk_gate2("uart5_ipg_gate", "ipg", MXC_CCM_CCGR7, 12);
  237. clk[uart5_per_gate] = imx_clk_gate2("uart5_per_gate", "uart_root", MXC_CCM_CCGR7, 14);
  238. clk[gpc_dvfs] = imx_clk_gate2("gpc_dvfs", "dummy", MXC_CCM_CCGR5, 24);
  239. clk[ssi_apm] = imx_clk_mux("ssi_apm", MXC_CCM_CSCMR1, 8, 2, ssi_apm_sels, ARRAY_SIZE(ssi_apm_sels));
  240. clk[ssi1_root_sel] = imx_clk_mux("ssi1_root_sel", MXC_CCM_CSCMR1, 14, 2, ssi_clk_sels, ARRAY_SIZE(ssi_clk_sels));
  241. clk[ssi2_root_sel] = imx_clk_mux("ssi2_root_sel", MXC_CCM_CSCMR1, 12, 2, ssi_clk_sels, ARRAY_SIZE(ssi_clk_sels));
  242. clk[ssi3_root_sel] = imx_clk_mux("ssi3_root_sel", MXC_CCM_CSCMR1, 11, 1, ssi3_clk_sels, ARRAY_SIZE(ssi3_clk_sels));
  243. clk[ssi_ext1_sel] = imx_clk_mux("ssi_ext1_sel", MXC_CCM_CSCMR1, 28, 2, ssi_clk_sels, ARRAY_SIZE(ssi_clk_sels));
  244. clk[ssi_ext2_sel] = imx_clk_mux("ssi_ext2_sel", MXC_CCM_CSCMR1, 30, 2, ssi_clk_sels, ARRAY_SIZE(ssi_clk_sels));
  245. clk[ssi_ext1_com_sel] = imx_clk_mux("ssi_ext1_com_sel", MXC_CCM_CSCMR1, 0, 1, ssi_ext1_com_sels, ARRAY_SIZE(ssi_ext1_com_sels));
  246. clk[ssi_ext2_com_sel] = imx_clk_mux("ssi_ext2_com_sel", MXC_CCM_CSCMR1, 1, 1, ssi_ext2_com_sels, ARRAY_SIZE(ssi_ext2_com_sels));
  247. clk[ssi1_root_pred] = imx_clk_divider("ssi1_root_pred", "ssi1_root_sel", MXC_CCM_CS1CDR, 6, 3);
  248. clk[ssi1_root_podf] = imx_clk_divider("ssi1_root_podf", "ssi1_root_pred", MXC_CCM_CS1CDR, 0, 6);
  249. clk[ssi2_root_pred] = imx_clk_divider("ssi2_root_pred", "ssi2_root_sel", MXC_CCM_CS2CDR, 6, 3);
  250. clk[ssi2_root_podf] = imx_clk_divider("ssi2_root_podf", "ssi2_root_pred", MXC_CCM_CS2CDR, 0, 6);
  251. clk[ssi_ext1_pred] = imx_clk_divider("ssi_ext1_pred", "ssi_ext1_sel", MXC_CCM_CS1CDR, 22, 3);
  252. clk[ssi_ext1_podf] = imx_clk_divider("ssi_ext1_podf", "ssi_ext1_pred", MXC_CCM_CS1CDR, 16, 6);
  253. clk[ssi_ext2_pred] = imx_clk_divider("ssi_ext2_pred", "ssi_ext2_sel", MXC_CCM_CS2CDR, 22, 3);
  254. clk[ssi_ext2_podf] = imx_clk_divider("ssi_ext2_podf", "ssi_ext2_pred", MXC_CCM_CS2CDR, 16, 6);
  255. clk[ssi1_root_gate] = imx_clk_gate2("ssi1_root_gate", "ssi1_root_podf", MXC_CCM_CCGR3, 18);
  256. clk[ssi2_root_gate] = imx_clk_gate2("ssi2_root_gate", "ssi2_root_podf", MXC_CCM_CCGR3, 22);
  257. clk[ssi3_root_gate] = imx_clk_gate2("ssi3_root_gate", "ssi3_root_sel", MXC_CCM_CCGR3, 26);
  258. clk[ssi_ext1_gate] = imx_clk_gate2("ssi_ext1_gate", "ssi_ext1_com_sel", MXC_CCM_CCGR3, 28);
  259. clk[ssi_ext2_gate] = imx_clk_gate2("ssi_ext2_gate", "ssi_ext2_com_sel", MXC_CCM_CCGR3, 30);
  260. clk[epit1_ipg_gate] = imx_clk_gate2("epit1_ipg_gate", "ipg", MXC_CCM_CCGR2, 2);
  261. clk[epit1_hf_gate] = imx_clk_gate2("epit1_hf_gate", "per_root", MXC_CCM_CCGR2, 4);
  262. clk[epit2_ipg_gate] = imx_clk_gate2("epit2_ipg_gate", "ipg", MXC_CCM_CCGR2, 6);
  263. clk[epit2_hf_gate] = imx_clk_gate2("epit2_hf_gate", "per_root", MXC_CCM_CCGR2, 8);
  264. clk[owire_gate] = imx_clk_gate2("owire_gate", "per_root", MXC_CCM_CCGR2, 22);
  265. clk[srtc_gate] = imx_clk_gate2("srtc_gate", "per_root", MXC_CCM_CCGR4, 28);
  266. clk[pata_gate] = imx_clk_gate2("pata_gate", "ipg", MXC_CCM_CCGR4, 0);
  267. clk[spdif0_sel] = imx_clk_mux("spdif0_sel", MXC_CCM_CSCMR2, 0, 2, spdif_sel, ARRAY_SIZE(spdif_sel));
  268. clk[spdif0_pred] = imx_clk_divider("spdif0_pred", "spdif0_sel", MXC_CCM_CDCDR, 25, 3);
  269. clk[spdif0_podf] = imx_clk_divider("spdif0_podf", "spdif0_pred", MXC_CCM_CDCDR, 19, 6);
  270. clk[spdif0_com_s] = imx_clk_mux_flags("spdif0_com_sel", MXC_CCM_CSCMR2, 4, 1,
  271. spdif0_com_sel, ARRAY_SIZE(spdif0_com_sel), CLK_SET_RATE_PARENT);
  272. clk[spdif0_gate] = imx_clk_gate2("spdif0_gate", "spdif0_com_sel", MXC_CCM_CCGR5, 26);
  273. clk[spdif_ipg_gate] = imx_clk_gate2("spdif_ipg_gate", "ipg", MXC_CCM_CCGR5, 30);
  274. for (i = 0; i < ARRAY_SIZE(clk); i++)
  275. if (IS_ERR(clk[i]))
  276. pr_err("i.MX5 clk %d: register failed with %ld\n",
  277. i, PTR_ERR(clk[i]));
  278. clk_register_clkdev(clk[gpt_hf_gate], "per", "imx-gpt.0");
  279. clk_register_clkdev(clk[gpt_ipg_gate], "ipg", "imx-gpt.0");
  280. clk_register_clkdev(clk[uart1_per_gate], "per", "imx21-uart.0");
  281. clk_register_clkdev(clk[uart1_ipg_gate], "ipg", "imx21-uart.0");
  282. clk_register_clkdev(clk[uart2_per_gate], "per", "imx21-uart.1");
  283. clk_register_clkdev(clk[uart2_ipg_gate], "ipg", "imx21-uart.1");
  284. clk_register_clkdev(clk[uart3_per_gate], "per", "imx21-uart.2");
  285. clk_register_clkdev(clk[uart3_ipg_gate], "ipg", "imx21-uart.2");
  286. clk_register_clkdev(clk[uart4_per_gate], "per", "imx21-uart.3");
  287. clk_register_clkdev(clk[uart4_ipg_gate], "ipg", "imx21-uart.3");
  288. clk_register_clkdev(clk[uart5_per_gate], "per", "imx21-uart.4");
  289. clk_register_clkdev(clk[uart5_ipg_gate], "ipg", "imx21-uart.4");
  290. clk_register_clkdev(clk[ecspi1_per_gate], "per", "imx51-ecspi.0");
  291. clk_register_clkdev(clk[ecspi1_ipg_gate], "ipg", "imx51-ecspi.0");
  292. clk_register_clkdev(clk[ecspi2_per_gate], "per", "imx51-ecspi.1");
  293. clk_register_clkdev(clk[ecspi2_ipg_gate], "ipg", "imx51-ecspi.1");
  294. clk_register_clkdev(clk[cspi_ipg_gate], NULL, "imx35-cspi.2");
  295. clk_register_clkdev(clk[pwm1_ipg_gate], "pwm", "mxc_pwm.0");
  296. clk_register_clkdev(clk[pwm2_ipg_gate], "pwm", "mxc_pwm.1");
  297. clk_register_clkdev(clk[i2c1_gate], NULL, "imx21-i2c.0");
  298. clk_register_clkdev(clk[i2c2_gate], NULL, "imx21-i2c.1");
  299. clk_register_clkdev(clk[usboh3_per_gate], "per", "mxc-ehci.0");
  300. clk_register_clkdev(clk[usboh3_gate], "ipg", "mxc-ehci.0");
  301. clk_register_clkdev(clk[usboh3_gate], "ahb", "mxc-ehci.0");
  302. clk_register_clkdev(clk[usboh3_per_gate], "per", "mxc-ehci.1");
  303. clk_register_clkdev(clk[usboh3_gate], "ipg", "mxc-ehci.1");
  304. clk_register_clkdev(clk[usboh3_gate], "ahb", "mxc-ehci.1");
  305. clk_register_clkdev(clk[usboh3_per_gate], "per", "mxc-ehci.2");
  306. clk_register_clkdev(clk[usboh3_gate], "ipg", "mxc-ehci.2");
  307. clk_register_clkdev(clk[usboh3_gate], "ahb", "mxc-ehci.2");
  308. clk_register_clkdev(clk[usboh3_per_gate], "per", "imx-udc-mx51");
  309. clk_register_clkdev(clk[usboh3_gate], "ipg", "imx-udc-mx51");
  310. clk_register_clkdev(clk[usboh3_gate], "ahb", "imx-udc-mx51");
  311. clk_register_clkdev(clk[nfc_gate], NULL, "imx51-nand");
  312. clk_register_clkdev(clk[ssi1_ipg_gate], NULL, "imx-ssi.0");
  313. clk_register_clkdev(clk[ssi2_ipg_gate], NULL, "imx-ssi.1");
  314. clk_register_clkdev(clk[ssi3_ipg_gate], NULL, "imx-ssi.2");
  315. clk_register_clkdev(clk[sdma_gate], NULL, "imx35-sdma");
  316. clk_register_clkdev(clk[cpu_podf], NULL, "cpufreq-cpu0.0");
  317. clk_register_clkdev(clk[iim_gate], "iim", NULL);
  318. clk_register_clkdev(clk[dummy], NULL, "imx2-wdt.0");
  319. clk_register_clkdev(clk[dummy], NULL, "imx2-wdt.1");
  320. clk_register_clkdev(clk[dummy], NULL, "imx-keypad");
  321. clk_register_clkdev(clk[ipu_di1_gate], "di1", "imx-tve.0");
  322. clk_register_clkdev(clk[gpc_dvfs], "gpc_dvfs", NULL);
  323. clk_register_clkdev(clk[epit1_ipg_gate], "ipg", "imx-epit.0");
  324. clk_register_clkdev(clk[epit1_hf_gate], "per", "imx-epit.0");
  325. clk_register_clkdev(clk[epit2_ipg_gate], "ipg", "imx-epit.1");
  326. clk_register_clkdev(clk[epit2_hf_gate], "per", "imx-epit.1");
  327. /* Set SDHC parents to be PLL2 */
  328. clk_set_parent(clk[esdhc_a_sel], clk[pll2_sw]);
  329. clk_set_parent(clk[esdhc_b_sel], clk[pll2_sw]);
  330. /* move usb phy clk to 24MHz */
  331. clk_set_parent(clk[usb_phy_sel], clk[osc]);
  332. clk_prepare_enable(clk[gpc_dvfs]);
  333. clk_prepare_enable(clk[ahb_max]); /* esdhc3 */
  334. clk_prepare_enable(clk[aips_tz1]);
  335. clk_prepare_enable(clk[aips_tz2]); /* fec */
  336. clk_prepare_enable(clk[spba]);
  337. clk_prepare_enable(clk[emi_fast_gate]); /* fec */
  338. clk_prepare_enable(clk[emi_slow_gate]); /* eim */
  339. clk_prepare_enable(clk[mipi_hsc1_gate]);
  340. clk_prepare_enable(clk[mipi_hsc2_gate]);
  341. clk_prepare_enable(clk[mipi_esc_gate]);
  342. clk_prepare_enable(clk[mipi_hsp_gate]);
  343. clk_prepare_enable(clk[tmax1]);
  344. clk_prepare_enable(clk[tmax2]); /* esdhc2, fec */
  345. clk_prepare_enable(clk[tmax3]); /* esdhc1, esdhc4 */
  346. }
  347. int __init mx51_clocks_init(unsigned long rate_ckil, unsigned long rate_osc,
  348. unsigned long rate_ckih1, unsigned long rate_ckih2)
  349. {
  350. int i;
  351. u32 val;
  352. struct device_node *np;
  353. clk[pll1_sw] = imx_clk_pllv2("pll1_sw", "osc", MX51_DPLL1_BASE);
  354. clk[pll2_sw] = imx_clk_pllv2("pll2_sw", "osc", MX51_DPLL2_BASE);
  355. clk[pll3_sw] = imx_clk_pllv2("pll3_sw", "osc", MX51_DPLL3_BASE);
  356. clk[ipu_di0_sel] = imx_clk_mux("ipu_di0_sel", MXC_CCM_CSCMR2, 26, 3,
  357. mx51_ipu_di0_sel, ARRAY_SIZE(mx51_ipu_di0_sel));
  358. clk[ipu_di1_sel] = imx_clk_mux("ipu_di1_sel", MXC_CCM_CSCMR2, 29, 3,
  359. mx51_ipu_di1_sel, ARRAY_SIZE(mx51_ipu_di1_sel));
  360. clk[tve_ext_sel] = imx_clk_mux_flags("tve_ext_sel", MXC_CCM_CSCMR1, 6, 1,
  361. mx51_tve_ext_sel, ARRAY_SIZE(mx51_tve_ext_sel), CLK_SET_RATE_PARENT);
  362. clk[tve_s] = imx_clk_mux("tve_sel", MXC_CCM_CSCMR1, 7, 1,
  363. mx51_tve_sel, ARRAY_SIZE(mx51_tve_sel));
  364. clk[tve_gate] = imx_clk_gate2("tve_gate", "tve_sel", MXC_CCM_CCGR2, 30);
  365. clk[tve_pred] = imx_clk_divider("tve_pred", "pll3_sw", MXC_CCM_CDCDR, 28, 3);
  366. clk[esdhc1_per_gate] = imx_clk_gate2("esdhc1_per_gate", "esdhc_a_podf", MXC_CCM_CCGR3, 2);
  367. clk[esdhc2_per_gate] = imx_clk_gate2("esdhc2_per_gate", "esdhc_b_podf", MXC_CCM_CCGR3, 6);
  368. clk[esdhc3_per_gate] = imx_clk_gate2("esdhc3_per_gate", "esdhc_c_sel", MXC_CCM_CCGR3, 10);
  369. clk[esdhc4_per_gate] = imx_clk_gate2("esdhc4_per_gate", "esdhc_d_sel", MXC_CCM_CCGR3, 14);
  370. clk[usb_phy_gate] = imx_clk_gate2("usb_phy_gate", "usb_phy_sel", MXC_CCM_CCGR2, 0);
  371. clk[hsi2c_gate] = imx_clk_gate2("hsi2c_gate", "ipg", MXC_CCM_CCGR1, 22);
  372. clk[mipi_hsc1_gate] = imx_clk_gate2("mipi_hsc1_gate", "ipg", MXC_CCM_CCGR4, 6);
  373. clk[mipi_hsc2_gate] = imx_clk_gate2("mipi_hsc2_gate", "ipg", MXC_CCM_CCGR4, 8);
  374. clk[mipi_esc_gate] = imx_clk_gate2("mipi_esc_gate", "ipg", MXC_CCM_CCGR4, 10);
  375. clk[mipi_hsp_gate] = imx_clk_gate2("mipi_hsp_gate", "ipg", MXC_CCM_CCGR4, 12);
  376. clk[spdif_xtal_sel] = imx_clk_mux("spdif_xtal_sel", MXC_CCM_CSCMR1, 2, 2,
  377. mx51_spdif_xtal_sel, ARRAY_SIZE(mx51_spdif_xtal_sel));
  378. clk[spdif1_sel] = imx_clk_mux("spdif1_sel", MXC_CCM_CSCMR2, 2, 2,
  379. spdif_sel, ARRAY_SIZE(spdif_sel));
  380. clk[spdif1_pred] = imx_clk_divider("spdif1_podf", "spdif1_sel", MXC_CCM_CDCDR, 16, 3);
  381. clk[spdif1_podf] = imx_clk_divider("spdif1_podf", "spdif1_pred", MXC_CCM_CDCDR, 9, 6);
  382. clk[spdif1_com_sel] = imx_clk_mux("spdif1_com_sel", MXC_CCM_CSCMR2, 5, 1,
  383. mx51_spdif1_com_sel, ARRAY_SIZE(mx51_spdif1_com_sel));
  384. clk[spdif1_gate] = imx_clk_gate2("spdif1_gate", "spdif1_com_sel", MXC_CCM_CCGR5, 28);
  385. for (i = 0; i < ARRAY_SIZE(clk); i++)
  386. if (IS_ERR(clk[i]))
  387. pr_err("i.MX51 clk %d: register failed with %ld\n",
  388. i, PTR_ERR(clk[i]));
  389. np = of_find_compatible_node(NULL, NULL, "fsl,imx51-ccm");
  390. clk_data.clks = clk;
  391. clk_data.clk_num = ARRAY_SIZE(clk);
  392. of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data);
  393. mx5_clocks_common_init(rate_ckil, rate_osc, rate_ckih1, rate_ckih2);
  394. clk_register_clkdev(clk[hsi2c_gate], NULL, "imx21-i2c.2");
  395. clk_register_clkdev(clk[mx51_mipi], "mipi_hsp", NULL);
  396. clk_register_clkdev(clk[vpu_gate], NULL, "imx51-vpu.0");
  397. clk_register_clkdev(clk[fec_gate], NULL, "imx27-fec.0");
  398. clk_register_clkdev(clk[usb_phy_gate], "phy", "mxc-ehci.0");
  399. clk_register_clkdev(clk[esdhc1_ipg_gate], "ipg", "sdhci-esdhc-imx51.0");
  400. clk_register_clkdev(clk[dummy], "ahb", "sdhci-esdhc-imx51.0");
  401. clk_register_clkdev(clk[esdhc1_per_gate], "per", "sdhci-esdhc-imx51.0");
  402. clk_register_clkdev(clk[esdhc2_ipg_gate], "ipg", "sdhci-esdhc-imx51.1");
  403. clk_register_clkdev(clk[dummy], "ahb", "sdhci-esdhc-imx51.1");
  404. clk_register_clkdev(clk[esdhc2_per_gate], "per", "sdhci-esdhc-imx51.1");
  405. clk_register_clkdev(clk[esdhc3_ipg_gate], "ipg", "sdhci-esdhc-imx51.2");
  406. clk_register_clkdev(clk[dummy], "ahb", "sdhci-esdhc-imx51.2");
  407. clk_register_clkdev(clk[esdhc3_per_gate], "per", "sdhci-esdhc-imx51.2");
  408. clk_register_clkdev(clk[esdhc4_ipg_gate], "ipg", "sdhci-esdhc-imx51.3");
  409. clk_register_clkdev(clk[dummy], "ahb", "sdhci-esdhc-imx51.3");
  410. clk_register_clkdev(clk[esdhc4_per_gate], "per", "sdhci-esdhc-imx51.3");
  411. /* set the usboh3 parent to pll2_sw */
  412. clk_set_parent(clk[usboh3_sel], clk[pll2_sw]);
  413. /* set SDHC root clock to 166.25MHZ*/
  414. clk_set_rate(clk[esdhc_a_podf], 166250000);
  415. clk_set_rate(clk[esdhc_b_podf], 166250000);
  416. /* System timer */
  417. mxc_timer_init(MX51_IO_ADDRESS(MX51_GPT1_BASE_ADDR), MX51_INT_GPT);
  418. clk_prepare_enable(clk[iim_gate]);
  419. imx_print_silicon_rev("i.MX51", mx51_revision());
  420. clk_disable_unprepare(clk[iim_gate]);
  421. /*
  422. * Reference Manual says: Functionality of CCDR[18] and CLPCR[23] is no
  423. * longer supported. Set to one for better power saving.
  424. *
  425. * The effect of not setting these bits is that MIPI clocks can't be
  426. * enabled without the IPU clock being enabled aswell.
  427. */
  428. val = readl(MXC_CCM_CCDR);
  429. val |= 1 << 18;
  430. writel(val, MXC_CCM_CCDR);
  431. val = readl(MXC_CCM_CLPCR);
  432. val |= 1 << 23;
  433. writel(val, MXC_CCM_CLPCR);
  434. return 0;
  435. }
  436. int __init mx53_clocks_init(unsigned long rate_ckil, unsigned long rate_osc,
  437. unsigned long rate_ckih1, unsigned long rate_ckih2)
  438. {
  439. int i;
  440. unsigned long r;
  441. struct device_node *np;
  442. clk[pll1_sw] = imx_clk_pllv2("pll1_sw", "osc", MX53_DPLL1_BASE);
  443. clk[pll2_sw] = imx_clk_pllv2("pll2_sw", "osc", MX53_DPLL2_BASE);
  444. clk[pll3_sw] = imx_clk_pllv2("pll3_sw", "osc", MX53_DPLL3_BASE);
  445. clk[pll4_sw] = imx_clk_pllv2("pll4_sw", "osc", MX53_DPLL4_BASE);
  446. clk[ldb_di1_div_3_5] = imx_clk_fixed_factor("ldb_di1_div_3_5", "ldb_di1_sel", 2, 7);
  447. clk[ldb_di1_div] = imx_clk_divider_flags("ldb_di1_div", "ldb_di1_div_3_5", MXC_CCM_CSCMR2, 11, 1, 0);
  448. clk[ldb_di1_sel] = imx_clk_mux_flags("ldb_di1_sel", MXC_CCM_CSCMR2, 9, 1,
  449. mx53_ldb_di1_sel, ARRAY_SIZE(mx53_ldb_di1_sel), CLK_SET_RATE_PARENT);
  450. clk[di_pll4_podf] = imx_clk_divider("di_pll4_podf", "pll4_sw", MXC_CCM_CDCDR, 16, 3);
  451. clk[ldb_di0_div_3_5] = imx_clk_fixed_factor("ldb_di0_div_3_5", "ldb_di0_sel", 2, 7);
  452. clk[ldb_di0_div] = imx_clk_divider_flags("ldb_di0_div", "ldb_di0_div_3_5", MXC_CCM_CSCMR2, 10, 1, 0);
  453. clk[ldb_di0_sel] = imx_clk_mux_flags("ldb_di0_sel", MXC_CCM_CSCMR2, 8, 1,
  454. mx53_ldb_di0_sel, ARRAY_SIZE(mx53_ldb_di0_sel), CLK_SET_RATE_PARENT);
  455. clk[ldb_di0_gate] = imx_clk_gate2("ldb_di0_gate", "ldb_di0_div", MXC_CCM_CCGR6, 28);
  456. clk[ldb_di1_gate] = imx_clk_gate2("ldb_di1_gate", "ldb_di1_div", MXC_CCM_CCGR6, 30);
  457. clk[ipu_di0_sel] = imx_clk_mux("ipu_di0_sel", MXC_CCM_CSCMR2, 26, 3,
  458. mx53_ipu_di0_sel, ARRAY_SIZE(mx53_ipu_di0_sel));
  459. clk[ipu_di1_sel] = imx_clk_mux("ipu_di1_sel", MXC_CCM_CSCMR2, 29, 3,
  460. mx53_ipu_di1_sel, ARRAY_SIZE(mx53_ipu_di1_sel));
  461. clk[tve_ext_sel] = imx_clk_mux_flags("tve_ext_sel", MXC_CCM_CSCMR1, 6, 1,
  462. mx53_tve_ext_sel, ARRAY_SIZE(mx53_tve_ext_sel), CLK_SET_RATE_PARENT);
  463. clk[tve_gate] = imx_clk_gate2("tve_gate", "tve_pred", MXC_CCM_CCGR2, 30);
  464. clk[tve_pred] = imx_clk_divider("tve_pred", "tve_ext_sel", MXC_CCM_CDCDR, 28, 3);
  465. clk[esdhc1_per_gate] = imx_clk_gate2("esdhc1_per_gate", "esdhc_a_podf", MXC_CCM_CCGR3, 2);
  466. clk[esdhc2_per_gate] = imx_clk_gate2("esdhc2_per_gate", "esdhc_c_sel", MXC_CCM_CCGR3, 6);
  467. clk[esdhc3_per_gate] = imx_clk_gate2("esdhc3_per_gate", "esdhc_b_podf", MXC_CCM_CCGR3, 10);
  468. clk[esdhc4_per_gate] = imx_clk_gate2("esdhc4_per_gate", "esdhc_d_sel", MXC_CCM_CCGR3, 14);
  469. clk[usb_phy1_gate] = imx_clk_gate2("usb_phy1_gate", "usb_phy_sel", MXC_CCM_CCGR4, 10);
  470. clk[usb_phy2_gate] = imx_clk_gate2("usb_phy2_gate", "usb_phy_sel", MXC_CCM_CCGR4, 12);
  471. clk[can_sel] = imx_clk_mux("can_sel", MXC_CCM_CSCMR2, 6, 2,
  472. mx53_can_sel, ARRAY_SIZE(mx53_can_sel));
  473. clk[can1_serial_gate] = imx_clk_gate2("can1_serial_gate", "can_sel", MXC_CCM_CCGR6, 22);
  474. clk[can1_ipg_gate] = imx_clk_gate2("can1_ipg_gate", "ipg", MXC_CCM_CCGR6, 20);
  475. clk[can2_serial_gate] = imx_clk_gate2("can2_serial_gate", "can_sel", MXC_CCM_CCGR4, 8);
  476. clk[can2_ipg_gate] = imx_clk_gate2("can2_ipg_gate", "ipg", MXC_CCM_CCGR4, 6);
  477. clk[i2c3_gate] = imx_clk_gate2("i2c3_gate", "per_root", MXC_CCM_CCGR1, 22);
  478. clk[sata_gate] = imx_clk_gate2("sata_gate", "ipg", MXC_CCM_CCGR4, 2);
  479. clk[cko1_sel] = imx_clk_mux("cko1_sel", MXC_CCM_CCOSR, 0, 4,
  480. mx53_cko1_sel, ARRAY_SIZE(mx53_cko1_sel));
  481. clk[cko1_podf] = imx_clk_divider("cko1_podf", "cko1_sel", MXC_CCM_CCOSR, 4, 3);
  482. clk[cko1] = imx_clk_gate2("cko1", "cko1_podf", MXC_CCM_CCOSR, 7);
  483. clk[cko2_sel] = imx_clk_mux("cko2_sel", MXC_CCM_CCOSR, 16, 5,
  484. mx53_cko2_sel, ARRAY_SIZE(mx53_cko2_sel));
  485. clk[cko2_podf] = imx_clk_divider("cko2_podf", "cko2_sel", MXC_CCM_CCOSR, 21, 3);
  486. clk[cko2] = imx_clk_gate2("cko2", "cko2_podf", MXC_CCM_CCOSR, 24);
  487. clk[spdif_xtal_sel] = imx_clk_mux("spdif_xtal_sel", MXC_CCM_CSCMR1, 2, 2,
  488. mx53_spdif_xtal_sel, ARRAY_SIZE(mx53_spdif_xtal_sel));
  489. for (i = 0; i < ARRAY_SIZE(clk); i++)
  490. if (IS_ERR(clk[i]))
  491. pr_err("i.MX53 clk %d: register failed with %ld\n",
  492. i, PTR_ERR(clk[i]));
  493. np = of_find_compatible_node(NULL, NULL, "fsl,imx53-ccm");
  494. clk_data.clks = clk;
  495. clk_data.clk_num = ARRAY_SIZE(clk);
  496. of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data);
  497. mx5_clocks_common_init(rate_ckil, rate_osc, rate_ckih1, rate_ckih2);
  498. clk_register_clkdev(clk[vpu_gate], NULL, "imx53-vpu.0");
  499. clk_register_clkdev(clk[i2c3_gate], NULL, "imx21-i2c.2");
  500. clk_register_clkdev(clk[fec_gate], NULL, "imx25-fec.0");
  501. clk_register_clkdev(clk[usb_phy1_gate], "usb_phy1", "mxc-ehci.0");
  502. clk_register_clkdev(clk[esdhc1_ipg_gate], "ipg", "sdhci-esdhc-imx53.0");
  503. clk_register_clkdev(clk[dummy], "ahb", "sdhci-esdhc-imx53.0");
  504. clk_register_clkdev(clk[esdhc1_per_gate], "per", "sdhci-esdhc-imx53.0");
  505. clk_register_clkdev(clk[esdhc2_ipg_gate], "ipg", "sdhci-esdhc-imx53.1");
  506. clk_register_clkdev(clk[dummy], "ahb", "sdhci-esdhc-imx53.1");
  507. clk_register_clkdev(clk[esdhc2_per_gate], "per", "sdhci-esdhc-imx53.1");
  508. clk_register_clkdev(clk[esdhc3_ipg_gate], "ipg", "sdhci-esdhc-imx53.2");
  509. clk_register_clkdev(clk[dummy], "ahb", "sdhci-esdhc-imx53.2");
  510. clk_register_clkdev(clk[esdhc3_per_gate], "per", "sdhci-esdhc-imx53.2");
  511. clk_register_clkdev(clk[esdhc4_ipg_gate], "ipg", "sdhci-esdhc-imx53.3");
  512. clk_register_clkdev(clk[dummy], "ahb", "sdhci-esdhc-imx53.3");
  513. clk_register_clkdev(clk[esdhc4_per_gate], "per", "sdhci-esdhc-imx53.3");
  514. /* set SDHC root clock to 200MHZ*/
  515. clk_set_rate(clk[esdhc_a_podf], 200000000);
  516. clk_set_rate(clk[esdhc_b_podf], 200000000);
  517. /* System timer */
  518. mxc_timer_init(MX53_IO_ADDRESS(MX53_GPT1_BASE_ADDR), MX53_INT_GPT);
  519. clk_prepare_enable(clk[iim_gate]);
  520. imx_print_silicon_rev("i.MX53", mx53_revision());
  521. clk_disable_unprepare(clk[iim_gate]);
  522. r = clk_round_rate(clk[usboh3_per_gate], 54000000);
  523. clk_set_rate(clk[usboh3_per_gate], r);
  524. return 0;
  525. }
  526. int __init mx51_clocks_init_dt(void)
  527. {
  528. return mx51_clocks_init(0, 0, 0, 0);
  529. }
  530. int __init mx53_clocks_init_dt(void)
  531. {
  532. return mx53_clocks_init(0, 0, 0, 0);
  533. }