clock-r8a7740.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  1. /*
  2. * R8A7740 processor support
  3. *
  4. * Copyright (C) 2011 Renesas Solutions Corp.
  5. * Copyright (C) 2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
  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
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. */
  20. #include <linux/init.h>
  21. #include <linux/kernel.h>
  22. #include <linux/io.h>
  23. #include <linux/sh_clk.h>
  24. #include <linux/clkdev.h>
  25. #include <mach/common.h>
  26. #include <mach/r8a7740.h>
  27. /*
  28. * | MDx | XTAL1/EXTAL1 | System | EXTALR |
  29. * Clock |-------+-----------------+ clock | 32.768 | RCLK
  30. * Mode | 2/1/0 | src MHz | source | KHz | source
  31. * -------+-------+-----------------+-----------+--------+----------
  32. * 0 | 0 0 0 | External 20~50 | XTAL1 | O | EXTALR
  33. * 1 | 0 0 1 | Crystal 20~30 | XTAL1 | O | EXTALR
  34. * 2 | 0 1 0 | External 40~50 | XTAL1 / 2 | O | EXTALR
  35. * 3 | 0 1 1 | Crystal 40~50 | XTAL1 / 2 | O | EXTALR
  36. * 4 | 1 0 0 | External 20~50 | XTAL1 | x | XTAL1 / 1024
  37. * 5 | 1 0 1 | Crystal 20~30 | XTAL1 | x | XTAL1 / 1024
  38. * 6 | 1 1 0 | External 40~50 | XTAL1 / 2 | x | XTAL1 / 2048
  39. * 7 | 1 1 1 | Crystal 40~50 | XTAL1 / 2 | x | XTAL1 / 2048
  40. */
  41. /* CPG registers */
  42. #define FRQCRA 0xe6150000
  43. #define FRQCRB 0xe6150004
  44. #define FRQCRC 0xe61500e0
  45. #define PLLC01CR 0xe6150028
  46. #define SUBCKCR 0xe6150080
  47. #define USBCKCR 0xe615008c
  48. #define MSTPSR0 0xe6150030
  49. #define MSTPSR1 0xe6150038
  50. #define MSTPSR2 0xe6150040
  51. #define MSTPSR3 0xe6150048
  52. #define MSTPSR4 0xe615004c
  53. #define SMSTPCR0 0xe6150130
  54. #define SMSTPCR1 0xe6150134
  55. #define SMSTPCR2 0xe6150138
  56. #define SMSTPCR3 0xe615013c
  57. #define SMSTPCR4 0xe6150140
  58. /* Fixed 32 KHz root clock from EXTALR pin */
  59. static struct clk extalr_clk = {
  60. .rate = 32768,
  61. };
  62. /*
  63. * 25MHz default rate for the EXTAL1 root input clock.
  64. * If needed, reset this with clk_set_rate() from the platform code.
  65. */
  66. static struct clk extal1_clk = {
  67. .rate = 25000000,
  68. };
  69. /*
  70. * 48MHz default rate for the EXTAL2 root input clock.
  71. * If needed, reset this with clk_set_rate() from the platform code.
  72. */
  73. static struct clk extal2_clk = {
  74. .rate = 48000000,
  75. };
  76. /*
  77. * 27MHz default rate for the DV_CLKI root input clock.
  78. * If needed, reset this with clk_set_rate() from the platform code.
  79. */
  80. static struct clk dv_clk = {
  81. .rate = 27000000,
  82. };
  83. static unsigned long div_recalc(struct clk *clk)
  84. {
  85. return clk->parent->rate / (int)(clk->priv);
  86. }
  87. static struct sh_clk_ops div_clk_ops = {
  88. .recalc = div_recalc,
  89. };
  90. /* extal1 / 2 */
  91. static struct clk extal1_div2_clk = {
  92. .ops = &div_clk_ops,
  93. .priv = (void *)2,
  94. .parent = &extal1_clk,
  95. };
  96. /* extal1 / 1024 */
  97. static struct clk extal1_div1024_clk = {
  98. .ops = &div_clk_ops,
  99. .priv = (void *)1024,
  100. .parent = &extal1_clk,
  101. };
  102. /* extal1 / 2 / 1024 */
  103. static struct clk extal1_div2048_clk = {
  104. .ops = &div_clk_ops,
  105. .priv = (void *)1024,
  106. .parent = &extal1_div2_clk,
  107. };
  108. /* extal2 / 2 */
  109. static struct clk extal2_div2_clk = {
  110. .ops = &div_clk_ops,
  111. .priv = (void *)2,
  112. .parent = &extal2_clk,
  113. };
  114. static struct sh_clk_ops followparent_clk_ops = {
  115. .recalc = followparent_recalc,
  116. };
  117. /* Main clock */
  118. static struct clk system_clk = {
  119. .ops = &followparent_clk_ops,
  120. };
  121. static struct clk system_div2_clk = {
  122. .ops = &div_clk_ops,
  123. .priv = (void *)2,
  124. .parent = &system_clk,
  125. };
  126. /* r_clk */
  127. static struct clk r_clk = {
  128. .ops = &followparent_clk_ops,
  129. };
  130. /* PLLC0/PLLC1 */
  131. static unsigned long pllc01_recalc(struct clk *clk)
  132. {
  133. unsigned long mult = 1;
  134. if (__raw_readl(PLLC01CR) & (1 << 14))
  135. mult = ((__raw_readl(clk->enable_reg) >> 24) & 0x7f) + 1;
  136. return clk->parent->rate * mult;
  137. }
  138. static struct sh_clk_ops pllc01_clk_ops = {
  139. .recalc = pllc01_recalc,
  140. };
  141. static struct clk pllc0_clk = {
  142. .ops = &pllc01_clk_ops,
  143. .flags = CLK_ENABLE_ON_INIT,
  144. .parent = &system_clk,
  145. .enable_reg = (void __iomem *)FRQCRC,
  146. };
  147. static struct clk pllc1_clk = {
  148. .ops = &pllc01_clk_ops,
  149. .flags = CLK_ENABLE_ON_INIT,
  150. .parent = &system_div2_clk,
  151. .enable_reg = (void __iomem *)FRQCRA,
  152. };
  153. /* PLLC1 / 2 */
  154. static struct clk pllc1_div2_clk = {
  155. .ops = &div_clk_ops,
  156. .priv = (void *)2,
  157. .parent = &pllc1_clk,
  158. };
  159. /* USB clock */
  160. static struct clk *usb24s_parents[] = {
  161. [0] = &system_clk,
  162. [1] = &extal2_clk
  163. };
  164. static int usb24s_enable(struct clk *clk)
  165. {
  166. __raw_writel(__raw_readl(USBCKCR) & ~(1 << 8), USBCKCR);
  167. return 0;
  168. }
  169. static void usb24s_disable(struct clk *clk)
  170. {
  171. __raw_writel(__raw_readl(USBCKCR) | (1 << 8), USBCKCR);
  172. }
  173. static int usb24s_set_parent(struct clk *clk, struct clk *parent)
  174. {
  175. int i, ret;
  176. u32 val;
  177. if (!clk->parent_table || !clk->parent_num)
  178. return -EINVAL;
  179. /* Search the parent */
  180. for (i = 0; i < clk->parent_num; i++)
  181. if (clk->parent_table[i] == parent)
  182. break;
  183. if (i == clk->parent_num)
  184. return -ENODEV;
  185. ret = clk_reparent(clk, parent);
  186. if (ret < 0)
  187. return ret;
  188. val = __raw_readl(USBCKCR);
  189. val &= ~(1 << 7);
  190. val |= i << 7;
  191. __raw_writel(val, USBCKCR);
  192. return 0;
  193. }
  194. static struct sh_clk_ops usb24s_clk_ops = {
  195. .recalc = followparent_recalc,
  196. .enable = usb24s_enable,
  197. .disable = usb24s_disable,
  198. .set_parent = usb24s_set_parent,
  199. };
  200. static struct clk usb24s_clk = {
  201. .ops = &usb24s_clk_ops,
  202. .parent_table = usb24s_parents,
  203. .parent_num = ARRAY_SIZE(usb24s_parents),
  204. .parent = &system_clk,
  205. };
  206. static unsigned long usb24_recalc(struct clk *clk)
  207. {
  208. return clk->parent->rate /
  209. ((__raw_readl(USBCKCR) & (1 << 6)) ? 1 : 2);
  210. };
  211. static int usb24_set_rate(struct clk *clk, unsigned long rate)
  212. {
  213. u32 val;
  214. /* closer to which ? parent->rate or parent->rate/2 */
  215. val = __raw_readl(USBCKCR);
  216. val &= ~(1 << 6);
  217. val |= (rate > (clk->parent->rate / 4) * 3) << 6;
  218. __raw_writel(val, USBCKCR);
  219. return 0;
  220. }
  221. static struct sh_clk_ops usb24_clk_ops = {
  222. .recalc = usb24_recalc,
  223. .set_rate = usb24_set_rate,
  224. };
  225. static struct clk usb24_clk = {
  226. .ops = &usb24_clk_ops,
  227. .parent = &usb24s_clk,
  228. };
  229. struct clk *main_clks[] = {
  230. &extalr_clk,
  231. &extal1_clk,
  232. &extal2_clk,
  233. &extal1_div2_clk,
  234. &extal1_div1024_clk,
  235. &extal1_div2048_clk,
  236. &extal2_div2_clk,
  237. &dv_clk,
  238. &system_clk,
  239. &system_div2_clk,
  240. &r_clk,
  241. &pllc0_clk,
  242. &pllc1_clk,
  243. &pllc1_div2_clk,
  244. &usb24s_clk,
  245. &usb24_clk,
  246. };
  247. static void div4_kick(struct clk *clk)
  248. {
  249. unsigned long value;
  250. /* set KICK bit in FRQCRB to update hardware setting */
  251. value = __raw_readl(FRQCRB);
  252. value |= (1 << 31);
  253. __raw_writel(value, FRQCRB);
  254. }
  255. static int divisors[] = { 2, 3, 4, 6, 8, 12, 16, 18,
  256. 24, 32, 36, 48, 0, 72, 96, 0 };
  257. static struct clk_div_mult_table div4_div_mult_table = {
  258. .divisors = divisors,
  259. .nr_divisors = ARRAY_SIZE(divisors),
  260. };
  261. static struct clk_div4_table div4_table = {
  262. .div_mult_table = &div4_div_mult_table,
  263. .kick = div4_kick,
  264. };
  265. enum {
  266. DIV4_I, DIV4_ZG, DIV4_B, DIV4_M1, DIV4_HP,
  267. DIV4_HPP, DIV4_USBP, DIV4_S, DIV4_ZB, DIV4_M3, DIV4_CP,
  268. DIV4_NR
  269. };
  270. struct clk div4_clks[DIV4_NR] = {
  271. [DIV4_I] = SH_CLK_DIV4(&pllc1_clk, FRQCRA, 20, 0x6fff, CLK_ENABLE_ON_INIT),
  272. [DIV4_ZG] = SH_CLK_DIV4(&pllc1_clk, FRQCRA, 16, 0x6fff, CLK_ENABLE_ON_INIT),
  273. [DIV4_B] = SH_CLK_DIV4(&pllc1_clk, FRQCRA, 8, 0x6fff, CLK_ENABLE_ON_INIT),
  274. [DIV4_M1] = SH_CLK_DIV4(&pllc1_clk, FRQCRA, 4, 0x6fff, CLK_ENABLE_ON_INIT),
  275. [DIV4_HP] = SH_CLK_DIV4(&pllc1_clk, FRQCRB, 4, 0x6fff, 0),
  276. [DIV4_HPP] = SH_CLK_DIV4(&pllc1_clk, FRQCRC, 20, 0x6fff, 0),
  277. [DIV4_USBP] = SH_CLK_DIV4(&pllc1_clk, FRQCRC, 16, 0x6fff, 0),
  278. [DIV4_S] = SH_CLK_DIV4(&pllc1_clk, FRQCRC, 12, 0x6fff, 0),
  279. [DIV4_ZB] = SH_CLK_DIV4(&pllc1_clk, FRQCRC, 8, 0x6fff, 0),
  280. [DIV4_M3] = SH_CLK_DIV4(&pllc1_clk, FRQCRC, 4, 0x6fff, 0),
  281. [DIV4_CP] = SH_CLK_DIV4(&pllc1_clk, FRQCRC, 0, 0x6fff, 0),
  282. };
  283. enum {
  284. DIV6_SUB,
  285. DIV6_NR
  286. };
  287. static struct clk div6_clks[DIV6_NR] = {
  288. [DIV6_SUB] = SH_CLK_DIV6(&pllc1_div2_clk, SUBCKCR, 0),
  289. };
  290. enum {
  291. MSTP125,
  292. MSTP116, MSTP111, MSTP100, MSTP117,
  293. MSTP230,
  294. MSTP222,
  295. MSTP207, MSTP206, MSTP204, MSTP203, MSTP202, MSTP201, MSTP200,
  296. MSTP329, MSTP328, MSTP323, MSTP320,
  297. MSTP314, MSTP313, MSTP312,
  298. MSTP309,
  299. MSTP416, MSTP415, MSTP407, MSTP406,
  300. MSTP_NR
  301. };
  302. static struct clk mstp_clks[MSTP_NR] = {
  303. [MSTP125] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR1, 25, 0), /* TMU0 */
  304. [MSTP117] = SH_CLK_MSTP32(&div4_clks[DIV4_B], SMSTPCR1, 17, 0), /* LCDC1 */
  305. [MSTP116] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR1, 16, 0), /* IIC0 */
  306. [MSTP111] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR1, 11, 0), /* TMU1 */
  307. [MSTP100] = SH_CLK_MSTP32(&div4_clks[DIV4_B], SMSTPCR1, 0, 0), /* LCDC0 */
  308. [MSTP230] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 30, 0), /* SCIFA6 */
  309. [MSTP222] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 22, 0), /* SCIFA7 */
  310. [MSTP207] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 7, 0), /* SCIFA5 */
  311. [MSTP206] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 6, 0), /* SCIFB */
  312. [MSTP204] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 4, 0), /* SCIFA0 */
  313. [MSTP203] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 3, 0), /* SCIFA1 */
  314. [MSTP202] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 2, 0), /* SCIFA2 */
  315. [MSTP201] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 1, 0), /* SCIFA3 */
  316. [MSTP200] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 0, 0), /* SCIFA4 */
  317. [MSTP329] = SH_CLK_MSTP32(&r_clk, SMSTPCR3, 29, 0), /* CMT10 */
  318. [MSTP328] = SH_CLK_MSTP32(&div4_clks[DIV4_HP], SMSTPCR3, 28, 0), /* FSI */
  319. [MSTP323] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR3, 23, 0), /* IIC1 */
  320. [MSTP320] = SH_CLK_MSTP32(&div4_clks[DIV4_HP], SMSTPCR3, 20, 0), /* USBF */
  321. [MSTP314] = SH_CLK_MSTP32(&div4_clks[DIV4_HP], SMSTPCR3, 14, 0), /* SDHI0 */
  322. [MSTP313] = SH_CLK_MSTP32(&div4_clks[DIV4_HP], SMSTPCR3, 13, 0), /* SDHI1 */
  323. [MSTP312] = SH_CLK_MSTP32(&div4_clks[DIV4_HP], SMSTPCR3, 12, 0), /* MMC */
  324. [MSTP309] = SH_CLK_MSTP32(&div4_clks[DIV4_HP], SMSTPCR3, 9, 0), /* GEther */
  325. [MSTP416] = SH_CLK_MSTP32(&div4_clks[DIV4_HP], SMSTPCR4, 16, 0), /* USBHOST */
  326. [MSTP415] = SH_CLK_MSTP32(&div4_clks[DIV4_HP], SMSTPCR4, 15, 0), /* SDHI2 */
  327. [MSTP407] = SH_CLK_MSTP32(&div4_clks[DIV4_HP], SMSTPCR4, 7, 0), /* USB-Func */
  328. [MSTP406] = SH_CLK_MSTP32(&div4_clks[DIV4_HP], SMSTPCR4, 6, 0), /* USB Phy */
  329. };
  330. static struct clk_lookup lookups[] = {
  331. /* main clocks */
  332. CLKDEV_CON_ID("extalr", &extalr_clk),
  333. CLKDEV_CON_ID("extal1", &extal1_clk),
  334. CLKDEV_CON_ID("extal2", &extal2_clk),
  335. CLKDEV_CON_ID("extal1_div2", &extal1_div2_clk),
  336. CLKDEV_CON_ID("extal1_div1024", &extal1_div1024_clk),
  337. CLKDEV_CON_ID("extal1_div2048", &extal1_div2048_clk),
  338. CLKDEV_CON_ID("extal2_div2", &extal2_div2_clk),
  339. CLKDEV_CON_ID("dv_clk", &dv_clk),
  340. CLKDEV_CON_ID("system_clk", &system_clk),
  341. CLKDEV_CON_ID("system_div2_clk", &system_div2_clk),
  342. CLKDEV_CON_ID("r_clk", &r_clk),
  343. CLKDEV_CON_ID("pllc0_clk", &pllc0_clk),
  344. CLKDEV_CON_ID("pllc1_clk", &pllc1_clk),
  345. CLKDEV_CON_ID("pllc1_div2_clk", &pllc1_div2_clk),
  346. CLKDEV_CON_ID("usb24s", &usb24s_clk),
  347. /* DIV4 clocks */
  348. CLKDEV_CON_ID("i_clk", &div4_clks[DIV4_I]),
  349. CLKDEV_CON_ID("zg_clk", &div4_clks[DIV4_ZG]),
  350. CLKDEV_CON_ID("b_clk", &div4_clks[DIV4_B]),
  351. CLKDEV_CON_ID("m1_clk", &div4_clks[DIV4_M1]),
  352. CLKDEV_CON_ID("hp_clk", &div4_clks[DIV4_HP]),
  353. CLKDEV_CON_ID("hpp_clk", &div4_clks[DIV4_HPP]),
  354. CLKDEV_CON_ID("s_clk", &div4_clks[DIV4_S]),
  355. CLKDEV_CON_ID("zb_clk", &div4_clks[DIV4_ZB]),
  356. CLKDEV_CON_ID("m3_clk", &div4_clks[DIV4_M3]),
  357. CLKDEV_CON_ID("cp_clk", &div4_clks[DIV4_CP]),
  358. /* DIV6 clocks */
  359. CLKDEV_CON_ID("sub_clk", &div6_clks[DIV6_SUB]),
  360. /* MSTP32 clocks */
  361. CLKDEV_DEV_ID("sh_mobile_lcdc_fb.0", &mstp_clks[MSTP100]),
  362. CLKDEV_DEV_ID("sh_tmu.1", &mstp_clks[MSTP111]),
  363. CLKDEV_DEV_ID("i2c-sh_mobile.0", &mstp_clks[MSTP116]),
  364. CLKDEV_DEV_ID("sh_mobile_lcdc_fb.1", &mstp_clks[MSTP117]),
  365. CLKDEV_DEV_ID("sh_tmu.0", &mstp_clks[MSTP125]),
  366. CLKDEV_DEV_ID("sh-sci.4", &mstp_clks[MSTP200]),
  367. CLKDEV_DEV_ID("sh-sci.3", &mstp_clks[MSTP201]),
  368. CLKDEV_DEV_ID("sh-sci.2", &mstp_clks[MSTP202]),
  369. CLKDEV_DEV_ID("sh-sci.1", &mstp_clks[MSTP203]),
  370. CLKDEV_DEV_ID("sh-sci.0", &mstp_clks[MSTP204]),
  371. CLKDEV_DEV_ID("sh-sci.8", &mstp_clks[MSTP206]),
  372. CLKDEV_DEV_ID("sh-sci.5", &mstp_clks[MSTP207]),
  373. CLKDEV_DEV_ID("sh-sci.7", &mstp_clks[MSTP222]),
  374. CLKDEV_DEV_ID("sh-sci.6", &mstp_clks[MSTP230]),
  375. CLKDEV_DEV_ID("sh_cmt.10", &mstp_clks[MSTP329]),
  376. CLKDEV_DEV_ID("sh_fsi2", &mstp_clks[MSTP328]),
  377. CLKDEV_DEV_ID("i2c-sh_mobile.1", &mstp_clks[MSTP323]),
  378. CLKDEV_DEV_ID("renesas_usbhs", &mstp_clks[MSTP320]),
  379. CLKDEV_DEV_ID("sh_mobile_sdhi.0", &mstp_clks[MSTP314]),
  380. CLKDEV_DEV_ID("sh_mobile_sdhi.1", &mstp_clks[MSTP313]),
  381. CLKDEV_DEV_ID("sh_mmcif", &mstp_clks[MSTP312]),
  382. CLKDEV_DEV_ID("sh-eth", &mstp_clks[MSTP309]),
  383. CLKDEV_DEV_ID("sh_mobile_sdhi.2", &mstp_clks[MSTP415]),
  384. /* ICK */
  385. CLKDEV_ICK_ID("host", "renesas_usbhs", &mstp_clks[MSTP416]),
  386. CLKDEV_ICK_ID("func", "renesas_usbhs", &mstp_clks[MSTP407]),
  387. CLKDEV_ICK_ID("phy", "renesas_usbhs", &mstp_clks[MSTP406]),
  388. CLKDEV_ICK_ID("pci", "renesas_usbhs", &div4_clks[DIV4_USBP]),
  389. CLKDEV_ICK_ID("usb24", "renesas_usbhs", &usb24_clk),
  390. };
  391. void __init r8a7740_clock_init(u8 md_ck)
  392. {
  393. int k, ret = 0;
  394. /* detect system clock parent */
  395. if (md_ck & MD_CK1)
  396. system_clk.parent = &extal1_div2_clk;
  397. else
  398. system_clk.parent = &extal1_clk;
  399. /* detect RCLK parent */
  400. switch (md_ck & (MD_CK2 | MD_CK1)) {
  401. case MD_CK2 | MD_CK1:
  402. r_clk.parent = &extal1_div2048_clk;
  403. break;
  404. case MD_CK2:
  405. r_clk.parent = &extal1_div1024_clk;
  406. break;
  407. case MD_CK1:
  408. default:
  409. r_clk.parent = &extalr_clk;
  410. break;
  411. }
  412. for (k = 0; !ret && (k < ARRAY_SIZE(main_clks)); k++)
  413. ret = clk_register(main_clks[k]);
  414. if (!ret)
  415. ret = sh_clk_div4_register(div4_clks, DIV4_NR, &div4_table);
  416. if (!ret)
  417. ret = sh_clk_div6_register(div6_clks, DIV6_NR);
  418. if (!ret)
  419. ret = sh_clk_mstp32_register(mstp_clks, MSTP_NR);
  420. clkdev_add_table(lookups, ARRAY_SIZE(lookups));
  421. if (!ret)
  422. shmobile_clk_init();
  423. else
  424. panic("failed to setup r8a7740 clocks\n");
  425. }