clock-imx35.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. /*
  2. * Copyright (C) 2009 by Sascha Hauer, Pengutronix
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version 2
  7. * of the License, or (at your option) any later version.
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program; if not, write to the Free Software
  15. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  16. * MA 02110-1301, USA.
  17. */
  18. #include <linux/kernel.h>
  19. #include <linux/init.h>
  20. #include <linux/list.h>
  21. #include <linux/clk.h>
  22. #include <linux/io.h>
  23. #include <linux/clkdev.h>
  24. #include <mach/clock.h>
  25. #include <mach/hardware.h>
  26. #include <mach/common.h>
  27. #include "crmregs-imx3.h"
  28. #ifdef HAVE_SET_RATE_SUPPORT
  29. static void calc_dividers(u32 div, u32 *pre, u32 *post, u32 maxpost)
  30. {
  31. u32 min_pre, temp_pre, old_err, err;
  32. min_pre = (div - 1) / maxpost + 1;
  33. old_err = 8;
  34. for (temp_pre = 8; temp_pre >= min_pre; temp_pre--) {
  35. if (div > (temp_pre * maxpost))
  36. break;
  37. if (div < (temp_pre * temp_pre))
  38. continue;
  39. err = div % temp_pre;
  40. if (err == 0) {
  41. *pre = temp_pre;
  42. break;
  43. }
  44. err = temp_pre - err;
  45. if (err < old_err) {
  46. old_err = err;
  47. *pre = temp_pre;
  48. }
  49. }
  50. *post = (div + *pre - 1) / *pre;
  51. }
  52. /* get the best values for a 3-bit divider combined with a 6-bit divider */
  53. static void calc_dividers_3_6(u32 div, u32 *pre, u32 *post)
  54. {
  55. if (div >= 512) {
  56. *pre = 8;
  57. *post = 64;
  58. } else if (div >= 64) {
  59. calc_dividers(div, pre, post, 64);
  60. } else if (div <= 8) {
  61. *pre = div;
  62. *post = 1;
  63. } else {
  64. *pre = 1;
  65. *post = div;
  66. }
  67. }
  68. /* get the best values for two cascaded 3-bit dividers */
  69. static void calc_dividers_3_3(u32 div, u32 *pre, u32 *post)
  70. {
  71. if (div >= 64) {
  72. *pre = *post = 8;
  73. } else if (div > 8) {
  74. calc_dividers(div, pre, post, 8);
  75. } else {
  76. *pre = 1;
  77. *post = div;
  78. }
  79. }
  80. #endif
  81. static unsigned long get_rate_mpll(void)
  82. {
  83. ulong mpctl = __raw_readl(MX35_CCM_MPCTL);
  84. return mxc_decode_pll(mpctl, 24000000);
  85. }
  86. static unsigned long get_rate_ppll(void)
  87. {
  88. ulong ppctl = __raw_readl(MX35_CCM_PPCTL);
  89. return mxc_decode_pll(ppctl, 24000000);
  90. }
  91. struct arm_ahb_div {
  92. unsigned char arm, ahb, sel;
  93. };
  94. static struct arm_ahb_div clk_consumer[] = {
  95. { .arm = 1, .ahb = 4, .sel = 0},
  96. { .arm = 1, .ahb = 3, .sel = 1},
  97. { .arm = 2, .ahb = 2, .sel = 0},
  98. { .arm = 0, .ahb = 0, .sel = 0},
  99. { .arm = 0, .ahb = 0, .sel = 0},
  100. { .arm = 0, .ahb = 0, .sel = 0},
  101. { .arm = 4, .ahb = 1, .sel = 0},
  102. { .arm = 1, .ahb = 5, .sel = 0},
  103. { .arm = 1, .ahb = 8, .sel = 0},
  104. { .arm = 1, .ahb = 6, .sel = 1},
  105. { .arm = 2, .ahb = 4, .sel = 0},
  106. { .arm = 0, .ahb = 0, .sel = 0},
  107. { .arm = 0, .ahb = 0, .sel = 0},
  108. { .arm = 0, .ahb = 0, .sel = 0},
  109. { .arm = 4, .ahb = 2, .sel = 0},
  110. { .arm = 0, .ahb = 0, .sel = 0},
  111. };
  112. static unsigned long get_rate_arm(void)
  113. {
  114. unsigned long pdr0 = __raw_readl(MXC_CCM_PDR0);
  115. struct arm_ahb_div *aad;
  116. unsigned long fref = get_rate_mpll();
  117. aad = &clk_consumer[(pdr0 >> 16) & 0xf];
  118. if (aad->sel)
  119. fref = fref * 3 / 4;
  120. return fref / aad->arm;
  121. }
  122. static unsigned long get_rate_ahb(struct clk *clk)
  123. {
  124. unsigned long pdr0 = __raw_readl(MXC_CCM_PDR0);
  125. struct arm_ahb_div *aad;
  126. unsigned long fref = get_rate_arm();
  127. aad = &clk_consumer[(pdr0 >> 16) & 0xf];
  128. return fref / aad->ahb;
  129. }
  130. static unsigned long get_rate_ipg(struct clk *clk)
  131. {
  132. return get_rate_ahb(NULL) >> 1;
  133. }
  134. static unsigned long get_rate_uart(struct clk *clk)
  135. {
  136. unsigned long pdr3 = __raw_readl(MX35_CCM_PDR3);
  137. unsigned long pdr4 = __raw_readl(MX35_CCM_PDR4);
  138. unsigned long div = ((pdr4 >> 10) & 0x3f) + 1;
  139. if (pdr3 & (1 << 14))
  140. return get_rate_arm() / div;
  141. else
  142. return get_rate_ppll() / div;
  143. }
  144. static unsigned long get_rate_sdhc(struct clk *clk)
  145. {
  146. unsigned long pdr3 = __raw_readl(MX35_CCM_PDR3);
  147. unsigned long div, rate;
  148. if (pdr3 & (1 << 6))
  149. rate = get_rate_arm();
  150. else
  151. rate = get_rate_ppll();
  152. switch (clk->id) {
  153. default:
  154. case 0:
  155. div = pdr3 & 0x3f;
  156. break;
  157. case 1:
  158. div = (pdr3 >> 8) & 0x3f;
  159. break;
  160. case 2:
  161. div = (pdr3 >> 16) & 0x3f;
  162. break;
  163. }
  164. return rate / (div + 1);
  165. }
  166. static unsigned long get_rate_mshc(struct clk *clk)
  167. {
  168. unsigned long pdr1 = __raw_readl(MXC_CCM_PDR1);
  169. unsigned long div1, div2, rate;
  170. if (pdr1 & (1 << 7))
  171. rate = get_rate_arm();
  172. else
  173. rate = get_rate_ppll();
  174. div1 = (pdr1 >> 29) & 0x7;
  175. div2 = (pdr1 >> 22) & 0x3f;
  176. return rate / ((div1 + 1) * (div2 + 1));
  177. }
  178. static unsigned long get_rate_ssi(struct clk *clk)
  179. {
  180. unsigned long pdr2 = __raw_readl(MX35_CCM_PDR2);
  181. unsigned long div1, div2, rate;
  182. if (pdr2 & (1 << 6))
  183. rate = get_rate_arm();
  184. else
  185. rate = get_rate_ppll();
  186. switch (clk->id) {
  187. default:
  188. case 0:
  189. div1 = pdr2 & 0x3f;
  190. div2 = (pdr2 >> 24) & 0x7;
  191. break;
  192. case 1:
  193. div1 = (pdr2 >> 8) & 0x3f;
  194. div2 = (pdr2 >> 27) & 0x7;
  195. break;
  196. }
  197. return rate / ((div1 + 1) * (div2 + 1));
  198. }
  199. static unsigned long get_rate_csi(struct clk *clk)
  200. {
  201. unsigned long pdr2 = __raw_readl(MX35_CCM_PDR2);
  202. unsigned long rate;
  203. if (pdr2 & (1 << 7))
  204. rate = get_rate_arm();
  205. else
  206. rate = get_rate_ppll();
  207. return rate / (((pdr2 >> 16) & 0x3f) + 1);
  208. }
  209. static unsigned long get_rate_otg(struct clk *clk)
  210. {
  211. unsigned long pdr4 = __raw_readl(MX35_CCM_PDR4);
  212. unsigned long rate;
  213. if (pdr4 & (1 << 9))
  214. rate = get_rate_arm();
  215. else
  216. rate = get_rate_ppll();
  217. return rate / (((pdr4 >> 22) & 0x3f) + 1);
  218. }
  219. static unsigned long get_rate_ipg_per(struct clk *clk)
  220. {
  221. unsigned long pdr0 = __raw_readl(MXC_CCM_PDR0);
  222. unsigned long pdr4 = __raw_readl(MX35_CCM_PDR4);
  223. unsigned long div;
  224. if (pdr0 & (1 << 26)) {
  225. div = (pdr4 >> 16) & 0x3f;
  226. return get_rate_arm() / (div + 1);
  227. } else {
  228. div = (pdr0 >> 12) & 0x7;
  229. return get_rate_ahb(NULL) / (div + 1);
  230. }
  231. }
  232. static unsigned long get_rate_hsp(struct clk *clk)
  233. {
  234. unsigned long hsp_podf = (__raw_readl(MXC_CCM_PDR0) >> 20) & 0x03;
  235. unsigned long fref = get_rate_mpll();
  236. if (fref > 400 * 1000 * 1000) {
  237. switch (hsp_podf) {
  238. case 0:
  239. return fref >> 2;
  240. case 1:
  241. return fref >> 3;
  242. case 2:
  243. return fref / 3;
  244. }
  245. } else {
  246. switch (hsp_podf) {
  247. case 0:
  248. case 2:
  249. return fref / 3;
  250. case 1:
  251. return fref / 6;
  252. }
  253. }
  254. return 0;
  255. }
  256. static int clk_cgr_enable(struct clk *clk)
  257. {
  258. u32 reg;
  259. reg = __raw_readl(clk->enable_reg);
  260. reg |= 3 << clk->enable_shift;
  261. __raw_writel(reg, clk->enable_reg);
  262. return 0;
  263. }
  264. static void clk_cgr_disable(struct clk *clk)
  265. {
  266. u32 reg;
  267. reg = __raw_readl(clk->enable_reg);
  268. reg &= ~(3 << clk->enable_shift);
  269. __raw_writel(reg, clk->enable_reg);
  270. }
  271. #define DEFINE_CLOCK(name, i, er, es, gr, sr) \
  272. static struct clk name = { \
  273. .id = i, \
  274. .enable_reg = er, \
  275. .enable_shift = es, \
  276. .get_rate = gr, \
  277. .set_rate = sr, \
  278. .enable = clk_cgr_enable, \
  279. .disable = clk_cgr_disable, \
  280. }
  281. DEFINE_CLOCK(asrc_clk, 0, MX35_CCM_CGR0, 0, NULL, NULL);
  282. DEFINE_CLOCK(pata_clk, 0, MX35_CCM_CGR0, 2, get_rate_ipg, NULL);
  283. /* DEFINE_CLOCK(audmux_clk, 0, MX35_CCM_CGR0, 4, NULL, NULL); */
  284. DEFINE_CLOCK(can1_clk, 0, MX35_CCM_CGR0, 6, get_rate_ipg, NULL);
  285. DEFINE_CLOCK(can2_clk, 1, MX35_CCM_CGR0, 8, get_rate_ipg, NULL);
  286. DEFINE_CLOCK(cspi1_clk, 0, MX35_CCM_CGR0, 10, get_rate_ipg, NULL);
  287. DEFINE_CLOCK(cspi2_clk, 1, MX35_CCM_CGR0, 12, get_rate_ipg, NULL);
  288. DEFINE_CLOCK(ect_clk, 0, MX35_CCM_CGR0, 14, get_rate_ipg, NULL);
  289. DEFINE_CLOCK(edio_clk, 0, MX35_CCM_CGR0, 16, NULL, NULL);
  290. DEFINE_CLOCK(emi_clk, 0, MX35_CCM_CGR0, 18, get_rate_ipg, NULL);
  291. DEFINE_CLOCK(epit1_clk, 0, MX35_CCM_CGR0, 20, get_rate_ipg, NULL);
  292. DEFINE_CLOCK(epit2_clk, 1, MX35_CCM_CGR0, 22, get_rate_ipg, NULL);
  293. DEFINE_CLOCK(esai_clk, 0, MX35_CCM_CGR0, 24, NULL, NULL);
  294. DEFINE_CLOCK(esdhc1_clk, 0, MX35_CCM_CGR0, 26, get_rate_sdhc, NULL);
  295. DEFINE_CLOCK(esdhc2_clk, 1, MX35_CCM_CGR0, 28, get_rate_sdhc, NULL);
  296. DEFINE_CLOCK(esdhc3_clk, 2, MX35_CCM_CGR0, 30, get_rate_sdhc, NULL);
  297. DEFINE_CLOCK(fec_clk, 0, MX35_CCM_CGR1, 0, get_rate_ipg, NULL);
  298. DEFINE_CLOCK(gpio1_clk, 0, MX35_CCM_CGR1, 2, NULL, NULL);
  299. DEFINE_CLOCK(gpio2_clk, 1, MX35_CCM_CGR1, 4, NULL, NULL);
  300. DEFINE_CLOCK(gpio3_clk, 2, MX35_CCM_CGR1, 6, NULL, NULL);
  301. DEFINE_CLOCK(gpt_clk, 0, MX35_CCM_CGR1, 8, get_rate_ipg, NULL);
  302. DEFINE_CLOCK(i2c1_clk, 0, MX35_CCM_CGR1, 10, get_rate_ipg_per, NULL);
  303. DEFINE_CLOCK(i2c2_clk, 1, MX35_CCM_CGR1, 12, get_rate_ipg_per, NULL);
  304. DEFINE_CLOCK(i2c3_clk, 2, MX35_CCM_CGR1, 14, get_rate_ipg_per, NULL);
  305. DEFINE_CLOCK(iomuxc_clk, 0, MX35_CCM_CGR1, 16, NULL, NULL);
  306. DEFINE_CLOCK(ipu_clk, 0, MX35_CCM_CGR1, 18, get_rate_hsp, NULL);
  307. DEFINE_CLOCK(kpp_clk, 0, MX35_CCM_CGR1, 20, get_rate_ipg, NULL);
  308. DEFINE_CLOCK(mlb_clk, 0, MX35_CCM_CGR1, 22, get_rate_ahb, NULL);
  309. DEFINE_CLOCK(mshc_clk, 0, MX35_CCM_CGR1, 24, get_rate_mshc, NULL);
  310. DEFINE_CLOCK(owire_clk, 0, MX35_CCM_CGR1, 26, get_rate_ipg_per, NULL);
  311. DEFINE_CLOCK(pwm_clk, 0, MX35_CCM_CGR1, 28, get_rate_ipg_per, NULL);
  312. DEFINE_CLOCK(rngc_clk, 0, MX35_CCM_CGR1, 30, get_rate_ipg, NULL);
  313. DEFINE_CLOCK(rtc_clk, 0, MX35_CCM_CGR2, 0, get_rate_ipg, NULL);
  314. DEFINE_CLOCK(rtic_clk, 0, MX35_CCM_CGR2, 2, get_rate_ahb, NULL);
  315. DEFINE_CLOCK(scc_clk, 0, MX35_CCM_CGR2, 4, get_rate_ipg, NULL);
  316. DEFINE_CLOCK(sdma_clk, 0, MX35_CCM_CGR2, 6, NULL, NULL);
  317. DEFINE_CLOCK(spba_clk, 0, MX35_CCM_CGR2, 8, get_rate_ipg, NULL);
  318. DEFINE_CLOCK(spdif_clk, 0, MX35_CCM_CGR2, 10, NULL, NULL);
  319. DEFINE_CLOCK(ssi1_clk, 0, MX35_CCM_CGR2, 12, get_rate_ssi, NULL);
  320. DEFINE_CLOCK(ssi2_clk, 1, MX35_CCM_CGR2, 14, get_rate_ssi, NULL);
  321. DEFINE_CLOCK(uart1_clk, 0, MX35_CCM_CGR2, 16, get_rate_uart, NULL);
  322. DEFINE_CLOCK(uart2_clk, 1, MX35_CCM_CGR2, 18, get_rate_uart, NULL);
  323. DEFINE_CLOCK(uart3_clk, 2, MX35_CCM_CGR2, 20, get_rate_uart, NULL);
  324. DEFINE_CLOCK(usbotg_clk, 0, MX35_CCM_CGR2, 22, get_rate_otg, NULL);
  325. DEFINE_CLOCK(wdog_clk, 0, MX35_CCM_CGR2, 24, NULL, NULL);
  326. DEFINE_CLOCK(max_clk, 0, MX35_CCM_CGR2, 26, NULL, NULL);
  327. DEFINE_CLOCK(audmux_clk, 0, MX35_CCM_CGR2, 30, NULL, NULL);
  328. DEFINE_CLOCK(csi_clk, 0, MX35_CCM_CGR3, 0, get_rate_csi, NULL);
  329. DEFINE_CLOCK(iim_clk, 0, MX35_CCM_CGR3, 2, NULL, NULL);
  330. DEFINE_CLOCK(gpu2d_clk, 0, MX35_CCM_CGR3, 4, NULL, NULL);
  331. DEFINE_CLOCK(usbahb_clk, 0, 0, 0, get_rate_ahb, NULL);
  332. static int clk_dummy_enable(struct clk *clk)
  333. {
  334. return 0;
  335. }
  336. static void clk_dummy_disable(struct clk *clk)
  337. {
  338. }
  339. static unsigned long get_rate_nfc(struct clk *clk)
  340. {
  341. unsigned long div1;
  342. div1 = (__raw_readl(MX35_CCM_PDR4) >> 28) + 1;
  343. return get_rate_ahb(NULL) / div1;
  344. }
  345. /* NAND Controller: It seems it can't be disabled */
  346. static struct clk nfc_clk = {
  347. .id = 0,
  348. .enable_reg = 0,
  349. .enable_shift = 0,
  350. .get_rate = get_rate_nfc,
  351. .set_rate = NULL, /* set_rate_nfc, */
  352. .enable = clk_dummy_enable,
  353. .disable = clk_dummy_disable
  354. };
  355. #define _REGISTER_CLOCK(d, n, c) \
  356. { \
  357. .dev_id = d, \
  358. .con_id = n, \
  359. .clk = &c, \
  360. },
  361. static struct clk_lookup lookups[] = {
  362. _REGISTER_CLOCK(NULL, "asrc", asrc_clk)
  363. _REGISTER_CLOCK("pata_imx", NULL, pata_clk)
  364. _REGISTER_CLOCK("flexcan.0", NULL, can1_clk)
  365. _REGISTER_CLOCK("flexcan.1", NULL, can2_clk)
  366. _REGISTER_CLOCK("imx35-cspi.0", NULL, cspi1_clk)
  367. _REGISTER_CLOCK("imx35-cspi.1", NULL, cspi2_clk)
  368. _REGISTER_CLOCK(NULL, "ect", ect_clk)
  369. _REGISTER_CLOCK(NULL, "edio", edio_clk)
  370. _REGISTER_CLOCK(NULL, "emi", emi_clk)
  371. _REGISTER_CLOCK("imx-epit.0", NULL, epit1_clk)
  372. _REGISTER_CLOCK("imx-epit.1", NULL, epit2_clk)
  373. _REGISTER_CLOCK(NULL, "esai", esai_clk)
  374. _REGISTER_CLOCK("sdhci-esdhc-imx35.0", NULL, esdhc1_clk)
  375. _REGISTER_CLOCK("sdhci-esdhc-imx35.1", NULL, esdhc2_clk)
  376. _REGISTER_CLOCK("sdhci-esdhc-imx35.2", NULL, esdhc3_clk)
  377. /* i.mx35 has the i.mx27 type fec */
  378. _REGISTER_CLOCK("imx27-fec.0", NULL, fec_clk)
  379. _REGISTER_CLOCK(NULL, "gpio", gpio1_clk)
  380. _REGISTER_CLOCK(NULL, "gpio", gpio2_clk)
  381. _REGISTER_CLOCK(NULL, "gpio", gpio3_clk)
  382. _REGISTER_CLOCK("gpt.0", NULL, gpt_clk)
  383. _REGISTER_CLOCK("imx-i2c.0", NULL, i2c1_clk)
  384. _REGISTER_CLOCK("imx-i2c.1", NULL, i2c2_clk)
  385. _REGISTER_CLOCK("imx-i2c.2", NULL, i2c3_clk)
  386. _REGISTER_CLOCK(NULL, "iomuxc", iomuxc_clk)
  387. _REGISTER_CLOCK("ipu-core", NULL, ipu_clk)
  388. _REGISTER_CLOCK("mx3_sdc_fb", NULL, ipu_clk)
  389. _REGISTER_CLOCK(NULL, "kpp", kpp_clk)
  390. _REGISTER_CLOCK(NULL, "mlb", mlb_clk)
  391. _REGISTER_CLOCK(NULL, "mshc", mshc_clk)
  392. _REGISTER_CLOCK("mxc_w1", NULL, owire_clk)
  393. _REGISTER_CLOCK(NULL, "pwm", pwm_clk)
  394. _REGISTER_CLOCK(NULL, "rngc", rngc_clk)
  395. _REGISTER_CLOCK(NULL, "rtc", rtc_clk)
  396. _REGISTER_CLOCK(NULL, "rtic", rtic_clk)
  397. _REGISTER_CLOCK(NULL, "scc", scc_clk)
  398. _REGISTER_CLOCK("imx35-sdma", NULL, sdma_clk)
  399. _REGISTER_CLOCK(NULL, "spba", spba_clk)
  400. _REGISTER_CLOCK(NULL, "spdif", spdif_clk)
  401. _REGISTER_CLOCK("imx-ssi.0", NULL, ssi1_clk)
  402. _REGISTER_CLOCK("imx-ssi.1", NULL, ssi2_clk)
  403. /* i.mx35 has the i.mx21 type uart */
  404. _REGISTER_CLOCK("imx21-uart.0", NULL, uart1_clk)
  405. _REGISTER_CLOCK("imx21-uart.1", NULL, uart2_clk)
  406. _REGISTER_CLOCK("imx21-uart.2", NULL, uart3_clk)
  407. _REGISTER_CLOCK("mxc-ehci.0", "usb", usbotg_clk)
  408. _REGISTER_CLOCK("mxc-ehci.1", "usb", usbotg_clk)
  409. _REGISTER_CLOCK("mxc-ehci.2", "usb", usbotg_clk)
  410. _REGISTER_CLOCK("fsl-usb2-udc", "usb", usbotg_clk)
  411. _REGISTER_CLOCK("fsl-usb2-udc", "usb_ahb", usbahb_clk)
  412. _REGISTER_CLOCK("imx2-wdt.0", NULL, wdog_clk)
  413. _REGISTER_CLOCK(NULL, "max", max_clk)
  414. _REGISTER_CLOCK(NULL, "audmux", audmux_clk)
  415. _REGISTER_CLOCK("mx3-camera.0", NULL, csi_clk)
  416. _REGISTER_CLOCK(NULL, "iim", iim_clk)
  417. _REGISTER_CLOCK(NULL, "gpu2d", gpu2d_clk)
  418. _REGISTER_CLOCK("mxc_nand.0", NULL, nfc_clk)
  419. };
  420. int __init mx35_clocks_init()
  421. {
  422. unsigned int cgr2 = 3 << 26;
  423. #if defined(CONFIG_DEBUG_LL) && !defined(CONFIG_DEBUG_ICEDCC)
  424. cgr2 |= 3 << 16;
  425. #endif
  426. clkdev_add_table(lookups, ARRAY_SIZE(lookups));
  427. /* Turn off all clocks except the ones we need to survive, namely:
  428. * EMI, GPIO1/2/3, GPT, IOMUX, MAX and eventually uart
  429. */
  430. __raw_writel((3 << 18), MX35_CCM_CGR0);
  431. __raw_writel((3 << 2) | (3 << 4) | (3 << 6) | (3 << 8) | (3 << 16),
  432. MX35_CCM_CGR1);
  433. __raw_writel(cgr2, MX35_CCM_CGR2);
  434. __raw_writel(0, MX35_CCM_CGR3);
  435. clk_enable(&iim_clk);
  436. imx_print_silicon_rev("i.MX35", mx35_revision());
  437. clk_disable(&iim_clk);
  438. /*
  439. * Check if we came up in internal boot mode. If yes, we need some
  440. * extra clocks turned on, otherwise the MX35 boot ROM code will
  441. * hang after a watchdog reset.
  442. */
  443. if (!(__raw_readl(MX35_CCM_RCSR) & (3 << 10))) {
  444. /* Additionally turn on UART1, SCC, and IIM clocks */
  445. clk_enable(&iim_clk);
  446. clk_enable(&uart1_clk);
  447. clk_enable(&scc_clk);
  448. }
  449. #ifdef CONFIG_MXC_USE_EPIT
  450. epit_timer_init(&epit1_clk,
  451. MX35_IO_ADDRESS(MX35_EPIT1_BASE_ADDR), MX35_INT_EPIT1);
  452. #else
  453. mxc_timer_init(&gpt_clk,
  454. MX35_IO_ADDRESS(MX35_GPT1_BASE_ADDR), MX35_INT_GPT);
  455. #endif
  456. return 0;
  457. }