tegra20_clocks_data.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143
  1. /*
  2. * arch/arm/mach-tegra/tegra2_clocks.c
  3. *
  4. * Copyright (C) 2010 Google, Inc.
  5. * Copyright (c) 2012 NVIDIA CORPORATION. All rights reserved.
  6. *
  7. * Author:
  8. * Colin Cross <ccross@google.com>
  9. *
  10. * This software is licensed under the terms of the GNU General Public
  11. * License version 2, as published by the Free Software Foundation, and
  12. * may be copied, distributed, and modified under those terms.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. */
  20. #include <linux/clk-private.h>
  21. #include <linux/kernel.h>
  22. #include <linux/module.h>
  23. #include <linux/list.h>
  24. #include <linux/spinlock.h>
  25. #include <linux/delay.h>
  26. #include <linux/io.h>
  27. #include <linux/clk.h>
  28. #include "clock.h"
  29. #include "fuse.h"
  30. #include "tegra2_emc.h"
  31. #include "tegra20_clocks.h"
  32. #include "tegra_cpu_car.h"
  33. /* Clock definitions */
  34. #define DEFINE_CLK_TEGRA(_name, _rate, _ops, _flags, \
  35. _parent_names, _parents, _parent) \
  36. static struct clk tegra_##_name = { \
  37. .hw = &tegra_##_name##_hw.hw, \
  38. .name = #_name, \
  39. .rate = _rate, \
  40. .ops = _ops, \
  41. .flags = _flags, \
  42. .parent_names = _parent_names, \
  43. .parents = _parents, \
  44. .num_parents = ARRAY_SIZE(_parent_names), \
  45. .parent = _parent, \
  46. };
  47. static struct clk tegra_clk_32k;
  48. static struct clk_tegra tegra_clk_32k_hw = {
  49. .hw = {
  50. .clk = &tegra_clk_32k,
  51. },
  52. .fixed_rate = 32768,
  53. };
  54. static struct clk tegra_clk_32k = {
  55. .name = "clk_32k",
  56. .rate = 32768,
  57. .ops = &tegra_clk_32k_ops,
  58. .hw = &tegra_clk_32k_hw.hw,
  59. .flags = CLK_IS_ROOT,
  60. };
  61. static struct clk tegra_clk_m;
  62. static struct clk_tegra tegra_clk_m_hw = {
  63. .hw = {
  64. .clk = &tegra_clk_m,
  65. },
  66. .flags = ENABLE_ON_INIT,
  67. .reg = 0x1fc,
  68. .reg_shift = 28,
  69. .max_rate = 26000000,
  70. .fixed_rate = 0,
  71. };
  72. static struct clk tegra_clk_m = {
  73. .name = "clk_m",
  74. .ops = &tegra_clk_m_ops,
  75. .hw = &tegra_clk_m_hw.hw,
  76. .flags = CLK_IS_ROOT,
  77. };
  78. #define DEFINE_PLL(_name, _flags, _reg, _max_rate, _input_min, \
  79. _input_max, _cf_min, _cf_max, _vco_min, \
  80. _vco_max, _freq_table, _lock_delay, _ops, \
  81. _fixed_rate, _parent) \
  82. static const char *tegra_##_name##_parent_names[] = { \
  83. #_parent, \
  84. }; \
  85. static struct clk *tegra_##_name##_parents[] = { \
  86. &tegra_##_parent, \
  87. }; \
  88. static struct clk tegra_##_name; \
  89. static struct clk_tegra tegra_##_name##_hw = { \
  90. .hw = { \
  91. .clk = &tegra_##_name, \
  92. }, \
  93. .flags = _flags, \
  94. .reg = _reg, \
  95. .max_rate = _max_rate, \
  96. .u.pll = { \
  97. .input_min = _input_min, \
  98. .input_max = _input_max, \
  99. .cf_min = _cf_min, \
  100. .cf_max = _cf_max, \
  101. .vco_min = _vco_min, \
  102. .vco_max = _vco_max, \
  103. .freq_table = _freq_table, \
  104. .lock_delay = _lock_delay, \
  105. .fixed_rate = _fixed_rate, \
  106. }, \
  107. }; \
  108. static struct clk tegra_##_name = { \
  109. .name = #_name, \
  110. .ops = &_ops, \
  111. .hw = &tegra_##_name##_hw.hw, \
  112. .parent = &tegra_##_parent, \
  113. .parent_names = tegra_##_name##_parent_names, \
  114. .parents = tegra_##_name##_parents, \
  115. .num_parents = 1, \
  116. };
  117. #define DEFINE_PLL_OUT(_name, _flags, _reg, _reg_shift, \
  118. _max_rate, _ops, _parent, _clk_flags) \
  119. static const char *tegra_##_name##_parent_names[] = { \
  120. #_parent, \
  121. }; \
  122. static struct clk *tegra_##_name##_parents[] = { \
  123. &tegra_##_parent, \
  124. }; \
  125. static struct clk tegra_##_name; \
  126. static struct clk_tegra tegra_##_name##_hw = { \
  127. .hw = { \
  128. .clk = &tegra_##_name, \
  129. }, \
  130. .flags = _flags, \
  131. .reg = _reg, \
  132. .max_rate = _max_rate, \
  133. .reg_shift = _reg_shift, \
  134. }; \
  135. static struct clk tegra_##_name = { \
  136. .name = #_name, \
  137. .ops = &tegra_pll_div_ops, \
  138. .hw = &tegra_##_name##_hw.hw, \
  139. .parent = &tegra_##_parent, \
  140. .parent_names = tegra_##_name##_parent_names, \
  141. .parents = tegra_##_name##_parents, \
  142. .num_parents = 1, \
  143. .flags = _clk_flags, \
  144. };
  145. static struct clk_pll_freq_table tegra_pll_s_freq_table[] = {
  146. {32768, 12000000, 366, 1, 1, 0},
  147. {32768, 13000000, 397, 1, 1, 0},
  148. {32768, 19200000, 586, 1, 1, 0},
  149. {32768, 26000000, 793, 1, 1, 0},
  150. {0, 0, 0, 0, 0, 0},
  151. };
  152. DEFINE_PLL(pll_s, PLL_ALT_MISC_REG, 0xf0, 26000000, 32768, 32768, 0,
  153. 0, 12000000, 26000000, tegra_pll_s_freq_table, 300,
  154. tegra_pll_ops, 0, clk_32k);
  155. static struct clk_pll_freq_table tegra_pll_c_freq_table[] = {
  156. { 12000000, 600000000, 600, 12, 1, 8 },
  157. { 13000000, 600000000, 600, 13, 1, 8 },
  158. { 19200000, 600000000, 500, 16, 1, 6 },
  159. { 26000000, 600000000, 600, 26, 1, 8 },
  160. { 0, 0, 0, 0, 0, 0 },
  161. };
  162. DEFINE_PLL(pll_c, PLL_HAS_CPCON, 0x80, 600000000, 2000000, 31000000, 1000000,
  163. 6000000, 20000000, 1400000000, tegra_pll_c_freq_table, 300,
  164. tegra_pll_ops, 0, clk_m);
  165. DEFINE_PLL_OUT(pll_c_out1, DIV_U71, 0x84, 0, 600000000,
  166. tegra_pll_div_ops, pll_c, 0);
  167. static struct clk_pll_freq_table tegra_pll_m_freq_table[] = {
  168. { 12000000, 666000000, 666, 12, 1, 8},
  169. { 13000000, 666000000, 666, 13, 1, 8},
  170. { 19200000, 666000000, 555, 16, 1, 8},
  171. { 26000000, 666000000, 666, 26, 1, 8},
  172. { 12000000, 600000000, 600, 12, 1, 8},
  173. { 13000000, 600000000, 600, 13, 1, 8},
  174. { 19200000, 600000000, 375, 12, 1, 6},
  175. { 26000000, 600000000, 600, 26, 1, 8},
  176. { 0, 0, 0, 0, 0, 0 },
  177. };
  178. DEFINE_PLL(pll_m, PLL_HAS_CPCON, 0x90, 800000000, 2000000, 31000000, 1000000,
  179. 6000000, 20000000, 1200000000, tegra_pll_m_freq_table, 300,
  180. tegra_pll_ops, 0, clk_m);
  181. DEFINE_PLL_OUT(pll_m_out1, DIV_U71, 0x94, 0, 600000000,
  182. tegra_pll_div_ops, pll_m, 0);
  183. static struct clk_pll_freq_table tegra_pll_p_freq_table[] = {
  184. { 12000000, 216000000, 432, 12, 2, 8},
  185. { 13000000, 216000000, 432, 13, 2, 8},
  186. { 19200000, 216000000, 90, 4, 2, 1},
  187. { 26000000, 216000000, 432, 26, 2, 8},
  188. { 12000000, 432000000, 432, 12, 1, 8},
  189. { 13000000, 432000000, 432, 13, 1, 8},
  190. { 19200000, 432000000, 90, 4, 1, 1},
  191. { 26000000, 432000000, 432, 26, 1, 8},
  192. { 0, 0, 0, 0, 0, 0 },
  193. };
  194. DEFINE_PLL(pll_p, ENABLE_ON_INIT | PLL_FIXED | PLL_HAS_CPCON, 0xa0, 432000000,
  195. 2000000, 31000000, 1000000, 6000000, 20000000, 1400000000,
  196. tegra_pll_p_freq_table, 300, tegra_pll_ops, 216000000, clk_m);
  197. DEFINE_PLL_OUT(pll_p_out1, ENABLE_ON_INIT | DIV_U71 | DIV_U71_FIXED, 0xa4, 0,
  198. 432000000, tegra_pll_div_ops, pll_p, 0);
  199. DEFINE_PLL_OUT(pll_p_out2, ENABLE_ON_INIT | DIV_U71 | DIV_U71_FIXED, 0xa4, 16,
  200. 432000000, tegra_pll_div_ops, pll_p, 0);
  201. DEFINE_PLL_OUT(pll_p_out3, ENABLE_ON_INIT | DIV_U71 | DIV_U71_FIXED, 0xa8, 0,
  202. 432000000, tegra_pll_div_ops, pll_p, 0);
  203. DEFINE_PLL_OUT(pll_p_out4, ENABLE_ON_INIT | DIV_U71 | DIV_U71_FIXED, 0xa8, 16,
  204. 432000000, tegra_pll_div_ops, pll_p, 0);
  205. static struct clk_pll_freq_table tegra_pll_a_freq_table[] = {
  206. { 28800000, 56448000, 49, 25, 1, 1},
  207. { 28800000, 73728000, 64, 25, 1, 1},
  208. { 28800000, 24000000, 5, 6, 1, 1},
  209. { 0, 0, 0, 0, 0, 0 },
  210. };
  211. DEFINE_PLL(pll_a, PLL_HAS_CPCON, 0xb0, 73728000, 2000000, 31000000, 1000000,
  212. 6000000, 20000000, 1400000000, tegra_pll_a_freq_table, 300,
  213. tegra_pll_ops, 0, pll_p_out1);
  214. DEFINE_PLL_OUT(pll_a_out0, DIV_U71, 0xb4, 0, 73728000,
  215. tegra_pll_div_ops, pll_a, 0);
  216. static struct clk_pll_freq_table tegra_pll_d_freq_table[] = {
  217. { 12000000, 216000000, 216, 12, 1, 4},
  218. { 13000000, 216000000, 216, 13, 1, 4},
  219. { 19200000, 216000000, 135, 12, 1, 3},
  220. { 26000000, 216000000, 216, 26, 1, 4},
  221. { 12000000, 297000000, 99, 4, 1, 4 },
  222. { 12000000, 339000000, 113, 4, 1, 4 },
  223. { 12000000, 594000000, 594, 12, 1, 8},
  224. { 13000000, 594000000, 594, 13, 1, 8},
  225. { 19200000, 594000000, 495, 16, 1, 8},
  226. { 26000000, 594000000, 594, 26, 1, 8},
  227. { 12000000, 616000000, 616, 12, 1, 8},
  228. { 12000000, 1000000000, 1000, 12, 1, 12},
  229. { 13000000, 1000000000, 1000, 13, 1, 12},
  230. { 19200000, 1000000000, 625, 12, 1, 8},
  231. { 26000000, 1000000000, 1000, 26, 1, 12},
  232. { 0, 0, 0, 0, 0, 0 },
  233. };
  234. DEFINE_PLL(pll_d, PLL_HAS_CPCON | PLLD, 0xd0, 1000000000, 2000000, 40000000,
  235. 1000000, 6000000, 40000000, 1000000000, tegra_pll_d_freq_table,
  236. 1000, tegra_pll_ops, 0, clk_m);
  237. DEFINE_PLL_OUT(pll_d_out0, DIV_2 | PLLD, 0, 0, 500000000,
  238. tegra_pll_div_ops, pll_d, CLK_SET_RATE_PARENT);
  239. static struct clk_pll_freq_table tegra_pll_u_freq_table[] = {
  240. { 12000000, 480000000, 960, 12, 2, 0},
  241. { 13000000, 480000000, 960, 13, 2, 0},
  242. { 19200000, 480000000, 200, 4, 2, 0},
  243. { 26000000, 480000000, 960, 26, 2, 0},
  244. { 0, 0, 0, 0, 0, 0 },
  245. };
  246. DEFINE_PLL(pll_u, PLLU, 0xc0, 480000000, 2000000, 40000000, 1000000, 6000000,
  247. 48000000, 960000000, tegra_pll_u_freq_table, 1000,
  248. tegra_pll_ops, 0, clk_m);
  249. static struct clk_pll_freq_table tegra_pll_x_freq_table[] = {
  250. /* 1 GHz */
  251. { 12000000, 1000000000, 1000, 12, 1, 12},
  252. { 13000000, 1000000000, 1000, 13, 1, 12},
  253. { 19200000, 1000000000, 625, 12, 1, 8},
  254. { 26000000, 1000000000, 1000, 26, 1, 12},
  255. /* 912 MHz */
  256. { 12000000, 912000000, 912, 12, 1, 12},
  257. { 13000000, 912000000, 912, 13, 1, 12},
  258. { 19200000, 912000000, 760, 16, 1, 8},
  259. { 26000000, 912000000, 912, 26, 1, 12},
  260. /* 816 MHz */
  261. { 12000000, 816000000, 816, 12, 1, 12},
  262. { 13000000, 816000000, 816, 13, 1, 12},
  263. { 19200000, 816000000, 680, 16, 1, 8},
  264. { 26000000, 816000000, 816, 26, 1, 12},
  265. /* 760 MHz */
  266. { 12000000, 760000000, 760, 12, 1, 12},
  267. { 13000000, 760000000, 760, 13, 1, 12},
  268. { 19200000, 760000000, 950, 24, 1, 8},
  269. { 26000000, 760000000, 760, 26, 1, 12},
  270. /* 750 MHz */
  271. { 12000000, 750000000, 750, 12, 1, 12},
  272. { 13000000, 750000000, 750, 13, 1, 12},
  273. { 19200000, 750000000, 625, 16, 1, 8},
  274. { 26000000, 750000000, 750, 26, 1, 12},
  275. /* 608 MHz */
  276. { 12000000, 608000000, 608, 12, 1, 12},
  277. { 13000000, 608000000, 608, 13, 1, 12},
  278. { 19200000, 608000000, 380, 12, 1, 8},
  279. { 26000000, 608000000, 608, 26, 1, 12},
  280. /* 456 MHz */
  281. { 12000000, 456000000, 456, 12, 1, 12},
  282. { 13000000, 456000000, 456, 13, 1, 12},
  283. { 19200000, 456000000, 380, 16, 1, 8},
  284. { 26000000, 456000000, 456, 26, 1, 12},
  285. /* 312 MHz */
  286. { 12000000, 312000000, 312, 12, 1, 12},
  287. { 13000000, 312000000, 312, 13, 1, 12},
  288. { 19200000, 312000000, 260, 16, 1, 8},
  289. { 26000000, 312000000, 312, 26, 1, 12},
  290. { 0, 0, 0, 0, 0, 0 },
  291. };
  292. DEFINE_PLL(pll_x, PLL_HAS_CPCON | PLL_ALT_MISC_REG, 0xe0, 1000000000, 2000000,
  293. 31000000, 1000000, 6000000, 20000000, 1200000000,
  294. tegra_pll_x_freq_table, 300, tegra_pllx_ops, 0, clk_m);
  295. static struct clk_pll_freq_table tegra_pll_e_freq_table[] = {
  296. { 12000000, 100000000, 200, 24, 1, 0 },
  297. { 0, 0, 0, 0, 0, 0 },
  298. };
  299. DEFINE_PLL(pll_e, PLL_ALT_MISC_REG, 0xe8, 100000000, 12000000, 12000000, 0, 0,
  300. 0, 0, tegra_pll_e_freq_table, 0, tegra_plle_ops, 0, clk_m);
  301. static const char *tegra_common_parent_names[] = {
  302. "clk_m",
  303. };
  304. static struct clk *tegra_common_parents[] = {
  305. &tegra_clk_m,
  306. };
  307. static struct clk tegra_clk_d;
  308. static struct clk_tegra tegra_clk_d_hw = {
  309. .hw = {
  310. .clk = &tegra_clk_d,
  311. },
  312. .flags = PERIPH_NO_RESET,
  313. .reg = 0x34,
  314. .reg_shift = 12,
  315. .max_rate = 52000000,
  316. .u.periph = {
  317. .clk_num = 90,
  318. },
  319. };
  320. static struct clk tegra_clk_d = {
  321. .name = "clk_d",
  322. .hw = &tegra_clk_d_hw.hw,
  323. .ops = &tegra_clk_double_ops,
  324. .parent = &tegra_clk_m,
  325. .parent_names = tegra_common_parent_names,
  326. .parents = tegra_common_parents,
  327. .num_parents = ARRAY_SIZE(tegra_common_parent_names),
  328. };
  329. static struct clk tegra_cdev1;
  330. static struct clk_tegra tegra_cdev1_hw = {
  331. .hw = {
  332. .clk = &tegra_cdev1,
  333. },
  334. .fixed_rate = 26000000,
  335. .u.periph = {
  336. .clk_num = 94,
  337. },
  338. };
  339. static struct clk tegra_cdev1 = {
  340. .name = "cdev1",
  341. .hw = &tegra_cdev1_hw.hw,
  342. .ops = &tegra_cdev_clk_ops,
  343. .flags = CLK_IS_ROOT,
  344. };
  345. /* dap_mclk2, belongs to the cdev2 pingroup. */
  346. static struct clk tegra_cdev2;
  347. static struct clk_tegra tegra_cdev2_hw = {
  348. .hw = {
  349. .clk = &tegra_cdev2,
  350. },
  351. .fixed_rate = 26000000,
  352. .u.periph = {
  353. .clk_num = 93,
  354. },
  355. };
  356. static struct clk tegra_cdev2 = {
  357. .name = "cdev2",
  358. .hw = &tegra_cdev2_hw.hw,
  359. .ops = &tegra_cdev_clk_ops,
  360. .flags = CLK_IS_ROOT,
  361. };
  362. /* initialized before peripheral clocks */
  363. static struct clk_mux_sel mux_audio_sync_clk[8+1];
  364. static const struct audio_sources {
  365. const char *name;
  366. int value;
  367. } mux_audio_sync_clk_sources[] = {
  368. { .name = "spdif_in", .value = 0 },
  369. { .name = "i2s1", .value = 1 },
  370. { .name = "i2s2", .value = 2 },
  371. { .name = "pll_a_out0", .value = 4 },
  372. #if 0 /* FIXME: not implemented */
  373. { .name = "ac97", .value = 3 },
  374. { .name = "ext_audio_clk2", .value = 5 },
  375. { .name = "ext_audio_clk1", .value = 6 },
  376. { .name = "ext_vimclk", .value = 7 },
  377. #endif
  378. { NULL, 0 }
  379. };
  380. static const char *audio_parent_names[] = {
  381. "spdif_in",
  382. "i2s1",
  383. "i2s2",
  384. "dummy",
  385. "pll_a_out0",
  386. "dummy",
  387. "dummy",
  388. "dummy",
  389. };
  390. static struct clk *audio_parents[] = {
  391. NULL,
  392. NULL,
  393. NULL,
  394. NULL,
  395. NULL,
  396. NULL,
  397. NULL,
  398. NULL,
  399. };
  400. static struct clk tegra_audio;
  401. static struct clk_tegra tegra_audio_hw = {
  402. .hw = {
  403. .clk = &tegra_audio,
  404. },
  405. .reg = 0x38,
  406. .max_rate = 73728000,
  407. };
  408. DEFINE_CLK_TEGRA(audio, 0, &tegra_audio_sync_clk_ops, 0, audio_parent_names,
  409. audio_parents, NULL);
  410. static const char *audio_2x_parent_names[] = {
  411. "audio",
  412. };
  413. static struct clk *audio_2x_parents[] = {
  414. &tegra_audio,
  415. };
  416. static struct clk tegra_audio_2x;
  417. static struct clk_tegra tegra_audio_2x_hw = {
  418. .hw = {
  419. .clk = &tegra_audio_2x,
  420. },
  421. .flags = PERIPH_NO_RESET,
  422. .max_rate = 48000000,
  423. .reg = 0x34,
  424. .reg_shift = 8,
  425. .u.periph = {
  426. .clk_num = 89,
  427. },
  428. };
  429. DEFINE_CLK_TEGRA(audio_2x, 0, &tegra_clk_double_ops, 0, audio_2x_parent_names,
  430. audio_2x_parents, &tegra_audio);
  431. static struct clk_lookup tegra_audio_clk_lookups[] = {
  432. { .con_id = "audio", .clk = &tegra_audio },
  433. { .con_id = "audio_2x", .clk = &tegra_audio_2x }
  434. };
  435. /* This is called after peripheral clocks are initialized, as the
  436. * audio_sync clock depends on some of the peripheral clocks.
  437. */
  438. static void init_audio_sync_clock_mux(void)
  439. {
  440. int i;
  441. struct clk_mux_sel *sel = mux_audio_sync_clk;
  442. const struct audio_sources *src = mux_audio_sync_clk_sources;
  443. struct clk_lookup *lookup;
  444. for (i = 0; src->name; i++, sel++, src++) {
  445. sel->input = tegra_get_clock_by_name(src->name);
  446. if (!sel->input)
  447. pr_err("%s: could not find clk %s\n", __func__,
  448. src->name);
  449. audio_parents[src->value] = sel->input;
  450. sel->value = src->value;
  451. }
  452. lookup = tegra_audio_clk_lookups;
  453. for (i = 0; i < ARRAY_SIZE(tegra_audio_clk_lookups); i++, lookup++) {
  454. struct clk *c = lookup->clk;
  455. struct clk_tegra *clk = to_clk_tegra(c->hw);
  456. __clk_init(NULL, c);
  457. INIT_LIST_HEAD(&clk->shared_bus_list);
  458. clk->lookup.con_id = lookup->con_id;
  459. clk->lookup.clk = c;
  460. clkdev_add(&clk->lookup);
  461. tegra_clk_add(c);
  462. }
  463. }
  464. static const char *mux_cclk[] = {
  465. "clk_m",
  466. "pll_c",
  467. "clk_32k",
  468. "pll_m",
  469. "pll_p",
  470. "pll_p_out4",
  471. "pll_p_out3",
  472. "clk_d",
  473. "pll_x",
  474. };
  475. static struct clk *mux_cclk_p[] = {
  476. &tegra_clk_m,
  477. &tegra_pll_c,
  478. &tegra_clk_32k,
  479. &tegra_pll_m,
  480. &tegra_pll_p,
  481. &tegra_pll_p_out4,
  482. &tegra_pll_p_out3,
  483. &tegra_clk_d,
  484. &tegra_pll_x,
  485. };
  486. static const char *mux_sclk[] = {
  487. "clk_m",
  488. "pll_c_out1",
  489. "pll_p_out4",
  490. "pllp_p_out3",
  491. "pll_p_out2",
  492. "clk_d",
  493. "clk_32k",
  494. "pll_m_out1",
  495. };
  496. static struct clk *mux_sclk_p[] = {
  497. &tegra_clk_m,
  498. &tegra_pll_c_out1,
  499. &tegra_pll_p_out4,
  500. &tegra_pll_p_out3,
  501. &tegra_pll_p_out2,
  502. &tegra_clk_d,
  503. &tegra_clk_32k,
  504. &tegra_pll_m_out1,
  505. };
  506. static struct clk tegra_cclk;
  507. static struct clk_tegra tegra_cclk_hw = {
  508. .hw = {
  509. .clk = &tegra_cclk,
  510. },
  511. .reg = 0x20,
  512. .max_rate = 1000000000,
  513. };
  514. DEFINE_CLK_TEGRA(cclk, 0, &tegra_super_ops, 0, mux_cclk,
  515. mux_cclk_p, NULL);
  516. static const char *mux_twd[] = {
  517. "cclk",
  518. };
  519. static struct clk *mux_twd_p[] = {
  520. &tegra_cclk,
  521. };
  522. static struct clk tegra_clk_twd;
  523. static struct clk_tegra tegra_clk_twd_hw = {
  524. .hw = {
  525. .clk = &tegra_clk_twd,
  526. },
  527. .max_rate = 1000000000,
  528. .mul = 1,
  529. .div = 4,
  530. };
  531. static struct clk tegra_clk_twd = {
  532. .name = "twd",
  533. .ops = &tegra_twd_ops,
  534. .hw = &tegra_clk_twd_hw.hw,
  535. .parent = &tegra_cclk,
  536. .parent_names = mux_twd,
  537. .parents = mux_twd_p,
  538. .num_parents = ARRAY_SIZE(mux_twd),
  539. };
  540. static struct clk tegra_sclk;
  541. static struct clk_tegra tegra_sclk_hw = {
  542. .hw = {
  543. .clk = &tegra_sclk,
  544. },
  545. .reg = 0x28,
  546. .max_rate = 240000000,
  547. .min_rate = 120000000,
  548. };
  549. DEFINE_CLK_TEGRA(sclk, 0, &tegra_super_ops, 0, mux_sclk,
  550. mux_sclk_p, NULL);
  551. static const char *tegra_cop_parent_names[] = {
  552. "tegra_sclk",
  553. };
  554. static struct clk *tegra_cop_parents[] = {
  555. &tegra_sclk,
  556. };
  557. static struct clk tegra_cop;
  558. static struct clk_tegra tegra_cop_hw = {
  559. .hw = {
  560. .clk = &tegra_cop,
  561. },
  562. .max_rate = 240000000,
  563. .reset = &tegra2_cop_clk_reset,
  564. };
  565. DEFINE_CLK_TEGRA(cop, 0, &tegra_cop_ops, CLK_SET_RATE_PARENT,
  566. tegra_cop_parent_names, tegra_cop_parents, &tegra_sclk);
  567. static const char *tegra_hclk_parent_names[] = {
  568. "tegra_sclk",
  569. };
  570. static struct clk *tegra_hclk_parents[] = {
  571. &tegra_sclk,
  572. };
  573. static struct clk tegra_hclk;
  574. static struct clk_tegra tegra_hclk_hw = {
  575. .hw = {
  576. .clk = &tegra_hclk,
  577. },
  578. .flags = DIV_BUS,
  579. .reg = 0x30,
  580. .reg_shift = 4,
  581. .max_rate = 240000000,
  582. };
  583. DEFINE_CLK_TEGRA(hclk, 0, &tegra_bus_ops, 0, tegra_hclk_parent_names,
  584. tegra_hclk_parents, &tegra_sclk);
  585. static const char *tegra_pclk_parent_names[] = {
  586. "tegra_hclk",
  587. };
  588. static struct clk *tegra_pclk_parents[] = {
  589. &tegra_hclk,
  590. };
  591. static struct clk tegra_pclk;
  592. static struct clk_tegra tegra_pclk_hw = {
  593. .hw = {
  594. .clk = &tegra_pclk,
  595. },
  596. .flags = DIV_BUS,
  597. .reg = 0x30,
  598. .reg_shift = 0,
  599. .max_rate = 120000000,
  600. };
  601. DEFINE_CLK_TEGRA(pclk, 0, &tegra_bus_ops, 0, tegra_pclk_parent_names,
  602. tegra_pclk_parents, &tegra_hclk);
  603. static const char *tegra_blink_parent_names[] = {
  604. "clk_32k",
  605. };
  606. static struct clk *tegra_blink_parents[] = {
  607. &tegra_clk_32k,
  608. };
  609. static struct clk tegra_blink;
  610. static struct clk_tegra tegra_blink_hw = {
  611. .hw = {
  612. .clk = &tegra_blink,
  613. },
  614. .reg = 0x40,
  615. .max_rate = 32768,
  616. };
  617. DEFINE_CLK_TEGRA(blink, 0, &tegra_blink_clk_ops, 0, tegra_blink_parent_names,
  618. tegra_blink_parents, &tegra_clk_32k);
  619. static const char *mux_pllm_pllc_pllp_plla[] = {
  620. "pll_m",
  621. "pll_c",
  622. "pll_p",
  623. "pll_a_out0",
  624. };
  625. static struct clk *mux_pllm_pllc_pllp_plla_p[] = {
  626. &tegra_pll_m,
  627. &tegra_pll_c,
  628. &tegra_pll_p,
  629. &tegra_pll_a_out0,
  630. };
  631. static const char *mux_pllm_pllc_pllp_clkm[] = {
  632. "pll_m",
  633. "pll_c",
  634. "pll_p",
  635. "clk_m",
  636. };
  637. static struct clk *mux_pllm_pllc_pllp_clkm_p[] = {
  638. &tegra_pll_m,
  639. &tegra_pll_c,
  640. &tegra_pll_p,
  641. &tegra_clk_m,
  642. };
  643. static const char *mux_pllp_pllc_pllm_clkm[] = {
  644. "pll_p",
  645. "pll_c",
  646. "pll_m",
  647. "clk_m",
  648. };
  649. static struct clk *mux_pllp_pllc_pllm_clkm_p[] = {
  650. &tegra_pll_p,
  651. &tegra_pll_c,
  652. &tegra_pll_m,
  653. &tegra_clk_m,
  654. };
  655. static const char *mux_pllaout0_audio2x_pllp_clkm[] = {
  656. "pll_a_out0",
  657. "audio_2x",
  658. "pll_p",
  659. "clk_m",
  660. };
  661. static struct clk *mux_pllaout0_audio2x_pllp_clkm_p[] = {
  662. &tegra_pll_a_out0,
  663. &tegra_audio_2x,
  664. &tegra_pll_p,
  665. &tegra_clk_m,
  666. };
  667. static const char *mux_pllp_plld_pllc_clkm[] = {
  668. "pllp",
  669. "pll_d_out0",
  670. "pll_c",
  671. "clk_m",
  672. };
  673. static struct clk *mux_pllp_plld_pllc_clkm_p[] = {
  674. &tegra_pll_p,
  675. &tegra_pll_d_out0,
  676. &tegra_pll_c,
  677. &tegra_clk_m,
  678. };
  679. static const char *mux_pllp_pllc_audio_clkm_clk32[] = {
  680. "pll_p",
  681. "pll_c",
  682. "audio",
  683. "clk_m",
  684. "clk_32k",
  685. };
  686. static struct clk *mux_pllp_pllc_audio_clkm_clk32_p[] = {
  687. &tegra_pll_p,
  688. &tegra_pll_c,
  689. &tegra_audio,
  690. &tegra_clk_m,
  691. &tegra_clk_32k,
  692. };
  693. static const char *mux_pllp_pllc_pllm[] = {
  694. "pll_p",
  695. "pll_c",
  696. "pll_m"
  697. };
  698. static struct clk *mux_pllp_pllc_pllm_p[] = {
  699. &tegra_pll_p,
  700. &tegra_pll_c,
  701. &tegra_pll_m,
  702. };
  703. static const char *mux_clk_m[] = {
  704. "clk_m",
  705. };
  706. static struct clk *mux_clk_m_p[] = {
  707. &tegra_clk_m,
  708. };
  709. static const char *mux_pllp_out3[] = {
  710. "pll_p_out3",
  711. };
  712. static struct clk *mux_pllp_out3_p[] = {
  713. &tegra_pll_p_out3,
  714. };
  715. static const char *mux_plld[] = {
  716. "pll_d",
  717. };
  718. static struct clk *mux_plld_p[] = {
  719. &tegra_pll_d,
  720. };
  721. static const char *mux_clk_32k[] = {
  722. "clk_32k",
  723. };
  724. static struct clk *mux_clk_32k_p[] = {
  725. &tegra_clk_32k,
  726. };
  727. static const char *mux_pclk[] = {
  728. "pclk",
  729. };
  730. static struct clk *mux_pclk_p[] = {
  731. &tegra_pclk,
  732. };
  733. static struct clk tegra_emc;
  734. static struct clk_tegra tegra_emc_hw = {
  735. .hw = {
  736. .clk = &tegra_emc,
  737. },
  738. .reg = 0x19c,
  739. .max_rate = 800000000,
  740. .flags = MUX | DIV_U71 | PERIPH_EMC_ENB,
  741. .reset = &tegra2_periph_clk_reset,
  742. .u.periph = {
  743. .clk_num = 57,
  744. },
  745. };
  746. DEFINE_CLK_TEGRA(emc, 0, &tegra_emc_clk_ops, 0, mux_pllm_pllc_pllp_clkm,
  747. mux_pllm_pllc_pllp_clkm_p, NULL);
  748. #define PERIPH_CLK(_name, _dev, _con, _clk_num, _reg, \
  749. _max, _inputs, _flags) \
  750. static struct clk tegra_##_name; \
  751. static struct clk_tegra tegra_##_name##_hw = { \
  752. .hw = { \
  753. .clk = &tegra_##_name, \
  754. }, \
  755. .lookup = { \
  756. .dev_id = _dev, \
  757. .con_id = _con, \
  758. }, \
  759. .reg = _reg, \
  760. .flags = _flags, \
  761. .max_rate = _max, \
  762. .u.periph = { \
  763. .clk_num = _clk_num, \
  764. }, \
  765. .reset = tegra2_periph_clk_reset, \
  766. }; \
  767. static struct clk tegra_##_name = { \
  768. .name = #_name, \
  769. .ops = &tegra_periph_clk_ops, \
  770. .hw = &tegra_##_name##_hw.hw, \
  771. .parent_names = _inputs, \
  772. .parents = _inputs##_p, \
  773. .num_parents = ARRAY_SIZE(_inputs), \
  774. };
  775. PERIPH_CLK(apbdma, "tegra-apbdma", NULL, 34, 0, 108000000, mux_pclk, 0);
  776. PERIPH_CLK(rtc, "rtc-tegra", NULL, 4, 0, 32768, mux_clk_32k, PERIPH_NO_RESET);
  777. PERIPH_CLK(timer, "timer", NULL, 5, 0, 26000000, mux_clk_m, 0);
  778. PERIPH_CLK(i2s1, "tegra20-i2s.0", NULL, 11, 0x100, 26000000, mux_pllaout0_audio2x_pllp_clkm, MUX | DIV_U71);
  779. PERIPH_CLK(i2s2, "tegra20-i2s.1", NULL, 18, 0x104, 26000000, mux_pllaout0_audio2x_pllp_clkm, MUX | DIV_U71);
  780. PERIPH_CLK(spdif_out, "spdif_out", NULL, 10, 0x108, 100000000, mux_pllaout0_audio2x_pllp_clkm, MUX | DIV_U71);
  781. PERIPH_CLK(spdif_in, "spdif_in", NULL, 10, 0x10c, 100000000, mux_pllp_pllc_pllm, MUX | DIV_U71);
  782. PERIPH_CLK(pwm, "tegra-pwm", NULL, 17, 0x110, 432000000, mux_pllp_pllc_audio_clkm_clk32, MUX | DIV_U71 | MUX_PWM);
  783. PERIPH_CLK(spi, "spi", NULL, 43, 0x114, 40000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71);
  784. PERIPH_CLK(xio, "xio", NULL, 45, 0x120, 150000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71);
  785. PERIPH_CLK(twc, "twc", NULL, 16, 0x12c, 150000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71);
  786. PERIPH_CLK(sbc1, "spi_tegra.0", NULL, 41, 0x134, 160000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71);
  787. PERIPH_CLK(sbc2, "spi_tegra.1", NULL, 44, 0x118, 160000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71);
  788. PERIPH_CLK(sbc3, "spi_tegra.2", NULL, 46, 0x11c, 160000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71);
  789. PERIPH_CLK(sbc4, "spi_tegra.3", NULL, 68, 0x1b4, 160000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71);
  790. PERIPH_CLK(ide, "ide", NULL, 25, 0x144, 100000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71); /* requires min voltage */
  791. PERIPH_CLK(ndflash, "tegra_nand", NULL, 13, 0x160, 164000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71); /* scales with voltage */
  792. PERIPH_CLK(vfir, "vfir", NULL, 7, 0x168, 72000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71);
  793. PERIPH_CLK(sdmmc1, "sdhci-tegra.0", NULL, 14, 0x150, 52000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71); /* scales with voltage */
  794. PERIPH_CLK(sdmmc2, "sdhci-tegra.1", NULL, 9, 0x154, 52000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71); /* scales with voltage */
  795. PERIPH_CLK(sdmmc3, "sdhci-tegra.2", NULL, 69, 0x1bc, 52000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71); /* scales with voltage */
  796. PERIPH_CLK(sdmmc4, "sdhci-tegra.3", NULL, 15, 0x164, 52000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71); /* scales with voltage */
  797. PERIPH_CLK(vcp, "tegra-avp", "vcp", 29, 0, 250000000, mux_clk_m, 0);
  798. PERIPH_CLK(bsea, "tegra-avp", "bsea", 62, 0, 250000000, mux_clk_m, 0);
  799. PERIPH_CLK(bsev, "tegra-aes", "bsev", 63, 0, 250000000, mux_clk_m, 0);
  800. PERIPH_CLK(vde, "tegra-avp", "vde", 61, 0x1c8, 250000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71); /* scales with voltage and process_id */
  801. PERIPH_CLK(csite, "csite", NULL, 73, 0x1d4, 144000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71); /* max rate ??? */
  802. /* FIXME: what is la? */
  803. PERIPH_CLK(la, "la", NULL, 76, 0x1f8, 26000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71);
  804. PERIPH_CLK(owr, "tegra_w1", NULL, 71, 0x1cc, 26000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71);
  805. PERIPH_CLK(nor, "nor", NULL, 42, 0x1d0, 92000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71); /* requires min voltage */
  806. PERIPH_CLK(mipi, "mipi", NULL, 50, 0x174, 60000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71); /* scales with voltage */
  807. PERIPH_CLK(i2c1, "tegra-i2c.0", "div-clk", 12, 0x124, 26000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U16);
  808. PERIPH_CLK(i2c2, "tegra-i2c.1", "div-clk", 54, 0x198, 26000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U16);
  809. PERIPH_CLK(i2c3, "tegra-i2c.2", "div-clk", 67, 0x1b8, 26000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U16);
  810. PERIPH_CLK(dvc, "tegra-i2c.3", "div-clk", 47, 0x128, 26000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U16);
  811. PERIPH_CLK(uarta, "tegra-uart.0", NULL, 6, 0x178, 600000000, mux_pllp_pllc_pllm_clkm, MUX);
  812. PERIPH_CLK(uartb, "tegra-uart.1", NULL, 7, 0x17c, 600000000, mux_pllp_pllc_pllm_clkm, MUX);
  813. PERIPH_CLK(uartc, "tegra-uart.2", NULL, 55, 0x1a0, 600000000, mux_pllp_pllc_pllm_clkm, MUX);
  814. PERIPH_CLK(uartd, "tegra-uart.3", NULL, 65, 0x1c0, 600000000, mux_pllp_pllc_pllm_clkm, MUX);
  815. PERIPH_CLK(uarte, "tegra-uart.4", NULL, 66, 0x1c4, 600000000, mux_pllp_pllc_pllm_clkm, MUX);
  816. PERIPH_CLK(3d, "3d", NULL, 24, 0x158, 300000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71 | PERIPH_MANUAL_RESET); /* scales with voltage and process_id */
  817. PERIPH_CLK(2d, "2d", NULL, 21, 0x15c, 300000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71); /* scales with voltage and process_id */
  818. PERIPH_CLK(vi, "tegra_camera", "vi", 20, 0x148, 150000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71); /* scales with voltage and process_id */
  819. PERIPH_CLK(vi_sensor, "tegra_camera", "vi_sensor", 20, 0x1a8, 150000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71 | PERIPH_NO_RESET); /* scales with voltage and process_id */
  820. PERIPH_CLK(epp, "epp", NULL, 19, 0x16c, 300000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71); /* scales with voltage and process_id */
  821. PERIPH_CLK(mpe, "mpe", NULL, 60, 0x170, 250000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71); /* scales with voltage and process_id */
  822. PERIPH_CLK(host1x, "host1x", NULL, 28, 0x180, 166000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71); /* scales with voltage and process_id */
  823. PERIPH_CLK(cve, "cve", NULL, 49, 0x140, 250000000, mux_pllp_plld_pllc_clkm, MUX | DIV_U71); /* requires min voltage */
  824. PERIPH_CLK(tvo, "tvo", NULL, 49, 0x188, 250000000, mux_pllp_plld_pllc_clkm, MUX | DIV_U71); /* requires min voltage */
  825. PERIPH_CLK(hdmi, "hdmi", NULL, 51, 0x18c, 600000000, mux_pllp_plld_pllc_clkm, MUX | DIV_U71); /* requires min voltage */
  826. PERIPH_CLK(tvdac, "tvdac", NULL, 53, 0x194, 250000000, mux_pllp_plld_pllc_clkm, MUX | DIV_U71); /* requires min voltage */
  827. PERIPH_CLK(disp1, "tegradc.0", NULL, 27, 0x138, 600000000, mux_pllp_plld_pllc_clkm, MUX); /* scales with voltage and process_id */
  828. PERIPH_CLK(disp2, "tegradc.1", NULL, 26, 0x13c, 600000000, mux_pllp_plld_pllc_clkm, MUX); /* scales with voltage and process_id */
  829. PERIPH_CLK(usbd, "fsl-tegra-udc", NULL, 22, 0, 480000000, mux_clk_m, 0); /* requires min voltage */
  830. PERIPH_CLK(usb2, "tegra-ehci.1", NULL, 58, 0, 480000000, mux_clk_m, 0); /* requires min voltage */
  831. PERIPH_CLK(usb3, "tegra-ehci.2", NULL, 59, 0, 480000000, mux_clk_m, 0); /* requires min voltage */
  832. PERIPH_CLK(dsi, "dsi", NULL, 48, 0, 500000000, mux_plld, 0); /* scales with voltage */
  833. PERIPH_CLK(csi, "tegra_camera", "csi", 52, 0, 72000000, mux_pllp_out3, 0);
  834. PERIPH_CLK(isp, "tegra_camera", "isp", 23, 0, 150000000, mux_clk_m, 0); /* same frequency as VI */
  835. PERIPH_CLK(csus, "tegra_camera", "csus", 92, 0, 150000000, mux_clk_m, PERIPH_NO_RESET);
  836. PERIPH_CLK(pex, NULL, "pex", 70, 0, 26000000, mux_clk_m, PERIPH_MANUAL_RESET);
  837. PERIPH_CLK(afi, NULL, "afi", 72, 0, 26000000, mux_clk_m, PERIPH_MANUAL_RESET);
  838. PERIPH_CLK(pcie_xclk, NULL, "pcie_xclk", 74, 0, 26000000, mux_clk_m, PERIPH_MANUAL_RESET);
  839. static struct clk *tegra_list_clks[] = {
  840. &tegra_apbdma,
  841. &tegra_rtc,
  842. &tegra_timer,
  843. &tegra_i2s1,
  844. &tegra_i2s2,
  845. &tegra_spdif_out,
  846. &tegra_spdif_in,
  847. &tegra_pwm,
  848. &tegra_spi,
  849. &tegra_xio,
  850. &tegra_twc,
  851. &tegra_sbc1,
  852. &tegra_sbc2,
  853. &tegra_sbc3,
  854. &tegra_sbc4,
  855. &tegra_ide,
  856. &tegra_ndflash,
  857. &tegra_vfir,
  858. &tegra_sdmmc1,
  859. &tegra_sdmmc2,
  860. &tegra_sdmmc3,
  861. &tegra_sdmmc4,
  862. &tegra_vcp,
  863. &tegra_bsea,
  864. &tegra_bsev,
  865. &tegra_vde,
  866. &tegra_csite,
  867. &tegra_la,
  868. &tegra_owr,
  869. &tegra_nor,
  870. &tegra_mipi,
  871. &tegra_i2c1,
  872. &tegra_i2c2,
  873. &tegra_i2c3,
  874. &tegra_dvc,
  875. &tegra_uarta,
  876. &tegra_uartb,
  877. &tegra_uartc,
  878. &tegra_uartd,
  879. &tegra_uarte,
  880. &tegra_3d,
  881. &tegra_2d,
  882. &tegra_vi,
  883. &tegra_vi_sensor,
  884. &tegra_epp,
  885. &tegra_mpe,
  886. &tegra_host1x,
  887. &tegra_cve,
  888. &tegra_tvo,
  889. &tegra_hdmi,
  890. &tegra_tvdac,
  891. &tegra_disp1,
  892. &tegra_disp2,
  893. &tegra_usbd,
  894. &tegra_usb2,
  895. &tegra_usb3,
  896. &tegra_dsi,
  897. &tegra_csi,
  898. &tegra_isp,
  899. &tegra_csus,
  900. &tegra_pex,
  901. &tegra_afi,
  902. &tegra_pcie_xclk,
  903. };
  904. #define CLK_DUPLICATE(_name, _dev, _con) \
  905. { \
  906. .name = _name, \
  907. .lookup = { \
  908. .dev_id = _dev, \
  909. .con_id = _con, \
  910. }, \
  911. }
  912. /* Some clocks may be used by different drivers depending on the board
  913. * configuration. List those here to register them twice in the clock lookup
  914. * table under two names.
  915. */
  916. static struct clk_duplicate tegra_clk_duplicates[] = {
  917. CLK_DUPLICATE("uarta", "serial8250.0", NULL),
  918. CLK_DUPLICATE("uartb", "serial8250.1", NULL),
  919. CLK_DUPLICATE("uartc", "serial8250.2", NULL),
  920. CLK_DUPLICATE("uartd", "serial8250.3", NULL),
  921. CLK_DUPLICATE("uarte", "serial8250.4", NULL),
  922. CLK_DUPLICATE("usbd", "utmip-pad", NULL),
  923. CLK_DUPLICATE("usbd", "tegra-ehci.0", NULL),
  924. CLK_DUPLICATE("usbd", "tegra-otg", NULL),
  925. CLK_DUPLICATE("2d", "tegra_grhost", "gr2d"),
  926. CLK_DUPLICATE("3d", "tegra_grhost", "gr3d"),
  927. CLK_DUPLICATE("epp", "tegra_grhost", "epp"),
  928. CLK_DUPLICATE("mpe", "tegra_grhost", "mpe"),
  929. CLK_DUPLICATE("cop", "tegra-avp", "cop"),
  930. CLK_DUPLICATE("vde", "tegra-aes", "vde"),
  931. CLK_DUPLICATE("cclk", NULL, "cpu"),
  932. CLK_DUPLICATE("twd", "smp_twd", NULL),
  933. CLK_DUPLICATE("pll_p_out3", "tegra-i2c.0", "fast-clk"),
  934. CLK_DUPLICATE("pll_p_out3", "tegra-i2c.1", "fast-clk"),
  935. CLK_DUPLICATE("pll_p_out3", "tegra-i2c.2", "fast-clk"),
  936. CLK_DUPLICATE("pll_p_out3", "tegra-i2c.3", "fast-clk"),
  937. CLK_DUPLICATE("pll_p", "tegradc.0", "parent"),
  938. CLK_DUPLICATE("pll_p", "tegradc.1", "parent"),
  939. CLK_DUPLICATE("pll_d_out0", "hdmi", "parent"),
  940. };
  941. #define CLK(dev, con, ck) \
  942. { \
  943. .dev_id = dev, \
  944. .con_id = con, \
  945. .clk = ck, \
  946. }
  947. static struct clk *tegra_ptr_clks[] = {
  948. &tegra_clk_32k,
  949. &tegra_pll_s,
  950. &tegra_clk_m,
  951. &tegra_pll_m,
  952. &tegra_pll_m_out1,
  953. &tegra_pll_c,
  954. &tegra_pll_c_out1,
  955. &tegra_pll_p,
  956. &tegra_pll_p_out1,
  957. &tegra_pll_p_out2,
  958. &tegra_pll_p_out3,
  959. &tegra_pll_p_out4,
  960. &tegra_pll_a,
  961. &tegra_pll_a_out0,
  962. &tegra_pll_d,
  963. &tegra_pll_d_out0,
  964. &tegra_pll_u,
  965. &tegra_pll_x,
  966. &tegra_pll_e,
  967. &tegra_cclk,
  968. &tegra_clk_twd,
  969. &tegra_sclk,
  970. &tegra_hclk,
  971. &tegra_pclk,
  972. &tegra_clk_d,
  973. &tegra_cdev1,
  974. &tegra_cdev2,
  975. &tegra_blink,
  976. &tegra_cop,
  977. &tegra_emc,
  978. };
  979. static void tegra2_init_one_clock(struct clk *c)
  980. {
  981. struct clk_tegra *clk = to_clk_tegra(c->hw);
  982. int ret;
  983. ret = __clk_init(NULL, c);
  984. if (ret)
  985. pr_err("clk init failed %s\n", __clk_get_name(c));
  986. INIT_LIST_HEAD(&clk->shared_bus_list);
  987. if (!clk->lookup.dev_id && !clk->lookup.con_id)
  988. clk->lookup.con_id = c->name;
  989. clk->lookup.clk = c;
  990. clkdev_add(&clk->lookup);
  991. tegra_clk_add(c);
  992. }
  993. void __init tegra2_init_clocks(void)
  994. {
  995. int i;
  996. struct clk *c;
  997. for (i = 0; i < ARRAY_SIZE(tegra_ptr_clks); i++)
  998. tegra2_init_one_clock(tegra_ptr_clks[i]);
  999. for (i = 0; i < ARRAY_SIZE(tegra_list_clks); i++)
  1000. tegra2_init_one_clock(tegra_list_clks[i]);
  1001. for (i = 0; i < ARRAY_SIZE(tegra_clk_duplicates); i++) {
  1002. c = tegra_get_clock_by_name(tegra_clk_duplicates[i].name);
  1003. if (!c) {
  1004. pr_err("%s: Unknown duplicate clock %s\n", __func__,
  1005. tegra_clk_duplicates[i].name);
  1006. continue;
  1007. }
  1008. tegra_clk_duplicates[i].lookup.clk = c;
  1009. clkdev_add(&tegra_clk_duplicates[i].lookup);
  1010. }
  1011. init_audio_sync_clock_mux();
  1012. tegra20_cpu_car_ops_init();
  1013. }