19952f691SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
2b08e8c0eSPrashant Gaikwad /*
3b08e8c0eSPrashant Gaikwad * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved.
4b08e8c0eSPrashant Gaikwad */
5b08e8c0eSPrashant Gaikwad
6b08e8c0eSPrashant Gaikwad #include <linux/io.h>
7b08e8c0eSPrashant Gaikwad #include <linux/delay.h>
8b08e8c0eSPrashant Gaikwad #include <linux/clk-provider.h>
9b08e8c0eSPrashant Gaikwad #include <linux/clkdev.h>
10b1bc04a2SDmitry Osipenko #include <linux/init.h>
11b08e8c0eSPrashant Gaikwad #include <linux/of.h>
12b08e8c0eSPrashant Gaikwad #include <linux/of_address.h>
13b1bc04a2SDmitry Osipenko #include <linux/platform_device.h>
14b08e8c0eSPrashant Gaikwad #include <linux/clk/tegra.h>
15306a7f91SThierry Reding
167232398aSThierry Reding #include <soc/tegra/pmc.h>
17306a7f91SThierry Reding
181bf40915SPeter De Schrijver #include <dt-bindings/clock/tegra30-car.h>
19306a7f91SThierry Reding
20b08e8c0eSPrashant Gaikwad #include "clk.h"
211bf40915SPeter De Schrijver #include "clk-id.h"
22b08e8c0eSPrashant Gaikwad
23b08e8c0eSPrashant Gaikwad #define OSC_CTRL 0x50
24b08e8c0eSPrashant Gaikwad #define OSC_CTRL_OSC_FREQ_MASK (0xF<<28)
25b08e8c0eSPrashant Gaikwad #define OSC_CTRL_OSC_FREQ_13MHZ (0X0<<28)
26b08e8c0eSPrashant Gaikwad #define OSC_CTRL_OSC_FREQ_19_2MHZ (0X4<<28)
27b08e8c0eSPrashant Gaikwad #define OSC_CTRL_OSC_FREQ_12MHZ (0X8<<28)
28b08e8c0eSPrashant Gaikwad #define OSC_CTRL_OSC_FREQ_26MHZ (0XC<<28)
29b08e8c0eSPrashant Gaikwad #define OSC_CTRL_OSC_FREQ_16_8MHZ (0X1<<28)
30b08e8c0eSPrashant Gaikwad #define OSC_CTRL_OSC_FREQ_38_4MHZ (0X5<<28)
31b08e8c0eSPrashant Gaikwad #define OSC_CTRL_OSC_FREQ_48MHZ (0X9<<28)
32b08e8c0eSPrashant Gaikwad #define OSC_CTRL_MASK (0x3f2 | OSC_CTRL_OSC_FREQ_MASK)
33b08e8c0eSPrashant Gaikwad
34b08e8c0eSPrashant Gaikwad #define OSC_CTRL_PLL_REF_DIV_MASK (3<<26)
35b08e8c0eSPrashant Gaikwad #define OSC_CTRL_PLL_REF_DIV_1 (0<<26)
36b08e8c0eSPrashant Gaikwad #define OSC_CTRL_PLL_REF_DIV_2 (1<<26)
37b08e8c0eSPrashant Gaikwad #define OSC_CTRL_PLL_REF_DIV_4 (2<<26)
38b08e8c0eSPrashant Gaikwad
39b08e8c0eSPrashant Gaikwad #define OSC_FREQ_DET 0x58
40b08e8c0eSPrashant Gaikwad #define OSC_FREQ_DET_TRIG BIT(31)
41b08e8c0eSPrashant Gaikwad
42b08e8c0eSPrashant Gaikwad #define OSC_FREQ_DET_STATUS 0x5c
43b08e8c0eSPrashant Gaikwad #define OSC_FREQ_DET_BUSY BIT(31)
44b08e8c0eSPrashant Gaikwad #define OSC_FREQ_DET_CNT_MASK 0xffff
45b08e8c0eSPrashant Gaikwad
46b08e8c0eSPrashant Gaikwad #define CCLKG_BURST_POLICY 0x368
47b08e8c0eSPrashant Gaikwad #define SUPER_CCLKG_DIVIDER 0x36c
48b08e8c0eSPrashant Gaikwad #define CCLKLP_BURST_POLICY 0x370
49b08e8c0eSPrashant Gaikwad #define SUPER_CCLKLP_DIVIDER 0x374
50b08e8c0eSPrashant Gaikwad #define SCLK_BURST_POLICY 0x028
51b08e8c0eSPrashant Gaikwad #define SUPER_SCLK_DIVIDER 0x02c
52b08e8c0eSPrashant Gaikwad
53b08e8c0eSPrashant Gaikwad #define SYSTEM_CLK_RATE 0x030
54b08e8c0eSPrashant Gaikwad
55d5ff89a8SPeter De Schrijver #define TEGRA30_CLK_PERIPH_BANKS 5
56d5ff89a8SPeter De Schrijver
57b08e8c0eSPrashant Gaikwad #define PLLC_BASE 0x80
58b08e8c0eSPrashant Gaikwad #define PLLC_MISC 0x8c
59b08e8c0eSPrashant Gaikwad #define PLLM_BASE 0x90
60b08e8c0eSPrashant Gaikwad #define PLLM_MISC 0x9c
61b08e8c0eSPrashant Gaikwad #define PLLP_BASE 0xa0
62b08e8c0eSPrashant Gaikwad #define PLLP_MISC 0xac
63b08e8c0eSPrashant Gaikwad #define PLLX_BASE 0xe0
64b08e8c0eSPrashant Gaikwad #define PLLX_MISC 0xe4
65b08e8c0eSPrashant Gaikwad #define PLLD_BASE 0xd0
66b08e8c0eSPrashant Gaikwad #define PLLD_MISC 0xdc
67b08e8c0eSPrashant Gaikwad #define PLLD2_BASE 0x4b8
68b08e8c0eSPrashant Gaikwad #define PLLD2_MISC 0x4bc
69b08e8c0eSPrashant Gaikwad #define PLLE_BASE 0xe8
70b08e8c0eSPrashant Gaikwad #define PLLE_MISC 0xec
71b08e8c0eSPrashant Gaikwad #define PLLA_BASE 0xb0
72b08e8c0eSPrashant Gaikwad #define PLLA_MISC 0xbc
73b08e8c0eSPrashant Gaikwad #define PLLU_BASE 0xc0
74b08e8c0eSPrashant Gaikwad #define PLLU_MISC 0xcc
75b08e8c0eSPrashant Gaikwad
76b08e8c0eSPrashant Gaikwad #define PLL_MISC_LOCK_ENABLE 18
77b08e8c0eSPrashant Gaikwad #define PLLDU_MISC_LOCK_ENABLE 22
78b08e8c0eSPrashant Gaikwad #define PLLE_MISC_LOCK_ENABLE 9
79b08e8c0eSPrashant Gaikwad
803e72771eSPeter De Schrijver #define PLL_BASE_LOCK BIT(27)
813e72771eSPeter De Schrijver #define PLLE_MISC_LOCK BIT(11)
82b08e8c0eSPrashant Gaikwad
83b08e8c0eSPrashant Gaikwad #define PLLE_AUX 0x48c
84b08e8c0eSPrashant Gaikwad #define PLLC_OUT 0x84
85b08e8c0eSPrashant Gaikwad #define PLLM_OUT 0x94
86b08e8c0eSPrashant Gaikwad #define PLLP_OUTA 0xa4
87b08e8c0eSPrashant Gaikwad #define PLLP_OUTB 0xa8
88b08e8c0eSPrashant Gaikwad #define PLLA_OUT 0xb4
89b08e8c0eSPrashant Gaikwad
90b08e8c0eSPrashant Gaikwad #define AUDIO_SYNC_CLK_I2S0 0x4a0
91b08e8c0eSPrashant Gaikwad #define AUDIO_SYNC_CLK_I2S1 0x4a4
92b08e8c0eSPrashant Gaikwad #define AUDIO_SYNC_CLK_I2S2 0x4a8
93b08e8c0eSPrashant Gaikwad #define AUDIO_SYNC_CLK_I2S3 0x4ac
94b08e8c0eSPrashant Gaikwad #define AUDIO_SYNC_CLK_I2S4 0x4b0
95b08e8c0eSPrashant Gaikwad #define AUDIO_SYNC_CLK_SPDIF 0x4b4
96b08e8c0eSPrashant Gaikwad
97b08e8c0eSPrashant Gaikwad #define CLK_SOURCE_SPDIF_OUT 0x108
98c04bf559SThierry Reding #define CLK_SOURCE_PWM 0x110
99b08e8c0eSPrashant Gaikwad #define CLK_SOURCE_D_AUDIO 0x3d0
100b08e8c0eSPrashant Gaikwad #define CLK_SOURCE_DAM0 0x3d8
101b08e8c0eSPrashant Gaikwad #define CLK_SOURCE_DAM1 0x3dc
102b08e8c0eSPrashant Gaikwad #define CLK_SOURCE_DAM2 0x3e0
103b08e8c0eSPrashant Gaikwad #define CLK_SOURCE_3D2 0x3b0
104b08e8c0eSPrashant Gaikwad #define CLK_SOURCE_2D 0x15c
105b08e8c0eSPrashant Gaikwad #define CLK_SOURCE_HDMI 0x18c
106b08e8c0eSPrashant Gaikwad #define CLK_SOURCE_DSIB 0xd0
107b08e8c0eSPrashant Gaikwad #define CLK_SOURCE_SE 0x42c
108b08e8c0eSPrashant Gaikwad #define CLK_SOURCE_EMC 0x19c
109b08e8c0eSPrashant Gaikwad
110b08e8c0eSPrashant Gaikwad #define AUDIO_SYNC_DOUBLER 0x49c
111b08e8c0eSPrashant Gaikwad
112b08e8c0eSPrashant Gaikwad /* Tegra CPU clock and reset control regs */
113b08e8c0eSPrashant Gaikwad #define TEGRA_CLK_RST_CONTROLLER_CLK_CPU_CMPLX 0x4c
114b08e8c0eSPrashant Gaikwad #define TEGRA_CLK_RST_CONTROLLER_RST_CPU_CMPLX_SET 0x340
115b08e8c0eSPrashant Gaikwad #define TEGRA_CLK_RST_CONTROLLER_RST_CPU_CMPLX_CLR 0x344
116b08e8c0eSPrashant Gaikwad #define TEGRA30_CLK_RST_CONTROLLER_CLK_CPU_CMPLX_CLR 0x34c
117b08e8c0eSPrashant Gaikwad #define TEGRA30_CLK_RST_CONTROLLER_CPU_CMPLX_STATUS 0x470
118b08e8c0eSPrashant Gaikwad
119b08e8c0eSPrashant Gaikwad #define CPU_CLOCK(cpu) (0x1 << (8 + cpu))
120b08e8c0eSPrashant Gaikwad #define CPU_RESET(cpu) (0x1111ul << (cpu))
121b08e8c0eSPrashant Gaikwad
122b08e8c0eSPrashant Gaikwad #define CLK_RESET_CCLK_BURST 0x20
123b08e8c0eSPrashant Gaikwad #define CLK_RESET_CCLK_DIVIDER 0x24
124b08e8c0eSPrashant Gaikwad #define CLK_RESET_PLLX_BASE 0xe0
125b08e8c0eSPrashant Gaikwad #define CLK_RESET_PLLX_MISC 0xe4
126b08e8c0eSPrashant Gaikwad
127b08e8c0eSPrashant Gaikwad #define CLK_RESET_SOURCE_CSITE 0x1d4
128b08e8c0eSPrashant Gaikwad
129b08e8c0eSPrashant Gaikwad #define CLK_RESET_CCLK_BURST_POLICY_SHIFT 28
130b08e8c0eSPrashant Gaikwad #define CLK_RESET_CCLK_RUN_POLICY_SHIFT 4
131b08e8c0eSPrashant Gaikwad #define CLK_RESET_CCLK_IDLE_POLICY_SHIFT 0
132b08e8c0eSPrashant Gaikwad #define CLK_RESET_CCLK_IDLE_POLICY 1
133b08e8c0eSPrashant Gaikwad #define CLK_RESET_CCLK_RUN_POLICY 2
134b08e8c0eSPrashant Gaikwad #define CLK_RESET_CCLK_BURST_POLICY_PLLX 8
135b08e8c0eSPrashant Gaikwad
136c09e32bbSPeter De Schrijver /* PLLM override registers */
137c09e32bbSPeter De Schrijver #define PMC_PLLM_WB0_OVERRIDE 0x1dc
138c09e32bbSPeter De Schrijver
139b08e8c0eSPrashant Gaikwad #ifdef CONFIG_PM_SLEEP
140b08e8c0eSPrashant Gaikwad static struct cpu_clk_suspend_context {
141b08e8c0eSPrashant Gaikwad u32 pllx_misc;
142b08e8c0eSPrashant Gaikwad u32 pllx_base;
143b08e8c0eSPrashant Gaikwad
144b08e8c0eSPrashant Gaikwad u32 cpu_burst;
145b08e8c0eSPrashant Gaikwad u32 clk_csite_src;
146b08e8c0eSPrashant Gaikwad u32 cclk_divider;
147b08e8c0eSPrashant Gaikwad } tegra30_cpu_clk_sctx;
148b08e8c0eSPrashant Gaikwad #endif
149b08e8c0eSPrashant Gaikwad
150b08e8c0eSPrashant Gaikwad static void __iomem *clk_base;
151b08e8c0eSPrashant Gaikwad static void __iomem *pmc_base;
152b08e8c0eSPrashant Gaikwad static unsigned long input_freq;
153b08e8c0eSPrashant Gaikwad
154b08e8c0eSPrashant Gaikwad static DEFINE_SPINLOCK(cml_lock);
155b08e8c0eSPrashant Gaikwad static DEFINE_SPINLOCK(pll_d_lock);
156b08e8c0eSPrashant Gaikwad
1571bf40915SPeter De Schrijver #define TEGRA_INIT_DATA_MUX(_name, _parents, _offset, \
158d5ff89a8SPeter De Schrijver _clk_num, _gate_flags, _clk_id) \
1591bf40915SPeter De Schrijver TEGRA_INIT_DATA(_name, NULL, NULL, _parents, _offset, \
160d5ff89a8SPeter De Schrijver 30, 2, 0, 0, 8, 1, TEGRA_DIVIDER_ROUND_UP, \
161343a607cSPeter De Schrijver _clk_num, _gate_flags, _clk_id)
162b08e8c0eSPrashant Gaikwad
1631bf40915SPeter De Schrijver #define TEGRA_INIT_DATA_MUX8(_name, _parents, _offset, \
164d5ff89a8SPeter De Schrijver _clk_num, _gate_flags, _clk_id) \
1651bf40915SPeter De Schrijver TEGRA_INIT_DATA(_name, NULL, NULL, _parents, _offset, \
166d5ff89a8SPeter De Schrijver 29, 3, 0, 0, 8, 1, TEGRA_DIVIDER_ROUND_UP, \
167343a607cSPeter De Schrijver _clk_num, _gate_flags, _clk_id)
168b08e8c0eSPrashant Gaikwad
1691bf40915SPeter De Schrijver #define TEGRA_INIT_DATA_INT(_name, _parents, _offset, \
170d5ff89a8SPeter De Schrijver _clk_num, _gate_flags, _clk_id) \
1711bf40915SPeter De Schrijver TEGRA_INIT_DATA(_name, NULL, NULL, _parents, _offset, \
172252d0d2bSPeter De Schrijver 30, 2, 0, 0, 8, 1, TEGRA_DIVIDER_INT | \
173d5ff89a8SPeter De Schrijver TEGRA_DIVIDER_ROUND_UP, _clk_num, \
174343a607cSPeter De Schrijver _gate_flags, _clk_id)
175b08e8c0eSPrashant Gaikwad
1761bf40915SPeter De Schrijver #define TEGRA_INIT_DATA_NODIV(_name, _parents, _offset, \
177d5ff89a8SPeter De Schrijver _mux_shift, _mux_width, _clk_num, \
178b08e8c0eSPrashant Gaikwad _gate_flags, _clk_id) \
1791bf40915SPeter De Schrijver TEGRA_INIT_DATA(_name, NULL, NULL, _parents, _offset, \
180d5ff89a8SPeter De Schrijver _mux_shift, _mux_width, 0, 0, 0, 0, 0,\
181343a607cSPeter De Schrijver _clk_num, _gate_flags, \
182b08e8c0eSPrashant Gaikwad _clk_id)
183b08e8c0eSPrashant Gaikwad
184343a607cSPeter De Schrijver static struct clk **clks;
185b08e8c0eSPrashant Gaikwad
186b08e8c0eSPrashant Gaikwad static struct tegra_clk_pll_freq_table pll_c_freq_table[] = {
18786c679a5SRhyland Klein { 12000000, 1040000000, 520, 6, 1, 8 },
18886c679a5SRhyland Klein { 13000000, 1040000000, 480, 6, 1, 8 },
18986c679a5SRhyland Klein { 16800000, 1040000000, 495, 8, 1, 8 }, /* actual: 1039.5 MHz */
19086c679a5SRhyland Klein { 19200000, 1040000000, 325, 6, 1, 6 },
19186c679a5SRhyland Klein { 26000000, 1040000000, 520, 13, 1, 8 },
19286c679a5SRhyland Klein { 12000000, 832000000, 416, 6, 1, 8 },
19386c679a5SRhyland Klein { 13000000, 832000000, 832, 13, 1, 8 },
19486c679a5SRhyland Klein { 16800000, 832000000, 396, 8, 1, 8 }, /* actual: 831.6 MHz */
19586c679a5SRhyland Klein { 19200000, 832000000, 260, 6, 1, 8 },
19686c679a5SRhyland Klein { 26000000, 832000000, 416, 13, 1, 8 },
19786c679a5SRhyland Klein { 12000000, 624000000, 624, 12, 1, 8 },
19886c679a5SRhyland Klein { 13000000, 624000000, 624, 13, 1, 8 },
19986c679a5SRhyland Klein { 16800000, 600000000, 520, 14, 1, 8 },
20086c679a5SRhyland Klein { 19200000, 624000000, 520, 16, 1, 8 },
20186c679a5SRhyland Klein { 26000000, 624000000, 624, 26, 1, 8 },
20286c679a5SRhyland Klein { 12000000, 600000000, 600, 12, 1, 8 },
20386c679a5SRhyland Klein { 13000000, 600000000, 600, 13, 1, 8 },
20486c679a5SRhyland Klein { 16800000, 600000000, 500, 14, 1, 8 },
20586c679a5SRhyland Klein { 19200000, 600000000, 375, 12, 1, 6 },
20686c679a5SRhyland Klein { 26000000, 600000000, 600, 26, 1, 8 },
20786c679a5SRhyland Klein { 12000000, 520000000, 520, 12, 1, 8 },
20886c679a5SRhyland Klein { 13000000, 520000000, 520, 13, 1, 8 },
20986c679a5SRhyland Klein { 16800000, 520000000, 495, 16, 1, 8 }, /* actual: 519.75 MHz */
21086c679a5SRhyland Klein { 19200000, 520000000, 325, 12, 1, 6 },
21186c679a5SRhyland Klein { 26000000, 520000000, 520, 26, 1, 8 },
21286c679a5SRhyland Klein { 12000000, 416000000, 416, 12, 1, 8 },
21386c679a5SRhyland Klein { 13000000, 416000000, 416, 13, 1, 8 },
21486c679a5SRhyland Klein { 16800000, 416000000, 396, 16, 1, 8 }, /* actual: 415.8 MHz */
21586c679a5SRhyland Klein { 19200000, 416000000, 260, 12, 1, 6 },
21686c679a5SRhyland Klein { 26000000, 416000000, 416, 26, 1, 8 },
217b08e8c0eSPrashant Gaikwad { 0, 0, 0, 0, 0, 0 },
218b08e8c0eSPrashant Gaikwad };
219b08e8c0eSPrashant Gaikwad
220b08e8c0eSPrashant Gaikwad static struct tegra_clk_pll_freq_table pll_m_freq_table[] = {
22186c679a5SRhyland Klein { 12000000, 666000000, 666, 12, 1, 8 },
22286c679a5SRhyland Klein { 13000000, 666000000, 666, 13, 1, 8 },
22386c679a5SRhyland Klein { 16800000, 666000000, 555, 14, 1, 8 },
22486c679a5SRhyland Klein { 19200000, 666000000, 555, 16, 1, 8 },
22586c679a5SRhyland Klein { 26000000, 666000000, 666, 26, 1, 8 },
22686c679a5SRhyland Klein { 12000000, 600000000, 600, 12, 1, 8 },
22786c679a5SRhyland Klein { 13000000, 600000000, 600, 13, 1, 8 },
22886c679a5SRhyland Klein { 16800000, 600000000, 500, 14, 1, 8 },
22986c679a5SRhyland Klein { 19200000, 600000000, 375, 12, 1, 6 },
23086c679a5SRhyland Klein { 26000000, 600000000, 600, 26, 1, 8 },
231b08e8c0eSPrashant Gaikwad { 0, 0, 0, 0, 0, 0 },
232b08e8c0eSPrashant Gaikwad };
233b08e8c0eSPrashant Gaikwad
234b08e8c0eSPrashant Gaikwad static struct tegra_clk_pll_freq_table pll_p_freq_table[] = {
23586c679a5SRhyland Klein { 12000000, 216000000, 432, 12, 2, 8 },
23686c679a5SRhyland Klein { 13000000, 216000000, 432, 13, 2, 8 },
23786c679a5SRhyland Klein { 16800000, 216000000, 360, 14, 2, 8 },
23886c679a5SRhyland Klein { 19200000, 216000000, 360, 16, 2, 8 },
23986c679a5SRhyland Klein { 26000000, 216000000, 432, 26, 2, 8 },
240b08e8c0eSPrashant Gaikwad { 0, 0, 0, 0, 0, 0 },
241b08e8c0eSPrashant Gaikwad };
242b08e8c0eSPrashant Gaikwad
243b08e8c0eSPrashant Gaikwad static struct tegra_clk_pll_freq_table pll_a_freq_table[] = {
24486c679a5SRhyland Klein { 9600000, 564480000, 294, 5, 1, 4 },
24586c679a5SRhyland Klein { 9600000, 552960000, 288, 5, 1, 4 },
24686c679a5SRhyland Klein { 9600000, 24000000, 5, 2, 1, 1 },
24786c679a5SRhyland Klein { 28800000, 56448000, 49, 25, 1, 1 },
24886c679a5SRhyland Klein { 28800000, 73728000, 64, 25, 1, 1 },
24986c679a5SRhyland Klein { 28800000, 24000000, 5, 6, 1, 1 },
250b08e8c0eSPrashant Gaikwad { 0, 0, 0, 0, 0, 0 },
251b08e8c0eSPrashant Gaikwad };
252b08e8c0eSPrashant Gaikwad
253b08e8c0eSPrashant Gaikwad static struct tegra_clk_pll_freq_table pll_d_freq_table[] = {
25486c679a5SRhyland Klein { 12000000, 216000000, 216, 12, 1, 4 },
25586c679a5SRhyland Klein { 13000000, 216000000, 216, 13, 1, 4 },
25686c679a5SRhyland Klein { 16800000, 216000000, 180, 14, 1, 4 },
25786c679a5SRhyland Klein { 19200000, 216000000, 180, 16, 1, 4 },
25886c679a5SRhyland Klein { 26000000, 216000000, 216, 26, 1, 4 },
25986c679a5SRhyland Klein { 12000000, 594000000, 594, 12, 1, 8 },
26086c679a5SRhyland Klein { 13000000, 594000000, 594, 13, 1, 8 },
26186c679a5SRhyland Klein { 16800000, 594000000, 495, 14, 1, 8 },
26286c679a5SRhyland Klein { 19200000, 594000000, 495, 16, 1, 8 },
26386c679a5SRhyland Klein { 26000000, 594000000, 594, 26, 1, 8 },
26486c679a5SRhyland Klein { 12000000, 1000000000, 1000, 12, 1, 12 },
26586c679a5SRhyland Klein { 13000000, 1000000000, 1000, 13, 1, 12 },
26686c679a5SRhyland Klein { 19200000, 1000000000, 625, 12, 1, 8 },
26786c679a5SRhyland Klein { 26000000, 1000000000, 1000, 26, 1, 12 },
268b08e8c0eSPrashant Gaikwad { 0, 0, 0, 0, 0, 0 },
269b08e8c0eSPrashant Gaikwad };
270b08e8c0eSPrashant Gaikwad
271385f9adfSThierry Reding static const struct pdiv_map pllu_p[] = {
2720b6525acSPeter De Schrijver { .pdiv = 1, .hw_val = 1 },
2730b6525acSPeter De Schrijver { .pdiv = 2, .hw_val = 0 },
2740b6525acSPeter De Schrijver { .pdiv = 0, .hw_val = 0 },
2750b6525acSPeter De Schrijver };
2760b6525acSPeter De Schrijver
277b08e8c0eSPrashant Gaikwad static struct tegra_clk_pll_freq_table pll_u_freq_table[] = {
27879709730SLucas Stach { 12000000, 480000000, 960, 12, 2, 12 },
27979709730SLucas Stach { 13000000, 480000000, 960, 13, 2, 12 },
28079709730SLucas Stach { 16800000, 480000000, 400, 7, 2, 5 },
28179709730SLucas Stach { 19200000, 480000000, 200, 4, 2, 3 },
28279709730SLucas Stach { 26000000, 480000000, 960, 26, 2, 12 },
283b08e8c0eSPrashant Gaikwad { 0, 0, 0, 0, 0, 0 },
284b08e8c0eSPrashant Gaikwad };
285b08e8c0eSPrashant Gaikwad
286b08e8c0eSPrashant Gaikwad static struct tegra_clk_pll_freq_table pll_x_freq_table[] = {
287b08e8c0eSPrashant Gaikwad /* 1.7 GHz */
28886c679a5SRhyland Klein { 12000000, 1700000000, 850, 6, 1, 8 },
28986c679a5SRhyland Klein { 13000000, 1700000000, 915, 7, 1, 8 }, /* actual: 1699.2 MHz */
29086c679a5SRhyland Klein { 16800000, 1700000000, 708, 7, 1, 8 }, /* actual: 1699.2 MHz */
29186c679a5SRhyland Klein { 19200000, 1700000000, 885, 10, 1, 8 }, /* actual: 1699.2 MHz */
29286c679a5SRhyland Klein { 26000000, 1700000000, 850, 13, 1, 8 },
293b08e8c0eSPrashant Gaikwad /* 1.6 GHz */
29486c679a5SRhyland Klein { 12000000, 1600000000, 800, 6, 1, 8 },
29586c679a5SRhyland Klein { 13000000, 1600000000, 738, 6, 1, 8 }, /* actual: 1599.0 MHz */
29686c679a5SRhyland Klein { 16800000, 1600000000, 857, 9, 1, 8 }, /* actual: 1599.7 MHz */
29786c679a5SRhyland Klein { 19200000, 1600000000, 500, 6, 1, 8 },
29886c679a5SRhyland Klein { 26000000, 1600000000, 800, 13, 1, 8 },
299b08e8c0eSPrashant Gaikwad /* 1.5 GHz */
30086c679a5SRhyland Klein { 12000000, 1500000000, 750, 6, 1, 8 },
30186c679a5SRhyland Klein { 13000000, 1500000000, 923, 8, 1, 8 }, /* actual: 1499.8 MHz */
30286c679a5SRhyland Klein { 16800000, 1500000000, 625, 7, 1, 8 },
30386c679a5SRhyland Klein { 19200000, 1500000000, 625, 8, 1, 8 },
30486c679a5SRhyland Klein { 26000000, 1500000000, 750, 13, 1, 8 },
305b08e8c0eSPrashant Gaikwad /* 1.4 GHz */
30686c679a5SRhyland Klein { 12000000, 1400000000, 700, 6, 1, 8 },
30786c679a5SRhyland Klein { 13000000, 1400000000, 969, 9, 1, 8 }, /* actual: 1399.7 MHz */
30886c679a5SRhyland Klein { 16800000, 1400000000, 1000, 12, 1, 8 },
30986c679a5SRhyland Klein { 19200000, 1400000000, 875, 12, 1, 8 },
31086c679a5SRhyland Klein { 26000000, 1400000000, 700, 13, 1, 8 },
311b08e8c0eSPrashant Gaikwad /* 1.3 GHz */
31286c679a5SRhyland Klein { 12000000, 1300000000, 975, 9, 1, 8 },
31386c679a5SRhyland Klein { 13000000, 1300000000, 1000, 10, 1, 8 },
31486c679a5SRhyland Klein { 16800000, 1300000000, 928, 12, 1, 8 }, /* actual: 1299.2 MHz */
31586c679a5SRhyland Klein { 19200000, 1300000000, 812, 12, 1, 8 }, /* actual: 1299.2 MHz */
31686c679a5SRhyland Klein { 26000000, 1300000000, 650, 13, 1, 8 },
317b08e8c0eSPrashant Gaikwad /* 1.2 GHz */
31886c679a5SRhyland Klein { 12000000, 1200000000, 1000, 10, 1, 8 },
31986c679a5SRhyland Klein { 13000000, 1200000000, 923, 10, 1, 8 }, /* actual: 1199.9 MHz */
32086c679a5SRhyland Klein { 16800000, 1200000000, 1000, 14, 1, 8 },
32186c679a5SRhyland Klein { 19200000, 1200000000, 1000, 16, 1, 8 },
32286c679a5SRhyland Klein { 26000000, 1200000000, 600, 13, 1, 8 },
323b08e8c0eSPrashant Gaikwad /* 1.1 GHz */
32486c679a5SRhyland Klein { 12000000, 1100000000, 825, 9, 1, 8 },
32586c679a5SRhyland Klein { 13000000, 1100000000, 846, 10, 1, 8 }, /* actual: 1099.8 MHz */
32686c679a5SRhyland Klein { 16800000, 1100000000, 982, 15, 1, 8 }, /* actual: 1099.8 MHz */
32786c679a5SRhyland Klein { 19200000, 1100000000, 859, 15, 1, 8 }, /* actual: 1099.5 MHz */
32886c679a5SRhyland Klein { 26000000, 1100000000, 550, 13, 1, 8 },
329b08e8c0eSPrashant Gaikwad /* 1 GHz */
33086c679a5SRhyland Klein { 12000000, 1000000000, 1000, 12, 1, 8 },
33186c679a5SRhyland Klein { 13000000, 1000000000, 1000, 13, 1, 8 },
33286c679a5SRhyland Klein { 16800000, 1000000000, 833, 14, 1, 8 }, /* actual: 999.6 MHz */
33386c679a5SRhyland Klein { 19200000, 1000000000, 625, 12, 1, 8 },
33486c679a5SRhyland Klein { 26000000, 1000000000, 1000, 26, 1, 8 },
335b08e8c0eSPrashant Gaikwad { 0, 0, 0, 0, 0, 0 },
336b08e8c0eSPrashant Gaikwad };
337b08e8c0eSPrashant Gaikwad
33886c679a5SRhyland Klein static const struct pdiv_map plle_p[] = {
33986c679a5SRhyland Klein { .pdiv = 18, .hw_val = 18 },
34086c679a5SRhyland Klein { .pdiv = 24, .hw_val = 24 },
34186c679a5SRhyland Klein { .pdiv = 0, .hw_val = 0 },
34286c679a5SRhyland Klein };
34386c679a5SRhyland Klein
344b08e8c0eSPrashant Gaikwad static struct tegra_clk_pll_freq_table pll_e_freq_table[] = {
345b08e8c0eSPrashant Gaikwad /* PLLE special case: use cpcon field to store cml divider value */
346b08e8c0eSPrashant Gaikwad { 12000000, 100000000, 150, 1, 18, 11 },
347b08e8c0eSPrashant Gaikwad { 216000000, 100000000, 200, 18, 24, 13 },
348b08e8c0eSPrashant Gaikwad { 0, 0, 0, 0, 0, 0 },
349b08e8c0eSPrashant Gaikwad };
350b08e8c0eSPrashant Gaikwad
351b08e8c0eSPrashant Gaikwad /* PLL parameters */
352d83b26e0SBhumika Goyal static struct tegra_clk_pll_params pll_c_params __ro_after_init = {
353b08e8c0eSPrashant Gaikwad .input_min = 2000000,
354b08e8c0eSPrashant Gaikwad .input_max = 31000000,
355b08e8c0eSPrashant Gaikwad .cf_min = 1000000,
356b08e8c0eSPrashant Gaikwad .cf_max = 6000000,
357b08e8c0eSPrashant Gaikwad .vco_min = 20000000,
358b08e8c0eSPrashant Gaikwad .vco_max = 1400000000,
359b08e8c0eSPrashant Gaikwad .base_reg = PLLC_BASE,
360b08e8c0eSPrashant Gaikwad .misc_reg = PLLC_MISC,
3613e72771eSPeter De Schrijver .lock_mask = PLL_BASE_LOCK,
362b08e8c0eSPrashant Gaikwad .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
363b08e8c0eSPrashant Gaikwad .lock_delay = 300,
364ebe142b2SPeter De Schrijver .freq_table = pll_c_freq_table,
3653706b436SRhyland Klein .flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_USE_LOCK |
3663706b436SRhyland Klein TEGRA_PLL_HAS_LOCK_ENABLE,
367b08e8c0eSPrashant Gaikwad };
368b08e8c0eSPrashant Gaikwad
369c09e32bbSPeter De Schrijver static struct div_nmp pllm_nmp = {
370c09e32bbSPeter De Schrijver .divn_shift = 8,
371c09e32bbSPeter De Schrijver .divn_width = 10,
372c09e32bbSPeter De Schrijver .override_divn_shift = 5,
373c09e32bbSPeter De Schrijver .divm_shift = 0,
374c09e32bbSPeter De Schrijver .divm_width = 5,
375c09e32bbSPeter De Schrijver .override_divm_shift = 0,
376c09e32bbSPeter De Schrijver .divp_shift = 20,
377c09e32bbSPeter De Schrijver .divp_width = 3,
378c09e32bbSPeter De Schrijver .override_divp_shift = 15,
379c09e32bbSPeter De Schrijver };
380c09e32bbSPeter De Schrijver
381d83b26e0SBhumika Goyal static struct tegra_clk_pll_params pll_m_params __ro_after_init = {
382b08e8c0eSPrashant Gaikwad .input_min = 2000000,
383b08e8c0eSPrashant Gaikwad .input_max = 31000000,
384b08e8c0eSPrashant Gaikwad .cf_min = 1000000,
385b08e8c0eSPrashant Gaikwad .cf_max = 6000000,
386b08e8c0eSPrashant Gaikwad .vco_min = 20000000,
387b08e8c0eSPrashant Gaikwad .vco_max = 1200000000,
388b08e8c0eSPrashant Gaikwad .base_reg = PLLM_BASE,
389b08e8c0eSPrashant Gaikwad .misc_reg = PLLM_MISC,
3903e72771eSPeter De Schrijver .lock_mask = PLL_BASE_LOCK,
391b08e8c0eSPrashant Gaikwad .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
392b08e8c0eSPrashant Gaikwad .lock_delay = 300,
393c09e32bbSPeter De Schrijver .div_nmp = &pllm_nmp,
394c09e32bbSPeter De Schrijver .pmc_divnm_reg = PMC_PLLM_WB0_OVERRIDE,
395c09e32bbSPeter De Schrijver .pmc_divp_reg = PMC_PLLM_WB0_OVERRIDE,
396ebe142b2SPeter De Schrijver .freq_table = pll_m_freq_table,
397ebe142b2SPeter De Schrijver .flags = TEGRA_PLLM | TEGRA_PLL_HAS_CPCON |
3983706b436SRhyland Klein TEGRA_PLL_SET_DCCON | TEGRA_PLL_USE_LOCK |
399267b62a9SDanny Huang TEGRA_PLL_HAS_LOCK_ENABLE | TEGRA_PLL_FIXED,
400b08e8c0eSPrashant Gaikwad };
401b08e8c0eSPrashant Gaikwad
402d83b26e0SBhumika Goyal static struct tegra_clk_pll_params pll_p_params __ro_after_init = {
403b08e8c0eSPrashant Gaikwad .input_min = 2000000,
404b08e8c0eSPrashant Gaikwad .input_max = 31000000,
405b08e8c0eSPrashant Gaikwad .cf_min = 1000000,
406b08e8c0eSPrashant Gaikwad .cf_max = 6000000,
407b08e8c0eSPrashant Gaikwad .vco_min = 20000000,
408b08e8c0eSPrashant Gaikwad .vco_max = 1400000000,
409b08e8c0eSPrashant Gaikwad .base_reg = PLLP_BASE,
410b08e8c0eSPrashant Gaikwad .misc_reg = PLLP_MISC,
4113e72771eSPeter De Schrijver .lock_mask = PLL_BASE_LOCK,
412b08e8c0eSPrashant Gaikwad .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
413b08e8c0eSPrashant Gaikwad .lock_delay = 300,
414ebe142b2SPeter De Schrijver .freq_table = pll_p_freq_table,
4153706b436SRhyland Klein .flags = TEGRA_PLL_FIXED | TEGRA_PLL_HAS_CPCON | TEGRA_PLL_USE_LOCK |
4163706b436SRhyland Klein TEGRA_PLL_HAS_LOCK_ENABLE,
417ebe142b2SPeter De Schrijver .fixed_rate = 408000000,
418b08e8c0eSPrashant Gaikwad };
419b08e8c0eSPrashant Gaikwad
420b08e8c0eSPrashant Gaikwad static struct tegra_clk_pll_params pll_a_params = {
421b08e8c0eSPrashant Gaikwad .input_min = 2000000,
422b08e8c0eSPrashant Gaikwad .input_max = 31000000,
423b08e8c0eSPrashant Gaikwad .cf_min = 1000000,
424b08e8c0eSPrashant Gaikwad .cf_max = 6000000,
425b08e8c0eSPrashant Gaikwad .vco_min = 20000000,
426b08e8c0eSPrashant Gaikwad .vco_max = 1400000000,
427b08e8c0eSPrashant Gaikwad .base_reg = PLLA_BASE,
428b08e8c0eSPrashant Gaikwad .misc_reg = PLLA_MISC,
4293e72771eSPeter De Schrijver .lock_mask = PLL_BASE_LOCK,
430b08e8c0eSPrashant Gaikwad .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
431b08e8c0eSPrashant Gaikwad .lock_delay = 300,
432ebe142b2SPeter De Schrijver .freq_table = pll_a_freq_table,
4333706b436SRhyland Klein .flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_USE_LOCK |
4343706b436SRhyland Klein TEGRA_PLL_HAS_LOCK_ENABLE,
435b08e8c0eSPrashant Gaikwad };
436b08e8c0eSPrashant Gaikwad
437d83b26e0SBhumika Goyal static struct tegra_clk_pll_params pll_d_params __ro_after_init = {
438b08e8c0eSPrashant Gaikwad .input_min = 2000000,
439b08e8c0eSPrashant Gaikwad .input_max = 40000000,
440b08e8c0eSPrashant Gaikwad .cf_min = 1000000,
441b08e8c0eSPrashant Gaikwad .cf_max = 6000000,
442b08e8c0eSPrashant Gaikwad .vco_min = 40000000,
443b08e8c0eSPrashant Gaikwad .vco_max = 1000000000,
444b08e8c0eSPrashant Gaikwad .base_reg = PLLD_BASE,
445b08e8c0eSPrashant Gaikwad .misc_reg = PLLD_MISC,
4463e72771eSPeter De Schrijver .lock_mask = PLL_BASE_LOCK,
447b08e8c0eSPrashant Gaikwad .lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE,
448b08e8c0eSPrashant Gaikwad .lock_delay = 1000,
449ebe142b2SPeter De Schrijver .freq_table = pll_d_freq_table,
450ebe142b2SPeter De Schrijver .flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON |
4513706b436SRhyland Klein TEGRA_PLL_USE_LOCK | TEGRA_PLL_HAS_LOCK_ENABLE,
452b08e8c0eSPrashant Gaikwad };
453b08e8c0eSPrashant Gaikwad
454d83b26e0SBhumika Goyal static struct tegra_clk_pll_params pll_d2_params __ro_after_init = {
455b08e8c0eSPrashant Gaikwad .input_min = 2000000,
456b08e8c0eSPrashant Gaikwad .input_max = 40000000,
457b08e8c0eSPrashant Gaikwad .cf_min = 1000000,
458b08e8c0eSPrashant Gaikwad .cf_max = 6000000,
459b08e8c0eSPrashant Gaikwad .vco_min = 40000000,
460b08e8c0eSPrashant Gaikwad .vco_max = 1000000000,
461b08e8c0eSPrashant Gaikwad .base_reg = PLLD2_BASE,
462b08e8c0eSPrashant Gaikwad .misc_reg = PLLD2_MISC,
4633e72771eSPeter De Schrijver .lock_mask = PLL_BASE_LOCK,
464b08e8c0eSPrashant Gaikwad .lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE,
465b08e8c0eSPrashant Gaikwad .lock_delay = 1000,
466ebe142b2SPeter De Schrijver .freq_table = pll_d_freq_table,
467ebe142b2SPeter De Schrijver .flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON |
4683706b436SRhyland Klein TEGRA_PLL_USE_LOCK | TEGRA_PLL_HAS_LOCK_ENABLE,
469b08e8c0eSPrashant Gaikwad };
470b08e8c0eSPrashant Gaikwad
471d83b26e0SBhumika Goyal static struct tegra_clk_pll_params pll_u_params __ro_after_init = {
472b08e8c0eSPrashant Gaikwad .input_min = 2000000,
473b08e8c0eSPrashant Gaikwad .input_max = 40000000,
474b08e8c0eSPrashant Gaikwad .cf_min = 1000000,
475b08e8c0eSPrashant Gaikwad .cf_max = 6000000,
476b08e8c0eSPrashant Gaikwad .vco_min = 48000000,
477b08e8c0eSPrashant Gaikwad .vco_max = 960000000,
478b08e8c0eSPrashant Gaikwad .base_reg = PLLU_BASE,
479b08e8c0eSPrashant Gaikwad .misc_reg = PLLU_MISC,
4803e72771eSPeter De Schrijver .lock_mask = PLL_BASE_LOCK,
481b08e8c0eSPrashant Gaikwad .lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE,
482b08e8c0eSPrashant Gaikwad .lock_delay = 1000,
4830b6525acSPeter De Schrijver .pdiv_tohw = pllu_p,
484ebe142b2SPeter De Schrijver .freq_table = pll_u_freq_table,
4853706b436SRhyland Klein .flags = TEGRA_PLLU | TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON |
4863706b436SRhyland Klein TEGRA_PLL_HAS_LOCK_ENABLE,
487b08e8c0eSPrashant Gaikwad };
488b08e8c0eSPrashant Gaikwad
489d83b26e0SBhumika Goyal static struct tegra_clk_pll_params pll_x_params __ro_after_init = {
490b08e8c0eSPrashant Gaikwad .input_min = 2000000,
491b08e8c0eSPrashant Gaikwad .input_max = 31000000,
492b08e8c0eSPrashant Gaikwad .cf_min = 1000000,
493b08e8c0eSPrashant Gaikwad .cf_max = 6000000,
494b08e8c0eSPrashant Gaikwad .vco_min = 20000000,
495b08e8c0eSPrashant Gaikwad .vco_max = 1700000000,
496b08e8c0eSPrashant Gaikwad .base_reg = PLLX_BASE,
497b08e8c0eSPrashant Gaikwad .misc_reg = PLLX_MISC,
4983e72771eSPeter De Schrijver .lock_mask = PLL_BASE_LOCK,
499b08e8c0eSPrashant Gaikwad .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
500b08e8c0eSPrashant Gaikwad .lock_delay = 300,
501ebe142b2SPeter De Schrijver .freq_table = pll_x_freq_table,
502ebe142b2SPeter De Schrijver .flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_DCCON |
5033706b436SRhyland Klein TEGRA_PLL_USE_LOCK | TEGRA_PLL_HAS_LOCK_ENABLE,
50442329854SDmitry Osipenko .pre_rate_change = tegra_cclk_pre_pllx_rate_change,
50542329854SDmitry Osipenko .post_rate_change = tegra_cclk_post_pllx_rate_change,
506b08e8c0eSPrashant Gaikwad };
507b08e8c0eSPrashant Gaikwad
508d83b26e0SBhumika Goyal static struct tegra_clk_pll_params pll_e_params __ro_after_init = {
509b08e8c0eSPrashant Gaikwad .input_min = 12000000,
510b08e8c0eSPrashant Gaikwad .input_max = 216000000,
511b08e8c0eSPrashant Gaikwad .cf_min = 12000000,
512b08e8c0eSPrashant Gaikwad .cf_max = 12000000,
513b08e8c0eSPrashant Gaikwad .vco_min = 1200000000,
514b08e8c0eSPrashant Gaikwad .vco_max = 2400000000U,
515b08e8c0eSPrashant Gaikwad .base_reg = PLLE_BASE,
516b08e8c0eSPrashant Gaikwad .misc_reg = PLLE_MISC,
5173e72771eSPeter De Schrijver .lock_mask = PLLE_MISC_LOCK,
518b08e8c0eSPrashant Gaikwad .lock_enable_bit_idx = PLLE_MISC_LOCK_ENABLE,
519b08e8c0eSPrashant Gaikwad .lock_delay = 300,
52086c679a5SRhyland Klein .pdiv_tohw = plle_p,
521ebe142b2SPeter De Schrijver .freq_table = pll_e_freq_table,
5223706b436SRhyland Klein .flags = TEGRA_PLLE_CONFIGURE | TEGRA_PLL_FIXED |
5233706b436SRhyland Klein TEGRA_PLL_HAS_LOCK_ENABLE | TEGRA_PLL_LOCK_MISC,
524ebe142b2SPeter De Schrijver .fixed_rate = 100000000,
525b08e8c0eSPrashant Gaikwad };
526b08e8c0eSPrashant Gaikwad
5271bf40915SPeter De Schrijver static unsigned long tegra30_input_freq[] = {
5281bf40915SPeter De Schrijver [ 0] = 13000000,
5291bf40915SPeter De Schrijver [ 1] = 16800000,
5301bf40915SPeter De Schrijver [ 4] = 19200000,
5311bf40915SPeter De Schrijver [ 5] = 38400000,
5321bf40915SPeter De Schrijver [ 8] = 12000000,
5331bf40915SPeter De Schrijver [ 9] = 48000000,
534c4947e36SThierry Reding [12] = 26000000,
5351bf40915SPeter De Schrijver };
536b08e8c0eSPrashant Gaikwad
537b1bc04a2SDmitry Osipenko static struct tegra_devclk devclks[] = {
5381bf40915SPeter De Schrijver { .con_id = "pll_c", .dt_id = TEGRA30_CLK_PLL_C },
5391bf40915SPeter De Schrijver { .con_id = "pll_c_out1", .dt_id = TEGRA30_CLK_PLL_C_OUT1 },
5401bf40915SPeter De Schrijver { .con_id = "pll_p", .dt_id = TEGRA30_CLK_PLL_P },
5411bf40915SPeter De Schrijver { .con_id = "pll_p_out1", .dt_id = TEGRA30_CLK_PLL_P_OUT1 },
5421bf40915SPeter De Schrijver { .con_id = "pll_p_out2", .dt_id = TEGRA30_CLK_PLL_P_OUT2 },
5431bf40915SPeter De Schrijver { .con_id = "pll_p_out3", .dt_id = TEGRA30_CLK_PLL_P_OUT3 },
5441bf40915SPeter De Schrijver { .con_id = "pll_p_out4", .dt_id = TEGRA30_CLK_PLL_P_OUT4 },
5451bf40915SPeter De Schrijver { .con_id = "pll_m", .dt_id = TEGRA30_CLK_PLL_M },
5461bf40915SPeter De Schrijver { .con_id = "pll_m_out1", .dt_id = TEGRA30_CLK_PLL_M_OUT1 },
5471bf40915SPeter De Schrijver { .con_id = "pll_x", .dt_id = TEGRA30_CLK_PLL_X },
5481bf40915SPeter De Schrijver { .con_id = "pll_x_out0", .dt_id = TEGRA30_CLK_PLL_X_OUT0 },
5491bf40915SPeter De Schrijver { .con_id = "pll_u", .dt_id = TEGRA30_CLK_PLL_U },
5501bf40915SPeter De Schrijver { .con_id = "pll_d", .dt_id = TEGRA30_CLK_PLL_D },
5511bf40915SPeter De Schrijver { .con_id = "pll_d_out0", .dt_id = TEGRA30_CLK_PLL_D_OUT0 },
5521bf40915SPeter De Schrijver { .con_id = "pll_d2", .dt_id = TEGRA30_CLK_PLL_D2 },
5531bf40915SPeter De Schrijver { .con_id = "pll_d2_out0", .dt_id = TEGRA30_CLK_PLL_D2_OUT0 },
5541bf40915SPeter De Schrijver { .con_id = "pll_a", .dt_id = TEGRA30_CLK_PLL_A },
5551bf40915SPeter De Schrijver { .con_id = "pll_a_out0", .dt_id = TEGRA30_CLK_PLL_A_OUT0 },
5561bf40915SPeter De Schrijver { .con_id = "pll_e", .dt_id = TEGRA30_CLK_PLL_E },
5571bf40915SPeter De Schrijver { .con_id = "spdif_in_sync", .dt_id = TEGRA30_CLK_SPDIF_IN_SYNC },
5581bf40915SPeter De Schrijver { .con_id = "i2s0_sync", .dt_id = TEGRA30_CLK_I2S0_SYNC },
5591bf40915SPeter De Schrijver { .con_id = "i2s1_sync", .dt_id = TEGRA30_CLK_I2S1_SYNC },
5601bf40915SPeter De Schrijver { .con_id = "i2s2_sync", .dt_id = TEGRA30_CLK_I2S2_SYNC },
5611bf40915SPeter De Schrijver { .con_id = "i2s3_sync", .dt_id = TEGRA30_CLK_I2S3_SYNC },
5621bf40915SPeter De Schrijver { .con_id = "i2s4_sync", .dt_id = TEGRA30_CLK_I2S4_SYNC },
5631bf40915SPeter De Schrijver { .con_id = "vimclk_sync", .dt_id = TEGRA30_CLK_VIMCLK_SYNC },
5641bf40915SPeter De Schrijver { .con_id = "audio0", .dt_id = TEGRA30_CLK_AUDIO0 },
5651bf40915SPeter De Schrijver { .con_id = "audio1", .dt_id = TEGRA30_CLK_AUDIO1 },
5661bf40915SPeter De Schrijver { .con_id = "audio2", .dt_id = TEGRA30_CLK_AUDIO2 },
5671bf40915SPeter De Schrijver { .con_id = "audio3", .dt_id = TEGRA30_CLK_AUDIO3 },
5681bf40915SPeter De Schrijver { .con_id = "audio4", .dt_id = TEGRA30_CLK_AUDIO4 },
5691bf40915SPeter De Schrijver { .con_id = "spdif", .dt_id = TEGRA30_CLK_SPDIF },
5701bf40915SPeter De Schrijver { .con_id = "audio0_2x", .dt_id = TEGRA30_CLK_AUDIO0_2X },
5711bf40915SPeter De Schrijver { .con_id = "audio1_2x", .dt_id = TEGRA30_CLK_AUDIO1_2X },
5721bf40915SPeter De Schrijver { .con_id = "audio2_2x", .dt_id = TEGRA30_CLK_AUDIO2_2X },
5731bf40915SPeter De Schrijver { .con_id = "audio3_2x", .dt_id = TEGRA30_CLK_AUDIO3_2X },
5741bf40915SPeter De Schrijver { .con_id = "audio4_2x", .dt_id = TEGRA30_CLK_AUDIO4_2X },
5751bf40915SPeter De Schrijver { .con_id = "spdif_2x", .dt_id = TEGRA30_CLK_SPDIF_2X },
576acbeec3dSSowjanya Komatineni { .con_id = "extern1", .dt_id = TEGRA30_CLK_EXTERN1 },
577acbeec3dSSowjanya Komatineni { .con_id = "extern2", .dt_id = TEGRA30_CLK_EXTERN2 },
578acbeec3dSSowjanya Komatineni { .con_id = "extern3", .dt_id = TEGRA30_CLK_EXTERN3 },
5791bf40915SPeter De Schrijver { .con_id = "cclk_g", .dt_id = TEGRA30_CLK_CCLK_G },
5801bf40915SPeter De Schrijver { .con_id = "cclk_lp", .dt_id = TEGRA30_CLK_CCLK_LP },
5811bf40915SPeter De Schrijver { .con_id = "sclk", .dt_id = TEGRA30_CLK_SCLK },
5821bf40915SPeter De Schrijver { .con_id = "hclk", .dt_id = TEGRA30_CLK_HCLK },
5831bf40915SPeter De Schrijver { .con_id = "pclk", .dt_id = TEGRA30_CLK_PCLK },
5841bf40915SPeter De Schrijver { .con_id = "twd", .dt_id = TEGRA30_CLK_TWD },
5851bf40915SPeter De Schrijver { .con_id = "emc", .dt_id = TEGRA30_CLK_EMC },
5861bf40915SPeter De Schrijver { .con_id = "clk_32k", .dt_id = TEGRA30_CLK_CLK_32K },
5872b50e49bSSowjanya Komatineni { .con_id = "osc", .dt_id = TEGRA30_CLK_OSC },
5889a85eb4dSSowjanya Komatineni { .con_id = "osc_div2", .dt_id = TEGRA30_CLK_OSC_DIV2 },
5899a85eb4dSSowjanya Komatineni { .con_id = "osc_div4", .dt_id = TEGRA30_CLK_OSC_DIV4 },
5901bf40915SPeter De Schrijver { .con_id = "cml0", .dt_id = TEGRA30_CLK_CML0 },
5911bf40915SPeter De Schrijver { .con_id = "cml1", .dt_id = TEGRA30_CLK_CML1 },
5921bf40915SPeter De Schrijver { .con_id = "clk_m", .dt_id = TEGRA30_CLK_CLK_M },
5931bf40915SPeter De Schrijver { .con_id = "pll_ref", .dt_id = TEGRA30_CLK_PLL_REF },
5941bf40915SPeter De Schrijver { .con_id = "csus", .dev_id = "tengra_camera", .dt_id = TEGRA30_CLK_CSUS },
5951bf40915SPeter De Schrijver { .con_id = "vcp", .dev_id = "tegra-avp", .dt_id = TEGRA30_CLK_VCP },
5961bf40915SPeter De Schrijver { .con_id = "bsea", .dev_id = "tegra-avp", .dt_id = TEGRA30_CLK_BSEA },
5971bf40915SPeter De Schrijver { .con_id = "bsev", .dev_id = "tegra-aes", .dt_id = TEGRA30_CLK_BSEV },
5981bf40915SPeter De Schrijver { .con_id = "dsia", .dev_id = "tegradc.0", .dt_id = TEGRA30_CLK_DSIA },
5991bf40915SPeter De Schrijver { .con_id = "csi", .dev_id = "tegra_camera", .dt_id = TEGRA30_CLK_CSI },
6001bf40915SPeter De Schrijver { .con_id = "isp", .dev_id = "tegra_camera", .dt_id = TEGRA30_CLK_ISP },
6011bf40915SPeter De Schrijver { .con_id = "pcie", .dev_id = "tegra-pcie", .dt_id = TEGRA30_CLK_PCIE },
6021bf40915SPeter De Schrijver { .con_id = "afi", .dev_id = "tegra-pcie", .dt_id = TEGRA30_CLK_AFI },
6035ab5d404SAlexandre Courbot { .con_id = "fuse", .dt_id = TEGRA30_CLK_FUSE },
6041bf40915SPeter De Schrijver { .con_id = "fuse_burn", .dev_id = "fuse-tegra", .dt_id = TEGRA30_CLK_FUSE_BURN },
6051bf40915SPeter De Schrijver { .con_id = "apbif", .dev_id = "tegra30-ahub", .dt_id = TEGRA30_CLK_APBIF },
6061bf40915SPeter De Schrijver { .con_id = "hda2hdmi", .dev_id = "tegra30-hda", .dt_id = TEGRA30_CLK_HDA2HDMI },
6071bf40915SPeter De Schrijver { .dev_id = "tegra-apbdma", .dt_id = TEGRA30_CLK_APBDMA },
6081bf40915SPeter De Schrijver { .dev_id = "rtc-tegra", .dt_id = TEGRA30_CLK_RTC },
6091bf40915SPeter De Schrijver { .dev_id = "timer", .dt_id = TEGRA30_CLK_TIMER },
6101bf40915SPeter De Schrijver { .dev_id = "tegra-kbc", .dt_id = TEGRA30_CLK_KBC },
6111bf40915SPeter De Schrijver { .dev_id = "fsl-tegra-udc", .dt_id = TEGRA30_CLK_USBD },
6121bf40915SPeter De Schrijver { .dev_id = "tegra-ehci.1", .dt_id = TEGRA30_CLK_USB2 },
6131bf40915SPeter De Schrijver { .dev_id = "tegra-ehci.2", .dt_id = TEGRA30_CLK_USB2 },
6141bf40915SPeter De Schrijver { .dev_id = "kfuse-tegra", .dt_id = TEGRA30_CLK_KFUSE },
6151bf40915SPeter De Schrijver { .dev_id = "tegra_sata_cold", .dt_id = TEGRA30_CLK_SATA_COLD },
6161bf40915SPeter De Schrijver { .dev_id = "dtv", .dt_id = TEGRA30_CLK_DTV },
6171bf40915SPeter De Schrijver { .dev_id = "tegra30-i2s.0", .dt_id = TEGRA30_CLK_I2S0 },
6181bf40915SPeter De Schrijver { .dev_id = "tegra30-i2s.1", .dt_id = TEGRA30_CLK_I2S1 },
6191bf40915SPeter De Schrijver { .dev_id = "tegra30-i2s.2", .dt_id = TEGRA30_CLK_I2S2 },
6201bf40915SPeter De Schrijver { .dev_id = "tegra30-i2s.3", .dt_id = TEGRA30_CLK_I2S3 },
6211bf40915SPeter De Schrijver { .dev_id = "tegra30-i2s.4", .dt_id = TEGRA30_CLK_I2S4 },
6221bf40915SPeter De Schrijver { .con_id = "spdif_out", .dev_id = "tegra30-spdif", .dt_id = TEGRA30_CLK_SPDIF_OUT },
6231bf40915SPeter De Schrijver { .con_id = "spdif_in", .dev_id = "tegra30-spdif", .dt_id = TEGRA30_CLK_SPDIF_IN },
6241bf40915SPeter De Schrijver { .con_id = "d_audio", .dev_id = "tegra30-ahub", .dt_id = TEGRA30_CLK_D_AUDIO },
6251bf40915SPeter De Schrijver { .dev_id = "tegra30-dam.0", .dt_id = TEGRA30_CLK_DAM0 },
6261bf40915SPeter De Schrijver { .dev_id = "tegra30-dam.1", .dt_id = TEGRA30_CLK_DAM1 },
6271bf40915SPeter De Schrijver { .dev_id = "tegra30-dam.2", .dt_id = TEGRA30_CLK_DAM2 },
6281bf40915SPeter De Schrijver { .con_id = "hda", .dev_id = "tegra30-hda", .dt_id = TEGRA30_CLK_HDA },
62936b7be6dSMarcel Ziswiler { .con_id = "hda2codec_2x", .dev_id = "tegra30-hda", .dt_id = TEGRA30_CLK_HDA2CODEC_2X },
6301bf40915SPeter De Schrijver { .dev_id = "spi_tegra.0", .dt_id = TEGRA30_CLK_SBC1 },
6311bf40915SPeter De Schrijver { .dev_id = "spi_tegra.1", .dt_id = TEGRA30_CLK_SBC2 },
6321bf40915SPeter De Schrijver { .dev_id = "spi_tegra.2", .dt_id = TEGRA30_CLK_SBC3 },
6331bf40915SPeter De Schrijver { .dev_id = "spi_tegra.3", .dt_id = TEGRA30_CLK_SBC4 },
6341bf40915SPeter De Schrijver { .dev_id = "spi_tegra.4", .dt_id = TEGRA30_CLK_SBC5 },
6351bf40915SPeter De Schrijver { .dev_id = "spi_tegra.5", .dt_id = TEGRA30_CLK_SBC6 },
6361bf40915SPeter De Schrijver { .dev_id = "tegra_sata_oob", .dt_id = TEGRA30_CLK_SATA_OOB },
6371bf40915SPeter De Schrijver { .dev_id = "tegra_sata", .dt_id = TEGRA30_CLK_SATA },
6381bf40915SPeter De Schrijver { .dev_id = "tegra_nand", .dt_id = TEGRA30_CLK_NDFLASH },
6391bf40915SPeter De Schrijver { .dev_id = "tegra_nand_speed", .dt_id = TEGRA30_CLK_NDSPEED },
6401bf40915SPeter De Schrijver { .dev_id = "vfir", .dt_id = TEGRA30_CLK_VFIR },
6411bf40915SPeter De Schrijver { .dev_id = "csite", .dt_id = TEGRA30_CLK_CSITE },
6421bf40915SPeter De Schrijver { .dev_id = "la", .dt_id = TEGRA30_CLK_LA },
6431bf40915SPeter De Schrijver { .dev_id = "tegra_w1", .dt_id = TEGRA30_CLK_OWR },
6441bf40915SPeter De Schrijver { .dev_id = "mipi", .dt_id = TEGRA30_CLK_MIPI },
6451bf40915SPeter De Schrijver { .dev_id = "tegra-tsensor", .dt_id = TEGRA30_CLK_TSENSOR },
6461bf40915SPeter De Schrijver { .dev_id = "i2cslow", .dt_id = TEGRA30_CLK_I2CSLOW },
6471bf40915SPeter De Schrijver { .dev_id = "vde", .dt_id = TEGRA30_CLK_VDE },
6481bf40915SPeter De Schrijver { .con_id = "vi", .dev_id = "tegra_camera", .dt_id = TEGRA30_CLK_VI },
6491bf40915SPeter De Schrijver { .dev_id = "epp", .dt_id = TEGRA30_CLK_EPP },
6501bf40915SPeter De Schrijver { .dev_id = "mpe", .dt_id = TEGRA30_CLK_MPE },
6511bf40915SPeter De Schrijver { .dev_id = "host1x", .dt_id = TEGRA30_CLK_HOST1X },
6521bf40915SPeter De Schrijver { .dev_id = "3d", .dt_id = TEGRA30_CLK_GR3D },
6531bf40915SPeter De Schrijver { .dev_id = "3d2", .dt_id = TEGRA30_CLK_GR3D2 },
6541bf40915SPeter De Schrijver { .dev_id = "2d", .dt_id = TEGRA30_CLK_GR2D },
6551bf40915SPeter De Schrijver { .dev_id = "se", .dt_id = TEGRA30_CLK_SE },
6561bf40915SPeter De Schrijver { .dev_id = "mselect", .dt_id = TEGRA30_CLK_MSELECT },
6571bf40915SPeter De Schrijver { .dev_id = "tegra-nor", .dt_id = TEGRA30_CLK_NOR },
6581bf40915SPeter De Schrijver { .dev_id = "sdhci-tegra.0", .dt_id = TEGRA30_CLK_SDMMC1 },
6591bf40915SPeter De Schrijver { .dev_id = "sdhci-tegra.1", .dt_id = TEGRA30_CLK_SDMMC2 },
6601bf40915SPeter De Schrijver { .dev_id = "sdhci-tegra.2", .dt_id = TEGRA30_CLK_SDMMC3 },
6611bf40915SPeter De Schrijver { .dev_id = "sdhci-tegra.3", .dt_id = TEGRA30_CLK_SDMMC4 },
6621bf40915SPeter De Schrijver { .dev_id = "cve", .dt_id = TEGRA30_CLK_CVE },
6631bf40915SPeter De Schrijver { .dev_id = "tvo", .dt_id = TEGRA30_CLK_TVO },
6641bf40915SPeter De Schrijver { .dev_id = "tvdac", .dt_id = TEGRA30_CLK_TVDAC },
6651bf40915SPeter De Schrijver { .dev_id = "actmon", .dt_id = TEGRA30_CLK_ACTMON },
6661bf40915SPeter De Schrijver { .con_id = "vi_sensor", .dev_id = "tegra_camera", .dt_id = TEGRA30_CLK_VI_SENSOR },
6671bf40915SPeter De Schrijver { .con_id = "div-clk", .dev_id = "tegra-i2c.0", .dt_id = TEGRA30_CLK_I2C1 },
6681bf40915SPeter De Schrijver { .con_id = "div-clk", .dev_id = "tegra-i2c.1", .dt_id = TEGRA30_CLK_I2C2 },
6691bf40915SPeter De Schrijver { .con_id = "div-clk", .dev_id = "tegra-i2c.2", .dt_id = TEGRA30_CLK_I2C3 },
6701bf40915SPeter De Schrijver { .con_id = "div-clk", .dev_id = "tegra-i2c.3", .dt_id = TEGRA30_CLK_I2C4 },
6711bf40915SPeter De Schrijver { .con_id = "div-clk", .dev_id = "tegra-i2c.4", .dt_id = TEGRA30_CLK_I2C5 },
6721bf40915SPeter De Schrijver { .dev_id = "tegra_uart.0", .dt_id = TEGRA30_CLK_UARTA },
6731bf40915SPeter De Schrijver { .dev_id = "tegra_uart.1", .dt_id = TEGRA30_CLK_UARTB },
6741bf40915SPeter De Schrijver { .dev_id = "tegra_uart.2", .dt_id = TEGRA30_CLK_UARTC },
6751bf40915SPeter De Schrijver { .dev_id = "tegra_uart.3", .dt_id = TEGRA30_CLK_UARTD },
6761bf40915SPeter De Schrijver { .dev_id = "tegra_uart.4", .dt_id = TEGRA30_CLK_UARTE },
6771bf40915SPeter De Schrijver { .dev_id = "hdmi", .dt_id = TEGRA30_CLK_HDMI },
6781bf40915SPeter De Schrijver { .dev_id = "extern1", .dt_id = TEGRA30_CLK_EXTERN1 },
6791bf40915SPeter De Schrijver { .dev_id = "extern2", .dt_id = TEGRA30_CLK_EXTERN2 },
6801bf40915SPeter De Schrijver { .dev_id = "extern3", .dt_id = TEGRA30_CLK_EXTERN3 },
6811bf40915SPeter De Schrijver { .dev_id = "pwm", .dt_id = TEGRA30_CLK_PWM },
6821bf40915SPeter De Schrijver { .dev_id = "tegradc.0", .dt_id = TEGRA30_CLK_DISP1 },
6831bf40915SPeter De Schrijver { .dev_id = "tegradc.1", .dt_id = TEGRA30_CLK_DISP2 },
6841bf40915SPeter De Schrijver { .dev_id = "tegradc.1", .dt_id = TEGRA30_CLK_DSIB },
6851bf40915SPeter De Schrijver };
686b08e8c0eSPrashant Gaikwad
6871bf40915SPeter De Schrijver static struct tegra_clk tegra30_clks[tegra_clk_max] __initdata = {
6881bf40915SPeter De Schrijver [tegra_clk_clk_32k] = { .dt_id = TEGRA30_CLK_CLK_32K, .present = true },
6891bf40915SPeter De Schrijver [tegra_clk_clk_m] = { .dt_id = TEGRA30_CLK_CLK_M, .present = true },
6902b50e49bSSowjanya Komatineni [tegra_clk_osc] = { .dt_id = TEGRA30_CLK_OSC, .present = true },
6919a85eb4dSSowjanya Komatineni [tegra_clk_osc_div2] = { .dt_id = TEGRA30_CLK_OSC_DIV2, .present = true },
6929a85eb4dSSowjanya Komatineni [tegra_clk_osc_div4] = { .dt_id = TEGRA30_CLK_OSC_DIV4, .present = true },
6931bf40915SPeter De Schrijver [tegra_clk_pll_ref] = { .dt_id = TEGRA30_CLK_PLL_REF, .present = true },
6941bf40915SPeter De Schrijver [tegra_clk_spdif_in_sync] = { .dt_id = TEGRA30_CLK_SPDIF_IN_SYNC, .present = true },
6951bf40915SPeter De Schrijver [tegra_clk_i2s0_sync] = { .dt_id = TEGRA30_CLK_I2S0_SYNC, .present = true },
6961bf40915SPeter De Schrijver [tegra_clk_i2s1_sync] = { .dt_id = TEGRA30_CLK_I2S1_SYNC, .present = true },
6971bf40915SPeter De Schrijver [tegra_clk_i2s2_sync] = { .dt_id = TEGRA30_CLK_I2S2_SYNC, .present = true },
6981bf40915SPeter De Schrijver [tegra_clk_i2s3_sync] = { .dt_id = TEGRA30_CLK_I2S3_SYNC, .present = true },
6991bf40915SPeter De Schrijver [tegra_clk_i2s4_sync] = { .dt_id = TEGRA30_CLK_I2S4_SYNC, .present = true },
7001bf40915SPeter De Schrijver [tegra_clk_vimclk_sync] = { .dt_id = TEGRA30_CLK_VIMCLK_SYNC, .present = true },
7011bf40915SPeter De Schrijver [tegra_clk_audio0] = { .dt_id = TEGRA30_CLK_AUDIO0, .present = true },
7021bf40915SPeter De Schrijver [tegra_clk_audio1] = { .dt_id = TEGRA30_CLK_AUDIO1, .present = true },
7031bf40915SPeter De Schrijver [tegra_clk_audio2] = { .dt_id = TEGRA30_CLK_AUDIO2, .present = true },
7041bf40915SPeter De Schrijver [tegra_clk_audio3] = { .dt_id = TEGRA30_CLK_AUDIO3, .present = true },
7051bf40915SPeter De Schrijver [tegra_clk_audio4] = { .dt_id = TEGRA30_CLK_AUDIO4, .present = true },
7061bf40915SPeter De Schrijver [tegra_clk_spdif] = { .dt_id = TEGRA30_CLK_SPDIF, .present = true },
7071bf40915SPeter De Schrijver [tegra_clk_audio0_mux] = { .dt_id = TEGRA30_CLK_AUDIO0_MUX, .present = true },
7081bf40915SPeter De Schrijver [tegra_clk_audio1_mux] = { .dt_id = TEGRA30_CLK_AUDIO1_MUX, .present = true },
7091bf40915SPeter De Schrijver [tegra_clk_audio2_mux] = { .dt_id = TEGRA30_CLK_AUDIO2_MUX, .present = true },
7101bf40915SPeter De Schrijver [tegra_clk_audio3_mux] = { .dt_id = TEGRA30_CLK_AUDIO3_MUX, .present = true },
7111bf40915SPeter De Schrijver [tegra_clk_audio4_mux] = { .dt_id = TEGRA30_CLK_AUDIO4_MUX, .present = true },
7121bf40915SPeter De Schrijver [tegra_clk_spdif_mux] = { .dt_id = TEGRA30_CLK_SPDIF_MUX, .present = true },
7131bf40915SPeter De Schrijver [tegra_clk_audio0_2x] = { .dt_id = TEGRA30_CLK_AUDIO0_2X, .present = true },
7141bf40915SPeter De Schrijver [tegra_clk_audio1_2x] = { .dt_id = TEGRA30_CLK_AUDIO1_2X, .present = true },
7151bf40915SPeter De Schrijver [tegra_clk_audio2_2x] = { .dt_id = TEGRA30_CLK_AUDIO2_2X, .present = true },
7161bf40915SPeter De Schrijver [tegra_clk_audio3_2x] = { .dt_id = TEGRA30_CLK_AUDIO3_2X, .present = true },
7171bf40915SPeter De Schrijver [tegra_clk_audio4_2x] = { .dt_id = TEGRA30_CLK_AUDIO4_2X, .present = true },
7181bf40915SPeter De Schrijver [tegra_clk_spdif_2x] = { .dt_id = TEGRA30_CLK_SPDIF_2X, .present = true },
7191bf40915SPeter De Schrijver [tegra_clk_hclk] = { .dt_id = TEGRA30_CLK_HCLK, .present = true },
7201bf40915SPeter De Schrijver [tegra_clk_pclk] = { .dt_id = TEGRA30_CLK_PCLK, .present = true },
7211bf40915SPeter De Schrijver [tegra_clk_i2s0] = { .dt_id = TEGRA30_CLK_I2S0, .present = true },
7221bf40915SPeter De Schrijver [tegra_clk_i2s1] = { .dt_id = TEGRA30_CLK_I2S1, .present = true },
7231bf40915SPeter De Schrijver [tegra_clk_i2s2] = { .dt_id = TEGRA30_CLK_I2S2, .present = true },
7241bf40915SPeter De Schrijver [tegra_clk_i2s3] = { .dt_id = TEGRA30_CLK_I2S3, .present = true },
7251bf40915SPeter De Schrijver [tegra_clk_i2s4] = { .dt_id = TEGRA30_CLK_I2S4, .present = true },
7261bf40915SPeter De Schrijver [tegra_clk_spdif_in] = { .dt_id = TEGRA30_CLK_SPDIF_IN, .present = true },
7271bf40915SPeter De Schrijver [tegra_clk_hda] = { .dt_id = TEGRA30_CLK_HDA, .present = true },
7281bf40915SPeter De Schrijver [tegra_clk_hda2codec_2x] = { .dt_id = TEGRA30_CLK_HDA2CODEC_2X, .present = true },
7291bf40915SPeter De Schrijver [tegra_clk_sbc1] = { .dt_id = TEGRA30_CLK_SBC1, .present = true },
7301bf40915SPeter De Schrijver [tegra_clk_sbc2] = { .dt_id = TEGRA30_CLK_SBC2, .present = true },
7311bf40915SPeter De Schrijver [tegra_clk_sbc3] = { .dt_id = TEGRA30_CLK_SBC3, .present = true },
7321bf40915SPeter De Schrijver [tegra_clk_sbc4] = { .dt_id = TEGRA30_CLK_SBC4, .present = true },
7331bf40915SPeter De Schrijver [tegra_clk_sbc5] = { .dt_id = TEGRA30_CLK_SBC5, .present = true },
7341bf40915SPeter De Schrijver [tegra_clk_sbc6] = { .dt_id = TEGRA30_CLK_SBC6, .present = true },
7351bf40915SPeter De Schrijver [tegra_clk_ndflash] = { .dt_id = TEGRA30_CLK_NDFLASH, .present = true },
7361bf40915SPeter De Schrijver [tegra_clk_ndspeed] = { .dt_id = TEGRA30_CLK_NDSPEED, .present = true },
7371bf40915SPeter De Schrijver [tegra_clk_vfir] = { .dt_id = TEGRA30_CLK_VFIR, .present = true },
7381bf40915SPeter De Schrijver [tegra_clk_la] = { .dt_id = TEGRA30_CLK_LA, .present = true },
7391bf40915SPeter De Schrijver [tegra_clk_csite] = { .dt_id = TEGRA30_CLK_CSITE, .present = true },
7401bf40915SPeter De Schrijver [tegra_clk_owr] = { .dt_id = TEGRA30_CLK_OWR, .present = true },
7411bf40915SPeter De Schrijver [tegra_clk_mipi] = { .dt_id = TEGRA30_CLK_MIPI, .present = true },
7421bf40915SPeter De Schrijver [tegra_clk_tsensor] = { .dt_id = TEGRA30_CLK_TSENSOR, .present = true },
7431bf40915SPeter De Schrijver [tegra_clk_i2cslow] = { .dt_id = TEGRA30_CLK_I2CSLOW, .present = true },
7441bf40915SPeter De Schrijver [tegra_clk_vde] = { .dt_id = TEGRA30_CLK_VDE, .present = true },
7451bf40915SPeter De Schrijver [tegra_clk_vi] = { .dt_id = TEGRA30_CLK_VI, .present = true },
7461bf40915SPeter De Schrijver [tegra_clk_epp] = { .dt_id = TEGRA30_CLK_EPP, .present = true },
7471bf40915SPeter De Schrijver [tegra_clk_mpe] = { .dt_id = TEGRA30_CLK_MPE, .present = true },
7481bf40915SPeter De Schrijver [tegra_clk_host1x] = { .dt_id = TEGRA30_CLK_HOST1X, .present = true },
7491bf40915SPeter De Schrijver [tegra_clk_gr2d] = { .dt_id = TEGRA30_CLK_GR2D, .present = true },
7501bf40915SPeter De Schrijver [tegra_clk_gr3d] = { .dt_id = TEGRA30_CLK_GR3D, .present = true },
7511bf40915SPeter De Schrijver [tegra_clk_mselect] = { .dt_id = TEGRA30_CLK_MSELECT, .present = true },
7521bf40915SPeter De Schrijver [tegra_clk_nor] = { .dt_id = TEGRA30_CLK_NOR, .present = true },
7531bf40915SPeter De Schrijver [tegra_clk_sdmmc1] = { .dt_id = TEGRA30_CLK_SDMMC1, .present = true },
7541bf40915SPeter De Schrijver [tegra_clk_sdmmc2] = { .dt_id = TEGRA30_CLK_SDMMC2, .present = true },
7551bf40915SPeter De Schrijver [tegra_clk_sdmmc3] = { .dt_id = TEGRA30_CLK_SDMMC3, .present = true },
7561bf40915SPeter De Schrijver [tegra_clk_sdmmc4] = { .dt_id = TEGRA30_CLK_SDMMC4, .present = true },
7571bf40915SPeter De Schrijver [tegra_clk_cve] = { .dt_id = TEGRA30_CLK_CVE, .present = true },
7581bf40915SPeter De Schrijver [tegra_clk_tvo] = { .dt_id = TEGRA30_CLK_TVO, .present = true },
7591bf40915SPeter De Schrijver [tegra_clk_tvdac] = { .dt_id = TEGRA30_CLK_TVDAC, .present = true },
7601bf40915SPeter De Schrijver [tegra_clk_actmon] = { .dt_id = TEGRA30_CLK_ACTMON, .present = true },
7611bf40915SPeter De Schrijver [tegra_clk_vi_sensor] = { .dt_id = TEGRA30_CLK_VI_SENSOR, .present = true },
7621bf40915SPeter De Schrijver [tegra_clk_i2c1] = { .dt_id = TEGRA30_CLK_I2C1, .present = true },
7631bf40915SPeter De Schrijver [tegra_clk_i2c2] = { .dt_id = TEGRA30_CLK_I2C2, .present = true },
7641bf40915SPeter De Schrijver [tegra_clk_i2c3] = { .dt_id = TEGRA30_CLK_I2C3, .present = true },
7651bf40915SPeter De Schrijver [tegra_clk_i2c4] = { .dt_id = TEGRA30_CLK_I2C4, .present = true },
7661bf40915SPeter De Schrijver [tegra_clk_i2c5] = { .dt_id = TEGRA30_CLK_I2C5, .present = true },
7671bf40915SPeter De Schrijver [tegra_clk_uarta] = { .dt_id = TEGRA30_CLK_UARTA, .present = true },
7681bf40915SPeter De Schrijver [tegra_clk_uartb] = { .dt_id = TEGRA30_CLK_UARTB, .present = true },
7691bf40915SPeter De Schrijver [tegra_clk_uartc] = { .dt_id = TEGRA30_CLK_UARTC, .present = true },
7701bf40915SPeter De Schrijver [tegra_clk_uartd] = { .dt_id = TEGRA30_CLK_UARTD, .present = true },
7711bf40915SPeter De Schrijver [tegra_clk_uarte] = { .dt_id = TEGRA30_CLK_UARTE, .present = true },
7721bf40915SPeter De Schrijver [tegra_clk_extern1] = { .dt_id = TEGRA30_CLK_EXTERN1, .present = true },
7731bf40915SPeter De Schrijver [tegra_clk_extern2] = { .dt_id = TEGRA30_CLK_EXTERN2, .present = true },
7741bf40915SPeter De Schrijver [tegra_clk_extern3] = { .dt_id = TEGRA30_CLK_EXTERN3, .present = true },
7751bf40915SPeter De Schrijver [tegra_clk_disp1] = { .dt_id = TEGRA30_CLK_DISP1, .present = true },
7761bf40915SPeter De Schrijver [tegra_clk_disp2] = { .dt_id = TEGRA30_CLK_DISP2, .present = true },
777899f8095SDmitry Osipenko [tegra_clk_ahbdma] = { .dt_id = TEGRA30_CLK_AHBDMA, .present = true },
7781bf40915SPeter De Schrijver [tegra_clk_apbdma] = { .dt_id = TEGRA30_CLK_APBDMA, .present = true },
7791bf40915SPeter De Schrijver [tegra_clk_rtc] = { .dt_id = TEGRA30_CLK_RTC, .present = true },
7801bf40915SPeter De Schrijver [tegra_clk_timer] = { .dt_id = TEGRA30_CLK_TIMER, .present = true },
7811bf40915SPeter De Schrijver [tegra_clk_kbc] = { .dt_id = TEGRA30_CLK_KBC, .present = true },
7821bf40915SPeter De Schrijver [tegra_clk_csus] = { .dt_id = TEGRA30_CLK_CSUS, .present = true },
7831bf40915SPeter De Schrijver [tegra_clk_vcp] = { .dt_id = TEGRA30_CLK_VCP, .present = true },
7841bf40915SPeter De Schrijver [tegra_clk_bsea] = { .dt_id = TEGRA30_CLK_BSEA, .present = true },
7851bf40915SPeter De Schrijver [tegra_clk_bsev] = { .dt_id = TEGRA30_CLK_BSEV, .present = true },
7861bf40915SPeter De Schrijver [tegra_clk_usbd] = { .dt_id = TEGRA30_CLK_USBD, .present = true },
7871bf40915SPeter De Schrijver [tegra_clk_usb2] = { .dt_id = TEGRA30_CLK_USB2, .present = true },
7881bf40915SPeter De Schrijver [tegra_clk_usb3] = { .dt_id = TEGRA30_CLK_USB3, .present = true },
7891bf40915SPeter De Schrijver [tegra_clk_csi] = { .dt_id = TEGRA30_CLK_CSI, .present = true },
7901bf40915SPeter De Schrijver [tegra_clk_isp] = { .dt_id = TEGRA30_CLK_ISP, .present = true },
7911bf40915SPeter De Schrijver [tegra_clk_kfuse] = { .dt_id = TEGRA30_CLK_KFUSE, .present = true },
7921bf40915SPeter De Schrijver [tegra_clk_fuse] = { .dt_id = TEGRA30_CLK_FUSE, .present = true },
7931bf40915SPeter De Schrijver [tegra_clk_fuse_burn] = { .dt_id = TEGRA30_CLK_FUSE_BURN, .present = true },
7941bf40915SPeter De Schrijver [tegra_clk_apbif] = { .dt_id = TEGRA30_CLK_APBIF, .present = true },
7951bf40915SPeter De Schrijver [tegra_clk_hda2hdmi] = { .dt_id = TEGRA30_CLK_HDA2HDMI, .present = true },
7961bf40915SPeter De Schrijver [tegra_clk_sata_cold] = { .dt_id = TEGRA30_CLK_SATA_COLD, .present = true },
7971bf40915SPeter De Schrijver [tegra_clk_sata_oob] = { .dt_id = TEGRA30_CLK_SATA_OOB, .present = true },
7981bf40915SPeter De Schrijver [tegra_clk_sata] = { .dt_id = TEGRA30_CLK_SATA, .present = true },
7991bf40915SPeter De Schrijver [tegra_clk_dtv] = { .dt_id = TEGRA30_CLK_DTV, .present = true },
8001bf40915SPeter De Schrijver [tegra_clk_pll_p] = { .dt_id = TEGRA30_CLK_PLL_P, .present = true },
8011bf40915SPeter De Schrijver [tegra_clk_pll_p_out1] = { .dt_id = TEGRA30_CLK_PLL_P_OUT1, .present = true },
8021bf40915SPeter De Schrijver [tegra_clk_pll_p_out2] = { .dt_id = TEGRA30_CLK_PLL_P_OUT2, .present = true },
8031bf40915SPeter De Schrijver [tegra_clk_pll_p_out3] = { .dt_id = TEGRA30_CLK_PLL_P_OUT3, .present = true },
8041bf40915SPeter De Schrijver [tegra_clk_pll_p_out4] = { .dt_id = TEGRA30_CLK_PLL_P_OUT4, .present = true },
8051bf40915SPeter De Schrijver [tegra_clk_pll_a] = { .dt_id = TEGRA30_CLK_PLL_A, .present = true },
8061bf40915SPeter De Schrijver [tegra_clk_pll_a_out0] = { .dt_id = TEGRA30_CLK_PLL_A_OUT0, .present = true },
807bfa34832SPeter De Schrijver [tegra_clk_cec] = { .dt_id = TEGRA30_CLK_CEC, .present = true },
808ed1a2459SDmitry Osipenko [tegra_clk_emc] = { .dt_id = TEGRA30_CLK_EMC, .present = false },
8091bf40915SPeter De Schrijver };
810b08e8c0eSPrashant Gaikwad
811b08e8c0eSPrashant Gaikwad static const char *pll_e_parents[] = { "pll_ref", "pll_p" };
812b08e8c0eSPrashant Gaikwad
tegra30_pll_init(void)813b08e8c0eSPrashant Gaikwad static void __init tegra30_pll_init(void)
814b08e8c0eSPrashant Gaikwad {
815b08e8c0eSPrashant Gaikwad struct clk *clk;
816b08e8c0eSPrashant Gaikwad
817b08e8c0eSPrashant Gaikwad /* PLLC_OUT1 */
818b08e8c0eSPrashant Gaikwad clk = tegra_clk_register_divider("pll_c_out1_div", "pll_c",
819b08e8c0eSPrashant Gaikwad clk_base + PLLC_OUT, 0, TEGRA_DIVIDER_ROUND_UP,
820b08e8c0eSPrashant Gaikwad 8, 8, 1, NULL);
821b08e8c0eSPrashant Gaikwad clk = tegra_clk_register_pll_out("pll_c_out1", "pll_c_out1_div",
822b08e8c0eSPrashant Gaikwad clk_base + PLLC_OUT, 1, 0, CLK_SET_RATE_PARENT,
823b08e8c0eSPrashant Gaikwad 0, NULL);
8241bf40915SPeter De Schrijver clks[TEGRA30_CLK_PLL_C_OUT1] = clk;
825b08e8c0eSPrashant Gaikwad
826b08e8c0eSPrashant Gaikwad /* PLLM_OUT1 */
827b08e8c0eSPrashant Gaikwad clk = tegra_clk_register_divider("pll_m_out1_div", "pll_m",
828b08e8c0eSPrashant Gaikwad clk_base + PLLM_OUT, 0, TEGRA_DIVIDER_ROUND_UP,
829b08e8c0eSPrashant Gaikwad 8, 8, 1, NULL);
830b08e8c0eSPrashant Gaikwad clk = tegra_clk_register_pll_out("pll_m_out1", "pll_m_out1_div",
8312dcabf05SDmitry Osipenko clk_base + PLLM_OUT, 1, 0,
832b08e8c0eSPrashant Gaikwad CLK_SET_RATE_PARENT, 0, NULL);
8331bf40915SPeter De Schrijver clks[TEGRA30_CLK_PLL_M_OUT1] = clk;
834b08e8c0eSPrashant Gaikwad
835b08e8c0eSPrashant Gaikwad /* PLLX */
836b08e8c0eSPrashant Gaikwad clk = tegra_clk_register_pll("pll_x", "pll_ref", clk_base, pmc_base, 0,
837ebe142b2SPeter De Schrijver &pll_x_params, NULL);
8381bf40915SPeter De Schrijver clks[TEGRA30_CLK_PLL_X] = clk;
839b08e8c0eSPrashant Gaikwad
840b08e8c0eSPrashant Gaikwad /* PLLX_OUT0 */
841b08e8c0eSPrashant Gaikwad clk = clk_register_fixed_factor(NULL, "pll_x_out0", "pll_x",
842b08e8c0eSPrashant Gaikwad CLK_SET_RATE_PARENT, 1, 2);
8431bf40915SPeter De Schrijver clks[TEGRA30_CLK_PLL_X_OUT0] = clk;
844b08e8c0eSPrashant Gaikwad
845b08e8c0eSPrashant Gaikwad /* PLLU */
84615d68e8cSAndrew Bresticker clk = tegra_clk_register_pllu("pll_u", "pll_ref", clk_base, 0,
847ebe142b2SPeter De Schrijver &pll_u_params, NULL);
8481bf40915SPeter De Schrijver clks[TEGRA30_CLK_PLL_U] = clk;
849b08e8c0eSPrashant Gaikwad
850b08e8c0eSPrashant Gaikwad /* PLLD */
851b08e8c0eSPrashant Gaikwad clk = tegra_clk_register_pll("pll_d", "pll_ref", clk_base, pmc_base, 0,
852ebe142b2SPeter De Schrijver &pll_d_params, &pll_d_lock);
8531bf40915SPeter De Schrijver clks[TEGRA30_CLK_PLL_D] = clk;
854b08e8c0eSPrashant Gaikwad
855b08e8c0eSPrashant Gaikwad /* PLLD_OUT0 */
856b08e8c0eSPrashant Gaikwad clk = clk_register_fixed_factor(NULL, "pll_d_out0", "pll_d",
857b08e8c0eSPrashant Gaikwad CLK_SET_RATE_PARENT, 1, 2);
8581bf40915SPeter De Schrijver clks[TEGRA30_CLK_PLL_D_OUT0] = clk;
859b08e8c0eSPrashant Gaikwad
860b08e8c0eSPrashant Gaikwad /* PLLD2 */
861b08e8c0eSPrashant Gaikwad clk = tegra_clk_register_pll("pll_d2", "pll_ref", clk_base, pmc_base, 0,
862ebe142b2SPeter De Schrijver &pll_d2_params, NULL);
8631bf40915SPeter De Schrijver clks[TEGRA30_CLK_PLL_D2] = clk;
864b08e8c0eSPrashant Gaikwad
865b08e8c0eSPrashant Gaikwad /* PLLD2_OUT0 */
866b08e8c0eSPrashant Gaikwad clk = clk_register_fixed_factor(NULL, "pll_d2_out0", "pll_d2",
867b08e8c0eSPrashant Gaikwad CLK_SET_RATE_PARENT, 1, 2);
8681bf40915SPeter De Schrijver clks[TEGRA30_CLK_PLL_D2_OUT0] = clk;
869b08e8c0eSPrashant Gaikwad
870b08e8c0eSPrashant Gaikwad /* PLLE */
871b08e8c0eSPrashant Gaikwad clk = clk_register_mux(NULL, "pll_e_mux", pll_e_parents,
872819c1de3SJames Hogan ARRAY_SIZE(pll_e_parents),
873819c1de3SJames Hogan CLK_SET_RATE_NO_REPARENT,
874b08e8c0eSPrashant Gaikwad clk_base + PLLE_AUX, 2, 1, 0, NULL);
875b08e8c0eSPrashant Gaikwad }
876b08e8c0eSPrashant Gaikwad
877b4c154a3SPeter De Schrijver static const char *cclk_g_parents[] = { "clk_m", "pll_c", "clk_32k", "pll_m",
878b08e8c0eSPrashant Gaikwad "pll_p_cclkg", "pll_p_out4_cclkg",
879b08e8c0eSPrashant Gaikwad "pll_p_out3_cclkg", "unused", "pll_x" };
880b4c154a3SPeter De Schrijver static const char *cclk_lp_parents[] = { "clk_m", "pll_c", "clk_32k", "pll_m",
881b08e8c0eSPrashant Gaikwad "pll_p_cclklp", "pll_p_out4_cclklp",
882b08e8c0eSPrashant Gaikwad "pll_p_out3_cclklp", "unused", "pll_x",
883b08e8c0eSPrashant Gaikwad "pll_x_out0" };
884b4c154a3SPeter De Schrijver static const char *sclk_parents[] = { "clk_m", "pll_c_out1", "pll_p_out4",
885b08e8c0eSPrashant Gaikwad "pll_p_out3", "pll_p_out2", "unused",
886b08e8c0eSPrashant Gaikwad "clk_32k", "pll_m_out1" };
887b08e8c0eSPrashant Gaikwad
tegra30_super_clk_init(void)888b08e8c0eSPrashant Gaikwad static void __init tegra30_super_clk_init(void)
889b08e8c0eSPrashant Gaikwad {
890b08e8c0eSPrashant Gaikwad struct clk *clk;
891b08e8c0eSPrashant Gaikwad
892b08e8c0eSPrashant Gaikwad /*
893b08e8c0eSPrashant Gaikwad * Clock input to cclk_g divided from pll_p using
894b08e8c0eSPrashant Gaikwad * U71 divider of cclk_g.
895b08e8c0eSPrashant Gaikwad */
896b08e8c0eSPrashant Gaikwad clk = tegra_clk_register_divider("pll_p_cclkg", "pll_p",
897b08e8c0eSPrashant Gaikwad clk_base + SUPER_CCLKG_DIVIDER, 0,
898b08e8c0eSPrashant Gaikwad TEGRA_DIVIDER_INT, 16, 8, 1, NULL);
899b08e8c0eSPrashant Gaikwad clk_register_clkdev(clk, "pll_p_cclkg", NULL);
900b08e8c0eSPrashant Gaikwad
901b08e8c0eSPrashant Gaikwad /*
902b08e8c0eSPrashant Gaikwad * Clock input to cclk_g divided from pll_p_out3 using
903b08e8c0eSPrashant Gaikwad * U71 divider of cclk_g.
904b08e8c0eSPrashant Gaikwad */
905b08e8c0eSPrashant Gaikwad clk = tegra_clk_register_divider("pll_p_out3_cclkg", "pll_p_out3",
906b08e8c0eSPrashant Gaikwad clk_base + SUPER_CCLKG_DIVIDER, 0,
907b08e8c0eSPrashant Gaikwad TEGRA_DIVIDER_INT, 16, 8, 1, NULL);
908b08e8c0eSPrashant Gaikwad clk_register_clkdev(clk, "pll_p_out3_cclkg", NULL);
909b08e8c0eSPrashant Gaikwad
910b08e8c0eSPrashant Gaikwad /*
911b08e8c0eSPrashant Gaikwad * Clock input to cclk_g divided from pll_p_out4 using
912b08e8c0eSPrashant Gaikwad * U71 divider of cclk_g.
913b08e8c0eSPrashant Gaikwad */
914b08e8c0eSPrashant Gaikwad clk = tegra_clk_register_divider("pll_p_out4_cclkg", "pll_p_out4",
915b08e8c0eSPrashant Gaikwad clk_base + SUPER_CCLKG_DIVIDER, 0,
916b08e8c0eSPrashant Gaikwad TEGRA_DIVIDER_INT, 16, 8, 1, NULL);
917b08e8c0eSPrashant Gaikwad clk_register_clkdev(clk, "pll_p_out4_cclkg", NULL);
918b08e8c0eSPrashant Gaikwad
919b08e8c0eSPrashant Gaikwad /* CCLKG */
92042329854SDmitry Osipenko clk = tegra_clk_register_super_cclk("cclk_g", cclk_g_parents,
921b08e8c0eSPrashant Gaikwad ARRAY_SIZE(cclk_g_parents),
922344d5df3SDmitry Osipenko CLK_SET_RATE_PARENT | CLK_GET_RATE_NOCACHE,
923b08e8c0eSPrashant Gaikwad clk_base + CCLKG_BURST_POLICY,
92442329854SDmitry Osipenko 0, NULL);
9251bf40915SPeter De Schrijver clks[TEGRA30_CLK_CCLK_G] = clk;
926b08e8c0eSPrashant Gaikwad
927b08e8c0eSPrashant Gaikwad /*
928b08e8c0eSPrashant Gaikwad * Clock input to cclk_lp divided from pll_p using
929b08e8c0eSPrashant Gaikwad * U71 divider of cclk_lp.
930b08e8c0eSPrashant Gaikwad */
931b08e8c0eSPrashant Gaikwad clk = tegra_clk_register_divider("pll_p_cclklp", "pll_p",
932b08e8c0eSPrashant Gaikwad clk_base + SUPER_CCLKLP_DIVIDER, 0,
933b08e8c0eSPrashant Gaikwad TEGRA_DIVIDER_INT, 16, 8, 1, NULL);
934b08e8c0eSPrashant Gaikwad clk_register_clkdev(clk, "pll_p_cclklp", NULL);
935b08e8c0eSPrashant Gaikwad
936b08e8c0eSPrashant Gaikwad /*
937b08e8c0eSPrashant Gaikwad * Clock input to cclk_lp divided from pll_p_out3 using
938b08e8c0eSPrashant Gaikwad * U71 divider of cclk_lp.
939b08e8c0eSPrashant Gaikwad */
940b08e8c0eSPrashant Gaikwad clk = tegra_clk_register_divider("pll_p_out3_cclklp", "pll_p_out3",
94154eff226SMichał Mirosław clk_base + SUPER_CCLKLP_DIVIDER, 0,
942b08e8c0eSPrashant Gaikwad TEGRA_DIVIDER_INT, 16, 8, 1, NULL);
943b08e8c0eSPrashant Gaikwad clk_register_clkdev(clk, "pll_p_out3_cclklp", NULL);
944b08e8c0eSPrashant Gaikwad
945b08e8c0eSPrashant Gaikwad /*
946b08e8c0eSPrashant Gaikwad * Clock input to cclk_lp divided from pll_p_out4 using
947b08e8c0eSPrashant Gaikwad * U71 divider of cclk_lp.
948b08e8c0eSPrashant Gaikwad */
949b08e8c0eSPrashant Gaikwad clk = tegra_clk_register_divider("pll_p_out4_cclklp", "pll_p_out4",
950b08e8c0eSPrashant Gaikwad clk_base + SUPER_CCLKLP_DIVIDER, 0,
951b08e8c0eSPrashant Gaikwad TEGRA_DIVIDER_INT, 16, 8, 1, NULL);
952b08e8c0eSPrashant Gaikwad clk_register_clkdev(clk, "pll_p_out4_cclklp", NULL);
953b08e8c0eSPrashant Gaikwad
954b08e8c0eSPrashant Gaikwad /* CCLKLP */
955b08e8c0eSPrashant Gaikwad clk = tegra_clk_register_super_mux("cclk_lp", cclk_lp_parents,
956b08e8c0eSPrashant Gaikwad ARRAY_SIZE(cclk_lp_parents),
957b08e8c0eSPrashant Gaikwad CLK_SET_RATE_PARENT,
958b08e8c0eSPrashant Gaikwad clk_base + CCLKLP_BURST_POLICY,
959b08e8c0eSPrashant Gaikwad TEGRA_DIVIDER_2, 4, 8, 9,
960b08e8c0eSPrashant Gaikwad NULL);
9611bf40915SPeter De Schrijver clks[TEGRA30_CLK_CCLK_LP] = clk;
962b08e8c0eSPrashant Gaikwad
963b08e8c0eSPrashant Gaikwad /* twd */
964b08e8c0eSPrashant Gaikwad clk = clk_register_fixed_factor(NULL, "twd", "cclk_g",
965b08e8c0eSPrashant Gaikwad CLK_SET_RATE_PARENT, 1, 2);
9661bf40915SPeter De Schrijver clks[TEGRA30_CLK_TWD] = clk;
9671bf40915SPeter De Schrijver
9681bf40915SPeter De Schrijver tegra_super_clk_gen4_init(clk_base, pmc_base, tegra30_clks, NULL);
969b08e8c0eSPrashant Gaikwad }
970b08e8c0eSPrashant Gaikwad
971b08e8c0eSPrashant Gaikwad static const char *mux_pllacp_clkm[] = { "pll_a_out0", "unused", "pll_p",
972b08e8c0eSPrashant Gaikwad "clk_m" };
973b08e8c0eSPrashant Gaikwad static const char *mux_pllpcm_clkm[] = { "pll_p", "pll_c", "pll_m", "clk_m" };
974b08e8c0eSPrashant Gaikwad static const char *spdif_out_parents[] = { "pll_a_out0", "spdif_2x", "pll_p",
975b08e8c0eSPrashant Gaikwad "clk_m" };
976b08e8c0eSPrashant Gaikwad static const char *mux_pllmcpa[] = { "pll_m", "pll_c", "pll_p", "pll_a_out0" };
977b08e8c0eSPrashant Gaikwad static const char *mux_pllpmdacd2_clkm[] = { "pll_p", "pll_m", "pll_d_out0",
978b08e8c0eSPrashant Gaikwad "pll_a_out0", "pll_c",
979b08e8c0eSPrashant Gaikwad "pll_d2_out0", "clk_m" };
980b08e8c0eSPrashant Gaikwad static const char *mux_plld_out0_plld2_out0[] = { "pll_d_out0",
981b08e8c0eSPrashant Gaikwad "pll_d2_out0" };
982c04bf559SThierry Reding static const char *pwm_parents[] = { "pll_p", "pll_c", "clk_32k", "clk_m" };
983b08e8c0eSPrashant Gaikwad
984b08e8c0eSPrashant Gaikwad static struct tegra_periph_init_data tegra_periph_clk_list[] = {
9851bf40915SPeter De Schrijver TEGRA_INIT_DATA_MUX("spdif_out", spdif_out_parents, CLK_SOURCE_SPDIF_OUT, 10, TEGRA_PERIPH_ON_APB, TEGRA30_CLK_SPDIF_OUT),
9861bf40915SPeter De Schrijver TEGRA_INIT_DATA_MUX("d_audio", mux_pllacp_clkm, CLK_SOURCE_D_AUDIO, 106, 0, TEGRA30_CLK_D_AUDIO),
9871bf40915SPeter De Schrijver TEGRA_INIT_DATA_MUX("dam0", mux_pllacp_clkm, CLK_SOURCE_DAM0, 108, 0, TEGRA30_CLK_DAM0),
9881bf40915SPeter De Schrijver TEGRA_INIT_DATA_MUX("dam1", mux_pllacp_clkm, CLK_SOURCE_DAM1, 109, 0, TEGRA30_CLK_DAM1),
9891bf40915SPeter De Schrijver TEGRA_INIT_DATA_MUX("dam2", mux_pllacp_clkm, CLK_SOURCE_DAM2, 110, 0, TEGRA30_CLK_DAM2),
9904782c0a5SDmitry Osipenko TEGRA_INIT_DATA_INT("3d2", mux_pllmcpa, CLK_SOURCE_3D2, 98, 0, TEGRA30_CLK_GR3D2),
9911bf40915SPeter De Schrijver TEGRA_INIT_DATA_INT("se", mux_pllpcm_clkm, CLK_SOURCE_SE, 127, 0, TEGRA30_CLK_SE),
9921bf40915SPeter De Schrijver TEGRA_INIT_DATA_MUX8("hdmi", mux_pllpmdacd2_clkm, CLK_SOURCE_HDMI, 51, 0, TEGRA30_CLK_HDMI),
993c04bf559SThierry Reding TEGRA_INIT_DATA("pwm", NULL, NULL, pwm_parents, CLK_SOURCE_PWM, 28, 2, 0, 0, 8, 1, 0, 17, TEGRA_PERIPH_ON_APB, TEGRA30_CLK_PWM),
994b08e8c0eSPrashant Gaikwad };
995b08e8c0eSPrashant Gaikwad
996b08e8c0eSPrashant Gaikwad static struct tegra_periph_init_data tegra_periph_nodiv_clk_list[] = {
9971bf40915SPeter De Schrijver TEGRA_INIT_DATA_NODIV("dsib", mux_plld_out0_plld2_out0, CLK_SOURCE_DSIB, 25, 1, 82, 0, TEGRA30_CLK_DSIB),
998b08e8c0eSPrashant Gaikwad };
999b08e8c0eSPrashant Gaikwad
tegra30_periph_clk_init(void)1000b08e8c0eSPrashant Gaikwad static void __init tegra30_periph_clk_init(void)
1001b08e8c0eSPrashant Gaikwad {
1002b08e8c0eSPrashant Gaikwad struct tegra_periph_init_data *data;
1003b08e8c0eSPrashant Gaikwad struct clk *clk;
1004e52d7c04SThierry Reding unsigned int i;
1005b08e8c0eSPrashant Gaikwad
1006b08e8c0eSPrashant Gaikwad /* dsia */
1007b08e8c0eSPrashant Gaikwad clk = tegra_clk_register_periph_gate("dsia", "pll_d_out0", 0, clk_base,
1008d5ff89a8SPeter De Schrijver 0, 48, periph_clk_enb_refcnt);
10091bf40915SPeter De Schrijver clks[TEGRA30_CLK_DSIA] = clk;
1010b08e8c0eSPrashant Gaikwad
1011b08e8c0eSPrashant Gaikwad /* pcie */
1012b08e8c0eSPrashant Gaikwad clk = tegra_clk_register_periph_gate("pcie", "clk_m", 0, clk_base, 0,
1013d5ff89a8SPeter De Schrijver 70, periph_clk_enb_refcnt);
10141bf40915SPeter De Schrijver clks[TEGRA30_CLK_PCIE] = clk;
1015b08e8c0eSPrashant Gaikwad
1016b08e8c0eSPrashant Gaikwad /* afi */
1017b08e8c0eSPrashant Gaikwad clk = tegra_clk_register_periph_gate("afi", "clk_m", 0, clk_base, 0, 72,
1018d5ff89a8SPeter De Schrijver periph_clk_enb_refcnt);
10191bf40915SPeter De Schrijver clks[TEGRA30_CLK_AFI] = clk;
1020b08e8c0eSPrashant Gaikwad
1021b08e8c0eSPrashant Gaikwad /* emc */
1022ed1a2459SDmitry Osipenko clk = tegra20_clk_register_emc(clk_base + CLK_SOURCE_EMC, true);
10231bf40915SPeter De Schrijver
1024ed1a2459SDmitry Osipenko clks[TEGRA30_CLK_EMC] = clk;
1025ed1a2459SDmitry Osipenko
1026ed1a2459SDmitry Osipenko clk = tegra_clk_register_mc("mc", "emc", clk_base + CLK_SOURCE_EMC,
1027ed1a2459SDmitry Osipenko NULL);
10284f4f85faSThierry Reding clks[TEGRA30_CLK_MC] = clk;
10294f4f85faSThierry Reding
10301bf40915SPeter De Schrijver /* cml0 */
10311bf40915SPeter De Schrijver clk = clk_register_gate(NULL, "cml0", "pll_e", 0, clk_base + PLLE_AUX,
10321bf40915SPeter De Schrijver 0, 0, &cml_lock);
10331bf40915SPeter De Schrijver clks[TEGRA30_CLK_CML0] = clk;
10341bf40915SPeter De Schrijver
10351bf40915SPeter De Schrijver /* cml1 */
10361bf40915SPeter De Schrijver clk = clk_register_gate(NULL, "cml1", "pll_e", 0, clk_base + PLLE_AUX,
10371bf40915SPeter De Schrijver 1, 0, &cml_lock);
10381bf40915SPeter De Schrijver clks[TEGRA30_CLK_CML1] = clk;
1039b08e8c0eSPrashant Gaikwad
1040b08e8c0eSPrashant Gaikwad for (i = 0; i < ARRAY_SIZE(tegra_periph_clk_list); i++) {
1041b08e8c0eSPrashant Gaikwad data = &tegra_periph_clk_list[i];
10421d7e2c8eSThierry Reding clk = tegra_clk_register_periph_data(clk_base, data);
1043b08e8c0eSPrashant Gaikwad clks[data->clk_id] = clk;
1044b08e8c0eSPrashant Gaikwad }
1045b08e8c0eSPrashant Gaikwad
1046b08e8c0eSPrashant Gaikwad for (i = 0; i < ARRAY_SIZE(tegra_periph_nodiv_clk_list); i++) {
1047b08e8c0eSPrashant Gaikwad data = &tegra_periph_nodiv_clk_list[i];
1048b08e8c0eSPrashant Gaikwad clk = tegra_clk_register_periph_nodiv(data->name,
104976ebc134SPeter De Schrijver data->p.parent_names,
1050b08e8c0eSPrashant Gaikwad data->num_parents, &data->periph,
1051b08e8c0eSPrashant Gaikwad clk_base, data->offset);
1052b08e8c0eSPrashant Gaikwad clks[data->clk_id] = clk;
1053b08e8c0eSPrashant Gaikwad }
1054b08e8c0eSPrashant Gaikwad
10551bf40915SPeter De Schrijver tegra_periph_clk_init(clk_base, pmc_base, tegra30_clks, &pll_p_params);
1056b08e8c0eSPrashant Gaikwad }
1057b08e8c0eSPrashant Gaikwad
1058b08e8c0eSPrashant Gaikwad /* Tegra30 CPU clock and reset control functions */
tegra30_wait_cpu_in_reset(u32 cpu)1059b08e8c0eSPrashant Gaikwad static void tegra30_wait_cpu_in_reset(u32 cpu)
1060b08e8c0eSPrashant Gaikwad {
1061b08e8c0eSPrashant Gaikwad unsigned int reg;
1062b08e8c0eSPrashant Gaikwad
1063b08e8c0eSPrashant Gaikwad do {
1064b08e8c0eSPrashant Gaikwad reg = readl(clk_base +
1065b08e8c0eSPrashant Gaikwad TEGRA30_CLK_RST_CONTROLLER_CPU_CMPLX_STATUS);
1066b08e8c0eSPrashant Gaikwad cpu_relax();
1067b08e8c0eSPrashant Gaikwad } while (!(reg & (1 << cpu))); /* check CPU been reset or not */
1068b08e8c0eSPrashant Gaikwad
1069b08e8c0eSPrashant Gaikwad return;
1070b08e8c0eSPrashant Gaikwad }
1071b08e8c0eSPrashant Gaikwad
tegra30_put_cpu_in_reset(u32 cpu)1072b08e8c0eSPrashant Gaikwad static void tegra30_put_cpu_in_reset(u32 cpu)
1073b08e8c0eSPrashant Gaikwad {
1074b08e8c0eSPrashant Gaikwad writel(CPU_RESET(cpu),
1075b08e8c0eSPrashant Gaikwad clk_base + TEGRA_CLK_RST_CONTROLLER_RST_CPU_CMPLX_SET);
1076b08e8c0eSPrashant Gaikwad dmb();
1077b08e8c0eSPrashant Gaikwad }
1078b08e8c0eSPrashant Gaikwad
tegra30_cpu_out_of_reset(u32 cpu)1079b08e8c0eSPrashant Gaikwad static void tegra30_cpu_out_of_reset(u32 cpu)
1080b08e8c0eSPrashant Gaikwad {
1081b08e8c0eSPrashant Gaikwad writel(CPU_RESET(cpu),
1082b08e8c0eSPrashant Gaikwad clk_base + TEGRA_CLK_RST_CONTROLLER_RST_CPU_CMPLX_CLR);
1083b08e8c0eSPrashant Gaikwad wmb();
1084b08e8c0eSPrashant Gaikwad }
1085b08e8c0eSPrashant Gaikwad
tegra30_enable_cpu_clock(u32 cpu)1086b08e8c0eSPrashant Gaikwad static void tegra30_enable_cpu_clock(u32 cpu)
1087b08e8c0eSPrashant Gaikwad {
1088b08e8c0eSPrashant Gaikwad writel(CPU_CLOCK(cpu),
1089b08e8c0eSPrashant Gaikwad clk_base + TEGRA30_CLK_RST_CONTROLLER_CLK_CPU_CMPLX_CLR);
1090a89bd29aSLee Jones readl(clk_base + TEGRA30_CLK_RST_CONTROLLER_CLK_CPU_CMPLX_CLR);
1091b08e8c0eSPrashant Gaikwad }
1092b08e8c0eSPrashant Gaikwad
tegra30_disable_cpu_clock(u32 cpu)1093b08e8c0eSPrashant Gaikwad static void tegra30_disable_cpu_clock(u32 cpu)
1094b08e8c0eSPrashant Gaikwad {
1095b08e8c0eSPrashant Gaikwad unsigned int reg;
1096b08e8c0eSPrashant Gaikwad
1097b08e8c0eSPrashant Gaikwad reg = readl(clk_base + TEGRA_CLK_RST_CONTROLLER_CLK_CPU_CMPLX);
1098b08e8c0eSPrashant Gaikwad writel(reg | CPU_CLOCK(cpu),
1099b08e8c0eSPrashant Gaikwad clk_base + TEGRA_CLK_RST_CONTROLLER_CLK_CPU_CMPLX);
1100b08e8c0eSPrashant Gaikwad }
1101b08e8c0eSPrashant Gaikwad
1102b08e8c0eSPrashant Gaikwad #ifdef CONFIG_PM_SLEEP
tegra30_cpu_rail_off_ready(void)1103b08e8c0eSPrashant Gaikwad static bool tegra30_cpu_rail_off_ready(void)
1104b08e8c0eSPrashant Gaikwad {
1105b08e8c0eSPrashant Gaikwad unsigned int cpu_rst_status;
1106b08e8c0eSPrashant Gaikwad int cpu_pwr_status;
1107b08e8c0eSPrashant Gaikwad
1108b08e8c0eSPrashant Gaikwad cpu_rst_status = readl(clk_base +
1109b08e8c0eSPrashant Gaikwad TEGRA30_CLK_RST_CONTROLLER_CPU_CMPLX_STATUS);
1110b158aeeaSJon Hunter cpu_pwr_status = tegra_pmc_cpu_is_powered(1) ||
1111b158aeeaSJon Hunter tegra_pmc_cpu_is_powered(2) ||
1112b158aeeaSJon Hunter tegra_pmc_cpu_is_powered(3);
1113b08e8c0eSPrashant Gaikwad
1114b08e8c0eSPrashant Gaikwad if (((cpu_rst_status & 0xE) != 0xE) || cpu_pwr_status)
1115b08e8c0eSPrashant Gaikwad return false;
1116b08e8c0eSPrashant Gaikwad
1117b08e8c0eSPrashant Gaikwad return true;
1118b08e8c0eSPrashant Gaikwad }
1119b08e8c0eSPrashant Gaikwad
tegra30_cpu_clock_suspend(void)1120b08e8c0eSPrashant Gaikwad static void tegra30_cpu_clock_suspend(void)
1121b08e8c0eSPrashant Gaikwad {
1122b08e8c0eSPrashant Gaikwad /* switch coresite to clk_m, save off original source */
1123b08e8c0eSPrashant Gaikwad tegra30_cpu_clk_sctx.clk_csite_src =
1124b08e8c0eSPrashant Gaikwad readl(clk_base + CLK_RESET_SOURCE_CSITE);
1125b08e8c0eSPrashant Gaikwad writel(3 << 30, clk_base + CLK_RESET_SOURCE_CSITE);
1126b08e8c0eSPrashant Gaikwad
1127b08e8c0eSPrashant Gaikwad tegra30_cpu_clk_sctx.cpu_burst =
1128b08e8c0eSPrashant Gaikwad readl(clk_base + CLK_RESET_CCLK_BURST);
1129b08e8c0eSPrashant Gaikwad tegra30_cpu_clk_sctx.pllx_base =
1130b08e8c0eSPrashant Gaikwad readl(clk_base + CLK_RESET_PLLX_BASE);
1131b08e8c0eSPrashant Gaikwad tegra30_cpu_clk_sctx.pllx_misc =
1132b08e8c0eSPrashant Gaikwad readl(clk_base + CLK_RESET_PLLX_MISC);
1133b08e8c0eSPrashant Gaikwad tegra30_cpu_clk_sctx.cclk_divider =
1134b08e8c0eSPrashant Gaikwad readl(clk_base + CLK_RESET_CCLK_DIVIDER);
1135b08e8c0eSPrashant Gaikwad }
1136b08e8c0eSPrashant Gaikwad
tegra30_cpu_clock_resume(void)1137b08e8c0eSPrashant Gaikwad static void tegra30_cpu_clock_resume(void)
1138b08e8c0eSPrashant Gaikwad {
1139b08e8c0eSPrashant Gaikwad unsigned int reg, policy;
1140204ce75bSDmitry Osipenko u32 misc, base;
1141b08e8c0eSPrashant Gaikwad
1142b08e8c0eSPrashant Gaikwad /* Is CPU complex already running on PLLX? */
1143b08e8c0eSPrashant Gaikwad reg = readl(clk_base + CLK_RESET_CCLK_BURST);
1144b08e8c0eSPrashant Gaikwad policy = (reg >> CLK_RESET_CCLK_BURST_POLICY_SHIFT) & 0xF;
1145b08e8c0eSPrashant Gaikwad
1146b08e8c0eSPrashant Gaikwad if (policy == CLK_RESET_CCLK_IDLE_POLICY)
1147b08e8c0eSPrashant Gaikwad reg = (reg >> CLK_RESET_CCLK_IDLE_POLICY_SHIFT) & 0xF;
1148b08e8c0eSPrashant Gaikwad else if (policy == CLK_RESET_CCLK_RUN_POLICY)
1149b08e8c0eSPrashant Gaikwad reg = (reg >> CLK_RESET_CCLK_RUN_POLICY_SHIFT) & 0xF;
1150b08e8c0eSPrashant Gaikwad else
1151b08e8c0eSPrashant Gaikwad BUG();
1152b08e8c0eSPrashant Gaikwad
1153b08e8c0eSPrashant Gaikwad if (reg != CLK_RESET_CCLK_BURST_POLICY_PLLX) {
1154204ce75bSDmitry Osipenko misc = readl_relaxed(clk_base + CLK_RESET_PLLX_MISC);
1155204ce75bSDmitry Osipenko base = readl_relaxed(clk_base + CLK_RESET_PLLX_BASE);
1156204ce75bSDmitry Osipenko
1157204ce75bSDmitry Osipenko if (misc != tegra30_cpu_clk_sctx.pllx_misc ||
1158204ce75bSDmitry Osipenko base != tegra30_cpu_clk_sctx.pllx_base) {
1159b08e8c0eSPrashant Gaikwad /* restore PLLX settings if CPU is on different PLL */
1160b08e8c0eSPrashant Gaikwad writel(tegra30_cpu_clk_sctx.pllx_misc,
1161b08e8c0eSPrashant Gaikwad clk_base + CLK_RESET_PLLX_MISC);
1162b08e8c0eSPrashant Gaikwad writel(tegra30_cpu_clk_sctx.pllx_base,
1163b08e8c0eSPrashant Gaikwad clk_base + CLK_RESET_PLLX_BASE);
1164b08e8c0eSPrashant Gaikwad
1165b08e8c0eSPrashant Gaikwad /* wait for PLL stabilization if PLLX was enabled */
1166b08e8c0eSPrashant Gaikwad if (tegra30_cpu_clk_sctx.pllx_base & (1 << 30))
1167b08e8c0eSPrashant Gaikwad udelay(300);
1168b08e8c0eSPrashant Gaikwad }
1169204ce75bSDmitry Osipenko }
1170b08e8c0eSPrashant Gaikwad
1171b08e8c0eSPrashant Gaikwad /*
1172b08e8c0eSPrashant Gaikwad * Restore original burst policy setting for calls resulting from CPU
1173b08e8c0eSPrashant Gaikwad * LP2 in idle or system suspend.
1174b08e8c0eSPrashant Gaikwad */
1175b08e8c0eSPrashant Gaikwad writel(tegra30_cpu_clk_sctx.cclk_divider,
1176b08e8c0eSPrashant Gaikwad clk_base + CLK_RESET_CCLK_DIVIDER);
1177b08e8c0eSPrashant Gaikwad writel(tegra30_cpu_clk_sctx.cpu_burst,
1178b08e8c0eSPrashant Gaikwad clk_base + CLK_RESET_CCLK_BURST);
1179b08e8c0eSPrashant Gaikwad
1180b08e8c0eSPrashant Gaikwad writel(tegra30_cpu_clk_sctx.clk_csite_src,
1181b08e8c0eSPrashant Gaikwad clk_base + CLK_RESET_SOURCE_CSITE);
1182b08e8c0eSPrashant Gaikwad }
1183b08e8c0eSPrashant Gaikwad #endif
1184b08e8c0eSPrashant Gaikwad
1185b08e8c0eSPrashant Gaikwad static struct tegra_cpu_car_ops tegra30_cpu_car_ops = {
1186b08e8c0eSPrashant Gaikwad .wait_for_reset = tegra30_wait_cpu_in_reset,
1187b08e8c0eSPrashant Gaikwad .put_in_reset = tegra30_put_cpu_in_reset,
1188b08e8c0eSPrashant Gaikwad .out_of_reset = tegra30_cpu_out_of_reset,
1189b08e8c0eSPrashant Gaikwad .enable_clock = tegra30_enable_cpu_clock,
1190b08e8c0eSPrashant Gaikwad .disable_clock = tegra30_disable_cpu_clock,
1191b08e8c0eSPrashant Gaikwad #ifdef CONFIG_PM_SLEEP
1192b08e8c0eSPrashant Gaikwad .rail_off_ready = tegra30_cpu_rail_off_ready,
1193b08e8c0eSPrashant Gaikwad .suspend = tegra30_cpu_clock_suspend,
1194b08e8c0eSPrashant Gaikwad .resume = tegra30_cpu_clock_resume,
1195b08e8c0eSPrashant Gaikwad #endif
1196b08e8c0eSPrashant Gaikwad };
1197b08e8c0eSPrashant Gaikwad
1198b1bc04a2SDmitry Osipenko static struct tegra_clk_init_table init_table[] = {
11991bf40915SPeter De Schrijver { TEGRA30_CLK_UARTA, TEGRA30_CLK_PLL_P, 408000000, 0 },
12001bf40915SPeter De Schrijver { TEGRA30_CLK_UARTB, TEGRA30_CLK_PLL_P, 408000000, 0 },
12011bf40915SPeter De Schrijver { TEGRA30_CLK_UARTC, TEGRA30_CLK_PLL_P, 408000000, 0 },
12021bf40915SPeter De Schrijver { TEGRA30_CLK_UARTD, TEGRA30_CLK_PLL_P, 408000000, 0 },
12031bf40915SPeter De Schrijver { TEGRA30_CLK_UARTE, TEGRA30_CLK_PLL_P, 408000000, 0 },
1204efdd205cSSowjanya Komatineni { TEGRA30_CLK_PLL_A, TEGRA30_CLK_CLK_MAX, 564480000, 0 },
1205efdd205cSSowjanya Komatineni { TEGRA30_CLK_PLL_A_OUT0, TEGRA30_CLK_CLK_MAX, 11289600, 0 },
12061bf40915SPeter De Schrijver { TEGRA30_CLK_I2S0, TEGRA30_CLK_PLL_A_OUT0, 11289600, 0 },
12071bf40915SPeter De Schrijver { TEGRA30_CLK_I2S1, TEGRA30_CLK_PLL_A_OUT0, 11289600, 0 },
12081bf40915SPeter De Schrijver { TEGRA30_CLK_I2S2, TEGRA30_CLK_PLL_A_OUT0, 11289600, 0 },
12091bf40915SPeter De Schrijver { TEGRA30_CLK_I2S3, TEGRA30_CLK_PLL_A_OUT0, 11289600, 0 },
12101bf40915SPeter De Schrijver { TEGRA30_CLK_I2S4, TEGRA30_CLK_PLL_A_OUT0, 11289600, 0 },
12111bf40915SPeter De Schrijver { TEGRA30_CLK_SDMMC1, TEGRA30_CLK_PLL_P, 48000000, 0 },
12121bf40915SPeter De Schrijver { TEGRA30_CLK_SDMMC2, TEGRA30_CLK_PLL_P, 48000000, 0 },
12131bf40915SPeter De Schrijver { TEGRA30_CLK_SDMMC3, TEGRA30_CLK_PLL_P, 48000000, 0 },
12141bf40915SPeter De Schrijver { TEGRA30_CLK_CSITE, TEGRA30_CLK_CLK_MAX, 0, 1 },
12151bf40915SPeter De Schrijver { TEGRA30_CLK_MSELECT, TEGRA30_CLK_CLK_MAX, 0, 1 },
12161bf40915SPeter De Schrijver { TEGRA30_CLK_SBC1, TEGRA30_CLK_PLL_P, 100000000, 0 },
12171bf40915SPeter De Schrijver { TEGRA30_CLK_SBC2, TEGRA30_CLK_PLL_P, 100000000, 0 },
12181bf40915SPeter De Schrijver { TEGRA30_CLK_SBC3, TEGRA30_CLK_PLL_P, 100000000, 0 },
12191bf40915SPeter De Schrijver { TEGRA30_CLK_SBC4, TEGRA30_CLK_PLL_P, 100000000, 0 },
12201bf40915SPeter De Schrijver { TEGRA30_CLK_SBC5, TEGRA30_CLK_PLL_P, 100000000, 0 },
12211bf40915SPeter De Schrijver { TEGRA30_CLK_SBC6, TEGRA30_CLK_PLL_P, 100000000, 0 },
1222a02cc84aSLucas Stach { TEGRA30_CLK_PLL_C, TEGRA30_CLK_CLK_MAX, 600000000, 0 },
12231bf40915SPeter De Schrijver { TEGRA30_CLK_HOST1X, TEGRA30_CLK_PLL_C, 150000000, 0 },
12241bf40915SPeter De Schrijver { TEGRA30_CLK_TWD, TEGRA30_CLK_CLK_MAX, 0, 1 },
12251bf40915SPeter De Schrijver { TEGRA30_CLK_GR2D, TEGRA30_CLK_PLL_C, 300000000, 0 },
12261bf40915SPeter De Schrijver { TEGRA30_CLK_GR3D, TEGRA30_CLK_PLL_C, 300000000, 0 },
122743e36a96SThierry Reding { TEGRA30_CLK_GR3D2, TEGRA30_CLK_PLL_C, 300000000, 0 },
122879709730SLucas Stach { TEGRA30_CLK_PLL_U, TEGRA30_CLK_CLK_MAX, 480000000, 0 },
122956bb7c28SDmitry Osipenko { TEGRA30_CLK_VDE, TEGRA30_CLK_PLL_C, 300000000, 0 },
1230845d782dSJon Hunter { TEGRA30_CLK_SPDIF_IN_SYNC, TEGRA30_CLK_CLK_MAX, 24000000, 0 },
1231845d782dSJon Hunter { TEGRA30_CLK_I2S0_SYNC, TEGRA30_CLK_CLK_MAX, 24000000, 0 },
1232845d782dSJon Hunter { TEGRA30_CLK_I2S1_SYNC, TEGRA30_CLK_CLK_MAX, 24000000, 0 },
1233845d782dSJon Hunter { TEGRA30_CLK_I2S2_SYNC, TEGRA30_CLK_CLK_MAX, 24000000, 0 },
1234845d782dSJon Hunter { TEGRA30_CLK_I2S3_SYNC, TEGRA30_CLK_CLK_MAX, 24000000, 0 },
1235845d782dSJon Hunter { TEGRA30_CLK_I2S4_SYNC, TEGRA30_CLK_CLK_MAX, 24000000, 0 },
1236845d782dSJon Hunter { TEGRA30_CLK_VIMCLK_SYNC, TEGRA30_CLK_CLK_MAX, 24000000, 0 },
1237f4eccc7fSPeter Geis { TEGRA30_CLK_HDA, TEGRA30_CLK_PLL_P, 102000000, 0 },
1238f4eccc7fSPeter Geis { TEGRA30_CLK_HDA2CODEC_2X, TEGRA30_CLK_PLL_P, 48000000, 0 },
1239*c461c677SJon Hunter { TEGRA30_CLK_PWM, TEGRA30_CLK_PLL_P, 48000000, 0 },
12408d99704fSThierry Reding /* must be the last entry */
12418d99704fSThierry Reding { TEGRA30_CLK_CLK_MAX, TEGRA30_CLK_CLK_MAX, 0, 0 },
1242b08e8c0eSPrashant Gaikwad };
1243b08e8c0eSPrashant Gaikwad
1244b08e8c0eSPrashant Gaikwad /*
1245b08e8c0eSPrashant Gaikwad * Some clocks may be used by different drivers depending on the board
1246b08e8c0eSPrashant Gaikwad * configuration. List those here to register them twice in the clock lookup
1247b08e8c0eSPrashant Gaikwad * table under two names.
1248b08e8c0eSPrashant Gaikwad */
1249b08e8c0eSPrashant Gaikwad static struct tegra_clk_duplicate tegra_clk_duplicates[] = {
12501bf40915SPeter De Schrijver TEGRA_CLK_DUPLICATE(TEGRA30_CLK_USBD, "utmip-pad", NULL),
12511bf40915SPeter De Schrijver TEGRA_CLK_DUPLICATE(TEGRA30_CLK_USBD, "tegra-ehci.0", NULL),
12521bf40915SPeter De Schrijver TEGRA_CLK_DUPLICATE(TEGRA30_CLK_USBD, "tegra-otg", NULL),
12531bf40915SPeter De Schrijver TEGRA_CLK_DUPLICATE(TEGRA30_CLK_BSEV, "tegra-avp", "bsev"),
12541bf40915SPeter De Schrijver TEGRA_CLK_DUPLICATE(TEGRA30_CLK_BSEV, "nvavp", "bsev"),
12551bf40915SPeter De Schrijver TEGRA_CLK_DUPLICATE(TEGRA30_CLK_VDE, "tegra-aes", "vde"),
12561bf40915SPeter De Schrijver TEGRA_CLK_DUPLICATE(TEGRA30_CLK_BSEA, "tegra-aes", "bsea"),
12571bf40915SPeter De Schrijver TEGRA_CLK_DUPLICATE(TEGRA30_CLK_BSEA, "nvavp", "bsea"),
12581bf40915SPeter De Schrijver TEGRA_CLK_DUPLICATE(TEGRA30_CLK_CML1, "tegra_sata_cml", NULL),
12591bf40915SPeter De Schrijver TEGRA_CLK_DUPLICATE(TEGRA30_CLK_CML0, "tegra_pcie", "cml"),
12601bf40915SPeter De Schrijver TEGRA_CLK_DUPLICATE(TEGRA30_CLK_VCP, "nvavp", "vcp"),
12618d99704fSThierry Reding /* must be the last entry */
12628d99704fSThierry Reding TEGRA_CLK_DUPLICATE(TEGRA30_CLK_CLK_MAX, NULL, NULL),
1263b08e8c0eSPrashant Gaikwad };
1264b08e8c0eSPrashant Gaikwad
1265b08e8c0eSPrashant Gaikwad static const struct of_device_id pmc_match[] __initconst = {
1266b08e8c0eSPrashant Gaikwad { .compatible = "nvidia,tegra30-pmc" },
1267b08e8c0eSPrashant Gaikwad { },
1268b08e8c0eSPrashant Gaikwad };
1269b08e8c0eSPrashant Gaikwad
127088d909beSRhyland Klein static struct tegra_audio_clk_info tegra30_audio_plls[] = {
127188d909beSRhyland Klein { "pll_a", &pll_a_params, tegra_clk_pll_a, "pll_p_out1" },
127288d909beSRhyland Klein };
127388d909beSRhyland Klein
1274b1bc04a2SDmitry Osipenko static bool tegra30_car_initialized;
1275b1bc04a2SDmitry Osipenko
tegra30_clk_src_onecell_get(struct of_phandle_args * clkspec,void * data)1276ed1a2459SDmitry Osipenko static struct clk *tegra30_clk_src_onecell_get(struct of_phandle_args *clkspec,
1277ed1a2459SDmitry Osipenko void *data)
1278ed1a2459SDmitry Osipenko {
1279ed1a2459SDmitry Osipenko struct clk_hw *hw;
1280ed1a2459SDmitry Osipenko struct clk *clk;
1281ed1a2459SDmitry Osipenko
1282b1bc04a2SDmitry Osipenko /*
1283b1bc04a2SDmitry Osipenko * Timer clocks are needed early, the rest of the clocks shouldn't be
1284b1bc04a2SDmitry Osipenko * available to device drivers until clock tree is fully initialized.
1285b1bc04a2SDmitry Osipenko */
1286b1bc04a2SDmitry Osipenko if (clkspec->args[0] != TEGRA30_CLK_RTC &&
1287b1bc04a2SDmitry Osipenko clkspec->args[0] != TEGRA30_CLK_TWD &&
1288b1bc04a2SDmitry Osipenko clkspec->args[0] != TEGRA30_CLK_TIMER &&
1289b1bc04a2SDmitry Osipenko !tegra30_car_initialized)
1290b1bc04a2SDmitry Osipenko return ERR_PTR(-EPROBE_DEFER);
1291b1bc04a2SDmitry Osipenko
1292ed1a2459SDmitry Osipenko clk = of_clk_src_onecell_get(clkspec, data);
1293ed1a2459SDmitry Osipenko if (IS_ERR(clk))
1294ed1a2459SDmitry Osipenko return clk;
1295ed1a2459SDmitry Osipenko
1296ed1a2459SDmitry Osipenko hw = __clk_get_hw(clk);
1297ed1a2459SDmitry Osipenko
1298ed1a2459SDmitry Osipenko if (clkspec->args[0] == TEGRA30_CLK_EMC) {
1299ed1a2459SDmitry Osipenko if (!tegra20_clk_emc_driver_available(hw))
1300ed1a2459SDmitry Osipenko return ERR_PTR(-EPROBE_DEFER);
1301ed1a2459SDmitry Osipenko }
1302ed1a2459SDmitry Osipenko
1303ed1a2459SDmitry Osipenko return clk;
1304ed1a2459SDmitry Osipenko }
1305ed1a2459SDmitry Osipenko
tegra30_clock_init(struct device_node * np)1306061cec92SPrashant Gaikwad static void __init tegra30_clock_init(struct device_node *np)
1307b08e8c0eSPrashant Gaikwad {
1308b08e8c0eSPrashant Gaikwad struct device_node *node;
1309b08e8c0eSPrashant Gaikwad
1310b08e8c0eSPrashant Gaikwad clk_base = of_iomap(np, 0);
1311b08e8c0eSPrashant Gaikwad if (!clk_base) {
1312b08e8c0eSPrashant Gaikwad pr_err("ioremap tegra30 CAR failed\n");
1313b08e8c0eSPrashant Gaikwad return;
1314b08e8c0eSPrashant Gaikwad }
1315b08e8c0eSPrashant Gaikwad
1316b08e8c0eSPrashant Gaikwad node = of_find_matching_node(NULL, pmc_match);
1317b08e8c0eSPrashant Gaikwad if (!node) {
1318b08e8c0eSPrashant Gaikwad pr_err("Failed to find pmc node\n");
1319b08e8c0eSPrashant Gaikwad BUG();
1320b08e8c0eSPrashant Gaikwad }
1321b08e8c0eSPrashant Gaikwad
1322b08e8c0eSPrashant Gaikwad pmc_base = of_iomap(node, 0);
132302bd544fSLiang He of_node_put(node);
1324b08e8c0eSPrashant Gaikwad if (!pmc_base) {
1325b08e8c0eSPrashant Gaikwad pr_err("Can't map pmc registers\n");
1326b08e8c0eSPrashant Gaikwad BUG();
1327b08e8c0eSPrashant Gaikwad }
1328b08e8c0eSPrashant Gaikwad
13296d5b988eSStephen Warren clks = tegra_clk_init(clk_base, TEGRA30_CLK_CLK_MAX,
13306d5b988eSStephen Warren TEGRA30_CLK_PERIPH_BANKS);
1331343a607cSPeter De Schrijver if (!clks)
1332d5ff89a8SPeter De Schrijver return;
1333d5ff89a8SPeter De Schrijver
13341bf40915SPeter De Schrijver if (tegra_osc_clk_init(clk_base, tegra30_clks, tegra30_input_freq,
133563cc5a4dSThierry Reding ARRAY_SIZE(tegra30_input_freq), 1, &input_freq,
133663cc5a4dSThierry Reding NULL) < 0)
13371bf40915SPeter De Schrijver return;
13381bf40915SPeter De Schrijver
13391bf40915SPeter De Schrijver tegra_fixed_clk_init(tegra30_clks);
1340b08e8c0eSPrashant Gaikwad tegra30_pll_init();
1341b08e8c0eSPrashant Gaikwad tegra30_super_clk_init();
1342b08e8c0eSPrashant Gaikwad tegra30_periph_clk_init();
134388d909beSRhyland Klein tegra_audio_clk_init(clk_base, pmc_base, tegra30_clks,
134488d909beSRhyland Klein tegra30_audio_plls,
1345845d782dSJon Hunter ARRAY_SIZE(tegra30_audio_plls), 24000000);
1346b08e8c0eSPrashant Gaikwad
13471bf40915SPeter De Schrijver tegra_init_dup_clks(tegra_clk_duplicates, clks, TEGRA30_CLK_CLK_MAX);
1348b08e8c0eSPrashant Gaikwad
1349ed1a2459SDmitry Osipenko tegra_add_of_provider(np, tegra30_clk_src_onecell_get);
1350b08e8c0eSPrashant Gaikwad
1351b08e8c0eSPrashant Gaikwad tegra_cpu_car_ops = &tegra30_cpu_car_ops;
1352b08e8c0eSPrashant Gaikwad }
1353b1bc04a2SDmitry Osipenko CLK_OF_DECLARE_DRIVER(tegra30, "nvidia,tegra30-car", tegra30_clock_init);
1354b1bc04a2SDmitry Osipenko
1355b1bc04a2SDmitry Osipenko /*
1356b1bc04a2SDmitry Osipenko * Clocks that use runtime PM can't be created at the tegra30_clock_init
1357b1bc04a2SDmitry Osipenko * time because drivers' base isn't initialized yet, and thus platform
1358b1bc04a2SDmitry Osipenko * devices can't be created for the clocks. Hence we need to split the
1359b1bc04a2SDmitry Osipenko * registration of the clocks into two phases. The first phase registers
1360b1bc04a2SDmitry Osipenko * essential clocks which don't require RPM and are actually used during
1361b1bc04a2SDmitry Osipenko * early boot. The second phase registers clocks which use RPM and this
1362b1bc04a2SDmitry Osipenko * is done when device drivers' core API is ready.
1363b1bc04a2SDmitry Osipenko */
tegra30_car_probe(struct platform_device * pdev)1364b1bc04a2SDmitry Osipenko static int tegra30_car_probe(struct platform_device *pdev)
1365b1bc04a2SDmitry Osipenko {
1366b1bc04a2SDmitry Osipenko struct clk *clk;
1367b1bc04a2SDmitry Osipenko
1368b1bc04a2SDmitry Osipenko /* PLLC */
1369b1bc04a2SDmitry Osipenko clk = tegra_clk_register_pll("pll_c", "pll_ref", clk_base, pmc_base, 0,
1370b1bc04a2SDmitry Osipenko &pll_c_params, NULL);
1371b1bc04a2SDmitry Osipenko clks[TEGRA30_CLK_PLL_C] = clk;
1372b1bc04a2SDmitry Osipenko
1373b1bc04a2SDmitry Osipenko /* PLLE */
1374b1bc04a2SDmitry Osipenko clk = tegra_clk_register_plle("pll_e", "pll_e_mux", clk_base, pmc_base,
1375b1bc04a2SDmitry Osipenko CLK_GET_RATE_NOCACHE, &pll_e_params, NULL);
1376b1bc04a2SDmitry Osipenko clks[TEGRA30_CLK_PLL_E] = clk;
1377b1bc04a2SDmitry Osipenko
1378b1bc04a2SDmitry Osipenko /* PLLM */
1379b1bc04a2SDmitry Osipenko clk = tegra_clk_register_pll("pll_m", "pll_ref", clk_base, pmc_base,
1380b1bc04a2SDmitry Osipenko CLK_SET_RATE_GATE, &pll_m_params, NULL);
1381b1bc04a2SDmitry Osipenko clks[TEGRA30_CLK_PLL_M] = clk;
1382b1bc04a2SDmitry Osipenko
1383b1bc04a2SDmitry Osipenko /* SCLK */
1384b1bc04a2SDmitry Osipenko clk = tegra_clk_register_super_mux("sclk", sclk_parents,
1385b1bc04a2SDmitry Osipenko ARRAY_SIZE(sclk_parents),
1386b1bc04a2SDmitry Osipenko CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
1387b1bc04a2SDmitry Osipenko clk_base + SCLK_BURST_POLICY,
1388b1bc04a2SDmitry Osipenko 0, 4, 0, 0, NULL);
1389b1bc04a2SDmitry Osipenko clks[TEGRA30_CLK_SCLK] = clk;
1390b1bc04a2SDmitry Osipenko
1391b1bc04a2SDmitry Osipenko tegra_register_devclks(devclks, ARRAY_SIZE(devclks));
1392b1bc04a2SDmitry Osipenko tegra_init_from_table(init_table, clks, TEGRA30_CLK_CLK_MAX);
1393b1bc04a2SDmitry Osipenko tegra30_car_initialized = true;
1394b1bc04a2SDmitry Osipenko
1395b1bc04a2SDmitry Osipenko return 0;
1396b1bc04a2SDmitry Osipenko }
1397b1bc04a2SDmitry Osipenko
1398b1bc04a2SDmitry Osipenko static const struct of_device_id tegra30_car_match[] = {
1399b1bc04a2SDmitry Osipenko { .compatible = "nvidia,tegra30-car" },
1400b1bc04a2SDmitry Osipenko { }
1401b1bc04a2SDmitry Osipenko };
1402b1bc04a2SDmitry Osipenko
1403b1bc04a2SDmitry Osipenko static struct platform_driver tegra30_car_driver = {
1404b1bc04a2SDmitry Osipenko .driver = {
1405b1bc04a2SDmitry Osipenko .name = "tegra30-car",
1406b1bc04a2SDmitry Osipenko .of_match_table = tegra30_car_match,
1407b1bc04a2SDmitry Osipenko .suppress_bind_attrs = true,
1408b1bc04a2SDmitry Osipenko },
1409b1bc04a2SDmitry Osipenko .probe = tegra30_car_probe,
1410b1bc04a2SDmitry Osipenko };
1411b1bc04a2SDmitry Osipenko
1412b1bc04a2SDmitry Osipenko /*
1413b1bc04a2SDmitry Osipenko * Clock driver must be registered before memory controller driver,
1414b1bc04a2SDmitry Osipenko * which doesn't support deferred probing for today and is registered
1415b1bc04a2SDmitry Osipenko * from arch init-level.
1416b1bc04a2SDmitry Osipenko */
tegra30_car_init(void)1417b1bc04a2SDmitry Osipenko static int tegra30_car_init(void)
1418b1bc04a2SDmitry Osipenko {
1419b1bc04a2SDmitry Osipenko return platform_driver_register(&tegra30_car_driver);
1420b1bc04a2SDmitry Osipenko }
1421b1bc04a2SDmitry Osipenko postcore_initcall(tegra30_car_init);
1422