clk-tegra124.c 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428
  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.h>
  18. #include <linux/clk-provider.h>
  19. #include <linux/clkdev.h>
  20. #include <linux/of.h>
  21. #include <linux/of_address.h>
  22. #include <linux/delay.h>
  23. #include <linux/export.h>
  24. #include <linux/clk/tegra.h>
  25. #include <dt-bindings/clock/tegra124-car.h>
  26. #include "clk.h"
  27. #include "clk-id.h"
  28. #define CLK_SOURCE_CSITE 0x1d4
  29. #define CLK_SOURCE_EMC 0x19c
  30. #define PLLC_BASE 0x80
  31. #define PLLC_OUT 0x84
  32. #define PLLC_MISC2 0x88
  33. #define PLLC_MISC 0x8c
  34. #define PLLC2_BASE 0x4e8
  35. #define PLLC2_MISC 0x4ec
  36. #define PLLC3_BASE 0x4fc
  37. #define PLLC3_MISC 0x500
  38. #define PLLM_BASE 0x90
  39. #define PLLM_OUT 0x94
  40. #define PLLM_MISC 0x9c
  41. #define PLLP_BASE 0xa0
  42. #define PLLP_MISC 0xac
  43. #define PLLA_BASE 0xb0
  44. #define PLLA_MISC 0xbc
  45. #define PLLD_BASE 0xd0
  46. #define PLLD_MISC 0xdc
  47. #define PLLU_BASE 0xc0
  48. #define PLLU_MISC 0xcc
  49. #define PLLX_BASE 0xe0
  50. #define PLLX_MISC 0xe4
  51. #define PLLX_MISC2 0x514
  52. #define PLLX_MISC3 0x518
  53. #define PLLE_BASE 0xe8
  54. #define PLLE_MISC 0xec
  55. #define PLLD2_BASE 0x4b8
  56. #define PLLD2_MISC 0x4bc
  57. #define PLLE_AUX 0x48c
  58. #define PLLRE_BASE 0x4c4
  59. #define PLLRE_MISC 0x4c8
  60. #define PLLDP_BASE 0x590
  61. #define PLLDP_MISC 0x594
  62. #define PLLC4_BASE 0x5a4
  63. #define PLLC4_MISC 0x5a8
  64. #define PLLC_IDDQ_BIT 26
  65. #define PLLRE_IDDQ_BIT 16
  66. #define PLLSS_IDDQ_BIT 19
  67. #define PLL_BASE_LOCK BIT(27)
  68. #define PLLE_MISC_LOCK BIT(11)
  69. #define PLLRE_MISC_LOCK BIT(24)
  70. #define PLL_MISC_LOCK_ENABLE 18
  71. #define PLLC_MISC_LOCK_ENABLE 24
  72. #define PLLDU_MISC_LOCK_ENABLE 22
  73. #define PLLE_MISC_LOCK_ENABLE 9
  74. #define PLLRE_MISC_LOCK_ENABLE 30
  75. #define PLLSS_MISC_LOCK_ENABLE 30
  76. #define PLLXC_SW_MAX_P 6
  77. #define PMC_PLLM_WB0_OVERRIDE 0x1dc
  78. #define PMC_PLLM_WB0_OVERRIDE_2 0x2b0
  79. #define UTMIP_PLL_CFG2 0x488
  80. #define UTMIP_PLL_CFG2_STABLE_COUNT(x) (((x) & 0xffff) << 6)
  81. #define UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT(x) (((x) & 0x3f) << 18)
  82. #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_A_POWERDOWN BIT(0)
  83. #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_B_POWERDOWN BIT(2)
  84. #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_C_POWERDOWN BIT(4)
  85. #define UTMIP_PLL_CFG1 0x484
  86. #define UTMIP_PLL_CFG1_ENABLE_DLY_COUNT(x) (((x) & 0x1f) << 6)
  87. #define UTMIP_PLL_CFG1_XTAL_FREQ_COUNT(x) (((x) & 0xfff) << 0)
  88. #define UTMIP_PLL_CFG1_FORCE_PLLU_POWERUP BIT(17)
  89. #define UTMIP_PLL_CFG1_FORCE_PLLU_POWERDOWN BIT(16)
  90. #define UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERUP BIT(15)
  91. #define UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERDOWN BIT(14)
  92. #define UTMIP_PLL_CFG1_FORCE_PLL_ACTIVE_POWERDOWN BIT(12)
  93. #define UTMIPLL_HW_PWRDN_CFG0 0x52c
  94. #define UTMIPLL_HW_PWRDN_CFG0_SEQ_START_STATE BIT(25)
  95. #define UTMIPLL_HW_PWRDN_CFG0_SEQ_ENABLE BIT(24)
  96. #define UTMIPLL_HW_PWRDN_CFG0_USE_LOCKDET BIT(6)
  97. #define UTMIPLL_HW_PWRDN_CFG0_SEQ_RESET_INPUT_VALUE BIT(5)
  98. #define UTMIPLL_HW_PWRDN_CFG0_SEQ_IN_SWCTL BIT(4)
  99. #define UTMIPLL_HW_PWRDN_CFG0_CLK_ENABLE_SWCTL BIT(2)
  100. #define UTMIPLL_HW_PWRDN_CFG0_IDDQ_OVERRIDE BIT(1)
  101. #define UTMIPLL_HW_PWRDN_CFG0_IDDQ_SWCTL BIT(0)
  102. /* Tegra CPU clock and reset control regs */
  103. #define CLK_RST_CONTROLLER_CPU_CMPLX_STATUS 0x470
  104. #ifdef CONFIG_PM_SLEEP
  105. static struct cpu_clk_suspend_context {
  106. u32 clk_csite_src;
  107. } tegra124_cpu_clk_sctx;
  108. #endif
  109. static void __iomem *clk_base;
  110. static void __iomem *pmc_base;
  111. static unsigned long osc_freq;
  112. static unsigned long pll_ref_freq;
  113. static DEFINE_SPINLOCK(pll_d_lock);
  114. static DEFINE_SPINLOCK(pll_d2_lock);
  115. static DEFINE_SPINLOCK(pll_e_lock);
  116. static DEFINE_SPINLOCK(pll_re_lock);
  117. static DEFINE_SPINLOCK(pll_u_lock);
  118. /* possible OSC frequencies in Hz */
  119. static unsigned long tegra124_input_freq[] = {
  120. [0] = 13000000,
  121. [1] = 16800000,
  122. [4] = 19200000,
  123. [5] = 38400000,
  124. [8] = 12000000,
  125. [9] = 48000000,
  126. [12] = 260000000,
  127. };
  128. static const char *mux_plld_out0_plld2_out0[] = {
  129. "pll_d_out0", "pll_d2_out0",
  130. };
  131. #define mux_plld_out0_plld2_out0_idx NULL
  132. static const char *mux_pllmcp_clkm[] = {
  133. "pll_m", "pll_c", "pll_p", "clk_m", "pll_m_ud", "pll_c2", "pll_c3",
  134. };
  135. #define mux_pllmcp_clkm_idx NULL
  136. static struct div_nmp pllxc_nmp = {
  137. .divm_shift = 0,
  138. .divm_width = 8,
  139. .divn_shift = 8,
  140. .divn_width = 8,
  141. .divp_shift = 20,
  142. .divp_width = 4,
  143. };
  144. static struct pdiv_map pllxc_p[] = {
  145. { .pdiv = 1, .hw_val = 0 },
  146. { .pdiv = 2, .hw_val = 1 },
  147. { .pdiv = 3, .hw_val = 2 },
  148. { .pdiv = 4, .hw_val = 3 },
  149. { .pdiv = 5, .hw_val = 4 },
  150. { .pdiv = 6, .hw_val = 5 },
  151. { .pdiv = 8, .hw_val = 6 },
  152. { .pdiv = 10, .hw_val = 7 },
  153. { .pdiv = 12, .hw_val = 8 },
  154. { .pdiv = 16, .hw_val = 9 },
  155. { .pdiv = 12, .hw_val = 10 },
  156. { .pdiv = 16, .hw_val = 11 },
  157. { .pdiv = 20, .hw_val = 12 },
  158. { .pdiv = 24, .hw_val = 13 },
  159. { .pdiv = 32, .hw_val = 14 },
  160. { .pdiv = 0, .hw_val = 0 },
  161. };
  162. static struct tegra_clk_pll_freq_table pll_x_freq_table[] = {
  163. /* 1 GHz */
  164. {12000000, 1000000000, 83, 0, 1}, /* actual: 996.0 MHz */
  165. {13000000, 1000000000, 76, 0, 1}, /* actual: 988.0 MHz */
  166. {16800000, 1000000000, 59, 0, 1}, /* actual: 991.2 MHz */
  167. {19200000, 1000000000, 52, 0, 1}, /* actual: 998.4 MHz */
  168. {26000000, 1000000000, 76, 1, 1}, /* actual: 988.0 MHz */
  169. {0, 0, 0, 0, 0, 0},
  170. };
  171. static struct tegra_clk_pll_params pll_x_params = {
  172. .input_min = 12000000,
  173. .input_max = 800000000,
  174. .cf_min = 12000000,
  175. .cf_max = 19200000, /* s/w policy, h/w capability 50 MHz */
  176. .vco_min = 700000000,
  177. .vco_max = 3000000000UL,
  178. .base_reg = PLLX_BASE,
  179. .misc_reg = PLLX_MISC,
  180. .lock_mask = PLL_BASE_LOCK,
  181. .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
  182. .lock_delay = 300,
  183. .iddq_reg = PLLX_MISC3,
  184. .iddq_bit_idx = 3,
  185. .max_p = 6,
  186. .dyn_ramp_reg = PLLX_MISC2,
  187. .stepa_shift = 16,
  188. .stepb_shift = 24,
  189. .pdiv_tohw = pllxc_p,
  190. .div_nmp = &pllxc_nmp,
  191. .freq_table = pll_x_freq_table,
  192. .flags = TEGRA_PLL_USE_LOCK,
  193. };
  194. static struct tegra_clk_pll_freq_table pll_c_freq_table[] = {
  195. { 12000000, 624000000, 104, 1, 2},
  196. { 12000000, 600000000, 100, 1, 2},
  197. { 13000000, 600000000, 92, 1, 2}, /* actual: 598.0 MHz */
  198. { 16800000, 600000000, 71, 1, 2}, /* actual: 596.4 MHz */
  199. { 19200000, 600000000, 62, 1, 2}, /* actual: 595.2 MHz */
  200. { 26000000, 600000000, 92, 2, 2}, /* actual: 598.0 MHz */
  201. { 0, 0, 0, 0, 0, 0 },
  202. };
  203. static struct tegra_clk_pll_params pll_c_params = {
  204. .input_min = 12000000,
  205. .input_max = 800000000,
  206. .cf_min = 12000000,
  207. .cf_max = 19200000, /* s/w policy, h/w capability 50 MHz */
  208. .vco_min = 600000000,
  209. .vco_max = 1400000000,
  210. .base_reg = PLLC_BASE,
  211. .misc_reg = PLLC_MISC,
  212. .lock_mask = PLL_BASE_LOCK,
  213. .lock_enable_bit_idx = PLLC_MISC_LOCK_ENABLE,
  214. .lock_delay = 300,
  215. .iddq_reg = PLLC_MISC,
  216. .iddq_bit_idx = PLLC_IDDQ_BIT,
  217. .max_p = PLLXC_SW_MAX_P,
  218. .dyn_ramp_reg = PLLC_MISC2,
  219. .stepa_shift = 17,
  220. .stepb_shift = 9,
  221. .pdiv_tohw = pllxc_p,
  222. .div_nmp = &pllxc_nmp,
  223. .freq_table = pll_c_freq_table,
  224. .flags = TEGRA_PLL_USE_LOCK,
  225. };
  226. static struct div_nmp pllcx_nmp = {
  227. .divm_shift = 0,
  228. .divm_width = 2,
  229. .divn_shift = 8,
  230. .divn_width = 8,
  231. .divp_shift = 20,
  232. .divp_width = 3,
  233. };
  234. static struct pdiv_map pllc_p[] = {
  235. { .pdiv = 1, .hw_val = 0 },
  236. { .pdiv = 2, .hw_val = 1 },
  237. { .pdiv = 3, .hw_val = 2 },
  238. { .pdiv = 4, .hw_val = 3 },
  239. { .pdiv = 6, .hw_val = 4 },
  240. { .pdiv = 8, .hw_val = 5 },
  241. { .pdiv = 12, .hw_val = 6 },
  242. { .pdiv = 16, .hw_val = 7 },
  243. { .pdiv = 0, .hw_val = 0 },
  244. };
  245. static struct tegra_clk_pll_freq_table pll_cx_freq_table[] = {
  246. {12000000, 600000000, 100, 1, 2},
  247. {13000000, 600000000, 92, 1, 2}, /* actual: 598.0 MHz */
  248. {16800000, 600000000, 71, 1, 2}, /* actual: 596.4 MHz */
  249. {19200000, 600000000, 62, 1, 2}, /* actual: 595.2 MHz */
  250. {26000000, 600000000, 92, 2, 2}, /* actual: 598.0 MHz */
  251. {0, 0, 0, 0, 0, 0},
  252. };
  253. static struct tegra_clk_pll_params pll_c2_params = {
  254. .input_min = 12000000,
  255. .input_max = 48000000,
  256. .cf_min = 12000000,
  257. .cf_max = 19200000,
  258. .vco_min = 600000000,
  259. .vco_max = 1200000000,
  260. .base_reg = PLLC2_BASE,
  261. .misc_reg = PLLC2_MISC,
  262. .lock_mask = PLL_BASE_LOCK,
  263. .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
  264. .lock_delay = 300,
  265. .pdiv_tohw = pllc_p,
  266. .div_nmp = &pllcx_nmp,
  267. .max_p = 7,
  268. .ext_misc_reg[0] = 0x4f0,
  269. .ext_misc_reg[1] = 0x4f4,
  270. .ext_misc_reg[2] = 0x4f8,
  271. .freq_table = pll_cx_freq_table,
  272. .flags = TEGRA_PLL_USE_LOCK,
  273. };
  274. static struct tegra_clk_pll_params pll_c3_params = {
  275. .input_min = 12000000,
  276. .input_max = 48000000,
  277. .cf_min = 12000000,
  278. .cf_max = 19200000,
  279. .vco_min = 600000000,
  280. .vco_max = 1200000000,
  281. .base_reg = PLLC3_BASE,
  282. .misc_reg = PLLC3_MISC,
  283. .lock_mask = PLL_BASE_LOCK,
  284. .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
  285. .lock_delay = 300,
  286. .pdiv_tohw = pllc_p,
  287. .div_nmp = &pllcx_nmp,
  288. .max_p = 7,
  289. .ext_misc_reg[0] = 0x504,
  290. .ext_misc_reg[1] = 0x508,
  291. .ext_misc_reg[2] = 0x50c,
  292. .freq_table = pll_cx_freq_table,
  293. .flags = TEGRA_PLL_USE_LOCK,
  294. };
  295. static struct div_nmp pllss_nmp = {
  296. .divm_shift = 0,
  297. .divm_width = 8,
  298. .divn_shift = 8,
  299. .divn_width = 8,
  300. .divp_shift = 20,
  301. .divp_width = 4,
  302. };
  303. static struct pdiv_map pll12g_ssd_esd_p[] = {
  304. { .pdiv = 1, .hw_val = 0 },
  305. { .pdiv = 2, .hw_val = 1 },
  306. { .pdiv = 3, .hw_val = 2 },
  307. { .pdiv = 4, .hw_val = 3 },
  308. { .pdiv = 5, .hw_val = 4 },
  309. { .pdiv = 6, .hw_val = 5 },
  310. { .pdiv = 8, .hw_val = 6 },
  311. { .pdiv = 10, .hw_val = 7 },
  312. { .pdiv = 12, .hw_val = 8 },
  313. { .pdiv = 16, .hw_val = 9 },
  314. { .pdiv = 12, .hw_val = 10 },
  315. { .pdiv = 16, .hw_val = 11 },
  316. { .pdiv = 20, .hw_val = 12 },
  317. { .pdiv = 24, .hw_val = 13 },
  318. { .pdiv = 32, .hw_val = 14 },
  319. { .pdiv = 0, .hw_val = 0 },
  320. };
  321. static struct tegra_clk_pll_freq_table pll_c4_freq_table[] = {
  322. { 12000000, 600000000, 100, 1, 1},
  323. { 13000000, 600000000, 92, 1, 1}, /* actual: 598.0 MHz */
  324. { 16800000, 600000000, 71, 1, 1}, /* actual: 596.4 MHz */
  325. { 19200000, 600000000, 62, 1, 1}, /* actual: 595.2 MHz */
  326. { 26000000, 600000000, 92, 2, 1}, /* actual: 598.0 MHz */
  327. { 0, 0, 0, 0, 0, 0 },
  328. };
  329. static struct tegra_clk_pll_params pll_c4_params = {
  330. .input_min = 12000000,
  331. .input_max = 1000000000,
  332. .cf_min = 12000000,
  333. .cf_max = 19200000, /* s/w policy, h/w capability 38 MHz */
  334. .vco_min = 600000000,
  335. .vco_max = 1200000000,
  336. .base_reg = PLLC4_BASE,
  337. .misc_reg = PLLC4_MISC,
  338. .lock_mask = PLL_BASE_LOCK,
  339. .lock_enable_bit_idx = PLLSS_MISC_LOCK_ENABLE,
  340. .lock_delay = 300,
  341. .iddq_reg = PLLC4_BASE,
  342. .iddq_bit_idx = PLLSS_IDDQ_BIT,
  343. .pdiv_tohw = pll12g_ssd_esd_p,
  344. .div_nmp = &pllss_nmp,
  345. .ext_misc_reg[0] = 0x5ac,
  346. .ext_misc_reg[1] = 0x5b0,
  347. .ext_misc_reg[2] = 0x5b4,
  348. .freq_table = pll_c4_freq_table,
  349. };
  350. static struct pdiv_map pllm_p[] = {
  351. { .pdiv = 1, .hw_val = 0 },
  352. { .pdiv = 2, .hw_val = 1 },
  353. { .pdiv = 0, .hw_val = 0 },
  354. };
  355. static struct tegra_clk_pll_freq_table pll_m_freq_table[] = {
  356. {12000000, 800000000, 66, 1, 1}, /* actual: 792.0 MHz */
  357. {13000000, 800000000, 61, 1, 1}, /* actual: 793.0 MHz */
  358. {16800000, 800000000, 47, 1, 1}, /* actual: 789.6 MHz */
  359. {19200000, 800000000, 41, 1, 1}, /* actual: 787.2 MHz */
  360. {26000000, 800000000, 61, 2, 1}, /* actual: 793.0 MHz */
  361. {0, 0, 0, 0, 0, 0},
  362. };
  363. static struct div_nmp pllm_nmp = {
  364. .divm_shift = 0,
  365. .divm_width = 8,
  366. .override_divm_shift = 0,
  367. .divn_shift = 8,
  368. .divn_width = 8,
  369. .override_divn_shift = 8,
  370. .divp_shift = 20,
  371. .divp_width = 1,
  372. .override_divp_shift = 27,
  373. };
  374. static struct tegra_clk_pll_params pll_m_params = {
  375. .input_min = 12000000,
  376. .input_max = 500000000,
  377. .cf_min = 12000000,
  378. .cf_max = 19200000, /* s/w policy, h/w capability 50 MHz */
  379. .vco_min = 400000000,
  380. .vco_max = 1066000000,
  381. .base_reg = PLLM_BASE,
  382. .misc_reg = PLLM_MISC,
  383. .lock_mask = PLL_BASE_LOCK,
  384. .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
  385. .lock_delay = 300,
  386. .max_p = 2,
  387. .pdiv_tohw = pllm_p,
  388. .div_nmp = &pllm_nmp,
  389. .pmc_divnm_reg = PMC_PLLM_WB0_OVERRIDE,
  390. .pmc_divp_reg = PMC_PLLM_WB0_OVERRIDE_2,
  391. .freq_table = pll_m_freq_table,
  392. .flags = TEGRA_PLL_USE_LOCK,
  393. };
  394. static struct tegra_clk_pll_freq_table pll_e_freq_table[] = {
  395. /* PLLE special case: use cpcon field to store cml divider value */
  396. {336000000, 100000000, 100, 21, 16, 11},
  397. {312000000, 100000000, 200, 26, 24, 13},
  398. {13000000, 100000000, 200, 1, 26, 13},
  399. {12000000, 100000000, 200, 1, 24, 13},
  400. {0, 0, 0, 0, 0, 0},
  401. };
  402. static struct div_nmp plle_nmp = {
  403. .divm_shift = 0,
  404. .divm_width = 8,
  405. .divn_shift = 8,
  406. .divn_width = 8,
  407. .divp_shift = 24,
  408. .divp_width = 4,
  409. };
  410. static struct tegra_clk_pll_params pll_e_params = {
  411. .input_min = 12000000,
  412. .input_max = 1000000000,
  413. .cf_min = 12000000,
  414. .cf_max = 75000000,
  415. .vco_min = 1600000000,
  416. .vco_max = 2400000000U,
  417. .base_reg = PLLE_BASE,
  418. .misc_reg = PLLE_MISC,
  419. .aux_reg = PLLE_AUX,
  420. .lock_mask = PLLE_MISC_LOCK,
  421. .lock_enable_bit_idx = PLLE_MISC_LOCK_ENABLE,
  422. .lock_delay = 300,
  423. .div_nmp = &plle_nmp,
  424. .freq_table = pll_e_freq_table,
  425. .flags = TEGRA_PLL_FIXED,
  426. .fixed_rate = 100000000,
  427. };
  428. static const struct clk_div_table pll_re_div_table[] = {
  429. { .val = 0, .div = 1 },
  430. { .val = 1, .div = 2 },
  431. { .val = 2, .div = 3 },
  432. { .val = 3, .div = 4 },
  433. { .val = 4, .div = 5 },
  434. { .val = 5, .div = 6 },
  435. { .val = 0, .div = 0 },
  436. };
  437. static struct div_nmp pllre_nmp = {
  438. .divm_shift = 0,
  439. .divm_width = 8,
  440. .divn_shift = 8,
  441. .divn_width = 8,
  442. .divp_shift = 16,
  443. .divp_width = 4,
  444. };
  445. static struct tegra_clk_pll_params pll_re_vco_params = {
  446. .input_min = 12000000,
  447. .input_max = 1000000000,
  448. .cf_min = 12000000,
  449. .cf_max = 19200000, /* s/w policy, h/w capability 38 MHz */
  450. .vco_min = 300000000,
  451. .vco_max = 600000000,
  452. .base_reg = PLLRE_BASE,
  453. .misc_reg = PLLRE_MISC,
  454. .lock_mask = PLLRE_MISC_LOCK,
  455. .lock_enable_bit_idx = PLLRE_MISC_LOCK_ENABLE,
  456. .lock_delay = 300,
  457. .iddq_reg = PLLRE_MISC,
  458. .iddq_bit_idx = PLLRE_IDDQ_BIT,
  459. .div_nmp = &pllre_nmp,
  460. .flags = TEGRA_PLL_USE_LOCK,
  461. };
  462. static struct div_nmp pllp_nmp = {
  463. .divm_shift = 0,
  464. .divm_width = 5,
  465. .divn_shift = 8,
  466. .divn_width = 10,
  467. .divp_shift = 20,
  468. .divp_width = 3,
  469. };
  470. static struct tegra_clk_pll_freq_table pll_p_freq_table[] = {
  471. {12000000, 408000000, 408, 12, 0, 8},
  472. {13000000, 408000000, 408, 13, 0, 8},
  473. {16800000, 408000000, 340, 14, 0, 8},
  474. {19200000, 408000000, 340, 16, 0, 8},
  475. {26000000, 408000000, 408, 26, 0, 8},
  476. {0, 0, 0, 0, 0, 0},
  477. };
  478. static struct tegra_clk_pll_params pll_p_params = {
  479. .input_min = 2000000,
  480. .input_max = 31000000,
  481. .cf_min = 1000000,
  482. .cf_max = 6000000,
  483. .vco_min = 200000000,
  484. .vco_max = 700000000,
  485. .base_reg = PLLP_BASE,
  486. .misc_reg = PLLP_MISC,
  487. .lock_mask = PLL_BASE_LOCK,
  488. .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
  489. .lock_delay = 300,
  490. .div_nmp = &pllp_nmp,
  491. .freq_table = pll_p_freq_table,
  492. .fixed_rate = 408000000,
  493. .flags = TEGRA_PLL_FIXED | TEGRA_PLL_USE_LOCK,
  494. };
  495. static struct tegra_clk_pll_freq_table pll_a_freq_table[] = {
  496. {9600000, 282240000, 147, 5, 0, 4},
  497. {9600000, 368640000, 192, 5, 0, 4},
  498. {9600000, 240000000, 200, 8, 0, 8},
  499. {28800000, 282240000, 245, 25, 0, 8},
  500. {28800000, 368640000, 320, 25, 0, 8},
  501. {28800000, 240000000, 200, 24, 0, 8},
  502. {0, 0, 0, 0, 0, 0},
  503. };
  504. static struct tegra_clk_pll_params pll_a_params = {
  505. .input_min = 2000000,
  506. .input_max = 31000000,
  507. .cf_min = 1000000,
  508. .cf_max = 6000000,
  509. .vco_min = 200000000,
  510. .vco_max = 700000000,
  511. .base_reg = PLLA_BASE,
  512. .misc_reg = PLLA_MISC,
  513. .lock_mask = PLL_BASE_LOCK,
  514. .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
  515. .lock_delay = 300,
  516. .div_nmp = &pllp_nmp,
  517. .freq_table = pll_a_freq_table,
  518. .flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_USE_LOCK,
  519. };
  520. static struct div_nmp plld_nmp = {
  521. .divm_shift = 0,
  522. .divm_width = 5,
  523. .divn_shift = 8,
  524. .divn_width = 11,
  525. .divp_shift = 20,
  526. .divp_width = 3,
  527. };
  528. static struct tegra_clk_pll_freq_table pll_d_freq_table[] = {
  529. {12000000, 216000000, 864, 12, 4, 12},
  530. {13000000, 216000000, 864, 13, 4, 12},
  531. {16800000, 216000000, 720, 14, 4, 12},
  532. {19200000, 216000000, 720, 16, 4, 12},
  533. {26000000, 216000000, 864, 26, 4, 12},
  534. {12000000, 594000000, 594, 12, 1, 12},
  535. {13000000, 594000000, 594, 13, 1, 12},
  536. {16800000, 594000000, 495, 14, 1, 12},
  537. {19200000, 594000000, 495, 16, 1, 12},
  538. {26000000, 594000000, 594, 26, 1, 12},
  539. {12000000, 1000000000, 1000, 12, 1, 12},
  540. {13000000, 1000000000, 1000, 13, 1, 12},
  541. {19200000, 1000000000, 625, 12, 1, 12},
  542. {26000000, 1000000000, 1000, 26, 1, 12},
  543. {0, 0, 0, 0, 0, 0},
  544. };
  545. static struct tegra_clk_pll_params pll_d_params = {
  546. .input_min = 2000000,
  547. .input_max = 40000000,
  548. .cf_min = 1000000,
  549. .cf_max = 6000000,
  550. .vco_min = 500000000,
  551. .vco_max = 1000000000,
  552. .base_reg = PLLD_BASE,
  553. .misc_reg = PLLD_MISC,
  554. .lock_mask = PLL_BASE_LOCK,
  555. .lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE,
  556. .lock_delay = 1000,
  557. .div_nmp = &plld_nmp,
  558. .freq_table = pll_d_freq_table,
  559. .flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON |
  560. TEGRA_PLL_USE_LOCK,
  561. };
  562. static struct tegra_clk_pll_freq_table tegra124_pll_d2_freq_table[] = {
  563. { 12000000, 594000000, 99, 1, 2},
  564. { 13000000, 594000000, 91, 1, 2}, /* actual: 591.5 MHz */
  565. { 16800000, 594000000, 71, 1, 2}, /* actual: 596.4 MHz */
  566. { 19200000, 594000000, 62, 1, 2}, /* actual: 595.2 MHz */
  567. { 26000000, 594000000, 91, 2, 2}, /* actual: 591.5 MHz */
  568. { 0, 0, 0, 0, 0, 0 },
  569. };
  570. static struct tegra_clk_pll_params tegra124_pll_d2_params = {
  571. .input_min = 12000000,
  572. .input_max = 1000000000,
  573. .cf_min = 12000000,
  574. .cf_max = 19200000, /* s/w policy, h/w capability 38 MHz */
  575. .vco_min = 600000000,
  576. .vco_max = 1200000000,
  577. .base_reg = PLLD2_BASE,
  578. .misc_reg = PLLD2_MISC,
  579. .lock_mask = PLL_BASE_LOCK,
  580. .lock_enable_bit_idx = PLLSS_MISC_LOCK_ENABLE,
  581. .lock_delay = 300,
  582. .iddq_reg = PLLD2_BASE,
  583. .iddq_bit_idx = PLLSS_IDDQ_BIT,
  584. .pdiv_tohw = pll12g_ssd_esd_p,
  585. .div_nmp = &pllss_nmp,
  586. .ext_misc_reg[0] = 0x570,
  587. .ext_misc_reg[1] = 0x574,
  588. .ext_misc_reg[2] = 0x578,
  589. .max_p = 15,
  590. .freq_table = tegra124_pll_d2_freq_table,
  591. };
  592. static struct tegra_clk_pll_freq_table pll_dp_freq_table[] = {
  593. { 12000000, 600000000, 100, 1, 1},
  594. { 13000000, 600000000, 92, 1, 1}, /* actual: 598.0 MHz */
  595. { 16800000, 600000000, 71, 1, 1}, /* actual: 596.4 MHz */
  596. { 19200000, 600000000, 62, 1, 1}, /* actual: 595.2 MHz */
  597. { 26000000, 600000000, 92, 2, 1}, /* actual: 598.0 MHz */
  598. { 0, 0, 0, 0, 0, 0 },
  599. };
  600. static struct tegra_clk_pll_params pll_dp_params = {
  601. .input_min = 12000000,
  602. .input_max = 1000000000,
  603. .cf_min = 12000000,
  604. .cf_max = 19200000, /* s/w policy, h/w capability 38 MHz */
  605. .vco_min = 600000000,
  606. .vco_max = 1200000000,
  607. .base_reg = PLLDP_BASE,
  608. .misc_reg = PLLDP_MISC,
  609. .lock_mask = PLL_BASE_LOCK,
  610. .lock_enable_bit_idx = PLLSS_MISC_LOCK_ENABLE,
  611. .lock_delay = 300,
  612. .iddq_reg = PLLDP_BASE,
  613. .iddq_bit_idx = PLLSS_IDDQ_BIT,
  614. .pdiv_tohw = pll12g_ssd_esd_p,
  615. .div_nmp = &pllss_nmp,
  616. .ext_misc_reg[0] = 0x598,
  617. .ext_misc_reg[1] = 0x59c,
  618. .ext_misc_reg[2] = 0x5a0,
  619. .max_p = 5,
  620. .freq_table = pll_dp_freq_table,
  621. };
  622. static struct pdiv_map pllu_p[] = {
  623. { .pdiv = 1, .hw_val = 1 },
  624. { .pdiv = 2, .hw_val = 0 },
  625. { .pdiv = 0, .hw_val = 0 },
  626. };
  627. static struct div_nmp pllu_nmp = {
  628. .divm_shift = 0,
  629. .divm_width = 5,
  630. .divn_shift = 8,
  631. .divn_width = 10,
  632. .divp_shift = 20,
  633. .divp_width = 1,
  634. };
  635. static struct tegra_clk_pll_freq_table pll_u_freq_table[] = {
  636. {12000000, 480000000, 960, 12, 2, 12},
  637. {13000000, 480000000, 960, 13, 2, 12},
  638. {16800000, 480000000, 400, 7, 2, 5},
  639. {19200000, 480000000, 200, 4, 2, 3},
  640. {26000000, 480000000, 960, 26, 2, 12},
  641. {0, 0, 0, 0, 0, 0},
  642. };
  643. static struct tegra_clk_pll_params pll_u_params = {
  644. .input_min = 2000000,
  645. .input_max = 40000000,
  646. .cf_min = 1000000,
  647. .cf_max = 6000000,
  648. .vco_min = 480000000,
  649. .vco_max = 960000000,
  650. .base_reg = PLLU_BASE,
  651. .misc_reg = PLLU_MISC,
  652. .lock_mask = PLL_BASE_LOCK,
  653. .lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE,
  654. .lock_delay = 1000,
  655. .pdiv_tohw = pllu_p,
  656. .div_nmp = &pllu_nmp,
  657. .freq_table = pll_u_freq_table,
  658. .flags = TEGRA_PLLU | TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON |
  659. TEGRA_PLL_USE_LOCK,
  660. };
  661. struct utmi_clk_param {
  662. /* Oscillator Frequency in KHz */
  663. u32 osc_frequency;
  664. /* UTMIP PLL Enable Delay Count */
  665. u8 enable_delay_count;
  666. /* UTMIP PLL Stable count */
  667. u8 stable_count;
  668. /* UTMIP PLL Active delay count */
  669. u8 active_delay_count;
  670. /* UTMIP PLL Xtal frequency count */
  671. u8 xtal_freq_count;
  672. };
  673. static const struct utmi_clk_param utmi_parameters[] = {
  674. {.osc_frequency = 13000000, .enable_delay_count = 0x02,
  675. .stable_count = 0x33, .active_delay_count = 0x05,
  676. .xtal_freq_count = 0x7F},
  677. {.osc_frequency = 19200000, .enable_delay_count = 0x03,
  678. .stable_count = 0x4B, .active_delay_count = 0x06,
  679. .xtal_freq_count = 0xBB},
  680. {.osc_frequency = 12000000, .enable_delay_count = 0x02,
  681. .stable_count = 0x2F, .active_delay_count = 0x04,
  682. .xtal_freq_count = 0x76},
  683. {.osc_frequency = 26000000, .enable_delay_count = 0x04,
  684. .stable_count = 0x66, .active_delay_count = 0x09,
  685. .xtal_freq_count = 0xFE},
  686. {.osc_frequency = 16800000, .enable_delay_count = 0x03,
  687. .stable_count = 0x41, .active_delay_count = 0x0A,
  688. .xtal_freq_count = 0xA4},
  689. };
  690. static struct tegra_clk tegra124_clks[tegra_clk_max] __initdata = {
  691. [tegra_clk_ispb] = { .dt_id = TEGRA124_CLK_ISPB, .present = true },
  692. [tegra_clk_rtc] = { .dt_id = TEGRA124_CLK_RTC, .present = true },
  693. [tegra_clk_timer] = { .dt_id = TEGRA124_CLK_TIMER, .present = true },
  694. [tegra_clk_uarta] = { .dt_id = TEGRA124_CLK_UARTA, .present = true },
  695. [tegra_clk_sdmmc2_8] = { .dt_id = TEGRA124_CLK_SDMMC2, .present = true },
  696. [tegra_clk_i2s1] = { .dt_id = TEGRA124_CLK_I2S1, .present = true },
  697. [tegra_clk_i2c1] = { .dt_id = TEGRA124_CLK_I2C1, .present = true },
  698. [tegra_clk_sdmmc1_8] = { .dt_id = TEGRA124_CLK_SDMMC1, .present = true },
  699. [tegra_clk_sdmmc4_8] = { .dt_id = TEGRA124_CLK_SDMMC4, .present = true },
  700. [tegra_clk_pwm] = { .dt_id = TEGRA124_CLK_PWM, .present = true },
  701. [tegra_clk_i2s2] = { .dt_id = TEGRA124_CLK_I2S2, .present = true },
  702. [tegra_clk_usbd] = { .dt_id = TEGRA124_CLK_USBD, .present = true },
  703. [tegra_clk_isp_8] = { .dt_id = TEGRA124_CLK_ISP, .present = true },
  704. [tegra_clk_disp2] = { .dt_id = TEGRA124_CLK_DISP2, .present = true },
  705. [tegra_clk_disp1] = { .dt_id = TEGRA124_CLK_DISP1, .present = true },
  706. [tegra_clk_host1x_8] = { .dt_id = TEGRA124_CLK_HOST1X, .present = true },
  707. [tegra_clk_vcp] = { .dt_id = TEGRA124_CLK_VCP, .present = true },
  708. [tegra_clk_i2s0] = { .dt_id = TEGRA124_CLK_I2S0, .present = true },
  709. [tegra_clk_apbdma] = { .dt_id = TEGRA124_CLK_APBDMA, .present = true },
  710. [tegra_clk_kbc] = { .dt_id = TEGRA124_CLK_KBC, .present = true },
  711. [tegra_clk_kfuse] = { .dt_id = TEGRA124_CLK_KFUSE, .present = true },
  712. [tegra_clk_sbc1] = { .dt_id = TEGRA124_CLK_SBC1, .present = true },
  713. [tegra_clk_nor] = { .dt_id = TEGRA124_CLK_NOR, .present = true },
  714. [tegra_clk_sbc2] = { .dt_id = TEGRA124_CLK_SBC2, .present = true },
  715. [tegra_clk_sbc3] = { .dt_id = TEGRA124_CLK_SBC3, .present = true },
  716. [tegra_clk_i2c5] = { .dt_id = TEGRA124_CLK_I2C5, .present = true },
  717. [tegra_clk_dsia] = { .dt_id = TEGRA124_CLK_DSIA, .present = true },
  718. [tegra_clk_mipi] = { .dt_id = TEGRA124_CLK_MIPI, .present = true },
  719. [tegra_clk_hdmi] = { .dt_id = TEGRA124_CLK_HDMI, .present = true },
  720. [tegra_clk_csi] = { .dt_id = TEGRA124_CLK_CSI, .present = true },
  721. [tegra_clk_i2c2] = { .dt_id = TEGRA124_CLK_I2C2, .present = true },
  722. [tegra_clk_uartc] = { .dt_id = TEGRA124_CLK_UARTC, .present = true },
  723. [tegra_clk_mipi_cal] = { .dt_id = TEGRA124_CLK_MIPI_CAL, .present = true },
  724. [tegra_clk_emc] = { .dt_id = TEGRA124_CLK_EMC, .present = true },
  725. [tegra_clk_usb2] = { .dt_id = TEGRA124_CLK_USB2, .present = true },
  726. [tegra_clk_usb3] = { .dt_id = TEGRA124_CLK_USB3, .present = true },
  727. [tegra_clk_vde_8] = { .dt_id = TEGRA124_CLK_VDE, .present = true },
  728. [tegra_clk_bsea] = { .dt_id = TEGRA124_CLK_BSEA, .present = true },
  729. [tegra_clk_bsev] = { .dt_id = TEGRA124_CLK_BSEV, .present = true },
  730. [tegra_clk_uartd] = { .dt_id = TEGRA124_CLK_UARTD, .present = true },
  731. [tegra_clk_i2c3] = { .dt_id = TEGRA124_CLK_I2C3, .present = true },
  732. [tegra_clk_sbc4] = { .dt_id = TEGRA124_CLK_SBC4, .present = true },
  733. [tegra_clk_sdmmc3_8] = { .dt_id = TEGRA124_CLK_SDMMC3, .present = true },
  734. [tegra_clk_pcie] = { .dt_id = TEGRA124_CLK_PCIE, .present = true },
  735. [tegra_clk_owr] = { .dt_id = TEGRA124_CLK_OWR, .present = true },
  736. [tegra_clk_afi] = { .dt_id = TEGRA124_CLK_AFI, .present = true },
  737. [tegra_clk_csite] = { .dt_id = TEGRA124_CLK_CSITE, .present = true },
  738. [tegra_clk_la] = { .dt_id = TEGRA124_CLK_LA, .present = true },
  739. [tegra_clk_trace] = { .dt_id = TEGRA124_CLK_TRACE, .present = true },
  740. [tegra_clk_soc_therm] = { .dt_id = TEGRA124_CLK_SOC_THERM, .present = true },
  741. [tegra_clk_dtv] = { .dt_id = TEGRA124_CLK_DTV, .present = true },
  742. [tegra_clk_i2cslow] = { .dt_id = TEGRA124_CLK_I2CSLOW, .present = true },
  743. [tegra_clk_dsib] = { .dt_id = TEGRA124_CLK_DSIB, .present = true },
  744. [tegra_clk_tsec] = { .dt_id = TEGRA124_CLK_TSEC, .present = true },
  745. [tegra_clk_xusb_host] = { .dt_id = TEGRA124_CLK_XUSB_HOST, .present = true },
  746. [tegra_clk_msenc] = { .dt_id = TEGRA124_CLK_MSENC, .present = true },
  747. [tegra_clk_csus] = { .dt_id = TEGRA124_CLK_CSUS, .present = true },
  748. [tegra_clk_mselect] = { .dt_id = TEGRA124_CLK_MSELECT, .present = true },
  749. [tegra_clk_tsensor] = { .dt_id = TEGRA124_CLK_TSENSOR, .present = true },
  750. [tegra_clk_i2s3] = { .dt_id = TEGRA124_CLK_I2S3, .present = true },
  751. [tegra_clk_i2s4] = { .dt_id = TEGRA124_CLK_I2S4, .present = true },
  752. [tegra_clk_i2c4] = { .dt_id = TEGRA124_CLK_I2C4, .present = true },
  753. [tegra_clk_sbc5] = { .dt_id = TEGRA124_CLK_SBC5, .present = true },
  754. [tegra_clk_sbc6] = { .dt_id = TEGRA124_CLK_SBC6, .present = true },
  755. [tegra_clk_d_audio] = { .dt_id = TEGRA124_CLK_D_AUDIO, .present = true },
  756. [tegra_clk_apbif] = { .dt_id = TEGRA124_CLK_APBIF, .present = true },
  757. [tegra_clk_dam0] = { .dt_id = TEGRA124_CLK_DAM0, .present = true },
  758. [tegra_clk_dam1] = { .dt_id = TEGRA124_CLK_DAM1, .present = true },
  759. [tegra_clk_dam2] = { .dt_id = TEGRA124_CLK_DAM2, .present = true },
  760. [tegra_clk_hda2codec_2x] = { .dt_id = TEGRA124_CLK_HDA2CODEC_2X, .present = true },
  761. [tegra_clk_audio0_2x] = { .dt_id = TEGRA124_CLK_AUDIO0_2X, .present = true },
  762. [tegra_clk_audio1_2x] = { .dt_id = TEGRA124_CLK_AUDIO1_2X, .present = true },
  763. [tegra_clk_audio2_2x] = { .dt_id = TEGRA124_CLK_AUDIO2_2X, .present = true },
  764. [tegra_clk_audio3_2x] = { .dt_id = TEGRA124_CLK_AUDIO3_2X, .present = true },
  765. [tegra_clk_audio4_2x] = { .dt_id = TEGRA124_CLK_AUDIO4_2X, .present = true },
  766. [tegra_clk_spdif_2x] = { .dt_id = TEGRA124_CLK_SPDIF_2X, .present = true },
  767. [tegra_clk_actmon] = { .dt_id = TEGRA124_CLK_ACTMON, .present = true },
  768. [tegra_clk_extern1] = { .dt_id = TEGRA124_CLK_EXTERN1, .present = true },
  769. [tegra_clk_extern2] = { .dt_id = TEGRA124_CLK_EXTERN2, .present = true },
  770. [tegra_clk_extern3] = { .dt_id = TEGRA124_CLK_EXTERN3, .present = true },
  771. [tegra_clk_sata_oob] = { .dt_id = TEGRA124_CLK_SATA_OOB, .present = true },
  772. [tegra_clk_sata] = { .dt_id = TEGRA124_CLK_SATA, .present = true },
  773. [tegra_clk_hda] = { .dt_id = TEGRA124_CLK_HDA, .present = true },
  774. [tegra_clk_se] = { .dt_id = TEGRA124_CLK_SE, .present = true },
  775. [tegra_clk_hda2hdmi] = { .dt_id = TEGRA124_CLK_HDA2HDMI, .present = true },
  776. [tegra_clk_sata_cold] = { .dt_id = TEGRA124_CLK_SATA_COLD, .present = true },
  777. [tegra_clk_cilab] = { .dt_id = TEGRA124_CLK_CILAB, .present = true },
  778. [tegra_clk_cilcd] = { .dt_id = TEGRA124_CLK_CILCD, .present = true },
  779. [tegra_clk_cile] = { .dt_id = TEGRA124_CLK_CILE, .present = true },
  780. [tegra_clk_dsialp] = { .dt_id = TEGRA124_CLK_DSIALP, .present = true },
  781. [tegra_clk_dsiblp] = { .dt_id = TEGRA124_CLK_DSIBLP, .present = true },
  782. [tegra_clk_entropy] = { .dt_id = TEGRA124_CLK_ENTROPY, .present = true },
  783. [tegra_clk_dds] = { .dt_id = TEGRA124_CLK_DDS, .present = true },
  784. [tegra_clk_dp2] = { .dt_id = TEGRA124_CLK_DP2, .present = true },
  785. [tegra_clk_amx] = { .dt_id = TEGRA124_CLK_AMX, .present = true },
  786. [tegra_clk_adx] = { .dt_id = TEGRA124_CLK_ADX, .present = true },
  787. [tegra_clk_xusb_ss] = { .dt_id = TEGRA124_CLK_XUSB_SS, .present = true },
  788. [tegra_clk_i2c6] = { .dt_id = TEGRA124_CLK_I2C6, .present = true },
  789. [tegra_clk_vim2_clk] = { .dt_id = TEGRA124_CLK_VIM2_CLK, .present = true },
  790. [tegra_clk_hdmi_audio] = { .dt_id = TEGRA124_CLK_HDMI_AUDIO, .present = true },
  791. [tegra_clk_clk72Mhz] = { .dt_id = TEGRA124_CLK_CLK72MHZ, .present = true },
  792. [tegra_clk_vic03] = { .dt_id = TEGRA124_CLK_VIC03, .present = true },
  793. [tegra_clk_adx1] = { .dt_id = TEGRA124_CLK_ADX1, .present = true },
  794. [tegra_clk_dpaux] = { .dt_id = TEGRA124_CLK_DPAUX, .present = true },
  795. [tegra_clk_sor0] = { .dt_id = TEGRA124_CLK_SOR0, .present = true },
  796. [tegra_clk_sor0_lvds] = { .dt_id = TEGRA124_CLK_SOR0_LVDS, .present = true },
  797. [tegra_clk_gpu] = { .dt_id = TEGRA124_CLK_GPU, .present = true },
  798. [tegra_clk_amx1] = { .dt_id = TEGRA124_CLK_AMX1, .present = true },
  799. [tegra_clk_uartb] = { .dt_id = TEGRA124_CLK_UARTB, .present = true },
  800. [tegra_clk_vfir] = { .dt_id = TEGRA124_CLK_VFIR, .present = true },
  801. [tegra_clk_spdif_in] = { .dt_id = TEGRA124_CLK_SPDIF_IN, .present = true },
  802. [tegra_clk_spdif_out] = { .dt_id = TEGRA124_CLK_SPDIF_OUT, .present = true },
  803. [tegra_clk_vi_9] = { .dt_id = TEGRA124_CLK_VI, .present = true },
  804. [tegra_clk_vi_sensor] = { .dt_id = TEGRA124_CLK_VI_SENSOR, .present = true },
  805. [tegra_clk_fuse] = { .dt_id = TEGRA124_CLK_FUSE, .present = true },
  806. [tegra_clk_fuse_burn] = { .dt_id = TEGRA124_CLK_FUSE_BURN, .present = true },
  807. [tegra_clk_clk_32k] = { .dt_id = TEGRA124_CLK_CLK_32K, .present = true },
  808. [tegra_clk_clk_m] = { .dt_id = TEGRA124_CLK_CLK_M, .present = true },
  809. [tegra_clk_clk_m_div2] = { .dt_id = TEGRA124_CLK_CLK_M_DIV2, .present = true },
  810. [tegra_clk_clk_m_div4] = { .dt_id = TEGRA124_CLK_CLK_M_DIV4, .present = true },
  811. [tegra_clk_pll_ref] = { .dt_id = TEGRA124_CLK_PLL_REF, .present = true },
  812. [tegra_clk_pll_c] = { .dt_id = TEGRA124_CLK_PLL_C, .present = true },
  813. [tegra_clk_pll_c_out1] = { .dt_id = TEGRA124_CLK_PLL_C_OUT1, .present = true },
  814. [tegra_clk_pll_c2] = { .dt_id = TEGRA124_CLK_PLL_C2, .present = true },
  815. [tegra_clk_pll_c3] = { .dt_id = TEGRA124_CLK_PLL_C3, .present = true },
  816. [tegra_clk_pll_m] = { .dt_id = TEGRA124_CLK_PLL_M, .present = true },
  817. [tegra_clk_pll_m_out1] = { .dt_id = TEGRA124_CLK_PLL_M_OUT1, .present = true },
  818. [tegra_clk_pll_p] = { .dt_id = TEGRA124_CLK_PLL_P, .present = true },
  819. [tegra_clk_pll_p_out1] = { .dt_id = TEGRA124_CLK_PLL_P_OUT1, .present = true },
  820. [tegra_clk_pll_p_out2] = { .dt_id = TEGRA124_CLK_PLL_P_OUT2, .present = true },
  821. [tegra_clk_pll_p_out3] = { .dt_id = TEGRA124_CLK_PLL_P_OUT3, .present = true },
  822. [tegra_clk_pll_p_out4] = { .dt_id = TEGRA124_CLK_PLL_P_OUT4, .present = true },
  823. [tegra_clk_pll_a] = { .dt_id = TEGRA124_CLK_PLL_A, .present = true },
  824. [tegra_clk_pll_a_out0] = { .dt_id = TEGRA124_CLK_PLL_A_OUT0, .present = true },
  825. [tegra_clk_pll_d] = { .dt_id = TEGRA124_CLK_PLL_D, .present = true },
  826. [tegra_clk_pll_d_out0] = { .dt_id = TEGRA124_CLK_PLL_D_OUT0, .present = true },
  827. [tegra_clk_pll_d2] = { .dt_id = TEGRA124_CLK_PLL_D2, .present = true },
  828. [tegra_clk_pll_d2_out0] = { .dt_id = TEGRA124_CLK_PLL_D2_OUT0, .present = true },
  829. [tegra_clk_pll_u] = { .dt_id = TEGRA124_CLK_PLL_U, .present = true },
  830. [tegra_clk_pll_u_480m] = { .dt_id = TEGRA124_CLK_PLL_U_480M, .present = true },
  831. [tegra_clk_pll_u_60m] = { .dt_id = TEGRA124_CLK_PLL_U_60M, .present = true },
  832. [tegra_clk_pll_u_48m] = { .dt_id = TEGRA124_CLK_PLL_U_48M, .present = true },
  833. [tegra_clk_pll_u_12m] = { .dt_id = TEGRA124_CLK_PLL_U_12M, .present = true },
  834. [tegra_clk_pll_x] = { .dt_id = TEGRA124_CLK_PLL_X, .present = true },
  835. [tegra_clk_pll_x_out0] = { .dt_id = TEGRA124_CLK_PLL_X_OUT0, .present = true },
  836. [tegra_clk_pll_re_vco] = { .dt_id = TEGRA124_CLK_PLL_RE_VCO, .present = true },
  837. [tegra_clk_pll_re_out] = { .dt_id = TEGRA124_CLK_PLL_RE_OUT, .present = true },
  838. [tegra_clk_spdif_in_sync] = { .dt_id = TEGRA124_CLK_SPDIF_IN_SYNC, .present = true },
  839. [tegra_clk_i2s0_sync] = { .dt_id = TEGRA124_CLK_I2S0_SYNC, .present = true },
  840. [tegra_clk_i2s1_sync] = { .dt_id = TEGRA124_CLK_I2S1_SYNC, .present = true },
  841. [tegra_clk_i2s2_sync] = { .dt_id = TEGRA124_CLK_I2S2_SYNC, .present = true },
  842. [tegra_clk_i2s3_sync] = { .dt_id = TEGRA124_CLK_I2S3_SYNC, .present = true },
  843. [tegra_clk_i2s4_sync] = { .dt_id = TEGRA124_CLK_I2S4_SYNC, .present = true },
  844. [tegra_clk_vimclk_sync] = { .dt_id = TEGRA124_CLK_VIMCLK_SYNC, .present = true },
  845. [tegra_clk_audio0] = { .dt_id = TEGRA124_CLK_AUDIO0, .present = true },
  846. [tegra_clk_audio1] = { .dt_id = TEGRA124_CLK_AUDIO1, .present = true },
  847. [tegra_clk_audio2] = { .dt_id = TEGRA124_CLK_AUDIO2, .present = true },
  848. [tegra_clk_audio3] = { .dt_id = TEGRA124_CLK_AUDIO3, .present = true },
  849. [tegra_clk_audio4] = { .dt_id = TEGRA124_CLK_AUDIO4, .present = true },
  850. [tegra_clk_spdif] = { .dt_id = TEGRA124_CLK_SPDIF, .present = true },
  851. [tegra_clk_clk_out_1] = { .dt_id = TEGRA124_CLK_CLK_OUT_1, .present = true },
  852. [tegra_clk_clk_out_2] = { .dt_id = TEGRA124_CLK_CLK_OUT_2, .present = true },
  853. [tegra_clk_clk_out_3] = { .dt_id = TEGRA124_CLK_CLK_OUT_3, .present = true },
  854. [tegra_clk_blink] = { .dt_id = TEGRA124_CLK_BLINK, .present = true },
  855. [tegra_clk_xusb_host_src] = { .dt_id = TEGRA124_CLK_XUSB_HOST_SRC, .present = true },
  856. [tegra_clk_xusb_falcon_src] = { .dt_id = TEGRA124_CLK_XUSB_FALCON_SRC, .present = true },
  857. [tegra_clk_xusb_fs_src] = { .dt_id = TEGRA124_CLK_XUSB_FS_SRC, .present = true },
  858. [tegra_clk_xusb_ss_src] = { .dt_id = TEGRA124_CLK_XUSB_SS_SRC, .present = true },
  859. [tegra_clk_xusb_ss_div2] = { .dt_id = TEGRA124_CLK_XUSB_SS_DIV2, .present = true },
  860. [tegra_clk_xusb_dev_src] = { .dt_id = TEGRA124_CLK_XUSB_DEV_SRC, .present = true },
  861. [tegra_clk_xusb_dev] = { .dt_id = TEGRA124_CLK_XUSB_DEV, .present = true },
  862. [tegra_clk_xusb_hs_src] = { .dt_id = TEGRA124_CLK_XUSB_HS_SRC, .present = true },
  863. [tegra_clk_sclk] = { .dt_id = TEGRA124_CLK_SCLK, .present = true },
  864. [tegra_clk_hclk] = { .dt_id = TEGRA124_CLK_HCLK, .present = true },
  865. [tegra_clk_pclk] = { .dt_id = TEGRA124_CLK_PCLK, .present = true },
  866. [tegra_clk_cclk_g] = { .dt_id = TEGRA124_CLK_CCLK_G, .present = true },
  867. [tegra_clk_cclk_lp] = { .dt_id = TEGRA124_CLK_CCLK_LP, .present = true },
  868. [tegra_clk_dfll_ref] = { .dt_id = TEGRA124_CLK_DFLL_REF, .present = true },
  869. [tegra_clk_dfll_soc] = { .dt_id = TEGRA124_CLK_DFLL_SOC, .present = true },
  870. [tegra_clk_vi_sensor2] = { .dt_id = TEGRA124_CLK_VI_SENSOR2, .present = true },
  871. [tegra_clk_pll_p_out5] = { .dt_id = TEGRA124_CLK_PLL_P_OUT5, .present = true },
  872. [tegra_clk_pll_c4] = { .dt_id = TEGRA124_CLK_PLL_C4, .present = true },
  873. [tegra_clk_pll_dp] = { .dt_id = TEGRA124_CLK_PLL_DP, .present = true },
  874. [tegra_clk_audio0_mux] = { .dt_id = TEGRA124_CLK_AUDIO0_MUX, .present = true },
  875. [tegra_clk_audio1_mux] = { .dt_id = TEGRA124_CLK_AUDIO1_MUX, .present = true },
  876. [tegra_clk_audio2_mux] = { .dt_id = TEGRA124_CLK_AUDIO2_MUX, .present = true },
  877. [tegra_clk_audio3_mux] = { .dt_id = TEGRA124_CLK_AUDIO3_MUX, .present = true },
  878. [tegra_clk_audio4_mux] = { .dt_id = TEGRA124_CLK_AUDIO4_MUX, .present = true },
  879. [tegra_clk_spdif_mux] = { .dt_id = TEGRA124_CLK_SPDIF_MUX, .present = true },
  880. [tegra_clk_clk_out_1_mux] = { .dt_id = TEGRA124_CLK_CLK_OUT_1_MUX, .present = true },
  881. [tegra_clk_clk_out_2_mux] = { .dt_id = TEGRA124_CLK_CLK_OUT_2_MUX, .present = true },
  882. [tegra_clk_clk_out_3_mux] = { .dt_id = TEGRA124_CLK_CLK_OUT_3_MUX, .present = true },
  883. [tegra_clk_dsia_mux] = { .dt_id = TEGRA124_CLK_DSIA_MUX, .present = true },
  884. [tegra_clk_dsib_mux] = { .dt_id = TEGRA124_CLK_DSIB_MUX, .present = true },
  885. };
  886. static struct tegra_devclk devclks[] __initdata = {
  887. { .con_id = "clk_m", .dt_id = TEGRA124_CLK_CLK_M },
  888. { .con_id = "pll_ref", .dt_id = TEGRA124_CLK_PLL_REF },
  889. { .con_id = "clk_32k", .dt_id = TEGRA124_CLK_CLK_32K },
  890. { .con_id = "clk_m_div2", .dt_id = TEGRA124_CLK_CLK_M_DIV2 },
  891. { .con_id = "clk_m_div4", .dt_id = TEGRA124_CLK_CLK_M_DIV4 },
  892. { .con_id = "pll_c", .dt_id = TEGRA124_CLK_PLL_C },
  893. { .con_id = "pll_c_out1", .dt_id = TEGRA124_CLK_PLL_C_OUT1 },
  894. { .con_id = "pll_c2", .dt_id = TEGRA124_CLK_PLL_C2 },
  895. { .con_id = "pll_c3", .dt_id = TEGRA124_CLK_PLL_C3 },
  896. { .con_id = "pll_p", .dt_id = TEGRA124_CLK_PLL_P },
  897. { .con_id = "pll_p_out1", .dt_id = TEGRA124_CLK_PLL_P_OUT1 },
  898. { .con_id = "pll_p_out2", .dt_id = TEGRA124_CLK_PLL_P_OUT2 },
  899. { .con_id = "pll_p_out3", .dt_id = TEGRA124_CLK_PLL_P_OUT3 },
  900. { .con_id = "pll_p_out4", .dt_id = TEGRA124_CLK_PLL_P_OUT4 },
  901. { .con_id = "pll_m", .dt_id = TEGRA124_CLK_PLL_M },
  902. { .con_id = "pll_m_out1", .dt_id = TEGRA124_CLK_PLL_M_OUT1 },
  903. { .con_id = "pll_x", .dt_id = TEGRA124_CLK_PLL_X },
  904. { .con_id = "pll_x_out0", .dt_id = TEGRA124_CLK_PLL_X_OUT0 },
  905. { .con_id = "pll_u", .dt_id = TEGRA124_CLK_PLL_U },
  906. { .con_id = "pll_u_480M", .dt_id = TEGRA124_CLK_PLL_U_480M },
  907. { .con_id = "pll_u_60M", .dt_id = TEGRA124_CLK_PLL_U_60M },
  908. { .con_id = "pll_u_48M", .dt_id = TEGRA124_CLK_PLL_U_48M },
  909. { .con_id = "pll_u_12M", .dt_id = TEGRA124_CLK_PLL_U_12M },
  910. { .con_id = "pll_d", .dt_id = TEGRA124_CLK_PLL_D },
  911. { .con_id = "pll_d_out0", .dt_id = TEGRA124_CLK_PLL_D_OUT0 },
  912. { .con_id = "pll_d2", .dt_id = TEGRA124_CLK_PLL_D2 },
  913. { .con_id = "pll_d2_out0", .dt_id = TEGRA124_CLK_PLL_D2_OUT0 },
  914. { .con_id = "pll_a", .dt_id = TEGRA124_CLK_PLL_A },
  915. { .con_id = "pll_a_out0", .dt_id = TEGRA124_CLK_PLL_A_OUT0 },
  916. { .con_id = "pll_re_vco", .dt_id = TEGRA124_CLK_PLL_RE_VCO },
  917. { .con_id = "pll_re_out", .dt_id = TEGRA124_CLK_PLL_RE_OUT },
  918. { .con_id = "spdif_in_sync", .dt_id = TEGRA124_CLK_SPDIF_IN_SYNC },
  919. { .con_id = "i2s0_sync", .dt_id = TEGRA124_CLK_I2S0_SYNC },
  920. { .con_id = "i2s1_sync", .dt_id = TEGRA124_CLK_I2S1_SYNC },
  921. { .con_id = "i2s2_sync", .dt_id = TEGRA124_CLK_I2S2_SYNC },
  922. { .con_id = "i2s3_sync", .dt_id = TEGRA124_CLK_I2S3_SYNC },
  923. { .con_id = "i2s4_sync", .dt_id = TEGRA124_CLK_I2S4_SYNC },
  924. { .con_id = "vimclk_sync", .dt_id = TEGRA124_CLK_VIMCLK_SYNC },
  925. { .con_id = "audio0", .dt_id = TEGRA124_CLK_AUDIO0 },
  926. { .con_id = "audio1", .dt_id = TEGRA124_CLK_AUDIO1 },
  927. { .con_id = "audio2", .dt_id = TEGRA124_CLK_AUDIO2 },
  928. { .con_id = "audio3", .dt_id = TEGRA124_CLK_AUDIO3 },
  929. { .con_id = "audio4", .dt_id = TEGRA124_CLK_AUDIO4 },
  930. { .con_id = "spdif", .dt_id = TEGRA124_CLK_SPDIF },
  931. { .con_id = "audio0_2x", .dt_id = TEGRA124_CLK_AUDIO0_2X },
  932. { .con_id = "audio1_2x", .dt_id = TEGRA124_CLK_AUDIO1_2X },
  933. { .con_id = "audio2_2x", .dt_id = TEGRA124_CLK_AUDIO2_2X },
  934. { .con_id = "audio3_2x", .dt_id = TEGRA124_CLK_AUDIO3_2X },
  935. { .con_id = "audio4_2x", .dt_id = TEGRA124_CLK_AUDIO4_2X },
  936. { .con_id = "spdif_2x", .dt_id = TEGRA124_CLK_SPDIF_2X },
  937. { .con_id = "extern1", .dev_id = "clk_out_1", .dt_id = TEGRA124_CLK_EXTERN1 },
  938. { .con_id = "extern2", .dev_id = "clk_out_2", .dt_id = TEGRA124_CLK_EXTERN2 },
  939. { .con_id = "extern3", .dev_id = "clk_out_3", .dt_id = TEGRA124_CLK_EXTERN3 },
  940. { .con_id = "blink", .dt_id = TEGRA124_CLK_BLINK },
  941. { .con_id = "cclk_g", .dt_id = TEGRA124_CLK_CCLK_G },
  942. { .con_id = "cclk_lp", .dt_id = TEGRA124_CLK_CCLK_LP },
  943. { .con_id = "sclk", .dt_id = TEGRA124_CLK_SCLK },
  944. { .con_id = "hclk", .dt_id = TEGRA124_CLK_HCLK },
  945. { .con_id = "pclk", .dt_id = TEGRA124_CLK_PCLK },
  946. { .con_id = "fuse", .dt_id = TEGRA124_CLK_FUSE },
  947. { .dev_id = "rtc-tegra", .dt_id = TEGRA124_CLK_RTC },
  948. { .dev_id = "timer", .dt_id = TEGRA124_CLK_TIMER },
  949. };
  950. static struct clk **clks;
  951. static void tegra124_utmi_param_configure(void __iomem *clk_base)
  952. {
  953. u32 reg;
  954. int i;
  955. for (i = 0; i < ARRAY_SIZE(utmi_parameters); i++) {
  956. if (osc_freq == utmi_parameters[i].osc_frequency)
  957. break;
  958. }
  959. if (i >= ARRAY_SIZE(utmi_parameters)) {
  960. pr_err("%s: Unexpected oscillator freq %lu\n", __func__,
  961. osc_freq);
  962. return;
  963. }
  964. reg = readl_relaxed(clk_base + UTMIP_PLL_CFG2);
  965. /* Program UTMIP PLL stable and active counts */
  966. /* [FIXME] arclk_rst.h says WRONG! This should be 1ms -> 0x50 Check! */
  967. reg &= ~UTMIP_PLL_CFG2_STABLE_COUNT(~0);
  968. reg |= UTMIP_PLL_CFG2_STABLE_COUNT(utmi_parameters[i].stable_count);
  969. reg &= ~UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT(~0);
  970. reg |= UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT(utmi_parameters[i].
  971. active_delay_count);
  972. /* Remove power downs from UTMIP PLL control bits */
  973. reg &= ~UTMIP_PLL_CFG2_FORCE_PD_SAMP_A_POWERDOWN;
  974. reg &= ~UTMIP_PLL_CFG2_FORCE_PD_SAMP_B_POWERDOWN;
  975. reg &= ~UTMIP_PLL_CFG2_FORCE_PD_SAMP_C_POWERDOWN;
  976. writel_relaxed(reg, clk_base + UTMIP_PLL_CFG2);
  977. /* Program UTMIP PLL delay and oscillator frequency counts */
  978. reg = readl_relaxed(clk_base + UTMIP_PLL_CFG1);
  979. reg &= ~UTMIP_PLL_CFG1_ENABLE_DLY_COUNT(~0);
  980. reg |= UTMIP_PLL_CFG1_ENABLE_DLY_COUNT(utmi_parameters[i].
  981. enable_delay_count);
  982. reg &= ~UTMIP_PLL_CFG1_XTAL_FREQ_COUNT(~0);
  983. reg |= UTMIP_PLL_CFG1_XTAL_FREQ_COUNT(utmi_parameters[i].
  984. xtal_freq_count);
  985. /* Remove power downs from UTMIP PLL control bits */
  986. reg &= ~UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERDOWN;
  987. reg &= ~UTMIP_PLL_CFG1_FORCE_PLL_ACTIVE_POWERDOWN;
  988. reg &= ~UTMIP_PLL_CFG1_FORCE_PLLU_POWERUP;
  989. reg &= ~UTMIP_PLL_CFG1_FORCE_PLLU_POWERDOWN;
  990. writel_relaxed(reg, clk_base + UTMIP_PLL_CFG1);
  991. /* Setup HW control of UTMIPLL */
  992. reg = readl_relaxed(clk_base + UTMIPLL_HW_PWRDN_CFG0);
  993. reg |= UTMIPLL_HW_PWRDN_CFG0_USE_LOCKDET;
  994. reg &= ~UTMIPLL_HW_PWRDN_CFG0_CLK_ENABLE_SWCTL;
  995. reg |= UTMIPLL_HW_PWRDN_CFG0_SEQ_START_STATE;
  996. writel_relaxed(reg, clk_base + UTMIPLL_HW_PWRDN_CFG0);
  997. reg = readl_relaxed(clk_base + UTMIP_PLL_CFG1);
  998. reg &= ~UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERUP;
  999. reg &= ~UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERDOWN;
  1000. writel_relaxed(reg, clk_base + UTMIP_PLL_CFG1);
  1001. udelay(1);
  1002. /* Setup SW override of UTMIPLL assuming USB2.0
  1003. ports are assigned to USB2 */
  1004. reg = readl_relaxed(clk_base + UTMIPLL_HW_PWRDN_CFG0);
  1005. reg |= UTMIPLL_HW_PWRDN_CFG0_IDDQ_SWCTL;
  1006. reg &= ~UTMIPLL_HW_PWRDN_CFG0_IDDQ_OVERRIDE;
  1007. writel_relaxed(reg, clk_base + UTMIPLL_HW_PWRDN_CFG0);
  1008. udelay(1);
  1009. /* Enable HW control UTMIPLL */
  1010. reg = readl_relaxed(clk_base + UTMIPLL_HW_PWRDN_CFG0);
  1011. reg |= UTMIPLL_HW_PWRDN_CFG0_SEQ_ENABLE;
  1012. writel_relaxed(reg, clk_base + UTMIPLL_HW_PWRDN_CFG0);
  1013. }
  1014. static __init void tegra124_periph_clk_init(void __iomem *clk_base,
  1015. void __iomem *pmc_base)
  1016. {
  1017. struct clk *clk;
  1018. /* xusb_ss_div2 */
  1019. clk = clk_register_fixed_factor(NULL, "xusb_ss_div2", "xusb_ss_src", 0,
  1020. 1, 2);
  1021. clks[TEGRA124_CLK_XUSB_SS_DIV2] = clk;
  1022. /* dsia mux */
  1023. clk = clk_register_mux(NULL, "dsia_mux", mux_plld_out0_plld2_out0,
  1024. ARRAY_SIZE(mux_plld_out0_plld2_out0), 0,
  1025. clk_base + PLLD_BASE, 25, 1, 0, &pll_d_lock);
  1026. clks[TEGRA124_CLK_DSIA_MUX] = clk;
  1027. /* dsib mux */
  1028. clk = clk_register_mux(NULL, "dsib_mux", mux_plld_out0_plld2_out0,
  1029. ARRAY_SIZE(mux_plld_out0_plld2_out0), 0,
  1030. clk_base + PLLD2_BASE, 25, 1, 0, &pll_d2_lock);
  1031. clks[TEGRA124_CLK_DSIB_MUX] = clk;
  1032. /* emc mux */
  1033. clk = clk_register_mux(NULL, "emc_mux", mux_pllmcp_clkm,
  1034. ARRAY_SIZE(mux_pllmcp_clkm), 0,
  1035. clk_base + CLK_SOURCE_EMC,
  1036. 29, 3, 0, NULL);
  1037. /* cml0 */
  1038. clk = clk_register_gate(NULL, "cml0", "pll_e", 0, clk_base + PLLE_AUX,
  1039. 0, 0, &pll_e_lock);
  1040. clk_register_clkdev(clk, "cml0", NULL);
  1041. clks[TEGRA124_CLK_CML0] = clk;
  1042. /* cml1 */
  1043. clk = clk_register_gate(NULL, "cml1", "pll_e", 0, clk_base + PLLE_AUX,
  1044. 1, 0, &pll_e_lock);
  1045. clk_register_clkdev(clk, "cml1", NULL);
  1046. clks[TEGRA124_CLK_CML1] = clk;
  1047. tegra_periph_clk_init(clk_base, pmc_base, tegra124_clks, &pll_p_params);
  1048. }
  1049. static void __init tegra124_pll_init(void __iomem *clk_base,
  1050. void __iomem *pmc)
  1051. {
  1052. u32 val;
  1053. struct clk *clk;
  1054. /* PLLC */
  1055. clk = tegra_clk_register_pllxc("pll_c", "pll_ref", clk_base,
  1056. pmc, 0, &pll_c_params, NULL);
  1057. clk_register_clkdev(clk, "pll_c", NULL);
  1058. clks[TEGRA124_CLK_PLL_C] = clk;
  1059. /* PLLC_OUT1 */
  1060. clk = tegra_clk_register_divider("pll_c_out1_div", "pll_c",
  1061. clk_base + PLLC_OUT, 0, TEGRA_DIVIDER_ROUND_UP,
  1062. 8, 8, 1, NULL);
  1063. clk = tegra_clk_register_pll_out("pll_c_out1", "pll_c_out1_div",
  1064. clk_base + PLLC_OUT, 1, 0,
  1065. CLK_SET_RATE_PARENT, 0, NULL);
  1066. clk_register_clkdev(clk, "pll_c_out1", NULL);
  1067. clks[TEGRA124_CLK_PLL_C_OUT1] = clk;
  1068. /* PLLC2 */
  1069. clk = tegra_clk_register_pllc("pll_c2", "pll_ref", clk_base, pmc, 0,
  1070. &pll_c2_params, NULL);
  1071. clk_register_clkdev(clk, "pll_c2", NULL);
  1072. clks[TEGRA124_CLK_PLL_C2] = clk;
  1073. /* PLLC3 */
  1074. clk = tegra_clk_register_pllc("pll_c3", "pll_ref", clk_base, pmc, 0,
  1075. &pll_c3_params, NULL);
  1076. clk_register_clkdev(clk, "pll_c3", NULL);
  1077. clks[TEGRA124_CLK_PLL_C3] = clk;
  1078. /* PLLM */
  1079. clk = tegra_clk_register_pllm("pll_m", "pll_ref", clk_base, pmc,
  1080. CLK_IGNORE_UNUSED | CLK_SET_RATE_GATE,
  1081. &pll_m_params, NULL);
  1082. clk_register_clkdev(clk, "pll_m", NULL);
  1083. clks[TEGRA124_CLK_PLL_M] = clk;
  1084. /* PLLM_OUT1 */
  1085. clk = tegra_clk_register_divider("pll_m_out1_div", "pll_m",
  1086. clk_base + PLLM_OUT, 0, TEGRA_DIVIDER_ROUND_UP,
  1087. 8, 8, 1, NULL);
  1088. clk = tegra_clk_register_pll_out("pll_m_out1", "pll_m_out1_div",
  1089. clk_base + PLLM_OUT, 1, 0, CLK_IGNORE_UNUSED |
  1090. CLK_SET_RATE_PARENT, 0, NULL);
  1091. clk_register_clkdev(clk, "pll_m_out1", NULL);
  1092. clks[TEGRA124_CLK_PLL_M_OUT1] = clk;
  1093. /* PLLM_UD */
  1094. clk = clk_register_fixed_factor(NULL, "pll_m_ud", "pll_m",
  1095. CLK_SET_RATE_PARENT, 1, 1);
  1096. /* PLLU */
  1097. val = readl(clk_base + pll_u_params.base_reg);
  1098. val &= ~BIT(24); /* disable PLLU_OVERRIDE */
  1099. writel(val, clk_base + pll_u_params.base_reg);
  1100. clk = tegra_clk_register_pll("pll_u", "pll_ref", clk_base, pmc, 0,
  1101. &pll_u_params, &pll_u_lock);
  1102. clk_register_clkdev(clk, "pll_u", NULL);
  1103. clks[TEGRA124_CLK_PLL_U] = clk;
  1104. tegra124_utmi_param_configure(clk_base);
  1105. /* PLLU_480M */
  1106. clk = clk_register_gate(NULL, "pll_u_480M", "pll_u",
  1107. CLK_SET_RATE_PARENT, clk_base + PLLU_BASE,
  1108. 22, 0, &pll_u_lock);
  1109. clk_register_clkdev(clk, "pll_u_480M", NULL);
  1110. clks[TEGRA124_CLK_PLL_U_480M] = clk;
  1111. /* PLLU_60M */
  1112. clk = clk_register_fixed_factor(NULL, "pll_u_60M", "pll_u",
  1113. CLK_SET_RATE_PARENT, 1, 8);
  1114. clk_register_clkdev(clk, "pll_u_60M", NULL);
  1115. clks[TEGRA124_CLK_PLL_U_60M] = clk;
  1116. /* PLLU_48M */
  1117. clk = clk_register_fixed_factor(NULL, "pll_u_48M", "pll_u",
  1118. CLK_SET_RATE_PARENT, 1, 10);
  1119. clk_register_clkdev(clk, "pll_u_48M", NULL);
  1120. clks[TEGRA124_CLK_PLL_U_48M] = clk;
  1121. /* PLLU_12M */
  1122. clk = clk_register_fixed_factor(NULL, "pll_u_12M", "pll_u",
  1123. CLK_SET_RATE_PARENT, 1, 40);
  1124. clk_register_clkdev(clk, "pll_u_12M", NULL);
  1125. clks[TEGRA124_CLK_PLL_U_12M] = clk;
  1126. /* PLLD */
  1127. clk = tegra_clk_register_pll("pll_d", "pll_ref", clk_base, pmc, 0,
  1128. &pll_d_params, &pll_d_lock);
  1129. clk_register_clkdev(clk, "pll_d", NULL);
  1130. clks[TEGRA124_CLK_PLL_D] = clk;
  1131. /* PLLD_OUT0 */
  1132. clk = clk_register_fixed_factor(NULL, "pll_d_out0", "pll_d",
  1133. CLK_SET_RATE_PARENT, 1, 2);
  1134. clk_register_clkdev(clk, "pll_d_out0", NULL);
  1135. clks[TEGRA124_CLK_PLL_D_OUT0] = clk;
  1136. /* PLLRE */
  1137. clk = tegra_clk_register_pllre("pll_re_vco", "pll_ref", clk_base, pmc,
  1138. 0, &pll_re_vco_params, &pll_re_lock, pll_ref_freq);
  1139. clk_register_clkdev(clk, "pll_re_vco", NULL);
  1140. clks[TEGRA124_CLK_PLL_RE_VCO] = clk;
  1141. clk = clk_register_divider_table(NULL, "pll_re_out", "pll_re_vco", 0,
  1142. clk_base + PLLRE_BASE, 16, 4, 0,
  1143. pll_re_div_table, &pll_re_lock);
  1144. clk_register_clkdev(clk, "pll_re_out", NULL);
  1145. clks[TEGRA124_CLK_PLL_RE_OUT] = clk;
  1146. /* PLLE */
  1147. clk = tegra_clk_register_plle_tegra114("pll_e", "pll_ref",
  1148. clk_base, 0, &pll_e_params, NULL);
  1149. clk_register_clkdev(clk, "pll_e", NULL);
  1150. clks[TEGRA124_CLK_PLL_E] = clk;
  1151. /* PLLC4 */
  1152. clk = tegra_clk_register_pllss("pll_c4", "pll_ref", clk_base, 0,
  1153. &pll_c4_params, NULL);
  1154. clk_register_clkdev(clk, "pll_c4", NULL);
  1155. clks[TEGRA124_CLK_PLL_C4] = clk;
  1156. /* PLLDP */
  1157. clk = tegra_clk_register_pllss("pll_dp", "pll_ref", clk_base, 0,
  1158. &pll_dp_params, NULL);
  1159. clk_register_clkdev(clk, "pll_dp", NULL);
  1160. clks[TEGRA124_CLK_PLL_DP] = clk;
  1161. /* PLLD2 */
  1162. clk = tegra_clk_register_pllss("pll_d2", "pll_ref", clk_base, 0,
  1163. &tegra124_pll_d2_params, NULL);
  1164. clk_register_clkdev(clk, "pll_d2", NULL);
  1165. clks[TEGRA124_CLK_PLL_D2] = clk;
  1166. /* PLLD2_OUT0 */
  1167. clk = clk_register_fixed_factor(NULL, "pll_d2_out0", "pll_d2",
  1168. CLK_SET_RATE_PARENT, 1, 1);
  1169. clk_register_clkdev(clk, "pll_d2_out0", NULL);
  1170. clks[TEGRA124_CLK_PLL_D2_OUT0] = clk;
  1171. }
  1172. /* Tegra124 CPU clock and reset control functions */
  1173. static void tegra124_wait_cpu_in_reset(u32 cpu)
  1174. {
  1175. unsigned int reg;
  1176. do {
  1177. reg = readl(clk_base + CLK_RST_CONTROLLER_CPU_CMPLX_STATUS);
  1178. cpu_relax();
  1179. } while (!(reg & (1 << cpu))); /* check CPU been reset or not */
  1180. }
  1181. static void tegra124_disable_cpu_clock(u32 cpu)
  1182. {
  1183. /* flow controller would take care in the power sequence. */
  1184. }
  1185. #ifdef CONFIG_PM_SLEEP
  1186. static void tegra124_cpu_clock_suspend(void)
  1187. {
  1188. /* switch coresite to clk_m, save off original source */
  1189. tegra124_cpu_clk_sctx.clk_csite_src =
  1190. readl(clk_base + CLK_SOURCE_CSITE);
  1191. writel(3 << 30, clk_base + CLK_SOURCE_CSITE);
  1192. }
  1193. static void tegra124_cpu_clock_resume(void)
  1194. {
  1195. writel(tegra124_cpu_clk_sctx.clk_csite_src,
  1196. clk_base + CLK_SOURCE_CSITE);
  1197. }
  1198. #endif
  1199. static struct tegra_cpu_car_ops tegra124_cpu_car_ops = {
  1200. .wait_for_reset = tegra124_wait_cpu_in_reset,
  1201. .disable_clock = tegra124_disable_cpu_clock,
  1202. #ifdef CONFIG_PM_SLEEP
  1203. .suspend = tegra124_cpu_clock_suspend,
  1204. .resume = tegra124_cpu_clock_resume,
  1205. #endif
  1206. };
  1207. static const struct of_device_id pmc_match[] __initconst = {
  1208. { .compatible = "nvidia,tegra124-pmc" },
  1209. {},
  1210. };
  1211. static struct tegra_clk_init_table init_table[] __initdata = {
  1212. {TEGRA124_CLK_UARTA, TEGRA124_CLK_PLL_P, 408000000, 0},
  1213. {TEGRA124_CLK_UARTB, TEGRA124_CLK_PLL_P, 408000000, 0},
  1214. {TEGRA124_CLK_UARTC, TEGRA124_CLK_PLL_P, 408000000, 0},
  1215. {TEGRA124_CLK_UARTD, TEGRA124_CLK_PLL_P, 408000000, 0},
  1216. {TEGRA124_CLK_PLL_A, TEGRA124_CLK_CLK_MAX, 564480000, 1},
  1217. {TEGRA124_CLK_PLL_A_OUT0, TEGRA124_CLK_CLK_MAX, 11289600, 1},
  1218. {TEGRA124_CLK_EXTERN1, TEGRA124_CLK_PLL_A_OUT0, 0, 1},
  1219. {TEGRA124_CLK_CLK_OUT_1_MUX, TEGRA124_CLK_EXTERN1, 0, 1},
  1220. {TEGRA124_CLK_CLK_OUT_1, TEGRA124_CLK_CLK_MAX, 0, 1},
  1221. {TEGRA124_CLK_I2S0, TEGRA124_CLK_PLL_A_OUT0, 11289600, 0},
  1222. {TEGRA124_CLK_I2S1, TEGRA124_CLK_PLL_A_OUT0, 11289600, 0},
  1223. {TEGRA124_CLK_I2S2, TEGRA124_CLK_PLL_A_OUT0, 11289600, 0},
  1224. {TEGRA124_CLK_I2S3, TEGRA124_CLK_PLL_A_OUT0, 11289600, 0},
  1225. {TEGRA124_CLK_I2S4, TEGRA124_CLK_PLL_A_OUT0, 11289600, 0},
  1226. {TEGRA124_CLK_VDE, TEGRA124_CLK_PLL_P, 0, 0},
  1227. {TEGRA124_CLK_HOST1X, TEGRA124_CLK_PLL_P, 136000000, 1},
  1228. {TEGRA124_CLK_SCLK, TEGRA124_CLK_PLL_P_OUT2, 102000000, 1},
  1229. {TEGRA124_CLK_DFLL_SOC, TEGRA124_CLK_PLL_P, 51000000, 1},
  1230. {TEGRA124_CLK_DFLL_REF, TEGRA124_CLK_PLL_P, 51000000, 1},
  1231. {TEGRA124_CLK_PLL_C, TEGRA124_CLK_CLK_MAX, 768000000, 0},
  1232. {TEGRA124_CLK_PLL_C_OUT1, TEGRA124_CLK_CLK_MAX, 100000000, 0},
  1233. {TEGRA124_CLK_SBC4, TEGRA124_CLK_PLL_P, 12000000, 1},
  1234. {TEGRA124_CLK_TSEC, TEGRA124_CLK_PLL_C3, 0, 0},
  1235. {TEGRA124_CLK_MSENC, TEGRA124_CLK_PLL_C3, 0, 0},
  1236. {TEGRA124_CLK_PLL_RE_VCO, TEGRA124_CLK_CLK_MAX, 672000000, 0},
  1237. {TEGRA124_CLK_XUSB_SS_SRC, TEGRA124_CLK_PLL_U_480M, 120000000, 0},
  1238. {TEGRA124_CLK_XUSB_FS_SRC, TEGRA124_CLK_PLL_U_48M, 48000000, 0},
  1239. {TEGRA124_CLK_XUSB_HS_SRC, TEGRA124_CLK_PLL_U_60M, 60000000, 0},
  1240. {TEGRA124_CLK_XUSB_FALCON_SRC, TEGRA124_CLK_PLL_RE_OUT, 224000000, 0},
  1241. {TEGRA124_CLK_XUSB_HOST_SRC, TEGRA124_CLK_PLL_RE_OUT, 112000000, 0},
  1242. /* This MUST be the last entry. */
  1243. {TEGRA124_CLK_CLK_MAX, TEGRA124_CLK_CLK_MAX, 0, 0},
  1244. };
  1245. static void __init tegra124_clock_apply_init_table(void)
  1246. {
  1247. tegra_init_from_table(init_table, clks, TEGRA124_CLK_CLK_MAX);
  1248. }
  1249. static void __init tegra124_clock_init(struct device_node *np)
  1250. {
  1251. struct device_node *node;
  1252. clk_base = of_iomap(np, 0);
  1253. if (!clk_base) {
  1254. pr_err("ioremap tegra124 CAR failed\n");
  1255. return;
  1256. }
  1257. node = of_find_matching_node(NULL, pmc_match);
  1258. if (!node) {
  1259. pr_err("Failed to find pmc node\n");
  1260. WARN_ON(1);
  1261. return;
  1262. }
  1263. pmc_base = of_iomap(node, 0);
  1264. if (!pmc_base) {
  1265. pr_err("Can't map pmc registers\n");
  1266. WARN_ON(1);
  1267. return;
  1268. }
  1269. clks = tegra_clk_init(clk_base, TEGRA124_CLK_CLK_MAX, 6);
  1270. if (!clks)
  1271. return;
  1272. if (tegra_osc_clk_init(clk_base, tegra124_clks, tegra124_input_freq,
  1273. ARRAY_SIZE(tegra124_input_freq), &osc_freq, &pll_ref_freq) < 0)
  1274. return;
  1275. tegra_fixed_clk_init(tegra124_clks);
  1276. tegra124_pll_init(clk_base, pmc_base);
  1277. tegra124_periph_clk_init(clk_base, pmc_base);
  1278. tegra_audio_clk_init(clk_base, pmc_base, tegra124_clks, &pll_a_params);
  1279. tegra_pmc_clk_init(pmc_base, tegra124_clks);
  1280. tegra_super_clk_gen4_init(clk_base, pmc_base, tegra124_clks,
  1281. &pll_x_params);
  1282. tegra_add_of_provider(np);
  1283. tegra_register_devclks(devclks, ARRAY_SIZE(devclks));
  1284. tegra_clk_apply_init_table = tegra124_clock_apply_init_table;
  1285. tegra_cpu_car_ops = &tegra124_cpu_car_ops;
  1286. }
  1287. CLK_OF_DECLARE(tegra124, "nvidia,tegra124-car", tegra124_clock_init);