clk-tegra-periph.c 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. /*
  2. * Copyright (c) 2012, 2013, NVIDIA CORPORATION. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms and conditions of the GNU General Public License,
  6. * version 2, as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope it will be useful, but WITHOUT
  9. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. * more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include <linux/io.h>
  17. #include <linux/clk-provider.h>
  18. #include <linux/clkdev.h>
  19. #include <linux/of.h>
  20. #include <linux/of_address.h>
  21. #include <linux/delay.h>
  22. #include <linux/export.h>
  23. #include <linux/clk/tegra.h>
  24. #include "clk.h"
  25. #include "clk-id.h"
  26. #define CLK_SOURCE_I2S0 0x1d8
  27. #define CLK_SOURCE_I2S1 0x100
  28. #define CLK_SOURCE_I2S2 0x104
  29. #define CLK_SOURCE_NDFLASH 0x160
  30. #define CLK_SOURCE_I2S3 0x3bc
  31. #define CLK_SOURCE_I2S4 0x3c0
  32. #define CLK_SOURCE_SPDIF_OUT 0x108
  33. #define CLK_SOURCE_SPDIF_IN 0x10c
  34. #define CLK_SOURCE_PWM 0x110
  35. #define CLK_SOURCE_ADX 0x638
  36. #define CLK_SOURCE_ADX1 0x670
  37. #define CLK_SOURCE_AMX 0x63c
  38. #define CLK_SOURCE_AMX1 0x674
  39. #define CLK_SOURCE_HDA 0x428
  40. #define CLK_SOURCE_HDA2CODEC_2X 0x3e4
  41. #define CLK_SOURCE_SBC1 0x134
  42. #define CLK_SOURCE_SBC2 0x118
  43. #define CLK_SOURCE_SBC3 0x11c
  44. #define CLK_SOURCE_SBC4 0x1b4
  45. #define CLK_SOURCE_SBC5 0x3c8
  46. #define CLK_SOURCE_SBC6 0x3cc
  47. #define CLK_SOURCE_SATA_OOB 0x420
  48. #define CLK_SOURCE_SATA 0x424
  49. #define CLK_SOURCE_NDSPEED 0x3f8
  50. #define CLK_SOURCE_VFIR 0x168
  51. #define CLK_SOURCE_SDMMC1 0x150
  52. #define CLK_SOURCE_SDMMC2 0x154
  53. #define CLK_SOURCE_SDMMC3 0x1bc
  54. #define CLK_SOURCE_SDMMC4 0x164
  55. #define CLK_SOURCE_CVE 0x140
  56. #define CLK_SOURCE_TVO 0x188
  57. #define CLK_SOURCE_TVDAC 0x194
  58. #define CLK_SOURCE_VDE 0x1c8
  59. #define CLK_SOURCE_CSITE 0x1d4
  60. #define CLK_SOURCE_LA 0x1f8
  61. #define CLK_SOURCE_TRACE 0x634
  62. #define CLK_SOURCE_OWR 0x1cc
  63. #define CLK_SOURCE_NOR 0x1d0
  64. #define CLK_SOURCE_MIPI 0x174
  65. #define CLK_SOURCE_I2C1 0x124
  66. #define CLK_SOURCE_I2C2 0x198
  67. #define CLK_SOURCE_I2C3 0x1b8
  68. #define CLK_SOURCE_I2C4 0x3c4
  69. #define CLK_SOURCE_I2C5 0x128
  70. #define CLK_SOURCE_I2C6 0x65c
  71. #define CLK_SOURCE_UARTA 0x178
  72. #define CLK_SOURCE_UARTB 0x17c
  73. #define CLK_SOURCE_UARTC 0x1a0
  74. #define CLK_SOURCE_UARTD 0x1c0
  75. #define CLK_SOURCE_UARTE 0x1c4
  76. #define CLK_SOURCE_3D 0x158
  77. #define CLK_SOURCE_2D 0x15c
  78. #define CLK_SOURCE_MPE 0x170
  79. #define CLK_SOURCE_UARTE 0x1c4
  80. #define CLK_SOURCE_VI_SENSOR 0x1a8
  81. #define CLK_SOURCE_VI 0x148
  82. #define CLK_SOURCE_EPP 0x16c
  83. #define CLK_SOURCE_MSENC 0x1f0
  84. #define CLK_SOURCE_TSEC 0x1f4
  85. #define CLK_SOURCE_HOST1X 0x180
  86. #define CLK_SOURCE_HDMI 0x18c
  87. #define CLK_SOURCE_DISP1 0x138
  88. #define CLK_SOURCE_DISP2 0x13c
  89. #define CLK_SOURCE_CILAB 0x614
  90. #define CLK_SOURCE_CILCD 0x618
  91. #define CLK_SOURCE_CILE 0x61c
  92. #define CLK_SOURCE_DSIALP 0x620
  93. #define CLK_SOURCE_DSIBLP 0x624
  94. #define CLK_SOURCE_TSENSOR 0x3b8
  95. #define CLK_SOURCE_D_AUDIO 0x3d0
  96. #define CLK_SOURCE_DAM0 0x3d8
  97. #define CLK_SOURCE_DAM1 0x3dc
  98. #define CLK_SOURCE_DAM2 0x3e0
  99. #define CLK_SOURCE_ACTMON 0x3e8
  100. #define CLK_SOURCE_EXTERN1 0x3ec
  101. #define CLK_SOURCE_EXTERN2 0x3f0
  102. #define CLK_SOURCE_EXTERN3 0x3f4
  103. #define CLK_SOURCE_I2CSLOW 0x3fc
  104. #define CLK_SOURCE_SE 0x42c
  105. #define CLK_SOURCE_MSELECT 0x3b4
  106. #define CLK_SOURCE_DFLL_REF 0x62c
  107. #define CLK_SOURCE_DFLL_SOC 0x630
  108. #define CLK_SOURCE_SOC_THERM 0x644
  109. #define CLK_SOURCE_XUSB_HOST_SRC 0x600
  110. #define CLK_SOURCE_XUSB_FALCON_SRC 0x604
  111. #define CLK_SOURCE_XUSB_FS_SRC 0x608
  112. #define CLK_SOURCE_XUSB_SS_SRC 0x610
  113. #define CLK_SOURCE_XUSB_DEV_SRC 0x60c
  114. #define CLK_SOURCE_ISP 0x144
  115. #define CLK_SOURCE_SOR0 0x414
  116. #define CLK_SOURCE_DPAUX 0x418
  117. #define CLK_SOURCE_SATA_OOB 0x420
  118. #define CLK_SOURCE_SATA 0x424
  119. #define CLK_SOURCE_ENTROPY 0x628
  120. #define CLK_SOURCE_VI_SENSOR2 0x658
  121. #define CLK_SOURCE_HDMI_AUDIO 0x668
  122. #define CLK_SOURCE_VIC03 0x678
  123. #define CLK_SOURCE_CLK72MHZ 0x66c
  124. #define MASK(x) (BIT(x) - 1)
  125. #define MUX(_name, _parents, _offset, \
  126. _clk_num, _gate_flags, _clk_id) \
  127. TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset,\
  128. 30, MASK(2), 0, 0, 8, 1, TEGRA_DIVIDER_ROUND_UP, \
  129. _clk_num, _gate_flags, _clk_id, _parents##_idx, 0,\
  130. NULL)
  131. #define MUX_FLAGS(_name, _parents, _offset,\
  132. _clk_num, _gate_flags, _clk_id, flags)\
  133. TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset,\
  134. 30, MASK(2), 0, 0, 8, 1, TEGRA_DIVIDER_ROUND_UP,\
  135. _clk_num, _gate_flags, _clk_id, _parents##_idx, flags,\
  136. NULL)
  137. #define MUX8(_name, _parents, _offset, \
  138. _clk_num, _gate_flags, _clk_id) \
  139. TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset,\
  140. 29, MASK(3), 0, 0, 8, 1, TEGRA_DIVIDER_ROUND_UP,\
  141. _clk_num, _gate_flags, _clk_id, _parents##_idx, 0,\
  142. NULL)
  143. #define MUX8_NOGATE_LOCK(_name, _parents, _offset, _clk_id, _lock) \
  144. TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset, \
  145. 29, MASK(3), 0, 0, 8, 1, TEGRA_DIVIDER_ROUND_UP,\
  146. 0, TEGRA_PERIPH_NO_GATE, _clk_id,\
  147. _parents##_idx, 0, _lock)
  148. #define INT(_name, _parents, _offset, \
  149. _clk_num, _gate_flags, _clk_id) \
  150. TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset,\
  151. 30, MASK(2), 0, 0, 8, 1, TEGRA_DIVIDER_INT| \
  152. TEGRA_DIVIDER_ROUND_UP, _clk_num, _gate_flags,\
  153. _clk_id, _parents##_idx, 0, NULL)
  154. #define INT_FLAGS(_name, _parents, _offset,\
  155. _clk_num, _gate_flags, _clk_id, flags)\
  156. TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset,\
  157. 30, MASK(2), 0, 0, 8, 1, TEGRA_DIVIDER_INT| \
  158. TEGRA_DIVIDER_ROUND_UP, _clk_num, _gate_flags,\
  159. _clk_id, _parents##_idx, flags, NULL)
  160. #define INT8(_name, _parents, _offset,\
  161. _clk_num, _gate_flags, _clk_id) \
  162. TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset,\
  163. 29, MASK(3), 0, 0, 8, 1, TEGRA_DIVIDER_INT| \
  164. TEGRA_DIVIDER_ROUND_UP, _clk_num, _gate_flags,\
  165. _clk_id, _parents##_idx, 0, NULL)
  166. #define UART(_name, _parents, _offset,\
  167. _clk_num, _clk_id) \
  168. TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset,\
  169. 30, MASK(2), 0, 0, 16, 1, TEGRA_DIVIDER_UART| \
  170. TEGRA_DIVIDER_ROUND_UP, _clk_num, 0, _clk_id,\
  171. _parents##_idx, 0, NULL)
  172. #define I2C(_name, _parents, _offset,\
  173. _clk_num, _clk_id) \
  174. TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset,\
  175. 30, MASK(2), 0, 0, 16, 0, TEGRA_DIVIDER_ROUND_UP,\
  176. _clk_num, 0, _clk_id, _parents##_idx, 0, NULL)
  177. #define XUSB(_name, _parents, _offset, \
  178. _clk_num, _gate_flags, _clk_id) \
  179. TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset, \
  180. 29, MASK(3), 0, 0, 8, 1, TEGRA_DIVIDER_INT| \
  181. TEGRA_DIVIDER_ROUND_UP, _clk_num, _gate_flags,\
  182. _clk_id, _parents##_idx, 0, NULL)
  183. #define AUDIO(_name, _offset, _clk_num,\
  184. _gate_flags, _clk_id) \
  185. TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, mux_d_audio_clk, \
  186. _offset, 16, 0xE01F, 0, 0, 8, 1, \
  187. TEGRA_DIVIDER_ROUND_UP, _clk_num, _gate_flags, \
  188. _clk_id, mux_d_audio_clk_idx, 0, NULL)
  189. #define NODIV(_name, _parents, _offset, \
  190. _mux_shift, _mux_mask, _clk_num, \
  191. _gate_flags, _clk_id, _lock) \
  192. TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset,\
  193. _mux_shift, _mux_mask, 0, 0, 0, 0, 0,\
  194. _clk_num, (_gate_flags) | TEGRA_PERIPH_NO_DIV,\
  195. _clk_id, _parents##_idx, 0, _lock)
  196. #define GATE(_name, _parent_name, \
  197. _clk_num, _gate_flags, _clk_id, _flags) \
  198. { \
  199. .name = _name, \
  200. .clk_id = _clk_id, \
  201. .p.parent_name = _parent_name, \
  202. .periph = TEGRA_CLK_PERIPH(0, 0, 0, 0, 0, 0, 0, \
  203. _clk_num, _gate_flags, NULL, NULL), \
  204. .flags = _flags \
  205. }
  206. #define PLLP_BASE 0xa0
  207. #define PLLP_MISC 0xac
  208. #define PLLP_OUTA 0xa4
  209. #define PLLP_OUTB 0xa8
  210. #define PLLP_OUTC 0x67c
  211. #define PLL_BASE_LOCK BIT(27)
  212. #define PLL_MISC_LOCK_ENABLE 18
  213. static DEFINE_SPINLOCK(PLLP_OUTA_lock);
  214. static DEFINE_SPINLOCK(PLLP_OUTB_lock);
  215. static DEFINE_SPINLOCK(PLLP_OUTC_lock);
  216. static DEFINE_SPINLOCK(sor0_lock);
  217. #define MUX_I2S_SPDIF(_id) \
  218. static const char *mux_pllaout0_##_id##_2x_pllp_clkm[] = { "pll_a_out0", \
  219. #_id, "pll_p",\
  220. "clk_m"};
  221. MUX_I2S_SPDIF(audio0)
  222. MUX_I2S_SPDIF(audio1)
  223. MUX_I2S_SPDIF(audio2)
  224. MUX_I2S_SPDIF(audio3)
  225. MUX_I2S_SPDIF(audio4)
  226. MUX_I2S_SPDIF(audio)
  227. #define mux_pllaout0_audio0_2x_pllp_clkm_idx NULL
  228. #define mux_pllaout0_audio1_2x_pllp_clkm_idx NULL
  229. #define mux_pllaout0_audio2_2x_pllp_clkm_idx NULL
  230. #define mux_pllaout0_audio3_2x_pllp_clkm_idx NULL
  231. #define mux_pllaout0_audio4_2x_pllp_clkm_idx NULL
  232. #define mux_pllaout0_audio_2x_pllp_clkm_idx NULL
  233. static const char *mux_pllp_pllc_pllm_clkm[] = {
  234. "pll_p", "pll_c", "pll_m", "clk_m"
  235. };
  236. #define mux_pllp_pllc_pllm_clkm_idx NULL
  237. static const char *mux_pllp_pllc_pllm[] = { "pll_p", "pll_c", "pll_m" };
  238. #define mux_pllp_pllc_pllm_idx NULL
  239. static const char *mux_pllp_pllc_clk32_clkm[] = {
  240. "pll_p", "pll_c", "clk_32k", "clk_m"
  241. };
  242. #define mux_pllp_pllc_clk32_clkm_idx NULL
  243. static const char *mux_plla_pllc_pllp_clkm[] = {
  244. "pll_a_out0", "pll_c", "pll_p", "clk_m"
  245. };
  246. #define mux_plla_pllc_pllp_clkm_idx mux_pllp_pllc_pllm_clkm_idx
  247. static const char *mux_pllp_pllc2_c_c3_pllm_clkm[] = {
  248. "pll_p", "pll_c2", "pll_c", "pll_c3", "pll_m", "clk_m"
  249. };
  250. static u32 mux_pllp_pllc2_c_c3_pllm_clkm_idx[] = {
  251. [0] = 0, [1] = 1, [2] = 2, [3] = 3, [4] = 4, [5] = 6,
  252. };
  253. static const char *mux_pllp_clkm[] = {
  254. "pll_p", "clk_m"
  255. };
  256. static u32 mux_pllp_clkm_idx[] = {
  257. [0] = 0, [1] = 3,
  258. };
  259. static const char *mux_pllm_pllc2_c_c3_pllp_plla[] = {
  260. "pll_m", "pll_c2", "pll_c", "pll_c3", "pll_p", "pll_a_out0"
  261. };
  262. #define mux_pllm_pllc2_c_c3_pllp_plla_idx mux_pllp_pllc2_c_c3_pllm_clkm_idx
  263. static const char *mux_pllp_pllm_plld_plla_pllc_plld2_clkm[] = {
  264. "pll_p", "pll_m", "pll_d_out0", "pll_a_out0", "pll_c",
  265. "pll_d2_out0", "clk_m"
  266. };
  267. #define mux_pllp_pllm_plld_plla_pllc_plld2_clkm_idx NULL
  268. static const char *mux_pllm_pllc_pllp_plla[] = {
  269. "pll_m", "pll_c", "pll_p", "pll_a_out0"
  270. };
  271. #define mux_pllm_pllc_pllp_plla_idx mux_pllp_pllc_pllm_clkm_idx
  272. static const char *mux_pllp_pllc_clkm[] = {
  273. "pll_p", "pll_c", "pll_m"
  274. };
  275. static u32 mux_pllp_pllc_clkm_idx[] = {
  276. [0] = 0, [1] = 1, [2] = 3,
  277. };
  278. static const char *mux_pllp_pllc_clkm_clk32[] = {
  279. "pll_p", "pll_c", "clk_m", "clk_32k"
  280. };
  281. #define mux_pllp_pllc_clkm_clk32_idx NULL
  282. static const char *mux_plla_clk32_pllp_clkm_plle[] = {
  283. "pll_a_out0", "clk_32k", "pll_p", "clk_m", "pll_e_out0"
  284. };
  285. #define mux_plla_clk32_pllp_clkm_plle_idx NULL
  286. static const char *mux_clkm_pllp_pllc_pllre[] = {
  287. "clk_m", "pll_p", "pll_c", "pll_re_out"
  288. };
  289. static u32 mux_clkm_pllp_pllc_pllre_idx[] = {
  290. [0] = 0, [1] = 1, [2] = 3, [3] = 5,
  291. };
  292. static const char *mux_clkm_48M_pllp_480M[] = {
  293. "clk_m", "pll_u_48M", "pll_p", "pll_u_480M"
  294. };
  295. static u32 mux_clkm_48M_pllp_480M_idx[] = {
  296. [0] = 0, [1] = 2, [2] = 4, [3] = 6,
  297. };
  298. static const char *mux_clkm_pllre_clk32_480M_pllc_ref[] = {
  299. "clk_m", "pll_re_out", "clk_32k", "pll_u_480M", "pll_c", "pll_ref"
  300. };
  301. static u32 mux_clkm_pllre_clk32_480M_pllc_ref_idx[] = {
  302. [0] = 0, [1] = 1, [2] = 3, [3] = 3, [4] = 4, [5] = 7,
  303. };
  304. static const char *mux_ss_60M[] = {
  305. "xusb_ss_div2", "pll_u_60M"
  306. };
  307. #define mux_ss_60M_idx NULL
  308. static const char *mux_d_audio_clk[] = {
  309. "pll_a_out0", "pll_p", "clk_m", "spdif_in_sync", "i2s0_sync",
  310. "i2s1_sync", "i2s2_sync", "i2s3_sync", "i2s4_sync", "vimclk_sync",
  311. };
  312. static u32 mux_d_audio_clk_idx[] = {
  313. [0] = 0, [1] = 0x8000, [2] = 0xc000, [3] = 0xE000, [4] = 0xE001,
  314. [5] = 0xE002, [6] = 0xE003, [7] = 0xE004, [8] = 0xE005, [9] = 0xE007,
  315. };
  316. static const char *mux_pllp_plld_pllc_clkm[] = {
  317. "pll_p", "pll_d_out0", "pll_c", "clk_m"
  318. };
  319. #define mux_pllp_plld_pllc_clkm_idx NULL
  320. static const char *mux_pllm_pllc_pllp_plla_clkm_pllc4[] = {
  321. "pll_m", "pll_c", "pll_p", "pll_a_out0", "clk_m", "pll_c4",
  322. };
  323. static u32 mux_pllm_pllc_pllp_plla_clkm_pllc4_idx[] = {
  324. [0] = 0, [1] = 1, [2] = 3, [3] = 3, [4] = 6, [5] = 7,
  325. };
  326. static const char *mux_pllp_clkm1[] = {
  327. "pll_p", "clk_m",
  328. };
  329. #define mux_pllp_clkm1_idx NULL
  330. static const char *mux_pllp3_pllc_clkm[] = {
  331. "pll_p_out3", "pll_c", "pll_c2", "clk_m",
  332. };
  333. #define mux_pllp3_pllc_clkm_idx NULL
  334. static const char *mux_pllm_pllc_pllp_plla_pllc2_c3_clkm[] = {
  335. "pll_m", "pll_c", "pll_p", "pll_a", "pll_c2", "pll_c3", "clk_m"
  336. };
  337. #define mux_pllm_pllc_pllp_plla_pllc2_c3_clkm_idx NULL
  338. static const char *mux_pllm_pllc2_c_c3_pllp_plla_pllc4[] = {
  339. "pll_m", "pll_c2", "pll_c", "pll_c3", "pll_p", "pll_a_out0", "pll_c4",
  340. };
  341. static u32 mux_pllm_pllc2_c_c3_pllp_plla_pllc4_idx[] = {
  342. [0] = 0, [1] = 1, [2] = 2, [3] = 3, [4] = 4, [5] = 6, [6] = 7,
  343. };
  344. static const char *mux_clkm_plldp_sor0lvds[] = {
  345. "clk_m", "pll_dp", "sor0_lvds",
  346. };
  347. #define mux_clkm_plldp_sor0lvds_idx NULL
  348. static struct tegra_periph_init_data periph_clks[] = {
  349. AUDIO("d_audio", CLK_SOURCE_D_AUDIO, 106, TEGRA_PERIPH_ON_APB, tegra_clk_d_audio),
  350. AUDIO("dam0", CLK_SOURCE_DAM0, 108, TEGRA_PERIPH_ON_APB, tegra_clk_dam0),
  351. AUDIO("dam1", CLK_SOURCE_DAM1, 109, TEGRA_PERIPH_ON_APB, tegra_clk_dam1),
  352. AUDIO("dam2", CLK_SOURCE_DAM2, 110, TEGRA_PERIPH_ON_APB, tegra_clk_dam2),
  353. I2C("i2c1", mux_pllp_clkm, CLK_SOURCE_I2C1, 12, tegra_clk_i2c1),
  354. I2C("i2c2", mux_pllp_clkm, CLK_SOURCE_I2C2, 54, tegra_clk_i2c2),
  355. I2C("i2c3", mux_pllp_clkm, CLK_SOURCE_I2C3, 67, tegra_clk_i2c3),
  356. I2C("i2c4", mux_pllp_clkm, CLK_SOURCE_I2C4, 103, tegra_clk_i2c4),
  357. I2C("i2c5", mux_pllp_clkm, CLK_SOURCE_I2C5, 47, tegra_clk_i2c5),
  358. INT("vde", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_VDE, 61, 0, tegra_clk_vde),
  359. INT("vi", mux_pllm_pllc_pllp_plla, CLK_SOURCE_VI, 20, 0, tegra_clk_vi),
  360. INT("epp", mux_pllm_pllc_pllp_plla, CLK_SOURCE_EPP, 19, 0, tegra_clk_epp),
  361. INT("host1x", mux_pllm_pllc_pllp_plla, CLK_SOURCE_HOST1X, 28, 0, tegra_clk_host1x),
  362. INT("mpe", mux_pllm_pllc_pllp_plla, CLK_SOURCE_MPE, 60, 0, tegra_clk_mpe),
  363. INT("2d", mux_pllm_pllc_pllp_plla, CLK_SOURCE_2D, 21, 0, tegra_clk_gr2d),
  364. INT("3d", mux_pllm_pllc_pllp_plla, CLK_SOURCE_3D, 24, 0, tegra_clk_gr3d),
  365. INT8("vde", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_VDE, 61, 0, tegra_clk_vde_8),
  366. INT8("vi", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_VI, 20, 0, tegra_clk_vi_8),
  367. INT8("vi", mux_pllm_pllc2_c_c3_pllp_plla_pllc4, CLK_SOURCE_VI, 20, 0, tegra_clk_vi_9),
  368. INT8("epp", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_EPP, 19, 0, tegra_clk_epp_8),
  369. INT8("msenc", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_MSENC, 91, TEGRA_PERIPH_WAR_1005168, tegra_clk_msenc),
  370. INT8("tsec", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_TSEC, 83, 0, tegra_clk_tsec),
  371. INT8("host1x", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_HOST1X, 28, 0, tegra_clk_host1x_8),
  372. INT8("se", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_SE, 127, TEGRA_PERIPH_ON_APB, tegra_clk_se),
  373. INT8("2d", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_2D, 21, 0, tegra_clk_gr2d_8),
  374. INT8("3d", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_3D, 24, 0, tegra_clk_gr3d_8),
  375. INT8("vic03", mux_pllm_pllc_pllp_plla_pllc2_c3_clkm, CLK_SOURCE_VIC03, 178, 0, tegra_clk_vic03),
  376. INT_FLAGS("mselect", mux_pllp_clkm, CLK_SOURCE_MSELECT, 99, 0, tegra_clk_mselect, CLK_IGNORE_UNUSED),
  377. MUX("i2s0", mux_pllaout0_audio0_2x_pllp_clkm, CLK_SOURCE_I2S0, 30, TEGRA_PERIPH_ON_APB, tegra_clk_i2s0),
  378. MUX("i2s1", mux_pllaout0_audio1_2x_pllp_clkm, CLK_SOURCE_I2S1, 11, TEGRA_PERIPH_ON_APB, tegra_clk_i2s1),
  379. MUX("i2s2", mux_pllaout0_audio2_2x_pllp_clkm, CLK_SOURCE_I2S2, 18, TEGRA_PERIPH_ON_APB, tegra_clk_i2s2),
  380. MUX("i2s3", mux_pllaout0_audio3_2x_pllp_clkm, CLK_SOURCE_I2S3, 101, TEGRA_PERIPH_ON_APB, tegra_clk_i2s3),
  381. MUX("i2s4", mux_pllaout0_audio4_2x_pllp_clkm, CLK_SOURCE_I2S4, 102, TEGRA_PERIPH_ON_APB, tegra_clk_i2s4),
  382. MUX("spdif_out", mux_pllaout0_audio_2x_pllp_clkm, CLK_SOURCE_SPDIF_OUT, 10, TEGRA_PERIPH_ON_APB, tegra_clk_spdif_out),
  383. MUX("spdif_in", mux_pllp_pllc_pllm, CLK_SOURCE_SPDIF_IN, 10, TEGRA_PERIPH_ON_APB, tegra_clk_spdif_in),
  384. MUX("pwm", mux_pllp_pllc_clk32_clkm, CLK_SOURCE_PWM, 17, TEGRA_PERIPH_ON_APB, tegra_clk_pwm),
  385. MUX("adx", mux_plla_pllc_pllp_clkm, CLK_SOURCE_ADX, 154, TEGRA_PERIPH_ON_APB, tegra_clk_adx),
  386. MUX("amx", mux_plla_pllc_pllp_clkm, CLK_SOURCE_AMX, 153, TEGRA_PERIPH_ON_APB, tegra_clk_amx),
  387. MUX("hda", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_HDA, 125, TEGRA_PERIPH_ON_APB, tegra_clk_hda),
  388. MUX("hda2codec_2x", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_HDA2CODEC_2X, 111, TEGRA_PERIPH_ON_APB, tegra_clk_hda2codec_2x),
  389. MUX("vfir", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_VFIR, 7, TEGRA_PERIPH_ON_APB, tegra_clk_vfir),
  390. MUX("sdmmc1", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SDMMC1, 14, TEGRA_PERIPH_ON_APB, tegra_clk_sdmmc1),
  391. MUX("sdmmc2", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SDMMC2, 9, TEGRA_PERIPH_ON_APB, tegra_clk_sdmmc2),
  392. MUX("sdmmc3", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SDMMC3, 69, TEGRA_PERIPH_ON_APB, tegra_clk_sdmmc3),
  393. MUX("sdmmc4", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SDMMC4, 15, TEGRA_PERIPH_ON_APB, tegra_clk_sdmmc4),
  394. MUX("la", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_LA, 76, TEGRA_PERIPH_ON_APB, tegra_clk_la),
  395. MUX("trace", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_TRACE, 77, TEGRA_PERIPH_ON_APB, tegra_clk_trace),
  396. MUX("owr", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_OWR, 71, TEGRA_PERIPH_ON_APB, tegra_clk_owr),
  397. MUX("nor", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_NOR, 42, 0, tegra_clk_nor),
  398. MUX("mipi", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_MIPI, 50, TEGRA_PERIPH_ON_APB, tegra_clk_mipi),
  399. MUX("vi_sensor", mux_pllm_pllc_pllp_plla, CLK_SOURCE_VI_SENSOR, 20, TEGRA_PERIPH_NO_RESET, tegra_clk_vi_sensor),
  400. MUX("cilab", mux_pllp_pllc_clkm, CLK_SOURCE_CILAB, 144, 0, tegra_clk_cilab),
  401. MUX("cilcd", mux_pllp_pllc_clkm, CLK_SOURCE_CILCD, 145, 0, tegra_clk_cilcd),
  402. MUX("cile", mux_pllp_pllc_clkm, CLK_SOURCE_CILE, 146, 0, tegra_clk_cile),
  403. MUX("dsialp", mux_pllp_pllc_clkm, CLK_SOURCE_DSIALP, 147, 0, tegra_clk_dsialp),
  404. MUX("dsiblp", mux_pllp_pllc_clkm, CLK_SOURCE_DSIBLP, 148, 0, tegra_clk_dsiblp),
  405. MUX("tsensor", mux_pllp_pllc_clkm_clk32, CLK_SOURCE_TSENSOR, 100, TEGRA_PERIPH_ON_APB, tegra_clk_tsensor),
  406. MUX("actmon", mux_pllp_pllc_clk32_clkm, CLK_SOURCE_ACTMON, 119, 0, tegra_clk_actmon),
  407. MUX("dfll_ref", mux_pllp_clkm, CLK_SOURCE_DFLL_REF, 155, TEGRA_PERIPH_ON_APB, tegra_clk_dfll_ref),
  408. MUX("dfll_soc", mux_pllp_clkm, CLK_SOURCE_DFLL_SOC, 155, TEGRA_PERIPH_ON_APB, tegra_clk_dfll_soc),
  409. MUX("i2cslow", mux_pllp_pllc_clk32_clkm, CLK_SOURCE_I2CSLOW, 81, TEGRA_PERIPH_ON_APB, tegra_clk_i2cslow),
  410. MUX("sbc1", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SBC1, 41, TEGRA_PERIPH_ON_APB, tegra_clk_sbc1),
  411. MUX("sbc2", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SBC2, 44, TEGRA_PERIPH_ON_APB, tegra_clk_sbc2),
  412. MUX("sbc3", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SBC3, 46, TEGRA_PERIPH_ON_APB, tegra_clk_sbc3),
  413. MUX("sbc4", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SBC4, 68, TEGRA_PERIPH_ON_APB, tegra_clk_sbc4),
  414. MUX("sbc5", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SBC5, 104, TEGRA_PERIPH_ON_APB, tegra_clk_sbc5),
  415. MUX("sbc6", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SBC6, 105, TEGRA_PERIPH_ON_APB, tegra_clk_sbc6),
  416. MUX("cve", mux_pllp_plld_pllc_clkm, CLK_SOURCE_CVE, 49, 0, tegra_clk_cve),
  417. MUX("tvo", mux_pllp_plld_pllc_clkm, CLK_SOURCE_TVO, 49, 0, tegra_clk_tvo),
  418. MUX("tvdac", mux_pllp_plld_pllc_clkm, CLK_SOURCE_TVDAC, 53, 0, tegra_clk_tvdac),
  419. MUX("ndflash", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_NDFLASH, 13, TEGRA_PERIPH_ON_APB, tegra_clk_ndflash),
  420. MUX("ndspeed", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_NDSPEED, 80, TEGRA_PERIPH_ON_APB, tegra_clk_ndspeed),
  421. MUX("sata_oob", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SATA_OOB, 123, TEGRA_PERIPH_ON_APB, tegra_clk_sata_oob),
  422. MUX("sata", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SATA, 124, TEGRA_PERIPH_ON_APB, tegra_clk_sata),
  423. MUX("adx1", mux_plla_pllc_pllp_clkm, CLK_SOURCE_ADX1, 180, TEGRA_PERIPH_ON_APB, tegra_clk_adx1),
  424. MUX("amx1", mux_plla_pllc_pllp_clkm, CLK_SOURCE_AMX1, 185, TEGRA_PERIPH_ON_APB, tegra_clk_amx1),
  425. MUX("vi_sensor2", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_VI_SENSOR2, 165, TEGRA_PERIPH_NO_RESET, tegra_clk_vi_sensor2),
  426. MUX8("sdmmc1", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_SDMMC1, 14, TEGRA_PERIPH_ON_APB, tegra_clk_sdmmc1_8),
  427. MUX8("sdmmc2", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_SDMMC2, 9, TEGRA_PERIPH_ON_APB, tegra_clk_sdmmc2_8),
  428. MUX8("sdmmc3", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_SDMMC3, 69, TEGRA_PERIPH_ON_APB, tegra_clk_sdmmc3_8),
  429. MUX8("sdmmc4", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_SDMMC4, 15, TEGRA_PERIPH_ON_APB, tegra_clk_sdmmc4_8),
  430. MUX8("sbc1", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_SBC1, 41, TEGRA_PERIPH_ON_APB, tegra_clk_sbc1_8),
  431. MUX8("sbc2", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_SBC2, 44, TEGRA_PERIPH_ON_APB, tegra_clk_sbc2_8),
  432. MUX8("sbc3", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_SBC3, 46, TEGRA_PERIPH_ON_APB, tegra_clk_sbc3_8),
  433. MUX8("sbc4", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_SBC4, 68, TEGRA_PERIPH_ON_APB, tegra_clk_sbc4_8),
  434. MUX8("sbc5", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_SBC5, 104, TEGRA_PERIPH_ON_APB, tegra_clk_sbc5_8),
  435. MUX8("sbc6", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_SBC6, 105, TEGRA_PERIPH_ON_APB, tegra_clk_sbc6_8),
  436. MUX8("ndflash", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_NDFLASH, 13, TEGRA_PERIPH_ON_APB, tegra_clk_ndflash_8),
  437. MUX8("ndspeed", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_NDSPEED, 80, TEGRA_PERIPH_ON_APB, tegra_clk_ndspeed_8),
  438. MUX8("hdmi", mux_pllp_pllm_plld_plla_pllc_plld2_clkm, CLK_SOURCE_HDMI, 51, 0, tegra_clk_hdmi),
  439. MUX8("extern1", mux_plla_clk32_pllp_clkm_plle, CLK_SOURCE_EXTERN1, 120, 0, tegra_clk_extern1),
  440. MUX8("extern2", mux_plla_clk32_pllp_clkm_plle, CLK_SOURCE_EXTERN2, 121, 0, tegra_clk_extern2),
  441. MUX8("extern3", mux_plla_clk32_pllp_clkm_plle, CLK_SOURCE_EXTERN3, 122, 0, tegra_clk_extern3),
  442. MUX8("soc_therm", mux_pllm_pllc_pllp_plla, CLK_SOURCE_SOC_THERM, 78, TEGRA_PERIPH_ON_APB, tegra_clk_soc_therm),
  443. MUX8("vi_sensor", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_VI_SENSOR, 164, TEGRA_PERIPH_NO_RESET, tegra_clk_vi_sensor_8),
  444. MUX8("isp", mux_pllm_pllc_pllp_plla_clkm_pllc4, CLK_SOURCE_ISP, 23, TEGRA_PERIPH_ON_APB, tegra_clk_isp_8),
  445. MUX8("entropy", mux_pllp_clkm1, CLK_SOURCE_ENTROPY, 149, 0, tegra_clk_entropy),
  446. MUX8("hdmi_audio", mux_pllp3_pllc_clkm, CLK_SOURCE_HDMI_AUDIO, 176, TEGRA_PERIPH_NO_RESET, tegra_clk_hdmi_audio),
  447. MUX8("clk72mhz", mux_pllp3_pllc_clkm, CLK_SOURCE_CLK72MHZ, 177, TEGRA_PERIPH_NO_RESET, tegra_clk_clk72Mhz),
  448. MUX8_NOGATE_LOCK("sor0_lvds", mux_pllp_pllm_plld_plla_pllc_plld2_clkm, CLK_SOURCE_SOR0, tegra_clk_sor0_lvds, &sor0_lock),
  449. MUX_FLAGS("csite", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_CSITE, 73, TEGRA_PERIPH_ON_APB, tegra_clk_csite, CLK_IGNORE_UNUSED),
  450. NODIV("disp1", mux_pllp_pllm_plld_plla_pllc_plld2_clkm, CLK_SOURCE_DISP1, 29, 7, 27, 0, tegra_clk_disp1, NULL),
  451. NODIV("disp2", mux_pllp_pllm_plld_plla_pllc_plld2_clkm, CLK_SOURCE_DISP2, 29, 7, 26, 0, tegra_clk_disp2, NULL),
  452. NODIV("sor0", mux_clkm_plldp_sor0lvds, CLK_SOURCE_SOR0, 14, 3, 182, 0, tegra_clk_sor0, &sor0_lock),
  453. UART("uarta", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_UARTA, 6, tegra_clk_uarta),
  454. UART("uartb", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_UARTB, 7, tegra_clk_uartb),
  455. UART("uartc", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_UARTC, 55, tegra_clk_uartc),
  456. UART("uartd", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_UARTD, 65, tegra_clk_uartd),
  457. UART("uarte", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_UARTE, 66, tegra_clk_uarte),
  458. XUSB("xusb_host_src", mux_clkm_pllp_pllc_pllre, CLK_SOURCE_XUSB_HOST_SRC, 143, TEGRA_PERIPH_ON_APB | TEGRA_PERIPH_NO_RESET, tegra_clk_xusb_host_src),
  459. XUSB("xusb_falcon_src", mux_clkm_pllp_pllc_pllre, CLK_SOURCE_XUSB_FALCON_SRC, 143, TEGRA_PERIPH_NO_RESET, tegra_clk_xusb_falcon_src),
  460. XUSB("xusb_fs_src", mux_clkm_48M_pllp_480M, CLK_SOURCE_XUSB_FS_SRC, 143, TEGRA_PERIPH_NO_RESET, tegra_clk_xusb_fs_src),
  461. XUSB("xusb_ss_src", mux_clkm_pllre_clk32_480M_pllc_ref, CLK_SOURCE_XUSB_SS_SRC, 143, TEGRA_PERIPH_NO_RESET, tegra_clk_xusb_ss_src),
  462. NODIV("xusb_hs_src", mux_ss_60M, CLK_SOURCE_XUSB_SS_SRC, 25, MASK(1), 143, TEGRA_PERIPH_NO_RESET, tegra_clk_xusb_hs_src, NULL),
  463. XUSB("xusb_dev_src", mux_clkm_pllp_pllc_pllre, CLK_SOURCE_XUSB_DEV_SRC, 95, TEGRA_PERIPH_ON_APB | TEGRA_PERIPH_NO_RESET, tegra_clk_xusb_dev_src),
  464. };
  465. static struct tegra_periph_init_data gate_clks[] = {
  466. GATE("rtc", "clk_32k", 4, TEGRA_PERIPH_ON_APB | TEGRA_PERIPH_NO_RESET, tegra_clk_rtc, 0),
  467. GATE("timer", "clk_m", 5, 0, tegra_clk_timer, 0),
  468. GATE("isp", "clk_m", 23, 0, tegra_clk_isp, 0),
  469. GATE("vcp", "clk_m", 29, 0, tegra_clk_vcp, 0),
  470. GATE("apbdma", "clk_m", 34, 0, tegra_clk_apbdma, 0),
  471. GATE("kbc", "clk_32k", 36, TEGRA_PERIPH_ON_APB | TEGRA_PERIPH_NO_RESET, tegra_clk_kbc, 0),
  472. GATE("fuse", "clk_m", 39, TEGRA_PERIPH_ON_APB, tegra_clk_fuse, 0),
  473. GATE("fuse_burn", "clk_m", 39, TEGRA_PERIPH_ON_APB, tegra_clk_fuse_burn, 0),
  474. GATE("kfuse", "clk_m", 40, TEGRA_PERIPH_ON_APB, tegra_clk_kfuse, 0),
  475. GATE("apbif", "clk_m", 107, TEGRA_PERIPH_ON_APB, tegra_clk_apbif, 0),
  476. GATE("hda2hdmi", "clk_m", 128, TEGRA_PERIPH_ON_APB, tegra_clk_hda2hdmi, 0),
  477. GATE("bsea", "clk_m", 62, 0, tegra_clk_bsea, 0),
  478. GATE("bsev", "clk_m", 63, 0, tegra_clk_bsev, 0),
  479. GATE("mipi-cal", "clk_m", 56, 0, tegra_clk_mipi_cal, 0),
  480. GATE("usbd", "clk_m", 22, 0, tegra_clk_usbd, 0),
  481. GATE("usb2", "clk_m", 58, 0, tegra_clk_usb2, 0),
  482. GATE("usb3", "clk_m", 59, 0, tegra_clk_usb3, 0),
  483. GATE("csi", "pll_p_out3", 52, 0, tegra_clk_csi, 0),
  484. GATE("afi", "clk_m", 72, 0, tegra_clk_afi, 0),
  485. GATE("csus", "clk_m", 92, TEGRA_PERIPH_NO_RESET, tegra_clk_csus, 0),
  486. GATE("dds", "clk_m", 150, TEGRA_PERIPH_ON_APB, tegra_clk_dds, 0),
  487. GATE("dp2", "clk_m", 152, TEGRA_PERIPH_ON_APB, tegra_clk_dp2, 0),
  488. GATE("dtv", "clk_m", 79, TEGRA_PERIPH_ON_APB, tegra_clk_dtv, 0),
  489. GATE("xusb_host", "xusb_host_src", 89, 0, tegra_clk_xusb_host, 0),
  490. GATE("xusb_ss", "xusb_ss_src", 156, 0, tegra_clk_xusb_ss, 0),
  491. GATE("xusb_dev", "xusb_dev_src", 95, 0, tegra_clk_xusb_dev, 0),
  492. GATE("emc", "emc_mux", 57, 0, tegra_clk_emc, CLK_IGNORE_UNUSED),
  493. GATE("sata_cold", "clk_m", 129, TEGRA_PERIPH_ON_APB, tegra_clk_sata_cold, 0),
  494. GATE("ispb", "clk_m", 3, 0, tegra_clk_ispb, 0),
  495. GATE("vim2_clk", "clk_m", 11, 0, tegra_clk_vim2_clk, 0),
  496. GATE("pcie", "clk_m", 70, 0, tegra_clk_pcie, 0),
  497. GATE("dpaux", "clk_m", 181, 0, tegra_clk_dpaux, 0),
  498. GATE("gpu", "pll_ref", 184, 0, tegra_clk_gpu, 0),
  499. };
  500. struct pll_out_data {
  501. char *div_name;
  502. char *pll_out_name;
  503. u32 offset;
  504. int clk_id;
  505. u8 div_shift;
  506. u8 div_flags;
  507. u8 rst_shift;
  508. spinlock_t *lock;
  509. };
  510. #define PLL_OUT(_num, _offset, _div_shift, _div_flags, _rst_shift, _id) \
  511. {\
  512. .div_name = "pll_p_out" #_num "_div",\
  513. .pll_out_name = "pll_p_out" #_num,\
  514. .offset = _offset,\
  515. .div_shift = _div_shift,\
  516. .div_flags = _div_flags | TEGRA_DIVIDER_FIXED |\
  517. TEGRA_DIVIDER_ROUND_UP,\
  518. .rst_shift = _rst_shift,\
  519. .clk_id = tegra_clk_ ## _id,\
  520. .lock = &_offset ##_lock,\
  521. }
  522. static struct pll_out_data pllp_out_clks[] = {
  523. PLL_OUT(1, PLLP_OUTA, 8, 0, 0, pll_p_out1),
  524. PLL_OUT(2, PLLP_OUTA, 24, 0, 16, pll_p_out2),
  525. PLL_OUT(2, PLLP_OUTA, 24, TEGRA_DIVIDER_INT, 16, pll_p_out2_int),
  526. PLL_OUT(3, PLLP_OUTB, 8, 0, 0, pll_p_out3),
  527. PLL_OUT(4, PLLP_OUTB, 24, 0, 16, pll_p_out4),
  528. PLL_OUT(5, PLLP_OUTC, 24, 0, 16, pll_p_out5),
  529. };
  530. static void __init periph_clk_init(void __iomem *clk_base,
  531. struct tegra_clk *tegra_clks)
  532. {
  533. int i;
  534. struct clk *clk;
  535. struct clk **dt_clk;
  536. for (i = 0; i < ARRAY_SIZE(periph_clks); i++) {
  537. struct tegra_clk_periph_regs *bank;
  538. struct tegra_periph_init_data *data;
  539. data = periph_clks + i;
  540. dt_clk = tegra_lookup_dt_id(data->clk_id, tegra_clks);
  541. if (!dt_clk)
  542. continue;
  543. bank = get_reg_bank(data->periph.gate.clk_num);
  544. if (!bank)
  545. continue;
  546. data->periph.gate.regs = bank;
  547. clk = tegra_clk_register_periph(data->name,
  548. data->p.parent_names, data->num_parents,
  549. &data->periph, clk_base, data->offset,
  550. data->flags);
  551. *dt_clk = clk;
  552. }
  553. }
  554. static void __init gate_clk_init(void __iomem *clk_base,
  555. struct tegra_clk *tegra_clks)
  556. {
  557. int i;
  558. struct clk *clk;
  559. struct clk **dt_clk;
  560. for (i = 0; i < ARRAY_SIZE(gate_clks); i++) {
  561. struct tegra_periph_init_data *data;
  562. data = gate_clks + i;
  563. dt_clk = tegra_lookup_dt_id(data->clk_id, tegra_clks);
  564. if (!dt_clk)
  565. continue;
  566. clk = tegra_clk_register_periph_gate(data->name,
  567. data->p.parent_name, data->periph.gate.flags,
  568. clk_base, data->flags,
  569. data->periph.gate.clk_num,
  570. periph_clk_enb_refcnt);
  571. *dt_clk = clk;
  572. }
  573. }
  574. static void __init init_pllp(void __iomem *clk_base, void __iomem *pmc_base,
  575. struct tegra_clk *tegra_clks,
  576. struct tegra_clk_pll_params *pll_params)
  577. {
  578. struct clk *clk;
  579. struct clk **dt_clk;
  580. int i;
  581. dt_clk = tegra_lookup_dt_id(tegra_clk_pll_p, tegra_clks);
  582. if (dt_clk) {
  583. /* PLLP */
  584. clk = tegra_clk_register_pll("pll_p", "pll_ref", clk_base,
  585. pmc_base, 0, pll_params, NULL);
  586. clk_register_clkdev(clk, "pll_p", NULL);
  587. *dt_clk = clk;
  588. }
  589. for (i = 0; i < ARRAY_SIZE(pllp_out_clks); i++) {
  590. struct pll_out_data *data;
  591. data = pllp_out_clks + i;
  592. dt_clk = tegra_lookup_dt_id(data->clk_id, tegra_clks);
  593. if (!dt_clk)
  594. continue;
  595. clk = tegra_clk_register_divider(data->div_name, "pll_p",
  596. clk_base + data->offset, 0, data->div_flags,
  597. data->div_shift, 8, 1, data->lock);
  598. clk = tegra_clk_register_pll_out(data->pll_out_name,
  599. data->div_name, clk_base + data->offset,
  600. data->rst_shift + 1, data->rst_shift,
  601. CLK_IGNORE_UNUSED | CLK_SET_RATE_PARENT, 0,
  602. data->lock);
  603. *dt_clk = clk;
  604. }
  605. }
  606. void __init tegra_periph_clk_init(void __iomem *clk_base,
  607. void __iomem *pmc_base, struct tegra_clk *tegra_clks,
  608. struct tegra_clk_pll_params *pll_params)
  609. {
  610. init_pllp(clk_base, pmc_base, tegra_clks, pll_params);
  611. periph_clk_init(clk_base, tegra_clks);
  612. gate_clk_init(clk_base, tegra_clks);
  613. }