tegra20_clocks_data.c 31 KB

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