summaryrefslogtreecommitdiff
path: root/src/soc/samsung/exynos5420/clk.h
blob: 6b7f472c1e4683f54a0ee1c3d0252a123d2efca3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
/*
 * This file is part of the coreboot project.
 *
 * Copyright 2013 Google Inc.
 * Copyright (C) 2012 Samsung Electronics
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; version 2 of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 */

#ifndef CPU_SAMSUNG_EXYNOS5420_CLK_H
#define CPU_SAMSUNG_EXYNOS5420_CLK_H

#include <stdint.h>

#include "cpu.h"

enum periph_id;

/* This master list of PLLs is ordered arbitrarily. */
#define APLL	0
#define MPLL	1
#define EPLL	2
#define HPLL	3
#define VPLL	4
#define BPLL	5
#define RPLL	6
#define SPLL	7
#define CPLL	8
#define DPLL	9
#define IPLL	10

unsigned long get_pll_clk(int pllreg);
unsigned long get_arm_clk(void);
unsigned long get_pwm_clk(void);
unsigned long get_uart_clk(int dev_index);
void set_mmc_clk(int dev_index, unsigned int div);

/**
 * get the clk frequency of the required peripherial
 *
 * @param peripherial	Peripherial id
 *
 * @return frequency of the peripherial clk
 */
unsigned long clock_get_periph_rate(enum periph_id peripheral);

#include "pinmux.h"


#define MCT_HZ 24000000

/*
 * Set mshci controller instances clock drivder
 *
 * @param enum periph_id instance of the mshci controller
 *
 * Return	0 if ok else -1
 */
int clock_set_mshci(enum periph_id peripheral);

/*
 * Set dwmci controller instances clock drivder
 *
 * @param enum periph_id instance of the dwmci controller
 *
 * Return	0 if ok else -1
 */
int clock_set_dwmci(enum periph_id peripheral);

/*
 * Sets the epll clockrate
 *
 * @param rate	Required clock rate to the presacaler in Hz
 *
 * Return	0 if ok else -1
 */
int clock_epll_set_rate(unsigned long rate);

/*
 * selects the clk source for I2S MCLK
 */
void clock_select_i2s_clk_source(void);

/*
 * Set prescaler division based on input and output frequency
 * for i2s audio clock
 *
 * @param src_frq	Source frequency in Hz
 * @param dst_frq	Required MCLK frequency in Hz
 *
 * Return	0 if ok else -1
 */
int clock_set_i2s_clk_prescaler(unsigned int src_frq, unsigned int dst_frq);

