clk-imx51-imx53.c 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  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 <mach/hardware.h>
  17. #include <mach/common.h>
  18. #include "crm-regs-imx5.h"
  19. #include "clk.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 *emi_slow_sel[] = { "main_bus", "ahb", };
  31. static const char *usb_phy_sel_str[] = { "osc", "usb_phy_podf", };
  32. static const char *mx51_ipu_di0_sel[] = { "di_pred", "osc", "ckih1", "tve_di", };
  33. static const char *mx53_ipu_di0_sel[] = { "di_pred", "osc", "ckih1", "di_pll4_podf", "dummy", "ldb_di0", };
  34. static const char *mx53_ldb_di0_sel[] = { "pll3_sw", "pll4_sw", };
  35. static const char *mx51_ipu_di1_sel[] = { "di_pred", "osc", "ckih1", "tve_di", "ipp_di1", };
  36. static const char *mx53_ipu_di1_sel[] = { "di_pred", "osc", "ckih1", "tve_di", "ipp_di1", "ldb_di1", };
  37. static const char *mx53_ldb_di1_sel[] = { "pll3_sw", "pll4_sw", };
  38. static const char *mx51_tve_ext_sel[] = { "osc", "ckih1", };
  39. static const char *mx53_tve_ext_sel[] = { "pll4_sw", "ckih1", };
  40. static const char *tve_sel[] = { "tve_pred", "tve_ext_sel", };
  41. static const char *ipu_sel[] = { "axi_a", "axi_b", "emi_slow_gate", "ahb", };
  42. static const char *vpu_sel[] = { "axi_a", "axi_b", "emi_slow_gate", "ahb", };
  43. enum imx5_clks {
  44. dummy, ckil, osc, ckih1, ckih2, ahb, ipg, axi_a, axi_b, uart_pred,
  45. uart_root, esdhc_a_pred, esdhc_b_pred, esdhc_c_s, esdhc_d_s,
  46. emi_sel, emi_slow_podf, nfc_podf, ecspi_pred, ecspi_podf, usboh3_pred,
  47. usboh3_podf, usb_phy_pred, usb_phy_podf, cpu_podf, di_pred, tve_di,
  48. tve_s, uart1_ipg_gate, uart1_per_gate, uart2_ipg_gate,
  49. uart2_per_gate, uart3_ipg_gate, uart3_per_gate, i2c1_gate, i2c2_gate,
  50. gpt_ipg_gate, pwm1_ipg_gate, pwm1_hf_gate, pwm2_ipg_gate, pwm2_hf_gate,
  51. gpt_gate, fec_gate, usboh3_per_gate, esdhc1_ipg_gate, esdhc2_ipg_gate,
  52. esdhc3_ipg_gate, esdhc4_ipg_gate, ssi1_ipg_gate, ssi2_ipg_gate,
  53. ssi3_ipg_gate, ecspi1_ipg_gate, ecspi1_per_gate, ecspi2_ipg_gate,
  54. ecspi2_per_gate, cspi_ipg_gate, sdma_gate, emi_slow_gate, ipu_s,
  55. ipu_gate, nfc_gate, ipu_di1_gate, vpu_s, vpu_gate,
  56. vpu_reference_gate, uart4_ipg_gate, uart4_per_gate, uart5_ipg_gate,
  57. uart5_per_gate, tve_gate, tve_pred, esdhc1_per_gate, esdhc2_per_gate,
  58. esdhc3_per_gate, esdhc4_per_gate, usb_phy_gate, hsi2c_gate,
  59. mipi_hsc1_gate, mipi_hsc2_gate, mipi_esc_gate, mipi_hsp_gate,
  60. ldb_di1_div_3_5, ldb_di1_div, ldb_di0_div_3_5, ldb_di0_div,
  61. ldb_di1_gate, can2_serial_gate, can2_ipg_gate, i2c3_gate, lp_apm,
  62. periph_apm, main_bus, ahb_max, aips_tz1, aips_tz2, tmax1, tmax2,
  63. tmax3, spba, uart_sel, esdhc_a_sel, esdhc_b_sel, esdhc_a_podf,
  64. esdhc_b_podf, ecspi_sel, usboh3_sel, usb_phy_sel, iim_gate,
  65. usboh3_gate, emi_fast_gate, ipu_di0_gate,gpc_dvfs, pll1_sw, pll2_sw,
  66. pll3_sw, ipu_di0_sel, ipu_di1_sel, tve_ext_sel, mx51_mipi, pll4_sw,
  67. ldb_di1_sel, di_pll4_podf, ldb_di0_sel, ldb_di0_gate, usb_phy1_gate,
  68. usb_phy2_gate, per_lp_apm, per_pred1, per_pred2, per_podf, per_root,
  69. clk_max
  70. };
  71. static struct clk *clk[clk_max];
  72. static void __init mx5_clocks_common_init(unsigned long rate_ckil,
  73. unsigned long rate_osc, unsigned long rate_ckih1,
  74. unsigned long rate_ckih2)
  75. {
  76. int i;
  77. clk[dummy] = imx_clk_fixed("dummy", 0);
  78. clk[ckil] = imx_clk_fixed("ckil", rate_ckil);
  79. clk[osc] = imx_clk_fixed("osc", rate_osc);
  80. clk[ckih1] = imx_clk_fixed("ckih1", rate_ckih1);
  81. clk[ckih2] = imx_clk_fixed("ckih2", rate_ckih2);
  82. clk[lp_apm] = imx_clk_mux("lp_apm", MXC_CCM_CCSR, 9, 1,
  83. lp_apm_sel, ARRAY_SIZE(lp_apm_sel));
  84. clk[periph_apm] = imx_clk_mux("periph_apm", MXC_CCM_CBCMR, 12, 2,
  85. periph_apm_sel, ARRAY_SIZE(periph_apm_sel));
  86. clk[main_bus] = imx_clk_mux("main_bus", MXC_CCM_CBCDR, 25, 1,
  87. main_bus_sel, ARRAY_SIZE(main_bus_sel));
  88. clk[per_lp_apm] = imx_clk_mux("per_lp_apm", MXC_CCM_CBCMR, 1, 1,
  89. per_lp_apm_sel, ARRAY_SIZE(per_lp_apm_sel));
  90. clk[per_pred1] = imx_clk_divider("per_pred1", "per_lp_apm", MXC_CCM_CBCDR, 6, 2);
  91. clk[per_pred2] = imx_clk_divider("per_pred2", "per_pred1", MXC_CCM_CBCDR, 3, 3);
  92. clk[per_podf] = imx_clk_divider("per_podf", "per_pred2", MXC_CCM_CBCDR, 0, 3);
  93. clk[per_root] = imx_clk_mux("per_root", MXC_CCM_CBCMR, 0, 1,
  94. per_root_sel, ARRAY_SIZE(per_root_sel));
  95. clk[ahb] = imx_clk_divider("ahb", "main_bus", MXC_CCM_CBCDR, 10, 3);
  96. clk[ahb_max] = imx_clk_gate2("ahb_max", "ahb", MXC_CCM_CCGR0, 28);
  97. clk[aips_tz1] = imx_clk_gate2("aips_tz1", "ahb", MXC_CCM_CCGR0, 24);
  98. clk[aips_tz2] = imx_clk_gate2("aips_tz2", "ahb", MXC_CCM_CCGR0, 26);
  99. clk[tmax1] = imx_clk_gate2("tmax1", "ahb", MXC_CCM_CCGR1, 0);
  100. clk[tmax2] = imx_clk_gate2("tmax2", "ahb", MXC_CCM_CCGR1, 2);
  101. clk[tmax3] = imx_clk_gate2("tmax3", "ahb", MXC_CCM_CCGR1, 4);
  102. clk[spba] = imx_clk_gate2("spba", "ipg", MXC_CCM_CCGR5, 0);
  103. clk[ipg] = imx_clk_divider("ipg", "ahb", MXC_CCM_CBCDR, 8, 2);
  104. clk[axi_a] = imx_clk_divider("axi_a", "main_bus", MXC_CCM_CBCDR, 16, 3);
  105. clk[axi_b] = imx_clk_divider("axi_b", "main_bus", MXC_CCM_CBCDR, 19, 3);
  106. clk[uart_sel] = imx_clk_mux("uart_sel", MXC_CCM_CSCMR1, 24, 2,
  107. standard_pll_sel, ARRAY_SIZE(standard_pll_sel));
  108. clk[uart_pred] = imx_clk_divider("uart_pred", "uart_sel", MXC_CCM_CSCDR1, 3, 3);
  109. clk[uart_root] = imx_clk_divider("uart_root", "uart_pred", MXC_CCM_CSCDR1, 0, 3);
  110. clk[esdhc_a_sel] = imx_clk_mux("esdhc_a_sel", MXC_CCM_CSCMR1, 20, 2,
  111. standard_pll_sel, ARRAY_SIZE(standard_pll_sel));
  112. clk[esdhc_b_sel] = imx_clk_mux("esdhc_b_sel", MXC_CCM_CSCMR1, 16, 2,
  113. standard_pll_sel, ARRAY_SIZE(standard_pll_sel));
  114. clk[esdhc_a_pred] = imx_clk_divider("esdhc_a_pred", "esdhc_a_sel", MXC_CCM_CSCDR1, 16, 3);
  115. clk[esdhc_a_podf] = imx_clk_divider("esdhc_a_podf", "esdhc_a_pred", MXC_CCM_CSCDR1, 11, 3);
  116. clk[esdhc_b_pred] = imx_clk_divider("esdhc_b_pred", "esdhc_b_sel", MXC_CCM_CSCDR1, 22, 3);
  117. clk[esdhc_b_podf] = imx_clk_divider("esdhc_b_podf", "esdhc_b_pred", MXC_CCM_CSCDR1, 19, 3);
  118. clk[esdhc_c_s] = imx_clk_mux("esdhc_c_sel", MXC_CCM_CSCMR1, 19, 1, esdhc_c_sel, ARRAY_SIZE(esdhc_c_sel));
  119. clk[esdhc_d_s] = imx_clk_mux("esdhc_d_sel", MXC_CCM_CSCMR1, 18, 1, esdhc_d_sel, ARRAY_SIZE(esdhc_d_sel));
  120. clk[emi_sel] = imx_clk_mux("emi_sel", MXC_CCM_CBCDR, 26, 1,
  121. emi_slow_sel, ARRAY_SIZE(emi_slow_sel));
  122. clk[emi_slow_podf] = imx_clk_divider("emi_slow_podf", "emi_sel", MXC_CCM_CBCDR, 22, 3);
  123. clk[nfc_podf] = imx_clk_divider("nfc_podf", "emi_slow_podf", MXC_CCM_CBCDR, 13, 3);
  124. clk[ecspi_sel] = imx_clk_mux("ecspi_sel", MXC_CCM_CSCMR1, 4, 2,
  125. standard_pll_sel, ARRAY_SIZE(standard_pll_sel));
  126. clk[ecspi_pred] = imx_clk_divider("ecspi_pred", "ecspi_sel", MXC_CCM_CSCDR2, 25, 3);
  127. clk[ecspi_podf] = imx_clk_divider("ecspi_podf", "ecspi_pred", MXC_CCM_CSCDR2, 19, 6);
  128. clk[usboh3_sel] = imx_clk_mux("usboh3_sel", MXC_CCM_CSCMR1, 22, 2,
  129. standard_pll_sel, ARRAY_SIZE(standard_pll_sel));
  130. clk[usboh3_pred] = imx_clk_divider("usboh3_pred", "usboh3_sel", MXC_CCM_CSCDR1, 8, 3);
  131. clk[usboh3_podf] = imx_clk_divider("usboh3_podf", "usboh3_pred", MXC_CCM_CSCDR1, 6, 2);
  132. clk[usb_phy_pred] = imx_clk_divider("usb_phy_pred", "pll3_sw", MXC_CCM_CDCDR, 3, 3);
  133. clk[usb_phy_podf] = imx_clk_divider("usb_phy_podf", "usb_phy_pred", MXC_CCM_CDCDR, 0, 3);
  134. clk[usb_phy_sel] = imx_clk_mux("usb_phy_sel", MXC_CCM_CSCMR1, 26, 1,
  135. usb_phy_sel_str, ARRAY_SIZE(usb_phy_sel_str));
  136. clk[cpu_podf] = imx_clk_divider("cpu_podf", "pll1_sw", MXC_CCM_CACRR, 0, 3);
  137. clk[di_pred] = imx_clk_divider("di_pred", "pll3_sw", MXC_CCM_CDCDR, 6, 3);
  138. clk[tve_di] = imx_clk_fixed("tve_di", 65000000); /* FIXME */
  139. clk[tve_s] = imx_clk_mux("tve_sel", MXC_CCM_CSCMR1, 7, 1, tve_sel, ARRAY_SIZE(tve_sel));
  140. clk[iim_gate] = imx_clk_gate2("iim_gate", "ipg", MXC_CCM_CCGR0, 30);
  141. clk[uart1_ipg_gate] = imx_clk_gate2("uart1_ipg_gate", "ipg", MXC_CCM_CCGR1, 6);
  142. clk[uart1_per_gate] = imx_clk_gate2("uart1_per_gate", "uart_root", MXC_CCM_CCGR1, 8);
  143. clk[uart2_ipg_gate] = imx_clk_gate2("uart2_ipg_gate", "ipg", MXC_CCM_CCGR1, 10);
  144. clk[uart2_per_gate] = imx_clk_gate2("uart2_per_gate", "uart_root", MXC_CCM_CCGR1, 12);
  145. clk[uart3_ipg_gate] = imx_clk_gate2("uart3_ipg_gate", "ipg", MXC_CCM_CCGR1, 14);
  146. clk[uart3_per_gate] = imx_clk_gate2("uart3_per_gate", "uart_root", MXC_CCM_CCGR1, 16);
  147. clk[i2c1_gate] = imx_clk_gate2("i2c1_gate", "per_root", MXC_CCM_CCGR1, 18);
  148. clk[i2c2_gate] = imx_clk_gate2("i2c2_gate", "per_root", MXC_CCM_CCGR1, 20);
  149. clk[gpt_ipg_gate] = imx_clk_gate2("gpt_ipg_gate", "ipg", MXC_CCM_CCGR2, 20);
  150. clk[pwm1_ipg_gate] = imx_clk_gate2("pwm1_ipg_gate", "ipg", MXC_CCM_CCGR2, 10);
  151. clk[pwm1_hf_gate] = imx_clk_gate2("pwm1_hf_gate", "ipg", MXC_CCM_CCGR2, 12);
  152. clk[pwm2_ipg_gate] = imx_clk_gate2("pwm2_ipg_gate", "ipg", MXC_CCM_CCGR2, 14);
  153. clk[pwm2_hf_gate] = imx_clk_gate2("pwm2_hf_gate", "ipg", MXC_CCM_CCGR2, 16);
  154. clk[gpt_gate] = imx_clk_gate2("gpt_gate", "per_root", MXC_CCM_CCGR2, 18);
  155. clk[fec_gate] = imx_clk_gate2("fec_gate", "ipg", MXC_CCM_CCGR2, 24);
  156. clk[usboh3_gate] = imx_clk_gate2("usboh3_gate", "ipg", MXC_CCM_CCGR2, 26);
  157. clk[usboh3_per_gate] = imx_clk_gate2("usboh3_per_gate", "usboh3_podf", MXC_CCM_CCGR2, 28);
  158. clk[esdhc1_ipg_gate] = imx_clk_gate2("esdhc1_ipg_gate", "ipg", MXC_CCM_CCGR3, 0);
  159. clk[esdhc2_ipg_gate] = imx_clk_gate2("esdhc2_ipg_gate", "ipg", MXC_CCM_CCGR3, 4);
  160. clk[esdhc3_ipg_gate] = imx_clk_gate2("esdhc3_ipg_gate", "ipg", MXC_CCM_CCGR3, 8);
  161. clk[esdhc4_ipg_gate] = imx_clk_gate2("esdhc4_ipg_gate", "ipg", MXC_CCM_CCGR3, 12);
  162. clk[ssi1_ipg_gate] = imx_clk_gate2("ssi1_ipg_gate", "ipg", MXC_CCM_CCGR3, 16);
  163. clk[ssi2_ipg_gate] = imx_clk_gate2("ssi2_ipg_gate", "ipg", MXC_CCM_CCGR3, 20);
  164. clk[ssi3_ipg_gate] = imx_clk_gate2("ssi3_ipg_gate", "ipg", MXC_CCM_CCGR3, 24);
  165. clk[ecspi1_ipg_gate] = imx_clk_gate2("ecspi1_ipg_gate", "ipg", MXC_CCM_CCGR4, 18);
  166. clk[ecspi1_per_gate] = imx_clk_gate2("ecspi1_per_gate", "ecspi_podf", MXC_CCM_CCGR4, 20);
  167. clk[ecspi2_ipg_gate] = imx_clk_gate2("ecspi2_ipg_gate", "ipg", MXC_CCM_CCGR4, 22);
  168. clk[ecspi2_per_gate] = imx_clk_gate2("ecspi2_per_gate", "ecspi_podf", MXC_CCM_CCGR4, 24);
  169. clk[cspi_ipg_gate] = imx_clk_gate2("cspi_ipg_gate", "ipg", MXC_CCM_CCGR4, 26);
  170. clk[sdma_gate] = imx_clk_gate2("sdma_gate", "ipg", MXC_CCM_CCGR4, 30);
  171. clk[emi_fast_gate] = imx_clk_gate2("emi_fast_gate", "dummy", MXC_CCM_CCGR5, 14);
  172. clk[emi_slow_gate] = imx_clk_gate2("emi_slow_gate", "emi_slow_podf", MXC_CCM_CCGR5, 16);
  173. clk[ipu_s] = imx_clk_mux("ipu_sel", MXC_CCM_CBCMR, 6, 2, ipu_sel, ARRAY_SIZE(ipu_sel));
  174. clk[ipu_gate] = imx_clk_gate2("ipu_gate", "ipu_sel", MXC_CCM_CCGR5, 10);
  175. clk[nfc_gate] = imx_clk_gate2("nfc_gate", "nfc_podf", MXC_CCM_CCGR5, 20);
  176. clk[ipu_di0_gate] = imx_clk_gate2("ipu_di0_gate", "ipu_di0_sel", MXC_CCM_CCGR6, 10);
  177. clk[ipu_di1_gate] = imx_clk_gate2("ipu_di1_gate", "ipu_di1_sel", MXC_CCM_CCGR6, 12);
  178. clk[vpu_s] = imx_clk_mux("vpu_sel", MXC_CCM_CBCMR, 14, 2, vpu_sel, ARRAY_SIZE(vpu_sel));
  179. clk[vpu_gate] = imx_clk_gate2("vpu_gate", "vpu_sel", MXC_CCM_CCGR5, 6);
  180. clk[vpu_reference_gate] = imx_clk_gate2("vpu_reference_gate", "osc", MXC_CCM_CCGR5, 8);
  181. clk[uart4_ipg_gate] = imx_clk_gate2("uart4_ipg_gate", "ipg", MXC_CCM_CCGR7, 8);
  182. clk[uart4_per_gate] = imx_clk_gate2("uart4_per_gate", "uart_root", MXC_CCM_CCGR7, 10);
  183. clk[uart5_ipg_gate] = imx_clk_gate2("uart5_ipg_gate", "ipg", MXC_CCM_CCGR7, 12);
  184. clk[uart5_per_gate] = imx_clk_gate2("uart5_per_gate", "uart_root", MXC_CCM_CCGR7, 14);
  185. clk[gpc_dvfs] = imx_clk_gate2("gpc_dvfs", "dummy", MXC_CCM_CCGR5, 24);
  186. for (i = 0; i < ARRAY_SIZE(clk); i++)
  187. if (IS_ERR(clk[i]))
  188. pr_err("i.MX5 clk %d: register failed with %ld\n",
  189. i, PTR_ERR(clk[i]));
  190. clk_register_clkdev(clk[gpt_gate], "per", "imx-gpt.0");
  191. clk_register_clkdev(clk[gpt_ipg_gate], "ipg", "imx-gpt.0");
  192. clk_register_clkdev(clk[uart1_per_gate], "per", "imx21-uart.0");
  193. clk_register_clkdev(clk[uart1_ipg_gate], "ipg", "imx21-uart.0");
  194. clk_register_clkdev(clk[uart2_per_gate], "per", "imx21-uart.1");
  195. clk_register_clkdev(clk[uart2_ipg_gate], "ipg", "imx21-uart.1");
  196. clk_register_clkdev(clk[uart3_per_gate], "per", "imx21-uart.2");
  197. clk_register_clkdev(clk[uart3_ipg_gate], "ipg", "imx21-uart.2");
  198. clk_register_clkdev(clk[uart4_per_gate], "per", "imx21-uart.3");
  199. clk_register_clkdev(clk[uart4_ipg_gate], "ipg", "imx21-uart.3");
  200. clk_register_clkdev(clk[uart5_per_gate], "per", "imx21-uart.4");
  201. clk_register_clkdev(clk[uart5_ipg_gate], "ipg", "imx21-uart.4");
  202. clk_register_clkdev(clk[ecspi1_per_gate], "per", "imx51-ecspi.0");
  203. clk_register_clkdev(clk[ecspi1_ipg_gate], "ipg", "imx51-ecspi.0");
  204. clk_register_clkdev(clk[ecspi2_per_gate], "per", "imx51-ecspi.1");
  205. clk_register_clkdev(clk[ecspi2_ipg_gate], "ipg", "imx51-ecspi.1");
  206. clk_register_clkdev(clk[cspi_ipg_gate], NULL, "imx51-cspi.0");
  207. clk_register_clkdev(clk[pwm1_ipg_gate], "pwm", "mxc_pwm.0");
  208. clk_register_clkdev(clk[pwm2_ipg_gate], "pwm", "mxc_pwm.1");
  209. clk_register_clkdev(clk[i2c1_gate], NULL, "imx-i2c.0");
  210. clk_register_clkdev(clk[i2c2_gate], NULL, "imx-i2c.1");
  211. clk_register_clkdev(clk[usboh3_per_gate], "per", "mxc-ehci.0");
  212. clk_register_clkdev(clk[usboh3_gate], "ipg", "mxc-ehci.0");
  213. clk_register_clkdev(clk[usboh3_gate], "ahb", "mxc-ehci.0");
  214. clk_register_clkdev(clk[usboh3_per_gate], "per", "mxc-ehci.1");
  215. clk_register_clkdev(clk[usboh3_gate], "ipg", "mxc-ehci.1");
  216. clk_register_clkdev(clk[usboh3_gate], "ahb", "mxc-ehci.1");
  217. clk_register_clkdev(clk[usboh3_per_gate], "per", "mxc-ehci.2");
  218. clk_register_clkdev(clk[usboh3_gate], "ipg", "mxc-ehci.2");
  219. clk_register_clkdev(clk[usboh3_gate], "ahb", "mxc-ehci.2");
  220. clk_register_clkdev(clk[usboh3_per_gate], "per", "fsl-usb2-udc");
  221. clk_register_clkdev(clk[usboh3_gate], "ipg", "fsl-usb2-udc");
  222. clk_register_clkdev(clk[usboh3_gate], "ahb", "fsl-usb2-udc");
  223. clk_register_clkdev(clk[nfc_gate], NULL, "mxc_nand");
  224. clk_register_clkdev(clk[ssi1_ipg_gate], NULL, "imx-ssi.0");
  225. clk_register_clkdev(clk[ssi2_ipg_gate], NULL, "imx-ssi.1");
  226. clk_register_clkdev(clk[ssi3_ipg_gate], NULL, "imx-ssi.2");
  227. clk_register_clkdev(clk[sdma_gate], NULL, "imx35-sdma");
  228. clk_register_clkdev(clk[cpu_podf], "cpu", NULL);
  229. clk_register_clkdev(clk[iim_gate], "iim", NULL);
  230. clk_register_clkdev(clk[dummy], NULL, "imx2-wdt.0");
  231. clk_register_clkdev(clk[dummy], NULL, "imx2-wdt.1");
  232. clk_register_clkdev(clk[dummy], NULL, "imx-keypad");
  233. clk_register_clkdev(clk[tve_gate], NULL, "imx-tve.0");
  234. clk_register_clkdev(clk[ipu_di1_gate], "di1", "imx-tve.0");
  235. /* Set SDHC parents to be PLL2 */
  236. clk_set_parent(clk[esdhc_a_sel], clk[pll2_sw]);
  237. clk_set_parent(clk[esdhc_b_sel], clk[pll2_sw]);
  238. /* move usb phy clk to 24MHz */
  239. clk_set_parent(clk[usb_phy_sel], clk[osc]);
  240. clk_prepare_enable(clk[gpc_dvfs]);
  241. clk_prepare_enable(clk[ahb_max]); /* esdhc3 */
  242. clk_prepare_enable(clk[aips_tz1]);
  243. clk_prepare_enable(clk[aips_tz2]); /* fec */
  244. clk_prepare_enable(clk[spba]);
  245. clk_prepare_enable(clk[emi_fast_gate]); /* fec */
  246. clk_prepare_enable(clk[tmax1]);
  247. clk_prepare_enable(clk[tmax2]); /* esdhc2, fec */
  248. clk_prepare_enable(clk[tmax3]); /* esdhc1, esdhc4 */
  249. }
  250. int __init mx51_clocks_init(unsigned long rate_ckil, unsigned long rate_osc,
  251. unsigned long rate_ckih1, unsigned long rate_ckih2)
  252. {
  253. int i;
  254. clk[pll1_sw] = imx_clk_pllv2("pll1_sw", "osc", MX51_DPLL1_BASE);
  255. clk[pll2_sw] = imx_clk_pllv2("pll2_sw", "osc", MX51_DPLL2_BASE);
  256. clk[pll3_sw] = imx_clk_pllv2("pll3_sw", "osc", MX51_DPLL3_BASE);
  257. clk[ipu_di0_sel] = imx_clk_mux("ipu_di0_sel", MXC_CCM_CSCMR2, 26, 3,
  258. mx51_ipu_di0_sel, ARRAY_SIZE(mx51_ipu_di0_sel));
  259. clk[ipu_di1_sel] = imx_clk_mux("ipu_di1_sel", MXC_CCM_CSCMR2, 29, 3,
  260. mx51_ipu_di1_sel, ARRAY_SIZE(mx51_ipu_di1_sel));
  261. clk[tve_ext_sel] = imx_clk_mux("tve_ext_sel", MXC_CCM_CSCMR1, 6, 1,
  262. mx51_tve_ext_sel, ARRAY_SIZE(mx51_tve_ext_sel));
  263. clk[tve_gate] = imx_clk_gate2("tve_gate", "tve_sel", MXC_CCM_CCGR2, 30);
  264. clk[tve_pred] = imx_clk_divider("tve_pred", "pll3_sw", MXC_CCM_CDCDR, 28, 3);
  265. clk[esdhc1_per_gate] = imx_clk_gate2("esdhc1_per_gate", "esdhc_a_podf", MXC_CCM_CCGR3, 2);
  266. clk[esdhc2_per_gate] = imx_clk_gate2("esdhc2_per_gate", "esdhc_b_podf", MXC_CCM_CCGR3, 6);
  267. clk[esdhc3_per_gate] = imx_clk_gate2("esdhc3_per_gate", "esdhc_c_sel", MXC_CCM_CCGR3, 10);
  268. clk[esdhc4_per_gate] = imx_clk_gate2("esdhc4_per_gate", "esdhc_d_sel", MXC_CCM_CCGR3, 14);
  269. clk[usb_phy_gate] = imx_clk_gate2("usb_phy_gate", "usb_phy_sel", MXC_CCM_CCGR2, 0);
  270. clk[hsi2c_gate] = imx_clk_gate2("hsi2c_gate", "ipg", MXC_CCM_CCGR1, 22);
  271. clk[mipi_hsc1_gate] = imx_clk_gate2("mipi_hsc1_gate", "ipg", MXC_CCM_CCGR4, 6);
  272. clk[mipi_hsc2_gate] = imx_clk_gate2("mipi_hsc2_gate", "ipg", MXC_CCM_CCGR4, 8);
  273. clk[mipi_esc_gate] = imx_clk_gate2("mipi_esc_gate", "ipg", MXC_CCM_CCGR4, 10);
  274. clk[mipi_hsp_gate] = imx_clk_gate2("mipi_hsp_gate", "ipg", MXC_CCM_CCGR4, 12);
  275. for (i = 0; i < ARRAY_SIZE(clk); i++)
  276. if (IS_ERR(clk[i]))
  277. pr_err("i.MX51 clk %d: register failed with %ld\n",
  278. i, PTR_ERR(clk[i]));
  279. mx5_clocks_common_init(rate_ckil, rate_osc, rate_ckih1, rate_ckih2);
  280. clk_register_clkdev(clk[hsi2c_gate], NULL, "imx-i2c.2");
  281. clk_register_clkdev(clk[mx51_mipi], "mipi_hsp", NULL);
  282. clk_register_clkdev(clk[vpu_gate], NULL, "imx51-vpu.0");
  283. clk_register_clkdev(clk[fec_gate], NULL, "imx27-fec.0");
  284. clk_register_clkdev(clk[gpc_dvfs], "gpc_dvfs", NULL);
  285. clk_register_clkdev(clk[ipu_gate], "bus", "imx51-ipu");
  286. clk_register_clkdev(clk[ipu_di0_gate], "di0", "imx51-ipu");
  287. clk_register_clkdev(clk[ipu_di1_gate], "di1", "imx51-ipu");
  288. clk_register_clkdev(clk[ipu_gate], "hsp", "imx51-ipu");
  289. clk_register_clkdev(clk[usb_phy_gate], "phy", "mxc-ehci.0");
  290. clk_register_clkdev(clk[esdhc1_ipg_gate], "ipg", "sdhci-esdhc-imx51.0");
  291. clk_register_clkdev(clk[dummy], "ahb", "sdhci-esdhc-imx51.0");
  292. clk_register_clkdev(clk[esdhc1_per_gate], "per", "sdhci-esdhc-imx51.0");
  293. clk_register_clkdev(clk[esdhc2_ipg_gate], "ipg", "sdhci-esdhc-imx51.1");
  294. clk_register_clkdev(clk[dummy], "ahb", "sdhci-esdhc-imx51.1");
  295. clk_register_clkdev(clk[esdhc2_per_gate], "per", "sdhci-esdhc-imx51.1");
  296. clk_register_clkdev(clk[esdhc3_ipg_gate], "ipg", "sdhci-esdhc-imx51.2");
  297. clk_register_clkdev(clk[dummy], "ahb", "sdhci-esdhc-imx51.2");
  298. clk_register_clkdev(clk[esdhc3_per_gate], "per", "sdhci-esdhc-imx51.2");
  299. clk_register_clkdev(clk[esdhc4_ipg_gate], "ipg", "sdhci-esdhc-imx51.3");
  300. clk_register_clkdev(clk[dummy], "ahb", "sdhci-esdhc-imx51.3");
  301. clk_register_clkdev(clk[esdhc4_per_gate], "per", "sdhci-esdhc-imx51.3");
  302. /* set the usboh3 parent to pll2_sw */
  303. clk_set_parent(clk[usboh3_sel], clk[pll2_sw]);
  304. /* set SDHC root clock to 166.25MHZ*/
  305. clk_set_rate(clk[esdhc_a_podf], 166250000);
  306. clk_set_rate(clk[esdhc_b_podf], 166250000);
  307. /* System timer */
  308. mxc_timer_init(NULL, MX51_IO_ADDRESS(MX51_GPT1_BASE_ADDR),
  309. MX51_INT_GPT);
  310. clk_prepare_enable(clk[iim_gate]);
  311. imx_print_silicon_rev("i.MX51", mx51_revision());
  312. clk_disable_unprepare(clk[iim_gate]);
  313. return 0;
  314. }
  315. int __init mx53_clocks_init(unsigned long rate_ckil, unsigned long rate_osc,
  316. unsigned long rate_ckih1, unsigned long rate_ckih2)
  317. {
  318. int i;
  319. unsigned long r;
  320. clk[pll1_sw] = imx_clk_pllv2("pll1_sw", "osc", MX53_DPLL1_BASE);
  321. clk[pll2_sw] = imx_clk_pllv2("pll2_sw", "osc", MX53_DPLL2_BASE);
  322. clk[pll3_sw] = imx_clk_pllv2("pll3_sw", "osc", MX53_DPLL3_BASE);
  323. clk[pll4_sw] = imx_clk_pllv2("pll4_sw", "osc", MX53_DPLL4_BASE);
  324. clk[ldb_di1_sel] = imx_clk_mux("ldb_di1_sel", MXC_CCM_CSCMR2, 9, 1,
  325. mx53_ldb_di1_sel, ARRAY_SIZE(mx53_ldb_di1_sel));
  326. clk[ldb_di1_div_3_5] = imx_clk_fixed_factor("ldb_di1_div_3_5", "ldb_di1_sel", 2, 7);
  327. clk[ldb_di1_div] = imx_clk_divider("ldb_di1_div", "ldb_di1_div_3_5", MXC_CCM_CSCMR2, 11, 1);
  328. clk[di_pll4_podf] = imx_clk_divider("di_pll4_podf", "pll4_sw", MXC_CCM_CDCDR, 16, 3);
  329. clk[ldb_di0_sel] = imx_clk_mux("ldb_di0_sel", MXC_CCM_CSCMR2, 8, 1,
  330. mx53_ldb_di0_sel, ARRAY_SIZE(mx53_ldb_di0_sel));
  331. clk[ldb_di0_div_3_5] = imx_clk_fixed_factor("ldb_di0_div_3_5", "ldb_di0_sel", 2, 7);
  332. clk[ldb_di0_div] = imx_clk_divider("ldb_di0_div", "ldb_di0_div_3_5", MXC_CCM_CSCMR2, 10, 1);
  333. clk[ldb_di0_gate] = imx_clk_gate2("ldb_di0_gate", "ldb_di0_div", MXC_CCM_CCGR6, 28);
  334. clk[ldb_di1_gate] = imx_clk_gate2("ldb_di1_gate", "ldb_di1_div", MXC_CCM_CCGR6, 30);
  335. clk[ipu_di0_sel] = imx_clk_mux("ipu_di0_sel", MXC_CCM_CSCMR2, 26, 3,
  336. mx53_ipu_di0_sel, ARRAY_SIZE(mx53_ipu_di0_sel));
  337. clk[ipu_di1_sel] = imx_clk_mux("ipu_di1_sel", MXC_CCM_CSCMR2, 29, 3,
  338. mx53_ipu_di1_sel, ARRAY_SIZE(mx53_ipu_di1_sel));
  339. clk[tve_ext_sel] = imx_clk_mux("tve_ext_sel", MXC_CCM_CSCMR1, 6, 1,
  340. mx53_tve_ext_sel, ARRAY_SIZE(mx53_tve_ext_sel));
  341. clk[tve_gate] = imx_clk_gate2("tve_gate", "tve_pred", MXC_CCM_CCGR2, 30);
  342. clk[tve_pred] = imx_clk_divider("tve_pred", "tve_ext_sel", MXC_CCM_CDCDR, 28, 3);
  343. clk[esdhc1_per_gate] = imx_clk_gate2("esdhc1_per_gate", "esdhc_a_podf", MXC_CCM_CCGR3, 2);
  344. clk[esdhc2_per_gate] = imx_clk_gate2("esdhc2_per_gate", "esdhc_c_sel", MXC_CCM_CCGR3, 6);
  345. clk[esdhc3_per_gate] = imx_clk_gate2("esdhc3_per_gate", "esdhc_b_podf", MXC_CCM_CCGR3, 10);
  346. clk[esdhc4_per_gate] = imx_clk_gate2("esdhc4_per_gate", "esdhc_d_sel", MXC_CCM_CCGR3, 14);
  347. clk[usb_phy1_gate] = imx_clk_gate2("usb_phy1_gate", "usb_phy_sel", MXC_CCM_CCGR4, 10);
  348. clk[usb_phy2_gate] = imx_clk_gate2("usb_phy2_gate", "usb_phy_sel", MXC_CCM_CCGR4, 12);
  349. clk[can2_serial_gate] = imx_clk_gate2("can2_serial_gate", "ipg", MXC_CCM_CCGR4, 6);
  350. clk[can2_ipg_gate] = imx_clk_gate2("can2_ipg_gate", "ipg", MXC_CCM_CCGR4, 8);
  351. clk[i2c3_gate] = imx_clk_gate2("i2c3_gate", "per_root", MXC_CCM_CCGR1, 22);
  352. for (i = 0; i < ARRAY_SIZE(clk); i++)
  353. if (IS_ERR(clk[i]))
  354. pr_err("i.MX53 clk %d: register failed with %ld\n",
  355. i, PTR_ERR(clk[i]));
  356. mx5_clocks_common_init(rate_ckil, rate_osc, rate_ckih1, rate_ckih2);
  357. clk_register_clkdev(clk[vpu_gate], NULL, "imx53-vpu.0");
  358. clk_register_clkdev(clk[i2c3_gate], NULL, "imx-i2c.2");
  359. clk_register_clkdev(clk[fec_gate], NULL, "imx25-fec.0");
  360. clk_register_clkdev(clk[ipu_gate], "bus", "imx53-ipu");
  361. clk_register_clkdev(clk[ipu_di0_gate], "di0", "imx53-ipu");
  362. clk_register_clkdev(clk[ipu_di1_gate], "di1", "imx53-ipu");
  363. clk_register_clkdev(clk[ipu_gate], "hsp", "imx53-ipu");
  364. clk_register_clkdev(clk[usb_phy1_gate], "usb_phy1", "mxc-ehci.0");
  365. clk_register_clkdev(clk[esdhc1_ipg_gate], "ipg", "sdhci-esdhc-imx53.0");
  366. clk_register_clkdev(clk[dummy], "ahb", "sdhci-esdhc-imx53.0");
  367. clk_register_clkdev(clk[esdhc1_per_gate], "per", "sdhci-esdhc-imx53.0");
  368. clk_register_clkdev(clk[esdhc2_ipg_gate], "ipg", "sdhci-esdhc-imx53.1");
  369. clk_register_clkdev(clk[dummy], "ahb", "sdhci-esdhc-imx53.1");
  370. clk_register_clkdev(clk[esdhc2_per_gate], "per", "sdhci-esdhc-imx53.1");
  371. clk_register_clkdev(clk[esdhc3_ipg_gate], "ipg", "sdhci-esdhc-imx53.2");
  372. clk_register_clkdev(clk[dummy], "ahb", "sdhci-esdhc-imx53.2");
  373. clk_register_clkdev(clk[esdhc3_per_gate], "per", "sdhci-esdhc-imx53.2");
  374. clk_register_clkdev(clk[esdhc4_ipg_gate], "ipg", "sdhci-esdhc-imx53.3");
  375. clk_register_clkdev(clk[dummy], "ahb", "sdhci-esdhc-imx53.3");
  376. clk_register_clkdev(clk[esdhc4_per_gate], "per", "sdhci-esdhc-imx53.3");
  377. /* set SDHC root clock to 200MHZ*/
  378. clk_set_rate(clk[esdhc_a_podf], 200000000);
  379. clk_set_rate(clk[esdhc_b_podf], 200000000);
  380. /* System timer */
  381. mxc_timer_init(NULL, MX53_IO_ADDRESS(MX53_GPT1_BASE_ADDR),
  382. MX53_INT_GPT);
  383. clk_prepare_enable(clk[iim_gate]);
  384. imx_print_silicon_rev("i.MX53", mx53_revision());
  385. clk_disable_unprepare(clk[iim_gate]);
  386. r = clk_round_rate(clk[usboh3_per_gate], 54000000);
  387. clk_set_rate(clk[usboh3_per_gate], r);
  388. return 0;
  389. }
  390. #ifdef CONFIG_OF
  391. static void __init clk_get_freq_dt(unsigned long *ckil, unsigned long *osc,
  392. unsigned long *ckih1, unsigned long *ckih2)
  393. {
  394. struct device_node *np;
  395. /* retrieve the freqency of fixed clocks from device tree */
  396. for_each_compatible_node(np, NULL, "fixed-clock") {
  397. u32 rate;
  398. if (of_property_read_u32(np, "clock-frequency", &rate))
  399. continue;
  400. if (of_device_is_compatible(np, "fsl,imx-ckil"))
  401. *ckil = rate;
  402. else if (of_device_is_compatible(np, "fsl,imx-osc"))
  403. *osc = rate;
  404. else if (of_device_is_compatible(np, "fsl,imx-ckih1"))
  405. *ckih1 = rate;
  406. else if (of_device_is_compatible(np, "fsl,imx-ckih2"))
  407. *ckih2 = rate;
  408. }
  409. }
  410. int __init mx51_clocks_init_dt(void)
  411. {
  412. unsigned long ckil, osc, ckih1, ckih2;
  413. clk_get_freq_dt(&ckil, &osc, &ckih1, &ckih2);
  414. return mx51_clocks_init(ckil, osc, ckih1, ckih2);
  415. }
  416. int __init mx53_clocks_init_dt(void)
  417. {
  418. unsigned long ckil, osc, ckih1, ckih2;
  419. clk_get_freq_dt(&ckil, &osc, &ckih1, &ckih2);
  420. return mx53_clocks_init(ckil, osc, ckih1, ckih2);
  421. }
  422. #endif