22 #include <linux/kernel.h>
23 #include <linux/module.h>
24 #include <linux/list.h>
40 #define DEFINE_CLK_TEGRA(_name, _rate, _ops, _flags, \
41 _parent_names, _parents, _parent) \
42 static struct clk tegra_##_name = { \
43 .hw = &tegra_##_name##_hw.hw, \
48 .parent_names = _parent_names, \
49 .parents = _parents, \
50 .num_parents = ARRAY_SIZE(_parent_names), \
54 static struct clk tegra_clk_32k;
55 static struct clk_tegra tegra_clk_32k_hw = {
57 .clk = &tegra_clk_32k,
62 static struct clk tegra_clk_32k = {
66 .hw = &tegra_clk_32k_hw.
hw,
70 static struct clk tegra_clk_m;
71 static struct clk_tegra tegra_clk_m_hw = {
82 static struct clk tegra_clk_m = {
85 .hw = &tegra_clk_m_hw.
hw,
89 #define DEFINE_PLL(_name, _flags, _reg, _max_rate, _input_min, \
90 _input_max, _cf_min, _cf_max, _vco_min, \
91 _vco_max, _freq_table, _lock_delay, _ops, \
92 _fixed_rate, _parent) \
93 static const char *tegra_##_name##_parent_names[] = { \
96 static struct clk *tegra_##_name##_parents[] = { \
99 static struct clk tegra_##_name; \
100 static struct clk_tegra tegra_##_name##_hw = { \
102 .clk = &tegra_##_name, \
106 .max_rate = _max_rate, \
108 .input_min = _input_min, \
109 .input_max = _input_max, \
112 .vco_min = _vco_min, \
113 .vco_max = _vco_max, \
114 .freq_table = _freq_table, \
115 .lock_delay = _lock_delay, \
116 .fixed_rate = _fixed_rate, \
119 static struct clk tegra_##_name = { \
122 .hw = &tegra_##_name##_hw.hw, \
123 .parent = &tegra_##_parent, \
124 .parent_names = tegra_##_name##_parent_names, \
125 .parents = tegra_##_name##_parents, \
129 #define DEFINE_PLL_OUT(_name, _flags, _reg, _reg_shift, \
130 _max_rate, _ops, _parent, _clk_flags) \
131 static const char *tegra_##_name##_parent_names[] = { \
134 static struct clk *tegra_##_name##_parents[] = { \
137 static struct clk tegra_##_name; \
138 static struct clk_tegra tegra_##_name##_hw = { \
140 .clk = &tegra_##_name, \
144 .max_rate = _max_rate, \
145 .reg_shift = _reg_shift, \
147 static struct clk tegra_##_name = { \
149 .ops = &tegra_pll_div_ops, \
150 .hw = &tegra_##_name##_hw.hw, \
151 .parent = &tegra_##_parent, \
152 .parent_names = tegra_##_name##_parent_names, \
153 .parents = tegra_##_name##_parents, \
155 .flags = _clk_flags, \
160 {32768, 12000000, 366, 1, 1, 0},
161 {32768, 13000000, 397, 1, 1, 0},
162 {32768, 19200000, 586, 1, 1, 0},
163 {32768, 26000000, 793, 1, 1, 0},
168 0, 12000000, 26000000, tegra_pll_s_freq_table, 300,
172 { 12000000, 600000000, 600, 12, 1, 8 },
173 { 13000000, 600000000, 600, 13, 1, 8 },
174 { 19200000, 600000000, 500, 16, 1, 6 },
175 { 26000000, 600000000, 600, 26, 1, 8 },
176 { 0, 0, 0, 0, 0, 0 },
180 6000000, 20000000, 1400000000, tegra_pll_c_freq_table, 300,
187 { 12000000, 666000000, 666, 12, 1, 8},
188 { 13000000, 666000000, 666, 13, 1, 8},
189 { 19200000, 666000000, 555, 16, 1, 8},
190 { 26000000, 666000000, 666, 26, 1, 8},
191 { 12000000, 600000000, 600, 12, 1, 8},
192 { 13000000, 600000000, 600, 13, 1, 8},
193 { 19200000, 600000000, 375, 12, 1, 6},
194 { 26000000, 600000000, 600, 26, 1, 8},
195 { 0, 0, 0, 0, 0, 0 },
199 6000000, 20000000, 1200000000, tegra_pll_m_freq_table, 300,
206 { 12000000, 216000000, 432, 12, 2, 8},
207 { 13000000, 216000000, 432, 13, 2, 8},
208 { 19200000, 216000000, 90, 4, 2, 1},
209 { 26000000, 216000000, 432, 26, 2, 8},
210 { 12000000, 432000000, 432, 12, 1, 8},
211 { 13000000, 432000000, 432, 13, 1, 8},
212 { 19200000, 432000000, 90, 4, 1, 1},
213 { 26000000, 432000000, 432, 26, 1, 8},
214 { 0, 0, 0, 0, 0, 0 },
219 2000000, 31000000, 1000000, 6000000, 20000000, 1400000000,
220 tegra_pll_p_freq_table, 300,
tegra_pll_ops, 216000000, clk_m);
232 { 28800000, 56448000, 49, 25, 1, 1},
233 { 28800000, 73728000, 64, 25, 1, 1},
234 { 28800000, 24000000, 5, 6, 1, 1},
235 { 0, 0, 0, 0, 0, 0 },
239 6000000, 20000000, 1400000000, tegra_pll_a_freq_table, 300,
246 { 12000000, 216000000, 216, 12, 1, 4},
247 { 13000000, 216000000, 216, 13, 1, 4},
248 { 19200000, 216000000, 135, 12, 1, 3},
249 { 26000000, 216000000, 216, 26, 1, 4},
251 { 12000000, 594000000, 594, 12, 1, 8},
252 { 13000000, 594000000, 594, 13, 1, 8},
253 { 19200000, 594000000, 495, 16, 1, 8},
254 { 26000000, 594000000, 594, 26, 1, 8},
256 { 12000000, 1000000000, 1000, 12, 1, 12},
257 { 13000000, 1000000000, 1000, 13, 1, 12},
258 { 19200000, 1000000000, 625, 12, 1, 8},
259 { 26000000, 1000000000, 1000, 26, 1, 12},
261 { 0, 0, 0, 0, 0, 0 },
265 1000000, 6000000, 40000000, 1000000000, tegra_pll_d_freq_table,
272 { 12000000, 480000000, 960, 12, 2, 0},
273 { 13000000, 480000000, 960, 13, 2, 0},
274 { 19200000, 480000000, 200, 4, 2, 0},
275 { 26000000, 480000000, 960, 26, 2, 0},
276 { 0, 0, 0, 0, 0, 0 },
279 DEFINE_PLL(pll_u,
PLLU, 0xc0, 480000000, 2000000, 40000000, 1000000, 6000000,
280 48000000, 960000000, tegra_pll_u_freq_table, 1000,
285 { 12000000, 1000000000, 1000, 12, 1, 12},
286 { 13000000, 1000000000, 1000, 13, 1, 12},
287 { 19200000, 1000000000, 625, 12, 1, 8},
288 { 26000000, 1000000000, 1000, 26, 1, 12},
291 { 12000000, 912000000, 912, 12, 1, 12},
292 { 13000000, 912000000, 912, 13, 1, 12},
293 { 19200000, 912000000, 760, 16, 1, 8},
294 { 26000000, 912000000, 912, 26, 1, 12},
297 { 12000000, 816000000, 816, 12, 1, 12},
298 { 13000000, 816000000, 816, 13, 1, 12},
299 { 19200000, 816000000, 680, 16, 1, 8},
300 { 26000000, 816000000, 816, 26, 1, 12},
303 { 12000000, 760000000, 760, 12, 1, 12},
304 { 13000000, 760000000, 760, 13, 1, 12},
305 { 19200000, 760000000, 950, 24, 1, 8},
306 { 26000000, 760000000, 760, 26, 1, 12},
309 { 12000000, 750000000, 750, 12, 1, 12},
310 { 13000000, 750000000, 750, 13, 1, 12},
311 { 19200000, 750000000, 625, 16, 1, 8},
312 { 26000000, 750000000, 750, 26, 1, 12},
315 { 12000000, 608000000, 608, 12, 1, 12},
316 { 13000000, 608000000, 608, 13, 1, 12},
317 { 19200000, 608000000, 380, 12, 1, 8},
318 { 26000000, 608000000, 608, 26, 1, 12},
321 { 12000000, 456000000, 456, 12, 1, 12},
322 { 13000000, 456000000, 456, 13, 1, 12},
323 { 19200000, 456000000, 380, 16, 1, 8},
324 { 26000000, 456000000, 456, 26, 1, 12},
327 { 12000000, 312000000, 312, 12, 1, 12},
328 { 13000000, 312000000, 312, 13, 1, 12},
329 { 19200000, 312000000, 260, 16, 1, 8},
330 { 26000000, 312000000, 312, 26, 1, 12},
332 { 0, 0, 0, 0, 0, 0 },
336 31000000, 1000000, 6000000, 20000000, 1200000000,
340 { 12000000, 100000000, 200, 24, 1, 0 },
341 { 0, 0, 0, 0, 0, 0 },
347 static const char *tegra_common_parent_names[] = {
351 static struct clk *tegra_common_parents[] = {
355 static struct clk tegra_clk_d;
356 static struct clk_tegra tegra_clk_d_hw = {
363 .max_rate = 52000000,
369 static struct clk tegra_clk_d = {
371 .hw = &tegra_clk_d_hw.
hw,
373 .parent = &tegra_clk_m,
374 .parent_names = tegra_common_parent_names,
375 .parents = tegra_common_parents,
376 .num_parents =
ARRAY_SIZE(tegra_common_parent_names),
379 static struct clk tegra_cdev1;
380 static struct clk_tegra tegra_cdev1_hw = {
384 .fixed_rate = 26000000,
389 static struct clk tegra_cdev1 = {
391 .hw = &tegra_cdev1_hw.
hw,
393 .flags = CLK_IS_ROOT,
397 static struct clk tegra_cdev2;
398 static struct clk_tegra tegra_cdev2_hw = {
402 .fixed_rate = 26000000,
407 static struct clk tegra_cdev2 = {
409 .hw = &tegra_cdev2_hw.
hw,
411 .flags = CLK_IS_ROOT,
416 static const struct audio_sources {
419 } mux_audio_sync_clk_sources[] = {
420 { .name =
"spdif_in", .value = 0 },
421 { .name =
"i2s1", .value = 1 },
422 { .name =
"i2s2", .value = 2 },
423 { .name =
"pll_a_out0", .value = 4 },
425 { .name =
"ac97", .value = 3 },
426 { .name =
"ext_audio_clk2", .value = 5 },
427 { .name =
"ext_audio_clk1", .value = 6 },
428 { .name =
"ext_vimclk", .value = 7 },
433 static const char *audio_parent_names[] = {
444 static struct clk *audio_parents[] = {
455 static struct clk tegra_audio;
456 static struct clk_tegra tegra_audio_hw = {
461 .max_rate = 73728000,
464 audio_parents,
NULL);
466 static const char *audio_2x_parent_names[] = {
470 static struct clk *audio_2x_parents[] = {
474 static struct clk tegra_audio_2x;
475 static struct clk_tegra tegra_audio_2x_hw = {
477 .clk = &tegra_audio_2x,
480 .max_rate = 48000000,
488 audio_2x_parents, &tegra_audio);
490 static struct clk_lookup tegra_audio_clk_lookups[] = {
491 { .con_id =
"audio", .clk = &tegra_audio },
492 { .con_id =
"audio_2x", .clk = &tegra_audio_2x }
499 static void init_audio_sync_clock_mux(
void)
503 const struct audio_sources *
src = mux_audio_sync_clk_sources;
506 for (i = 0; src->name; i++, sel++, src++) {
509 pr_err(
"%s: could not find clk %s\n", __func__,
511 audio_parents[src->value] = sel->input;
512 sel->value = src->value;
515 lookup = tegra_audio_clk_lookups;
516 for (i = 0; i <
ARRAY_SIZE(tegra_audio_clk_lookups); i++, lookup++) {
528 static const char *mux_cclk[] = {
541 static struct clk *mux_cclk_p[] = {
553 static const char *mux_sclk[] = {
564 static struct clk *mux_sclk_p[] = {
575 static struct clk tegra_cclk;
576 static struct clk_tegra tegra_cclk_hw = {
581 .max_rate = 1000000000,
586 static const char *mux_twd[] = {
590 static struct clk *mux_twd_p[] = {
594 static struct clk tegra_clk_twd;
595 static struct clk_tegra tegra_clk_twd_hw = {
597 .clk = &tegra_clk_twd,
599 .max_rate = 1000000000,
604 static struct clk tegra_clk_twd = {
607 .hw = &tegra_clk_twd_hw.
hw,
608 .parent = &tegra_cclk,
609 .parent_names = mux_twd,
610 .parents = mux_twd_p,
614 static struct clk tegra_sclk;
615 static struct clk_tegra tegra_sclk_hw = {
620 .max_rate = 240000000,
621 .min_rate = 120000000,
626 static const char *tegra_cop_parent_names[] = {
630 static struct clk *tegra_cop_parents[] = {
634 static struct clk tegra_cop;
639 .max_rate = 240000000,
643 tegra_cop_parent_names, tegra_cop_parents, &tegra_sclk);
645 static const char *tegra_hclk_parent_names[] = {
649 static struct clk *tegra_hclk_parents[] = {
653 static struct clk tegra_hclk;
654 static struct clk_tegra tegra_hclk_hw = {
661 .max_rate = 240000000,
664 tegra_hclk_parents, &tegra_sclk);
666 static const char *tegra_pclk_parent_names[] = {
670 static struct clk *tegra_pclk_parents[] = {
674 static struct clk tegra_pclk;
675 static struct clk_tegra tegra_pclk_hw = {
682 .max_rate = 120000000,
685 tegra_pclk_parents, &tegra_hclk);
687 static const char *tegra_blink_parent_names[] = {
691 static struct clk *tegra_blink_parents[] = {
695 static struct clk tegra_blink;
696 static struct clk_tegra tegra_blink_hw = {
704 tegra_blink_parents, &tegra_clk_32k);
706 static const char *mux_pllm_pllc_pllp_plla[] = {
713 static struct clk *mux_pllm_pllc_pllp_plla_p[] = {
720 static const char *mux_pllm_pllc_pllp_clkm[] = {
727 static struct clk *mux_pllm_pllc_pllp_clkm_p[] = {
734 static const char *mux_pllp_pllc_pllm_clkm[] = {
741 static struct clk *mux_pllp_pllc_pllm_clkm_p[] = {
748 static const char *mux_pllaout0_audio2x_pllp_clkm[] = {
755 static struct clk *mux_pllaout0_audio2x_pllp_clkm_p[] = {
762 static const char *mux_pllp_plld_pllc_clkm[] = {
769 static struct clk *mux_pllp_plld_pllc_clkm_p[] = {
776 static const char *mux_pllp_pllc_audio_clkm_clk32[] = {
784 static struct clk *mux_pllp_pllc_audio_clkm_clk32_p[] = {
792 static const char *mux_pllp_pllc_pllm[] = {
798 static struct clk *mux_pllp_pllc_pllm_p[] = {
804 static const char *mux_clk_m[] = {
808 static struct clk *mux_clk_m_p[] = {
812 static const char *mux_pllp_out3[] = {
816 static struct clk *mux_pllp_out3_p[] = {
820 static const char *mux_plld[] = {
824 static struct clk *mux_plld_p[] = {
828 static const char *mux_clk_32k[] = {
832 static struct clk *mux_clk_32k_p[] = {
836 static const char *mux_pclk[] = {
840 static struct clk *mux_pclk_p[] = {
844 static struct clk tegra_emc;
850 .max_rate = 800000000,
858 mux_pllm_pllc_pllp_clkm_p,
NULL);
860 #define PERIPH_CLK(_name, _dev, _con, _clk_num, _reg, \
861 _max, _inputs, _flags) \
862 static struct clk tegra_##_name; \
863 static struct clk_tegra tegra_##_name##_hw = { \
865 .clk = &tegra_##_name, \
875 .clk_num = _clk_num, \
877 .reset = tegra2_periph_clk_reset, \
879 static struct clk tegra_##_name = { \
881 .ops = &tegra_periph_clk_ops, \
882 .hw = &tegra_##_name##_hw.hw, \
883 .parent_names = _inputs, \
884 .parents = _inputs##_p, \
885 .num_parents = ARRAY_SIZE(_inputs), \
888 PERIPH_CLK(apbdma,
"tegra-apbdma",
NULL, 34, 0, 108000000, mux_pclk, 0);
910 PERIPH_CLK(vcp,
"tegra-avp",
"vcp", 29, 0, 250000000, mux_clk_m, 0);
911 PERIPH_CLK(bsea,
"tegra-avp",
"bsea", 62, 0, 250000000, mux_clk_m, 0);
912 PERIPH_CLK(bsev,
"tegra-aes",
"bsev", 63, 0, 250000000, mux_clk_m, 0);
913 PERIPH_CLK(vde,
"tegra-avp",
"vde", 61, 0x1c8, 250000000, mux_pllp_pllc_pllm_clkm,
MUX |
DIV_U71);
923 PERIPH_CLK(dvc,
"tegra-i2c.3",
"div-clk", 47, 0x128, 26000000, mux_pllp_pllc_pllm_clkm,
MUX |
DIV_U16);
924 PERIPH_CLK(uarta,
"tegra-uart.0",
NULL, 6, 0x178, 600000000, mux_pllp_pllc_pllm_clkm,
MUX);
925 PERIPH_CLK(uartb,
"tegra-uart.1",
NULL, 7, 0x17c, 600000000, mux_pllp_pllc_pllm_clkm,
MUX);
926 PERIPH_CLK(uartc,
"tegra-uart.2",
NULL, 55, 0x1a0, 600000000, mux_pllp_pllc_pllm_clkm,
MUX);
927 PERIPH_CLK(uartd,
"tegra-uart.3",
NULL, 65, 0x1c0, 600000000, mux_pllp_pllc_pllm_clkm,
MUX);
928 PERIPH_CLK(uarte,
"tegra-uart.4",
NULL, 66, 0x1c4, 600000000, mux_pllp_pllc_pllm_clkm,
MUX);
931 PERIPH_CLK(vi,
"tegra_camera",
"vi", 20, 0x148, 150000000, mux_pllm_pllc_pllp_plla,
MUX |
DIV_U71);
940 PERIPH_CLK(disp1,
"tegradc.0",
NULL, 27, 0x138, 600000000, mux_pllp_plld_pllc_clkm,
MUX);
941 PERIPH_CLK(disp2,
"tegradc.1",
NULL, 26, 0x13c, 600000000, mux_pllp_plld_pllc_clkm,
MUX);
942 PERIPH_CLK(usbd,
"fsl-tegra-udc",
NULL, 22, 0, 480000000, mux_clk_m, 0);
943 PERIPH_CLK(usb2,
"tegra-ehci.1",
NULL, 58, 0, 480000000, mux_clk_m, 0);
944 PERIPH_CLK(usb3,
"tegra-ehci.2",
NULL, 59, 0, 480000000, mux_clk_m, 0);
946 PERIPH_CLK(
csi,
"tegra_camera",
"csi", 52, 0, 72000000, mux_pllp_out3, 0);
947 PERIPH_CLK(isp,
"tegra_camera",
"isp", 23, 0, 150000000, mux_clk_m, 0);
1019 #define CLK_DUPLICATE(_name, _dev, _con) \
1058 #define CLK(dev, con, ck) \
1098 static void tegra2_init_one_clock(
struct clk *
c)
1120 for (i = 0; i <
ARRAY_SIZE(tegra_ptr_clks); i++)
1121 tegra2_init_one_clock(tegra_ptr_clks[i]);
1123 for (i = 0; i <
ARRAY_SIZE(tegra_list_clks); i++)
1124 tegra2_init_one_clock(tegra_list_clks[i]);
1126 for (i = 0; i <
ARRAY_SIZE(tegra_clk_duplicates); i++) {
1129 pr_err(
"%s: Unknown duplicate clock %s\n", __func__,
1130 tegra_clk_duplicates[i].name);
1134 tegra_clk_duplicates[
i].
lookup.clk =
c;
1138 init_audio_sync_clock_mux();