struct exynos5420_clock {
	uint32_t	apll_lock;		/* 0x10010000 */
	uint8_t		res1[0xfc];
	uint32_t	apll_con0;
	uint32_t	apll_con1;
	uint8_t		res2[0xf8];
	uint32_t	clk_src_cpu;
	uint8_t		res3[0x1fc];
	uint32_t	clk_mux_stat_cpu;
	uint8_t		res4[0xfc];
	uint32_t	clk_div_cpu0;		/* 0x10010500 */
	uint32_t	clk_div_cpu1;
	uint8_t		res5[0xf8];
	uint32_t	clk_div_stat_cpu0;
	uint32_t	clk_div_stat_cpu1;
	uint8_t		res6[0xf8];
	uint32_t	clk_gate_bus_cpu;
	uint8_t		res7[0xfc];
	uint32_t	clk_gate_sclk_cpu;
	uint8_t		res8[0x1fc];
	uint32_t	clkout_cmu_cpu;		/* 0x10010a00 */
	uint32_t	clkout_cmu_cpu_div_stat;
	uint8_t		res9[0x5f8];
	uint32_t	armclk_stopctrl;
	uint8_t		res10[0x4];
	uint32_t	arm_ema_ctrl;
	uint32_t	arm_ema_status;
	uint8_t		res11[0x10];
	uint32_t	pwr_ctrl;
	uint32_t	pwr_ctrl2;
	uint8_t		res12[0xd8];
	uint32_t	apll_con0_l8;		/* 0x1001100 */
	uint32_t	apll_con0_l7;
	uint32_t	apll_con0_l6;
	uint32_t	apll_con0_l5;
	uint32_t	apll_con0_l4;
	uint32_t	apll_con0_l3;
	uint32_t	apll_con0_l2;
	uint32_t	apll_con0_l1;
	uint32_t	iem_control;
	uint8_t		res13[0xdc];
	uint32_t	apll_con1_l8;		/* 0x10011200 */
	uint32_t	apll_con1_l7;
	uint32_t	apll_con1_l6;
	uint32_t	apll_con1_l5;
	uint32_t	apll_con1_l4;
	uint32_t	apll_con1_l3;
	uint32_t	apll_con1_l2;
	uint32_t	apll_con1_l1;
	uint8_t		res14[0xe0];
	uint32_t	clkdiv_iem_l8;
	uint32_t	clkdiv_iem_l7;		/* 0x10011304 */
	uint32_t	clkdiv_iem_l6;
	uint32_t	clkdiv_iem_l5;
	uint32_t	clkdiv_iem_l4;
	uint32_t	clkdiv_iem_l3;
	uint32_t	clkdiv_iem_l2;
	uint32_t	clkdiv_iem_l1;
	uint8_t		res15[0xe0];
	uint32_t	l2_status;
	uint8_t		res16[0x0c];
	uint32_t	cpu_status;		/* 0x10011410 */
	uint8_t		res17[0x0c];
	uint32_t	ptm_status;
	uint8_t		res18[0xbdc];
	uint32_t	cmu_cpu_spare0;
	uint32_t	cmu_cpu_spare1;
	uint32_t	cmu_cpu_spare2;
	uint32_t	cmu_cpu_spare3;
	uint32_t	cmu_cpu_spare4;
	uint8_t		res19[0x1fdc];
	uint32_t	cmu_cpu_version;
	uint8_t		res20[0x20c];
	uint32_t	clk_src_cperi0;		/* 0x10014200 */
	uint32_t	clk_src_cperi1;
	uint8_t		res21[0xf8];
	uint32_t	clk_src_mask_cperi;
	uint8_t		res22[0x100];
	uint32_t	clk_mux_stat_cperi1;
	uint8_t		res23[0xfc];
	uint32_t	clk_div_cperi1;
	uint8_t		res24[0xfc];
	uint32_t	clk_div_stat_cperi1;
	uint8_t		res25[0xf8];
	uint32_t	clk_gate_bus_cperi0;	/* 0x10014700 */
	uint32_t	clk_gate_bus_cperi1;
	uint8_t		res26[0xf8];
	uint32_t	clk_gate_sclk_cperi;
	uint8_t		res27[0xfc];
	uint32_t	clk_gate_ip_cperi;
	uint8_t		res28[0xfc];
	uint32_t	clkout_cmu_cperi;
	uint32_t	clkout_cmu_cperi_div_stat;
	uint8_t		res29[0x5f8];
	uint32_t	dcgidx_map0;		/* 0x10015000 */
	uint32_t	dcgidx_map1;
	uint32_t	dcgidx_map2;
	uint8_t		res30[0x14];
	uint32_t	dcgperf_map0;
	uint32_t	dcgperf_map1;
	uint8_t		res31[0x18];
	uint32_t	dvcidx_map;
	uint8_t		res32[0x1c];
	uint32_t	freq_cpu;
	uint32_t	freq_dpm;
	uint8_t		res33[0x18];
	uint32_t	dvsemclk_en;		/* 0x10015080 */
	uint32_t	maxperf;
	uint8_t		res34[0x2e78];
	uint32_t	cmu_cperi_spare0;
	uint32_t	cmu_cperi_spare1;
	uint32_t	cmu_cperi_spare2;
	uint32_t	cmu_cperi_spare3;
	uint32_t	cmu_cperi_spare4;
	uint32_t	cmu_cperi_spare5;
	uint32_t	cmu_cperi_spare6;
	uint32_t	cmu_cperi_spare7;
	uint32_t	cmu_cperi_spare8;
	uint8_t		res35[0xcc];
	uint32_t	cmu_cperi_version;	/* 0x10017ff0 */
	uint8_t		res36[0x50c];
	uint32_t	clk_div_g2d;
	uint8_t		res37[0xfc];
	uint32_t	clk_div_stat_g2d;
	uint8_t		res38[0xfc];
	uint32_t	clk_gate_bus_g2d;
	uint8_t		res39[0xfc];
	uint32_t	clk_gate_ip_g2d;
	uint8_t		res40[0x1fc];
	uint32_t	clkout_cmu_g2d;
	uint32_t	clkout_cmu_g2d_div_stat;/* 0x10018a04 */
	uint8_t		res41[0xf8];
	uint32_t	cmu_g2d_spare0;
	uint32_t	cmu_g2d_spare1;
	uint32_t	cmu_g2d_spare2;
	uint32_t	cmu_g2d_spare3;
	uint32_t	cmu_g2d_spare4;
	uint8_t		res42[0x34dc];
	uint32_t	cmu_g2d_version;
	uint8_t		res43[0x30c];
	uint32_t	clk_div_cmu_isp0;
	uint32_t	clk_div_cmu_isp1;
	uint32_t	clk_div_isp2;		/* 0x1001c308 */
	uint8_t		res44[0xf4];
	uint32_t	clk_div_stat_cmu_isp0;
	uint32_t	clk_div_stat_cmu_isp1;
	uint32_t	clk_div_stat_isp2;
	uint8_t		res45[0x2f4];
	uint32_t	clk_gate_bus_isp0;
	uint32_t	clk_gate_bus_isp1;
	uint32_t	clk_gate_bus_isp2;
	uint32_t	clk_gate_bus_isp3;
	uint8_t		res46[0xf0];
	uint32_t	clk_gate_ip_isp0;
	uint32_t	clk_gate_ip_isp1;
	uint8_t		res47[0xf8];
	uint32_t	clk_gate_sclk_isp;
	uint8_t		res48[0x0c];
	uint32_t	mcuisp_pwr_ctrl;	/* 0x1001c910 */
	uint8_t		res49[0x0ec];
	uint32_t	clkout_cmu_isp;
	uint32_t	clkout_cmu_isp_div_stat;
	uint8_t		res50[0xf8];
	uint32_t	cmu_isp_spare0;
	uint32_t	cmu_isp_spare1;
	uint32_t	cmu_isp_spare2;
	uint32_t	cmu_isp_spare3;
	uint8_t		res51[0x34e0];
	uint32_t	cmu_isp_version;
	uint8_t		res52[0x2c];
	uint32_t	cpll_lock;		/* 10020020 */
	uint8_t		res53[0xc];
	uint32_t	dpll_lock;
	uint8_t		res54[0xc];
	uint32_t	epll_lock;
	uint8_t		res55[0xc];
	uint32_t	rpll_lock;
	uint8_t		res56[0xc];
	uint32_t	ipll_lock;
	uint8_t		res57[0xc];
	uint32_t	spll_lock;
	uint8_t		res58[0xc];
	uint32_t	vpll_lock;
	uint8_t		res59[0xc];
	uint32_t	mpll_lock;
	uint8_t		res60[0x8c];
	uint32_t	cpll_con0;		/* 10020120 */
	uint32_t	cpll_con1;
	uint32_t	dpll_con0;
	uint32_t	dpll_con1;
	uint32_t	epll_con0;
	uint32_t	epll_con1;
	uint32_t	epll_con2;
	uint8_t		res601[0x4];
	uint32_t	rpll_con0;
	uint32_t	rpll_con1;
	uint32_t	rpll_con2;
	uint8_t		res602[0x4];
	uint32_t	ipll_con0;
	uint32_t	ipll_con1;
	uint8_t		res61[0x8];
	uint32_t	spll_con0;
	uint32_t	spll_con1;
	uint8_t		res62[0x8];
	uint32_t	vpll_con0;
	uint32_t	vpll_con1;
	uint8_t		res63[0x8];
	uint32_t	mpll_con0;
	uint32_t	mpll_con1;
	uint8_t		res64[0x78];
	uint32_t	clk_src_top0;		/* 0x10020200 */
	uint32_t	clk_src_top1;
	uint32_t	clk_src_top2;
	uint32_t	clk_src_top3;
	uint32_t	clk_src_top4;
	uint32_t	clk_src_top5;
	uint32_t	clk_src_top6;
	uint32_t	clk_src_top7;
	uint8_t		res65[0xc];
	uint32_t	clk_src_disp10;		/* 0x1002022c */
	uint8_t		res66[0x10];
	uint32_t	clk_src_mau;
	uint32_t	clk_src_fsys;
	uint8_t		res67[0x8];
	uint32_t	clk_src_peric0;
	uint32_t	clk_src_peric1;
	uint8_t		res68[0x18];
	uint32_t	clk_src_isp;
	uint8_t		res69[0x0c];
	uint32_t	clk_src_top10;
	uint32_t	clk_src_top11;
	uint32_t	clk_src_top12;
	uint8_t		res70[0x74];
	uint32_t	clk_src_mask_top0;
	uint32_t	clk_src_mask_top1;
	uint32_t	clk_src_mask_top2;
	uint8_t		res71[0x10];
	uint32_t	clk_src_mask_top7;
	uint8_t		res72[0xc];
	uint32_t	clk_src_mask_disp10;	/* 0x1002032c */
	uint8_t		res73[0x4];
	uint32_t	clk_src_mask_mau;
	uint8_t		res74[0x8];
	uint32_t	clk_src_mask_fsys;
	uint8_t		res75[0xc];
	uint32_t	clk_src_mask_peric0;
	uint32_t	clk_src_mask_peric1;
	uint8_t		res76[0x18];
	uint32_t	clk_src_mask_isp;
	uint8_t		res77[0x8c];
	uint32_t	clk_mux_stat_top0;	/* 0x10020400 */
	uint32_t	clk_mux_stat_top1;
	uint32_t	clk_mux_stat_top2;
	uint32_t	clk_mux_stat_top3;
	uint32_t	clk_mux_stat_top4;
	uint32_t	clk_mux_stat_top5;
	uint32_t	clk_mux_stat_top6;
	uint32_t	clk_mux_stat_top7;
	uint8_t		res78[0x60];
	uint32_t	clk_mux_stat_top10;
	uint32_t	clk_mux_stat_top11;
	uint32_t	clk_mux_stat_top12;
	uint8_t		res79[0x74];
	uint32_t	clk_div_top0;		/* 0x10020500 */
	uint32_t	clk_div_top1;
	uint32_t	clk_div_top2;
	uint8_t		res80[0x20];
	uint32_t	clk_div_disp10;
	uint8_t		res81[0x14];
	uint32_t	clk_div_mau;
	uint32_t	clk_div_fsys0;
	uint32_t	clk_div_fsys1;
	uint32_t	clk_div_fsys2;
	uint8_t		res82[0x4];
	uint32_t	clk_div_peric0;
	uint32_t	clk_div_peric1;
	uint32_t	clk_div_peric2;
	uint32_t	clk_div_peric3;
	uint32_t	clk_div_peric4;		/* 0x10020568 */
	uint8_t		res83[0x14];
	uint32_t	clk_div_isp0;
	uint32_t	clk_div_isp1;
	uint8_t		res84[0x8];
	uint32_t	clkdiv2_ratio;
	uint8_t		res850[0xc];
	uint32_t	clkdiv4_ratio;
	uint8_t		res85[0x5c];
	uint32_t	clk_div_stat_top0;
	uint32_t	clk_div_stat_top1;
	uint32_t	clk_div_stat_top2;
	uint8_t		res86[0x20];
	uint32_t	clk_div_stat_disp10;
	uint8_t		res87[0x14];
	uint32_t	clk_div_stat_mau;	/* 0x10020644 */
	uint32_t	clk_div_stat_fsys0;
	uint32_t	clk_div_stat_fsys1;
	uint32_t	clk_div_stat_fsys2;
	uint8_t		res88[0x4];
	uint32_t	clk_div_stat_peric0;
	uint32_t	clk_div_stat_peric1;
	uint32_t	clk_div_stat_peric2;
	uint32_t	clk_div_stat_peric3;
	uint32_t	clk_div_stat_peric4;
	uint8_t		res89[0x14];
	uint32_t	clk_div_stat_isp0;
	uint32_t	clk_div_stat_isp1;
	uint8_t		res90[0x8];
	uint32_t	clkdiv2_stat0;
	uint8_t		res91[0xc];
	uint32_t	clkdiv4_stat;
	uint8_t		res92[0x5c];
	uint32_t	clk_gate_bus_top;	/* 0x10020700 */
	uint8_t		res93[0xc];
	uint32_t	clk_gate_bus_gscl0;
	uint8_t		res94[0xc];
	uint32_t	clk_gate_bus_gscl1;
	uint8_t		res95[0x4];
	uint32_t	clk_gate_bus_disp1;
	uint8_t		res96[0x4];
	uint32_t	clk_gate_bus_wcore;
	uint32_t	clk_gate_bus_mfc;
	uint32_t	clk_gate_bus_g3d;
	uint32_t	clk_gate_bus_gen;
	uint32_t	clk_gate_bus_fsys0;
	uint32_t	clk_gate_bus_fsys1;
	uint32_t	clk_gate_bus_fsys2;
	uint32_t	clk_gate_bus_mscl;
	uint32_t	clk_gate_bus_peric;
	uint32_t	clk_gate_bus_peric1;
	uint8_t		res97[0x8];
	uint32_t	clk_gate_bus_peris0;
	uint32_t	clk_gate_bus_peris1;	/* 0x10020764 */
	uint8_t		res98[0x8];
	uint32_t	clk_gate_bus_noc;
	uint8_t		res99[0xac];
	uint32_t	clk_gate_top_sclk_gscl;
	uint8_t		res1000[0x4];
	uint32_t	clk_gate_top_sclk_disp1;
	uint8_t		res100[0x10];
	uint32_t	clk_gate_top_sclk_mau;
	uint32_t	clk_gate_top_sclk_fsys;
	uint8_t		res101[0xc];
	uint32_t	clk_gate_top_sclk_peric;
	uint8_t		res102[0xc];
	uint32_t	clk_gate_top_sclk_cperi;
	uint8_t		res103[0xc];
	uint32_t	clk_gate_top_sclk_isp;
	uint8_t		res104[0x9c];
	uint32_t	clk_gate_ip_gscl0;
	uint8_t		res105[0xc];
	uint32_t	clk_gate_ip_gscl1;
	uint8_t		res106[0x4];
	uint32_t	clk_gate_ip_disp1;
	uint32_t	clk_gate_ip_mfc;
	uint32_t	clk_gate_ip_g3d;
	uint32_t	clk_gate_ip_gen;	/* 0x10020934 */
	uint8_t		res107[0xc];
	uint32_t	clk_gate_ip_fsys;
	uint8_t		res108[0x8];
	uint32_t	clk_gate_ip_peric;
	uint8_t		res109[0xc];
	uint32_t	clk_gate_ip_peris;
	uint8_t		res110[0xc];
	uint32_t	clk_gate_ip_mscl;
	uint8_t		res111[0xc];
	uint32_t	clk_gate_ip_block;
	uint8_t		res112[0xc];
	uint32_t	bypass;
	uint8_t		res113[0x6c];
	uint32_t	clkout_cmu_top;
	uint32_t	clkout_cmu_top_div_stat;
	uint8_t		res114[0xf8];
	uint32_t	clkout_top_spare0;
	uint32_t	clkout_top_spare1;
	uint32_t	clkout_top_spare2;
	uint32_t	clkout_top_spare3;
	uint8_t		res115[0x34e0];
	uint32_t	clkout_top_version;
	uint8_t		res116[0xc01c];
	uint32_t	bpll_lock;		/* 0x10030010 */
	uint8_t		res117[0xfc];
	uint32_t	bpll_con0;
	uint32_t	bpll_con1;
	uint8_t		res118[0xe8];
	uint32_t	clk_src_cdrex;
	uint8_t		res119[0x1fc];
	uint32_t	clk_mux_stat_cdrex;
	uint8_t		res120[0xfc];
	uint32_t	clk_div_cdrex0;
	uint32_t	clk_div_cdrex1;
	uint8_t		res121[0xf8];
	uint32_t	clk_div_stat_cdrex;
	uint8_t		res1211[0xfc];
	uint32_t	clk_gate_bus_cdrex;
	uint32_t	clk_gate_bus_cdrex1;
	uint8_t		res122[0x1f8];
	uint32_t	clk_gate_ip_cdrex;
	uint8_t		res123[0x10];
	uint32_t	dmc_freq_ctrl;		/* 0x10030914 */
	uint8_t		res124[0x4];
	uint32_t	pause;
	uint32_t	ddrphy_lock_ctrl;
	uint8_t		res125[0xdc];
	uint32_t	clkout_cmu_cdrex;
	uint32_t	clkout_cmu_cdrex_div_stat;
	uint8_t		res126[0x8];
	uint32_t	lpddr3phy_ctrl;
	uint32_t	lpddr3phy_con0;
	uint32_t	lpddr3phy_con1;
	uint32_t	lpddr3phy_con2;
	uint32_t	lpddr3phy_con3;
	uint32_t	lpddr3phy_con4;
	uint32_t	lpddr3phy_con5;		/* 0x10030a28 */
	uint32_t	pll_div2_sel;
	uint8_t		res127[0xd0];
	uint32_t	cmu_cdrex_spare0;
	uint32_t	cmu_cdrex_spare1;
	uint32_t	cmu_cdrex_spare2;
	uint32_t	cmu_cdrex_spare3;
	uint32_t	cmu_cdrex_spare4;
	uint8_t		res128[0x34dc];
	uint32_t	cmu_cdrex_version;	/* 0x10033ff0 */
	uint8_t		res129[0x400c];
	uint32_t	kpll_lock;
	uint8_t		res130[0xfc];
	uint32_t	kpll_con0;
	uint32_t	kpll_con1;
	uint8_t		res131[0xf8];
	uint32_t	clk_src_kfc;
	uint8_t		res132[0x1fc];
	uint32_t	clk_mux_stat_kfc;	/* 0x10038400 */
	uint8_t		res133[0xfc];
	uint32_t	clk_div_kfc0;
	uint8_t		res134[0xfc];
	uint32_t	clk_div_stat_kfc0;
	uint8_t		res135[0xfc];
	uint32_t	clk_gate_bus_cpu_kfc;
	uint8_t		res136[0xfc];
	uint32_t	clk_gate_sclk_cpu_kfc;
	uint8_t		res137[0x1fc];
	uint32_t	clkout_cmu_kfc;
	uint32_t	clkout_cmu_kfc_div_stat;/* 0x10038a04 */
	uint8_t		res138[0x5f8];
	uint32_t	armclk_stopctrl_kfc;
	uint8_t		res139[0x4];
	uint32_t	armclk_ema_ctrl_kfc;
	uint32_t	armclk_ema_status_kfc;
	uint8_t		res140[0x10];
	uint32_t	pwr_ctrl_kfc;
	uint32_t	pwr_ctrl2_kfc;
	uint8_t		res141[0xd8];
	uint32_t	kpll_con0_l8;
	uint32_t	kpll_con0_l7;
	uint32_t	kpll_con0_l6;
	uint32_t	kpll_con0_l5;
	uint32_t	kpll_con0_l4;
	uint32_t	kpll_con0_l3;
	uint32_t	kpll_con0_l2;
	uint32_t	kpll_con0_l1;
	uint32_t	iem_control_kfc;	/* 0x10039120 */
	uint8_t		res142[0xdc];
	uint32_t	kpll_con1_l8;
	uint32_t	kpll_con1_l7;
	uint32_t	kpll_con1_l6;
	uint32_t	kpll_con1_l5;
	uint32_t	kpll_con1_l4;
	uint32_t	kpll_con1_l3;
	uint32_t	kpll_con1_l2;
	uint32_t	kpll_con1_l1;
	uint8_t		res143[0xe0];
	uint32_t	clkdiv_iem_l8_kfc;	/* 0x10039300 */
	uint32_t	clkdiv_iem_l7_kfc;
	uint32_t	clkdiv_iem_l6_kfc;
	uint32_t	clkdiv_iem_l5_kfc;
	uint32_t	clkdiv_iem_l4_kfc;
	uint32_t	clkdiv_iem_l3_kfc;
	uint32_t	clkdiv_iem_l2_kfc;
	uint32_t	clkdiv_iem_l1_kfc;
	uint8_t		res144[0xe0];
	uint32_t	l2_status_kfc;
	uint8_t		res145[0xc];
	uint32_t	cpu_status_kfc;		/* 0x10039410 */
	uint8_t		res146[0xc];
	uint32_t	ptm_status_kfc;
	uint8_t		res147[0xbdc];
	uint32_t	cmu_kfc_spare0;
	uint32_t	cmu_kfc_spare1;
	uint32_t	cmu_kfc_spare2;
	uint32_t	cmu_kfc_spare3;
	uint32_t	cmu_kfc_spare4;
	uint8_t		res148[0x1fdc];
	uint32_t	cmu_kfc_version;	/* 0x1003bff0 */
};
check_member(exynos5420_clock, cmu_kfc_version, 0x2bff0);

