clock.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. /*
  2. * Copyright (C) 2009 ST-Ericsson
  3. * Copyright (C) 2009 STMicroelectronics
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. */
  9. #include <linux/module.h>
  10. #include <linux/kernel.h>
  11. #include <linux/list.h>
  12. #include <linux/errno.h>
  13. #include <linux/err.h>
  14. #include <linux/clk.h>
  15. #include <linux/io.h>
  16. #include <asm/clkdev.h>
  17. #include <plat/mtu.h>
  18. #include <mach/hardware.h>
  19. #include "clock.h"
  20. #define PRCC_PCKEN 0x00
  21. #define PRCC_PCKDIS 0x04
  22. #define PRCC_KCKEN 0x08
  23. #define PRCC_KCKDIS 0x0C
  24. #define PRCM_YYCLKEN0_MGT_SET 0x510
  25. #define PRCM_YYCLKEN1_MGT_SET 0x514
  26. #define PRCM_YYCLKEN0_MGT_CLR 0x518
  27. #define PRCM_YYCLKEN1_MGT_CLR 0x51C
  28. #define PRCM_YYCLKEN0_MGT_VAL 0x520
  29. #define PRCM_YYCLKEN1_MGT_VAL 0x524
  30. #define PRCM_SVAMMDSPCLK_MGT 0x008
  31. #define PRCM_SIAMMDSPCLK_MGT 0x00C
  32. #define PRCM_SGACLK_MGT 0x014
  33. #define PRCM_UARTCLK_MGT 0x018
  34. #define PRCM_MSP02CLK_MGT 0x01C
  35. #define PRCM_MSP1CLK_MGT 0x288
  36. #define PRCM_I2CCLK_MGT 0x020
  37. #define PRCM_SDMMCCLK_MGT 0x024
  38. #define PRCM_SLIMCLK_MGT 0x028
  39. #define PRCM_PER1CLK_MGT 0x02C
  40. #define PRCM_PER2CLK_MGT 0x030
  41. #define PRCM_PER3CLK_MGT 0x034
  42. #define PRCM_PER5CLK_MGT 0x038
  43. #define PRCM_PER6CLK_MGT 0x03C
  44. #define PRCM_PER7CLK_MGT 0x040
  45. #define PRCM_LCDCLK_MGT 0x044
  46. #define PRCM_BMLCLK_MGT 0x04C
  47. #define PRCM_HSITXCLK_MGT 0x050
  48. #define PRCM_HSIRXCLK_MGT 0x054
  49. #define PRCM_HDMICLK_MGT 0x058
  50. #define PRCM_APEATCLK_MGT 0x05C
  51. #define PRCM_APETRACECLK_MGT 0x060
  52. #define PRCM_MCDECLK_MGT 0x064
  53. #define PRCM_IPI2CCLK_MGT 0x068
  54. #define PRCM_DSIALTCLK_MGT 0x06C
  55. #define PRCM_DMACLK_MGT 0x074
  56. #define PRCM_B2R2CLK_MGT 0x078
  57. #define PRCM_TVCLK_MGT 0x07C
  58. #define PRCM_TCR 0x1C8
  59. #define PRCM_TCR_STOPPED (1 << 16)
  60. #define PRCM_TCR_DOZE_MODE (1 << 17)
  61. #define PRCM_UNIPROCLK_MGT 0x278
  62. #define PRCM_SSPCLK_MGT 0x280
  63. #define PRCM_RNGCLK_MGT 0x284
  64. #define PRCM_UICCCLK_MGT 0x27C
  65. #define PRCM_MGT_ENABLE (1 << 8)
  66. static DEFINE_SPINLOCK(clocks_lock);
  67. static void __clk_enable(struct clk *clk)
  68. {
  69. if (clk->enabled++ == 0) {
  70. if (clk->parent_cluster)
  71. __clk_enable(clk->parent_cluster);
  72. if (clk->parent_periph)
  73. __clk_enable(clk->parent_periph);
  74. if (clk->ops && clk->ops->enable)
  75. clk->ops->enable(clk);
  76. }
  77. }
  78. int clk_enable(struct clk *clk)
  79. {
  80. unsigned long flags;
  81. spin_lock_irqsave(&clocks_lock, flags);
  82. __clk_enable(clk);
  83. spin_unlock_irqrestore(&clocks_lock, flags);
  84. return 0;
  85. }
  86. EXPORT_SYMBOL(clk_enable);
  87. static void __clk_disable(struct clk *clk)
  88. {
  89. if (--clk->enabled == 0) {
  90. if (clk->ops && clk->ops->disable)
  91. clk->ops->disable(clk);
  92. if (clk->parent_periph)
  93. __clk_disable(clk->parent_periph);
  94. if (clk->parent_cluster)
  95. __clk_disable(clk->parent_cluster);
  96. }
  97. }
  98. void clk_disable(struct clk *clk)
  99. {
  100. unsigned long flags;
  101. WARN_ON(!clk->enabled);
  102. spin_lock_irqsave(&clocks_lock, flags);
  103. __clk_disable(clk);
  104. spin_unlock_irqrestore(&clocks_lock, flags);
  105. }
  106. EXPORT_SYMBOL(clk_disable);
  107. /*
  108. * The MTU has a separate, rather complex muxing setup
  109. * with alternative parents (peripheral cluster or
  110. * ULP or fixed 32768 Hz) depending on settings
  111. */
  112. static unsigned long clk_mtu_get_rate(struct clk *clk)
  113. {
  114. void __iomem *addr = __io_address(UX500_PRCMU_BASE)
  115. + PRCM_TCR;
  116. u32 tcr = readl(addr);
  117. int mtu = (int) clk->data;
  118. /*
  119. * One of these is selected eventually
  120. * TODO: Replace the constant with a reference
  121. * to the ULP source once this is modeled.
  122. */
  123. unsigned long clk32k = 32768;
  124. unsigned long mturate;
  125. unsigned long retclk;
  126. /* Get the rate from the parent as a default */
  127. if (clk->parent_periph)
  128. mturate = clk_get_rate(clk->parent_periph);
  129. else if (clk->parent_cluster)
  130. mturate = clk_get_rate(clk->parent_cluster);
  131. else
  132. /* We need to be connected SOMEWHERE */
  133. BUG();
  134. /*
  135. * Are we in doze mode?
  136. * In this mode the parent peripheral or the fixed 32768 Hz
  137. * clock is fed into the block.
  138. */
  139. if (!(tcr & PRCM_TCR_DOZE_MODE)) {
  140. /*
  141. * Here we're using the clock input from the APE ULP
  142. * clock domain. But first: are the timers stopped?
  143. */
  144. if (tcr & PRCM_TCR_STOPPED) {
  145. clk32k = 0;
  146. mturate = 0;
  147. } else {
  148. /* Else default mode: 0 and 2.4 MHz */
  149. clk32k = 0;
  150. if (cpu_is_u5500())
  151. /* DB5500 divides by 8 */
  152. mturate /= 8;
  153. else if (cpu_is_u8500ed()) {
  154. /*
  155. * This clocking setting must not be used
  156. * in the ED chip, it is simply not
  157. * connected anywhere!
  158. */
  159. mturate = 0;
  160. BUG();
  161. } else
  162. /*
  163. * In this mode the ulp38m4 clock is divided
  164. * by a factor 16, on the DB8500 typically
  165. * 38400000 / 16 ~ 2.4 MHz.
  166. * TODO: Replace the constant with a reference
  167. * to the ULP source once this is modeled.
  168. */
  169. mturate = 38400000 / 16;
  170. }
  171. }
  172. /* Return the clock selected for this MTU */
  173. if (tcr & (1 << mtu))
  174. retclk = clk32k;
  175. else
  176. retclk = mturate;
  177. pr_info("MTU%d clock rate: %lu Hz\n", mtu, retclk);
  178. return retclk;
  179. }
  180. unsigned long clk_get_rate(struct clk *clk)
  181. {
  182. unsigned long rate;
  183. /*
  184. * If there is a custom getrate callback for this clock,
  185. * it will take precedence.
  186. */
  187. if (clk->get_rate)
  188. return clk->get_rate(clk);
  189. if (clk->ops && clk->ops->get_rate)
  190. return clk->ops->get_rate(clk);
  191. rate = clk->rate;
  192. if (!rate) {
  193. if (clk->parent_periph)
  194. rate = clk_get_rate(clk->parent_periph);
  195. else if (clk->parent_cluster)
  196. rate = clk_get_rate(clk->parent_cluster);
  197. }
  198. return rate;
  199. }
  200. EXPORT_SYMBOL(clk_get_rate);
  201. long clk_round_rate(struct clk *clk, unsigned long rate)
  202. {
  203. /*TODO*/
  204. return rate;
  205. }
  206. EXPORT_SYMBOL(clk_round_rate);
  207. int clk_set_rate(struct clk *clk, unsigned long rate)
  208. {
  209. clk->rate = rate;
  210. return 0;
  211. }
  212. EXPORT_SYMBOL(clk_set_rate);
  213. static void clk_prcmu_enable(struct clk *clk)
  214. {
  215. void __iomem *cg_set_reg = __io_address(U8500_PRCMU_BASE)
  216. + PRCM_YYCLKEN0_MGT_SET + clk->prcmu_cg_off;
  217. writel(1 << clk->prcmu_cg_bit, cg_set_reg);
  218. }
  219. static void clk_prcmu_disable(struct clk *clk)
  220. {
  221. void __iomem *cg_clr_reg = __io_address(U8500_PRCMU_BASE)
  222. + PRCM_YYCLKEN0_MGT_CLR + clk->prcmu_cg_off;
  223. writel(1 << clk->prcmu_cg_bit, cg_clr_reg);
  224. }
  225. /* ED doesn't have the combined set/clr registers */
  226. static void clk_prcmu_ed_enable(struct clk *clk)
  227. {
  228. void __iomem *addr = __io_address(U8500_PRCMU_BASE)
  229. + clk->prcmu_cg_mgt;
  230. writel(readl(addr) | PRCM_MGT_ENABLE, addr);
  231. }
  232. static void clk_prcmu_ed_disable(struct clk *clk)
  233. {
  234. void __iomem *addr = __io_address(U8500_PRCMU_BASE)
  235. + clk->prcmu_cg_mgt;
  236. writel(readl(addr) & ~PRCM_MGT_ENABLE, addr);
  237. }
  238. static struct clkops clk_prcmu_ops = {
  239. .enable = clk_prcmu_enable,
  240. .disable = clk_prcmu_disable,
  241. };
  242. static unsigned int clkrst_base[] = {
  243. [1] = U8500_CLKRST1_BASE,
  244. [2] = U8500_CLKRST2_BASE,
  245. [3] = U8500_CLKRST3_BASE,
  246. [5] = U8500_CLKRST5_BASE,
  247. [6] = U8500_CLKRST6_BASE,
  248. [7] = U8500_CLKRST7_BASE_ED,
  249. };
  250. static void clk_prcc_enable(struct clk *clk)
  251. {
  252. void __iomem *addr = __io_address(clkrst_base[clk->cluster]);
  253. if (clk->prcc_kernel != -1)
  254. writel(1 << clk->prcc_kernel, addr + PRCC_KCKEN);
  255. if (clk->prcc_bus != -1)
  256. writel(1 << clk->prcc_bus, addr + PRCC_PCKEN);
  257. }
  258. static void clk_prcc_disable(struct clk *clk)
  259. {
  260. void __iomem *addr = __io_address(clkrst_base[clk->cluster]);
  261. if (clk->prcc_bus != -1)
  262. writel(1 << clk->prcc_bus, addr + PRCC_PCKDIS);
  263. if (clk->prcc_kernel != -1)
  264. writel(1 << clk->prcc_kernel, addr + PRCC_KCKDIS);
  265. }
  266. static struct clkops clk_prcc_ops = {
  267. .enable = clk_prcc_enable,
  268. .disable = clk_prcc_disable,
  269. };
  270. static struct clk clk_32khz = {
  271. .rate = 32000,
  272. };
  273. /*
  274. * PRCMU level clock gating
  275. */
  276. /* Bank 0 */
  277. static DEFINE_PRCMU_CLK(svaclk, 0x0, 2, SVAMMDSPCLK);
  278. static DEFINE_PRCMU_CLK(siaclk, 0x0, 3, SIAMMDSPCLK);
  279. static DEFINE_PRCMU_CLK(sgaclk, 0x0, 4, SGACLK);
  280. static DEFINE_PRCMU_CLK_RATE(uartclk, 0x0, 5, UARTCLK, 38400000);
  281. static DEFINE_PRCMU_CLK(msp02clk, 0x0, 6, MSP02CLK);
  282. static DEFINE_PRCMU_CLK(msp1clk, 0x0, 7, MSP1CLK); /* v1 */
  283. static DEFINE_PRCMU_CLK_RATE(i2cclk, 0x0, 8, I2CCLK, 48000000);
  284. static DEFINE_PRCMU_CLK_RATE(sdmmcclk, 0x0, 9, SDMMCCLK, 50000000);
  285. static DEFINE_PRCMU_CLK(slimclk, 0x0, 10, SLIMCLK);
  286. static DEFINE_PRCMU_CLK(per1clk, 0x0, 11, PER1CLK);
  287. static DEFINE_PRCMU_CLK(per2clk, 0x0, 12, PER2CLK);
  288. static DEFINE_PRCMU_CLK(per3clk, 0x0, 13, PER3CLK);
  289. static DEFINE_PRCMU_CLK(per5clk, 0x0, 14, PER5CLK);
  290. static DEFINE_PRCMU_CLK_RATE(per6clk, 0x0, 15, PER6CLK, 133330000);
  291. static DEFINE_PRCMU_CLK_RATE(per7clk, 0x0, 16, PER7CLK, 100000000);
  292. static DEFINE_PRCMU_CLK(lcdclk, 0x0, 17, LCDCLK);
  293. static DEFINE_PRCMU_CLK(bmlclk, 0x0, 18, BMLCLK);
  294. static DEFINE_PRCMU_CLK(hsitxclk, 0x0, 19, HSITXCLK);
  295. static DEFINE_PRCMU_CLK(hsirxclk, 0x0, 20, HSIRXCLK);
  296. static DEFINE_PRCMU_CLK(hdmiclk, 0x0, 21, HDMICLK);
  297. static DEFINE_PRCMU_CLK(apeatclk, 0x0, 22, APEATCLK);
  298. static DEFINE_PRCMU_CLK(apetraceclk, 0x0, 23, APETRACECLK);
  299. static DEFINE_PRCMU_CLK(mcdeclk, 0x0, 24, MCDECLK);
  300. static DEFINE_PRCMU_CLK(ipi2clk, 0x0, 25, IPI2CCLK);
  301. static DEFINE_PRCMU_CLK(dsialtclk, 0x0, 26, DSIALTCLK); /* v1 */
  302. static DEFINE_PRCMU_CLK(dmaclk, 0x0, 27, DMACLK);
  303. static DEFINE_PRCMU_CLK(b2r2clk, 0x0, 28, B2R2CLK);
  304. static DEFINE_PRCMU_CLK(tvclk, 0x0, 29, TVCLK);
  305. static DEFINE_PRCMU_CLK(uniproclk, 0x0, 30, UNIPROCLK); /* v1 */
  306. static DEFINE_PRCMU_CLK_RATE(sspclk, 0x0, 31, SSPCLK, 48000000); /* v1 */
  307. /* Bank 1 */
  308. static DEFINE_PRCMU_CLK(rngclk, 0x4, 0, RNGCLK); /* v1 */
  309. static DEFINE_PRCMU_CLK(uiccclk, 0x4, 1, UICCCLK); /* v1 */
  310. /*
  311. * PRCC level clock gating
  312. * Format: per#, clk, PCKEN bit, KCKEN bit, parent
  313. */
  314. /* Peripheral Cluster #1 */
  315. static DEFINE_PRCC_CLK(1, i2c4, 10, 9, &clk_i2cclk);
  316. static DEFINE_PRCC_CLK(1, gpio0, 9, -1, NULL);
  317. static DEFINE_PRCC_CLK(1, slimbus0, 8, 8, &clk_slimclk);
  318. static DEFINE_PRCC_CLK(1, spi3_ed, 7, 7, NULL);
  319. static DEFINE_PRCC_CLK(1, spi3_v1, 7, -1, NULL);
  320. static DEFINE_PRCC_CLK(1, i2c2, 6, 6, &clk_i2cclk);
  321. static DEFINE_PRCC_CLK(1, sdi0, 5, 5, &clk_sdmmcclk);
  322. static DEFINE_PRCC_CLK(1, msp1_ed, 4, 4, &clk_msp02clk);
  323. static DEFINE_PRCC_CLK(1, msp1_v1, 4, 4, &clk_msp1clk);
  324. static DEFINE_PRCC_CLK(1, msp0, 3, 3, &clk_msp02clk);
  325. static DEFINE_PRCC_CLK(1, i2c1, 2, 2, &clk_i2cclk);
  326. static DEFINE_PRCC_CLK(1, uart1, 1, 1, &clk_uartclk);
  327. static DEFINE_PRCC_CLK(1, uart0, 0, 0, &clk_uartclk);
  328. /* Peripheral Cluster #2 */
  329. static DEFINE_PRCC_CLK(2, gpio1_ed, 12, -1, NULL);
  330. static DEFINE_PRCC_CLK(2, ssitx_ed, 11, -1, NULL);
  331. static DEFINE_PRCC_CLK(2, ssirx_ed, 10, -1, NULL);
  332. static DEFINE_PRCC_CLK(2, spi0_ed, 9, -1, NULL);
  333. static DEFINE_PRCC_CLK(2, sdi3_ed, 8, 6, &clk_sdmmcclk);
  334. static DEFINE_PRCC_CLK(2, sdi1_ed, 7, 5, &clk_sdmmcclk);
  335. static DEFINE_PRCC_CLK(2, msp2_ed, 6, 4, &clk_msp02clk);
  336. static DEFINE_PRCC_CLK(2, sdi4_ed, 4, 2, &clk_sdmmcclk);
  337. static DEFINE_PRCC_CLK(2, pwl_ed, 3, 1, NULL);
  338. static DEFINE_PRCC_CLK(2, spi1_ed, 2, -1, NULL);
  339. static DEFINE_PRCC_CLK(2, spi2_ed, 1, -1, NULL);
  340. static DEFINE_PRCC_CLK(2, i2c3_ed, 0, 0, &clk_i2cclk);
  341. static DEFINE_PRCC_CLK(2, gpio1_v1, 11, -1, NULL);
  342. static DEFINE_PRCC_CLK(2, ssitx_v1, 10, 7, NULL);
  343. static DEFINE_PRCC_CLK(2, ssirx_v1, 9, 6, NULL);
  344. static DEFINE_PRCC_CLK(2, spi0_v1, 8, -1, NULL);
  345. static DEFINE_PRCC_CLK(2, sdi3_v1, 7, 5, &clk_sdmmcclk);
  346. static DEFINE_PRCC_CLK(2, sdi1_v1, 6, 4, &clk_sdmmcclk);
  347. static DEFINE_PRCC_CLK(2, msp2_v1, 5, 3, &clk_msp02clk);
  348. static DEFINE_PRCC_CLK(2, sdi4_v1, 4, 2, &clk_sdmmcclk);
  349. static DEFINE_PRCC_CLK(2, pwl_v1, 3, 1, NULL);
  350. static DEFINE_PRCC_CLK(2, spi1_v1, 2, -1, NULL);
  351. static DEFINE_PRCC_CLK(2, spi2_v1, 1, -1, NULL);
  352. static DEFINE_PRCC_CLK(2, i2c3_v1, 0, 0, &clk_i2cclk);
  353. /* Peripheral Cluster #3 */
  354. static DEFINE_PRCC_CLK(3, gpio2, 8, -1, NULL);
  355. static DEFINE_PRCC_CLK(3, sdi5, 7, 7, &clk_sdmmcclk);
  356. static DEFINE_PRCC_CLK(3, uart2, 6, 6, &clk_uartclk);
  357. static DEFINE_PRCC_CLK(3, ske, 5, 5, &clk_32khz);
  358. static DEFINE_PRCC_CLK(3, sdi2, 4, 4, &clk_sdmmcclk);
  359. static DEFINE_PRCC_CLK(3, i2c0, 3, 3, &clk_i2cclk);
  360. static DEFINE_PRCC_CLK(3, ssp1_ed, 2, 2, &clk_i2cclk);
  361. static DEFINE_PRCC_CLK(3, ssp0_ed, 1, 1, &clk_i2cclk);
  362. static DEFINE_PRCC_CLK(3, ssp1_v1, 2, 2, &clk_sspclk);
  363. static DEFINE_PRCC_CLK(3, ssp0_v1, 1, 1, &clk_sspclk);
  364. static DEFINE_PRCC_CLK(3, fsmc, 0, -1, NULL);
  365. /* Peripheral Cluster #4 is in the always on domain */
  366. /* Peripheral Cluster #5 */
  367. static DEFINE_PRCC_CLK(5, gpio3, 1, -1, NULL);
  368. static DEFINE_PRCC_CLK(5, usb_ed, 0, 0, &clk_i2cclk);
  369. static DEFINE_PRCC_CLK(5, usb_v1, 0, 0, NULL);
  370. /* Peripheral Cluster #6 */
  371. /* MTU ID in data */
  372. static DEFINE_PRCC_CLK_CUSTOM(6, mtu1_v1, 8, -1, NULL, clk_mtu_get_rate, 1);
  373. static DEFINE_PRCC_CLK_CUSTOM(6, mtu0_v1, 7, -1, NULL, clk_mtu_get_rate, 0);
  374. static DEFINE_PRCC_CLK(6, cfgreg_v1, 6, 6, NULL);
  375. static DEFINE_PRCC_CLK(6, dmc_ed, 6, 6, NULL);
  376. static DEFINE_PRCC_CLK(6, hash1, 5, -1, NULL);
  377. static DEFINE_PRCC_CLK(6, unipro_v1, 4, 1, &clk_uniproclk);
  378. static DEFINE_PRCC_CLK(6, cryp1_ed, 4, -1, NULL);
  379. static DEFINE_PRCC_CLK(6, pka, 3, -1, NULL);
  380. static DEFINE_PRCC_CLK(6, hash0, 2, -1, NULL);
  381. static DEFINE_PRCC_CLK(6, cryp0, 1, -1, NULL);
  382. static DEFINE_PRCC_CLK(6, rng_ed, 0, 0, &clk_i2cclk);
  383. static DEFINE_PRCC_CLK(6, rng_v1, 0, 0, &clk_rngclk);
  384. /* Peripheral Cluster #7 */
  385. static DEFINE_PRCC_CLK(7, tzpc0_ed, 4, -1, NULL);
  386. /* MTU ID in data */
  387. static DEFINE_PRCC_CLK_CUSTOM(7, mtu1_ed, 3, -1, NULL, clk_mtu_get_rate, 1);
  388. static DEFINE_PRCC_CLK_CUSTOM(7, mtu0_ed, 2, -1, NULL, clk_mtu_get_rate, 0);
  389. static DEFINE_PRCC_CLK(7, wdg_ed, 1, -1, NULL);
  390. static DEFINE_PRCC_CLK(7, cfgreg_ed, 0, -1, NULL);
  391. static struct clk clk_dummy_apb_pclk;
  392. static struct clk_lookup u8500_common_clks[] = {
  393. CLK(dummy_apb_pclk, NULL, "apb_pclk"),
  394. /* Peripheral Cluster #1 */
  395. CLK(gpio0, "gpio.0", NULL),
  396. CLK(gpio0, "gpio.1", NULL),
  397. CLK(slimbus0, "slimbus0", NULL),
  398. CLK(i2c2, "nmk-i2c.2", NULL),
  399. CLK(sdi0, "sdi0", NULL),
  400. CLK(msp0, "msp0", NULL),
  401. CLK(i2c1, "nmk-i2c.1", NULL),
  402. CLK(uart1, "uart1", NULL),
  403. CLK(uart0, "uart0", NULL),
  404. /* Peripheral Cluster #3 */
  405. CLK(gpio2, "gpio.2", NULL),
  406. CLK(gpio2, "gpio.3", NULL),
  407. CLK(gpio2, "gpio.4", NULL),
  408. CLK(gpio2, "gpio.5", NULL),
  409. CLK(sdi5, "sdi5", NULL),
  410. CLK(uart2, "uart2", NULL),
  411. CLK(ske, "ske", NULL),
  412. CLK(sdi2, "sdi2", NULL),
  413. CLK(i2c0, "nmk-i2c.0", NULL),
  414. CLK(fsmc, "fsmc", NULL),
  415. /* Peripheral Cluster #5 */
  416. CLK(gpio3, "gpio.8", NULL),
  417. /* Peripheral Cluster #6 */
  418. CLK(hash1, "hash1", NULL),
  419. CLK(pka, "pka", NULL),
  420. CLK(hash0, "hash0", NULL),
  421. CLK(cryp0, "cryp0", NULL),
  422. /* PRCMU level clock gating */
  423. /* Bank 0 */
  424. CLK(svaclk, "sva", NULL),
  425. CLK(siaclk, "sia", NULL),
  426. CLK(sgaclk, "sga", NULL),
  427. CLK(slimclk, "slim", NULL),
  428. CLK(lcdclk, "lcd", NULL),
  429. CLK(bmlclk, "bml", NULL),
  430. CLK(hsitxclk, "stm-hsi.0", NULL),
  431. CLK(hsirxclk, "stm-hsi.1", NULL),
  432. CLK(hdmiclk, "hdmi", NULL),
  433. CLK(apeatclk, "apeat", NULL),
  434. CLK(apetraceclk, "apetrace", NULL),
  435. CLK(mcdeclk, "mcde", NULL),
  436. CLK(ipi2clk, "ipi2", NULL),
  437. CLK(dmaclk, "dma40.0", NULL),
  438. CLK(b2r2clk, "b2r2", NULL),
  439. CLK(tvclk, "tv", NULL),
  440. };
  441. static struct clk_lookup u8500_ed_clks[] = {
  442. /* Peripheral Cluster #1 */
  443. CLK(spi3_ed, "spi3", NULL),
  444. CLK(msp1_ed, "msp1", NULL),
  445. /* Peripheral Cluster #2 */
  446. CLK(gpio1_ed, "gpio.6", NULL),
  447. CLK(gpio1_ed, "gpio.7", NULL),
  448. CLK(ssitx_ed, "ssitx", NULL),
  449. CLK(ssirx_ed, "ssirx", NULL),
  450. CLK(spi0_ed, "spi0", NULL),
  451. CLK(sdi3_ed, "sdi3", NULL),
  452. CLK(sdi1_ed, "sdi1", NULL),
  453. CLK(msp2_ed, "msp2", NULL),
  454. CLK(sdi4_ed, "sdi4", NULL),
  455. CLK(pwl_ed, "pwl", NULL),
  456. CLK(spi1_ed, "spi1", NULL),
  457. CLK(spi2_ed, "spi2", NULL),
  458. CLK(i2c3_ed, "nmk-i2c.3", NULL),
  459. /* Peripheral Cluster #3 */
  460. CLK(ssp1_ed, "ssp1", NULL),
  461. CLK(ssp0_ed, "ssp0", NULL),
  462. /* Peripheral Cluster #5 */
  463. CLK(usb_ed, "musb_hdrc.0", "usb"),
  464. /* Peripheral Cluster #6 */
  465. CLK(dmc_ed, "dmc", NULL),
  466. CLK(cryp1_ed, "cryp1", NULL),
  467. CLK(rng_ed, "rng", NULL),
  468. /* Peripheral Cluster #7 */
  469. CLK(tzpc0_ed, "tzpc0", NULL),
  470. CLK(mtu1_ed, "mtu1", NULL),
  471. CLK(mtu0_ed, "mtu0", NULL),
  472. CLK(wdg_ed, "wdg", NULL),
  473. CLK(cfgreg_ed, "cfgreg", NULL),
  474. };
  475. static struct clk_lookup u8500_v1_clks[] = {
  476. /* Peripheral Cluster #1 */
  477. CLK(i2c4, "nmk-i2c.4", NULL),
  478. CLK(spi3_v1, "spi3", NULL),
  479. CLK(msp1_v1, "msp1", NULL),
  480. /* Peripheral Cluster #2 */
  481. CLK(gpio1_v1, "gpio.6", NULL),
  482. CLK(gpio1_v1, "gpio.7", NULL),
  483. CLK(ssitx_v1, "ssitx", NULL),
  484. CLK(ssirx_v1, "ssirx", NULL),
  485. CLK(spi0_v1, "spi0", NULL),
  486. CLK(sdi3_v1, "sdi3", NULL),
  487. CLK(sdi1_v1, "sdi1", NULL),
  488. CLK(msp2_v1, "msp2", NULL),
  489. CLK(sdi4_v1, "sdi4", NULL),
  490. CLK(pwl_v1, "pwl", NULL),
  491. CLK(spi1_v1, "spi1", NULL),
  492. CLK(spi2_v1, "spi2", NULL),
  493. CLK(i2c3_v1, "nmk-i2c.3", NULL),
  494. /* Peripheral Cluster #3 */
  495. CLK(ssp1_v1, "ssp1", NULL),
  496. CLK(ssp0_v1, "ssp0", NULL),
  497. /* Peripheral Cluster #5 */
  498. CLK(usb_v1, "musb_hdrc.0", "usb"),
  499. /* Peripheral Cluster #6 */
  500. CLK(mtu1_v1, "mtu1", NULL),
  501. CLK(mtu0_v1, "mtu0", NULL),
  502. CLK(cfgreg_v1, "cfgreg", NULL),
  503. CLK(hash1, "hash1", NULL),
  504. CLK(unipro_v1, "unipro", NULL),
  505. CLK(rng_v1, "rng", NULL),
  506. /* PRCMU level clock gating */
  507. /* Bank 0 */
  508. CLK(uniproclk, "uniproclk", NULL),
  509. CLK(dsialtclk, "dsialt", NULL),
  510. /* Bank 1 */
  511. CLK(rngclk, "rng", NULL),
  512. CLK(uiccclk, "uicc", NULL),
  513. };
  514. int __init clk_init(void)
  515. {
  516. if (cpu_is_u8500ed()) {
  517. clk_prcmu_ops.enable = clk_prcmu_ed_enable;
  518. clk_prcmu_ops.disable = clk_prcmu_ed_disable;
  519. clk_per6clk.rate = 100000000;
  520. } else if (cpu_is_u5500()) {
  521. /* Clock tree for U5500 not implemented yet */
  522. clk_prcc_ops.enable = clk_prcc_ops.disable = NULL;
  523. clk_prcmu_ops.enable = clk_prcmu_ops.disable = NULL;
  524. clk_per6clk.rate = 26000000;
  525. }
  526. clkdev_add_table(u8500_common_clks, ARRAY_SIZE(u8500_common_clks));
  527. if (cpu_is_u8500ed())
  528. clkdev_add_table(u8500_ed_clks, ARRAY_SIZE(u8500_ed_clks));
  529. else
  530. clkdev_add_table(u8500_v1_clks, ARRAY_SIZE(u8500_v1_clks));
  531. return 0;
  532. }