clock.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  1. /*
  2. * arch/arm/mach-ep93xx/clock.c
  3. * Clock control for Cirrus EP93xx chips.
  4. *
  5. * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or (at
  10. * your option) any later version.
  11. */
  12. #define pr_fmt(fmt) "ep93xx " KBUILD_MODNAME ": " fmt
  13. #include <linux/kernel.h>
  14. #include <linux/clk.h>
  15. #include <linux/err.h>
  16. #include <linux/module.h>
  17. #include <linux/string.h>
  18. #include <linux/io.h>
  19. #include <linux/spinlock.h>
  20. #include <linux/clkdev.h>
  21. #include <mach/hardware.h>
  22. #include <asm/div64.h>
  23. #include "soc.h"
  24. struct clk {
  25. struct clk *parent;
  26. unsigned long rate;
  27. int users;
  28. int sw_locked;
  29. void __iomem *enable_reg;
  30. u32 enable_mask;
  31. unsigned long (*get_rate)(struct clk *clk);
  32. int (*set_rate)(struct clk *clk, unsigned long rate);
  33. };
  34. static unsigned long get_uart_rate(struct clk *clk);
  35. static int set_keytchclk_rate(struct clk *clk, unsigned long rate);
  36. static int set_div_rate(struct clk *clk, unsigned long rate);
  37. static int set_i2s_sclk_rate(struct clk *clk, unsigned long rate);
  38. static int set_i2s_lrclk_rate(struct clk *clk, unsigned long rate);
  39. static struct clk clk_xtali = {
  40. .rate = EP93XX_EXT_CLK_RATE,
  41. };
  42. static struct clk clk_uart1 = {
  43. .parent = &clk_xtali,
  44. .sw_locked = 1,
  45. .enable_reg = EP93XX_SYSCON_DEVCFG,
  46. .enable_mask = EP93XX_SYSCON_DEVCFG_U1EN,
  47. .get_rate = get_uart_rate,
  48. };
  49. static struct clk clk_uart2 = {
  50. .parent = &clk_xtali,
  51. .sw_locked = 1,
  52. .enable_reg = EP93XX_SYSCON_DEVCFG,
  53. .enable_mask = EP93XX_SYSCON_DEVCFG_U2EN,
  54. .get_rate = get_uart_rate,
  55. };
  56. static struct clk clk_uart3 = {
  57. .parent = &clk_xtali,
  58. .sw_locked = 1,
  59. .enable_reg = EP93XX_SYSCON_DEVCFG,
  60. .enable_mask = EP93XX_SYSCON_DEVCFG_U3EN,
  61. .get_rate = get_uart_rate,
  62. };
  63. static struct clk clk_pll1 = {
  64. .parent = &clk_xtali,
  65. };
  66. static struct clk clk_f = {
  67. .parent = &clk_pll1,
  68. };
  69. static struct clk clk_h = {
  70. .parent = &clk_pll1,
  71. };
  72. static struct clk clk_p = {
  73. .parent = &clk_pll1,
  74. };
  75. static struct clk clk_pll2 = {
  76. .parent = &clk_xtali,
  77. };
  78. static struct clk clk_usb_host = {
  79. .parent = &clk_pll2,
  80. .enable_reg = EP93XX_SYSCON_PWRCNT,
  81. .enable_mask = EP93XX_SYSCON_PWRCNT_USH_EN,
  82. };
  83. static struct clk clk_keypad = {
  84. .parent = &clk_xtali,
  85. .sw_locked = 1,
  86. .enable_reg = EP93XX_SYSCON_KEYTCHCLKDIV,
  87. .enable_mask = EP93XX_SYSCON_KEYTCHCLKDIV_KEN,
  88. .set_rate = set_keytchclk_rate,
  89. };
  90. static struct clk clk_adc = {
  91. .parent = &clk_xtali,
  92. .sw_locked = 1,
  93. .enable_reg = EP93XX_SYSCON_KEYTCHCLKDIV,
  94. .enable_mask = EP93XX_SYSCON_KEYTCHCLKDIV_TSEN,
  95. .set_rate = set_keytchclk_rate,
  96. };
  97. static struct clk clk_spi = {
  98. .parent = &clk_xtali,
  99. .rate = EP93XX_EXT_CLK_RATE,
  100. };
  101. static struct clk clk_pwm = {
  102. .parent = &clk_xtali,
  103. .rate = EP93XX_EXT_CLK_RATE,
  104. };
  105. static struct clk clk_video = {
  106. .sw_locked = 1,
  107. .enable_reg = EP93XX_SYSCON_VIDCLKDIV,
  108. .enable_mask = EP93XX_SYSCON_CLKDIV_ENABLE,
  109. .set_rate = set_div_rate,
  110. };
  111. static struct clk clk_i2s_mclk = {
  112. .sw_locked = 1,
  113. .enable_reg = EP93XX_SYSCON_I2SCLKDIV,
  114. .enable_mask = EP93XX_SYSCON_CLKDIV_ENABLE,
  115. .set_rate = set_div_rate,
  116. };
  117. static struct clk clk_i2s_sclk = {
  118. .sw_locked = 1,
  119. .parent = &clk_i2s_mclk,
  120. .enable_reg = EP93XX_SYSCON_I2SCLKDIV,
  121. .enable_mask = EP93XX_SYSCON_I2SCLKDIV_SENA,
  122. .set_rate = set_i2s_sclk_rate,
  123. };
  124. static struct clk clk_i2s_lrclk = {
  125. .sw_locked = 1,
  126. .parent = &clk_i2s_sclk,
  127. .enable_reg = EP93XX_SYSCON_I2SCLKDIV,
  128. .enable_mask = EP93XX_SYSCON_I2SCLKDIV_SENA,
  129. .set_rate = set_i2s_lrclk_rate,
  130. };
  131. /* DMA Clocks */
  132. static struct clk clk_m2p0 = {
  133. .parent = &clk_h,
  134. .enable_reg = EP93XX_SYSCON_PWRCNT,
  135. .enable_mask = EP93XX_SYSCON_PWRCNT_DMA_M2P0,
  136. };
  137. static struct clk clk_m2p1 = {
  138. .parent = &clk_h,
  139. .enable_reg = EP93XX_SYSCON_PWRCNT,
  140. .enable_mask = EP93XX_SYSCON_PWRCNT_DMA_M2P1,
  141. };
  142. static struct clk clk_m2p2 = {
  143. .parent = &clk_h,
  144. .enable_reg = EP93XX_SYSCON_PWRCNT,
  145. .enable_mask = EP93XX_SYSCON_PWRCNT_DMA_M2P2,
  146. };
  147. static struct clk clk_m2p3 = {
  148. .parent = &clk_h,
  149. .enable_reg = EP93XX_SYSCON_PWRCNT,
  150. .enable_mask = EP93XX_SYSCON_PWRCNT_DMA_M2P3,
  151. };
  152. static struct clk clk_m2p4 = {
  153. .parent = &clk_h,
  154. .enable_reg = EP93XX_SYSCON_PWRCNT,
  155. .enable_mask = EP93XX_SYSCON_PWRCNT_DMA_M2P4,
  156. };
  157. static struct clk clk_m2p5 = {
  158. .parent = &clk_h,
  159. .enable_reg = EP93XX_SYSCON_PWRCNT,
  160. .enable_mask = EP93XX_SYSCON_PWRCNT_DMA_M2P5,
  161. };
  162. static struct clk clk_m2p6 = {
  163. .parent = &clk_h,
  164. .enable_reg = EP93XX_SYSCON_PWRCNT,
  165. .enable_mask = EP93XX_SYSCON_PWRCNT_DMA_M2P6,
  166. };
  167. static struct clk clk_m2p7 = {
  168. .parent = &clk_h,
  169. .enable_reg = EP93XX_SYSCON_PWRCNT,
  170. .enable_mask = EP93XX_SYSCON_PWRCNT_DMA_M2P7,
  171. };
  172. static struct clk clk_m2p8 = {
  173. .parent = &clk_h,
  174. .enable_reg = EP93XX_SYSCON_PWRCNT,
  175. .enable_mask = EP93XX_SYSCON_PWRCNT_DMA_M2P8,
  176. };
  177. static struct clk clk_m2p9 = {
  178. .parent = &clk_h,
  179. .enable_reg = EP93XX_SYSCON_PWRCNT,
  180. .enable_mask = EP93XX_SYSCON_PWRCNT_DMA_M2P9,
  181. };
  182. static struct clk clk_m2m0 = {
  183. .parent = &clk_h,
  184. .enable_reg = EP93XX_SYSCON_PWRCNT,
  185. .enable_mask = EP93XX_SYSCON_PWRCNT_DMA_M2M0,
  186. };
  187. static struct clk clk_m2m1 = {
  188. .parent = &clk_h,
  189. .enable_reg = EP93XX_SYSCON_PWRCNT,
  190. .enable_mask = EP93XX_SYSCON_PWRCNT_DMA_M2M1,
  191. };
  192. #define INIT_CK(dev,con,ck) \
  193. { .dev_id = dev, .con_id = con, .clk = ck }
  194. static struct clk_lookup clocks[] = {
  195. INIT_CK(NULL, "xtali", &clk_xtali),
  196. INIT_CK("apb:uart1", NULL, &clk_uart1),
  197. INIT_CK("apb:uart2", NULL, &clk_uart2),
  198. INIT_CK("apb:uart3", NULL, &clk_uart3),
  199. INIT_CK(NULL, "pll1", &clk_pll1),
  200. INIT_CK(NULL, "fclk", &clk_f),
  201. INIT_CK(NULL, "hclk", &clk_h),
  202. INIT_CK(NULL, "apb_pclk", &clk_p),
  203. INIT_CK(NULL, "pll2", &clk_pll2),
  204. INIT_CK("ohci-platform", NULL, &clk_usb_host),
  205. INIT_CK("ep93xx-keypad", NULL, &clk_keypad),
  206. INIT_CK("ep93xx-adc", NULL, &clk_adc),
  207. INIT_CK("ep93xx-fb", NULL, &clk_video),
  208. INIT_CK("ep93xx-spi.0", NULL, &clk_spi),
  209. INIT_CK("ep93xx-i2s", "mclk", &clk_i2s_mclk),
  210. INIT_CK("ep93xx-i2s", "sclk", &clk_i2s_sclk),
  211. INIT_CK("ep93xx-i2s", "lrclk", &clk_i2s_lrclk),
  212. INIT_CK(NULL, "pwm_clk", &clk_pwm),
  213. INIT_CK(NULL, "m2p0", &clk_m2p0),
  214. INIT_CK(NULL, "m2p1", &clk_m2p1),
  215. INIT_CK(NULL, "m2p2", &clk_m2p2),
  216. INIT_CK(NULL, "m2p3", &clk_m2p3),
  217. INIT_CK(NULL, "m2p4", &clk_m2p4),
  218. INIT_CK(NULL, "m2p5", &clk_m2p5),
  219. INIT_CK(NULL, "m2p6", &clk_m2p6),
  220. INIT_CK(NULL, "m2p7", &clk_m2p7),
  221. INIT_CK(NULL, "m2p8", &clk_m2p8),
  222. INIT_CK(NULL, "m2p9", &clk_m2p9),
  223. INIT_CK(NULL, "m2m0", &clk_m2m0),
  224. INIT_CK(NULL, "m2m1", &clk_m2m1),
  225. };
  226. static DEFINE_SPINLOCK(clk_lock);
  227. static void __clk_enable(struct clk *clk)
  228. {
  229. if (!clk->users++) {
  230. if (clk->parent)
  231. __clk_enable(clk->parent);
  232. if (clk->enable_reg) {
  233. u32 v;
  234. v = __raw_readl(clk->enable_reg);
  235. v |= clk->enable_mask;
  236. if (clk->sw_locked)
  237. ep93xx_syscon_swlocked_write(v, clk->enable_reg);
  238. else
  239. __raw_writel(v, clk->enable_reg);
  240. }
  241. }
  242. }
  243. int clk_enable(struct clk *clk)
  244. {
  245. unsigned long flags;
  246. if (!clk)
  247. return -EINVAL;
  248. spin_lock_irqsave(&clk_lock, flags);
  249. __clk_enable(clk);
  250. spin_unlock_irqrestore(&clk_lock, flags);
  251. return 0;
  252. }
  253. EXPORT_SYMBOL(clk_enable);
  254. static void __clk_disable(struct clk *clk)
  255. {
  256. if (!--clk->users) {
  257. if (clk->enable_reg) {
  258. u32 v;
  259. v = __raw_readl(clk->enable_reg);
  260. v &= ~clk->enable_mask;
  261. if (clk->sw_locked)
  262. ep93xx_syscon_swlocked_write(v, clk->enable_reg);
  263. else
  264. __raw_writel(v, clk->enable_reg);
  265. }
  266. if (clk->parent)
  267. __clk_disable(clk->parent);
  268. }
  269. }
  270. void clk_disable(struct clk *clk)
  271. {
  272. unsigned long flags;
  273. if (!clk)
  274. return;
  275. spin_lock_irqsave(&clk_lock, flags);
  276. __clk_disable(clk);
  277. spin_unlock_irqrestore(&clk_lock, flags);
  278. }
  279. EXPORT_SYMBOL(clk_disable);
  280. static unsigned long get_uart_rate(struct clk *clk)
  281. {
  282. unsigned long rate = clk_get_rate(clk->parent);
  283. u32 value;
  284. value = __raw_readl(EP93XX_SYSCON_PWRCNT);
  285. if (value & EP93XX_SYSCON_PWRCNT_UARTBAUD)
  286. return rate;
  287. else
  288. return rate / 2;
  289. }
  290. unsigned long clk_get_rate(struct clk *clk)
  291. {
  292. if (clk->get_rate)
  293. return clk->get_rate(clk);
  294. return clk->rate;
  295. }
  296. EXPORT_SYMBOL(clk_get_rate);
  297. static int set_keytchclk_rate(struct clk *clk, unsigned long rate)
  298. {
  299. u32 val;
  300. u32 div_bit;
  301. val = __raw_readl(clk->enable_reg);
  302. /*
  303. * The Key Matrix and ADC clocks are configured using the same
  304. * System Controller register. The clock used will be either
  305. * 1/4 or 1/16 the external clock rate depending on the
  306. * EP93XX_SYSCON_KEYTCHCLKDIV_KDIV/EP93XX_SYSCON_KEYTCHCLKDIV_ADIV
  307. * bit being set or cleared.
  308. */
  309. div_bit = clk->enable_mask >> 15;
  310. if (rate == EP93XX_KEYTCHCLK_DIV4)
  311. val |= div_bit;
  312. else if (rate == EP93XX_KEYTCHCLK_DIV16)
  313. val &= ~div_bit;
  314. else
  315. return -EINVAL;
  316. ep93xx_syscon_swlocked_write(val, clk->enable_reg);
  317. clk->rate = rate;
  318. return 0;
  319. }
  320. static int calc_clk_div(struct clk *clk, unsigned long rate,
  321. int *psel, int *esel, int *pdiv, int *div)
  322. {
  323. struct clk *mclk;
  324. unsigned long max_rate, actual_rate, mclk_rate, rate_err = -1;
  325. int i, found = 0, __div = 0, __pdiv = 0;
  326. /* Don't exceed the maximum rate */
  327. max_rate = max3(clk_pll1.rate / 4, clk_pll2.rate / 4, clk_xtali.rate / 4);
  328. rate = min(rate, max_rate);
  329. /*
  330. * Try the two pll's and the external clock
  331. * Because the valid predividers are 2, 2.5 and 3, we multiply
  332. * all the clocks by 2 to avoid floating point math.
  333. *
  334. * This is based on the algorithm in the ep93xx raster guide:
  335. * http://be-a-maverick.com/en/pubs/appNote/AN269REV1.pdf
  336. *
  337. */
  338. for (i = 0; i < 3; i++) {
  339. if (i == 0)
  340. mclk = &clk_xtali;
  341. else if (i == 1)
  342. mclk = &clk_pll1;
  343. else
  344. mclk = &clk_pll2;
  345. mclk_rate = mclk->rate * 2;
  346. /* Try each predivider value */
  347. for (__pdiv = 4; __pdiv <= 6; __pdiv++) {
  348. __div = mclk_rate / (rate * __pdiv);
  349. if (__div < 2 || __div > 127)
  350. continue;
  351. actual_rate = mclk_rate / (__pdiv * __div);
  352. if (!found || abs(actual_rate - rate) < rate_err) {
  353. *pdiv = __pdiv - 3;
  354. *div = __div;
  355. *psel = (i == 2);
  356. *esel = (i != 0);
  357. clk->parent = mclk;
  358. clk->rate = actual_rate;
  359. rate_err = abs(actual_rate - rate);
  360. found = 1;
  361. }
  362. }
  363. }
  364. if (!found)
  365. return -EINVAL;
  366. return 0;
  367. }
  368. static int set_div_rate(struct clk *clk, unsigned long rate)
  369. {
  370. int err, psel = 0, esel = 0, pdiv = 0, div = 0;
  371. u32 val;
  372. err = calc_clk_div(clk, rate, &psel, &esel, &pdiv, &div);
  373. if (err)
  374. return err;
  375. /* Clear the esel, psel, pdiv and div bits */
  376. val = __raw_readl(clk->enable_reg);
  377. val &= ~0x7fff;
  378. /* Set the new esel, psel, pdiv and div bits for the new clock rate */
  379. val |= (esel ? EP93XX_SYSCON_CLKDIV_ESEL : 0) |
  380. (psel ? EP93XX_SYSCON_CLKDIV_PSEL : 0) |
  381. (pdiv << EP93XX_SYSCON_CLKDIV_PDIV_SHIFT) | div;
  382. ep93xx_syscon_swlocked_write(val, clk->enable_reg);
  383. return 0;
  384. }
  385. static int set_i2s_sclk_rate(struct clk *clk, unsigned long rate)
  386. {
  387. unsigned val = __raw_readl(clk->enable_reg);
  388. if (rate == clk_i2s_mclk.rate / 2)
  389. ep93xx_syscon_swlocked_write(val & ~EP93XX_I2SCLKDIV_SDIV,
  390. clk->enable_reg);
  391. else if (rate == clk_i2s_mclk.rate / 4)
  392. ep93xx_syscon_swlocked_write(val | EP93XX_I2SCLKDIV_SDIV,
  393. clk->enable_reg);
  394. else
  395. return -EINVAL;
  396. clk_i2s_sclk.rate = rate;
  397. return 0;
  398. }
  399. static int set_i2s_lrclk_rate(struct clk *clk, unsigned long rate)
  400. {
  401. unsigned val = __raw_readl(clk->enable_reg) &
  402. ~EP93XX_I2SCLKDIV_LRDIV_MASK;
  403. if (rate == clk_i2s_sclk.rate / 32)
  404. ep93xx_syscon_swlocked_write(val | EP93XX_I2SCLKDIV_LRDIV32,
  405. clk->enable_reg);
  406. else if (rate == clk_i2s_sclk.rate / 64)
  407. ep93xx_syscon_swlocked_write(val | EP93XX_I2SCLKDIV_LRDIV64,
  408. clk->enable_reg);
  409. else if (rate == clk_i2s_sclk.rate / 128)
  410. ep93xx_syscon_swlocked_write(val | EP93XX_I2SCLKDIV_LRDIV128,
  411. clk->enable_reg);
  412. else
  413. return -EINVAL;
  414. clk_i2s_lrclk.rate = rate;
  415. return 0;
  416. }
  417. int clk_set_rate(struct clk *clk, unsigned long rate)
  418. {
  419. if (clk->set_rate)
  420. return clk->set_rate(clk, rate);
  421. return -EINVAL;
  422. }
  423. EXPORT_SYMBOL(clk_set_rate);
  424. long clk_round_rate(struct clk *clk, unsigned long rate)
  425. {
  426. WARN_ON(clk);
  427. return 0;
  428. }
  429. EXPORT_SYMBOL(clk_round_rate);
  430. int clk_set_parent(struct clk *clk, struct clk *parent)
  431. {
  432. WARN_ON(clk);
  433. return 0;
  434. }
  435. EXPORT_SYMBOL(clk_set_parent);
  436. struct clk *clk_get_parent(struct clk *clk)
  437. {
  438. return clk->parent;
  439. }
  440. EXPORT_SYMBOL(clk_get_parent);
  441. static char fclk_divisors[] = { 1, 2, 4, 8, 16, 1, 1, 1 };
  442. static char hclk_divisors[] = { 1, 2, 4, 5, 6, 8, 16, 32 };
  443. static char pclk_divisors[] = { 1, 2, 4, 8 };
  444. /*
  445. * PLL rate = 14.7456 MHz * (X1FBD + 1) * (X2FBD + 1) / (X2IPD + 1) / 2^PS
  446. */
  447. static unsigned long calc_pll_rate(u32 config_word)
  448. {
  449. unsigned long long rate;
  450. int i;
  451. rate = clk_xtali.rate;
  452. rate *= ((config_word >> 11) & 0x1f) + 1; /* X1FBD */
  453. rate *= ((config_word >> 5) & 0x3f) + 1; /* X2FBD */
  454. do_div(rate, (config_word & 0x1f) + 1); /* X2IPD */
  455. for (i = 0; i < ((config_word >> 16) & 3); i++) /* PS */
  456. rate >>= 1;
  457. return (unsigned long)rate;
  458. }
  459. static void __init ep93xx_dma_clock_init(void)
  460. {
  461. clk_m2p0.rate = clk_h.rate;
  462. clk_m2p1.rate = clk_h.rate;
  463. clk_m2p2.rate = clk_h.rate;
  464. clk_m2p3.rate = clk_h.rate;
  465. clk_m2p4.rate = clk_h.rate;
  466. clk_m2p5.rate = clk_h.rate;
  467. clk_m2p6.rate = clk_h.rate;
  468. clk_m2p7.rate = clk_h.rate;
  469. clk_m2p8.rate = clk_h.rate;
  470. clk_m2p9.rate = clk_h.rate;
  471. clk_m2m0.rate = clk_h.rate;
  472. clk_m2m1.rate = clk_h.rate;
  473. }
  474. static int __init ep93xx_clock_init(void)
  475. {
  476. u32 value;
  477. /* Determine the bootloader configured pll1 rate */
  478. value = __raw_readl(EP93XX_SYSCON_CLKSET1);
  479. if (!(value & EP93XX_SYSCON_CLKSET1_NBYP1))
  480. clk_pll1.rate = clk_xtali.rate;
  481. else
  482. clk_pll1.rate = calc_pll_rate(value);
  483. /* Initialize the pll1 derived clocks */
  484. clk_f.rate = clk_pll1.rate / fclk_divisors[(value >> 25) & 0x7];
  485. clk_h.rate = clk_pll1.rate / hclk_divisors[(value >> 20) & 0x7];
  486. clk_p.rate = clk_h.rate / pclk_divisors[(value >> 18) & 0x3];
  487. ep93xx_dma_clock_init();
  488. /* Determine the bootloader configured pll2 rate */
  489. value = __raw_readl(EP93XX_SYSCON_CLKSET2);
  490. if (!(value & EP93XX_SYSCON_CLKSET2_NBYP2))
  491. clk_pll2.rate = clk_xtali.rate;
  492. else if (value & EP93XX_SYSCON_CLKSET2_PLL2_EN)
  493. clk_pll2.rate = calc_pll_rate(value);
  494. else
  495. clk_pll2.rate = 0;
  496. /* Initialize the pll2 derived clocks */
  497. clk_usb_host.rate = clk_pll2.rate / (((value >> 28) & 0xf) + 1);
  498. /*
  499. * EP93xx SSP clock rate was doubled in version E2. For more information
  500. * see:
  501. * http://www.cirrus.com/en/pubs/appNote/AN273REV4.pdf
  502. */
  503. if (ep93xx_chip_revision() < EP93XX_CHIP_REV_E2)
  504. clk_spi.rate /= 2;
  505. pr_info("PLL1 running at %ld MHz, PLL2 at %ld MHz\n",
  506. clk_pll1.rate / 1000000, clk_pll2.rate / 1000000);
  507. pr_info("FCLK %ld MHz, HCLK %ld MHz, PCLK %ld MHz\n",
  508. clk_f.rate / 1000000, clk_h.rate / 1000000,
  509. clk_p.rate / 1000000);
  510. clkdev_add_table(clocks, ARRAY_SIZE(clocks));
  511. return 0;
  512. }
  513. postcore_initcall(ep93xx_clock_init);