x86/xen: resume timer irqs early
[linux/fpc-iii.git] / drivers / clk / tegra / clk-tegra114.c
blob406929d4ce2f207e577f5304ae37a05a83d41589
1 /*
2 * Copyright (c) 2012, 2013, NVIDIA CORPORATION. All rights reserved.
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.
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.
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/>.
17 #include <linux/io.h>
18 #include <linux/clk.h>
19 #include <linux/clk-provider.h>
20 #include <linux/clkdev.h>
21 #include <linux/of.h>
22 #include <linux/of_address.h>
23 #include <linux/delay.h>
24 #include <linux/export.h>
25 #include <linux/clk/tegra.h>
27 #include "clk.h"
29 #define RST_DEVICES_L 0x004
30 #define RST_DEVICES_H 0x008
31 #define RST_DEVICES_U 0x00C
32 #define RST_DFLL_DVCO 0x2F4
33 #define RST_DEVICES_V 0x358
34 #define RST_DEVICES_W 0x35C
35 #define RST_DEVICES_X 0x28C
36 #define RST_DEVICES_SET_L 0x300
37 #define RST_DEVICES_CLR_L 0x304
38 #define RST_DEVICES_SET_H 0x308
39 #define RST_DEVICES_CLR_H 0x30c
40 #define RST_DEVICES_SET_U 0x310
41 #define RST_DEVICES_CLR_U 0x314
42 #define RST_DEVICES_SET_V 0x430
43 #define RST_DEVICES_CLR_V 0x434
44 #define RST_DEVICES_SET_W 0x438
45 #define RST_DEVICES_CLR_W 0x43c
46 #define CPU_FINETRIM_SELECT 0x4d4 /* override default prop dlys */
47 #define CPU_FINETRIM_DR 0x4d8 /* rise->rise prop dly A */
48 #define CPU_FINETRIM_R 0x4e4 /* rise->rise prop dly inc A */
49 #define RST_DEVICES_NUM 5
51 /* RST_DFLL_DVCO bitfields */
52 #define DVFS_DFLL_RESET_SHIFT 0
54 /* CPU_FINETRIM_SELECT and CPU_FINETRIM_DR bitfields */
55 #define CPU_FINETRIM_1_FCPU_1 BIT(0) /* fcpu0 */
56 #define CPU_FINETRIM_1_FCPU_2 BIT(1) /* fcpu1 */
57 #define CPU_FINETRIM_1_FCPU_3 BIT(2) /* fcpu2 */
58 #define CPU_FINETRIM_1_FCPU_4 BIT(3) /* fcpu3 */
59 #define CPU_FINETRIM_1_FCPU_5 BIT(4) /* fl2 */
60 #define CPU_FINETRIM_1_FCPU_6 BIT(5) /* ftop */
62 /* CPU_FINETRIM_R bitfields */
63 #define CPU_FINETRIM_R_FCPU_1_SHIFT 0 /* fcpu0 */
64 #define CPU_FINETRIM_R_FCPU_1_MASK (0x3 << CPU_FINETRIM_R_FCPU_1_SHIFT)
65 #define CPU_FINETRIM_R_FCPU_2_SHIFT 2 /* fcpu1 */
66 #define CPU_FINETRIM_R_FCPU_2_MASK (0x3 << CPU_FINETRIM_R_FCPU_2_SHIFT)
67 #define CPU_FINETRIM_R_FCPU_3_SHIFT 4 /* fcpu2 */
68 #define CPU_FINETRIM_R_FCPU_3_MASK (0x3 << CPU_FINETRIM_R_FCPU_3_SHIFT)
69 #define CPU_FINETRIM_R_FCPU_4_SHIFT 6 /* fcpu3 */
70 #define CPU_FINETRIM_R_FCPU_4_MASK (0x3 << CPU_FINETRIM_R_FCPU_4_SHIFT)
71 #define CPU_FINETRIM_R_FCPU_5_SHIFT 8 /* fl2 */
72 #define CPU_FINETRIM_R_FCPU_5_MASK (0x3 << CPU_FINETRIM_R_FCPU_5_SHIFT)
73 #define CPU_FINETRIM_R_FCPU_6_SHIFT 10 /* ftop */
74 #define CPU_FINETRIM_R_FCPU_6_MASK (0x3 << CPU_FINETRIM_R_FCPU_6_SHIFT)
76 #define CLK_OUT_ENB_L 0x010
77 #define CLK_OUT_ENB_H 0x014
78 #define CLK_OUT_ENB_U 0x018
79 #define CLK_OUT_ENB_V 0x360
80 #define CLK_OUT_ENB_W 0x364
81 #define CLK_OUT_ENB_X 0x280
82 #define CLK_OUT_ENB_SET_L 0x320
83 #define CLK_OUT_ENB_CLR_L 0x324
84 #define CLK_OUT_ENB_SET_H 0x328
85 #define CLK_OUT_ENB_CLR_H 0x32c
86 #define CLK_OUT_ENB_SET_U 0x330
87 #define CLK_OUT_ENB_CLR_U 0x334
88 #define CLK_OUT_ENB_SET_V 0x440
89 #define CLK_OUT_ENB_CLR_V 0x444
90 #define CLK_OUT_ENB_SET_W 0x448
91 #define CLK_OUT_ENB_CLR_W 0x44c
92 #define CLK_OUT_ENB_SET_X 0x284
93 #define CLK_OUT_ENB_CLR_X 0x288
94 #define CLK_OUT_ENB_NUM 6
96 #define PLLC_BASE 0x80
97 #define PLLC_MISC2 0x88
98 #define PLLC_MISC 0x8c
99 #define PLLC2_BASE 0x4e8
100 #define PLLC2_MISC 0x4ec
101 #define PLLC3_BASE 0x4fc
102 #define PLLC3_MISC 0x500
103 #define PLLM_BASE 0x90
104 #define PLLM_MISC 0x9c
105 #define PLLP_BASE 0xa0
106 #define PLLP_MISC 0xac
107 #define PLLX_BASE 0xe0
108 #define PLLX_MISC 0xe4
109 #define PLLX_MISC2 0x514
110 #define PLLX_MISC3 0x518
111 #define PLLD_BASE 0xd0
112 #define PLLD_MISC 0xdc
113 #define PLLD2_BASE 0x4b8
114 #define PLLD2_MISC 0x4bc
115 #define PLLE_BASE 0xe8
116 #define PLLE_MISC 0xec
117 #define PLLA_BASE 0xb0
118 #define PLLA_MISC 0xbc
119 #define PLLU_BASE 0xc0
120 #define PLLU_MISC 0xcc
121 #define PLLRE_BASE 0x4c4
122 #define PLLRE_MISC 0x4c8
124 #define PLL_MISC_LOCK_ENABLE 18
125 #define PLLC_MISC_LOCK_ENABLE 24
126 #define PLLDU_MISC_LOCK_ENABLE 22
127 #define PLLE_MISC_LOCK_ENABLE 9
128 #define PLLRE_MISC_LOCK_ENABLE 30
130 #define PLLC_IDDQ_BIT 26
131 #define PLLX_IDDQ_BIT 3
132 #define PLLRE_IDDQ_BIT 16
134 #define PLL_BASE_LOCK BIT(27)
135 #define PLLE_MISC_LOCK BIT(11)
136 #define PLLRE_MISC_LOCK BIT(24)
137 #define PLLCX_BASE_LOCK (BIT(26)|BIT(27))
139 #define PLLE_AUX 0x48c
140 #define PLLC_OUT 0x84
141 #define PLLM_OUT 0x94
142 #define PLLP_OUTA 0xa4
143 #define PLLP_OUTB 0xa8
144 #define PLLA_OUT 0xb4
146 #define AUDIO_SYNC_CLK_I2S0 0x4a0
147 #define AUDIO_SYNC_CLK_I2S1 0x4a4
148 #define AUDIO_SYNC_CLK_I2S2 0x4a8
149 #define AUDIO_SYNC_CLK_I2S3 0x4ac
150 #define AUDIO_SYNC_CLK_I2S4 0x4b0
151 #define AUDIO_SYNC_CLK_SPDIF 0x4b4
153 #define AUDIO_SYNC_DOUBLER 0x49c
155 #define PMC_CLK_OUT_CNTRL 0x1a8
156 #define PMC_DPD_PADS_ORIDE 0x1c
157 #define PMC_DPD_PADS_ORIDE_BLINK_ENB 20
158 #define PMC_CTRL 0
159 #define PMC_CTRL_BLINK_ENB 7
160 #define PMC_BLINK_TIMER 0x40
162 #define OSC_CTRL 0x50
163 #define OSC_CTRL_OSC_FREQ_SHIFT 28
164 #define OSC_CTRL_PLL_REF_DIV_SHIFT 26
166 #define PLLXC_SW_MAX_P 6
168 #define CCLKG_BURST_POLICY 0x368
169 #define CCLKLP_BURST_POLICY 0x370
170 #define SCLK_BURST_POLICY 0x028
171 #define SYSTEM_CLK_RATE 0x030
173 #define UTMIP_PLL_CFG2 0x488
174 #define UTMIP_PLL_CFG2_STABLE_COUNT(x) (((x) & 0xffff) << 6)
175 #define UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT(x) (((x) & 0x3f) << 18)
176 #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_A_POWERDOWN BIT(0)
177 #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_B_POWERDOWN BIT(2)
178 #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_C_POWERDOWN BIT(4)
180 #define UTMIP_PLL_CFG1 0x484
181 #define UTMIP_PLL_CFG1_ENABLE_DLY_COUNT(x) (((x) & 0x1f) << 6)
182 #define UTMIP_PLL_CFG1_XTAL_FREQ_COUNT(x) (((x) & 0xfff) << 0)
183 #define UTMIP_PLL_CFG1_FORCE_PLLU_POWERUP BIT(17)
184 #define UTMIP_PLL_CFG1_FORCE_PLLU_POWERDOWN BIT(16)
185 #define UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERUP BIT(15)
186 #define UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERDOWN BIT(14)
187 #define UTMIP_PLL_CFG1_FORCE_PLL_ACTIVE_POWERDOWN BIT(12)
189 #define UTMIPLL_HW_PWRDN_CFG0 0x52c
190 #define UTMIPLL_HW_PWRDN_CFG0_SEQ_START_STATE BIT(25)
191 #define UTMIPLL_HW_PWRDN_CFG0_SEQ_ENABLE BIT(24)
192 #define UTMIPLL_HW_PWRDN_CFG0_USE_LOCKDET BIT(6)
193 #define UTMIPLL_HW_PWRDN_CFG0_SEQ_RESET_INPUT_VALUE BIT(5)
194 #define UTMIPLL_HW_PWRDN_CFG0_SEQ_IN_SWCTL BIT(4)
195 #define UTMIPLL_HW_PWRDN_CFG0_CLK_ENABLE_SWCTL BIT(2)
196 #define UTMIPLL_HW_PWRDN_CFG0_IDDQ_OVERRIDE BIT(1)
197 #define UTMIPLL_HW_PWRDN_CFG0_IDDQ_SWCTL BIT(0)
199 #define CLK_SOURCE_I2S0 0x1d8
200 #define CLK_SOURCE_I2S1 0x100
201 #define CLK_SOURCE_I2S2 0x104
202 #define CLK_SOURCE_NDFLASH 0x160
203 #define CLK_SOURCE_I2S3 0x3bc
204 #define CLK_SOURCE_I2S4 0x3c0
205 #define CLK_SOURCE_SPDIF_OUT 0x108
206 #define CLK_SOURCE_SPDIF_IN 0x10c
207 #define CLK_SOURCE_PWM 0x110
208 #define CLK_SOURCE_ADX 0x638
209 #define CLK_SOURCE_AMX 0x63c
210 #define CLK_SOURCE_HDA 0x428
211 #define CLK_SOURCE_HDA2CODEC_2X 0x3e4
212 #define CLK_SOURCE_SBC1 0x134
213 #define CLK_SOURCE_SBC2 0x118
214 #define CLK_SOURCE_SBC3 0x11c
215 #define CLK_SOURCE_SBC4 0x1b4
216 #define CLK_SOURCE_SBC5 0x3c8
217 #define CLK_SOURCE_SBC6 0x3cc
218 #define CLK_SOURCE_SATA_OOB 0x420
219 #define CLK_SOURCE_SATA 0x424
220 #define CLK_SOURCE_NDSPEED 0x3f8
221 #define CLK_SOURCE_VFIR 0x168
222 #define CLK_SOURCE_SDMMC1 0x150
223 #define CLK_SOURCE_SDMMC2 0x154
224 #define CLK_SOURCE_SDMMC3 0x1bc
225 #define CLK_SOURCE_SDMMC4 0x164
226 #define CLK_SOURCE_VDE 0x1c8
227 #define CLK_SOURCE_CSITE 0x1d4
228 #define CLK_SOURCE_LA 0x1f8
229 #define CLK_SOURCE_TRACE 0x634
230 #define CLK_SOURCE_OWR 0x1cc
231 #define CLK_SOURCE_NOR 0x1d0
232 #define CLK_SOURCE_MIPI 0x174
233 #define CLK_SOURCE_I2C1 0x124
234 #define CLK_SOURCE_I2C2 0x198
235 #define CLK_SOURCE_I2C3 0x1b8
236 #define CLK_SOURCE_I2C4 0x3c4
237 #define CLK_SOURCE_I2C5 0x128
238 #define CLK_SOURCE_UARTA 0x178
239 #define CLK_SOURCE_UARTB 0x17c
240 #define CLK_SOURCE_UARTC 0x1a0
241 #define CLK_SOURCE_UARTD 0x1c0
242 #define CLK_SOURCE_UARTE 0x1c4
243 #define CLK_SOURCE_UARTA_DBG 0x178
244 #define CLK_SOURCE_UARTB_DBG 0x17c
245 #define CLK_SOURCE_UARTC_DBG 0x1a0
246 #define CLK_SOURCE_UARTD_DBG 0x1c0
247 #define CLK_SOURCE_UARTE_DBG 0x1c4
248 #define CLK_SOURCE_3D 0x158
249 #define CLK_SOURCE_2D 0x15c
250 #define CLK_SOURCE_VI_SENSOR 0x1a8
251 #define CLK_SOURCE_VI 0x148
252 #define CLK_SOURCE_EPP 0x16c
253 #define CLK_SOURCE_MSENC 0x1f0
254 #define CLK_SOURCE_TSEC 0x1f4
255 #define CLK_SOURCE_HOST1X 0x180
256 #define CLK_SOURCE_HDMI 0x18c
257 #define CLK_SOURCE_DISP1 0x138
258 #define CLK_SOURCE_DISP2 0x13c
259 #define CLK_SOURCE_CILAB 0x614
260 #define CLK_SOURCE_CILCD 0x618
261 #define CLK_SOURCE_CILE 0x61c
262 #define CLK_SOURCE_DSIALP 0x620
263 #define CLK_SOURCE_DSIBLP 0x624
264 #define CLK_SOURCE_TSENSOR 0x3b8
265 #define CLK_SOURCE_D_AUDIO 0x3d0
266 #define CLK_SOURCE_DAM0 0x3d8
267 #define CLK_SOURCE_DAM1 0x3dc
268 #define CLK_SOURCE_DAM2 0x3e0
269 #define CLK_SOURCE_ACTMON 0x3e8
270 #define CLK_SOURCE_EXTERN1 0x3ec
271 #define CLK_SOURCE_EXTERN2 0x3f0
272 #define CLK_SOURCE_EXTERN3 0x3f4
273 #define CLK_SOURCE_I2CSLOW 0x3fc
274 #define CLK_SOURCE_SE 0x42c
275 #define CLK_SOURCE_MSELECT 0x3b4
276 #define CLK_SOURCE_DFLL_REF 0x62c
277 #define CLK_SOURCE_DFLL_SOC 0x630
278 #define CLK_SOURCE_SOC_THERM 0x644
279 #define CLK_SOURCE_XUSB_HOST_SRC 0x600
280 #define CLK_SOURCE_XUSB_FALCON_SRC 0x604
281 #define CLK_SOURCE_XUSB_FS_SRC 0x608
282 #define CLK_SOURCE_XUSB_SS_SRC 0x610
283 #define CLK_SOURCE_XUSB_DEV_SRC 0x60c
284 #define CLK_SOURCE_EMC 0x19c
286 /* PLLM override registers */
287 #define PMC_PLLM_WB0_OVERRIDE 0x1dc
288 #define PMC_PLLM_WB0_OVERRIDE_2 0x2b0
290 /* Tegra CPU clock and reset control regs */
291 #define CLK_RST_CONTROLLER_CPU_CMPLX_STATUS 0x470
293 #ifdef CONFIG_PM_SLEEP
294 static struct cpu_clk_suspend_context {
295 u32 clk_csite_src;
296 u32 cclkg_burst;
297 u32 cclkg_divider;
298 } tegra114_cpu_clk_sctx;
299 #endif
301 static int periph_clk_enb_refcnt[CLK_OUT_ENB_NUM * 32];
303 static void __iomem *clk_base;
304 static void __iomem *pmc_base;
306 static DEFINE_SPINLOCK(pll_d_lock);
307 static DEFINE_SPINLOCK(pll_d2_lock);
308 static DEFINE_SPINLOCK(pll_u_lock);
309 static DEFINE_SPINLOCK(pll_div_lock);
310 static DEFINE_SPINLOCK(pll_re_lock);
311 static DEFINE_SPINLOCK(clk_doubler_lock);
312 static DEFINE_SPINLOCK(clk_out_lock);
313 static DEFINE_SPINLOCK(sysrate_lock);
315 static struct div_nmp pllxc_nmp = {
316 .divm_shift = 0,
317 .divm_width = 8,
318 .divn_shift = 8,
319 .divn_width = 8,
320 .divp_shift = 20,
321 .divp_width = 4,
324 static struct pdiv_map pllxc_p[] = {
325 { .pdiv = 1, .hw_val = 0 },
326 { .pdiv = 2, .hw_val = 1 },
327 { .pdiv = 3, .hw_val = 2 },
328 { .pdiv = 4, .hw_val = 3 },
329 { .pdiv = 5, .hw_val = 4 },
330 { .pdiv = 6, .hw_val = 5 },
331 { .pdiv = 8, .hw_val = 6 },
332 { .pdiv = 10, .hw_val = 7 },
333 { .pdiv = 12, .hw_val = 8 },
334 { .pdiv = 16, .hw_val = 9 },
335 { .pdiv = 12, .hw_val = 10 },
336 { .pdiv = 16, .hw_val = 11 },
337 { .pdiv = 20, .hw_val = 12 },
338 { .pdiv = 24, .hw_val = 13 },
339 { .pdiv = 32, .hw_val = 14 },
340 { .pdiv = 0, .hw_val = 0 },
343 static struct tegra_clk_pll_freq_table pll_c_freq_table[] = {
344 { 12000000, 624000000, 104, 0, 2},
345 { 12000000, 600000000, 100, 0, 2},
346 { 13000000, 600000000, 92, 0, 2}, /* actual: 598.0 MHz */
347 { 16800000, 600000000, 71, 0, 2}, /* actual: 596.4 MHz */
348 { 19200000, 600000000, 62, 0, 2}, /* actual: 595.2 MHz */
349 { 26000000, 600000000, 92, 1, 2}, /* actual: 598.0 MHz */
350 { 0, 0, 0, 0, 0, 0 },
353 static struct tegra_clk_pll_params pll_c_params = {
354 .input_min = 12000000,
355 .input_max = 800000000,
356 .cf_min = 12000000,
357 .cf_max = 19200000, /* s/w policy, h/w capability 50 MHz */
358 .vco_min = 600000000,
359 .vco_max = 1400000000,
360 .base_reg = PLLC_BASE,
361 .misc_reg = PLLC_MISC,
362 .lock_mask = PLL_BASE_LOCK,
363 .lock_enable_bit_idx = PLLC_MISC_LOCK_ENABLE,
364 .lock_delay = 300,
365 .iddq_reg = PLLC_MISC,
366 .iddq_bit_idx = PLLC_IDDQ_BIT,
367 .max_p = PLLXC_SW_MAX_P,
368 .dyn_ramp_reg = PLLC_MISC2,
369 .stepa_shift = 17,
370 .stepb_shift = 9,
371 .pdiv_tohw = pllxc_p,
372 .div_nmp = &pllxc_nmp,
375 static struct div_nmp pllcx_nmp = {
376 .divm_shift = 0,
377 .divm_width = 2,
378 .divn_shift = 8,
379 .divn_width = 8,
380 .divp_shift = 20,
381 .divp_width = 3,
384 static struct pdiv_map pllc_p[] = {
385 { .pdiv = 1, .hw_val = 0 },
386 { .pdiv = 2, .hw_val = 1 },
387 { .pdiv = 4, .hw_val = 3 },
388 { .pdiv = 8, .hw_val = 5 },
389 { .pdiv = 16, .hw_val = 7 },
390 { .pdiv = 0, .hw_val = 0 },
393 static struct tegra_clk_pll_freq_table pll_cx_freq_table[] = {
394 {12000000, 600000000, 100, 0, 2},
395 {13000000, 600000000, 92, 0, 2}, /* actual: 598.0 MHz */
396 {16800000, 600000000, 71, 0, 2}, /* actual: 596.4 MHz */
397 {19200000, 600000000, 62, 0, 2}, /* actual: 595.2 MHz */
398 {26000000, 600000000, 92, 1, 2}, /* actual: 598.0 MHz */
399 {0, 0, 0, 0, 0, 0},
402 static struct tegra_clk_pll_params pll_c2_params = {
403 .input_min = 12000000,
404 .input_max = 48000000,
405 .cf_min = 12000000,
406 .cf_max = 19200000,
407 .vco_min = 600000000,
408 .vco_max = 1200000000,
409 .base_reg = PLLC2_BASE,
410 .misc_reg = PLLC2_MISC,
411 .lock_mask = PLL_BASE_LOCK,
412 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
413 .lock_delay = 300,
414 .pdiv_tohw = pllc_p,
415 .div_nmp = &pllcx_nmp,
416 .max_p = 7,
417 .ext_misc_reg[0] = 0x4f0,
418 .ext_misc_reg[1] = 0x4f4,
419 .ext_misc_reg[2] = 0x4f8,
422 static struct tegra_clk_pll_params pll_c3_params = {
423 .input_min = 12000000,
424 .input_max = 48000000,
425 .cf_min = 12000000,
426 .cf_max = 19200000,
427 .vco_min = 600000000,
428 .vco_max = 1200000000,
429 .base_reg = PLLC3_BASE,
430 .misc_reg = PLLC3_MISC,
431 .lock_mask = PLL_BASE_LOCK,
432 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
433 .lock_delay = 300,
434 .pdiv_tohw = pllc_p,
435 .div_nmp = &pllcx_nmp,
436 .max_p = 7,
437 .ext_misc_reg[0] = 0x504,
438 .ext_misc_reg[1] = 0x508,
439 .ext_misc_reg[2] = 0x50c,
442 static struct div_nmp pllm_nmp = {
443 .divm_shift = 0,
444 .divm_width = 8,
445 .override_divm_shift = 0,
446 .divn_shift = 8,
447 .divn_width = 8,
448 .override_divn_shift = 8,
449 .divp_shift = 20,
450 .divp_width = 1,
451 .override_divp_shift = 27,
454 static struct pdiv_map pllm_p[] = {
455 { .pdiv = 1, .hw_val = 0 },
456 { .pdiv = 2, .hw_val = 1 },
457 { .pdiv = 0, .hw_val = 0 },
460 static struct tegra_clk_pll_freq_table pll_m_freq_table[] = {
461 {12000000, 800000000, 66, 0, 1}, /* actual: 792.0 MHz */
462 {13000000, 800000000, 61, 0, 1}, /* actual: 793.0 MHz */
463 {16800000, 800000000, 47, 0, 1}, /* actual: 789.6 MHz */
464 {19200000, 800000000, 41, 0, 1}, /* actual: 787.2 MHz */
465 {26000000, 800000000, 61, 1, 1}, /* actual: 793.0 MHz */
466 {0, 0, 0, 0, 0, 0},
469 static struct tegra_clk_pll_params pll_m_params = {
470 .input_min = 12000000,
471 .input_max = 500000000,
472 .cf_min = 12000000,
473 .cf_max = 19200000, /* s/w policy, h/w capability 50 MHz */
474 .vco_min = 400000000,
475 .vco_max = 1066000000,
476 .base_reg = PLLM_BASE,
477 .misc_reg = PLLM_MISC,
478 .lock_mask = PLL_BASE_LOCK,
479 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
480 .lock_delay = 300,
481 .max_p = 2,
482 .pdiv_tohw = pllm_p,
483 .div_nmp = &pllm_nmp,
484 .pmc_divnm_reg = PMC_PLLM_WB0_OVERRIDE,
485 .pmc_divp_reg = PMC_PLLM_WB0_OVERRIDE_2,
488 static struct div_nmp pllp_nmp = {
489 .divm_shift = 0,
490 .divm_width = 5,
491 .divn_shift = 8,
492 .divn_width = 10,
493 .divp_shift = 20,
494 .divp_width = 3,
497 static struct tegra_clk_pll_freq_table pll_p_freq_table[] = {
498 {12000000, 216000000, 432, 12, 1, 8},
499 {13000000, 216000000, 432, 13, 1, 8},
500 {16800000, 216000000, 360, 14, 1, 8},
501 {19200000, 216000000, 360, 16, 1, 8},
502 {26000000, 216000000, 432, 26, 1, 8},
503 {0, 0, 0, 0, 0, 0},
506 static struct tegra_clk_pll_params pll_p_params = {
507 .input_min = 2000000,
508 .input_max = 31000000,
509 .cf_min = 1000000,
510 .cf_max = 6000000,
511 .vco_min = 200000000,
512 .vco_max = 700000000,
513 .base_reg = PLLP_BASE,
514 .misc_reg = PLLP_MISC,
515 .lock_mask = PLL_BASE_LOCK,
516 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
517 .lock_delay = 300,
518 .div_nmp = &pllp_nmp,
521 static struct tegra_clk_pll_freq_table pll_a_freq_table[] = {
522 {9600000, 282240000, 147, 5, 0, 4},
523 {9600000, 368640000, 192, 5, 0, 4},
524 {9600000, 240000000, 200, 8, 0, 8},
526 {28800000, 282240000, 245, 25, 0, 8},
527 {28800000, 368640000, 320, 25, 0, 8},
528 {28800000, 240000000, 200, 24, 0, 8},
529 {0, 0, 0, 0, 0, 0},
533 static struct tegra_clk_pll_params pll_a_params = {
534 .input_min = 2000000,
535 .input_max = 31000000,
536 .cf_min = 1000000,
537 .cf_max = 6000000,
538 .vco_min = 200000000,
539 .vco_max = 700000000,
540 .base_reg = PLLA_BASE,
541 .misc_reg = PLLA_MISC,
542 .lock_mask = PLL_BASE_LOCK,
543 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
544 .lock_delay = 300,
545 .div_nmp = &pllp_nmp,
548 static struct tegra_clk_pll_freq_table pll_d_freq_table[] = {
549 {12000000, 216000000, 864, 12, 2, 12},
550 {13000000, 216000000, 864, 13, 2, 12},
551 {16800000, 216000000, 720, 14, 2, 12},
552 {19200000, 216000000, 720, 16, 2, 12},
553 {26000000, 216000000, 864, 26, 2, 12},
555 {12000000, 594000000, 594, 12, 0, 12},
556 {13000000, 594000000, 594, 13, 0, 12},
557 {16800000, 594000000, 495, 14, 0, 12},
558 {19200000, 594000000, 495, 16, 0, 12},
559 {26000000, 594000000, 594, 26, 0, 12},
561 {12000000, 1000000000, 1000, 12, 0, 12},
562 {13000000, 1000000000, 1000, 13, 0, 12},
563 {19200000, 1000000000, 625, 12, 0, 12},
564 {26000000, 1000000000, 1000, 26, 0, 12},
566 {0, 0, 0, 0, 0, 0},
569 static struct tegra_clk_pll_params pll_d_params = {
570 .input_min = 2000000,
571 .input_max = 40000000,
572 .cf_min = 1000000,
573 .cf_max = 6000000,
574 .vco_min = 500000000,
575 .vco_max = 1000000000,
576 .base_reg = PLLD_BASE,
577 .misc_reg = PLLD_MISC,
578 .lock_mask = PLL_BASE_LOCK,
579 .lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE,
580 .lock_delay = 1000,
581 .div_nmp = &pllp_nmp,
584 static struct tegra_clk_pll_params pll_d2_params = {
585 .input_min = 2000000,
586 .input_max = 40000000,
587 .cf_min = 1000000,
588 .cf_max = 6000000,
589 .vco_min = 500000000,
590 .vco_max = 1000000000,
591 .base_reg = PLLD2_BASE,
592 .misc_reg = PLLD2_MISC,
593 .lock_mask = PLL_BASE_LOCK,
594 .lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE,
595 .lock_delay = 1000,
596 .div_nmp = &pllp_nmp,
599 static struct pdiv_map pllu_p[] = {
600 { .pdiv = 1, .hw_val = 1 },
601 { .pdiv = 2, .hw_val = 0 },
602 { .pdiv = 0, .hw_val = 0 },
605 static struct div_nmp pllu_nmp = {
606 .divm_shift = 0,
607 .divm_width = 5,
608 .divn_shift = 8,
609 .divn_width = 10,
610 .divp_shift = 20,
611 .divp_width = 1,
614 static struct tegra_clk_pll_freq_table pll_u_freq_table[] = {
615 {12000000, 480000000, 960, 12, 0, 12},
616 {13000000, 480000000, 960, 13, 0, 12},
617 {16800000, 480000000, 400, 7, 0, 5},
618 {19200000, 480000000, 200, 4, 0, 3},
619 {26000000, 480000000, 960, 26, 0, 12},
620 {0, 0, 0, 0, 0, 0},
623 static struct tegra_clk_pll_params pll_u_params = {
624 .input_min = 2000000,
625 .input_max = 40000000,
626 .cf_min = 1000000,
627 .cf_max = 6000000,
628 .vco_min = 480000000,
629 .vco_max = 960000000,
630 .base_reg = PLLU_BASE,
631 .misc_reg = PLLU_MISC,
632 .lock_mask = PLL_BASE_LOCK,
633 .lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE,
634 .lock_delay = 1000,
635 .pdiv_tohw = pllu_p,
636 .div_nmp = &pllu_nmp,
639 static struct tegra_clk_pll_freq_table pll_x_freq_table[] = {
640 /* 1 GHz */
641 {12000000, 1000000000, 83, 0, 1}, /* actual: 996.0 MHz */
642 {13000000, 1000000000, 76, 0, 1}, /* actual: 988.0 MHz */
643 {16800000, 1000000000, 59, 0, 1}, /* actual: 991.2 MHz */
644 {19200000, 1000000000, 52, 0, 1}, /* actual: 998.4 MHz */
645 {26000000, 1000000000, 76, 1, 1}, /* actual: 988.0 MHz */
647 {0, 0, 0, 0, 0, 0},
650 static struct tegra_clk_pll_params pll_x_params = {
651 .input_min = 12000000,
652 .input_max = 800000000,
653 .cf_min = 12000000,
654 .cf_max = 19200000, /* s/w policy, h/w capability 50 MHz */
655 .vco_min = 700000000,
656 .vco_max = 2400000000U,
657 .base_reg = PLLX_BASE,
658 .misc_reg = PLLX_MISC,
659 .lock_mask = PLL_BASE_LOCK,
660 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
661 .lock_delay = 300,
662 .iddq_reg = PLLX_MISC3,
663 .iddq_bit_idx = PLLX_IDDQ_BIT,
664 .max_p = PLLXC_SW_MAX_P,
665 .dyn_ramp_reg = PLLX_MISC2,
666 .stepa_shift = 16,
667 .stepb_shift = 24,
668 .pdiv_tohw = pllxc_p,
669 .div_nmp = &pllxc_nmp,
672 static struct tegra_clk_pll_freq_table pll_e_freq_table[] = {
673 /* PLLE special case: use cpcon field to store cml divider value */
674 {336000000, 100000000, 100, 21, 16, 11},
675 {312000000, 100000000, 200, 26, 24, 13},
676 {12000000, 100000000, 200, 1, 24, 13},
677 {0, 0, 0, 0, 0, 0},
680 static struct div_nmp plle_nmp = {
681 .divm_shift = 0,
682 .divm_width = 8,
683 .divn_shift = 8,
684 .divn_width = 8,
685 .divp_shift = 24,
686 .divp_width = 4,
689 static struct tegra_clk_pll_params pll_e_params = {
690 .input_min = 12000000,
691 .input_max = 1000000000,
692 .cf_min = 12000000,
693 .cf_max = 75000000,
694 .vco_min = 1600000000,
695 .vco_max = 2400000000U,
696 .base_reg = PLLE_BASE,
697 .misc_reg = PLLE_MISC,
698 .aux_reg = PLLE_AUX,
699 .lock_mask = PLLE_MISC_LOCK,
700 .lock_enable_bit_idx = PLLE_MISC_LOCK_ENABLE,
701 .lock_delay = 300,
702 .div_nmp = &plle_nmp,
705 static struct div_nmp pllre_nmp = {
706 .divm_shift = 0,
707 .divm_width = 8,
708 .divn_shift = 8,
709 .divn_width = 8,
710 .divp_shift = 16,
711 .divp_width = 4,
714 static struct tegra_clk_pll_params pll_re_vco_params = {
715 .input_min = 12000000,
716 .input_max = 1000000000,
717 .cf_min = 12000000,
718 .cf_max = 19200000, /* s/w policy, h/w capability 38 MHz */
719 .vco_min = 300000000,
720 .vco_max = 600000000,
721 .base_reg = PLLRE_BASE,
722 .misc_reg = PLLRE_MISC,
723 .lock_mask = PLLRE_MISC_LOCK,
724 .lock_enable_bit_idx = PLLRE_MISC_LOCK_ENABLE,
725 .lock_delay = 300,
726 .iddq_reg = PLLRE_MISC,
727 .iddq_bit_idx = PLLRE_IDDQ_BIT,
728 .div_nmp = &pllre_nmp,
731 /* Peripheral clock registers */
733 static struct tegra_clk_periph_regs periph_l_regs = {
734 .enb_reg = CLK_OUT_ENB_L,
735 .enb_set_reg = CLK_OUT_ENB_SET_L,
736 .enb_clr_reg = CLK_OUT_ENB_CLR_L,
737 .rst_reg = RST_DEVICES_L,
738 .rst_set_reg = RST_DEVICES_SET_L,
739 .rst_clr_reg = RST_DEVICES_CLR_L,
742 static struct tegra_clk_periph_regs periph_h_regs = {
743 .enb_reg = CLK_OUT_ENB_H,
744 .enb_set_reg = CLK_OUT_ENB_SET_H,
745 .enb_clr_reg = CLK_OUT_ENB_CLR_H,
746 .rst_reg = RST_DEVICES_H,
747 .rst_set_reg = RST_DEVICES_SET_H,
748 .rst_clr_reg = RST_DEVICES_CLR_H,
751 static struct tegra_clk_periph_regs periph_u_regs = {
752 .enb_reg = CLK_OUT_ENB_U,
753 .enb_set_reg = CLK_OUT_ENB_SET_U,
754 .enb_clr_reg = CLK_OUT_ENB_CLR_U,
755 .rst_reg = RST_DEVICES_U,
756 .rst_set_reg = RST_DEVICES_SET_U,
757 .rst_clr_reg = RST_DEVICES_CLR_U,
760 static struct tegra_clk_periph_regs periph_v_regs = {
761 .enb_reg = CLK_OUT_ENB_V,
762 .enb_set_reg = CLK_OUT_ENB_SET_V,
763 .enb_clr_reg = CLK_OUT_ENB_CLR_V,
764 .rst_reg = RST_DEVICES_V,
765 .rst_set_reg = RST_DEVICES_SET_V,
766 .rst_clr_reg = RST_DEVICES_CLR_V,
769 static struct tegra_clk_periph_regs periph_w_regs = {
770 .enb_reg = CLK_OUT_ENB_W,
771 .enb_set_reg = CLK_OUT_ENB_SET_W,
772 .enb_clr_reg = CLK_OUT_ENB_CLR_W,
773 .rst_reg = RST_DEVICES_W,
774 .rst_set_reg = RST_DEVICES_SET_W,
775 .rst_clr_reg = RST_DEVICES_CLR_W,
778 /* possible OSC frequencies in Hz */
779 static unsigned long tegra114_input_freq[] = {
780 [0] = 13000000,
781 [1] = 16800000,
782 [4] = 19200000,
783 [5] = 38400000,
784 [8] = 12000000,
785 [9] = 48000000,
786 [12] = 260000000,
789 #define MASK(x) (BIT(x) - 1)
791 #define TEGRA_INIT_DATA_MUX(_name, _con_id, _dev_id, _parents, _offset, \
792 _clk_num, _regs, _gate_flags, _clk_id) \
793 TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parents, _offset,\
794 30, MASK(2), 0, 0, 8, 1, 0, _regs, _clk_num, \
795 periph_clk_enb_refcnt, _gate_flags, _clk_id, \
796 _parents##_idx, 0)
798 #define TEGRA_INIT_DATA_MUX_FLAGS(_name, _con_id, _dev_id, _parents, _offset,\
799 _clk_num, _regs, _gate_flags, _clk_id, flags)\
800 TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parents, _offset,\
801 30, MASK(2), 0, 0, 8, 1, 0, _regs, _clk_num, \
802 periph_clk_enb_refcnt, _gate_flags, _clk_id, \
803 _parents##_idx, flags)
805 #define TEGRA_INIT_DATA_MUX8(_name, _con_id, _dev_id, _parents, _offset, \
806 _clk_num, _regs, _gate_flags, _clk_id) \
807 TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parents, _offset,\
808 29, MASK(3), 0, 0, 8, 1, 0, _regs, _clk_num, \
809 periph_clk_enb_refcnt, _gate_flags, _clk_id, \
810 _parents##_idx, 0)
812 #define TEGRA_INIT_DATA_INT(_name, _con_id, _dev_id, _parents, _offset, \
813 _clk_num, _regs, _gate_flags, _clk_id) \
814 TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parents, _offset,\
815 30, MASK(2), 0, 0, 8, 1, TEGRA_DIVIDER_INT, _regs,\
816 _clk_num, periph_clk_enb_refcnt, _gate_flags, \
817 _clk_id, _parents##_idx, 0)
819 #define TEGRA_INIT_DATA_INT_FLAGS(_name, _con_id, _dev_id, _parents, _offset,\
820 _clk_num, _regs, _gate_flags, _clk_id, flags)\
821 TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parents, _offset,\
822 30, MASK(2), 0, 0, 8, 1, TEGRA_DIVIDER_INT, _regs,\
823 _clk_num, periph_clk_enb_refcnt, _gate_flags, \
824 _clk_id, _parents##_idx, flags)
826 #define TEGRA_INIT_DATA_INT8(_name, _con_id, _dev_id, _parents, _offset,\
827 _clk_num, _regs, _gate_flags, _clk_id) \
828 TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parents, _offset,\
829 29, MASK(3), 0, 0, 8, 1, TEGRA_DIVIDER_INT, _regs,\
830 _clk_num, periph_clk_enb_refcnt, _gate_flags, \
831 _clk_id, _parents##_idx, 0)
833 #define TEGRA_INIT_DATA_UART(_name, _con_id, _dev_id, _parents, _offset,\
834 _clk_num, _regs, _clk_id) \
835 TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parents, _offset,\
836 30, MASK(2), 0, 0, 16, 1, TEGRA_DIVIDER_UART, _regs,\
837 _clk_num, periph_clk_enb_refcnt, 0, _clk_id, \
838 _parents##_idx, 0)
840 #define TEGRA_INIT_DATA_I2C(_name, _con_id, _dev_id, _parents, _offset,\
841 _clk_num, _regs, _clk_id) \
842 TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parents, _offset,\
843 30, MASK(2), 0, 0, 16, 0, 0, _regs, _clk_num, \
844 periph_clk_enb_refcnt, 0, _clk_id, _parents##_idx, 0)
846 #define TEGRA_INIT_DATA_NODIV(_name, _con_id, _dev_id, _parents, _offset, \
847 _mux_shift, _mux_mask, _clk_num, _regs, \
848 _gate_flags, _clk_id) \
849 TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parents, _offset,\
850 _mux_shift, _mux_mask, 0, 0, 0, 0, 0, _regs, \
851 _clk_num, periph_clk_enb_refcnt, _gate_flags, \
852 _clk_id, _parents##_idx, 0)
854 #define TEGRA_INIT_DATA_XUSB(_name, _con_id, _dev_id, _parents, _offset, \
855 _clk_num, _regs, _gate_flags, _clk_id) \
856 TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parents, _offset, \
857 29, MASK(3), 0, 0, 8, 1, TEGRA_DIVIDER_INT, _regs, \
858 _clk_num, periph_clk_enb_refcnt, _gate_flags, \
859 _clk_id, _parents##_idx, 0)
861 #define TEGRA_INIT_DATA_AUDIO(_name, _con_id, _dev_id, _offset, _clk_num,\
862 _regs, _gate_flags, _clk_id) \
863 TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, mux_d_audio_clk, \
864 _offset, 16, 0xE01F, 0, 0, 8, 1, 0, _regs, _clk_num, \
865 periph_clk_enb_refcnt, _gate_flags , _clk_id, \
866 mux_d_audio_clk_idx, 0)
868 enum tegra114_clk {
869 rtc = 4, timer = 5, uarta = 6, sdmmc2 = 9, i2s1 = 11, i2c1 = 12,
870 ndflash = 13, sdmmc1 = 14, sdmmc4 = 15, pwm = 17, i2s2 = 18, epp = 19,
871 gr_2d = 21, usbd = 22, isp = 23, gr_3d = 24, disp2 = 26, disp1 = 27,
872 host1x = 28, vcp = 29, i2s0 = 30, apbdma = 34, kbc = 36, kfuse = 40,
873 sbc1 = 41, nor = 42, sbc2 = 44, sbc3 = 46, i2c5 = 47, dsia = 48,
874 mipi = 50, hdmi = 51, csi = 52, i2c2 = 54, uartc = 55, mipi_cal = 56,
875 emc, usb2, usb3, vde = 61, bsea = 62, bsev = 63, uartd = 65,
876 i2c3 = 67, sbc4 = 68, sdmmc3 = 69, owr = 71, csite = 73,
877 la = 76, trace = 77, soc_therm = 78, dtv = 79, ndspeed = 80,
878 i2cslow = 81, dsib = 82, tsec = 83, xusb_host = 89, msenc = 91,
879 csus = 92, mselect = 99, tsensor = 100, i2s3 = 101, i2s4 = 102,
880 i2c4 = 103, sbc5 = 104, sbc6 = 105, d_audio, apbif = 107, dam0, dam1,
881 dam2, hda2codec_2x = 111, audio0_2x = 113, audio1_2x, audio2_2x,
882 audio3_2x, audio4_2x, spdif_2x, actmon = 119, extern1 = 120,
883 extern2 = 121, extern3 = 122, hda = 125, se = 127, hda2hdmi = 128,
884 cilab = 144, cilcd = 145, cile = 146, dsialp = 147, dsiblp = 148,
885 dds = 150, dp2 = 152, amx = 153, adx = 154, xusb_ss = 156, uartb = 192,
886 vfir, spdif_in, spdif_out, vi, vi_sensor, fuse, fuse_burn, clk_32k,
887 clk_m, clk_m_div2, clk_m_div4, pll_ref, pll_c, pll_c_out1, pll_c2,
888 pll_c3, pll_m, pll_m_out1, pll_p, pll_p_out1, pll_p_out2, pll_p_out3,
889 pll_p_out4, pll_a, pll_a_out0, pll_d, pll_d_out0, pll_d2, pll_d2_out0,
890 pll_u, pll_u_480M, pll_u_60M, pll_u_48M, pll_u_12M, pll_x, pll_x_out0,
891 pll_re_vco, pll_re_out, pll_e_out0, spdif_in_sync, i2s0_sync,
892 i2s1_sync, i2s2_sync, i2s3_sync, i2s4_sync, vimclk_sync, audio0,
893 audio1, audio2, audio3, audio4, spdif, clk_out_1, clk_out_2, clk_out_3,
894 blink, xusb_host_src = 252, xusb_falcon_src, xusb_fs_src, xusb_ss_src,
895 xusb_dev_src, xusb_dev, xusb_hs_src, sclk, hclk, pclk, cclk_g, cclk_lp,
896 dfll_ref = 264, dfll_soc,
898 /* Mux clocks */
900 audio0_mux = 300, audio1_mux, audio2_mux, audio3_mux, audio4_mux,
901 spdif_mux, clk_out_1_mux, clk_out_2_mux, clk_out_3_mux, dsia_mux,
902 dsib_mux, clk_max,
905 struct utmi_clk_param {
906 /* Oscillator Frequency in KHz */
907 u32 osc_frequency;
908 /* UTMIP PLL Enable Delay Count */
909 u8 enable_delay_count;
910 /* UTMIP PLL Stable count */
911 u8 stable_count;
912 /* UTMIP PLL Active delay count */
913 u8 active_delay_count;
914 /* UTMIP PLL Xtal frequency count */
915 u8 xtal_freq_count;
918 static const struct utmi_clk_param utmi_parameters[] = {
919 {.osc_frequency = 13000000, .enable_delay_count = 0x02,
920 .stable_count = 0x33, .active_delay_count = 0x05,
921 .xtal_freq_count = 0x7F},
922 {.osc_frequency = 19200000, .enable_delay_count = 0x03,
923 .stable_count = 0x4B, .active_delay_count = 0x06,
924 .xtal_freq_count = 0xBB},
925 {.osc_frequency = 12000000, .enable_delay_count = 0x02,
926 .stable_count = 0x2F, .active_delay_count = 0x04,
927 .xtal_freq_count = 0x76},
928 {.osc_frequency = 26000000, .enable_delay_count = 0x04,
929 .stable_count = 0x66, .active_delay_count = 0x09,
930 .xtal_freq_count = 0xFE},
931 {.osc_frequency = 16800000, .enable_delay_count = 0x03,
932 .stable_count = 0x41, .active_delay_count = 0x0A,
933 .xtal_freq_count = 0xA4},
936 /* peripheral mux definitions */
938 #define MUX_I2S_SPDIF(_id) \
939 static const char *mux_pllaout0_##_id##_2x_pllp_clkm[] = { "pll_a_out0", \
940 #_id, "pll_p",\
941 "clk_m"};
942 MUX_I2S_SPDIF(audio0)
943 MUX_I2S_SPDIF(audio1)
944 MUX_I2S_SPDIF(audio2)
945 MUX_I2S_SPDIF(audio3)
946 MUX_I2S_SPDIF(audio4)
947 MUX_I2S_SPDIF(audio)
949 #define mux_pllaout0_audio0_2x_pllp_clkm_idx NULL
950 #define mux_pllaout0_audio1_2x_pllp_clkm_idx NULL
951 #define mux_pllaout0_audio2_2x_pllp_clkm_idx NULL
952 #define mux_pllaout0_audio3_2x_pllp_clkm_idx NULL
953 #define mux_pllaout0_audio4_2x_pllp_clkm_idx NULL
954 #define mux_pllaout0_audio_2x_pllp_clkm_idx NULL
956 static const char *mux_pllp_pllc_pllm_clkm[] = {
957 "pll_p", "pll_c", "pll_m", "clk_m"
959 #define mux_pllp_pllc_pllm_clkm_idx NULL
961 static const char *mux_pllp_pllc_pllm[] = { "pll_p", "pll_c", "pll_m" };
962 #define mux_pllp_pllc_pllm_idx NULL
964 static const char *mux_pllp_pllc_clk32_clkm[] = {
965 "pll_p", "pll_c", "clk_32k", "clk_m"
967 #define mux_pllp_pllc_clk32_clkm_idx NULL
969 static const char *mux_plla_pllc_pllp_clkm[] = {
970 "pll_a_out0", "pll_c", "pll_p", "clk_m"
972 #define mux_plla_pllc_pllp_clkm_idx mux_pllp_pllc_pllm_clkm_idx
974 static const char *mux_pllp_pllc2_c_c3_pllm_clkm[] = {
975 "pll_p", "pll_c2", "pll_c", "pll_c3", "pll_m", "clk_m"
977 static u32 mux_pllp_pllc2_c_c3_pllm_clkm_idx[] = {
978 [0] = 0, [1] = 1, [2] = 2, [3] = 3, [4] = 4, [5] = 6,
981 static const char *mux_pllp_clkm[] = {
982 "pll_p", "clk_m"
984 static u32 mux_pllp_clkm_idx[] = {
985 [0] = 0, [1] = 3,
988 static const char *mux_pllm_pllc2_c_c3_pllp_plla[] = {
989 "pll_m", "pll_c2", "pll_c", "pll_c3", "pll_p", "pll_a_out0"
991 #define mux_pllm_pllc2_c_c3_pllp_plla_idx mux_pllp_pllc2_c_c3_pllm_clkm_idx
993 static const char *mux_pllp_pllm_plld_plla_pllc_plld2_clkm[] = {
994 "pll_p", "pll_m", "pll_d_out0", "pll_a_out0", "pll_c",
995 "pll_d2_out0", "clk_m"
997 #define mux_pllp_pllm_plld_plla_pllc_plld2_clkm_idx NULL
999 static const char *mux_pllm_pllc_pllp_plla[] = {
1000 "pll_m", "pll_c", "pll_p", "pll_a_out0"
1002 #define mux_pllm_pllc_pllp_plla_idx mux_pllp_pllc_pllm_clkm_idx
1004 static const char *mux_pllp_pllc_clkm[] = {
1005 "pll_p", "pll_c", "pll_m"
1007 static u32 mux_pllp_pllc_clkm_idx[] = {
1008 [0] = 0, [1] = 1, [2] = 3,
1011 static const char *mux_pllp_pllc_clkm_clk32[] = {
1012 "pll_p", "pll_c", "clk_m", "clk_32k"
1014 #define mux_pllp_pllc_clkm_clk32_idx NULL
1016 static const char *mux_plla_clk32_pllp_clkm_plle[] = {
1017 "pll_a_out0", "clk_32k", "pll_p", "clk_m", "pll_e_out0"
1019 #define mux_plla_clk32_pllp_clkm_plle_idx NULL
1021 static const char *mux_clkm_pllp_pllc_pllre[] = {
1022 "clk_m", "pll_p", "pll_c", "pll_re_out"
1024 static u32 mux_clkm_pllp_pllc_pllre_idx[] = {
1025 [0] = 0, [1] = 1, [2] = 3, [3] = 5,
1028 static const char *mux_clkm_48M_pllp_480M[] = {
1029 "clk_m", "pll_u_48M", "pll_p", "pll_u_480M"
1031 #define mux_clkm_48M_pllp_480M_idx NULL
1033 static const char *mux_clkm_pllre_clk32_480M_pllc_ref[] = {
1034 "clk_m", "pll_re_out", "clk_32k", "pll_u_480M", "pll_c", "pll_ref"
1036 static u32 mux_clkm_pllre_clk32_480M_pllc_ref_idx[] = {
1037 [0] = 0, [1] = 1, [2] = 3, [3] = 3, [4] = 4, [5] = 7,
1040 static const char *mux_plld_out0_plld2_out0[] = {
1041 "pll_d_out0", "pll_d2_out0",
1043 #define mux_plld_out0_plld2_out0_idx NULL
1045 static const char *mux_d_audio_clk[] = {
1046 "pll_a_out0", "pll_p", "clk_m", "spdif_in_sync", "i2s0_sync",
1047 "i2s1_sync", "i2s2_sync", "i2s3_sync", "i2s4_sync", "vimclk_sync",
1049 static u32 mux_d_audio_clk_idx[] = {
1050 [0] = 0, [1] = 0x8000, [2] = 0xc000, [3] = 0xE000, [4] = 0xE001,
1051 [5] = 0xE002, [6] = 0xE003, [7] = 0xE004, [8] = 0xE005, [9] = 0xE007,
1054 static const char *mux_pllmcp_clkm[] = {
1055 "pll_m_out0", "pll_c_out0", "pll_p_out0", "clk_m", "pll_m_ud",
1058 static const struct clk_div_table pll_re_div_table[] = {
1059 { .val = 0, .div = 1 },
1060 { .val = 1, .div = 2 },
1061 { .val = 2, .div = 3 },
1062 { .val = 3, .div = 4 },
1063 { .val = 4, .div = 5 },
1064 { .val = 5, .div = 6 },
1065 { .val = 0, .div = 0 },
1068 static struct clk *clks[clk_max];
1069 static struct clk_onecell_data clk_data;
1071 static unsigned long osc_freq;
1072 static unsigned long pll_ref_freq;
1074 static int __init tegra114_osc_clk_init(void __iomem *clk_base)
1076 struct clk *clk;
1077 u32 val, pll_ref_div;
1079 val = readl_relaxed(clk_base + OSC_CTRL);
1081 osc_freq = tegra114_input_freq[val >> OSC_CTRL_OSC_FREQ_SHIFT];
1082 if (!osc_freq) {
1083 WARN_ON(1);
1084 return -EINVAL;
1087 /* clk_m */
1088 clk = clk_register_fixed_rate(NULL, "clk_m", NULL, CLK_IS_ROOT,
1089 osc_freq);
1090 clk_register_clkdev(clk, "clk_m", NULL);
1091 clks[clk_m] = clk;
1093 /* pll_ref */
1094 val = (val >> OSC_CTRL_PLL_REF_DIV_SHIFT) & 3;
1095 pll_ref_div = 1 << val;
1096 clk = clk_register_fixed_factor(NULL, "pll_ref", "clk_m",
1097 CLK_SET_RATE_PARENT, 1, pll_ref_div);
1098 clk_register_clkdev(clk, "pll_ref", NULL);
1099 clks[pll_ref] = clk;
1101 pll_ref_freq = osc_freq / pll_ref_div;
1103 return 0;
1106 static void __init tegra114_fixed_clk_init(void __iomem *clk_base)
1108 struct clk *clk;
1110 /* clk_32k */
1111 clk = clk_register_fixed_rate(NULL, "clk_32k", NULL, CLK_IS_ROOT,
1112 32768);
1113 clk_register_clkdev(clk, "clk_32k", NULL);
1114 clks[clk_32k] = clk;
1116 /* clk_m_div2 */
1117 clk = clk_register_fixed_factor(NULL, "clk_m_div2", "clk_m",
1118 CLK_SET_RATE_PARENT, 1, 2);
1119 clk_register_clkdev(clk, "clk_m_div2", NULL);
1120 clks[clk_m_div2] = clk;
1122 /* clk_m_div4 */
1123 clk = clk_register_fixed_factor(NULL, "clk_m_div4", "clk_m",
1124 CLK_SET_RATE_PARENT, 1, 4);
1125 clk_register_clkdev(clk, "clk_m_div4", NULL);
1126 clks[clk_m_div4] = clk;
1130 static __init void tegra114_utmi_param_configure(void __iomem *clk_base)
1132 u32 reg;
1133 int i;
1135 for (i = 0; i < ARRAY_SIZE(utmi_parameters); i++) {
1136 if (osc_freq == utmi_parameters[i].osc_frequency)
1137 break;
1140 if (i >= ARRAY_SIZE(utmi_parameters)) {
1141 pr_err("%s: Unexpected oscillator freq %lu\n", __func__,
1142 osc_freq);
1143 return;
1146 reg = readl_relaxed(clk_base + UTMIP_PLL_CFG2);
1148 /* Program UTMIP PLL stable and active counts */
1149 /* [FIXME] arclk_rst.h says WRONG! This should be 1ms -> 0x50 Check! */
1150 reg &= ~UTMIP_PLL_CFG2_STABLE_COUNT(~0);
1151 reg |= UTMIP_PLL_CFG2_STABLE_COUNT(utmi_parameters[i].stable_count);
1153 reg &= ~UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT(~0);
1155 reg |= UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT(utmi_parameters[i].
1156 active_delay_count);
1158 /* Remove power downs from UTMIP PLL control bits */
1159 reg &= ~UTMIP_PLL_CFG2_FORCE_PD_SAMP_A_POWERDOWN;
1160 reg &= ~UTMIP_PLL_CFG2_FORCE_PD_SAMP_B_POWERDOWN;
1161 reg &= ~UTMIP_PLL_CFG2_FORCE_PD_SAMP_C_POWERDOWN;
1163 writel_relaxed(reg, clk_base + UTMIP_PLL_CFG2);
1165 /* Program UTMIP PLL delay and oscillator frequency counts */
1166 reg = readl_relaxed(clk_base + UTMIP_PLL_CFG1);
1167 reg &= ~UTMIP_PLL_CFG1_ENABLE_DLY_COUNT(~0);
1169 reg |= UTMIP_PLL_CFG1_ENABLE_DLY_COUNT(utmi_parameters[i].
1170 enable_delay_count);
1172 reg &= ~UTMIP_PLL_CFG1_XTAL_FREQ_COUNT(~0);
1173 reg |= UTMIP_PLL_CFG1_XTAL_FREQ_COUNT(utmi_parameters[i].
1174 xtal_freq_count);
1176 /* Remove power downs from UTMIP PLL control bits */
1177 reg &= ~UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERDOWN;
1178 reg &= ~UTMIP_PLL_CFG1_FORCE_PLL_ACTIVE_POWERDOWN;
1179 reg &= ~UTMIP_PLL_CFG1_FORCE_PLLU_POWERUP;
1180 reg &= ~UTMIP_PLL_CFG1_FORCE_PLLU_POWERDOWN;
1181 writel_relaxed(reg, clk_base + UTMIP_PLL_CFG1);
1183 /* Setup HW control of UTMIPLL */
1184 reg = readl_relaxed(clk_base + UTMIPLL_HW_PWRDN_CFG0);
1185 reg |= UTMIPLL_HW_PWRDN_CFG0_USE_LOCKDET;
1186 reg &= ~UTMIPLL_HW_PWRDN_CFG0_CLK_ENABLE_SWCTL;
1187 reg |= UTMIPLL_HW_PWRDN_CFG0_SEQ_START_STATE;
1188 writel_relaxed(reg, clk_base + UTMIPLL_HW_PWRDN_CFG0);
1190 reg = readl_relaxed(clk_base + UTMIP_PLL_CFG1);
1191 reg &= ~UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERUP;
1192 reg &= ~UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERDOWN;
1193 writel_relaxed(reg, clk_base + UTMIP_PLL_CFG1);
1195 udelay(1);
1197 /* Setup SW override of UTMIPLL assuming USB2.0
1198 ports are assigned to USB2 */
1199 reg = readl_relaxed(clk_base + UTMIPLL_HW_PWRDN_CFG0);
1200 reg |= UTMIPLL_HW_PWRDN_CFG0_IDDQ_SWCTL;
1201 reg &= ~UTMIPLL_HW_PWRDN_CFG0_IDDQ_OVERRIDE;
1202 writel_relaxed(reg, clk_base + UTMIPLL_HW_PWRDN_CFG0);
1204 udelay(1);
1206 /* Enable HW control UTMIPLL */
1207 reg = readl_relaxed(clk_base + UTMIPLL_HW_PWRDN_CFG0);
1208 reg |= UTMIPLL_HW_PWRDN_CFG0_SEQ_ENABLE;
1209 writel_relaxed(reg, clk_base + UTMIPLL_HW_PWRDN_CFG0);
1212 static void __init _clip_vco_min(struct tegra_clk_pll_params *pll_params)
1214 pll_params->vco_min =
1215 DIV_ROUND_UP(pll_params->vco_min, pll_ref_freq) * pll_ref_freq;
1218 static int __init _setup_dynamic_ramp(struct tegra_clk_pll_params *pll_params,
1219 void __iomem *clk_base)
1221 u32 val;
1222 u32 step_a, step_b;
1224 switch (pll_ref_freq) {
1225 case 12000000:
1226 case 13000000:
1227 case 26000000:
1228 step_a = 0x2B;
1229 step_b = 0x0B;
1230 break;
1231 case 16800000:
1232 step_a = 0x1A;
1233 step_b = 0x09;
1234 break;
1235 case 19200000:
1236 step_a = 0x12;
1237 step_b = 0x08;
1238 break;
1239 default:
1240 pr_err("%s: Unexpected reference rate %lu\n",
1241 __func__, pll_ref_freq);
1242 WARN_ON(1);
1243 return -EINVAL;
1246 val = step_a << pll_params->stepa_shift;
1247 val |= step_b << pll_params->stepb_shift;
1248 writel_relaxed(val, clk_base + pll_params->dyn_ramp_reg);
1250 return 0;
1253 static void __init _init_iddq(struct tegra_clk_pll_params *pll_params,
1254 void __iomem *clk_base)
1256 u32 val, val_iddq;
1258 val = readl_relaxed(clk_base + pll_params->base_reg);
1259 val_iddq = readl_relaxed(clk_base + pll_params->iddq_reg);
1261 if (val & BIT(30))
1262 WARN_ON(val_iddq & BIT(pll_params->iddq_bit_idx));
1263 else {
1264 val_iddq |= BIT(pll_params->iddq_bit_idx);
1265 writel_relaxed(val_iddq, clk_base + pll_params->iddq_reg);
1269 static void __init tegra114_pll_init(void __iomem *clk_base,
1270 void __iomem *pmc)
1272 u32 val;
1273 struct clk *clk;
1275 /* PLLC */
1276 _clip_vco_min(&pll_c_params);
1277 if (_setup_dynamic_ramp(&pll_c_params, clk_base) >= 0) {
1278 _init_iddq(&pll_c_params, clk_base);
1279 clk = tegra_clk_register_pllxc("pll_c", "pll_ref", clk_base,
1280 pmc, 0, 0, &pll_c_params, TEGRA_PLL_USE_LOCK,
1281 pll_c_freq_table, NULL);
1282 clk_register_clkdev(clk, "pll_c", NULL);
1283 clks[pll_c] = clk;
1285 /* PLLC_OUT1 */
1286 clk = tegra_clk_register_divider("pll_c_out1_div", "pll_c",
1287 clk_base + PLLC_OUT, 0, TEGRA_DIVIDER_ROUND_UP,
1288 8, 8, 1, NULL);
1289 clk = tegra_clk_register_pll_out("pll_c_out1", "pll_c_out1_div",
1290 clk_base + PLLC_OUT, 1, 0,
1291 CLK_SET_RATE_PARENT, 0, NULL);
1292 clk_register_clkdev(clk, "pll_c_out1", NULL);
1293 clks[pll_c_out1] = clk;
1296 /* PLLC2 */
1297 _clip_vco_min(&pll_c2_params);
1298 clk = tegra_clk_register_pllc("pll_c2", "pll_ref", clk_base, pmc, 0, 0,
1299 &pll_c2_params, TEGRA_PLL_USE_LOCK,
1300 pll_cx_freq_table, NULL);
1301 clk_register_clkdev(clk, "pll_c2", NULL);
1302 clks[pll_c2] = clk;
1304 /* PLLC3 */
1305 _clip_vco_min(&pll_c3_params);
1306 clk = tegra_clk_register_pllc("pll_c3", "pll_ref", clk_base, pmc, 0, 0,
1307 &pll_c3_params, TEGRA_PLL_USE_LOCK,
1308 pll_cx_freq_table, NULL);
1309 clk_register_clkdev(clk, "pll_c3", NULL);
1310 clks[pll_c3] = clk;
1312 /* PLLP */
1313 clk = tegra_clk_register_pll("pll_p", "pll_ref", clk_base, pmc, 0,
1314 408000000, &pll_p_params,
1315 TEGRA_PLL_FIXED | TEGRA_PLL_USE_LOCK,
1316 pll_p_freq_table, NULL);
1317 clk_register_clkdev(clk, "pll_p", NULL);
1318 clks[pll_p] = clk;
1320 /* PLLP_OUT1 */
1321 clk = tegra_clk_register_divider("pll_p_out1_div", "pll_p",
1322 clk_base + PLLP_OUTA, 0, TEGRA_DIVIDER_FIXED |
1323 TEGRA_DIVIDER_ROUND_UP, 8, 8, 1, &pll_div_lock);
1324 clk = tegra_clk_register_pll_out("pll_p_out1", "pll_p_out1_div",
1325 clk_base + PLLP_OUTA, 1, 0,
1326 CLK_IGNORE_UNUSED | CLK_SET_RATE_PARENT, 0,
1327 &pll_div_lock);
1328 clk_register_clkdev(clk, "pll_p_out1", NULL);
1329 clks[pll_p_out1] = clk;
1331 /* PLLP_OUT2 */
1332 clk = tegra_clk_register_divider("pll_p_out2_div", "pll_p",
1333 clk_base + PLLP_OUTA, 0, TEGRA_DIVIDER_FIXED |
1334 TEGRA_DIVIDER_ROUND_UP | TEGRA_DIVIDER_INT, 24,
1335 8, 1, &pll_div_lock);
1336 clk = tegra_clk_register_pll_out("pll_p_out2", "pll_p_out2_div",
1337 clk_base + PLLP_OUTA, 17, 16,
1338 CLK_IGNORE_UNUSED | CLK_SET_RATE_PARENT, 0,
1339 &pll_div_lock);
1340 clk_register_clkdev(clk, "pll_p_out2", NULL);
1341 clks[pll_p_out2] = clk;
1343 /* PLLP_OUT3 */
1344 clk = tegra_clk_register_divider("pll_p_out3_div", "pll_p",
1345 clk_base + PLLP_OUTB, 0, TEGRA_DIVIDER_FIXED |
1346 TEGRA_DIVIDER_ROUND_UP, 8, 8, 1, &pll_div_lock);
1347 clk = tegra_clk_register_pll_out("pll_p_out3", "pll_p_out3_div",
1348 clk_base + PLLP_OUTB, 1, 0,
1349 CLK_IGNORE_UNUSED | CLK_SET_RATE_PARENT, 0,
1350 &pll_div_lock);
1351 clk_register_clkdev(clk, "pll_p_out3", NULL);
1352 clks[pll_p_out3] = clk;
1354 /* PLLP_OUT4 */
1355 clk = tegra_clk_register_divider("pll_p_out4_div", "pll_p",
1356 clk_base + PLLP_OUTB, 0, TEGRA_DIVIDER_FIXED |
1357 TEGRA_DIVIDER_ROUND_UP, 24, 8, 1,
1358 &pll_div_lock);
1359 clk = tegra_clk_register_pll_out("pll_p_out4", "pll_p_out4_div",
1360 clk_base + PLLP_OUTB, 17, 16,
1361 CLK_IGNORE_UNUSED | CLK_SET_RATE_PARENT, 0,
1362 &pll_div_lock);
1363 clk_register_clkdev(clk, "pll_p_out4", NULL);
1364 clks[pll_p_out4] = clk;
1366 /* PLLM */
1367 _clip_vco_min(&pll_m_params);
1368 clk = tegra_clk_register_pllm("pll_m", "pll_ref", clk_base, pmc,
1369 CLK_IGNORE_UNUSED | CLK_SET_RATE_GATE, 0,
1370 &pll_m_params, TEGRA_PLL_USE_LOCK,
1371 pll_m_freq_table, NULL);
1372 clk_register_clkdev(clk, "pll_m", NULL);
1373 clks[pll_m] = clk;
1375 /* PLLM_OUT1 */
1376 clk = tegra_clk_register_divider("pll_m_out1_div", "pll_m",
1377 clk_base + PLLM_OUT, 0, TEGRA_DIVIDER_ROUND_UP,
1378 8, 8, 1, NULL);
1379 clk = tegra_clk_register_pll_out("pll_m_out1", "pll_m_out1_div",
1380 clk_base + PLLM_OUT, 1, 0, CLK_IGNORE_UNUSED |
1381 CLK_SET_RATE_PARENT, 0, NULL);
1382 clk_register_clkdev(clk, "pll_m_out1", NULL);
1383 clks[pll_m_out1] = clk;
1385 /* PLLM_UD */
1386 clk = clk_register_fixed_factor(NULL, "pll_m_ud", "pll_m",
1387 CLK_SET_RATE_PARENT, 1, 1);
1389 /* PLLX */
1390 _clip_vco_min(&pll_x_params);
1391 if (_setup_dynamic_ramp(&pll_x_params, clk_base) >= 0) {
1392 _init_iddq(&pll_x_params, clk_base);
1393 clk = tegra_clk_register_pllxc("pll_x", "pll_ref", clk_base,
1394 pmc, CLK_IGNORE_UNUSED, 0, &pll_x_params,
1395 TEGRA_PLL_USE_LOCK, pll_x_freq_table, NULL);
1396 clk_register_clkdev(clk, "pll_x", NULL);
1397 clks[pll_x] = clk;
1400 /* PLLX_OUT0 */
1401 clk = clk_register_fixed_factor(NULL, "pll_x_out0", "pll_x",
1402 CLK_SET_RATE_PARENT, 1, 2);
1403 clk_register_clkdev(clk, "pll_x_out0", NULL);
1404 clks[pll_x_out0] = clk;
1406 /* PLLU */
1407 val = readl(clk_base + pll_u_params.base_reg);
1408 val &= ~BIT(24); /* disable PLLU_OVERRIDE */
1409 writel(val, clk_base + pll_u_params.base_reg);
1411 clk = tegra_clk_register_pll("pll_u", "pll_ref", clk_base, pmc, 0,
1412 0, &pll_u_params, TEGRA_PLLU |
1413 TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON |
1414 TEGRA_PLL_USE_LOCK, pll_u_freq_table, &pll_u_lock);
1415 clk_register_clkdev(clk, "pll_u", NULL);
1416 clks[pll_u] = clk;
1418 tegra114_utmi_param_configure(clk_base);
1420 /* PLLU_480M */
1421 clk = clk_register_gate(NULL, "pll_u_480M", "pll_u",
1422 CLK_SET_RATE_PARENT, clk_base + PLLU_BASE,
1423 22, 0, &pll_u_lock);
1424 clk_register_clkdev(clk, "pll_u_480M", NULL);
1425 clks[pll_u_480M] = clk;
1427 /* PLLU_60M */
1428 clk = clk_register_fixed_factor(NULL, "pll_u_60M", "pll_u",
1429 CLK_SET_RATE_PARENT, 1, 8);
1430 clk_register_clkdev(clk, "pll_u_60M", NULL);
1431 clks[pll_u_60M] = clk;
1433 /* PLLU_48M */
1434 clk = clk_register_fixed_factor(NULL, "pll_u_48M", "pll_u",
1435 CLK_SET_RATE_PARENT, 1, 10);
1436 clk_register_clkdev(clk, "pll_u_48M", NULL);
1437 clks[pll_u_48M] = clk;
1439 /* PLLU_12M */
1440 clk = clk_register_fixed_factor(NULL, "pll_u_12M", "pll_u",
1441 CLK_SET_RATE_PARENT, 1, 40);
1442 clk_register_clkdev(clk, "pll_u_12M", NULL);
1443 clks[pll_u_12M] = clk;
1445 /* PLLD */
1446 clk = tegra_clk_register_pll("pll_d", "pll_ref", clk_base, pmc, 0,
1447 0, &pll_d_params,
1448 TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON |
1449 TEGRA_PLL_USE_LOCK, pll_d_freq_table, &pll_d_lock);
1450 clk_register_clkdev(clk, "pll_d", NULL);
1451 clks[pll_d] = clk;
1453 /* PLLD_OUT0 */
1454 clk = clk_register_fixed_factor(NULL, "pll_d_out0", "pll_d",
1455 CLK_SET_RATE_PARENT, 1, 2);
1456 clk_register_clkdev(clk, "pll_d_out0", NULL);
1457 clks[pll_d_out0] = clk;
1459 /* PLLD2 */
1460 clk = tegra_clk_register_pll("pll_d2", "pll_ref", clk_base, pmc, 0,
1461 0, &pll_d2_params,
1462 TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON |
1463 TEGRA_PLL_USE_LOCK, pll_d_freq_table, &pll_d2_lock);
1464 clk_register_clkdev(clk, "pll_d2", NULL);
1465 clks[pll_d2] = clk;
1467 /* PLLD2_OUT0 */
1468 clk = clk_register_fixed_factor(NULL, "pll_d2_out0", "pll_d2",
1469 CLK_SET_RATE_PARENT, 1, 2);
1470 clk_register_clkdev(clk, "pll_d2_out0", NULL);
1471 clks[pll_d2_out0] = clk;
1473 /* PLLA */
1474 clk = tegra_clk_register_pll("pll_a", "pll_p_out1", clk_base, pmc, 0,
1475 0, &pll_a_params, TEGRA_PLL_HAS_CPCON |
1476 TEGRA_PLL_USE_LOCK, pll_a_freq_table, NULL);
1477 clk_register_clkdev(clk, "pll_a", NULL);
1478 clks[pll_a] = clk;
1480 /* PLLA_OUT0 */
1481 clk = tegra_clk_register_divider("pll_a_out0_div", "pll_a",
1482 clk_base + PLLA_OUT, 0, TEGRA_DIVIDER_ROUND_UP,
1483 8, 8, 1, NULL);
1484 clk = tegra_clk_register_pll_out("pll_a_out0", "pll_a_out0_div",
1485 clk_base + PLLA_OUT, 1, 0, CLK_IGNORE_UNUSED |
1486 CLK_SET_RATE_PARENT, 0, NULL);
1487 clk_register_clkdev(clk, "pll_a_out0", NULL);
1488 clks[pll_a_out0] = clk;
1490 /* PLLRE */
1491 _clip_vco_min(&pll_re_vco_params);
1492 clk = tegra_clk_register_pllre("pll_re_vco", "pll_ref", clk_base, pmc,
1493 0, 0, &pll_re_vco_params, TEGRA_PLL_USE_LOCK,
1494 NULL, &pll_re_lock, pll_ref_freq);
1495 clk_register_clkdev(clk, "pll_re_vco", NULL);
1496 clks[pll_re_vco] = clk;
1498 clk = clk_register_divider_table(NULL, "pll_re_out", "pll_re_vco", 0,
1499 clk_base + PLLRE_BASE, 16, 4, 0,
1500 pll_re_div_table, &pll_re_lock);
1501 clk_register_clkdev(clk, "pll_re_out", NULL);
1502 clks[pll_re_out] = clk;
1504 /* PLLE */
1505 clk = tegra_clk_register_plle_tegra114("pll_e_out0", "pll_ref",
1506 clk_base, 0, 100000000, &pll_e_params,
1507 pll_e_freq_table, NULL);
1508 clk_register_clkdev(clk, "pll_e_out0", NULL);
1509 clks[pll_e_out0] = clk;
1512 static const char *mux_audio_sync_clk[] = { "spdif_in_sync", "i2s0_sync",
1513 "i2s1_sync", "i2s2_sync", "i2s3_sync", "i2s4_sync", "vimclk_sync",
1516 static const char *clk_out1_parents[] = { "clk_m", "clk_m_div2",
1517 "clk_m_div4", "extern1",
1520 static const char *clk_out2_parents[] = { "clk_m", "clk_m_div2",
1521 "clk_m_div4", "extern2",
1524 static const char *clk_out3_parents[] = { "clk_m", "clk_m_div2",
1525 "clk_m_div4", "extern3",
1528 static void __init tegra114_audio_clk_init(void __iomem *clk_base)
1530 struct clk *clk;
1532 /* spdif_in_sync */
1533 clk = tegra_clk_register_sync_source("spdif_in_sync", 24000000,
1534 24000000);
1535 clk_register_clkdev(clk, "spdif_in_sync", NULL);
1536 clks[spdif_in_sync] = clk;
1538 /* i2s0_sync */
1539 clk = tegra_clk_register_sync_source("i2s0_sync", 24000000, 24000000);
1540 clk_register_clkdev(clk, "i2s0_sync", NULL);
1541 clks[i2s0_sync] = clk;
1543 /* i2s1_sync */
1544 clk = tegra_clk_register_sync_source("i2s1_sync", 24000000, 24000000);
1545 clk_register_clkdev(clk, "i2s1_sync", NULL);
1546 clks[i2s1_sync] = clk;
1548 /* i2s2_sync */
1549 clk = tegra_clk_register_sync_source("i2s2_sync", 24000000, 24000000);
1550 clk_register_clkdev(clk, "i2s2_sync", NULL);
1551 clks[i2s2_sync] = clk;
1553 /* i2s3_sync */
1554 clk = tegra_clk_register_sync_source("i2s3_sync", 24000000, 24000000);
1555 clk_register_clkdev(clk, "i2s3_sync", NULL);
1556 clks[i2s3_sync] = clk;
1558 /* i2s4_sync */
1559 clk = tegra_clk_register_sync_source("i2s4_sync", 24000000, 24000000);
1560 clk_register_clkdev(clk, "i2s4_sync", NULL);
1561 clks[i2s4_sync] = clk;
1563 /* vimclk_sync */
1564 clk = tegra_clk_register_sync_source("vimclk_sync", 24000000, 24000000);
1565 clk_register_clkdev(clk, "vimclk_sync", NULL);
1566 clks[vimclk_sync] = clk;
1568 /* audio0 */
1569 clk = clk_register_mux(NULL, "audio0_mux", mux_audio_sync_clk,
1570 ARRAY_SIZE(mux_audio_sync_clk),
1571 CLK_SET_RATE_NO_REPARENT,
1572 clk_base + AUDIO_SYNC_CLK_I2S0, 0, 3, 0,
1573 NULL);
1574 clks[audio0_mux] = clk;
1575 clk = clk_register_gate(NULL, "audio0", "audio0_mux", 0,
1576 clk_base + AUDIO_SYNC_CLK_I2S0, 4,
1577 CLK_GATE_SET_TO_DISABLE, NULL);
1578 clk_register_clkdev(clk, "audio0", NULL);
1579 clks[audio0] = clk;
1581 /* audio1 */
1582 clk = clk_register_mux(NULL, "audio1_mux", mux_audio_sync_clk,
1583 ARRAY_SIZE(mux_audio_sync_clk),
1584 CLK_SET_RATE_NO_REPARENT,
1585 clk_base + AUDIO_SYNC_CLK_I2S1, 0, 3, 0,
1586 NULL);
1587 clks[audio1_mux] = clk;
1588 clk = clk_register_gate(NULL, "audio1", "audio1_mux", 0,
1589 clk_base + AUDIO_SYNC_CLK_I2S1, 4,
1590 CLK_GATE_SET_TO_DISABLE, NULL);
1591 clk_register_clkdev(clk, "audio1", NULL);
1592 clks[audio1] = clk;
1594 /* audio2 */
1595 clk = clk_register_mux(NULL, "audio2_mux", mux_audio_sync_clk,
1596 ARRAY_SIZE(mux_audio_sync_clk),
1597 CLK_SET_RATE_NO_REPARENT,
1598 clk_base + AUDIO_SYNC_CLK_I2S2, 0, 3, 0,
1599 NULL);
1600 clks[audio2_mux] = clk;
1601 clk = clk_register_gate(NULL, "audio2", "audio2_mux", 0,
1602 clk_base + AUDIO_SYNC_CLK_I2S2, 4,
1603 CLK_GATE_SET_TO_DISABLE, NULL);
1604 clk_register_clkdev(clk, "audio2", NULL);
1605 clks[audio2] = clk;
1607 /* audio3 */
1608 clk = clk_register_mux(NULL, "audio3_mux", mux_audio_sync_clk,
1609 ARRAY_SIZE(mux_audio_sync_clk),
1610 CLK_SET_RATE_NO_REPARENT,
1611 clk_base + AUDIO_SYNC_CLK_I2S3, 0, 3, 0,
1612 NULL);
1613 clks[audio3_mux] = clk;
1614 clk = clk_register_gate(NULL, "audio3", "audio3_mux", 0,
1615 clk_base + AUDIO_SYNC_CLK_I2S3, 4,
1616 CLK_GATE_SET_TO_DISABLE, NULL);
1617 clk_register_clkdev(clk, "audio3", NULL);
1618 clks[audio3] = clk;
1620 /* audio4 */
1621 clk = clk_register_mux(NULL, "audio4_mux", mux_audio_sync_clk,
1622 ARRAY_SIZE(mux_audio_sync_clk),
1623 CLK_SET_RATE_NO_REPARENT,
1624 clk_base + AUDIO_SYNC_CLK_I2S4, 0, 3, 0,
1625 NULL);
1626 clks[audio4_mux] = clk;
1627 clk = clk_register_gate(NULL, "audio4", "audio4_mux", 0,
1628 clk_base + AUDIO_SYNC_CLK_I2S4, 4,
1629 CLK_GATE_SET_TO_DISABLE, NULL);
1630 clk_register_clkdev(clk, "audio4", NULL);
1631 clks[audio4] = clk;
1633 /* spdif */
1634 clk = clk_register_mux(NULL, "spdif_mux", mux_audio_sync_clk,
1635 ARRAY_SIZE(mux_audio_sync_clk),
1636 CLK_SET_RATE_NO_REPARENT,
1637 clk_base + AUDIO_SYNC_CLK_SPDIF, 0, 3, 0,
1638 NULL);
1639 clks[spdif_mux] = clk;
1640 clk = clk_register_gate(NULL, "spdif", "spdif_mux", 0,
1641 clk_base + AUDIO_SYNC_CLK_SPDIF, 4,
1642 CLK_GATE_SET_TO_DISABLE, NULL);
1643 clk_register_clkdev(clk, "spdif", NULL);
1644 clks[spdif] = clk;
1646 /* audio0_2x */
1647 clk = clk_register_fixed_factor(NULL, "audio0_doubler", "audio0",
1648 CLK_SET_RATE_PARENT, 2, 1);
1649 clk = tegra_clk_register_divider("audio0_div", "audio0_doubler",
1650 clk_base + AUDIO_SYNC_DOUBLER, 0, 0, 24, 1,
1651 0, &clk_doubler_lock);
1652 clk = tegra_clk_register_periph_gate("audio0_2x", "audio0_div",
1653 TEGRA_PERIPH_NO_RESET, clk_base,
1654 CLK_SET_RATE_PARENT, 113, &periph_v_regs,
1655 periph_clk_enb_refcnt);
1656 clk_register_clkdev(clk, "audio0_2x", NULL);
1657 clks[audio0_2x] = clk;
1659 /* audio1_2x */
1660 clk = clk_register_fixed_factor(NULL, "audio1_doubler", "audio1",
1661 CLK_SET_RATE_PARENT, 2, 1);
1662 clk = tegra_clk_register_divider("audio1_div", "audio1_doubler",
1663 clk_base + AUDIO_SYNC_DOUBLER, 0, 0, 25, 1,
1664 0, &clk_doubler_lock);
1665 clk = tegra_clk_register_periph_gate("audio1_2x", "audio1_div",
1666 TEGRA_PERIPH_NO_RESET, clk_base,
1667 CLK_SET_RATE_PARENT, 114, &periph_v_regs,
1668 periph_clk_enb_refcnt);
1669 clk_register_clkdev(clk, "audio1_2x", NULL);
1670 clks[audio1_2x] = clk;
1672 /* audio2_2x */
1673 clk = clk_register_fixed_factor(NULL, "audio2_doubler", "audio2",
1674 CLK_SET_RATE_PARENT, 2, 1);
1675 clk = tegra_clk_register_divider("audio2_div", "audio2_doubler",
1676 clk_base + AUDIO_SYNC_DOUBLER, 0, 0, 26, 1,
1677 0, &clk_doubler_lock);
1678 clk = tegra_clk_register_periph_gate("audio2_2x", "audio2_div",
1679 TEGRA_PERIPH_NO_RESET, clk_base,
1680 CLK_SET_RATE_PARENT, 115, &periph_v_regs,
1681 periph_clk_enb_refcnt);
1682 clk_register_clkdev(clk, "audio2_2x", NULL);
1683 clks[audio2_2x] = clk;
1685 /* audio3_2x */
1686 clk = clk_register_fixed_factor(NULL, "audio3_doubler", "audio3",
1687 CLK_SET_RATE_PARENT, 2, 1);
1688 clk = tegra_clk_register_divider("audio3_div", "audio3_doubler",
1689 clk_base + AUDIO_SYNC_DOUBLER, 0, 0, 27, 1,
1690 0, &clk_doubler_lock);
1691 clk = tegra_clk_register_periph_gate("audio3_2x", "audio3_div",
1692 TEGRA_PERIPH_NO_RESET, clk_base,
1693 CLK_SET_RATE_PARENT, 116, &periph_v_regs,
1694 periph_clk_enb_refcnt);
1695 clk_register_clkdev(clk, "audio3_2x", NULL);
1696 clks[audio3_2x] = clk;
1698 /* audio4_2x */
1699 clk = clk_register_fixed_factor(NULL, "audio4_doubler", "audio4",
1700 CLK_SET_RATE_PARENT, 2, 1);
1701 clk = tegra_clk_register_divider("audio4_div", "audio4_doubler",
1702 clk_base + AUDIO_SYNC_DOUBLER, 0, 0, 28, 1,
1703 0, &clk_doubler_lock);
1704 clk = tegra_clk_register_periph_gate("audio4_2x", "audio4_div",
1705 TEGRA_PERIPH_NO_RESET, clk_base,
1706 CLK_SET_RATE_PARENT, 117, &periph_v_regs,
1707 periph_clk_enb_refcnt);
1708 clk_register_clkdev(clk, "audio4_2x", NULL);
1709 clks[audio4_2x] = clk;
1711 /* spdif_2x */
1712 clk = clk_register_fixed_factor(NULL, "spdif_doubler", "spdif",
1713 CLK_SET_RATE_PARENT, 2, 1);
1714 clk = tegra_clk_register_divider("spdif_div", "spdif_doubler",
1715 clk_base + AUDIO_SYNC_DOUBLER, 0, 0, 29, 1,
1716 0, &clk_doubler_lock);
1717 clk = tegra_clk_register_periph_gate("spdif_2x", "spdif_div",
1718 TEGRA_PERIPH_NO_RESET, clk_base,
1719 CLK_SET_RATE_PARENT, 118,
1720 &periph_v_regs, periph_clk_enb_refcnt);
1721 clk_register_clkdev(clk, "spdif_2x", NULL);
1722 clks[spdif_2x] = clk;
1725 static void __init tegra114_pmc_clk_init(void __iomem *pmc_base)
1727 struct clk *clk;
1729 /* clk_out_1 */
1730 clk = clk_register_mux(NULL, "clk_out_1_mux", clk_out1_parents,
1731 ARRAY_SIZE(clk_out1_parents),
1732 CLK_SET_RATE_NO_REPARENT,
1733 pmc_base + PMC_CLK_OUT_CNTRL, 6, 3, 0,
1734 &clk_out_lock);
1735 clks[clk_out_1_mux] = clk;
1736 clk = clk_register_gate(NULL, "clk_out_1", "clk_out_1_mux", 0,
1737 pmc_base + PMC_CLK_OUT_CNTRL, 2, 0,
1738 &clk_out_lock);
1739 clk_register_clkdev(clk, "extern1", "clk_out_1");
1740 clks[clk_out_1] = clk;
1742 /* clk_out_2 */
1743 clk = clk_register_mux(NULL, "clk_out_2_mux", clk_out2_parents,
1744 ARRAY_SIZE(clk_out2_parents),
1745 CLK_SET_RATE_NO_REPARENT,
1746 pmc_base + PMC_CLK_OUT_CNTRL, 14, 3, 0,
1747 &clk_out_lock);
1748 clks[clk_out_2_mux] = clk;
1749 clk = clk_register_gate(NULL, "clk_out_2", "clk_out_2_mux", 0,
1750 pmc_base + PMC_CLK_OUT_CNTRL, 10, 0,
1751 &clk_out_lock);
1752 clk_register_clkdev(clk, "extern2", "clk_out_2");
1753 clks[clk_out_2] = clk;
1755 /* clk_out_3 */
1756 clk = clk_register_mux(NULL, "clk_out_3_mux", clk_out3_parents,
1757 ARRAY_SIZE(clk_out3_parents),
1758 CLK_SET_RATE_NO_REPARENT,
1759 pmc_base + PMC_CLK_OUT_CNTRL, 22, 3, 0,
1760 &clk_out_lock);
1761 clks[clk_out_3_mux] = clk;
1762 clk = clk_register_gate(NULL, "clk_out_3", "clk_out_3_mux", 0,
1763 pmc_base + PMC_CLK_OUT_CNTRL, 18, 0,
1764 &clk_out_lock);
1765 clk_register_clkdev(clk, "extern3", "clk_out_3");
1766 clks[clk_out_3] = clk;
1768 /* blink */
1769 /* clear the blink timer register to directly output clk_32k */
1770 writel_relaxed(0, pmc_base + PMC_BLINK_TIMER);
1771 clk = clk_register_gate(NULL, "blink_override", "clk_32k", 0,
1772 pmc_base + PMC_DPD_PADS_ORIDE,
1773 PMC_DPD_PADS_ORIDE_BLINK_ENB, 0, NULL);
1774 clk = clk_register_gate(NULL, "blink", "blink_override", 0,
1775 pmc_base + PMC_CTRL,
1776 PMC_CTRL_BLINK_ENB, 0, NULL);
1777 clk_register_clkdev(clk, "blink", NULL);
1778 clks[blink] = clk;
1782 static const char *sclk_parents[] = { "clk_m", "pll_c_out1", "pll_p_out4",
1783 "pll_p", "pll_p_out2", "unused",
1784 "clk_32k", "pll_m_out1" };
1786 static const char *cclk_g_parents[] = { "clk_m", "pll_c", "clk_32k", "pll_m",
1787 "pll_p", "pll_p_out4", "unused",
1788 "unused", "pll_x" };
1790 static const char *cclk_lp_parents[] = { "clk_m", "pll_c", "clk_32k", "pll_m",
1791 "pll_p", "pll_p_out4", "unused",
1792 "unused", "pll_x", "pll_x_out0" };
1794 static void __init tegra114_super_clk_init(void __iomem *clk_base)
1796 struct clk *clk;
1798 /* CCLKG */
1799 clk = tegra_clk_register_super_mux("cclk_g", cclk_g_parents,
1800 ARRAY_SIZE(cclk_g_parents),
1801 CLK_SET_RATE_PARENT,
1802 clk_base + CCLKG_BURST_POLICY,
1803 0, 4, 0, 0, NULL);
1804 clk_register_clkdev(clk, "cclk_g", NULL);
1805 clks[cclk_g] = clk;
1807 /* CCLKLP */
1808 clk = tegra_clk_register_super_mux("cclk_lp", cclk_lp_parents,
1809 ARRAY_SIZE(cclk_lp_parents),
1810 CLK_SET_RATE_PARENT,
1811 clk_base + CCLKLP_BURST_POLICY,
1812 0, 4, 8, 9, NULL);
1813 clk_register_clkdev(clk, "cclk_lp", NULL);
1814 clks[cclk_lp] = clk;
1816 /* SCLK */
1817 clk = tegra_clk_register_super_mux("sclk", sclk_parents,
1818 ARRAY_SIZE(sclk_parents),
1819 CLK_SET_RATE_PARENT,
1820 clk_base + SCLK_BURST_POLICY,
1821 0, 4, 0, 0, NULL);
1822 clk_register_clkdev(clk, "sclk", NULL);
1823 clks[sclk] = clk;
1825 /* HCLK */
1826 clk = clk_register_divider(NULL, "hclk_div", "sclk", 0,
1827 clk_base + SYSTEM_CLK_RATE, 4, 2, 0,
1828 &sysrate_lock);
1829 clk = clk_register_gate(NULL, "hclk", "hclk_div", CLK_SET_RATE_PARENT |
1830 CLK_IGNORE_UNUSED, clk_base + SYSTEM_CLK_RATE,
1831 7, CLK_GATE_SET_TO_DISABLE, &sysrate_lock);
1832 clk_register_clkdev(clk, "hclk", NULL);
1833 clks[hclk] = clk;
1835 /* PCLK */
1836 clk = clk_register_divider(NULL, "pclk_div", "hclk", 0,
1837 clk_base + SYSTEM_CLK_RATE, 0, 2, 0,
1838 &sysrate_lock);
1839 clk = clk_register_gate(NULL, "pclk", "pclk_div", CLK_SET_RATE_PARENT |
1840 CLK_IGNORE_UNUSED, clk_base + SYSTEM_CLK_RATE,
1841 3, CLK_GATE_SET_TO_DISABLE, &sysrate_lock);
1842 clk_register_clkdev(clk, "pclk", NULL);
1843 clks[pclk] = clk;
1846 static struct tegra_periph_init_data tegra_periph_clk_list[] = {
1847 TEGRA_INIT_DATA_MUX("i2s0", NULL, "tegra30-i2s.0", mux_pllaout0_audio0_2x_pllp_clkm, CLK_SOURCE_I2S0, 30, &periph_l_regs, TEGRA_PERIPH_ON_APB, i2s0),
1848 TEGRA_INIT_DATA_MUX("i2s1", NULL, "tegra30-i2s.1", mux_pllaout0_audio1_2x_pllp_clkm, CLK_SOURCE_I2S1, 11, &periph_l_regs, TEGRA_PERIPH_ON_APB, i2s1),
1849 TEGRA_INIT_DATA_MUX("i2s2", NULL, "tegra30-i2s.2", mux_pllaout0_audio2_2x_pllp_clkm, CLK_SOURCE_I2S2, 18, &periph_l_regs, TEGRA_PERIPH_ON_APB, i2s2),
1850 TEGRA_INIT_DATA_MUX("i2s3", NULL, "tegra30-i2s.3", mux_pllaout0_audio3_2x_pllp_clkm, CLK_SOURCE_I2S3, 101, &periph_v_regs, TEGRA_PERIPH_ON_APB, i2s3),
1851 TEGRA_INIT_DATA_MUX("i2s4", NULL, "tegra30-i2s.4", mux_pllaout0_audio4_2x_pllp_clkm, CLK_SOURCE_I2S4, 102, &periph_v_regs, TEGRA_PERIPH_ON_APB, i2s4),
1852 TEGRA_INIT_DATA_MUX("spdif_out", "spdif_out", "tegra30-spdif", mux_pllaout0_audio_2x_pllp_clkm, CLK_SOURCE_SPDIF_OUT, 10, &periph_l_regs, TEGRA_PERIPH_ON_APB, spdif_out),
1853 TEGRA_INIT_DATA_MUX("spdif_in", "spdif_in", "tegra30-spdif", mux_pllp_pllc_pllm, CLK_SOURCE_SPDIF_IN, 10, &periph_l_regs, TEGRA_PERIPH_ON_APB, spdif_in),
1854 TEGRA_INIT_DATA_MUX("pwm", NULL, "pwm", mux_pllp_pllc_clk32_clkm, CLK_SOURCE_PWM, 17, &periph_l_regs, TEGRA_PERIPH_ON_APB, pwm),
1855 TEGRA_INIT_DATA_MUX("adx", NULL, "adx", mux_plla_pllc_pllp_clkm, CLK_SOURCE_ADX, 154, &periph_w_regs, TEGRA_PERIPH_ON_APB, adx),
1856 TEGRA_INIT_DATA_MUX("amx", NULL, "amx", mux_plla_pllc_pllp_clkm, CLK_SOURCE_AMX, 153, &periph_w_regs, TEGRA_PERIPH_ON_APB, amx),
1857 TEGRA_INIT_DATA_MUX("hda", "hda", "tegra30-hda", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_HDA, 125, &periph_v_regs, TEGRA_PERIPH_ON_APB, hda),
1858 TEGRA_INIT_DATA_MUX("hda2codec_2x", "hda2codec", "tegra30-hda", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_HDA2CODEC_2X, 111, &periph_v_regs, TEGRA_PERIPH_ON_APB, hda2codec_2x),
1859 TEGRA_INIT_DATA_MUX("sbc1", NULL, "tegra11-spi.0", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SBC1, 41, &periph_h_regs, TEGRA_PERIPH_ON_APB, sbc1),
1860 TEGRA_INIT_DATA_MUX("sbc2", NULL, "tegra11-spi.1", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SBC2, 44, &periph_h_regs, TEGRA_PERIPH_ON_APB, sbc2),
1861 TEGRA_INIT_DATA_MUX("sbc3", NULL, "tegra11-spi.2", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SBC3, 46, &periph_h_regs, TEGRA_PERIPH_ON_APB, sbc3),
1862 TEGRA_INIT_DATA_MUX("sbc4", NULL, "tegra11-spi.3", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SBC4, 68, &periph_u_regs, TEGRA_PERIPH_ON_APB, sbc4),
1863 TEGRA_INIT_DATA_MUX("sbc5", NULL, "tegra11-spi.4", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SBC5, 104, &periph_v_regs, TEGRA_PERIPH_ON_APB, sbc5),
1864 TEGRA_INIT_DATA_MUX("sbc6", NULL, "tegra11-spi.5", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SBC6, 105, &periph_v_regs, TEGRA_PERIPH_ON_APB, sbc6),
1865 TEGRA_INIT_DATA_MUX8("ndflash", NULL, "tegra_nand", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_NDFLASH, 13, &periph_u_regs, TEGRA_PERIPH_ON_APB, ndspeed),
1866 TEGRA_INIT_DATA_MUX8("ndspeed", NULL, "tegra_nand_speed", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_NDSPEED, 80, &periph_u_regs, TEGRA_PERIPH_ON_APB, ndspeed),
1867 TEGRA_INIT_DATA_MUX("vfir", NULL, "vfir", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_VFIR, 7, &periph_l_regs, TEGRA_PERIPH_ON_APB, vfir),
1868 TEGRA_INIT_DATA_MUX("sdmmc1", NULL, "sdhci-tegra.0", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SDMMC1, 14, &periph_l_regs, 0, sdmmc1),
1869 TEGRA_INIT_DATA_MUX("sdmmc2", NULL, "sdhci-tegra.1", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SDMMC2, 9, &periph_l_regs, 0, sdmmc2),
1870 TEGRA_INIT_DATA_MUX("sdmmc3", NULL, "sdhci-tegra.2", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SDMMC3, 69, &periph_u_regs, 0, sdmmc3),
1871 TEGRA_INIT_DATA_MUX("sdmmc4", NULL, "sdhci-tegra.3", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SDMMC4, 15, &periph_l_regs, 0, sdmmc4),
1872 TEGRA_INIT_DATA_INT("vde", NULL, "vde", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_VDE, 61, &periph_h_regs, 0, vde),
1873 TEGRA_INIT_DATA_MUX_FLAGS("csite", NULL, "csite", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_CSITE, 73, &periph_u_regs, TEGRA_PERIPH_ON_APB, csite, CLK_IGNORE_UNUSED),
1874 TEGRA_INIT_DATA_MUX("la", NULL, "la", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_LA, 76, &periph_u_regs, TEGRA_PERIPH_ON_APB, la),
1875 TEGRA_INIT_DATA_MUX("trace", NULL, "trace", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_TRACE, 77, &periph_u_regs, TEGRA_PERIPH_ON_APB, trace),
1876 TEGRA_INIT_DATA_MUX("owr", NULL, "tegra_w1", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_OWR, 71, &periph_u_regs, TEGRA_PERIPH_ON_APB, owr),
1877 TEGRA_INIT_DATA_MUX("nor", NULL, "tegra-nor", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_NOR, 42, &periph_h_regs, 0, nor),
1878 TEGRA_INIT_DATA_MUX("mipi", NULL, "mipi", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_MIPI, 50, &periph_h_regs, TEGRA_PERIPH_ON_APB, mipi),
1879 TEGRA_INIT_DATA_I2C("i2c1", "div-clk", "tegra11-i2c.0", mux_pllp_clkm, CLK_SOURCE_I2C1, 12, &periph_l_regs, i2c1),
1880 TEGRA_INIT_DATA_I2C("i2c2", "div-clk", "tegra11-i2c.1", mux_pllp_clkm, CLK_SOURCE_I2C2, 54, &periph_h_regs, i2c2),
1881 TEGRA_INIT_DATA_I2C("i2c3", "div-clk", "tegra11-i2c.2", mux_pllp_clkm, CLK_SOURCE_I2C3, 67, &periph_u_regs, i2c3),
1882 TEGRA_INIT_DATA_I2C("i2c4", "div-clk", "tegra11-i2c.3", mux_pllp_clkm, CLK_SOURCE_I2C4, 103, &periph_v_regs, i2c4),
1883 TEGRA_INIT_DATA_I2C("i2c5", "div-clk", "tegra11-i2c.4", mux_pllp_clkm, CLK_SOURCE_I2C5, 47, &periph_h_regs, i2c5),
1884 TEGRA_INIT_DATA_UART("uarta", NULL, "tegra_uart.0", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_UARTA, 6, &periph_l_regs, uarta),
1885 TEGRA_INIT_DATA_UART("uartb", NULL, "tegra_uart.1", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_UARTB, 7, &periph_l_regs, uartb),
1886 TEGRA_INIT_DATA_UART("uartc", NULL, "tegra_uart.2", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_UARTC, 55, &periph_h_regs, uartc),
1887 TEGRA_INIT_DATA_UART("uartd", NULL, "tegra_uart.3", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_UARTD, 65, &periph_u_regs, uartd),
1888 TEGRA_INIT_DATA_INT("3d", NULL, "3d", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_3D, 24, &periph_l_regs, 0, gr_3d),
1889 TEGRA_INIT_DATA_INT("2d", NULL, "2d", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_2D, 21, &periph_l_regs, 0, gr_2d),
1890 TEGRA_INIT_DATA_MUX("vi_sensor", "vi_sensor", "tegra_camera", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_VI_SENSOR, 20, &periph_l_regs, TEGRA_PERIPH_NO_RESET, vi_sensor),
1891 TEGRA_INIT_DATA_INT8("vi", "vi", "tegra_camera", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_VI, 20, &periph_l_regs, 0, vi),
1892 TEGRA_INIT_DATA_INT8("epp", NULL, "epp", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_EPP, 19, &periph_l_regs, 0, epp),
1893 TEGRA_INIT_DATA_INT8("msenc", NULL, "msenc", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_MSENC, 91, &periph_u_regs, TEGRA_PERIPH_WAR_1005168, msenc),
1894 TEGRA_INIT_DATA_INT8("tsec", NULL, "tsec", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_TSEC, 83, &periph_u_regs, 0, tsec),
1895 TEGRA_INIT_DATA_INT8("host1x", NULL, "host1x", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_HOST1X, 28, &periph_l_regs, 0, host1x),
1896 TEGRA_INIT_DATA_MUX8("hdmi", NULL, "hdmi", mux_pllp_pllm_plld_plla_pllc_plld2_clkm, CLK_SOURCE_HDMI, 51, &periph_h_regs, 0, hdmi),
1897 TEGRA_INIT_DATA_MUX("cilab", "cilab", "tegra_camera", mux_pllp_pllc_clkm, CLK_SOURCE_CILAB, 144, &periph_w_regs, 0, cilab),
1898 TEGRA_INIT_DATA_MUX("cilcd", "cilcd", "tegra_camera", mux_pllp_pllc_clkm, CLK_SOURCE_CILCD, 145, &periph_w_regs, 0, cilcd),
1899 TEGRA_INIT_DATA_MUX("cile", "cile", "tegra_camera", mux_pllp_pllc_clkm, CLK_SOURCE_CILE, 146, &periph_w_regs, 0, cile),
1900 TEGRA_INIT_DATA_MUX("dsialp", "dsialp", "tegradc.0", mux_pllp_pllc_clkm, CLK_SOURCE_DSIALP, 147, &periph_w_regs, 0, dsialp),
1901 TEGRA_INIT_DATA_MUX("dsiblp", "dsiblp", "tegradc.1", mux_pllp_pllc_clkm, CLK_SOURCE_DSIBLP, 148, &periph_w_regs, 0, dsiblp),
1902 TEGRA_INIT_DATA_MUX("tsensor", NULL, "tegra-tsensor", mux_pllp_pllc_clkm_clk32, CLK_SOURCE_TSENSOR, 100, &periph_v_regs, TEGRA_PERIPH_ON_APB, tsensor),
1903 TEGRA_INIT_DATA_MUX("actmon", NULL, "actmon", mux_pllp_pllc_clk32_clkm, CLK_SOURCE_ACTMON, 119, &periph_v_regs, 0, actmon),
1904 TEGRA_INIT_DATA_MUX8("extern1", NULL, "extern1", mux_plla_clk32_pllp_clkm_plle, CLK_SOURCE_EXTERN1, 120, &periph_v_regs, 0, extern1),
1905 TEGRA_INIT_DATA_MUX8("extern2", NULL, "extern2", mux_plla_clk32_pllp_clkm_plle, CLK_SOURCE_EXTERN2, 121, &periph_v_regs, 0, extern2),
1906 TEGRA_INIT_DATA_MUX8("extern3", NULL, "extern3", mux_plla_clk32_pllp_clkm_plle, CLK_SOURCE_EXTERN3, 122, &periph_v_regs, 0, extern3),
1907 TEGRA_INIT_DATA_MUX("i2cslow", NULL, "i2cslow", mux_pllp_pllc_clk32_clkm, CLK_SOURCE_I2CSLOW, 81, &periph_u_regs, TEGRA_PERIPH_ON_APB, i2cslow),
1908 TEGRA_INIT_DATA_INT8("se", NULL, "se", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_SE, 127, &periph_v_regs, TEGRA_PERIPH_ON_APB, se),
1909 TEGRA_INIT_DATA_INT_FLAGS("mselect", NULL, "mselect", mux_pllp_clkm, CLK_SOURCE_MSELECT, 99, &periph_v_regs, 0, mselect, CLK_IGNORE_UNUSED),
1910 TEGRA_INIT_DATA_MUX("dfll_ref", "ref", "t114_dfll", mux_pllp_clkm, CLK_SOURCE_DFLL_REF, 155, &periph_w_regs, TEGRA_PERIPH_ON_APB, dfll_ref),
1911 TEGRA_INIT_DATA_MUX("dfll_soc", "soc", "t114_dfll", mux_pllp_clkm, CLK_SOURCE_DFLL_SOC, 155, &periph_w_regs, TEGRA_PERIPH_ON_APB, dfll_soc),
1912 TEGRA_INIT_DATA_MUX8("soc_therm", NULL, "soc_therm", mux_pllm_pllc_pllp_plla, CLK_SOURCE_SOC_THERM, 78, &periph_u_regs, TEGRA_PERIPH_ON_APB, soc_therm),
1913 TEGRA_INIT_DATA_XUSB("xusb_host_src", "host_src", "tegra_xhci", mux_clkm_pllp_pllc_pllre, CLK_SOURCE_XUSB_HOST_SRC, 143, &periph_w_regs, TEGRA_PERIPH_ON_APB | TEGRA_PERIPH_NO_RESET, xusb_host_src),
1914 TEGRA_INIT_DATA_XUSB("xusb_falcon_src", "falcon_src", "tegra_xhci", mux_clkm_pllp_pllc_pllre, CLK_SOURCE_XUSB_FALCON_SRC, 143, &periph_w_regs, TEGRA_PERIPH_NO_RESET, xusb_falcon_src),
1915 TEGRA_INIT_DATA_XUSB("xusb_fs_src", "fs_src", "tegra_xhci", mux_clkm_48M_pllp_480M, CLK_SOURCE_XUSB_FS_SRC, 143, &periph_w_regs, TEGRA_PERIPH_NO_RESET, xusb_fs_src),
1916 TEGRA_INIT_DATA_XUSB("xusb_ss_src", "ss_src", "tegra_xhci", mux_clkm_pllre_clk32_480M_pllc_ref, CLK_SOURCE_XUSB_SS_SRC, 143, &periph_w_regs, TEGRA_PERIPH_NO_RESET, xusb_ss_src),
1917 TEGRA_INIT_DATA_XUSB("xusb_dev_src", "dev_src", "tegra_xhci", mux_clkm_pllp_pllc_pllre, CLK_SOURCE_XUSB_DEV_SRC, 95, &periph_u_regs, TEGRA_PERIPH_ON_APB | TEGRA_PERIPH_NO_RESET, xusb_dev_src),
1918 TEGRA_INIT_DATA_AUDIO("d_audio", "d_audio", "tegra30-ahub", CLK_SOURCE_D_AUDIO, 106, &periph_v_regs, TEGRA_PERIPH_ON_APB, d_audio),
1919 TEGRA_INIT_DATA_AUDIO("dam0", NULL, "tegra30-dam.0", CLK_SOURCE_DAM0, 108, &periph_v_regs, TEGRA_PERIPH_ON_APB, dam0),
1920 TEGRA_INIT_DATA_AUDIO("dam1", NULL, "tegra30-dam.1", CLK_SOURCE_DAM1, 109, &periph_v_regs, TEGRA_PERIPH_ON_APB, dam1),
1921 TEGRA_INIT_DATA_AUDIO("dam2", NULL, "tegra30-dam.2", CLK_SOURCE_DAM2, 110, &periph_v_regs, TEGRA_PERIPH_ON_APB, dam2),
1924 static struct tegra_periph_init_data tegra_periph_nodiv_clk_list[] = {
1925 TEGRA_INIT_DATA_NODIV("disp1", NULL, "tegradc.0", mux_pllp_pllm_plld_plla_pllc_plld2_clkm, CLK_SOURCE_DISP1, 29, 7, 27, &periph_l_regs, 0, disp1),
1926 TEGRA_INIT_DATA_NODIV("disp2", NULL, "tegradc.1", mux_pllp_pllm_plld_plla_pllc_plld2_clkm, CLK_SOURCE_DISP2, 29, 7, 26, &periph_l_regs, 0, disp2),
1929 static __init void tegra114_periph_clk_init(void __iomem *clk_base)
1931 struct tegra_periph_init_data *data;
1932 struct clk *clk;
1933 int i;
1934 u32 val;
1936 /* apbdma */
1937 clk = tegra_clk_register_periph_gate("apbdma", "clk_m", 0, clk_base,
1938 0, 34, &periph_h_regs,
1939 periph_clk_enb_refcnt);
1940 clks[apbdma] = clk;
1942 /* rtc */
1943 clk = tegra_clk_register_periph_gate("rtc", "clk_32k",
1944 TEGRA_PERIPH_ON_APB |
1945 TEGRA_PERIPH_NO_RESET, clk_base,
1946 0, 4, &periph_l_regs,
1947 periph_clk_enb_refcnt);
1948 clk_register_clkdev(clk, NULL, "rtc-tegra");
1949 clks[rtc] = clk;
1951 /* kbc */
1952 clk = tegra_clk_register_periph_gate("kbc", "clk_32k",
1953 TEGRA_PERIPH_ON_APB |
1954 TEGRA_PERIPH_NO_RESET, clk_base,
1955 0, 36, &periph_h_regs,
1956 periph_clk_enb_refcnt);
1957 clks[kbc] = clk;
1959 /* timer */
1960 clk = tegra_clk_register_periph_gate("timer", "clk_m", 0, clk_base,
1961 0, 5, &periph_l_regs,
1962 periph_clk_enb_refcnt);
1963 clk_register_clkdev(clk, NULL, "timer");
1964 clks[timer] = clk;
1966 /* kfuse */
1967 clk = tegra_clk_register_periph_gate("kfuse", "clk_m",
1968 TEGRA_PERIPH_ON_APB, clk_base, 0, 40,
1969 &periph_h_regs, periph_clk_enb_refcnt);
1970 clks[kfuse] = clk;
1972 /* fuse */
1973 clk = tegra_clk_register_periph_gate("fuse", "clk_m",
1974 TEGRA_PERIPH_ON_APB, clk_base, 0, 39,
1975 &periph_h_regs, periph_clk_enb_refcnt);
1976 clks[fuse] = clk;
1978 /* fuse_burn */
1979 clk = tegra_clk_register_periph_gate("fuse_burn", "clk_m",
1980 TEGRA_PERIPH_ON_APB, clk_base, 0, 39,
1981 &periph_h_regs, periph_clk_enb_refcnt);
1982 clks[fuse_burn] = clk;
1984 /* apbif */
1985 clk = tegra_clk_register_periph_gate("apbif", "clk_m",
1986 TEGRA_PERIPH_ON_APB, clk_base, 0, 107,
1987 &periph_v_regs, periph_clk_enb_refcnt);
1988 clks[apbif] = clk;
1990 /* hda2hdmi */
1991 clk = tegra_clk_register_periph_gate("hda2hdmi", "clk_m",
1992 TEGRA_PERIPH_ON_APB, clk_base, 0, 128,
1993 &periph_w_regs, periph_clk_enb_refcnt);
1994 clks[hda2hdmi] = clk;
1996 /* vcp */
1997 clk = tegra_clk_register_periph_gate("vcp", "clk_m", 0, clk_base, 0,
1998 29, &periph_l_regs,
1999 periph_clk_enb_refcnt);
2000 clks[vcp] = clk;
2002 /* bsea */
2003 clk = tegra_clk_register_periph_gate("bsea", "clk_m", 0, clk_base,
2004 0, 62, &periph_h_regs,
2005 periph_clk_enb_refcnt);
2006 clks[bsea] = clk;
2008 /* bsev */
2009 clk = tegra_clk_register_periph_gate("bsev", "clk_m", 0, clk_base,
2010 0, 63, &periph_h_regs,
2011 periph_clk_enb_refcnt);
2012 clks[bsev] = clk;
2014 /* mipi-cal */
2015 clk = tegra_clk_register_periph_gate("mipi-cal", "clk_m", 0, clk_base,
2016 0, 56, &periph_h_regs,
2017 periph_clk_enb_refcnt);
2018 clks[mipi_cal] = clk;
2020 /* usbd */
2021 clk = tegra_clk_register_periph_gate("usbd", "clk_m", 0, clk_base,
2022 0, 22, &periph_l_regs,
2023 periph_clk_enb_refcnt);
2024 clks[usbd] = clk;
2026 /* usb2 */
2027 clk = tegra_clk_register_periph_gate("usb2", "clk_m", 0, clk_base,
2028 0, 58, &periph_h_regs,
2029 periph_clk_enb_refcnt);
2030 clks[usb2] = clk;
2032 /* usb3 */
2033 clk = tegra_clk_register_periph_gate("usb3", "clk_m", 0, clk_base,
2034 0, 59, &periph_h_regs,
2035 periph_clk_enb_refcnt);
2036 clks[usb3] = clk;
2038 /* csi */
2039 clk = tegra_clk_register_periph_gate("csi", "pll_p_out3", 0, clk_base,
2040 0, 52, &periph_h_regs,
2041 periph_clk_enb_refcnt);
2042 clks[csi] = clk;
2044 /* isp */
2045 clk = tegra_clk_register_periph_gate("isp", "clk_m", 0, clk_base, 0,
2046 23, &periph_l_regs,
2047 periph_clk_enb_refcnt);
2048 clks[isp] = clk;
2050 /* csus */
2051 clk = tegra_clk_register_periph_gate("csus", "clk_m",
2052 TEGRA_PERIPH_NO_RESET, clk_base, 0, 92,
2053 &periph_u_regs, periph_clk_enb_refcnt);
2054 clks[csus] = clk;
2056 /* dds */
2057 clk = tegra_clk_register_periph_gate("dds", "clk_m",
2058 TEGRA_PERIPH_ON_APB, clk_base, 0, 150,
2059 &periph_w_regs, periph_clk_enb_refcnt);
2060 clks[dds] = clk;
2062 /* dp2 */
2063 clk = tegra_clk_register_periph_gate("dp2", "clk_m",
2064 TEGRA_PERIPH_ON_APB, clk_base, 0, 152,
2065 &periph_w_regs, periph_clk_enb_refcnt);
2066 clks[dp2] = clk;
2068 /* dtv */
2069 clk = tegra_clk_register_periph_gate("dtv", "clk_m",
2070 TEGRA_PERIPH_ON_APB, clk_base, 0, 79,
2071 &periph_u_regs, periph_clk_enb_refcnt);
2072 clks[dtv] = clk;
2074 /* dsia */
2075 clk = clk_register_mux(NULL, "dsia_mux", mux_plld_out0_plld2_out0,
2076 ARRAY_SIZE(mux_plld_out0_plld2_out0),
2077 CLK_SET_RATE_NO_REPARENT,
2078 clk_base + PLLD_BASE, 25, 1, 0, &pll_d_lock);
2079 clks[dsia_mux] = clk;
2080 clk = tegra_clk_register_periph_gate("dsia", "dsia_mux", 0, clk_base,
2081 0, 48, &periph_h_regs,
2082 periph_clk_enb_refcnt);
2083 clks[dsia] = clk;
2085 /* dsib */
2086 clk = clk_register_mux(NULL, "dsib_mux", mux_plld_out0_plld2_out0,
2087 ARRAY_SIZE(mux_plld_out0_plld2_out0),
2088 CLK_SET_RATE_NO_REPARENT,
2089 clk_base + PLLD2_BASE, 25, 1, 0, &pll_d2_lock);
2090 clks[dsib_mux] = clk;
2091 clk = tegra_clk_register_periph_gate("dsib", "dsib_mux", 0, clk_base,
2092 0, 82, &periph_u_regs,
2093 periph_clk_enb_refcnt);
2094 clks[dsib] = clk;
2096 /* xusb_hs_src */
2097 val = readl(clk_base + CLK_SOURCE_XUSB_SS_SRC);
2098 val |= BIT(25); /* always select PLLU_60M */
2099 writel(val, clk_base + CLK_SOURCE_XUSB_SS_SRC);
2101 clk = clk_register_fixed_factor(NULL, "xusb_hs_src", "pll_u_60M", 0,
2102 1, 1);
2103 clks[xusb_hs_src] = clk;
2105 /* xusb_host */
2106 clk = tegra_clk_register_periph_gate("xusb_host", "xusb_host_src", 0,
2107 clk_base, 0, 89, &periph_u_regs,
2108 periph_clk_enb_refcnt);
2109 clks[xusb_host] = clk;
2111 /* xusb_ss */
2112 clk = tegra_clk_register_periph_gate("xusb_ss", "xusb_ss_src", 0,
2113 clk_base, 0, 156, &periph_w_regs,
2114 periph_clk_enb_refcnt);
2115 clks[xusb_host] = clk;
2117 /* xusb_dev */
2118 clk = tegra_clk_register_periph_gate("xusb_dev", "xusb_dev_src", 0,
2119 clk_base, 0, 95, &periph_u_regs,
2120 periph_clk_enb_refcnt);
2121 clks[xusb_dev] = clk;
2123 /* emc */
2124 clk = clk_register_mux(NULL, "emc_mux", mux_pllmcp_clkm,
2125 ARRAY_SIZE(mux_pllmcp_clkm),
2126 CLK_SET_RATE_NO_REPARENT,
2127 clk_base + CLK_SOURCE_EMC,
2128 29, 3, 0, NULL);
2129 clk = tegra_clk_register_periph_gate("emc", "emc_mux", 0, clk_base,
2130 CLK_IGNORE_UNUSED, 57, &periph_h_regs,
2131 periph_clk_enb_refcnt);
2132 clks[emc] = clk;
2134 for (i = 0; i < ARRAY_SIZE(tegra_periph_clk_list); i++) {
2135 data = &tegra_periph_clk_list[i];
2136 clk = tegra_clk_register_periph(data->name, data->parent_names,
2137 data->num_parents, &data->periph,
2138 clk_base, data->offset, data->flags);
2139 clks[data->clk_id] = clk;
2142 for (i = 0; i < ARRAY_SIZE(tegra_periph_nodiv_clk_list); i++) {
2143 data = &tegra_periph_nodiv_clk_list[i];
2144 clk = tegra_clk_register_periph_nodiv(data->name,
2145 data->parent_names, data->num_parents,
2146 &data->periph, clk_base, data->offset);
2147 clks[data->clk_id] = clk;
2151 /* Tegra114 CPU clock and reset control functions */
2152 static void tegra114_wait_cpu_in_reset(u32 cpu)
2154 unsigned int reg;
2156 do {
2157 reg = readl(clk_base + CLK_RST_CONTROLLER_CPU_CMPLX_STATUS);
2158 cpu_relax();
2159 } while (!(reg & (1 << cpu))); /* check CPU been reset or not */
2161 static void tegra114_disable_cpu_clock(u32 cpu)
2163 /* flow controller would take care in the power sequence. */
2166 #ifdef CONFIG_PM_SLEEP
2167 static void tegra114_cpu_clock_suspend(void)
2169 /* switch coresite to clk_m, save off original source */
2170 tegra114_cpu_clk_sctx.clk_csite_src =
2171 readl(clk_base + CLK_SOURCE_CSITE);
2172 writel(3 << 30, clk_base + CLK_SOURCE_CSITE);
2174 tegra114_cpu_clk_sctx.cclkg_burst =
2175 readl(clk_base + CCLKG_BURST_POLICY);
2176 tegra114_cpu_clk_sctx.cclkg_divider =
2177 readl(clk_base + CCLKG_BURST_POLICY + 4);
2180 static void tegra114_cpu_clock_resume(void)
2182 writel(tegra114_cpu_clk_sctx.clk_csite_src,
2183 clk_base + CLK_SOURCE_CSITE);
2185 writel(tegra114_cpu_clk_sctx.cclkg_burst,
2186 clk_base + CCLKG_BURST_POLICY);
2187 writel(tegra114_cpu_clk_sctx.cclkg_divider,
2188 clk_base + CCLKG_BURST_POLICY + 4);
2190 #endif
2192 static struct tegra_cpu_car_ops tegra114_cpu_car_ops = {
2193 .wait_for_reset = tegra114_wait_cpu_in_reset,
2194 .disable_clock = tegra114_disable_cpu_clock,
2195 #ifdef CONFIG_PM_SLEEP
2196 .suspend = tegra114_cpu_clock_suspend,
2197 .resume = tegra114_cpu_clock_resume,
2198 #endif
2201 static const struct of_device_id pmc_match[] __initconst = {
2202 { .compatible = "nvidia,tegra114-pmc" },
2207 * dfll_soc/dfll_ref apparently must be kept enabled, otherwise I2C5
2208 * breaks
2210 static struct tegra_clk_init_table init_table[] __initdata = {
2211 {uarta, pll_p, 408000000, 0},
2212 {uartb, pll_p, 408000000, 0},
2213 {uartc, pll_p, 408000000, 0},
2214 {uartd, pll_p, 408000000, 0},
2215 {pll_a, clk_max, 564480000, 1},
2216 {pll_a_out0, clk_max, 11289600, 1},
2217 {extern1, pll_a_out0, 0, 1},
2218 {clk_out_1_mux, extern1, 0, 1},
2219 {clk_out_1, clk_max, 0, 1},
2220 {i2s0, pll_a_out0, 11289600, 0},
2221 {i2s1, pll_a_out0, 11289600, 0},
2222 {i2s2, pll_a_out0, 11289600, 0},
2223 {i2s3, pll_a_out0, 11289600, 0},
2224 {i2s4, pll_a_out0, 11289600, 0},
2225 {dfll_soc, pll_p, 51000000, 1},
2226 {dfll_ref, pll_p, 51000000, 1},
2227 {clk_max, clk_max, 0, 0}, /* This MUST be the last entry. */
2230 static void __init tegra114_clock_apply_init_table(void)
2232 tegra_init_from_table(init_table, clks, clk_max);
2237 * tegra114_car_barrier - wait for pending writes to the CAR to complete
2239 * Wait for any outstanding writes to the CAR MMIO space from this CPU
2240 * to complete before continuing execution. No return value.
2242 static void tegra114_car_barrier(void)
2244 wmb(); /* probably unnecessary */
2245 readl_relaxed(clk_base + CPU_FINETRIM_SELECT);
2249 * tegra114_clock_tune_cpu_trimmers_high - use high-voltage propagation delays
2251 * When the CPU rail voltage is in the high-voltage range, use the
2252 * built-in hardwired clock propagation delays in the CPU clock
2253 * shaper. No return value.
2255 void tegra114_clock_tune_cpu_trimmers_high(void)
2257 u32 select = 0;
2259 /* Use hardwired rise->rise & fall->fall clock propagation delays */
2260 select |= ~(CPU_FINETRIM_1_FCPU_1 | CPU_FINETRIM_1_FCPU_2 |
2261 CPU_FINETRIM_1_FCPU_3 | CPU_FINETRIM_1_FCPU_4 |
2262 CPU_FINETRIM_1_FCPU_5 | CPU_FINETRIM_1_FCPU_6);
2263 writel_relaxed(select, clk_base + CPU_FINETRIM_SELECT);
2265 tegra114_car_barrier();
2267 EXPORT_SYMBOL(tegra114_clock_tune_cpu_trimmers_high);
2270 * tegra114_clock_tune_cpu_trimmers_low - use low-voltage propagation delays
2272 * When the CPU rail voltage is in the low-voltage range, use the
2273 * extended clock propagation delays set by
2274 * tegra114_clock_tune_cpu_trimmers_init(). The intention is to
2275 * maintain the input clock duty cycle that the FCPU subsystem
2276 * expects. No return value.
2278 void tegra114_clock_tune_cpu_trimmers_low(void)
2280 u32 select = 0;
2283 * Use software-specified rise->rise & fall->fall clock
2284 * propagation delays (from
2285 * tegra114_clock_tune_cpu_trimmers_init()
2287 select |= (CPU_FINETRIM_1_FCPU_1 | CPU_FINETRIM_1_FCPU_2 |
2288 CPU_FINETRIM_1_FCPU_3 | CPU_FINETRIM_1_FCPU_4 |
2289 CPU_FINETRIM_1_FCPU_5 | CPU_FINETRIM_1_FCPU_6);
2290 writel_relaxed(select, clk_base + CPU_FINETRIM_SELECT);
2292 tegra114_car_barrier();
2294 EXPORT_SYMBOL(tegra114_clock_tune_cpu_trimmers_low);
2297 * tegra114_clock_tune_cpu_trimmers_init - set up and enable clk prop delays
2299 * Program extended clock propagation delays into the FCPU clock
2300 * shaper and enable them. XXX Define the purpose - peak current
2301 * reduction? No return value.
2303 /* XXX Initial voltage rail state assumption issues? */
2304 void tegra114_clock_tune_cpu_trimmers_init(void)
2306 u32 dr = 0, r = 0;
2308 /* Increment the rise->rise clock delay by four steps */
2309 r |= (CPU_FINETRIM_R_FCPU_1_MASK | CPU_FINETRIM_R_FCPU_2_MASK |
2310 CPU_FINETRIM_R_FCPU_3_MASK | CPU_FINETRIM_R_FCPU_4_MASK |
2311 CPU_FINETRIM_R_FCPU_5_MASK | CPU_FINETRIM_R_FCPU_6_MASK);
2312 writel_relaxed(r, clk_base + CPU_FINETRIM_R);
2315 * Use the rise->rise clock propagation delay specified in the
2316 * r field
2318 dr |= (CPU_FINETRIM_1_FCPU_1 | CPU_FINETRIM_1_FCPU_2 |
2319 CPU_FINETRIM_1_FCPU_3 | CPU_FINETRIM_1_FCPU_4 |
2320 CPU_FINETRIM_1_FCPU_5 | CPU_FINETRIM_1_FCPU_6);
2321 writel_relaxed(dr, clk_base + CPU_FINETRIM_DR);
2323 tegra114_clock_tune_cpu_trimmers_low();
2325 EXPORT_SYMBOL(tegra114_clock_tune_cpu_trimmers_init);
2328 * tegra114_clock_assert_dfll_dvco_reset - assert the DFLL's DVCO reset
2330 * Assert the reset line of the DFLL's DVCO. No return value.
2332 void tegra114_clock_assert_dfll_dvco_reset(void)
2334 u32 v;
2336 v = readl_relaxed(clk_base + RST_DFLL_DVCO);
2337 v |= (1 << DVFS_DFLL_RESET_SHIFT);
2338 writel_relaxed(v, clk_base + RST_DFLL_DVCO);
2339 tegra114_car_barrier();
2341 EXPORT_SYMBOL(tegra114_clock_assert_dfll_dvco_reset);
2344 * tegra114_clock_deassert_dfll_dvco_reset - deassert the DFLL's DVCO reset
2346 * Deassert the reset line of the DFLL's DVCO, allowing the DVCO to
2347 * operate. No return value.
2349 void tegra114_clock_deassert_dfll_dvco_reset(void)
2351 u32 v;
2353 v = readl_relaxed(clk_base + RST_DFLL_DVCO);
2354 v &= ~(1 << DVFS_DFLL_RESET_SHIFT);
2355 writel_relaxed(v, clk_base + RST_DFLL_DVCO);
2356 tegra114_car_barrier();
2358 EXPORT_SYMBOL(tegra114_clock_deassert_dfll_dvco_reset);
2360 static void __init tegra114_clock_init(struct device_node *np)
2362 struct device_node *node;
2363 int i;
2365 clk_base = of_iomap(np, 0);
2366 if (!clk_base) {
2367 pr_err("ioremap tegra114 CAR failed\n");
2368 return;
2371 node = of_find_matching_node(NULL, pmc_match);
2372 if (!node) {
2373 pr_err("Failed to find pmc node\n");
2374 WARN_ON(1);
2375 return;
2378 pmc_base = of_iomap(node, 0);
2379 if (!pmc_base) {
2380 pr_err("Can't map pmc registers\n");
2381 WARN_ON(1);
2382 return;
2385 if (tegra114_osc_clk_init(clk_base) < 0)
2386 return;
2388 tegra114_fixed_clk_init(clk_base);
2389 tegra114_pll_init(clk_base, pmc_base);
2390 tegra114_periph_clk_init(clk_base);
2391 tegra114_audio_clk_init(clk_base);
2392 tegra114_pmc_clk_init(pmc_base);
2393 tegra114_super_clk_init(clk_base);
2395 for (i = 0; i < ARRAY_SIZE(clks); i++) {
2396 if (IS_ERR(clks[i])) {
2397 pr_err
2398 ("Tegra114 clk %d: register failed with %ld\n",
2399 i, PTR_ERR(clks[i]));
2401 if (!clks[i])
2402 clks[i] = ERR_PTR(-EINVAL);
2405 clk_data.clks = clks;
2406 clk_data.clk_num = ARRAY_SIZE(clks);
2407 of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data);
2409 tegra_clk_apply_init_table = tegra114_clock_apply_init_table;
2411 tegra_cpu_car_ops = &tegra114_cpu_car_ops;
2413 CLK_OF_DECLARE(tegra114, "nvidia,tegra114-car", tegra114_clock_init);