clk-tegra124.c 59 KB

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