tegra20_clocks_data.c 31 KB

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