static struct exynos5420_clock * const exynos_clock =
		(void *)EXYNOS5_CLOCK_BASE;

struct exynos5_mct {
	uint32_t	mct_cfg;
	uint8_t		reserved0[0xfc];
	uint32_t	g_cnt_l;
	uint32_t	g_cnt_u;
	uint8_t		reserved1[0x8];
	uint32_t	g_cnt_wstat;
	uint8_t		reserved2[0xec];
	uint32_t	g_comp0_l;
	uint32_t	g_comp0_u;
	uint32_t	g_comp0_addr_incr;
	uint8_t		reserved3[0x4];
	uint32_t	g_comp1_l;
	uint32_t	g_comp1_u;
	uint32_t	g_comp1_addr_incr;
	uint8_t		reserved4[0x4];
	uint32_t	g_comp2_l;
	uint32_t	g_comp2_u;
	uint32_t	g_comp2_addr_incr;
	uint8_t		reserved5[0x4];
	uint32_t	g_comp3_l;
	uint32_t	g_comp3_u;
	uint32_t	g_comp3_addr_incr;
	uint8_t		reserved6[0x4];
	uint32_t	g_tcon;
	uint32_t	g_int_cstat;
	uint32_t	g_int_enb;
	uint32_t	g_wstat;
	uint8_t		reserved7[0xb0];
	uint32_t	l0_tcntb;
	uint32_t	l0_tcnto;
	uint32_t	l0_icntb;
	uint32_t	l0_icnto;
	uint32_t	l0_frcntb;
	uint32_t	l0_frcnto;
	uint8_t		reserved8[0x8];
	uint32_t	l0_tcon;
	uint8_t		reserved9[0xc];
	uint32_t	l0_int_cstat;
	uint32_t	l0_int_enb;
	uint8_t		reserved10[0x8];
	uint32_t	l0_wstat;
	uint8_t		reserved11[0xbc];
	uint32_t	l1_tcntb;
	uint32_t	l1_tcnto;
	uint32_t	l1_icntb;
	uint32_t	l1_icnto;
	uint32_t	l1_frcntb;
	uint32_t	l1_frcnto;
	uint8_t		reserved12[0x8];
	uint32_t	l1_tcon;
	uint8_t		reserved13[0xc];
	uint32_t	l1_int_cstat;
	uint32_t	l1_int_enb;
	uint8_t		reserved14[0x8];
	uint32_t	l1_wstat;
};
check_member(exynos5_mct, l1_wstat, 0x440);

