blob: c5db42217ba82754d8b785091963d94f5eec0558 [file] [log] [blame]
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301/*
2 * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include <linux/io.h>
18#include <linux/delay.h>
19#include <linux/clk.h>
20#include <linux/clk-provider.h>
21#include <linux/clkdev.h>
22#include <linux/of.h>
23#include <linux/of_address.h>
24#include <linux/clk/tegra.h>
Stephen Warrene4bcda22013-03-29 17:38:18 -060025#include <linux/tegra-powergate.h>
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +053026
27#include "clk.h"
28
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +053029#define OSC_CTRL 0x50
30#define OSC_CTRL_OSC_FREQ_MASK (0xF<<28)
31#define OSC_CTRL_OSC_FREQ_13MHZ (0X0<<28)
32#define OSC_CTRL_OSC_FREQ_19_2MHZ (0X4<<28)
33#define OSC_CTRL_OSC_FREQ_12MHZ (0X8<<28)
34#define OSC_CTRL_OSC_FREQ_26MHZ (0XC<<28)
35#define OSC_CTRL_OSC_FREQ_16_8MHZ (0X1<<28)
36#define OSC_CTRL_OSC_FREQ_38_4MHZ (0X5<<28)
37#define OSC_CTRL_OSC_FREQ_48MHZ (0X9<<28)
38#define OSC_CTRL_MASK (0x3f2 | OSC_CTRL_OSC_FREQ_MASK)
39
40#define OSC_CTRL_PLL_REF_DIV_MASK (3<<26)
41#define OSC_CTRL_PLL_REF_DIV_1 (0<<26)
42#define OSC_CTRL_PLL_REF_DIV_2 (1<<26)
43#define OSC_CTRL_PLL_REF_DIV_4 (2<<26)
44
45#define OSC_FREQ_DET 0x58
46#define OSC_FREQ_DET_TRIG BIT(31)
47
48#define OSC_FREQ_DET_STATUS 0x5c
49#define OSC_FREQ_DET_BUSY BIT(31)
50#define OSC_FREQ_DET_CNT_MASK 0xffff
51
52#define CCLKG_BURST_POLICY 0x368
53#define SUPER_CCLKG_DIVIDER 0x36c
54#define CCLKLP_BURST_POLICY 0x370
55#define SUPER_CCLKLP_DIVIDER 0x374
56#define SCLK_BURST_POLICY 0x028
57#define SUPER_SCLK_DIVIDER 0x02c
58
59#define SYSTEM_CLK_RATE 0x030
60
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +030061#define TEGRA30_CLK_PERIPH_BANKS 5
62
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +053063#define PLLC_BASE 0x80
64#define PLLC_MISC 0x8c
65#define PLLM_BASE 0x90
66#define PLLM_MISC 0x9c
67#define PLLP_BASE 0xa0
68#define PLLP_MISC 0xac
69#define PLLX_BASE 0xe0
70#define PLLX_MISC 0xe4
71#define PLLD_BASE 0xd0
72#define PLLD_MISC 0xdc
73#define PLLD2_BASE 0x4b8
74#define PLLD2_MISC 0x4bc
75#define PLLE_BASE 0xe8
76#define PLLE_MISC 0xec
77#define PLLA_BASE 0xb0
78#define PLLA_MISC 0xbc
79#define PLLU_BASE 0xc0
80#define PLLU_MISC 0xcc
81
82#define PLL_MISC_LOCK_ENABLE 18
83#define PLLDU_MISC_LOCK_ENABLE 22
84#define PLLE_MISC_LOCK_ENABLE 9
85
Peter De Schrijver3e727712013-04-03 17:40:40 +030086#define PLL_BASE_LOCK BIT(27)
87#define PLLE_MISC_LOCK BIT(11)
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +053088
89#define PLLE_AUX 0x48c
90#define PLLC_OUT 0x84
91#define PLLM_OUT 0x94
92#define PLLP_OUTA 0xa4
93#define PLLP_OUTB 0xa8
94#define PLLA_OUT 0xb4
95
96#define AUDIO_SYNC_CLK_I2S0 0x4a0
97#define AUDIO_SYNC_CLK_I2S1 0x4a4
98#define AUDIO_SYNC_CLK_I2S2 0x4a8
99#define AUDIO_SYNC_CLK_I2S3 0x4ac
100#define AUDIO_SYNC_CLK_I2S4 0x4b0
101#define AUDIO_SYNC_CLK_SPDIF 0x4b4
102
103#define PMC_CLK_OUT_CNTRL 0x1a8
104
105#define CLK_SOURCE_I2S0 0x1d8
106#define CLK_SOURCE_I2S1 0x100
107#define CLK_SOURCE_I2S2 0x104
108#define CLK_SOURCE_I2S3 0x3bc
109#define CLK_SOURCE_I2S4 0x3c0
110#define CLK_SOURCE_SPDIF_OUT 0x108
111#define CLK_SOURCE_SPDIF_IN 0x10c
112#define CLK_SOURCE_PWM 0x110
113#define CLK_SOURCE_D_AUDIO 0x3d0
114#define CLK_SOURCE_DAM0 0x3d8
115#define CLK_SOURCE_DAM1 0x3dc
116#define CLK_SOURCE_DAM2 0x3e0
117#define CLK_SOURCE_HDA 0x428
118#define CLK_SOURCE_HDA2CODEC_2X 0x3e4
119#define CLK_SOURCE_SBC1 0x134
120#define CLK_SOURCE_SBC2 0x118
121#define CLK_SOURCE_SBC3 0x11c
122#define CLK_SOURCE_SBC4 0x1b4
123#define CLK_SOURCE_SBC5 0x3c8
124#define CLK_SOURCE_SBC6 0x3cc
125#define CLK_SOURCE_SATA_OOB 0x420
126#define CLK_SOURCE_SATA 0x424
127#define CLK_SOURCE_NDFLASH 0x160
128#define CLK_SOURCE_NDSPEED 0x3f8
129#define CLK_SOURCE_VFIR 0x168
130#define CLK_SOURCE_SDMMC1 0x150
131#define CLK_SOURCE_SDMMC2 0x154
132#define CLK_SOURCE_SDMMC3 0x1bc
133#define CLK_SOURCE_SDMMC4 0x164
134#define CLK_SOURCE_VDE 0x1c8
135#define CLK_SOURCE_CSITE 0x1d4
136#define CLK_SOURCE_LA 0x1f8
137#define CLK_SOURCE_OWR 0x1cc
138#define CLK_SOURCE_NOR 0x1d0
139#define CLK_SOURCE_MIPI 0x174
140#define CLK_SOURCE_I2C1 0x124
141#define CLK_SOURCE_I2C2 0x198
142#define CLK_SOURCE_I2C3 0x1b8
143#define CLK_SOURCE_I2C4 0x3c4
144#define CLK_SOURCE_I2C5 0x128
145#define CLK_SOURCE_UARTA 0x178
146#define CLK_SOURCE_UARTB 0x17c
147#define CLK_SOURCE_UARTC 0x1a0
148#define CLK_SOURCE_UARTD 0x1c0
149#define CLK_SOURCE_UARTE 0x1c4
150#define CLK_SOURCE_VI 0x148
151#define CLK_SOURCE_VI_SENSOR 0x1a8
152#define CLK_SOURCE_3D 0x158
153#define CLK_SOURCE_3D2 0x3b0
154#define CLK_SOURCE_2D 0x15c
155#define CLK_SOURCE_EPP 0x16c
156#define CLK_SOURCE_MPE 0x170
157#define CLK_SOURCE_HOST1X 0x180
158#define CLK_SOURCE_CVE 0x140
159#define CLK_SOURCE_TVO 0x188
160#define CLK_SOURCE_DTV 0x1dc
161#define CLK_SOURCE_HDMI 0x18c
162#define CLK_SOURCE_TVDAC 0x194
163#define CLK_SOURCE_DISP1 0x138
164#define CLK_SOURCE_DISP2 0x13c
165#define CLK_SOURCE_DSIB 0xd0
166#define CLK_SOURCE_TSENSOR 0x3b8
167#define CLK_SOURCE_ACTMON 0x3e8
168#define CLK_SOURCE_EXTERN1 0x3ec
169#define CLK_SOURCE_EXTERN2 0x3f0
170#define CLK_SOURCE_EXTERN3 0x3f4
171#define CLK_SOURCE_I2CSLOW 0x3fc
172#define CLK_SOURCE_SE 0x42c
173#define CLK_SOURCE_MSELECT 0x3b4
174#define CLK_SOURCE_EMC 0x19c
175
176#define AUDIO_SYNC_DOUBLER 0x49c
177
178#define PMC_CTRL 0
179#define PMC_CTRL_BLINK_ENB 7
180
181#define PMC_DPD_PADS_ORIDE 0x1c
182#define PMC_DPD_PADS_ORIDE_BLINK_ENB 20
183#define PMC_BLINK_TIMER 0x40
184
185#define UTMIP_PLL_CFG2 0x488
186#define UTMIP_PLL_CFG2_STABLE_COUNT(x) (((x) & 0xffff) << 6)
187#define UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT(x) (((x) & 0x3f) << 18)
188#define UTMIP_PLL_CFG2_FORCE_PD_SAMP_A_POWERDOWN BIT(0)
189#define UTMIP_PLL_CFG2_FORCE_PD_SAMP_B_POWERDOWN BIT(2)
190#define UTMIP_PLL_CFG2_FORCE_PD_SAMP_C_POWERDOWN BIT(4)
191
192#define UTMIP_PLL_CFG1 0x484
193#define UTMIP_PLL_CFG1_ENABLE_DLY_COUNT(x) (((x) & 0x1f) << 6)
194#define UTMIP_PLL_CFG1_XTAL_FREQ_COUNT(x) (((x) & 0xfff) << 0)
195#define UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERDOWN BIT(14)
196#define UTMIP_PLL_CFG1_FORCE_PLL_ACTIVE_POWERDOWN BIT(12)
197#define UTMIP_PLL_CFG1_FORCE_PLLU_POWERDOWN BIT(16)
198
199/* Tegra CPU clock and reset control regs */
200#define TEGRA_CLK_RST_CONTROLLER_CLK_CPU_CMPLX 0x4c
201#define TEGRA_CLK_RST_CONTROLLER_RST_CPU_CMPLX_SET 0x340
202#define TEGRA_CLK_RST_CONTROLLER_RST_CPU_CMPLX_CLR 0x344
203#define TEGRA30_CLK_RST_CONTROLLER_CLK_CPU_CMPLX_CLR 0x34c
204#define TEGRA30_CLK_RST_CONTROLLER_CPU_CMPLX_STATUS 0x470
205
206#define CPU_CLOCK(cpu) (0x1 << (8 + cpu))
207#define CPU_RESET(cpu) (0x1111ul << (cpu))
208
209#define CLK_RESET_CCLK_BURST 0x20
210#define CLK_RESET_CCLK_DIVIDER 0x24
211#define CLK_RESET_PLLX_BASE 0xe0
212#define CLK_RESET_PLLX_MISC 0xe4
213
214#define CLK_RESET_SOURCE_CSITE 0x1d4
215
216#define CLK_RESET_CCLK_BURST_POLICY_SHIFT 28
217#define CLK_RESET_CCLK_RUN_POLICY_SHIFT 4
218#define CLK_RESET_CCLK_IDLE_POLICY_SHIFT 0
219#define CLK_RESET_CCLK_IDLE_POLICY 1
220#define CLK_RESET_CCLK_RUN_POLICY 2
221#define CLK_RESET_CCLK_BURST_POLICY_PLLX 8
222
Peter De Schrijverc09e32b2013-06-06 13:47:30 +0300223/* PLLM override registers */
224#define PMC_PLLM_WB0_OVERRIDE 0x1dc
225
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530226#ifdef CONFIG_PM_SLEEP
227static struct cpu_clk_suspend_context {
228 u32 pllx_misc;
229 u32 pllx_base;
230
231 u32 cpu_burst;
232 u32 clk_csite_src;
233 u32 cclk_divider;
234} tegra30_cpu_clk_sctx;
235#endif
236
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530237static void __iomem *clk_base;
238static void __iomem *pmc_base;
239static unsigned long input_freq;
240
241static DEFINE_SPINLOCK(clk_doubler_lock);
242static DEFINE_SPINLOCK(clk_out_lock);
243static DEFINE_SPINLOCK(pll_div_lock);
244static DEFINE_SPINLOCK(cml_lock);
245static DEFINE_SPINLOCK(pll_d_lock);
Peter De Schrijverd076a202013-02-07 18:37:35 +0200246static DEFINE_SPINLOCK(sysrate_lock);
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530247
248#define TEGRA_INIT_DATA_MUX(_name, _con_id, _dev_id, _parents, _offset, \
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +0300249 _clk_num, _gate_flags, _clk_id) \
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530250 TEGRA_INIT_DATA(_name, _con_id, _dev_id, _parents, _offset, \
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +0300251 30, 2, 0, 0, 8, 1, TEGRA_DIVIDER_ROUND_UP, \
Peter De Schrijver343a6072013-09-02 15:22:02 +0300252 _clk_num, _gate_flags, _clk_id)
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530253
254#define TEGRA_INIT_DATA_DIV16(_name, _con_id, _dev_id, _parents, _offset, \
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +0300255 _clk_num, _gate_flags, _clk_id) \
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530256 TEGRA_INIT_DATA(_name, _con_id, _dev_id, _parents, _offset, \
257 30, 2, 0, 0, 16, 0, TEGRA_DIVIDER_ROUND_UP, \
Peter De Schrijver343a6072013-09-02 15:22:02 +0300258 _clk_num, \
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530259 _gate_flags, _clk_id)
260
261#define TEGRA_INIT_DATA_MUX8(_name, _con_id, _dev_id, _parents, _offset, \
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +0300262 _clk_num, _gate_flags, _clk_id) \
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530263 TEGRA_INIT_DATA(_name, _con_id, _dev_id, _parents, _offset, \
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +0300264 29, 3, 0, 0, 8, 1, TEGRA_DIVIDER_ROUND_UP, \
Peter De Schrijver343a6072013-09-02 15:22:02 +0300265 _clk_num, _gate_flags, _clk_id)
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530266
267#define TEGRA_INIT_DATA_INT(_name, _con_id, _dev_id, _parents, _offset, \
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +0300268 _clk_num, _gate_flags, _clk_id) \
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530269 TEGRA_INIT_DATA(_name, _con_id, _dev_id, _parents, _offset, \
Peter De Schrijver252d0d22013-11-26 13:48:09 +0200270 30, 2, 0, 0, 8, 1, TEGRA_DIVIDER_INT | \
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +0300271 TEGRA_DIVIDER_ROUND_UP, _clk_num, \
Peter De Schrijver343a6072013-09-02 15:22:02 +0300272 _gate_flags, _clk_id)
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530273
274#define TEGRA_INIT_DATA_UART(_name, _con_id, _dev_id, _parents, _offset,\
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +0300275 _clk_num, _clk_id) \
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530276 TEGRA_INIT_DATA(_name, _con_id, _dev_id, _parents, _offset, \
Peter De Schrijver252d0d22013-11-26 13:48:09 +0200277 30, 2, 0, 0, 16, 1, TEGRA_DIVIDER_UART | \
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +0300278 TEGRA_DIVIDER_ROUND_UP, _clk_num, \
Peter De Schrijver343a6072013-09-02 15:22:02 +0300279 0, _clk_id)
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530280
281#define TEGRA_INIT_DATA_NODIV(_name, _con_id, _dev_id, _parents, _offset, \
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +0300282 _mux_shift, _mux_width, _clk_num, \
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530283 _gate_flags, _clk_id) \
284 TEGRA_INIT_DATA(_name, _con_id, _dev_id, _parents, _offset, \
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +0300285 _mux_shift, _mux_width, 0, 0, 0, 0, 0,\
Peter De Schrijver343a6072013-09-02 15:22:02 +0300286 _clk_num, _gate_flags, \
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530287 _clk_id)
288
289/*
290 * IDs assigned here must be in sync with DT bindings definition
291 * for Tegra30 clocks.
292 */
293enum tegra30_clk {
294 cpu, rtc = 4, timer, uarta, gpio = 8, sdmmc2, i2s1 = 11, i2c1, ndflash,
295 sdmmc1, sdmmc4, pwm = 17, i2s2, epp, gr2d = 21, usbd, isp, gr3d,
296 disp2 = 26, disp1, host1x, vcp, i2s0, cop_cache, mc, ahbdma, apbdma,
297 kbc = 36, statmon, pmc, kfuse = 40, sbc1, nor, sbc2 = 44, sbc3 = 46,
298 i2c5, dsia, mipi = 50, hdmi, csi, tvdac, i2c2, uartc, emc = 57, usb2,
299 usb3, mpe, vde, bsea, bsev, speedo, uartd, uarte, i2c3, sbc4, sdmmc3,
Stephen Warren0203d912013-02-12 12:17:37 -0700300 pcie, owr, afi, csite, pciex, avpucq, la, dtv = 79, ndspeed, i2cslow,
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530301 dsib, irama = 84, iramb, iramc, iramd, cram2, audio_2x = 90, csus = 92,
Prashant Gaikwad82ce7422013-04-04 14:35:04 +0530302 cdev2, cdev1, cpu_g = 96, cpu_lp, gr3d2, mselect, tsensor, i2s3, i2s4,
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530303 i2c4, sbc5, sbc6, d_audio, apbif, dam0, dam1, dam2, hda2codec_2x,
304 atomics, audio0_2x, audio1_2x, audio2_2x, audio3_2x, audio4_2x,
Joseph Lo22ca3352013-02-07 13:07:11 +0800305 spdif_2x, actmon, extern1, extern2, extern3, sata_oob, sata, hda,
Stephen Warren0203d912013-02-12 12:17:37 -0700306 se = 127, hda2hdmi, sata_cold, uartb = 160, vfir, spdif_in, spdif_out,
Joseph Lo22ca3352013-02-07 13:07:11 +0800307 vi, vi_sensor, fuse, fuse_burn, cve, tvo, clk_32k, clk_m, clk_m_div2,
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530308 clk_m_div4, pll_ref, pll_c, pll_c_out1, pll_m, pll_m_out1, pll_p,
309 pll_p_out1, pll_p_out2, pll_p_out3, pll_p_out4, pll_a, pll_a_out0,
310 pll_d, pll_d_out0, pll_d2, pll_d2_out0, pll_u, pll_x, pll_x_out0, pll_e,
311 spdif_in_sync, i2s0_sync, i2s1_sync, i2s2_sync, i2s3_sync, i2s4_sync,
312 vimclk_sync, audio0, audio1, audio2, audio3, audio4, spdif, clk_out_1,
313 clk_out_2, clk_out_3, sclk, blink, cclk_g, cclk_lp, twd, cml0, cml1,
Stephen Warren0203d912013-02-12 12:17:37 -0700314 hclk, pclk, clk_out_1_mux = 300, clk_max
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530315};
316
Peter De Schrijver343a6072013-09-02 15:22:02 +0300317static struct clk **clks;
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530318
319/*
320 * Structure defining the fields for USB UTMI clocks Parameters.
321 */
322struct utmi_clk_param {
323 /* Oscillator Frequency in KHz */
324 u32 osc_frequency;
325 /* UTMIP PLL Enable Delay Count */
326 u8 enable_delay_count;
327 /* UTMIP PLL Stable count */
328 u8 stable_count;
329 /* UTMIP PLL Active delay count */
330 u8 active_delay_count;
331 /* UTMIP PLL Xtal frequency count */
332 u8 xtal_freq_count;
333};
334
335static const struct utmi_clk_param utmi_parameters[] = {
336/* OSC_FREQUENCY, ENABLE_DLY, STABLE_CNT, ACTIVE_DLY, XTAL_FREQ_CNT */
337 {13000000, 0x02, 0x33, 0x05, 0x7F},
338 {19200000, 0x03, 0x4B, 0x06, 0xBB},
339 {12000000, 0x02, 0x2F, 0x04, 0x76},
340 {26000000, 0x04, 0x66, 0x09, 0xFE},
341 {16800000, 0x03, 0x41, 0x0A, 0xA4},
342};
343
344static struct tegra_clk_pll_freq_table pll_c_freq_table[] = {
Peter De Schrijverdba40722013-04-03 17:40:36 +0300345 { 12000000, 1040000000, 520, 6, 0, 8},
346 { 13000000, 1040000000, 480, 6, 0, 8},
347 { 16800000, 1040000000, 495, 8, 0, 8}, /* actual: 1039.5 MHz */
348 { 19200000, 1040000000, 325, 6, 0, 6},
349 { 26000000, 1040000000, 520, 13, 0, 8},
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530350
Peter De Schrijverdba40722013-04-03 17:40:36 +0300351 { 12000000, 832000000, 416, 6, 0, 8},
352 { 13000000, 832000000, 832, 13, 0, 8},
353 { 16800000, 832000000, 396, 8, 0, 8}, /* actual: 831.6 MHz */
354 { 19200000, 832000000, 260, 6, 0, 8},
355 { 26000000, 832000000, 416, 13, 0, 8},
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530356
Peter De Schrijverdba40722013-04-03 17:40:36 +0300357 { 12000000, 624000000, 624, 12, 0, 8},
358 { 13000000, 624000000, 624, 13, 0, 8},
359 { 16800000, 600000000, 520, 14, 0, 8},
360 { 19200000, 624000000, 520, 16, 0, 8},
361 { 26000000, 624000000, 624, 26, 0, 8},
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530362
Peter De Schrijverdba40722013-04-03 17:40:36 +0300363 { 12000000, 600000000, 600, 12, 0, 8},
364 { 13000000, 600000000, 600, 13, 0, 8},
365 { 16800000, 600000000, 500, 14, 0, 8},
366 { 19200000, 600000000, 375, 12, 0, 6},
367 { 26000000, 600000000, 600, 26, 0, 8},
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530368
Peter De Schrijverdba40722013-04-03 17:40:36 +0300369 { 12000000, 520000000, 520, 12, 0, 8},
370 { 13000000, 520000000, 520, 13, 0, 8},
371 { 16800000, 520000000, 495, 16, 0, 8}, /* actual: 519.75 MHz */
372 { 19200000, 520000000, 325, 12, 0, 6},
373 { 26000000, 520000000, 520, 26, 0, 8},
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530374
Peter De Schrijverdba40722013-04-03 17:40:36 +0300375 { 12000000, 416000000, 416, 12, 0, 8},
376 { 13000000, 416000000, 416, 13, 0, 8},
377 { 16800000, 416000000, 396, 16, 0, 8}, /* actual: 415.8 MHz */
378 { 19200000, 416000000, 260, 12, 0, 6},
379 { 26000000, 416000000, 416, 26, 0, 8},
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530380 { 0, 0, 0, 0, 0, 0 },
381};
382
383static struct tegra_clk_pll_freq_table pll_m_freq_table[] = {
Peter De Schrijverdba40722013-04-03 17:40:36 +0300384 { 12000000, 666000000, 666, 12, 0, 8},
385 { 13000000, 666000000, 666, 13, 0, 8},
386 { 16800000, 666000000, 555, 14, 0, 8},
387 { 19200000, 666000000, 555, 16, 0, 8},
388 { 26000000, 666000000, 666, 26, 0, 8},
389 { 12000000, 600000000, 600, 12, 0, 8},
390 { 13000000, 600000000, 600, 13, 0, 8},
391 { 16800000, 600000000, 500, 14, 0, 8},
392 { 19200000, 600000000, 375, 12, 0, 6},
393 { 26000000, 600000000, 600, 26, 0, 8},
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530394 { 0, 0, 0, 0, 0, 0 },
395};
396
397static struct tegra_clk_pll_freq_table pll_p_freq_table[] = {
Peter De Schrijverdba40722013-04-03 17:40:36 +0300398 { 12000000, 216000000, 432, 12, 1, 8},
399 { 13000000, 216000000, 432, 13, 1, 8},
400 { 16800000, 216000000, 360, 14, 1, 8},
401 { 19200000, 216000000, 360, 16, 1, 8},
402 { 26000000, 216000000, 432, 26, 1, 8},
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530403 { 0, 0, 0, 0, 0, 0 },
404};
405
406static struct tegra_clk_pll_freq_table pll_a_freq_table[] = {
Peter De Schrijverdba40722013-04-03 17:40:36 +0300407 { 9600000, 564480000, 294, 5, 0, 4},
408 { 9600000, 552960000, 288, 5, 0, 4},
409 { 9600000, 24000000, 5, 2, 0, 1},
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530410
Peter De Schrijverdba40722013-04-03 17:40:36 +0300411 { 28800000, 56448000, 49, 25, 0, 1},
412 { 28800000, 73728000, 64, 25, 0, 1},
413 { 28800000, 24000000, 5, 6, 0, 1},
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530414 { 0, 0, 0, 0, 0, 0 },
415};
416
417static struct tegra_clk_pll_freq_table pll_d_freq_table[] = {
Peter De Schrijverdba40722013-04-03 17:40:36 +0300418 { 12000000, 216000000, 216, 12, 0, 4},
419 { 13000000, 216000000, 216, 13, 0, 4},
420 { 16800000, 216000000, 180, 14, 0, 4},
421 { 19200000, 216000000, 180, 16, 0, 4},
422 { 26000000, 216000000, 216, 26, 0, 4},
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530423
Peter De Schrijverdba40722013-04-03 17:40:36 +0300424 { 12000000, 594000000, 594, 12, 0, 8},
425 { 13000000, 594000000, 594, 13, 0, 8},
426 { 16800000, 594000000, 495, 14, 0, 8},
427 { 19200000, 594000000, 495, 16, 0, 8},
428 { 26000000, 594000000, 594, 26, 0, 8},
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530429
Peter De Schrijverdba40722013-04-03 17:40:36 +0300430 { 12000000, 1000000000, 1000, 12, 0, 12},
431 { 13000000, 1000000000, 1000, 13, 0, 12},
432 { 19200000, 1000000000, 625, 12, 0, 8},
433 { 26000000, 1000000000, 1000, 26, 0, 12},
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530434
435 { 0, 0, 0, 0, 0, 0 },
436};
437
Peter De Schrijver0b6525a2013-04-03 17:40:39 +0300438static struct pdiv_map pllu_p[] = {
439 { .pdiv = 1, .hw_val = 1 },
440 { .pdiv = 2, .hw_val = 0 },
441 { .pdiv = 0, .hw_val = 0 },
442};
443
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530444static struct tegra_clk_pll_freq_table pll_u_freq_table[] = {
Peter De Schrijverdba40722013-04-03 17:40:36 +0300445 { 12000000, 480000000, 960, 12, 0, 12},
446 { 13000000, 480000000, 960, 13, 0, 12},
447 { 16800000, 480000000, 400, 7, 0, 5},
448 { 19200000, 480000000, 200, 4, 0, 3},
449 { 26000000, 480000000, 960, 26, 0, 12},
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530450 { 0, 0, 0, 0, 0, 0 },
451};
452
453static struct tegra_clk_pll_freq_table pll_x_freq_table[] = {
454 /* 1.7 GHz */
Peter De Schrijverdba40722013-04-03 17:40:36 +0300455 { 12000000, 1700000000, 850, 6, 0, 8},
456 { 13000000, 1700000000, 915, 7, 0, 8}, /* actual: 1699.2 MHz */
457 { 16800000, 1700000000, 708, 7, 0, 8}, /* actual: 1699.2 MHz */
458 { 19200000, 1700000000, 885, 10, 0, 8}, /* actual: 1699.2 MHz */
459 { 26000000, 1700000000, 850, 13, 0, 8},
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530460
461 /* 1.6 GHz */
Peter De Schrijverdba40722013-04-03 17:40:36 +0300462 { 12000000, 1600000000, 800, 6, 0, 8},
463 { 13000000, 1600000000, 738, 6, 0, 8}, /* actual: 1599.0 MHz */
464 { 16800000, 1600000000, 857, 9, 0, 8}, /* actual: 1599.7 MHz */
465 { 19200000, 1600000000, 500, 6, 0, 8},
466 { 26000000, 1600000000, 800, 13, 0, 8},
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530467
468 /* 1.5 GHz */
Peter De Schrijverdba40722013-04-03 17:40:36 +0300469 { 12000000, 1500000000, 750, 6, 0, 8},
470 { 13000000, 1500000000, 923, 8, 0, 8}, /* actual: 1499.8 MHz */
471 { 16800000, 1500000000, 625, 7, 0, 8},
472 { 19200000, 1500000000, 625, 8, 0, 8},
473 { 26000000, 1500000000, 750, 13, 0, 8},
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530474
475 /* 1.4 GHz */
Peter De Schrijverdba40722013-04-03 17:40:36 +0300476 { 12000000, 1400000000, 700, 6, 0, 8},
477 { 13000000, 1400000000, 969, 9, 0, 8}, /* actual: 1399.7 MHz */
478 { 16800000, 1400000000, 1000, 12, 0, 8},
479 { 19200000, 1400000000, 875, 12, 0, 8},
480 { 26000000, 1400000000, 700, 13, 0, 8},
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530481
482 /* 1.3 GHz */
Peter De Schrijverdba40722013-04-03 17:40:36 +0300483 { 12000000, 1300000000, 975, 9, 0, 8},
484 { 13000000, 1300000000, 1000, 10, 0, 8},
485 { 16800000, 1300000000, 928, 12, 0, 8}, /* actual: 1299.2 MHz */
486 { 19200000, 1300000000, 812, 12, 0, 8}, /* actual: 1299.2 MHz */
487 { 26000000, 1300000000, 650, 13, 0, 8},
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530488
489 /* 1.2 GHz */
Peter De Schrijverdba40722013-04-03 17:40:36 +0300490 { 12000000, 1200000000, 1000, 10, 0, 8},
491 { 13000000, 1200000000, 923, 10, 0, 8}, /* actual: 1199.9 MHz */
492 { 16800000, 1200000000, 1000, 14, 0, 8},
493 { 19200000, 1200000000, 1000, 16, 0, 8},
494 { 26000000, 1200000000, 600, 13, 0, 8},
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530495
496 /* 1.1 GHz */
Peter De Schrijverdba40722013-04-03 17:40:36 +0300497 { 12000000, 1100000000, 825, 9, 0, 8},
498 { 13000000, 1100000000, 846, 10, 0, 8}, /* actual: 1099.8 MHz */
499 { 16800000, 1100000000, 982, 15, 0, 8}, /* actual: 1099.8 MHz */
500 { 19200000, 1100000000, 859, 15, 0, 8}, /* actual: 1099.5 MHz */
501 { 26000000, 1100000000, 550, 13, 0, 8},
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530502
503 /* 1 GHz */
Peter De Schrijverdba40722013-04-03 17:40:36 +0300504 { 12000000, 1000000000, 1000, 12, 0, 8},
505 { 13000000, 1000000000, 1000, 13, 0, 8},
506 { 16800000, 1000000000, 833, 14, 0, 8}, /* actual: 999.6 MHz */
507 { 19200000, 1000000000, 625, 12, 0, 8},
508 { 26000000, 1000000000, 1000, 26, 0, 8},
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530509
510 { 0, 0, 0, 0, 0, 0 },
511};
512
513static struct tegra_clk_pll_freq_table pll_e_freq_table[] = {
514 /* PLLE special case: use cpcon field to store cml divider value */
515 { 12000000, 100000000, 150, 1, 18, 11},
516 { 216000000, 100000000, 200, 18, 24, 13},
517 { 0, 0, 0, 0, 0, 0 },
518};
519
520/* PLL parameters */
521static struct tegra_clk_pll_params pll_c_params = {
522 .input_min = 2000000,
523 .input_max = 31000000,
524 .cf_min = 1000000,
525 .cf_max = 6000000,
526 .vco_min = 20000000,
527 .vco_max = 1400000000,
528 .base_reg = PLLC_BASE,
529 .misc_reg = PLLC_MISC,
Peter De Schrijver3e727712013-04-03 17:40:40 +0300530 .lock_mask = PLL_BASE_LOCK,
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530531 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
532 .lock_delay = 300,
533};
534
Peter De Schrijverc09e32b2013-06-06 13:47:30 +0300535static struct div_nmp pllm_nmp = {
536 .divn_shift = 8,
537 .divn_width = 10,
538 .override_divn_shift = 5,
539 .divm_shift = 0,
540 .divm_width = 5,
541 .override_divm_shift = 0,
542 .divp_shift = 20,
543 .divp_width = 3,
544 .override_divp_shift = 15,
545};
546
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530547static struct tegra_clk_pll_params pll_m_params = {
548 .input_min = 2000000,
549 .input_max = 31000000,
550 .cf_min = 1000000,
551 .cf_max = 6000000,
552 .vco_min = 20000000,
553 .vco_max = 1200000000,
554 .base_reg = PLLM_BASE,
555 .misc_reg = PLLM_MISC,
Peter De Schrijver3e727712013-04-03 17:40:40 +0300556 .lock_mask = PLL_BASE_LOCK,
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530557 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
558 .lock_delay = 300,
Peter De Schrijverc09e32b2013-06-06 13:47:30 +0300559 .div_nmp = &pllm_nmp,
560 .pmc_divnm_reg = PMC_PLLM_WB0_OVERRIDE,
561 .pmc_divp_reg = PMC_PLLM_WB0_OVERRIDE,
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530562};
563
564static struct tegra_clk_pll_params pll_p_params = {
565 .input_min = 2000000,
566 .input_max = 31000000,
567 .cf_min = 1000000,
568 .cf_max = 6000000,
569 .vco_min = 20000000,
570 .vco_max = 1400000000,
571 .base_reg = PLLP_BASE,
572 .misc_reg = PLLP_MISC,
Peter De Schrijver3e727712013-04-03 17:40:40 +0300573 .lock_mask = PLL_BASE_LOCK,
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530574 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
575 .lock_delay = 300,
576};
577
578static struct tegra_clk_pll_params pll_a_params = {
579 .input_min = 2000000,
580 .input_max = 31000000,
581 .cf_min = 1000000,
582 .cf_max = 6000000,
583 .vco_min = 20000000,
584 .vco_max = 1400000000,
585 .base_reg = PLLA_BASE,
586 .misc_reg = PLLA_MISC,
Peter De Schrijver3e727712013-04-03 17:40:40 +0300587 .lock_mask = PLL_BASE_LOCK,
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530588 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
589 .lock_delay = 300,
590};
591
592static struct tegra_clk_pll_params pll_d_params = {
593 .input_min = 2000000,
594 .input_max = 40000000,
595 .cf_min = 1000000,
596 .cf_max = 6000000,
597 .vco_min = 40000000,
598 .vco_max = 1000000000,
599 .base_reg = PLLD_BASE,
600 .misc_reg = PLLD_MISC,
Peter De Schrijver3e727712013-04-03 17:40:40 +0300601 .lock_mask = PLL_BASE_LOCK,
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530602 .lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE,
603 .lock_delay = 1000,
604};
605
606static struct tegra_clk_pll_params pll_d2_params = {
607 .input_min = 2000000,
608 .input_max = 40000000,
609 .cf_min = 1000000,
610 .cf_max = 6000000,
611 .vco_min = 40000000,
612 .vco_max = 1000000000,
613 .base_reg = PLLD2_BASE,
614 .misc_reg = PLLD2_MISC,
Peter De Schrijver3e727712013-04-03 17:40:40 +0300615 .lock_mask = PLL_BASE_LOCK,
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530616 .lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE,
617 .lock_delay = 1000,
618};
619
620static struct tegra_clk_pll_params pll_u_params = {
621 .input_min = 2000000,
622 .input_max = 40000000,
623 .cf_min = 1000000,
624 .cf_max = 6000000,
625 .vco_min = 48000000,
626 .vco_max = 960000000,
627 .base_reg = PLLU_BASE,
628 .misc_reg = PLLU_MISC,
Peter De Schrijver3e727712013-04-03 17:40:40 +0300629 .lock_mask = PLL_BASE_LOCK,
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530630 .lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE,
631 .lock_delay = 1000,
Peter De Schrijver0b6525a2013-04-03 17:40:39 +0300632 .pdiv_tohw = pllu_p,
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530633};
634
635static struct tegra_clk_pll_params pll_x_params = {
636 .input_min = 2000000,
637 .input_max = 31000000,
638 .cf_min = 1000000,
639 .cf_max = 6000000,
640 .vco_min = 20000000,
641 .vco_max = 1700000000,
642 .base_reg = PLLX_BASE,
643 .misc_reg = PLLX_MISC,
Peter De Schrijver3e727712013-04-03 17:40:40 +0300644 .lock_mask = PLL_BASE_LOCK,
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530645 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
646 .lock_delay = 300,
647};
648
649static struct tegra_clk_pll_params pll_e_params = {
650 .input_min = 12000000,
651 .input_max = 216000000,
652 .cf_min = 12000000,
653 .cf_max = 12000000,
654 .vco_min = 1200000000,
655 .vco_max = 2400000000U,
656 .base_reg = PLLE_BASE,
657 .misc_reg = PLLE_MISC,
Peter De Schrijver3e727712013-04-03 17:40:40 +0300658 .lock_mask = PLLE_MISC_LOCK,
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530659 .lock_enable_bit_idx = PLLE_MISC_LOCK_ENABLE,
660 .lock_delay = 300,
661};
662
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530663static void tegra30_clk_measure_input_freq(void)
664{
665 u32 osc_ctrl = readl_relaxed(clk_base + OSC_CTRL);
666 u32 auto_clk_control = osc_ctrl & OSC_CTRL_OSC_FREQ_MASK;
667 u32 pll_ref_div = osc_ctrl & OSC_CTRL_PLL_REF_DIV_MASK;
668
669 switch (auto_clk_control) {
670 case OSC_CTRL_OSC_FREQ_12MHZ:
671 BUG_ON(pll_ref_div != OSC_CTRL_PLL_REF_DIV_1);
672 input_freq = 12000000;
673 break;
674 case OSC_CTRL_OSC_FREQ_13MHZ:
675 BUG_ON(pll_ref_div != OSC_CTRL_PLL_REF_DIV_1);
676 input_freq = 13000000;
677 break;
678 case OSC_CTRL_OSC_FREQ_19_2MHZ:
679 BUG_ON(pll_ref_div != OSC_CTRL_PLL_REF_DIV_1);
680 input_freq = 19200000;
681 break;
682 case OSC_CTRL_OSC_FREQ_26MHZ:
683 BUG_ON(pll_ref_div != OSC_CTRL_PLL_REF_DIV_1);
684 input_freq = 26000000;
685 break;
686 case OSC_CTRL_OSC_FREQ_16_8MHZ:
687 BUG_ON(pll_ref_div != OSC_CTRL_PLL_REF_DIV_1);
688 input_freq = 16800000;
689 break;
690 case OSC_CTRL_OSC_FREQ_38_4MHZ:
691 BUG_ON(pll_ref_div != OSC_CTRL_PLL_REF_DIV_2);
692 input_freq = 38400000;
693 break;
694 case OSC_CTRL_OSC_FREQ_48MHZ:
695 BUG_ON(pll_ref_div != OSC_CTRL_PLL_REF_DIV_4);
696 input_freq = 48000000;
697 break;
698 default:
699 pr_err("Unexpected auto clock control value %d",
700 auto_clk_control);
701 BUG();
702 return;
703 }
704}
705
706static unsigned int tegra30_get_pll_ref_div(void)
707{
708 u32 pll_ref_div = readl_relaxed(clk_base + OSC_CTRL) &
709 OSC_CTRL_PLL_REF_DIV_MASK;
710
711 switch (pll_ref_div) {
712 case OSC_CTRL_PLL_REF_DIV_1:
713 return 1;
714 case OSC_CTRL_PLL_REF_DIV_2:
715 return 2;
716 case OSC_CTRL_PLL_REF_DIV_4:
717 return 4;
718 default:
719 pr_err("Invalid pll ref divider %d", pll_ref_div);
720 BUG();
721 }
722 return 0;
723}
724
725static void tegra30_utmi_param_configure(void)
726{
727 u32 reg;
728 int i;
729
730 for (i = 0; i < ARRAY_SIZE(utmi_parameters); i++) {
731 if (input_freq == utmi_parameters[i].osc_frequency)
732 break;
733 }
734
735 if (i >= ARRAY_SIZE(utmi_parameters)) {
736 pr_err("%s: Unexpected input rate %lu\n", __func__, input_freq);
737 return;
738 }
739
740 reg = readl_relaxed(clk_base + UTMIP_PLL_CFG2);
741
742 /* Program UTMIP PLL stable and active counts */
743 reg &= ~UTMIP_PLL_CFG2_STABLE_COUNT(~0);
744 reg |= UTMIP_PLL_CFG2_STABLE_COUNT(
745 utmi_parameters[i].stable_count);
746
747 reg &= ~UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT(~0);
748
749 reg |= UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT(
750 utmi_parameters[i].active_delay_count);
751
752 /* Remove power downs from UTMIP PLL control bits */
753 reg &= ~UTMIP_PLL_CFG2_FORCE_PD_SAMP_A_POWERDOWN;
754 reg &= ~UTMIP_PLL_CFG2_FORCE_PD_SAMP_B_POWERDOWN;
755 reg &= ~UTMIP_PLL_CFG2_FORCE_PD_SAMP_C_POWERDOWN;
756
757 writel_relaxed(reg, clk_base + UTMIP_PLL_CFG2);
758
759 /* Program UTMIP PLL delay and oscillator frequency counts */
760 reg = readl_relaxed(clk_base + UTMIP_PLL_CFG1);
761 reg &= ~UTMIP_PLL_CFG1_ENABLE_DLY_COUNT(~0);
762
763 reg |= UTMIP_PLL_CFG1_ENABLE_DLY_COUNT(
764 utmi_parameters[i].enable_delay_count);
765
766 reg &= ~UTMIP_PLL_CFG1_XTAL_FREQ_COUNT(~0);
767 reg |= UTMIP_PLL_CFG1_XTAL_FREQ_COUNT(
768 utmi_parameters[i].xtal_freq_count);
769
770 /* Remove power downs from UTMIP PLL control bits */
771 reg &= ~UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERDOWN;
772 reg &= ~UTMIP_PLL_CFG1_FORCE_PLL_ACTIVE_POWERDOWN;
773 reg &= ~UTMIP_PLL_CFG1_FORCE_PLLU_POWERDOWN;
774
775 writel_relaxed(reg, clk_base + UTMIP_PLL_CFG1);
776}
777
778static const char *pll_e_parents[] = {"pll_ref", "pll_p"};
779
780static void __init tegra30_pll_init(void)
781{
782 struct clk *clk;
783
784 /* PLLC */
785 clk = tegra_clk_register_pll("pll_c", "pll_ref", clk_base, pmc_base, 0,
786 0, &pll_c_params,
787 TEGRA_PLL_HAS_CPCON | TEGRA_PLL_USE_LOCK,
788 pll_c_freq_table, NULL);
789 clk_register_clkdev(clk, "pll_c", NULL);
790 clks[pll_c] = clk;
791
792 /* PLLC_OUT1 */
793 clk = tegra_clk_register_divider("pll_c_out1_div", "pll_c",
794 clk_base + PLLC_OUT, 0, TEGRA_DIVIDER_ROUND_UP,
795 8, 8, 1, NULL);
796 clk = tegra_clk_register_pll_out("pll_c_out1", "pll_c_out1_div",
797 clk_base + PLLC_OUT, 1, 0, CLK_SET_RATE_PARENT,
798 0, NULL);
799 clk_register_clkdev(clk, "pll_c_out1", NULL);
800 clks[pll_c_out1] = clk;
801
802 /* PLLP */
803 clk = tegra_clk_register_pll("pll_p", "pll_ref", clk_base, pmc_base, 0,
804 408000000, &pll_p_params,
805 TEGRA_PLL_FIXED | TEGRA_PLL_HAS_CPCON |
806 TEGRA_PLL_USE_LOCK, pll_p_freq_table, NULL);
807 clk_register_clkdev(clk, "pll_p", NULL);
808 clks[pll_p] = clk;
809
810 /* PLLP_OUT1 */
811 clk = tegra_clk_register_divider("pll_p_out1_div", "pll_p",
812 clk_base + PLLP_OUTA, 0, TEGRA_DIVIDER_FIXED |
813 TEGRA_DIVIDER_ROUND_UP, 8, 8, 1,
814 &pll_div_lock);
815 clk = tegra_clk_register_pll_out("pll_p_out1", "pll_p_out1_div",
816 clk_base + PLLP_OUTA, 1, 0,
817 CLK_IGNORE_UNUSED | CLK_SET_RATE_PARENT, 0,
818 &pll_div_lock);
819 clk_register_clkdev(clk, "pll_p_out1", NULL);
820 clks[pll_p_out1] = clk;
821
822 /* PLLP_OUT2 */
823 clk = tegra_clk_register_divider("pll_p_out2_div", "pll_p",
824 clk_base + PLLP_OUTA, 0, TEGRA_DIVIDER_FIXED |
825 TEGRA_DIVIDER_ROUND_UP, 24, 8, 1,
826 &pll_div_lock);
827 clk = tegra_clk_register_pll_out("pll_p_out2", "pll_p_out2_div",
828 clk_base + PLLP_OUTA, 17, 16,
829 CLK_IGNORE_UNUSED | CLK_SET_RATE_PARENT, 0,
830 &pll_div_lock);
831 clk_register_clkdev(clk, "pll_p_out2", NULL);
832 clks[pll_p_out2] = clk;
833
834 /* PLLP_OUT3 */
835 clk = tegra_clk_register_divider("pll_p_out3_div", "pll_p",
836 clk_base + PLLP_OUTB, 0, TEGRA_DIVIDER_FIXED |
837 TEGRA_DIVIDER_ROUND_UP, 8, 8, 1,
838 &pll_div_lock);
839 clk = tegra_clk_register_pll_out("pll_p_out3", "pll_p_out3_div",
840 clk_base + PLLP_OUTB, 1, 0,
841 CLK_IGNORE_UNUSED | CLK_SET_RATE_PARENT, 0,
842 &pll_div_lock);
843 clk_register_clkdev(clk, "pll_p_out3", NULL);
844 clks[pll_p_out3] = clk;
845
846 /* PLLP_OUT4 */
847 clk = tegra_clk_register_divider("pll_p_out4_div", "pll_p",
848 clk_base + PLLP_OUTB, 0, TEGRA_DIVIDER_FIXED |
849 TEGRA_DIVIDER_ROUND_UP, 24, 8, 1,
850 &pll_div_lock);
851 clk = tegra_clk_register_pll_out("pll_p_out4", "pll_p_out4_div",
852 clk_base + PLLP_OUTB, 17, 16,
853 CLK_IGNORE_UNUSED | CLK_SET_RATE_PARENT, 0,
854 &pll_div_lock);
855 clk_register_clkdev(clk, "pll_p_out4", NULL);
856 clks[pll_p_out4] = clk;
857
858 /* PLLM */
859 clk = tegra_clk_register_pll("pll_m", "pll_ref", clk_base, pmc_base,
860 CLK_IGNORE_UNUSED | CLK_SET_RATE_GATE, 0,
861 &pll_m_params, TEGRA_PLLM | TEGRA_PLL_HAS_CPCON |
862 TEGRA_PLL_SET_DCCON | TEGRA_PLL_USE_LOCK,
863 pll_m_freq_table, NULL);
864 clk_register_clkdev(clk, "pll_m", NULL);
865 clks[pll_m] = clk;
866
867 /* PLLM_OUT1 */
868 clk = tegra_clk_register_divider("pll_m_out1_div", "pll_m",
869 clk_base + PLLM_OUT, 0, TEGRA_DIVIDER_ROUND_UP,
870 8, 8, 1, NULL);
871 clk = tegra_clk_register_pll_out("pll_m_out1", "pll_m_out1_div",
872 clk_base + PLLM_OUT, 1, 0, CLK_IGNORE_UNUSED |
873 CLK_SET_RATE_PARENT, 0, NULL);
874 clk_register_clkdev(clk, "pll_m_out1", NULL);
875 clks[pll_m_out1] = clk;
876
877 /* PLLX */
878 clk = tegra_clk_register_pll("pll_x", "pll_ref", clk_base, pmc_base, 0,
879 0, &pll_x_params, TEGRA_PLL_HAS_CPCON |
880 TEGRA_PLL_SET_DCCON | TEGRA_PLL_USE_LOCK,
881 pll_x_freq_table, NULL);
882 clk_register_clkdev(clk, "pll_x", NULL);
883 clks[pll_x] = clk;
884
885 /* PLLX_OUT0 */
886 clk = clk_register_fixed_factor(NULL, "pll_x_out0", "pll_x",
887 CLK_SET_RATE_PARENT, 1, 2);
888 clk_register_clkdev(clk, "pll_x_out0", NULL);
889 clks[pll_x_out0] = clk;
890
891 /* PLLU */
892 clk = tegra_clk_register_pll("pll_u", "pll_ref", clk_base, pmc_base, 0,
893 0, &pll_u_params, TEGRA_PLLU | TEGRA_PLL_HAS_CPCON |
Tuomas Tynkkynen89ac8562013-08-28 18:18:47 +0300894 TEGRA_PLL_SET_LFCON,
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530895 pll_u_freq_table,
896 NULL);
897 clk_register_clkdev(clk, "pll_u", NULL);
898 clks[pll_u] = clk;
899
900 tegra30_utmi_param_configure();
901
902 /* PLLD */
903 clk = tegra_clk_register_pll("pll_d", "pll_ref", clk_base, pmc_base, 0,
904 0, &pll_d_params, TEGRA_PLL_HAS_CPCON |
905 TEGRA_PLL_SET_LFCON | TEGRA_PLL_USE_LOCK,
906 pll_d_freq_table, &pll_d_lock);
907 clk_register_clkdev(clk, "pll_d", NULL);
908 clks[pll_d] = clk;
909
910 /* PLLD_OUT0 */
911 clk = clk_register_fixed_factor(NULL, "pll_d_out0", "pll_d",
912 CLK_SET_RATE_PARENT, 1, 2);
913 clk_register_clkdev(clk, "pll_d_out0", NULL);
914 clks[pll_d_out0] = clk;
915
916 /* PLLD2 */
917 clk = tegra_clk_register_pll("pll_d2", "pll_ref", clk_base, pmc_base, 0,
918 0, &pll_d2_params, TEGRA_PLL_HAS_CPCON |
919 TEGRA_PLL_SET_LFCON | TEGRA_PLL_USE_LOCK,
920 pll_d_freq_table, NULL);
921 clk_register_clkdev(clk, "pll_d2", NULL);
922 clks[pll_d2] = clk;
923
924 /* PLLD2_OUT0 */
925 clk = clk_register_fixed_factor(NULL, "pll_d2_out0", "pll_d2",
926 CLK_SET_RATE_PARENT, 1, 2);
927 clk_register_clkdev(clk, "pll_d2_out0", NULL);
928 clks[pll_d2_out0] = clk;
929
930 /* PLLA */
931 clk = tegra_clk_register_pll("pll_a", "pll_p_out1", clk_base, pmc_base,
932 0, 0, &pll_a_params, TEGRA_PLL_HAS_CPCON |
933 TEGRA_PLL_USE_LOCK, pll_a_freq_table, NULL);
934 clk_register_clkdev(clk, "pll_a", NULL);
935 clks[pll_a] = clk;
936
937 /* PLLA_OUT0 */
938 clk = tegra_clk_register_divider("pll_a_out0_div", "pll_a",
939 clk_base + PLLA_OUT, 0, TEGRA_DIVIDER_ROUND_UP,
940 8, 8, 1, NULL);
941 clk = tegra_clk_register_pll_out("pll_a_out0", "pll_a_out0_div",
942 clk_base + PLLA_OUT, 1, 0, CLK_IGNORE_UNUSED |
943 CLK_SET_RATE_PARENT, 0, NULL);
944 clk_register_clkdev(clk, "pll_a_out0", NULL);
945 clks[pll_a_out0] = clk;
946
947 /* PLLE */
948 clk = clk_register_mux(NULL, "pll_e_mux", pll_e_parents,
James Hogan819c1de2013-07-29 12:25:01 +0100949 ARRAY_SIZE(pll_e_parents),
950 CLK_SET_RATE_NO_REPARENT,
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +0530951 clk_base + PLLE_AUX, 2, 1, 0, NULL);
952 clk = tegra_clk_register_plle("pll_e", "pll_e_mux", clk_base, pmc_base,
953 CLK_GET_RATE_NOCACHE, 100000000, &pll_e_params,
954 TEGRA_PLLE_CONFIGURE, pll_e_freq_table, NULL);
955 clk_register_clkdev(clk, "pll_e", NULL);
956 clks[pll_e] = clk;
957}
958
959static const char *mux_audio_sync_clk[] = { "spdif_in_sync", "i2s0_sync",
960 "i2s1_sync", "i2s2_sync", "i2s3_sync", "i2s4_sync", "vimclk_sync",};
961static const char *clk_out1_parents[] = { "clk_m", "clk_m_div2",
962 "clk_m_div4", "extern1", };
963static const char *clk_out2_parents[] = { "clk_m", "clk_m_div2",
964 "clk_m_div4", "extern2", };
965static const char *clk_out3_parents[] = { "clk_m", "clk_m_div2",
966 "clk_m_div4", "extern3", };
967
968static void __init tegra30_audio_clk_init(void)
969{
970 struct clk *clk;
971
972 /* spdif_in_sync */
973 clk = tegra_clk_register_sync_source("spdif_in_sync", 24000000,
974 24000000);
975 clk_register_clkdev(clk, "spdif_in_sync", NULL);
976 clks[spdif_in_sync] = clk;
977
978 /* i2s0_sync */
979 clk = tegra_clk_register_sync_source("i2s0_sync", 24000000, 24000000);
980 clk_register_clkdev(clk, "i2s0_sync", NULL);
981 clks[i2s0_sync] = clk;
982
983 /* i2s1_sync */
984 clk = tegra_clk_register_sync_source("i2s1_sync", 24000000, 24000000);
985 clk_register_clkdev(clk, "i2s1_sync", NULL);
986 clks[i2s1_sync] = clk;
987
988 /* i2s2_sync */
989 clk = tegra_clk_register_sync_source("i2s2_sync", 24000000, 24000000);
990 clk_register_clkdev(clk, "i2s2_sync", NULL);
991 clks[i2s2_sync] = clk;
992
993 /* i2s3_sync */
994 clk = tegra_clk_register_sync_source("i2s3_sync", 24000000, 24000000);
995 clk_register_clkdev(clk, "i2s3_sync", NULL);
996 clks[i2s3_sync] = clk;
997
998 /* i2s4_sync */
999 clk = tegra_clk_register_sync_source("i2s4_sync", 24000000, 24000000);
1000 clk_register_clkdev(clk, "i2s4_sync", NULL);
1001 clks[i2s4_sync] = clk;
1002
1003 /* vimclk_sync */
1004 clk = tegra_clk_register_sync_source("vimclk_sync", 24000000, 24000000);
1005 clk_register_clkdev(clk, "vimclk_sync", NULL);
1006 clks[vimclk_sync] = clk;
1007
1008 /* audio0 */
1009 clk = clk_register_mux(NULL, "audio0_mux", mux_audio_sync_clk,
James Hogan819c1de2013-07-29 12:25:01 +01001010 ARRAY_SIZE(mux_audio_sync_clk),
1011 CLK_SET_RATE_NO_REPARENT,
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301012 clk_base + AUDIO_SYNC_CLK_I2S0, 0, 3, 0, NULL);
1013 clk = clk_register_gate(NULL, "audio0", "audio0_mux", 0,
1014 clk_base + AUDIO_SYNC_CLK_I2S0, 4,
1015 CLK_GATE_SET_TO_DISABLE, NULL);
1016 clk_register_clkdev(clk, "audio0", NULL);
1017 clks[audio0] = clk;
1018
1019 /* audio1 */
1020 clk = clk_register_mux(NULL, "audio1_mux", mux_audio_sync_clk,
James Hogan819c1de2013-07-29 12:25:01 +01001021 ARRAY_SIZE(mux_audio_sync_clk),
1022 CLK_SET_RATE_NO_REPARENT,
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301023 clk_base + AUDIO_SYNC_CLK_I2S1, 0, 3, 0, NULL);
1024 clk = clk_register_gate(NULL, "audio1", "audio1_mux", 0,
1025 clk_base + AUDIO_SYNC_CLK_I2S1, 4,
1026 CLK_GATE_SET_TO_DISABLE, NULL);
1027 clk_register_clkdev(clk, "audio1", NULL);
1028 clks[audio1] = clk;
1029
1030 /* audio2 */
1031 clk = clk_register_mux(NULL, "audio2_mux", mux_audio_sync_clk,
James Hogan819c1de2013-07-29 12:25:01 +01001032 ARRAY_SIZE(mux_audio_sync_clk),
1033 CLK_SET_RATE_NO_REPARENT,
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301034 clk_base + AUDIO_SYNC_CLK_I2S2, 0, 3, 0, NULL);
1035 clk = clk_register_gate(NULL, "audio2", "audio2_mux", 0,
1036 clk_base + AUDIO_SYNC_CLK_I2S2, 4,
1037 CLK_GATE_SET_TO_DISABLE, NULL);
1038 clk_register_clkdev(clk, "audio2", NULL);
1039 clks[audio2] = clk;
1040
1041 /* audio3 */
1042 clk = clk_register_mux(NULL, "audio3_mux", mux_audio_sync_clk,
James Hogan819c1de2013-07-29 12:25:01 +01001043 ARRAY_SIZE(mux_audio_sync_clk),
1044 CLK_SET_RATE_NO_REPARENT,
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301045 clk_base + AUDIO_SYNC_CLK_I2S3, 0, 3, 0, NULL);
1046 clk = clk_register_gate(NULL, "audio3", "audio3_mux", 0,
1047 clk_base + AUDIO_SYNC_CLK_I2S3, 4,
1048 CLK_GATE_SET_TO_DISABLE, NULL);
1049 clk_register_clkdev(clk, "audio3", NULL);
1050 clks[audio3] = clk;
1051
1052 /* audio4 */
1053 clk = clk_register_mux(NULL, "audio4_mux", mux_audio_sync_clk,
James Hogan819c1de2013-07-29 12:25:01 +01001054 ARRAY_SIZE(mux_audio_sync_clk),
1055 CLK_SET_RATE_NO_REPARENT,
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301056 clk_base + AUDIO_SYNC_CLK_I2S4, 0, 3, 0, NULL);
1057 clk = clk_register_gate(NULL, "audio4", "audio4_mux", 0,
1058 clk_base + AUDIO_SYNC_CLK_I2S4, 4,
1059 CLK_GATE_SET_TO_DISABLE, NULL);
1060 clk_register_clkdev(clk, "audio4", NULL);
1061 clks[audio4] = clk;
1062
1063 /* spdif */
1064 clk = clk_register_mux(NULL, "spdif_mux", mux_audio_sync_clk,
James Hogan819c1de2013-07-29 12:25:01 +01001065 ARRAY_SIZE(mux_audio_sync_clk),
1066 CLK_SET_RATE_NO_REPARENT,
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301067 clk_base + AUDIO_SYNC_CLK_SPDIF, 0, 3, 0, NULL);
1068 clk = clk_register_gate(NULL, "spdif", "spdif_mux", 0,
1069 clk_base + AUDIO_SYNC_CLK_SPDIF, 4,
1070 CLK_GATE_SET_TO_DISABLE, NULL);
1071 clk_register_clkdev(clk, "spdif", NULL);
1072 clks[spdif] = clk;
1073
1074 /* audio0_2x */
1075 clk = clk_register_fixed_factor(NULL, "audio0_doubler", "audio0",
1076 CLK_SET_RATE_PARENT, 2, 1);
1077 clk = tegra_clk_register_divider("audio0_div", "audio0_doubler",
1078 clk_base + AUDIO_SYNC_DOUBLER, 0, 0, 24, 1, 0,
1079 &clk_doubler_lock);
1080 clk = tegra_clk_register_periph_gate("audio0_2x", "audio0_div",
1081 TEGRA_PERIPH_NO_RESET, clk_base,
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +03001082 CLK_SET_RATE_PARENT, 113,
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301083 periph_clk_enb_refcnt);
1084 clk_register_clkdev(clk, "audio0_2x", NULL);
1085 clks[audio0_2x] = clk;
1086
1087 /* audio1_2x */
1088 clk = clk_register_fixed_factor(NULL, "audio1_doubler", "audio1",
1089 CLK_SET_RATE_PARENT, 2, 1);
1090 clk = tegra_clk_register_divider("audio1_div", "audio1_doubler",
1091 clk_base + AUDIO_SYNC_DOUBLER, 0, 0, 25, 1, 0,
1092 &clk_doubler_lock);
1093 clk = tegra_clk_register_periph_gate("audio1_2x", "audio1_div",
1094 TEGRA_PERIPH_NO_RESET, clk_base,
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +03001095 CLK_SET_RATE_PARENT, 114,
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301096 periph_clk_enb_refcnt);
1097 clk_register_clkdev(clk, "audio1_2x", NULL);
1098 clks[audio1_2x] = clk;
1099
1100 /* audio2_2x */
1101 clk = clk_register_fixed_factor(NULL, "audio2_doubler", "audio2",
1102 CLK_SET_RATE_PARENT, 2, 1);
1103 clk = tegra_clk_register_divider("audio2_div", "audio2_doubler",
1104 clk_base + AUDIO_SYNC_DOUBLER, 0, 0, 26, 1, 0,
1105 &clk_doubler_lock);
1106 clk = tegra_clk_register_periph_gate("audio2_2x", "audio2_div",
1107 TEGRA_PERIPH_NO_RESET, clk_base,
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +03001108 CLK_SET_RATE_PARENT, 115,
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301109 periph_clk_enb_refcnt);
1110 clk_register_clkdev(clk, "audio2_2x", NULL);
1111 clks[audio2_2x] = clk;
1112
1113 /* audio3_2x */
1114 clk = clk_register_fixed_factor(NULL, "audio3_doubler", "audio3",
1115 CLK_SET_RATE_PARENT, 2, 1);
1116 clk = tegra_clk_register_divider("audio3_div", "audio3_doubler",
1117 clk_base + AUDIO_SYNC_DOUBLER, 0, 0, 27, 1, 0,
1118 &clk_doubler_lock);
1119 clk = tegra_clk_register_periph_gate("audio3_2x", "audio3_div",
1120 TEGRA_PERIPH_NO_RESET, clk_base,
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +03001121 CLK_SET_RATE_PARENT, 116,
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301122 periph_clk_enb_refcnt);
1123 clk_register_clkdev(clk, "audio3_2x", NULL);
1124 clks[audio3_2x] = clk;
1125
1126 /* audio4_2x */
1127 clk = clk_register_fixed_factor(NULL, "audio4_doubler", "audio4",
1128 CLK_SET_RATE_PARENT, 2, 1);
1129 clk = tegra_clk_register_divider("audio4_div", "audio4_doubler",
1130 clk_base + AUDIO_SYNC_DOUBLER, 0, 0, 28, 1, 0,
1131 &clk_doubler_lock);
1132 clk = tegra_clk_register_periph_gate("audio4_2x", "audio4_div",
1133 TEGRA_PERIPH_NO_RESET, clk_base,
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +03001134 CLK_SET_RATE_PARENT, 117,
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301135 periph_clk_enb_refcnt);
1136 clk_register_clkdev(clk, "audio4_2x", NULL);
1137 clks[audio4_2x] = clk;
1138
1139 /* spdif_2x */
1140 clk = clk_register_fixed_factor(NULL, "spdif_doubler", "spdif",
1141 CLK_SET_RATE_PARENT, 2, 1);
1142 clk = tegra_clk_register_divider("spdif_div", "spdif_doubler",
1143 clk_base + AUDIO_SYNC_DOUBLER, 0, 0, 29, 1, 0,
1144 &clk_doubler_lock);
1145 clk = tegra_clk_register_periph_gate("spdif_2x", "spdif_div",
1146 TEGRA_PERIPH_NO_RESET, clk_base,
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +03001147 CLK_SET_RATE_PARENT, 118,
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301148 periph_clk_enb_refcnt);
1149 clk_register_clkdev(clk, "spdif_2x", NULL);
1150 clks[spdif_2x] = clk;
1151}
1152
1153static void __init tegra30_pmc_clk_init(void)
1154{
1155 struct clk *clk;
1156
1157 /* clk_out_1 */
1158 clk = clk_register_mux(NULL, "clk_out_1_mux", clk_out1_parents,
James Hogan819c1de2013-07-29 12:25:01 +01001159 ARRAY_SIZE(clk_out1_parents),
1160 CLK_SET_RATE_NO_REPARENT,
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301161 pmc_base + PMC_CLK_OUT_CNTRL, 6, 3, 0,
1162 &clk_out_lock);
1163 clks[clk_out_1_mux] = clk;
1164 clk = clk_register_gate(NULL, "clk_out_1", "clk_out_1_mux", 0,
1165 pmc_base + PMC_CLK_OUT_CNTRL, 2, 0,
1166 &clk_out_lock);
1167 clk_register_clkdev(clk, "extern1", "clk_out_1");
1168 clks[clk_out_1] = clk;
1169
1170 /* clk_out_2 */
1171 clk = clk_register_mux(NULL, "clk_out_2_mux", clk_out2_parents,
James Hogan819c1de2013-07-29 12:25:01 +01001172 ARRAY_SIZE(clk_out2_parents),
1173 CLK_SET_RATE_NO_REPARENT,
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301174 pmc_base + PMC_CLK_OUT_CNTRL, 14, 3, 0,
1175 &clk_out_lock);
1176 clk = clk_register_gate(NULL, "clk_out_2", "clk_out_2_mux", 0,
1177 pmc_base + PMC_CLK_OUT_CNTRL, 10, 0,
1178 &clk_out_lock);
1179 clk_register_clkdev(clk, "extern2", "clk_out_2");
1180 clks[clk_out_2] = clk;
1181
1182 /* clk_out_3 */
1183 clk = clk_register_mux(NULL, "clk_out_3_mux", clk_out3_parents,
James Hogan819c1de2013-07-29 12:25:01 +01001184 ARRAY_SIZE(clk_out3_parents),
1185 CLK_SET_RATE_NO_REPARENT,
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301186 pmc_base + PMC_CLK_OUT_CNTRL, 22, 3, 0,
1187 &clk_out_lock);
1188 clk = clk_register_gate(NULL, "clk_out_3", "clk_out_3_mux", 0,
1189 pmc_base + PMC_CLK_OUT_CNTRL, 18, 0,
1190 &clk_out_lock);
1191 clk_register_clkdev(clk, "extern3", "clk_out_3");
1192 clks[clk_out_3] = clk;
1193
1194 /* blink */
1195 writel_relaxed(0, pmc_base + PMC_BLINK_TIMER);
1196 clk = clk_register_gate(NULL, "blink_override", "clk_32k", 0,
1197 pmc_base + PMC_DPD_PADS_ORIDE,
1198 PMC_DPD_PADS_ORIDE_BLINK_ENB, 0, NULL);
1199 clk = clk_register_gate(NULL, "blink", "blink_override", 0,
1200 pmc_base + PMC_CTRL,
1201 PMC_CTRL_BLINK_ENB, 0, NULL);
1202 clk_register_clkdev(clk, "blink", NULL);
1203 clks[blink] = clk;
1204
1205}
1206
Peter De Schrijverb4c154a2013-02-07 18:30:36 +02001207static const char *cclk_g_parents[] = { "clk_m", "pll_c", "clk_32k", "pll_m",
1208 "pll_p_cclkg", "pll_p_out4_cclkg",
1209 "pll_p_out3_cclkg", "unused", "pll_x" };
1210static const char *cclk_lp_parents[] = { "clk_m", "pll_c", "clk_32k", "pll_m",
1211 "pll_p_cclklp", "pll_p_out4_cclklp",
1212 "pll_p_out3_cclklp", "unused", "pll_x",
1213 "pll_x_out0" };
1214static const char *sclk_parents[] = { "clk_m", "pll_c_out1", "pll_p_out4",
1215 "pll_p_out3", "pll_p_out2", "unused",
1216 "clk_32k", "pll_m_out1" };
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301217
1218static void __init tegra30_super_clk_init(void)
1219{
1220 struct clk *clk;
1221
1222 /*
1223 * Clock input to cclk_g divided from pll_p using
1224 * U71 divider of cclk_g.
1225 */
1226 clk = tegra_clk_register_divider("pll_p_cclkg", "pll_p",
1227 clk_base + SUPER_CCLKG_DIVIDER, 0,
1228 TEGRA_DIVIDER_INT, 16, 8, 1, NULL);
1229 clk_register_clkdev(clk, "pll_p_cclkg", NULL);
1230
1231 /*
1232 * Clock input to cclk_g divided from pll_p_out3 using
1233 * U71 divider of cclk_g.
1234 */
1235 clk = tegra_clk_register_divider("pll_p_out3_cclkg", "pll_p_out3",
1236 clk_base + SUPER_CCLKG_DIVIDER, 0,
1237 TEGRA_DIVIDER_INT, 16, 8, 1, NULL);
1238 clk_register_clkdev(clk, "pll_p_out3_cclkg", NULL);
1239
1240 /*
1241 * Clock input to cclk_g divided from pll_p_out4 using
1242 * U71 divider of cclk_g.
1243 */
1244 clk = tegra_clk_register_divider("pll_p_out4_cclkg", "pll_p_out4",
1245 clk_base + SUPER_CCLKG_DIVIDER, 0,
1246 TEGRA_DIVIDER_INT, 16, 8, 1, NULL);
1247 clk_register_clkdev(clk, "pll_p_out4_cclkg", NULL);
1248
1249 /* CCLKG */
1250 clk = tegra_clk_register_super_mux("cclk_g", cclk_g_parents,
1251 ARRAY_SIZE(cclk_g_parents),
1252 CLK_SET_RATE_PARENT,
1253 clk_base + CCLKG_BURST_POLICY,
1254 0, 4, 0, 0, NULL);
1255 clk_register_clkdev(clk, "cclk_g", NULL);
1256 clks[cclk_g] = clk;
1257
1258 /*
1259 * Clock input to cclk_lp divided from pll_p using
1260 * U71 divider of cclk_lp.
1261 */
1262 clk = tegra_clk_register_divider("pll_p_cclklp", "pll_p",
1263 clk_base + SUPER_CCLKLP_DIVIDER, 0,
1264 TEGRA_DIVIDER_INT, 16, 8, 1, NULL);
1265 clk_register_clkdev(clk, "pll_p_cclklp", NULL);
1266
1267 /*
1268 * Clock input to cclk_lp divided from pll_p_out3 using
1269 * U71 divider of cclk_lp.
1270 */
1271 clk = tegra_clk_register_divider("pll_p_out3_cclklp", "pll_p_out3",
1272 clk_base + SUPER_CCLKG_DIVIDER, 0,
1273 TEGRA_DIVIDER_INT, 16, 8, 1, NULL);
1274 clk_register_clkdev(clk, "pll_p_out3_cclklp", NULL);
1275
1276 /*
1277 * Clock input to cclk_lp divided from pll_p_out4 using
1278 * U71 divider of cclk_lp.
1279 */
1280 clk = tegra_clk_register_divider("pll_p_out4_cclklp", "pll_p_out4",
1281 clk_base + SUPER_CCLKLP_DIVIDER, 0,
1282 TEGRA_DIVIDER_INT, 16, 8, 1, NULL);
1283 clk_register_clkdev(clk, "pll_p_out4_cclklp", NULL);
1284
1285 /* CCLKLP */
1286 clk = tegra_clk_register_super_mux("cclk_lp", cclk_lp_parents,
1287 ARRAY_SIZE(cclk_lp_parents),
1288 CLK_SET_RATE_PARENT,
1289 clk_base + CCLKLP_BURST_POLICY,
1290 TEGRA_DIVIDER_2, 4, 8, 9,
1291 NULL);
1292 clk_register_clkdev(clk, "cclk_lp", NULL);
1293 clks[cclk_lp] = clk;
1294
1295 /* SCLK */
1296 clk = tegra_clk_register_super_mux("sclk", sclk_parents,
1297 ARRAY_SIZE(sclk_parents),
1298 CLK_SET_RATE_PARENT,
1299 clk_base + SCLK_BURST_POLICY,
1300 0, 4, 0, 0, NULL);
1301 clk_register_clkdev(clk, "sclk", NULL);
1302 clks[sclk] = clk;
1303
1304 /* HCLK */
1305 clk = clk_register_divider(NULL, "hclk_div", "sclk", 0,
Peter De Schrijverd076a202013-02-07 18:37:35 +02001306 clk_base + SYSTEM_CLK_RATE, 4, 2, 0,
1307 &sysrate_lock);
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301308 clk = clk_register_gate(NULL, "hclk", "hclk_div", CLK_SET_RATE_PARENT,
1309 clk_base + SYSTEM_CLK_RATE, 7,
Peter De Schrijverd076a202013-02-07 18:37:35 +02001310 CLK_GATE_SET_TO_DISABLE, &sysrate_lock);
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301311 clk_register_clkdev(clk, "hclk", NULL);
1312 clks[hclk] = clk;
1313
1314 /* PCLK */
1315 clk = clk_register_divider(NULL, "pclk_div", "hclk", 0,
Peter De Schrijverd076a202013-02-07 18:37:35 +02001316 clk_base + SYSTEM_CLK_RATE, 0, 2, 0,
1317 &sysrate_lock);
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301318 clk = clk_register_gate(NULL, "pclk", "pclk_div", CLK_SET_RATE_PARENT,
1319 clk_base + SYSTEM_CLK_RATE, 3,
Peter De Schrijverd076a202013-02-07 18:37:35 +02001320 CLK_GATE_SET_TO_DISABLE, &sysrate_lock);
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301321 clk_register_clkdev(clk, "pclk", NULL);
1322 clks[pclk] = clk;
1323
1324 /* twd */
1325 clk = clk_register_fixed_factor(NULL, "twd", "cclk_g",
1326 CLK_SET_RATE_PARENT, 1, 2);
1327 clk_register_clkdev(clk, "twd", NULL);
1328 clks[twd] = clk;
1329}
1330
1331static const char *mux_pllacp_clkm[] = { "pll_a_out0", "unused", "pll_p",
1332 "clk_m" };
1333static const char *mux_pllpcm_clkm[] = { "pll_p", "pll_c", "pll_m", "clk_m" };
1334static const char *mux_pllmcp_clkm[] = { "pll_m", "pll_c", "pll_p", "clk_m" };
1335static const char *i2s0_parents[] = { "pll_a_out0", "audio0_2x", "pll_p",
1336 "clk_m" };
1337static const char *i2s1_parents[] = { "pll_a_out0", "audio1_2x", "pll_p",
1338 "clk_m" };
1339static const char *i2s2_parents[] = { "pll_a_out0", "audio2_2x", "pll_p",
1340 "clk_m" };
1341static const char *i2s3_parents[] = { "pll_a_out0", "audio3_2x", "pll_p",
1342 "clk_m" };
1343static const char *i2s4_parents[] = { "pll_a_out0", "audio4_2x", "pll_p",
1344 "clk_m" };
1345static const char *spdif_out_parents[] = { "pll_a_out0", "spdif_2x", "pll_p",
1346 "clk_m" };
1347static const char *spdif_in_parents[] = { "pll_p", "pll_c", "pll_m" };
1348static const char *mux_pllpc_clk32k_clkm[] = { "pll_p", "pll_c", "clk_32k",
1349 "clk_m" };
1350static const char *mux_pllpc_clkm_clk32k[] = { "pll_p", "pll_c", "clk_m",
1351 "clk_32k" };
1352static const char *mux_pllmcpa[] = { "pll_m", "pll_c", "pll_p", "pll_a_out0" };
1353static const char *mux_pllpdc_clkm[] = { "pll_p", "pll_d_out0", "pll_c",
1354 "clk_m" };
1355static const char *mux_pllp_clkm[] = { "pll_p", "unused", "unused", "clk_m" };
1356static const char *mux_pllpmdacd2_clkm[] = { "pll_p", "pll_m", "pll_d_out0",
1357 "pll_a_out0", "pll_c",
1358 "pll_d2_out0", "clk_m" };
1359static const char *mux_plla_clk32k_pllp_clkm_plle[] = { "pll_a_out0",
1360 "clk_32k", "pll_p",
1361 "clk_m", "pll_e" };
1362static const char *mux_plld_out0_plld2_out0[] = { "pll_d_out0",
1363 "pll_d2_out0" };
1364
1365static struct tegra_periph_init_data tegra_periph_clk_list[] = {
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +03001366 TEGRA_INIT_DATA_MUX("i2s0", NULL, "tegra30-i2s.0", i2s0_parents, CLK_SOURCE_I2S0, 30, TEGRA_PERIPH_ON_APB, i2s0),
1367 TEGRA_INIT_DATA_MUX("i2s1", NULL, "tegra30-i2s.1", i2s1_parents, CLK_SOURCE_I2S1, 11, TEGRA_PERIPH_ON_APB, i2s1),
1368 TEGRA_INIT_DATA_MUX("i2s2", NULL, "tegra30-i2s.2", i2s2_parents, CLK_SOURCE_I2S2, 18, TEGRA_PERIPH_ON_APB, i2s2),
1369 TEGRA_INIT_DATA_MUX("i2s3", NULL, "tegra30-i2s.3", i2s3_parents, CLK_SOURCE_I2S3, 101, TEGRA_PERIPH_ON_APB, i2s3),
1370 TEGRA_INIT_DATA_MUX("i2s4", NULL, "tegra30-i2s.4", i2s4_parents, CLK_SOURCE_I2S4, 102, TEGRA_PERIPH_ON_APB, i2s4),
1371 TEGRA_INIT_DATA_MUX("spdif_out", "spdif_out", "tegra30-spdif", spdif_out_parents, CLK_SOURCE_SPDIF_OUT, 10, TEGRA_PERIPH_ON_APB, spdif_out),
1372 TEGRA_INIT_DATA_MUX("spdif_in", "spdif_in", "tegra30-spdif", spdif_in_parents, CLK_SOURCE_SPDIF_IN, 10, TEGRA_PERIPH_ON_APB, spdif_in),
1373 TEGRA_INIT_DATA_MUX("d_audio", "d_audio", "tegra30-ahub", mux_pllacp_clkm, CLK_SOURCE_D_AUDIO, 106, 0, d_audio),
1374 TEGRA_INIT_DATA_MUX("dam0", NULL, "tegra30-dam.0", mux_pllacp_clkm, CLK_SOURCE_DAM0, 108, 0, dam0),
1375 TEGRA_INIT_DATA_MUX("dam1", NULL, "tegra30-dam.1", mux_pllacp_clkm, CLK_SOURCE_DAM1, 109, 0, dam1),
1376 TEGRA_INIT_DATA_MUX("dam2", NULL, "tegra30-dam.2", mux_pllacp_clkm, CLK_SOURCE_DAM2, 110, 0, dam2),
1377 TEGRA_INIT_DATA_MUX("hda", "hda", "tegra30-hda", mux_pllpcm_clkm, CLK_SOURCE_HDA, 125, 0, hda),
1378 TEGRA_INIT_DATA_MUX("hda2codec_2x", "hda2codec", "tegra30-hda", mux_pllpcm_clkm, CLK_SOURCE_HDA2CODEC_2X, 111, 0, hda2codec_2x),
1379 TEGRA_INIT_DATA_MUX("sbc1", NULL, "spi_tegra.0", mux_pllpcm_clkm, CLK_SOURCE_SBC1, 41, TEGRA_PERIPH_ON_APB, sbc1),
1380 TEGRA_INIT_DATA_MUX("sbc2", NULL, "spi_tegra.1", mux_pllpcm_clkm, CLK_SOURCE_SBC2, 44, TEGRA_PERIPH_ON_APB, sbc2),
1381 TEGRA_INIT_DATA_MUX("sbc3", NULL, "spi_tegra.2", mux_pllpcm_clkm, CLK_SOURCE_SBC3, 46, TEGRA_PERIPH_ON_APB, sbc3),
1382 TEGRA_INIT_DATA_MUX("sbc4", NULL, "spi_tegra.3", mux_pllpcm_clkm, CLK_SOURCE_SBC4, 68, TEGRA_PERIPH_ON_APB, sbc4),
1383 TEGRA_INIT_DATA_MUX("sbc5", NULL, "spi_tegra.4", mux_pllpcm_clkm, CLK_SOURCE_SBC5, 104, TEGRA_PERIPH_ON_APB, sbc5),
1384 TEGRA_INIT_DATA_MUX("sbc6", NULL, "spi_tegra.5", mux_pllpcm_clkm, CLK_SOURCE_SBC6, 105, TEGRA_PERIPH_ON_APB, sbc6),
1385 TEGRA_INIT_DATA_MUX("sata_oob", NULL, "tegra_sata_oob", mux_pllpcm_clkm, CLK_SOURCE_SATA_OOB, 123, TEGRA_PERIPH_ON_APB, sata_oob),
1386 TEGRA_INIT_DATA_MUX("sata", NULL, "tegra_sata", mux_pllpcm_clkm, CLK_SOURCE_SATA, 124, TEGRA_PERIPH_ON_APB, sata),
1387 TEGRA_INIT_DATA_MUX("ndflash", NULL, "tegra_nand", mux_pllpcm_clkm, CLK_SOURCE_NDFLASH, 13, TEGRA_PERIPH_ON_APB, ndflash),
1388 TEGRA_INIT_DATA_MUX("ndspeed", NULL, "tegra_nand_speed", mux_pllpcm_clkm, CLK_SOURCE_NDSPEED, 80, TEGRA_PERIPH_ON_APB, ndspeed),
1389 TEGRA_INIT_DATA_MUX("vfir", NULL, "vfir", mux_pllpcm_clkm, CLK_SOURCE_VFIR, 7, TEGRA_PERIPH_ON_APB, vfir),
1390 TEGRA_INIT_DATA_MUX("csite", NULL, "csite", mux_pllpcm_clkm, CLK_SOURCE_CSITE, 73, TEGRA_PERIPH_ON_APB, csite),
1391 TEGRA_INIT_DATA_MUX("la", NULL, "la", mux_pllpcm_clkm, CLK_SOURCE_LA, 76, TEGRA_PERIPH_ON_APB, la),
1392 TEGRA_INIT_DATA_MUX("owr", NULL, "tegra_w1", mux_pllpcm_clkm, CLK_SOURCE_OWR, 71, TEGRA_PERIPH_ON_APB, owr),
1393 TEGRA_INIT_DATA_MUX("mipi", NULL, "mipi", mux_pllpcm_clkm, CLK_SOURCE_MIPI, 50, TEGRA_PERIPH_ON_APB, mipi),
1394 TEGRA_INIT_DATA_MUX("tsensor", NULL, "tegra-tsensor", mux_pllpc_clkm_clk32k, CLK_SOURCE_TSENSOR, 100, TEGRA_PERIPH_ON_APB, tsensor),
1395 TEGRA_INIT_DATA_MUX("i2cslow", NULL, "i2cslow", mux_pllpc_clk32k_clkm, CLK_SOURCE_I2CSLOW, 81, TEGRA_PERIPH_ON_APB, i2cslow),
1396 TEGRA_INIT_DATA_INT("vde", NULL, "vde", mux_pllpcm_clkm, CLK_SOURCE_VDE, 61, 0, vde),
1397 TEGRA_INIT_DATA_INT("vi", "vi", "tegra_camera", mux_pllmcpa, CLK_SOURCE_VI, 20, 0, vi),
1398 TEGRA_INIT_DATA_INT("epp", NULL, "epp", mux_pllmcpa, CLK_SOURCE_EPP, 19, 0, epp),
1399 TEGRA_INIT_DATA_INT("mpe", NULL, "mpe", mux_pllmcpa, CLK_SOURCE_MPE, 60, 0, mpe),
1400 TEGRA_INIT_DATA_INT("host1x", NULL, "host1x", mux_pllmcpa, CLK_SOURCE_HOST1X, 28, 0, host1x),
1401 TEGRA_INIT_DATA_INT("3d", NULL, "3d", mux_pllmcpa, CLK_SOURCE_3D, 24, TEGRA_PERIPH_MANUAL_RESET, gr3d),
1402 TEGRA_INIT_DATA_INT("3d2", NULL, "3d2", mux_pllmcpa, CLK_SOURCE_3D2, 98, TEGRA_PERIPH_MANUAL_RESET, gr3d2),
1403 TEGRA_INIT_DATA_INT("2d", NULL, "2d", mux_pllmcpa, CLK_SOURCE_2D, 21, 0, gr2d),
1404 TEGRA_INIT_DATA_INT("se", NULL, "se", mux_pllpcm_clkm, CLK_SOURCE_SE, 127, 0, se),
1405 TEGRA_INIT_DATA_MUX("mselect", NULL, "mselect", mux_pllp_clkm, CLK_SOURCE_MSELECT, 99, 0, mselect),
1406 TEGRA_INIT_DATA_MUX("nor", NULL, "tegra-nor", mux_pllpcm_clkm, CLK_SOURCE_NOR, 42, 0, nor),
1407 TEGRA_INIT_DATA_MUX("sdmmc1", NULL, "sdhci-tegra.0", mux_pllpcm_clkm, CLK_SOURCE_SDMMC1, 14, 0, sdmmc1),
1408 TEGRA_INIT_DATA_MUX("sdmmc2", NULL, "sdhci-tegra.1", mux_pllpcm_clkm, CLK_SOURCE_SDMMC2, 9, 0, sdmmc2),
1409 TEGRA_INIT_DATA_MUX("sdmmc3", NULL, "sdhci-tegra.2", mux_pllpcm_clkm, CLK_SOURCE_SDMMC3, 69, 0, sdmmc3),
1410 TEGRA_INIT_DATA_MUX("sdmmc4", NULL, "sdhci-tegra.3", mux_pllpcm_clkm, CLK_SOURCE_SDMMC4, 15, 0, sdmmc4),
1411 TEGRA_INIT_DATA_MUX("cve", NULL, "cve", mux_pllpdc_clkm, CLK_SOURCE_CVE, 49, 0, cve),
1412 TEGRA_INIT_DATA_MUX("tvo", NULL, "tvo", mux_pllpdc_clkm, CLK_SOURCE_TVO, 49, 0, tvo),
1413 TEGRA_INIT_DATA_MUX("tvdac", NULL, "tvdac", mux_pllpdc_clkm, CLK_SOURCE_TVDAC, 53, 0, tvdac),
1414 TEGRA_INIT_DATA_MUX("actmon", NULL, "actmon", mux_pllpc_clk32k_clkm, CLK_SOURCE_ACTMON, 119, 0, actmon),
1415 TEGRA_INIT_DATA_MUX("vi_sensor", "vi_sensor", "tegra_camera", mux_pllmcpa, CLK_SOURCE_VI_SENSOR, 20, TEGRA_PERIPH_NO_RESET, vi_sensor),
1416 TEGRA_INIT_DATA_DIV16("i2c1", "div-clk", "tegra-i2c.0", mux_pllp_clkm, CLK_SOURCE_I2C1, 12, TEGRA_PERIPH_ON_APB, i2c1),
1417 TEGRA_INIT_DATA_DIV16("i2c2", "div-clk", "tegra-i2c.1", mux_pllp_clkm, CLK_SOURCE_I2C2, 54, TEGRA_PERIPH_ON_APB, i2c2),
1418 TEGRA_INIT_DATA_DIV16("i2c3", "div-clk", "tegra-i2c.2", mux_pllp_clkm, CLK_SOURCE_I2C3, 67, TEGRA_PERIPH_ON_APB, i2c3),
1419 TEGRA_INIT_DATA_DIV16("i2c4", "div-clk", "tegra-i2c.3", mux_pllp_clkm, CLK_SOURCE_I2C4, 103, TEGRA_PERIPH_ON_APB, i2c4),
1420 TEGRA_INIT_DATA_DIV16("i2c5", "div-clk", "tegra-i2c.4", mux_pllp_clkm, CLK_SOURCE_I2C5, 47, TEGRA_PERIPH_ON_APB, i2c5),
1421 TEGRA_INIT_DATA_UART("uarta", NULL, "tegra_uart.0", mux_pllpcm_clkm, CLK_SOURCE_UARTA, 6, uarta),
1422 TEGRA_INIT_DATA_UART("uartb", NULL, "tegra_uart.1", mux_pllpcm_clkm, CLK_SOURCE_UARTB, 7, uartb),
1423 TEGRA_INIT_DATA_UART("uartc", NULL, "tegra_uart.2", mux_pllpcm_clkm, CLK_SOURCE_UARTC, 55, uartc),
1424 TEGRA_INIT_DATA_UART("uartd", NULL, "tegra_uart.3", mux_pllpcm_clkm, CLK_SOURCE_UARTD, 65, uartd),
1425 TEGRA_INIT_DATA_UART("uarte", NULL, "tegra_uart.4", mux_pllpcm_clkm, CLK_SOURCE_UARTE, 66, uarte),
1426 TEGRA_INIT_DATA_MUX8("hdmi", NULL, "hdmi", mux_pllpmdacd2_clkm, CLK_SOURCE_HDMI, 51, 0, hdmi),
1427 TEGRA_INIT_DATA_MUX8("extern1", NULL, "extern1", mux_plla_clk32k_pllp_clkm_plle, CLK_SOURCE_EXTERN1, 120, 0, extern1),
1428 TEGRA_INIT_DATA_MUX8("extern2", NULL, "extern2", mux_plla_clk32k_pllp_clkm_plle, CLK_SOURCE_EXTERN2, 121, 0, extern2),
1429 TEGRA_INIT_DATA_MUX8("extern3", NULL, "extern3", mux_plla_clk32k_pllp_clkm_plle, CLK_SOURCE_EXTERN3, 122, 0, extern3),
Peter De Schrijver343a6072013-09-02 15:22:02 +03001430 TEGRA_INIT_DATA("pwm", NULL, "pwm", mux_pllpc_clk32k_clkm, CLK_SOURCE_PWM, 28, 2, 0, 0, 8, 1, 0, 17, 0, pwm),
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301431};
1432
1433static struct tegra_periph_init_data tegra_periph_nodiv_clk_list[] = {
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +03001434 TEGRA_INIT_DATA_NODIV("disp1", NULL, "tegradc.0", mux_pllpmdacd2_clkm, CLK_SOURCE_DISP1, 29, 3, 27, 0, disp1),
1435 TEGRA_INIT_DATA_NODIV("disp2", NULL, "tegradc.1", mux_pllpmdacd2_clkm, CLK_SOURCE_DISP2, 29, 3, 26, 0, disp2),
1436 TEGRA_INIT_DATA_NODIV("dsib", NULL, "tegradc.1", mux_plld_out0_plld2_out0, CLK_SOURCE_DSIB, 25, 1, 82, 0, dsib),
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301437};
1438
1439static void __init tegra30_periph_clk_init(void)
1440{
1441 struct tegra_periph_init_data *data;
1442 struct clk *clk;
1443 int i;
1444
1445 /* apbdma */
1446 clk = tegra_clk_register_periph_gate("apbdma", "clk_m", 0, clk_base, 0, 34,
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +03001447 periph_clk_enb_refcnt);
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301448 clk_register_clkdev(clk, NULL, "tegra-apbdma");
1449 clks[apbdma] = clk;
1450
1451 /* rtc */
1452 clk = tegra_clk_register_periph_gate("rtc", "clk_32k",
1453 TEGRA_PERIPH_NO_RESET | TEGRA_PERIPH_ON_APB,
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +03001454 clk_base, 0, 4, periph_clk_enb_refcnt);
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301455 clk_register_clkdev(clk, NULL, "rtc-tegra");
1456 clks[rtc] = clk;
1457
1458 /* timer */
1459 clk = tegra_clk_register_periph_gate("timer", "clk_m", 0, clk_base, 0,
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +03001460 5, periph_clk_enb_refcnt);
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301461 clk_register_clkdev(clk, NULL, "timer");
1462 clks[timer] = clk;
1463
1464 /* kbc */
1465 clk = tegra_clk_register_periph_gate("kbc", "clk_32k",
1466 TEGRA_PERIPH_NO_RESET | TEGRA_PERIPH_ON_APB,
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +03001467 clk_base, 0, 36, periph_clk_enb_refcnt);
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301468 clk_register_clkdev(clk, NULL, "tegra-kbc");
1469 clks[kbc] = clk;
1470
1471 /* csus */
1472 clk = tegra_clk_register_periph_gate("csus", "clk_m",
1473 TEGRA_PERIPH_NO_RESET | TEGRA_PERIPH_ON_APB,
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +03001474 clk_base, 0, 92, periph_clk_enb_refcnt);
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301475 clk_register_clkdev(clk, "csus", "tengra_camera");
1476 clks[csus] = clk;
1477
1478 /* vcp */
1479 clk = tegra_clk_register_periph_gate("vcp", "clk_m", 0, clk_base, 0, 29,
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +03001480 periph_clk_enb_refcnt);
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301481 clk_register_clkdev(clk, "vcp", "tegra-avp");
1482 clks[vcp] = clk;
1483
1484 /* bsea */
1485 clk = tegra_clk_register_periph_gate("bsea", "clk_m", 0, clk_base, 0,
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +03001486 62, periph_clk_enb_refcnt);
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301487 clk_register_clkdev(clk, "bsea", "tegra-avp");
1488 clks[bsea] = clk;
1489
1490 /* bsev */
1491 clk = tegra_clk_register_periph_gate("bsev", "clk_m", 0, clk_base, 0,
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +03001492 63, periph_clk_enb_refcnt);
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301493 clk_register_clkdev(clk, "bsev", "tegra-aes");
1494 clks[bsev] = clk;
1495
1496 /* usbd */
1497 clk = tegra_clk_register_periph_gate("usbd", "clk_m", 0, clk_base, 0,
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +03001498 22, periph_clk_enb_refcnt);
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301499 clk_register_clkdev(clk, NULL, "fsl-tegra-udc");
1500 clks[usbd] = clk;
1501
1502 /* usb2 */
1503 clk = tegra_clk_register_periph_gate("usb2", "clk_m", 0, clk_base, 0,
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +03001504 58, periph_clk_enb_refcnt);
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301505 clk_register_clkdev(clk, NULL, "tegra-ehci.1");
1506 clks[usb2] = clk;
1507
1508 /* usb3 */
1509 clk = tegra_clk_register_periph_gate("usb3", "clk_m", 0, clk_base, 0,
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +03001510 59, periph_clk_enb_refcnt);
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301511 clk_register_clkdev(clk, NULL, "tegra-ehci.2");
1512 clks[usb3] = clk;
1513
1514 /* dsia */
1515 clk = tegra_clk_register_periph_gate("dsia", "pll_d_out0", 0, clk_base,
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +03001516 0, 48, periph_clk_enb_refcnt);
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301517 clk_register_clkdev(clk, "dsia", "tegradc.0");
1518 clks[dsia] = clk;
1519
1520 /* csi */
1521 clk = tegra_clk_register_periph_gate("csi", "pll_p_out3", 0, clk_base,
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +03001522 0, 52, periph_clk_enb_refcnt);
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301523 clk_register_clkdev(clk, "csi", "tegra_camera");
1524 clks[csi] = clk;
1525
1526 /* isp */
1527 clk = tegra_clk_register_periph_gate("isp", "clk_m", 0, clk_base, 0, 23,
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +03001528 periph_clk_enb_refcnt);
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301529 clk_register_clkdev(clk, "isp", "tegra_camera");
1530 clks[isp] = clk;
1531
1532 /* pcie */
1533 clk = tegra_clk_register_periph_gate("pcie", "clk_m", 0, clk_base, 0,
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +03001534 70, periph_clk_enb_refcnt);
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301535 clk_register_clkdev(clk, "pcie", "tegra-pcie");
1536 clks[pcie] = clk;
1537
1538 /* afi */
1539 clk = tegra_clk_register_periph_gate("afi", "clk_m", 0, clk_base, 0, 72,
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +03001540 periph_clk_enb_refcnt);
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301541 clk_register_clkdev(clk, "afi", "tegra-pcie");
1542 clks[afi] = clk;
1543
Jay Agarwalff49fad2013-06-12 12:43:43 +05301544 /* pciex */
1545 clk = tegra_clk_register_periph_gate("pciex", "pll_e", 0, clk_base, 0,
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +03001546 74, periph_clk_enb_refcnt);
Jay Agarwalff49fad2013-06-12 12:43:43 +05301547 clk_register_clkdev(clk, "pciex", "tegra-pcie");
1548 clks[pciex] = clk;
1549
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301550 /* kfuse */
1551 clk = tegra_clk_register_periph_gate("kfuse", "clk_m",
1552 TEGRA_PERIPH_ON_APB,
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +03001553 clk_base, 0, 40, periph_clk_enb_refcnt);
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301554 clk_register_clkdev(clk, NULL, "kfuse-tegra");
1555 clks[kfuse] = clk;
1556
1557 /* fuse */
1558 clk = tegra_clk_register_periph_gate("fuse", "clk_m",
1559 TEGRA_PERIPH_ON_APB,
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +03001560 clk_base, 0, 39, periph_clk_enb_refcnt);
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301561 clk_register_clkdev(clk, "fuse", "fuse-tegra");
1562 clks[fuse] = clk;
1563
1564 /* fuse_burn */
1565 clk = tegra_clk_register_periph_gate("fuse_burn", "clk_m",
1566 TEGRA_PERIPH_ON_APB,
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +03001567 clk_base, 0, 39, periph_clk_enb_refcnt);
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301568 clk_register_clkdev(clk, "fuse_burn", "fuse-tegra");
1569 clks[fuse_burn] = clk;
1570
1571 /* apbif */
1572 clk = tegra_clk_register_periph_gate("apbif", "clk_m", 0,
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +03001573 clk_base, 0, 107, periph_clk_enb_refcnt);
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301574 clk_register_clkdev(clk, "apbif", "tegra30-ahub");
1575 clks[apbif] = clk;
1576
1577 /* hda2hdmi */
1578 clk = tegra_clk_register_periph_gate("hda2hdmi", "clk_m",
1579 TEGRA_PERIPH_ON_APB,
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +03001580 clk_base, 0, 128, periph_clk_enb_refcnt);
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301581 clk_register_clkdev(clk, "hda2hdmi", "tegra30-hda");
1582 clks[hda2hdmi] = clk;
1583
1584 /* sata_cold */
1585 clk = tegra_clk_register_periph_gate("sata_cold", "clk_m",
1586 TEGRA_PERIPH_ON_APB,
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +03001587 clk_base, 0, 129, periph_clk_enb_refcnt);
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301588 clk_register_clkdev(clk, NULL, "tegra_sata_cold");
1589 clks[sata_cold] = clk;
1590
1591 /* dtv */
1592 clk = tegra_clk_register_periph_gate("dtv", "clk_m",
1593 TEGRA_PERIPH_ON_APB,
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +03001594 clk_base, 0, 79, periph_clk_enb_refcnt);
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301595 clk_register_clkdev(clk, NULL, "dtv");
1596 clks[dtv] = clk;
1597
1598 /* emc */
1599 clk = clk_register_mux(NULL, "emc_mux", mux_pllmcp_clkm,
James Hogan819c1de2013-07-29 12:25:01 +01001600 ARRAY_SIZE(mux_pllmcp_clkm),
1601 CLK_SET_RATE_NO_REPARENT,
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301602 clk_base + CLK_SOURCE_EMC,
1603 30, 2, 0, NULL);
1604 clk = tegra_clk_register_periph_gate("emc", "emc_mux", 0, clk_base, 0,
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +03001605 57, periph_clk_enb_refcnt);
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301606 clk_register_clkdev(clk, "emc", NULL);
1607 clks[emc] = clk;
1608
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301609 for (i = 0; i < ARRAY_SIZE(tegra_periph_clk_list); i++) {
1610 data = &tegra_periph_clk_list[i];
1611 clk = tegra_clk_register_periph(data->name, data->parent_names,
1612 data->num_parents, &data->periph,
Peter De Schrijvera26a0292013-04-03 17:40:42 +03001613 clk_base, data->offset, data->flags);
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301614 clk_register_clkdev(clk, data->con_id, data->dev_id);
1615 clks[data->clk_id] = clk;
1616 }
1617
1618 for (i = 0; i < ARRAY_SIZE(tegra_periph_nodiv_clk_list); i++) {
1619 data = &tegra_periph_nodiv_clk_list[i];
1620 clk = tegra_clk_register_periph_nodiv(data->name,
1621 data->parent_names,
1622 data->num_parents, &data->periph,
1623 clk_base, data->offset);
1624 clk_register_clkdev(clk, data->con_id, data->dev_id);
1625 clks[data->clk_id] = clk;
1626 }
1627}
1628
1629static void __init tegra30_fixed_clk_init(void)
1630{
1631 struct clk *clk;
1632
1633 /* clk_32k */
1634 clk = clk_register_fixed_rate(NULL, "clk_32k", NULL, CLK_IS_ROOT,
1635 32768);
1636 clk_register_clkdev(clk, "clk_32k", NULL);
1637 clks[clk_32k] = clk;
1638
1639 /* clk_m_div2 */
1640 clk = clk_register_fixed_factor(NULL, "clk_m_div2", "clk_m",
1641 CLK_SET_RATE_PARENT, 1, 2);
1642 clk_register_clkdev(clk, "clk_m_div2", NULL);
1643 clks[clk_m_div2] = clk;
1644
1645 /* clk_m_div4 */
1646 clk = clk_register_fixed_factor(NULL, "clk_m_div4", "clk_m",
1647 CLK_SET_RATE_PARENT, 1, 4);
1648 clk_register_clkdev(clk, "clk_m_div4", NULL);
1649 clks[clk_m_div4] = clk;
1650
1651 /* cml0 */
1652 clk = clk_register_gate(NULL, "cml0", "pll_e", 0, clk_base + PLLE_AUX,
1653 0, 0, &cml_lock);
1654 clk_register_clkdev(clk, "cml0", NULL);
1655 clks[cml0] = clk;
1656
1657 /* cml1 */
1658 clk = clk_register_gate(NULL, "cml1", "pll_e", 0, clk_base + PLLE_AUX,
1659 1, 0, &cml_lock);
1660 clk_register_clkdev(clk, "cml1", NULL);
1661 clks[cml1] = clk;
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301662}
1663
1664static void __init tegra30_osc_clk_init(void)
1665{
1666 struct clk *clk;
1667 unsigned int pll_ref_div;
1668
1669 tegra30_clk_measure_input_freq();
1670
1671 /* clk_m */
1672 clk = clk_register_fixed_rate(NULL, "clk_m", NULL, CLK_IS_ROOT,
1673 input_freq);
1674 clk_register_clkdev(clk, "clk_m", NULL);
1675 clks[clk_m] = clk;
1676
1677 /* pll_ref */
1678 pll_ref_div = tegra30_get_pll_ref_div();
1679 clk = clk_register_fixed_factor(NULL, "pll_ref", "clk_m",
1680 CLK_SET_RATE_PARENT, 1, pll_ref_div);
1681 clk_register_clkdev(clk, "pll_ref", NULL);
1682 clks[pll_ref] = clk;
1683}
1684
1685/* Tegra30 CPU clock and reset control functions */
1686static void tegra30_wait_cpu_in_reset(u32 cpu)
1687{
1688 unsigned int reg;
1689
1690 do {
1691 reg = readl(clk_base +
1692 TEGRA30_CLK_RST_CONTROLLER_CPU_CMPLX_STATUS);
1693 cpu_relax();
1694 } while (!(reg & (1 << cpu))); /* check CPU been reset or not */
1695
1696 return;
1697}
1698
1699static void tegra30_put_cpu_in_reset(u32 cpu)
1700{
1701 writel(CPU_RESET(cpu),
1702 clk_base + TEGRA_CLK_RST_CONTROLLER_RST_CPU_CMPLX_SET);
1703 dmb();
1704}
1705
1706static void tegra30_cpu_out_of_reset(u32 cpu)
1707{
1708 writel(CPU_RESET(cpu),
1709 clk_base + TEGRA_CLK_RST_CONTROLLER_RST_CPU_CMPLX_CLR);
1710 wmb();
1711}
1712
1713
1714static void tegra30_enable_cpu_clock(u32 cpu)
1715{
1716 unsigned int reg;
1717
1718 writel(CPU_CLOCK(cpu),
1719 clk_base + TEGRA30_CLK_RST_CONTROLLER_CLK_CPU_CMPLX_CLR);
1720 reg = readl(clk_base +
1721 TEGRA30_CLK_RST_CONTROLLER_CLK_CPU_CMPLX_CLR);
1722}
1723
1724static void tegra30_disable_cpu_clock(u32 cpu)
1725{
1726
1727 unsigned int reg;
1728
1729 reg = readl(clk_base + TEGRA_CLK_RST_CONTROLLER_CLK_CPU_CMPLX);
1730 writel(reg | CPU_CLOCK(cpu),
1731 clk_base + TEGRA_CLK_RST_CONTROLLER_CLK_CPU_CMPLX);
1732}
1733
1734#ifdef CONFIG_PM_SLEEP
1735static bool tegra30_cpu_rail_off_ready(void)
1736{
1737 unsigned int cpu_rst_status;
1738 int cpu_pwr_status;
1739
1740 cpu_rst_status = readl(clk_base +
1741 TEGRA30_CLK_RST_CONTROLLER_CPU_CMPLX_STATUS);
1742 cpu_pwr_status = tegra_powergate_is_powered(TEGRA_POWERGATE_CPU1) ||
1743 tegra_powergate_is_powered(TEGRA_POWERGATE_CPU2) ||
1744 tegra_powergate_is_powered(TEGRA_POWERGATE_CPU3);
1745
1746 if (((cpu_rst_status & 0xE) != 0xE) || cpu_pwr_status)
1747 return false;
1748
1749 return true;
1750}
1751
1752static void tegra30_cpu_clock_suspend(void)
1753{
1754 /* switch coresite to clk_m, save off original source */
1755 tegra30_cpu_clk_sctx.clk_csite_src =
1756 readl(clk_base + CLK_RESET_SOURCE_CSITE);
1757 writel(3<<30, clk_base + CLK_RESET_SOURCE_CSITE);
1758
1759 tegra30_cpu_clk_sctx.cpu_burst =
1760 readl(clk_base + CLK_RESET_CCLK_BURST);
1761 tegra30_cpu_clk_sctx.pllx_base =
1762 readl(clk_base + CLK_RESET_PLLX_BASE);
1763 tegra30_cpu_clk_sctx.pllx_misc =
1764 readl(clk_base + CLK_RESET_PLLX_MISC);
1765 tegra30_cpu_clk_sctx.cclk_divider =
1766 readl(clk_base + CLK_RESET_CCLK_DIVIDER);
1767}
1768
1769static void tegra30_cpu_clock_resume(void)
1770{
1771 unsigned int reg, policy;
1772
1773 /* Is CPU complex already running on PLLX? */
1774 reg = readl(clk_base + CLK_RESET_CCLK_BURST);
1775 policy = (reg >> CLK_RESET_CCLK_BURST_POLICY_SHIFT) & 0xF;
1776
1777 if (policy == CLK_RESET_CCLK_IDLE_POLICY)
1778 reg = (reg >> CLK_RESET_CCLK_IDLE_POLICY_SHIFT) & 0xF;
1779 else if (policy == CLK_RESET_CCLK_RUN_POLICY)
1780 reg = (reg >> CLK_RESET_CCLK_RUN_POLICY_SHIFT) & 0xF;
1781 else
1782 BUG();
1783
1784 if (reg != CLK_RESET_CCLK_BURST_POLICY_PLLX) {
1785 /* restore PLLX settings if CPU is on different PLL */
1786 writel(tegra30_cpu_clk_sctx.pllx_misc,
1787 clk_base + CLK_RESET_PLLX_MISC);
1788 writel(tegra30_cpu_clk_sctx.pllx_base,
1789 clk_base + CLK_RESET_PLLX_BASE);
1790
1791 /* wait for PLL stabilization if PLLX was enabled */
1792 if (tegra30_cpu_clk_sctx.pllx_base & (1 << 30))
1793 udelay(300);
1794 }
1795
1796 /*
1797 * Restore original burst policy setting for calls resulting from CPU
1798 * LP2 in idle or system suspend.
1799 */
1800 writel(tegra30_cpu_clk_sctx.cclk_divider,
1801 clk_base + CLK_RESET_CCLK_DIVIDER);
1802 writel(tegra30_cpu_clk_sctx.cpu_burst,
1803 clk_base + CLK_RESET_CCLK_BURST);
1804
1805 writel(tegra30_cpu_clk_sctx.clk_csite_src,
1806 clk_base + CLK_RESET_SOURCE_CSITE);
1807}
1808#endif
1809
1810static struct tegra_cpu_car_ops tegra30_cpu_car_ops = {
1811 .wait_for_reset = tegra30_wait_cpu_in_reset,
1812 .put_in_reset = tegra30_put_cpu_in_reset,
1813 .out_of_reset = tegra30_cpu_out_of_reset,
1814 .enable_clock = tegra30_enable_cpu_clock,
1815 .disable_clock = tegra30_disable_cpu_clock,
1816#ifdef CONFIG_PM_SLEEP
1817 .rail_off_ready = tegra30_cpu_rail_off_ready,
1818 .suspend = tegra30_cpu_clock_suspend,
1819 .resume = tegra30_cpu_clock_resume,
1820#endif
1821};
1822
Sachin Kamat4c3b2402013-08-08 09:55:49 +05301823static struct tegra_clk_init_table init_table[] __initdata = {
Laxman Dewangan527fad12013-02-12 20:47:59 +05301824 {uarta, pll_p, 408000000, 0},
1825 {uartb, pll_p, 408000000, 0},
1826 {uartc, pll_p, 408000000, 0},
1827 {uartd, pll_p, 408000000, 0},
1828 {uarte, pll_p, 408000000, 0},
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301829 {pll_a, clk_max, 564480000, 1},
1830 {pll_a_out0, clk_max, 11289600, 1},
1831 {extern1, pll_a_out0, 0, 1},
1832 {clk_out_1_mux, extern1, 0, 0},
1833 {clk_out_1, clk_max, 0, 1},
1834 {blink, clk_max, 0, 1},
1835 {i2s0, pll_a_out0, 11289600, 0},
1836 {i2s1, pll_a_out0, 11289600, 0},
1837 {i2s2, pll_a_out0, 11289600, 0},
1838 {i2s3, pll_a_out0, 11289600, 0},
1839 {i2s4, pll_a_out0, 11289600, 0},
1840 {sdmmc1, pll_p, 48000000, 0},
1841 {sdmmc2, pll_p, 48000000, 0},
1842 {sdmmc3, pll_p, 48000000, 0},
1843 {pll_m, clk_max, 0, 1},
1844 {pclk, clk_max, 0, 1},
1845 {csite, clk_max, 0, 1},
1846 {emc, clk_max, 0, 1},
1847 {mselect, clk_max, 0, 1},
1848 {sbc1, pll_p, 100000000, 0},
1849 {sbc2, pll_p, 100000000, 0},
1850 {sbc3, pll_p, 100000000, 0},
1851 {sbc4, pll_p, 100000000, 0},
1852 {sbc5, pll_p, 100000000, 0},
1853 {sbc6, pll_p, 100000000, 0},
1854 {host1x, pll_c, 150000000, 0},
1855 {disp1, pll_p, 600000000, 0},
1856 {disp2, pll_p, 600000000, 0},
1857 {twd, clk_max, 0, 1},
Thierry Redingce910682013-04-02 16:18:44 +02001858 {gr2d, pll_c, 300000000, 0},
1859 {gr3d, pll_c, 300000000, 0},
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301860 {clk_max, clk_max, 0, 0}, /* This MUST be the last entry. */
1861};
1862
Stephen Warren441f1992013-03-25 13:22:24 -06001863static void __init tegra30_clock_apply_init_table(void)
1864{
1865 tegra_init_from_table(init_table, clks, clk_max);
1866}
1867
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301868/*
1869 * Some clocks may be used by different drivers depending on the board
1870 * configuration. List those here to register them twice in the clock lookup
1871 * table under two names.
1872 */
1873static struct tegra_clk_duplicate tegra_clk_duplicates[] = {
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301874 TEGRA_CLK_DUPLICATE(usbd, "utmip-pad", NULL),
1875 TEGRA_CLK_DUPLICATE(usbd, "tegra-ehci.0", NULL),
1876 TEGRA_CLK_DUPLICATE(usbd, "tegra-otg", NULL),
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301877 TEGRA_CLK_DUPLICATE(bsev, "tegra-avp", "bsev"),
1878 TEGRA_CLK_DUPLICATE(bsev, "nvavp", "bsev"),
1879 TEGRA_CLK_DUPLICATE(vde, "tegra-aes", "vde"),
1880 TEGRA_CLK_DUPLICATE(bsea, "tegra-aes", "bsea"),
1881 TEGRA_CLK_DUPLICATE(bsea, "nvavp", "bsea"),
1882 TEGRA_CLK_DUPLICATE(cml1, "tegra_sata_cml", NULL),
1883 TEGRA_CLK_DUPLICATE(cml0, "tegra_pcie", "cml"),
1884 TEGRA_CLK_DUPLICATE(pciex, "tegra_pcie", "pciex"),
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301885 TEGRA_CLK_DUPLICATE(vcp, "nvavp", "vcp"),
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301886 TEGRA_CLK_DUPLICATE(clk_max, NULL, NULL), /* MUST be the last entry */
1887};
1888
1889static const struct of_device_id pmc_match[] __initconst = {
1890 { .compatible = "nvidia,tegra30-pmc" },
1891 {},
1892};
1893
Prashant Gaikwad061cec92013-05-27 13:10:09 +05301894static void __init tegra30_clock_init(struct device_node *np)
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301895{
1896 struct device_node *node;
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301897
1898 clk_base = of_iomap(np, 0);
1899 if (!clk_base) {
1900 pr_err("ioremap tegra30 CAR failed\n");
1901 return;
1902 }
1903
1904 node = of_find_matching_node(NULL, pmc_match);
1905 if (!node) {
1906 pr_err("Failed to find pmc node\n");
1907 BUG();
1908 }
1909
1910 pmc_base = of_iomap(node, 0);
1911 if (!pmc_base) {
1912 pr_err("Can't map pmc registers\n");
1913 BUG();
1914 }
1915
Peter De Schrijver343a6072013-09-02 15:22:02 +03001916 clks = tegra_clk_init(clk_max, TEGRA30_CLK_PERIPH_BANKS);
1917 if (!clks)
Peter De Schrijverd5ff89a2013-08-22 18:44:06 +03001918 return;
1919
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301920 tegra30_osc_clk_init();
1921 tegra30_fixed_clk_init();
1922 tegra30_pll_init();
1923 tegra30_super_clk_init();
1924 tegra30_periph_clk_init();
1925 tegra30_audio_clk_init();
1926 tegra30_pmc_clk_init();
1927
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301928 tegra_init_dup_clks(tegra_clk_duplicates, clks, clk_max);
1929
Peter De Schrijver343a6072013-09-02 15:22:02 +03001930 tegra_add_of_provider(np);
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301931
Stephen Warren441f1992013-03-25 13:22:24 -06001932 tegra_clk_apply_init_table = tegra30_clock_apply_init_table;
Prashant Gaikwadb08e8c02013-01-11 13:16:25 +05301933
1934 tegra_cpu_car_ops = &tegra30_cpu_car_ops;
1935}
Prashant Gaikwad061cec92013-05-27 13:10:09 +05301936CLK_OF_DECLARE(tegra30, "nvidia,tegra30-car", tegra30_clock_init);