blob: baa3042bcf0a62d9467b31bee8f89b047d0d20e6 [file] [log] [blame]
Chander Kashyap0aee53b2012-02-05 23:01:47 +00001/*
2 * Clock setup for SMDK5250 board based on EXYNOS5
3 *
4 * Copyright (C) 2012 Samsung Electronics
5 *
6 * See file CREDITS for list of people who contributed to this
7 * project.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22 * MA 02111-1307 USA
23 */
24
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +000025#include <common.h>
Chander Kashyap0aee53b2012-02-05 23:01:47 +000026#include <config.h>
Chander Kashyap0aee53b2012-02-05 23:01:47 +000027#include <asm/io.h>
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +000028#include <asm/arch/clk.h>
Chander Kashyap0aee53b2012-02-05 23:01:47 +000029#include <asm/arch/clock.h>
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +000030#include <asm/arch/spl.h>
31
32#include "clock_init.h"
Chander Kashyap0aee53b2012-02-05 23:01:47 +000033#include "setup.h"
34
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +000035DECLARE_GLOBAL_DATA_PTR;
36
37struct arm_clk_ratios arm_clk_ratios[] = {
38 {
39 .arm_freq_mhz = 600,
40
41 .apll_mdiv = 0xc8,
42 .apll_pdiv = 0x4,
43 .apll_sdiv = 0x1,
44
45 .arm2_ratio = 0x0,
46 .apll_ratio = 0x1,
47 .pclk_dbg_ratio = 0x1,
48 .atb_ratio = 0x2,
49 .periph_ratio = 0x7,
50 .acp_ratio = 0x7,
51 .cpud_ratio = 0x1,
52 .arm_ratio = 0x0,
53 }, {
54 .arm_freq_mhz = 800,
55
56 .apll_mdiv = 0x64,
57 .apll_pdiv = 0x3,
58 .apll_sdiv = 0x0,
59
60 .arm2_ratio = 0x0,
61 .apll_ratio = 0x1,
62 .pclk_dbg_ratio = 0x1,
63 .atb_ratio = 0x3,
64 .periph_ratio = 0x7,
65 .acp_ratio = 0x7,
66 .cpud_ratio = 0x2,
67 .arm_ratio = 0x0,
68 }, {
69 .arm_freq_mhz = 1000,
70
71 .apll_mdiv = 0x7d,
72 .apll_pdiv = 0x3,
73 .apll_sdiv = 0x0,
74
75 .arm2_ratio = 0x0,
76 .apll_ratio = 0x1,
77 .pclk_dbg_ratio = 0x1,
78 .atb_ratio = 0x4,
79 .periph_ratio = 0x7,
80 .acp_ratio = 0x7,
81 .cpud_ratio = 0x2,
82 .arm_ratio = 0x0,
83 }, {
84 .arm_freq_mhz = 1200,
85
86 .apll_mdiv = 0x96,
87 .apll_pdiv = 0x3,
88 .apll_sdiv = 0x0,
89
90 .arm2_ratio = 0x0,
91 .apll_ratio = 0x3,
92 .pclk_dbg_ratio = 0x1,
93 .atb_ratio = 0x5,
94 .periph_ratio = 0x7,
95 .acp_ratio = 0x7,
96 .cpud_ratio = 0x3,
97 .arm_ratio = 0x0,
98 }, {
99 .arm_freq_mhz = 1400,
100
101 .apll_mdiv = 0xaf,
102 .apll_pdiv = 0x3,
103 .apll_sdiv = 0x0,
104
105 .arm2_ratio = 0x0,
106 .apll_ratio = 0x3,
107 .pclk_dbg_ratio = 0x1,
108 .atb_ratio = 0x6,
109 .periph_ratio = 0x7,
110 .acp_ratio = 0x7,
111 .cpud_ratio = 0x3,
112 .arm_ratio = 0x0,
113 }, {
114 .arm_freq_mhz = 1700,
115
116 .apll_mdiv = 0x1a9,
117 .apll_pdiv = 0x6,
118 .apll_sdiv = 0x0,
119
120 .arm2_ratio = 0x0,
121 .apll_ratio = 0x3,
122 .pclk_dbg_ratio = 0x1,
123 .atb_ratio = 0x6,
124 .periph_ratio = 0x7,
125 .acp_ratio = 0x7,
126 .cpud_ratio = 0x3,
127 .arm_ratio = 0x0,
128 }
129};
130struct mem_timings mem_timings[] = {
131 {
132 .mem_manuf = MEM_MANUF_ELPIDA,
133 .mem_type = DDR_MODE_DDR3,
134 .frequency_mhz = 800,
135 .mpll_mdiv = 0xc8,
136 .mpll_pdiv = 0x3,
137 .mpll_sdiv = 0x0,
138 .cpll_mdiv = 0xde,
139 .cpll_pdiv = 0x4,
140 .cpll_sdiv = 0x2,
141 .gpll_mdiv = 0x215,
142 .gpll_pdiv = 0xc,
143 .gpll_sdiv = 0x1,
144 .epll_mdiv = 0x60,
145 .epll_pdiv = 0x3,
146 .epll_sdiv = 0x3,
147 .vpll_mdiv = 0x96,
148 .vpll_pdiv = 0x3,
149 .vpll_sdiv = 0x2,
150
151 .bpll_mdiv = 0x64,
152 .bpll_pdiv = 0x3,
153 .bpll_sdiv = 0x0,
154 .pclk_cdrex_ratio = 0x5,
155 .direct_cmd_msr = {
156 0x00020018, 0x00030000, 0x00010042, 0x00000d70
157 },
158 .timing_ref = 0x000000bb,
159 .timing_row = 0x8c36650e,
160 .timing_data = 0x3630580b,
161 .timing_power = 0x41000a44,
162 .phy0_dqs = 0x08080808,
163 .phy1_dqs = 0x08080808,
164 .phy0_dq = 0x08080808,
165 .phy1_dq = 0x08080808,
166 .phy0_tFS = 0x4,
167 .phy1_tFS = 0x4,
168 .phy0_pulld_dqs = 0xf,
169 .phy1_pulld_dqs = 0xf,
170
171 .lpddr3_ctrl_phy_reset = 0x1,
172 .ctrl_start_point = 0x10,
173 .ctrl_inc = 0x10,
174 .ctrl_start = 0x1,
175 .ctrl_dll_on = 0x1,
176 .ctrl_ref = 0x8,
177
178 .ctrl_force = 0x1a,
179 .ctrl_rdlat = 0x0b,
180 .ctrl_bstlen = 0x08,
181
182 .fp_resync = 0x8,
183 .iv_size = 0x7,
184 .dfi_init_start = 1,
185 .aref_en = 1,
186
187 .rd_fetch = 0x3,
188
189 .zq_mode_dds = 0x7,
190 .zq_mode_term = 0x1,
191 .zq_mode_noterm = 0,
192
193 /*
194 * Dynamic Clock: Always Running
195 * Memory Burst length: 8
196 * Number of chips: 1
197 * Memory Bus width: 32 bit
198 * Memory Type: DDR3
199 * Additional Latancy for PLL: 0 Cycle
200 */
201 .memcontrol = DMC_MEMCONTROL_CLK_STOP_DISABLE |
202 DMC_MEMCONTROL_DPWRDN_DISABLE |
203 DMC_MEMCONTROL_DPWRDN_ACTIVE_PRECHARGE |
204 DMC_MEMCONTROL_TP_DISABLE |
205 DMC_MEMCONTROL_DSREF_ENABLE |
206 DMC_MEMCONTROL_ADD_LAT_PALL_CYCLE(0) |
207 DMC_MEMCONTROL_MEM_TYPE_DDR3 |
208 DMC_MEMCONTROL_MEM_WIDTH_32BIT |
209 DMC_MEMCONTROL_NUM_CHIP_1 |
210 DMC_MEMCONTROL_BL_8 |
211 DMC_MEMCONTROL_PZQ_DISABLE |
212 DMC_MEMCONTROL_MRR_BYTE_7_0,
213 .memconfig = DMC_MEMCONFIGx_CHIP_MAP_INTERLEAVED |
214 DMC_MEMCONFIGx_CHIP_COL_10 |
215 DMC_MEMCONFIGx_CHIP_ROW_15 |
216 DMC_MEMCONFIGx_CHIP_BANK_8,
217 .membaseconfig0 = DMC_MEMBASECONFIG_VAL(0x40),
218 .membaseconfig1 = DMC_MEMBASECONFIG_VAL(0x80),
219 .prechconfig_tp_cnt = 0xff,
220 .dpwrdn_cyc = 0xff,
221 .dsref_cyc = 0xffff,
222 .concontrol = DMC_CONCONTROL_DFI_INIT_START_DISABLE |
223 DMC_CONCONTROL_TIMEOUT_LEVEL0 |
224 DMC_CONCONTROL_RD_FETCH_DISABLE |
225 DMC_CONCONTROL_EMPTY_DISABLE |
226 DMC_CONCONTROL_AREF_EN_DISABLE |
227 DMC_CONCONTROL_IO_PD_CON_DISABLE,
228 .dmc_channels = 2,
229 .chips_per_channel = 2,
230 .chips_to_configure = 1,
231 .send_zq_init = 1,
232 .impedance = IMP_OUTPUT_DRV_30_OHM,
233 .gate_leveling_enable = 0,
234 }, {
235 .mem_manuf = MEM_MANUF_SAMSUNG,
236 .mem_type = DDR_MODE_DDR3,
237 .frequency_mhz = 800,
238 .mpll_mdiv = 0xc8,
239 .mpll_pdiv = 0x3,
240 .mpll_sdiv = 0x0,
241 .cpll_mdiv = 0xde,
242 .cpll_pdiv = 0x4,
243 .cpll_sdiv = 0x2,
244 .gpll_mdiv = 0x215,
245 .gpll_pdiv = 0xc,
246 .gpll_sdiv = 0x1,
247 .epll_mdiv = 0x60,
248 .epll_pdiv = 0x3,
249 .epll_sdiv = 0x3,
250 .vpll_mdiv = 0x96,
251 .vpll_pdiv = 0x3,
252 .vpll_sdiv = 0x2,
253
254 .bpll_mdiv = 0x64,
255 .bpll_pdiv = 0x3,
256 .bpll_sdiv = 0x0,
257 .pclk_cdrex_ratio = 0x5,
258 .direct_cmd_msr = {
259 0x00020018, 0x00030000, 0x00010000, 0x00000d70
260 },
261 .timing_ref = 0x000000bb,
262 .timing_row = 0x8c36650e,
263 .timing_data = 0x3630580b,
264 .timing_power = 0x41000a44,
265 .phy0_dqs = 0x08080808,
266 .phy1_dqs = 0x08080808,
267 .phy0_dq = 0x08080808,
268 .phy1_dq = 0x08080808,
269 .phy0_tFS = 0x8,
270 .phy1_tFS = 0x8,
271 .phy0_pulld_dqs = 0xf,
272 .phy1_pulld_dqs = 0xf,
273
274 .lpddr3_ctrl_phy_reset = 0x1,
275 .ctrl_start_point = 0x10,
276 .ctrl_inc = 0x10,
277 .ctrl_start = 0x1,
278 .ctrl_dll_on = 0x1,
279 .ctrl_ref = 0x8,
280
281 .ctrl_force = 0x1a,
282 .ctrl_rdlat = 0x0b,
283 .ctrl_bstlen = 0x08,
284
285 .fp_resync = 0x8,
286 .iv_size = 0x7,
287 .dfi_init_start = 1,
288 .aref_en = 1,
289
290 .rd_fetch = 0x3,
291
292 .zq_mode_dds = 0x5,
293 .zq_mode_term = 0x1,
294 .zq_mode_noterm = 1,
295
296 /*
297 * Dynamic Clock: Always Running
298 * Memory Burst length: 8
299 * Number of chips: 1
300 * Memory Bus width: 32 bit
301 * Memory Type: DDR3
302 * Additional Latancy for PLL: 0 Cycle
303 */
304 .memcontrol = DMC_MEMCONTROL_CLK_STOP_DISABLE |
305 DMC_MEMCONTROL_DPWRDN_DISABLE |
306 DMC_MEMCONTROL_DPWRDN_ACTIVE_PRECHARGE |
307 DMC_MEMCONTROL_TP_DISABLE |
308 DMC_MEMCONTROL_DSREF_ENABLE |
309 DMC_MEMCONTROL_ADD_LAT_PALL_CYCLE(0) |
310 DMC_MEMCONTROL_MEM_TYPE_DDR3 |
311 DMC_MEMCONTROL_MEM_WIDTH_32BIT |
312 DMC_MEMCONTROL_NUM_CHIP_1 |
313 DMC_MEMCONTROL_BL_8 |
314 DMC_MEMCONTROL_PZQ_DISABLE |
315 DMC_MEMCONTROL_MRR_BYTE_7_0,
316 .memconfig = DMC_MEMCONFIGx_CHIP_MAP_INTERLEAVED |
317 DMC_MEMCONFIGx_CHIP_COL_10 |
318 DMC_MEMCONFIGx_CHIP_ROW_15 |
319 DMC_MEMCONFIGx_CHIP_BANK_8,
320 .membaseconfig0 = DMC_MEMBASECONFIG_VAL(0x40),
321 .membaseconfig1 = DMC_MEMBASECONFIG_VAL(0x80),
322 .prechconfig_tp_cnt = 0xff,
323 .dpwrdn_cyc = 0xff,
324 .dsref_cyc = 0xffff,
325 .concontrol = DMC_CONCONTROL_DFI_INIT_START_DISABLE |
326 DMC_CONCONTROL_TIMEOUT_LEVEL0 |
327 DMC_CONCONTROL_RD_FETCH_DISABLE |
328 DMC_CONCONTROL_EMPTY_DISABLE |
329 DMC_CONCONTROL_AREF_EN_DISABLE |
330 DMC_CONCONTROL_IO_PD_CON_DISABLE,
331 .dmc_channels = 2,
332 .chips_per_channel = 2,
333 .chips_to_configure = 1,
334 .send_zq_init = 1,
335 .impedance = IMP_OUTPUT_DRV_40_OHM,
336 .gate_leveling_enable = 1,
337 }
338};
339
340/**
341 * Get the required memory type and speed (SPL version).
342 *
343 * In SPL we have no device tree, so we use the machine parameters
344 *
345 * @param mem_type Returns memory type
346 * @param frequency_mhz Returns memory speed in MHz
347 * @param arm_freq Returns ARM clock speed in MHz
348 * @param mem_manuf Return Memory Manufacturer name
349 * @return 0 if all ok
350 */
351static int clock_get_mem_selection(enum ddr_mode *mem_type,
352 unsigned *frequency_mhz, unsigned *arm_freq,
353 enum mem_manuf *mem_manuf)
354{
355 struct spl_machine_param *params;
356
357 params = spl_get_machine_params();
358 *mem_type = params->mem_type;
359 *frequency_mhz = params->frequency_mhz;
360 *arm_freq = params->arm_freq_mhz;
361 *mem_manuf = params->mem_manuf;
362
363 return 0;
364}
365
366/* Get the ratios for setting ARM clock */
367struct arm_clk_ratios *get_arm_ratios(void)
368{
369 struct arm_clk_ratios *arm_ratio;
370 enum ddr_mode mem_type;
371 enum mem_manuf mem_manuf;
372 unsigned frequency_mhz, arm_freq;
373 int i;
374
375 if (clock_get_mem_selection(&mem_type, &frequency_mhz,
376 &arm_freq, &mem_manuf))
377 ;
378 for (i = 0, arm_ratio = arm_clk_ratios; i < ARRAY_SIZE(arm_clk_ratios);
379 i++, arm_ratio++) {
380 if (arm_ratio->arm_freq_mhz == arm_freq)
381 return arm_ratio;
382 }
383
384 /* will hang if failed to find clock ratio */
385 while (1)
386 ;
387
388 return NULL;
389}
390
391struct mem_timings *clock_get_mem_timings(void)
392{
393 struct mem_timings *mem;
394 enum ddr_mode mem_type;
395 enum mem_manuf mem_manuf;
396 unsigned frequency_mhz, arm_freq;
397 int i;
398
399 if (!clock_get_mem_selection(&mem_type, &frequency_mhz,
400 &arm_freq, &mem_manuf)) {
401 for (i = 0, mem = mem_timings; i < ARRAY_SIZE(mem_timings);
402 i++, mem++) {
403 if (mem->mem_type == mem_type &&
404 mem->frequency_mhz == frequency_mhz &&
405 mem->mem_manuf == mem_manuf)
406 return mem;
407 }
408 }
409
410 /* will hang if failed to find memory timings */
411 while (1)
412 ;
413
414 return NULL;
415}
416
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000417void system_clock_init()
418{
419 struct exynos5_clock *clk = (struct exynos5_clock *)EXYNOS5_CLOCK_BASE;
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000420 struct mem_timings *mem;
421 struct arm_clk_ratios *arm_clk_ratio;
422 u32 val, tmp;
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000423
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000424 mem = clock_get_mem_timings();
425 arm_clk_ratio = get_arm_ratios();
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000426
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000427 clrbits_le32(&clk->src_cpu, MUX_APLL_SEL_MASK);
428 do {
429 val = readl(&clk->mux_stat_cpu);
430 } while ((val | MUX_APLL_SEL_MASK) != val);
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000431
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000432 clrbits_le32(&clk->src_core1, MUX_MPLL_SEL_MASK);
433 do {
434 val = readl(&clk->mux_stat_core1);
435 } while ((val | MUX_MPLL_SEL_MASK) != val);
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000436
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000437 clrbits_le32(&clk->src_core1, MUX_CPLL_SEL_MASK);
438 clrbits_le32(&clk->src_core1, MUX_EPLL_SEL_MASK);
439 clrbits_le32(&clk->src_core1, MUX_VPLL_SEL_MASK);
440 clrbits_le32(&clk->src_core1, MUX_GPLL_SEL_MASK);
441 tmp = MUX_CPLL_SEL_MASK | MUX_EPLL_SEL_MASK | MUX_VPLL_SEL_MASK
442 | MUX_GPLL_SEL_MASK;
443 do {
444 val = readl(&clk->mux_stat_top2);
445 } while ((val | tmp) != val);
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000446
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000447 clrbits_le32(&clk->src_cdrex, MUX_BPLL_SEL_MASK);
448 do {
449 val = readl(&clk->mux_stat_cdrex);
450 } while ((val | MUX_BPLL_SEL_MASK) != val);
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000451
452 /* PLL locktime */
453 writel(APLL_LOCK_VAL, &clk->apll_lock);
454
455 writel(MPLL_LOCK_VAL, &clk->mpll_lock);
456
457 writel(BPLL_LOCK_VAL, &clk->bpll_lock);
458
459 writel(CPLL_LOCK_VAL, &clk->cpll_lock);
460
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000461 writel(GPLL_LOCK_VAL, &clk->gpll_lock);
462
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000463 writel(EPLL_LOCK_VAL, &clk->epll_lock);
464
465 writel(VPLL_LOCK_VAL, &clk->vpll_lock);
466
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000467 writel(CLK_REG_DISABLE, &clk->pll_div2_sel);
468
469 writel(MUX_HPM_SEL_MASK, &clk->src_cpu);
470 do {
471 val = readl(&clk->mux_stat_cpu);
472 } while ((val | HPM_SEL_SCLK_MPLL) != val);
473
474 val = arm_clk_ratio->arm2_ratio << 28
475 | arm_clk_ratio->apll_ratio << 24
476 | arm_clk_ratio->pclk_dbg_ratio << 20
477 | arm_clk_ratio->atb_ratio << 16
478 | arm_clk_ratio->periph_ratio << 12
479 | arm_clk_ratio->acp_ratio << 8
480 | arm_clk_ratio->cpud_ratio << 4
481 | arm_clk_ratio->arm_ratio;
482 writel(val, &clk->div_cpu0);
483 do {
484 val = readl(&clk->div_stat_cpu0);
485 } while (0 != val);
486
487 writel(CLK_DIV_CPU1_VAL, &clk->div_cpu1);
488 do {
489 val = readl(&clk->div_stat_cpu1);
490 } while (0 != val);
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000491
492 /* Set APLL */
493 writel(APLL_CON1_VAL, &clk->apll_con1);
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000494 val = set_pll(arm_clk_ratio->apll_mdiv, arm_clk_ratio->apll_pdiv,
495 arm_clk_ratio->apll_sdiv);
496 writel(val, &clk->apll_con0);
Akshay Saraswatdb9e5e62013-03-15 02:29:09 +0000497 while ((readl(&clk->apll_con0) & APLL_CON0_LOCKED) == 0)
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000498 ;
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000499
500 /* Set MPLL */
501 writel(MPLL_CON1_VAL, &clk->mpll_con1);
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000502 val = set_pll(mem->mpll_mdiv, mem->mpll_pdiv, mem->mpll_sdiv);
503 writel(val, &clk->mpll_con0);
Akshay Saraswatdb9e5e62013-03-15 02:29:09 +0000504 while ((readl(&clk->mpll_con0) & MPLL_CON0_LOCKED) == 0)
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000505 ;
506
507 /* Set BPLL */
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000508 writel(BPLL_CON1_VAL, &clk->bpll_con1);
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000509 val = set_pll(mem->bpll_mdiv, mem->bpll_pdiv, mem->bpll_sdiv);
510 writel(val, &clk->bpll_con0);
Akshay Saraswatdb9e5e62013-03-15 02:29:09 +0000511 while ((readl(&clk->bpll_con0) & BPLL_CON0_LOCKED) == 0)
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000512 ;
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000513
514 /* Set CPLL */
515 writel(CPLL_CON1_VAL, &clk->cpll_con1);
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000516 val = set_pll(mem->cpll_mdiv, mem->cpll_pdiv, mem->cpll_sdiv);
517 writel(val, &clk->cpll_con0);
Akshay Saraswatdb9e5e62013-03-15 02:29:09 +0000518 while ((readl(&clk->cpll_con0) & CPLL_CON0_LOCKED) == 0)
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000519 ;
520
521 /* Set GPLL */
522 writel(GPLL_CON1_VAL, &clk->gpll_con1);
523 val = set_pll(mem->gpll_mdiv, mem->gpll_pdiv, mem->gpll_sdiv);
524 writel(val, &clk->gpll_con0);
Akshay Saraswatdb9e5e62013-03-15 02:29:09 +0000525 while ((readl(&clk->gpll_con0) & GPLL_CON0_LOCKED) == 0)
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000526 ;
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000527
528 /* Set EPLL */
529 writel(EPLL_CON2_VAL, &clk->epll_con2);
530 writel(EPLL_CON1_VAL, &clk->epll_con1);
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000531 val = set_pll(mem->epll_mdiv, mem->epll_pdiv, mem->epll_sdiv);
532 writel(val, &clk->epll_con0);
Akshay Saraswatdb9e5e62013-03-15 02:29:09 +0000533 while ((readl(&clk->epll_con0) & EPLL_CON0_LOCKED) == 0)
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000534 ;
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000535
536 /* Set VPLL */
537 writel(VPLL_CON2_VAL, &clk->vpll_con2);
538 writel(VPLL_CON1_VAL, &clk->vpll_con1);
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000539 val = set_pll(mem->vpll_mdiv, mem->vpll_pdiv, mem->vpll_sdiv);
540 writel(val, &clk->vpll_con0);
Akshay Saraswatdb9e5e62013-03-15 02:29:09 +0000541 while ((readl(&clk->vpll_con0) & VPLL_CON0_LOCKED) == 0)
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000542 ;
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000543
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000544 writel(CLK_SRC_CORE0_VAL, &clk->src_core0);
545 writel(CLK_DIV_CORE0_VAL, &clk->div_core0);
546 while (readl(&clk->div_stat_core0) != 0)
547 ;
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000548
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000549 writel(CLK_DIV_CORE1_VAL, &clk->div_core1);
550 while (readl(&clk->div_stat_core1) != 0)
551 ;
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000552
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000553 writel(CLK_DIV_SYSRGT_VAL, &clk->div_sysrgt);
554 while (readl(&clk->div_stat_sysrgt) != 0)
555 ;
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000556
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000557 writel(CLK_DIV_ACP_VAL, &clk->div_acp);
558 while (readl(&clk->div_stat_acp) != 0)
559 ;
560
561 writel(CLK_DIV_SYSLFT_VAL, &clk->div_syslft);
562 while (readl(&clk->div_stat_syslft) != 0)
563 ;
564
565 writel(CLK_SRC_TOP0_VAL, &clk->src_top0);
566 writel(CLK_SRC_TOP1_VAL, &clk->src_top1);
567 writel(TOP2_VAL, &clk->src_top2);
568 writel(CLK_SRC_TOP3_VAL, &clk->src_top3);
569
570 writel(CLK_DIV_TOP0_VAL, &clk->div_top0);
571 while (readl(&clk->div_stat_top0))
572 ;
573
574 writel(CLK_DIV_TOP1_VAL, &clk->div_top1);
575 while (readl(&clk->div_stat_top1))
576 ;
577
578 writel(CLK_SRC_LEX_VAL, &clk->src_lex);
579 while (1) {
580 val = readl(&clk->mux_stat_lex);
581 if (val == (val | 1))
582 break;
583 }
584
585 writel(CLK_DIV_LEX_VAL, &clk->div_lex);
586 while (readl(&clk->div_stat_lex))
587 ;
588
589 writel(CLK_DIV_R0X_VAL, &clk->div_r0x);
590 while (readl(&clk->div_stat_r0x))
591 ;
592
593 writel(CLK_DIV_R0X_VAL, &clk->div_r0x);
594 while (readl(&clk->div_stat_r0x))
595 ;
596
597 writel(CLK_DIV_R1X_VAL, &clk->div_r1x);
598 while (readl(&clk->div_stat_r1x))
599 ;
600
601 writel(CLK_REG_DISABLE, &clk->src_cdrex);
602
603 writel(CLK_DIV_CDREX_VAL, &clk->div_cdrex);
604 while (readl(&clk->div_stat_cdrex))
605 ;
606
607 val = readl(&clk->src_cpu);
608 val |= CLK_SRC_CPU_VAL;
609 writel(val, &clk->src_cpu);
610
611 val = readl(&clk->src_top2);
612 val |= CLK_SRC_TOP2_VAL;
613 writel(val, &clk->src_top2);
614
615 val = readl(&clk->src_core1);
616 val |= CLK_SRC_CORE1_VAL;
617 writel(val, &clk->src_core1);
618
619 writel(CLK_SRC_FSYS0_VAL, &clk->src_fsys);
620 writel(CLK_DIV_FSYS0_VAL, &clk->div_fsys0);
621 while (readl(&clk->div_stat_fsys0))
622 ;
623
624 writel(CLK_REG_DISABLE, &clk->clkout_cmu_cpu);
625 writel(CLK_REG_DISABLE, &clk->clkout_cmu_core);
626 writel(CLK_REG_DISABLE, &clk->clkout_cmu_acp);
627 writel(CLK_REG_DISABLE, &clk->clkout_cmu_top);
628 writel(CLK_REG_DISABLE, &clk->clkout_cmu_lex);
629 writel(CLK_REG_DISABLE, &clk->clkout_cmu_r0x);
630 writel(CLK_REG_DISABLE, &clk->clkout_cmu_r1x);
631 writel(CLK_REG_DISABLE, &clk->clkout_cmu_cdrex);
632
633 writel(CLK_SRC_PERIC0_VAL, &clk->src_peric0);
634 writel(CLK_DIV_PERIC0_VAL, &clk->div_peric0);
635
636 writel(CLK_SRC_PERIC1_VAL, &clk->src_peric1);
637 writel(CLK_DIV_PERIC1_VAL, &clk->div_peric1);
638 writel(CLK_DIV_PERIC2_VAL, &clk->div_peric2);
639 writel(CLK_DIV_PERIC3_VAL, &clk->div_peric3);
640
641 writel(SCLK_SRC_ISP_VAL, &clk->sclk_src_isp);
642 writel(SCLK_DIV_ISP_VAL, &clk->sclk_div_isp);
643 writel(CLK_DIV_ISP0_VAL, &clk->div_isp0);
644 writel(CLK_DIV_ISP1_VAL, &clk->div_isp1);
645 writel(CLK_DIV_ISP2_VAL, &clk->div_isp2);
646
647 /* FIMD1 SRC CLK SELECTION */
648 writel(CLK_SRC_DISP1_0_VAL, &clk->src_disp1_0);
649
650 val = MMC2_PRE_RATIO_VAL << MMC2_PRE_RATIO_OFFSET
651 | MMC2_RATIO_VAL << MMC2_RATIO_OFFSET
652 | MMC3_PRE_RATIO_VAL << MMC3_PRE_RATIO_OFFSET
653 | MMC3_RATIO_VAL << MMC3_RATIO_OFFSET;
654 writel(val, &clk->div_fsys2);
655}
656
657void clock_init_dp_clock(void)
658{
659 struct exynos5_clock *clk = (struct exynos5_clock *)EXYNOS5_CLOCK_BASE;
660
661 /* DP clock enable */
662 setbits_le32(&clk->gate_ip_disp1, CLK_GATE_DP1_ALLOW);
663
664 /* We run DP at 267 Mhz */
665 setbits_le32(&clk->div_disp1_0, CLK_DIV_DISP1_0_FIMD1);
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000666}