tegra20_clocks_data.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141
  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 <mach/iomap.h>
  29. #include "clock.h"
  30. #include "fuse.h"
  31. #include "tegra2_emc.h"
  32. #include "tegra20_clocks.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, 594000000, 594, 12, 1, 8},
  222. { 13000000, 594000000, 594, 13, 1, 8},
  223. { 19200000, 594000000, 495, 16, 1, 8},
  224. { 26000000, 594000000, 594, 26, 1, 8},
  225. { 12000000, 1000000000, 1000, 12, 1, 12},
  226. { 13000000, 1000000000, 1000, 13, 1, 12},
  227. { 19200000, 1000000000, 625, 12, 1, 8},
  228. { 26000000, 1000000000, 1000, 26, 1, 12},
  229. { 0, 0, 0, 0, 0, 0 },
  230. };
  231. DEFINE_PLL(pll_d, PLL_HAS_CPCON | PLLD, 0xd0, 1000000000, 2000000, 40000000,
  232. 1000000, 6000000, 40000000, 1000000000, tegra_pll_d_freq_table,
  233. 1000, tegra_pll_ops, 0, clk_m);
  234. DEFINE_PLL_OUT(pll_d_out0, DIV_2 | PLLD, 0, 0, 500000000,
  235. tegra_pll_div_ops, pll_d, CLK_SET_RATE_PARENT);
  236. static struct clk_pll_freq_table tegra_pll_u_freq_table[] = {
  237. { 12000000, 480000000, 960, 12, 2, 0},
  238. { 13000000, 480000000, 960, 13, 2, 0},
  239. { 19200000, 480000000, 200, 4, 2, 0},
  240. { 26000000, 480000000, 960, 26, 2, 0},
  241. { 0, 0, 0, 0, 0, 0 },
  242. };
  243. DEFINE_PLL(pll_u, PLLU, 0xc0, 480000000, 2000000, 40000000, 1000000, 6000000,
  244. 48000000, 960000000, tegra_pll_u_freq_table, 1000,
  245. tegra_pll_ops, 0, clk_m);
  246. static struct clk_pll_freq_table tegra_pll_x_freq_table[] = {
  247. /* 1 GHz */
  248. { 12000000, 1000000000, 1000, 12, 1, 12},
  249. { 13000000, 1000000000, 1000, 13, 1, 12},
  250. { 19200000, 1000000000, 625, 12, 1, 8},
  251. { 26000000, 1000000000, 1000, 26, 1, 12},
  252. /* 912 MHz */
  253. { 12000000, 912000000, 912, 12, 1, 12},
  254. { 13000000, 912000000, 912, 13, 1, 12},
  255. { 19200000, 912000000, 760, 16, 1, 8},
  256. { 26000000, 912000000, 912, 26, 1, 12},
  257. /* 816 MHz */
  258. { 12000000, 816000000, 816, 12, 1, 12},
  259. { 13000000, 816000000, 816, 13, 1, 12},
  260. { 19200000, 816000000, 680, 16, 1, 8},
  261. { 26000000, 816000000, 816, 26, 1, 12},
  262. /* 760 MHz */
  263. { 12000000, 760000000, 760, 12, 1, 12},
  264. { 13000000, 760000000, 760, 13, 1, 12},
  265. { 19200000, 760000000, 950, 24, 1, 8},
  266. { 26000000, 760000000, 760, 26, 1, 12},
  267. /* 750 MHz */
  268. { 12000000, 750000000, 750, 12, 1, 12},
  269. { 13000000, 750000000, 750, 13, 1, 12},
  270. { 19200000, 750000000, 625, 16, 1, 8},
  271. { 26000000, 750000000, 750, 26, 1, 12},
  272. /* 608 MHz */
  273. { 12000000, 608000000, 608, 12, 1, 12},
  274. { 13000000, 608000000, 608, 13, 1, 12},
  275. { 19200000, 608000000, 380, 12, 1, 8},
  276. { 26000000, 608000000, 608, 26, 1, 12},
  277. /* 456 MHz */
  278. { 12000000, 456000000, 456, 12, 1, 12},
  279. { 13000000, 456000000, 456, 13, 1, 12},
  280. { 19200000, 456000000, 380, 16, 1, 8},
  281. { 26000000, 456000000, 456, 26, 1, 12},
  282. /* 312 MHz */
  283. { 12000000, 312000000, 312, 12, 1, 12},
  284. { 13000000, 312000000, 312, 13, 1, 12},
  285. { 19200000, 312000000, 260, 16, 1, 8},
  286. { 26000000, 312000000, 312, 26, 1, 12},
  287. { 0, 0, 0, 0, 0, 0 },
  288. };
  289. DEFINE_PLL(pll_x, PLL_HAS_CPCON | PLL_ALT_MISC_REG, 0xe0, 1000000000, 2000000,
  290. 31000000, 1000000, 6000000, 20000000, 1200000000,
  291. tegra_pll_x_freq_table, 300, tegra_pllx_ops, 0, clk_m);
  292. static struct clk_pll_freq_table tegra_pll_e_freq_table[] = {
  293. { 12000000, 100000000, 200, 24, 1, 0 },
  294. { 0, 0, 0, 0, 0, 0 },
  295. };
  296. DEFINE_PLL(pll_e, PLL_ALT_MISC_REG, 0xe8, 100000000, 12000000, 12000000, 0, 0,
  297. 0, 0, tegra_pll_e_freq_table, 0, tegra_plle_ops, 0, clk_m);
  298. static const char *tegra_common_parent_names[] = {
  299. "clk_m",
  300. };
  301. static struct clk *tegra_common_parents[] = {
  302. &tegra_clk_m,
  303. };
  304. static struct clk tegra_clk_d;
  305. static struct clk_tegra tegra_clk_d_hw = {
  306. .hw = {
  307. .clk = &tegra_clk_d,
  308. },
  309. .flags = PERIPH_NO_RESET,
  310. .reg = 0x34,
  311. .reg_shift = 12,
  312. .max_rate = 52000000,
  313. .u.periph = {
  314. .clk_num = 90,
  315. },
  316. };
  317. static struct clk tegra_clk_d = {
  318. .name = "clk_d",
  319. .hw = &tegra_clk_d_hw.hw,
  320. .ops = &tegra_clk_double_ops,
  321. .parent = &tegra_clk_m,
  322. .parent_names = tegra_common_parent_names,
  323. .parents = tegra_common_parents,
  324. .num_parents = ARRAY_SIZE(tegra_common_parent_names),
  325. };
  326. static struct clk tegra_cdev1;
  327. static struct clk_tegra tegra_cdev1_hw = {
  328. .hw = {
  329. .clk = &tegra_cdev1,
  330. },
  331. .fixed_rate = 26000000,
  332. .u.periph = {
  333. .clk_num = 94,
  334. },
  335. };
  336. static struct clk tegra_cdev1 = {
  337. .name = "cdev1",
  338. .hw = &tegra_cdev1_hw.hw,
  339. .ops = &tegra_cdev_clk_ops,
  340. .flags = CLK_IS_ROOT,
  341. };
  342. /* dap_mclk2, belongs to the cdev2 pingroup. */
  343. static struct clk tegra_cdev2;
  344. static struct clk_tegra tegra_cdev2_hw = {
  345. .hw = {
  346. .clk = &tegra_cdev2,
  347. },
  348. .fixed_rate = 26000000,
  349. .u.periph = {
  350. .clk_num = 93,
  351. },
  352. };
  353. static struct clk tegra_cdev2 = {
  354. .name = "cdev2",
  355. .hw = &tegra_cdev2_hw.hw,
  356. .ops = &tegra_cdev_clk_ops,
  357. .flags = CLK_IS_ROOT,
  358. };
  359. /* initialized before peripheral clocks */
  360. static struct clk_mux_sel mux_audio_sync_clk[8+1];
  361. static const struct audio_sources {
  362. const char *name;
  363. int value;
  364. } mux_audio_sync_clk_sources[] = {
  365. { .name = "spdif_in", .value = 0 },
  366. { .name = "i2s1", .value = 1 },
  367. { .name = "i2s2", .value = 2 },
  368. { .name = "pll_a_out0", .value = 4 },
  369. #if 0 /* FIXME: not implemented */
  370. { .name = "ac97", .value = 3 },
  371. { .name = "ext_audio_clk2", .value = 5 },
  372. { .name = "ext_audio_clk1", .value = 6 },
  373. { .name = "ext_vimclk", .value = 7 },
  374. #endif
  375. { NULL, 0 }
  376. };
  377. static const char *audio_parent_names[] = {
  378. "spdif_in",
  379. "i2s1",
  380. "i2s2",
  381. "dummy",
  382. "pll_a_out0",
  383. "dummy",
  384. "dummy",
  385. "dummy",
  386. };
  387. static struct clk *audio_parents[] = {
  388. NULL,
  389. NULL,
  390. NULL,
  391. NULL,
  392. NULL,
  393. NULL,
  394. NULL,
  395. NULL,
  396. };
  397. static struct clk tegra_audio;
  398. static struct clk_tegra tegra_audio_hw = {
  399. .hw = {
  400. .clk = &tegra_audio,
  401. },
  402. .reg = 0x38,
  403. .max_rate = 73728000,
  404. };
  405. DEFINE_CLK_TEGRA(audio, 0, &tegra_audio_sync_clk_ops, 0, audio_parent_names,
  406. audio_parents, NULL);
  407. static const char *audio_2x_parent_names[] = {
  408. "audio",
  409. };
  410. static struct clk *audio_2x_parents[] = {
  411. &tegra_audio,
  412. };
  413. static struct clk tegra_audio_2x;
  414. static struct clk_tegra tegra_audio_2x_hw = {
  415. .hw = {
  416. .clk = &tegra_audio_2x,
  417. },
  418. .flags = PERIPH_NO_RESET,
  419. .max_rate = 48000000,
  420. .reg = 0x34,
  421. .reg_shift = 8,
  422. .u.periph = {
  423. .clk_num = 89,
  424. },
  425. };
  426. DEFINE_CLK_TEGRA(audio_2x, 0, &tegra_clk_double_ops, 0, audio_2x_parent_names,
  427. audio_2x_parents, &tegra_audio);
  428. static struct clk_lookup tegra_audio_clk_lookups[] = {
  429. { .con_id = "audio", .clk = &tegra_audio },
  430. { .con_id = "audio_2x", .clk = &tegra_audio_2x }
  431. };
  432. /* This is called after peripheral clocks are initialized, as the
  433. * audio_sync clock depends on some of the peripheral clocks.
  434. */
  435. static void init_audio_sync_clock_mux(void)
  436. {
  437. int i;
  438. struct clk_mux_sel *sel = mux_audio_sync_clk;
  439. const struct audio_sources *src = mux_audio_sync_clk_sources;
  440. struct clk_lookup *lookup;
  441. for (i = 0; src->name; i++, sel++, src++) {
  442. sel->input = tegra_get_clock_by_name(src->name);
  443. if (!sel->input)
  444. pr_err("%s: could not find clk %s\n", __func__,
  445. src->name);
  446. audio_parents[src->value] = sel->input;
  447. sel->value = src->value;
  448. }
  449. lookup = tegra_audio_clk_lookups;
  450. for (i = 0; i < ARRAY_SIZE(tegra_audio_clk_lookups); i++, lookup++) {
  451. struct clk *c = lookup->clk;
  452. struct clk_tegra *clk = to_clk_tegra(c->hw);
  453. __clk_init(NULL, c);
  454. INIT_LIST_HEAD(&clk->shared_bus_list);
  455. clk->lookup.con_id = lookup->con_id;
  456. clk->lookup.clk = c;
  457. clkdev_add(&clk->lookup);
  458. tegra_clk_add(c);
  459. }
  460. }
  461. static const char *mux_cclk[] = {
  462. "clk_m",
  463. "pll_c",
  464. "clk_32k",
  465. "pll_m",
  466. "pll_p",
  467. "pll_p_out4",
  468. "pll_p_out3",
  469. "clk_d",
  470. "pll_x",
  471. };
  472. static struct clk *mux_cclk_p[] = {
  473. &tegra_clk_m,
  474. &tegra_pll_c,
  475. &tegra_clk_32k,
  476. &tegra_pll_m,
  477. &tegra_pll_p,
  478. &tegra_pll_p_out4,
  479. &tegra_pll_p_out3,
  480. &tegra_clk_d,
  481. &tegra_pll_x,
  482. };
  483. static const char *mux_sclk[] = {
  484. "clk_m",
  485. "pll_c_out1",
  486. "pll_p_out4",
  487. "pllp_p_out3",
  488. "pll_p_out2",
  489. "clk_d",
  490. "clk_32k",
  491. "pll_m_out1",
  492. };
  493. static struct clk *mux_sclk_p[] = {
  494. &tegra_clk_m,
  495. &tegra_pll_c_out1,
  496. &tegra_pll_p_out4,
  497. &tegra_pll_p_out3,
  498. &tegra_pll_p_out2,
  499. &tegra_clk_d,
  500. &tegra_clk_32k,
  501. &tegra_pll_m_out1,
  502. };
  503. static struct clk tegra_cclk;
  504. static struct clk_tegra tegra_cclk_hw = {
  505. .hw = {
  506. .clk = &tegra_cclk,
  507. },
  508. .reg = 0x20,
  509. .max_rate = 1000000000,
  510. };
  511. DEFINE_CLK_TEGRA(cclk, 0, &tegra_super_ops, 0, mux_cclk,
  512. mux_cclk_p, NULL);
  513. static const char *mux_twd[] = {
  514. "cclk",
  515. };
  516. static struct clk *mux_twd_p[] = {
  517. &tegra_cclk,
  518. };
  519. static struct clk tegra_clk_twd;
  520. static struct clk_tegra tegra_clk_twd_hw = {
  521. .hw = {
  522. .clk = &tegra_clk_twd,
  523. },
  524. .max_rate = 1000000000,
  525. .mul = 1,
  526. .div = 4,
  527. };
  528. static struct clk tegra_clk_twd = {
  529. .name = "twd",
  530. .ops = &tegra_twd_ops,
  531. .hw = &tegra_clk_twd_hw.hw,
  532. .parent = &tegra_cclk,
  533. .parent_names = mux_twd,
  534. .parents = mux_twd_p,
  535. .num_parents = ARRAY_SIZE(mux_twd),
  536. };
  537. static struct clk tegra_sclk;
  538. static struct clk_tegra tegra_sclk_hw = {
  539. .hw = {
  540. .clk = &tegra_sclk,
  541. },
  542. .reg = 0x28,
  543. .max_rate = 240000000,
  544. .min_rate = 120000000,
  545. };
  546. DEFINE_CLK_TEGRA(sclk, 0, &tegra_super_ops, 0, mux_sclk,
  547. mux_sclk_p, NULL);
  548. static const char *tegra_cop_parent_names[] = {
  549. "tegra_sclk",
  550. };
  551. static struct clk *tegra_cop_parents[] = {
  552. &tegra_sclk,
  553. };
  554. static struct clk tegra_cop;
  555. static struct clk_tegra tegra_cop_hw = {
  556. .hw = {
  557. .clk = &tegra_cop,
  558. },
  559. .max_rate = 240000000,
  560. .reset = &tegra2_cop_clk_reset,
  561. };
  562. DEFINE_CLK_TEGRA(cop, 0, &tegra_cop_ops, CLK_SET_RATE_PARENT,
  563. tegra_cop_parent_names, tegra_cop_parents, &tegra_sclk);
  564. static const char *tegra_hclk_parent_names[] = {
  565. "tegra_sclk",
  566. };
  567. static struct clk *tegra_hclk_parents[] = {
  568. &tegra_sclk,
  569. };
  570. static struct clk tegra_hclk;
  571. static struct clk_tegra tegra_hclk_hw = {
  572. .hw = {
  573. .clk = &tegra_hclk,
  574. },
  575. .flags = DIV_BUS,
  576. .reg = 0x30,
  577. .reg_shift = 4,
  578. .max_rate = 240000000,
  579. };
  580. DEFINE_CLK_TEGRA(hclk, 0, &tegra_bus_ops, 0, tegra_hclk_parent_names,
  581. tegra_hclk_parents, &tegra_sclk);
  582. static const char *tegra_pclk_parent_names[] = {
  583. "tegra_hclk",
  584. };
  585. static struct clk *tegra_pclk_parents[] = {
  586. &tegra_hclk,
  587. };
  588. static struct clk tegra_pclk;
  589. static struct clk_tegra tegra_pclk_hw = {
  590. .hw = {
  591. .clk = &tegra_pclk,
  592. },
  593. .flags = DIV_BUS,
  594. .reg = 0x30,
  595. .reg_shift = 0,
  596. .max_rate = 120000000,
  597. };
  598. DEFINE_CLK_TEGRA(pclk, 0, &tegra_bus_ops, 0, tegra_pclk_parent_names,
  599. tegra_pclk_parents, &tegra_hclk);
  600. static const char *tegra_blink_parent_names[] = {
  601. "clk_32k",
  602. };
  603. static struct clk *tegra_blink_parents[] = {
  604. &tegra_clk_32k,
  605. };
  606. static struct clk tegra_blink;
  607. static struct clk_tegra tegra_blink_hw = {
  608. .hw = {
  609. .clk = &tegra_blink,
  610. },
  611. .reg = 0x40,
  612. .max_rate = 32768,
  613. };
  614. DEFINE_CLK_TEGRA(blink, 0, &tegra_blink_clk_ops, 0, tegra_blink_parent_names,
  615. tegra_blink_parents, &tegra_clk_32k);
  616. static const char *mux_pllm_pllc_pllp_plla[] = {
  617. "pll_m",
  618. "pll_c",
  619. "pll_p",
  620. "pll_a_out0",
  621. };
  622. static struct clk *mux_pllm_pllc_pllp_plla_p[] = {
  623. &tegra_pll_m,
  624. &tegra_pll_c,
  625. &tegra_pll_p,
  626. &tegra_pll_a_out0,
  627. };
  628. static const char *mux_pllm_pllc_pllp_clkm[] = {
  629. "pll_m",
  630. "pll_c",
  631. "pll_p",
  632. "clk_m",
  633. };
  634. static struct clk *mux_pllm_pllc_pllp_clkm_p[] = {
  635. &tegra_pll_m,
  636. &tegra_pll_c,
  637. &tegra_pll_p,
  638. &tegra_clk_m,
  639. };
  640. static const char *mux_pllp_pllc_pllm_clkm[] = {
  641. "pll_p",
  642. "pll_c",
  643. "pll_m",
  644. "clk_m",
  645. };
  646. static struct clk *mux_pllp_pllc_pllm_clkm_p[] = {
  647. &tegra_pll_p,
  648. &tegra_pll_c,
  649. &tegra_pll_m,
  650. &tegra_clk_m,
  651. };
  652. static const char *mux_pllaout0_audio2x_pllp_clkm[] = {
  653. "pll_a_out0",
  654. "audio_2x",
  655. "pll_p",
  656. "clk_m",
  657. };
  658. static struct clk *mux_pllaout0_audio2x_pllp_clkm_p[] = {
  659. &tegra_pll_a_out0,
  660. &tegra_audio_2x,
  661. &tegra_pll_p,
  662. &tegra_clk_m,
  663. };
  664. static const char *mux_pllp_plld_pllc_clkm[] = {
  665. "pllp",
  666. "pll_d_out0",
  667. "pll_c",
  668. "clk_m",
  669. };
  670. static struct clk *mux_pllp_plld_pllc_clkm_p[] = {
  671. &tegra_pll_p,
  672. &tegra_pll_d_out0,
  673. &tegra_pll_c,
  674. &tegra_clk_m,
  675. };
  676. static const char *mux_pllp_pllc_audio_clkm_clk32[] = {
  677. "pll_p",
  678. "pll_c",
  679. "audio",
  680. "clk_m",
  681. "clk_32k",
  682. };
  683. static struct clk *mux_pllp_pllc_audio_clkm_clk32_p[] = {
  684. &tegra_pll_p,
  685. &tegra_pll_c,
  686. &tegra_audio,
  687. &tegra_clk_m,
  688. &tegra_clk_32k,
  689. };
  690. static const char *mux_pllp_pllc_pllm[] = {
  691. "pll_p",
  692. "pll_c",
  693. "pll_m"
  694. };
  695. static struct clk *mux_pllp_pllc_pllm_p[] = {
  696. &tegra_pll_p,
  697. &tegra_pll_c,
  698. &tegra_pll_m,
  699. };
  700. static const char *mux_clk_m[] = {
  701. "clk_m",
  702. };
  703. static struct clk *mux_clk_m_p[] = {
  704. &tegra_clk_m,
  705. };
  706. static const char *mux_pllp_out3[] = {
  707. "pll_p_out3",
  708. };
  709. static struct clk *mux_pllp_out3_p[] = {
  710. &tegra_pll_p_out3,
  711. };
  712. static const char *mux_plld[] = {
  713. "pll_d",
  714. };
  715. static struct clk *mux_plld_p[] = {
  716. &tegra_pll_d,
  717. };
  718. static const char *mux_clk_32k[] = {
  719. "clk_32k",
  720. };
  721. static struct clk *mux_clk_32k_p[] = {
  722. &tegra_clk_32k,
  723. };
  724. static const char *mux_pclk[] = {
  725. "pclk",
  726. };
  727. static struct clk *mux_pclk_p[] = {
  728. &tegra_pclk,
  729. };
  730. static struct clk tegra_emc;
  731. static struct clk_tegra tegra_emc_hw = {
  732. .hw = {
  733. .clk = &tegra_emc,
  734. },
  735. .reg = 0x19c,
  736. .max_rate = 800000000,
  737. .flags = MUX | DIV_U71 | PERIPH_EMC_ENB,
  738. .reset = &tegra2_periph_clk_reset,
  739. .u.periph = {
  740. .clk_num = 57,
  741. },
  742. };
  743. DEFINE_CLK_TEGRA(emc, 0, &tegra_emc_clk_ops, 0, mux_pllm_pllc_pllp_clkm,
  744. mux_pllm_pllc_pllp_clkm_p, NULL);
  745. #define PERIPH_CLK(_name, _dev, _con, _clk_num, _reg, \
  746. _max, _inputs, _flags) \
  747. static struct clk tegra_##_name; \
  748. static struct clk_tegra tegra_##_name##_hw = { \
  749. .hw = { \
  750. .clk = &tegra_##_name, \
  751. }, \
  752. .lookup = { \
  753. .dev_id = _dev, \
  754. .con_id = _con, \
  755. }, \
  756. .reg = _reg, \
  757. .flags = _flags, \
  758. .max_rate = _max, \
  759. .u.periph = { \
  760. .clk_num = _clk_num, \
  761. }, \
  762. .reset = tegra2_periph_clk_reset, \
  763. }; \
  764. static struct clk tegra_##_name = { \
  765. .name = #_name, \
  766. .ops = &tegra_periph_clk_ops, \
  767. .hw = &tegra_##_name##_hw.hw, \
  768. .parent_names = _inputs, \
  769. .parents = _inputs##_p, \
  770. .num_parents = ARRAY_SIZE(_inputs), \
  771. };
  772. PERIPH_CLK(apbdma, "tegra-apbdma", NULL, 34, 0, 108000000, mux_pclk, 0);
  773. PERIPH_CLK(rtc, "rtc-tegra", NULL, 4, 0, 32768, mux_clk_32k, PERIPH_NO_RESET);
  774. PERIPH_CLK(timer, "timer", NULL, 5, 0, 26000000, mux_clk_m, 0);
  775. PERIPH_CLK(i2s1, "tegra20-i2s.0", NULL, 11, 0x100, 26000000, mux_pllaout0_audio2x_pllp_clkm, MUX | DIV_U71);
  776. PERIPH_CLK(i2s2, "tegra20-i2s.1", NULL, 18, 0x104, 26000000, mux_pllaout0_audio2x_pllp_clkm, MUX | DIV_U71);
  777. PERIPH_CLK(spdif_out, "spdif_out", NULL, 10, 0x108, 100000000, mux_pllaout0_audio2x_pllp_clkm, MUX | DIV_U71);
  778. PERIPH_CLK(spdif_in, "spdif_in", NULL, 10, 0x10c, 100000000, mux_pllp_pllc_pllm, MUX | DIV_U71);
  779. PERIPH_CLK(pwm, "tegra-pwm", NULL, 17, 0x110, 432000000, mux_pllp_pllc_audio_clkm_clk32, MUX | DIV_U71 | MUX_PWM);
  780. PERIPH_CLK(spi, "spi", NULL, 43, 0x114, 40000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71);
  781. PERIPH_CLK(xio, "xio", NULL, 45, 0x120, 150000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71);
  782. PERIPH_CLK(twc, "twc", NULL, 16, 0x12c, 150000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71);
  783. PERIPH_CLK(sbc1, "spi_tegra.0", NULL, 41, 0x134, 160000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71);
  784. PERIPH_CLK(sbc2, "spi_tegra.1", NULL, 44, 0x118, 160000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71);
  785. PERIPH_CLK(sbc3, "spi_tegra.2", NULL, 46, 0x11c, 160000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71);
  786. PERIPH_CLK(sbc4, "spi_tegra.3", NULL, 68, 0x1b4, 160000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71);
  787. PERIPH_CLK(ide, "ide", NULL, 25, 0x144, 100000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71); /* requires min voltage */
  788. PERIPH_CLK(ndflash, "tegra_nand", NULL, 13, 0x160, 164000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71); /* scales with voltage */
  789. PERIPH_CLK(vfir, "vfir", NULL, 7, 0x168, 72000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71);
  790. PERIPH_CLK(sdmmc1, "sdhci-tegra.0", NULL, 14, 0x150, 52000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71); /* scales with voltage */
  791. PERIPH_CLK(sdmmc2, "sdhci-tegra.1", NULL, 9, 0x154, 52000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71); /* scales with voltage */
  792. PERIPH_CLK(sdmmc3, "sdhci-tegra.2", NULL, 69, 0x1bc, 52000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71); /* scales with voltage */
  793. PERIPH_CLK(sdmmc4, "sdhci-tegra.3", NULL, 15, 0x164, 52000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71); /* scales with voltage */
  794. PERIPH_CLK(vcp, "tegra-avp", "vcp", 29, 0, 250000000, mux_clk_m, 0);
  795. PERIPH_CLK(bsea, "tegra-avp", "bsea", 62, 0, 250000000, mux_clk_m, 0);
  796. PERIPH_CLK(bsev, "tegra-aes", "bsev", 63, 0, 250000000, mux_clk_m, 0);
  797. PERIPH_CLK(vde, "tegra-avp", "vde", 61, 0x1c8, 250000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71); /* scales with voltage and process_id */
  798. PERIPH_CLK(csite, "csite", NULL, 73, 0x1d4, 144000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71); /* max rate ??? */
  799. /* FIXME: what is la? */
  800. PERIPH_CLK(la, "la", NULL, 76, 0x1f8, 26000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71);
  801. PERIPH_CLK(owr, "tegra_w1", NULL, 71, 0x1cc, 26000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71);
  802. PERIPH_CLK(nor, "nor", NULL, 42, 0x1d0, 92000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71); /* requires min voltage */
  803. PERIPH_CLK(mipi, "mipi", NULL, 50, 0x174, 60000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71); /* scales with voltage */
  804. PERIPH_CLK(i2c1, "tegra-i2c.0", NULL, 12, 0x124, 26000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U16);
  805. PERIPH_CLK(i2c2, "tegra-i2c.1", NULL, 54, 0x198, 26000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U16);
  806. PERIPH_CLK(i2c3, "tegra-i2c.2", NULL, 67, 0x1b8, 26000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U16);
  807. PERIPH_CLK(dvc, "tegra-i2c.3", NULL, 47, 0x128, 26000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U16);
  808. PERIPH_CLK(i2c1_i2c, "tegra-i2c.0", "i2c", 0, 0, 72000000, mux_pllp_out3, 0);
  809. PERIPH_CLK(i2c2_i2c, "tegra-i2c.1", "i2c", 0, 0, 72000000, mux_pllp_out3, 0);
  810. PERIPH_CLK(i2c3_i2c, "tegra-i2c.2", "i2c", 0, 0, 72000000, mux_pllp_out3, 0);
  811. PERIPH_CLK(dvc_i2c, "tegra-i2c.3", "i2c", 0, 0, 72000000, mux_pllp_out3, 0);
  812. PERIPH_CLK(uarta, "tegra-uart.0", NULL, 6, 0x178, 600000000, mux_pllp_pllc_pllm_clkm, MUX);
  813. PERIPH_CLK(uartb, "tegra-uart.1", NULL, 7, 0x17c, 600000000, mux_pllp_pllc_pllm_clkm, MUX);
  814. PERIPH_CLK(uartc, "tegra-uart.2", NULL, 55, 0x1a0, 600000000, mux_pllp_pllc_pllm_clkm, MUX);
  815. PERIPH_CLK(uartd, "tegra-uart.3", NULL, 65, 0x1c0, 600000000, mux_pllp_pllc_pllm_clkm, MUX);
  816. PERIPH_CLK(uarte, "tegra-uart.4", NULL, 66, 0x1c4, 600000000, mux_pllp_pllc_pllm_clkm, MUX);
  817. 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 */
  818. PERIPH_CLK(2d, "2d", NULL, 21, 0x15c, 300000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71); /* scales with voltage and process_id */
  819. PERIPH_CLK(vi, "tegra_camera", "vi", 20, 0x148, 150000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71); /* scales with voltage and process_id */
  820. 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 */
  821. PERIPH_CLK(epp, "epp", NULL, 19, 0x16c, 300000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71); /* scales with voltage and process_id */
  822. PERIPH_CLK(mpe, "mpe", NULL, 60, 0x170, 250000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71); /* scales with voltage and process_id */
  823. PERIPH_CLK(host1x, "host1x", NULL, 28, 0x180, 166000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71); /* scales with voltage and process_id */
  824. PERIPH_CLK(cve, "cve", NULL, 49, 0x140, 250000000, mux_pllp_plld_pllc_clkm, MUX | DIV_U71); /* requires min voltage */
  825. PERIPH_CLK(tvo, "tvo", NULL, 49, 0x188, 250000000, mux_pllp_plld_pllc_clkm, MUX | DIV_U71); /* requires min voltage */
  826. PERIPH_CLK(hdmi, "hdmi", NULL, 51, 0x18c, 600000000, mux_pllp_plld_pllc_clkm, MUX | DIV_U71); /* requires min voltage */
  827. PERIPH_CLK(tvdac, "tvdac", NULL, 53, 0x194, 250000000, mux_pllp_plld_pllc_clkm, MUX | DIV_U71); /* requires min voltage */
  828. PERIPH_CLK(disp1, "tegradc.0", NULL, 27, 0x138, 600000000, mux_pllp_plld_pllc_clkm, MUX); /* scales with voltage and process_id */
  829. PERIPH_CLK(disp2, "tegradc.1", NULL, 26, 0x13c, 600000000, mux_pllp_plld_pllc_clkm, MUX); /* scales with voltage and process_id */
  830. PERIPH_CLK(usbd, "fsl-tegra-udc", NULL, 22, 0, 480000000, mux_clk_m, 0); /* requires min voltage */
  831. PERIPH_CLK(usb2, "tegra-ehci.1", NULL, 58, 0, 480000000, mux_clk_m, 0); /* requires min voltage */
  832. PERIPH_CLK(usb3, "tegra-ehci.2", NULL, 59, 0, 480000000, mux_clk_m, 0); /* requires min voltage */
  833. PERIPH_CLK(dsi, "dsi", NULL, 48, 0, 500000000, mux_plld, 0); /* scales with voltage */
  834. PERIPH_CLK(csi, "tegra_camera", "csi", 52, 0, 72000000, mux_pllp_out3, 0);
  835. PERIPH_CLK(isp, "tegra_camera", "isp", 23, 0, 150000000, mux_clk_m, 0); /* same frequency as VI */
  836. PERIPH_CLK(csus, "tegra_camera", "csus", 92, 0, 150000000, mux_clk_m, PERIPH_NO_RESET);
  837. PERIPH_CLK(pex, NULL, "pex", 70, 0, 26000000, mux_clk_m, PERIPH_MANUAL_RESET);
  838. PERIPH_CLK(afi, NULL, "afi", 72, 0, 26000000, mux_clk_m, PERIPH_MANUAL_RESET);
  839. PERIPH_CLK(pcie_xclk, NULL, "pcie_xclk", 74, 0, 26000000, mux_clk_m, PERIPH_MANUAL_RESET);
  840. static struct clk *tegra_list_clks[] = {
  841. &tegra_apbdma,
  842. &tegra_rtc,
  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_i2c1_i2c,
  876. &tegra_i2c2_i2c,
  877. &tegra_i2c3_i2c,
  878. &tegra_dvc_i2c,
  879. &tegra_uarta,
  880. &tegra_uartb,
  881. &tegra_uartc,
  882. &tegra_uartd,
  883. &tegra_uarte,
  884. &tegra_3d,
  885. &tegra_2d,
  886. &tegra_vi,
  887. &tegra_vi_sensor,
  888. &tegra_epp,
  889. &tegra_mpe,
  890. &tegra_host1x,
  891. &tegra_cve,
  892. &tegra_tvo,
  893. &tegra_hdmi,
  894. &tegra_tvdac,
  895. &tegra_disp1,
  896. &tegra_disp2,
  897. &tegra_usbd,
  898. &tegra_usb2,
  899. &tegra_usb3,
  900. &tegra_dsi,
  901. &tegra_csi,
  902. &tegra_isp,
  903. &tegra_csus,
  904. &tegra_pex,
  905. &tegra_afi,
  906. &tegra_pcie_xclk,
  907. };
  908. #define CLK_DUPLICATE(_name, _dev, _con) \
  909. { \
  910. .name = _name, \
  911. .lookup = { \
  912. .dev_id = _dev, \
  913. .con_id = _con, \
  914. }, \
  915. }
  916. /* Some clocks may be used by different drivers depending on the board
  917. * configuration. List those here to register them twice in the clock lookup
  918. * table under two names.
  919. */
  920. static struct clk_duplicate tegra_clk_duplicates[] = {
  921. CLK_DUPLICATE("uarta", "serial8250.0", NULL),
  922. CLK_DUPLICATE("uartb", "serial8250.1", NULL),
  923. CLK_DUPLICATE("uartc", "serial8250.2", NULL),
  924. CLK_DUPLICATE("uartd", "serial8250.3", NULL),
  925. CLK_DUPLICATE("uarte", "serial8250.4", NULL),
  926. CLK_DUPLICATE("usbd", "utmip-pad", NULL),
  927. CLK_DUPLICATE("usbd", "tegra-ehci.0", NULL),
  928. CLK_DUPLICATE("usbd", "tegra-otg", NULL),
  929. CLK_DUPLICATE("hdmi", "tegradc.0", "hdmi"),
  930. CLK_DUPLICATE("hdmi", "tegradc.1", "hdmi"),
  931. CLK_DUPLICATE("host1x", "tegra_grhost", "host1x"),
  932. CLK_DUPLICATE("2d", "tegra_grhost", "gr2d"),
  933. CLK_DUPLICATE("3d", "tegra_grhost", "gr3d"),
  934. CLK_DUPLICATE("epp", "tegra_grhost", "epp"),
  935. CLK_DUPLICATE("mpe", "tegra_grhost", "mpe"),
  936. CLK_DUPLICATE("cop", "tegra-avp", "cop"),
  937. CLK_DUPLICATE("vde", "tegra-aes", "vde"),
  938. CLK_DUPLICATE("cclk", NULL, "cpu"),
  939. CLK_DUPLICATE("twd", "smp_twd", NULL),
  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. }