static struct exynos5_mct * const exynos_mct =
		(void *)EXYNOS5_MULTI_CORE_TIMER_BASE;

#define EXYNOS5_EPLLCON0_LOCKED_SHIFT	29  /* EPLL Locked bit position*/
#define EPLL_SRC_CLOCK			24000000  /*24 MHz Cristal Input */
#define TIMEOUT_EPLL_LOCK		1000

#define AUDIO_0_RATIO_MASK		0x0f
#define AUDIO_1_RATIO_MASK		0x0f

#define CLK_SRC_PERIC1			0x254
#define AUDIO1_SEL_MASK			0xf
#define CLK_SRC_AUDIOCDCLK1		0x0
#define CLK_SRC_XXTI			0x1
#define CLK_SRC_SCLK_EPLL		0x7

/* CON0 bit-fields */
#define EPLL_CON0_MDIV_MASK		0x1ff
#define EPLL_CON0_PDIV_MASK		0x3f
#define EPLL_CON0_SDIV_MASK		0x7
#define EPLL_CON0_LOCKED_SHIFT		29
#define EPLL_CON0_MDIV_SHIFT		16
#define EPLL_CON0_PDIV_SHIFT		8
#define EPLL_CON0_SDIV_SHIFT		0
#define EPLL_CON0_LOCK_DET_EN_SHIFT	28
#define EPLL_CON0_LOCK_DET_EN_MASK	1

/* structure for epll configuration used in audio clock configuration */
struct st_epll_con_val {
	unsigned int freq_out;		/* frequency out */
	unsigned int en_lock_det;	/* enable lock detect */
	unsigned int m_div;		/* m divider value */
	unsigned int p_div;		/* p divider value */
	unsigned int s_div;		/* s divider value */
	unsigned int k_dsm;		/* k value of delta signal modulator */
};

/**
 * Low-level function to set the clock pre-ratio for a peripheral
 *
 * @param periph_id	Peripheral ID of peripheral to change
 * @param divisor	New divisor for this peripheral's clock
 */
void clock_ll_set_pre_ratio(enum periph_id periph_id, unsigned divisor);

/**
 * Low-level function to set the clock ratio for a peripheral
 *
 * @param periph_id	Peripheral ID of peripheral to change
 * @param divisor	New divisor for this peripheral's clock
 */
void clock_ll_set_ratio(enum periph_id periph_id, unsigned divisor);

/**
 * Low-level function that selects the best clock scalars for a given rate and
 * sets up the given peripheral's clock accordingly.
 *
 * @param periph_id	Peripheral ID of peripheral to change
 * @param rate		Desired clock rate in Hz
 *
 * @return zero on success, negative on error
 */
int clock_set_rate(enum periph_id periph_id, unsigned int rate);

/* Clock gate unused IP */
void clock_gate(void);

void mct_start(void);
uint64_t mct_raw_value(void);

#include "dmc.h"

/* These are the ratio's for configuring ARM clock */
struct arm_clk_ratios {
	unsigned int arm_freq_mhz;	/* Frequency of ARM core in MHz */

	unsigned int apll_mdiv;
	unsigned int apll_pdiv;
	unsigned int apll_sdiv;

	unsigned int arm2_ratio;
	unsigned int apll_ratio;
	unsigned int pclk_dbg_ratio;
	unsigned int atb_ratio;
	unsigned int periph_ratio;
	unsigned int acp_ratio;
	unsigned int cpud_ratio;
	unsigned int arm_ratio;
};

/**
 * Get the clock ratios for CPU configuration
 *
 * @return pointer to the clock ratios that we should use
 */
struct arm_clk_ratios *get_arm_clk_ratios(void);

/*
 * Initialize clock for the device
 */
struct mem_timings;
void system_clock_init(void);

#endif