xref: /rk3399_rockchip-uboot/arch/arm/mach-exynos/clock_init_exynos4.c (revision 783983f323730540f861413dfbea6802c88afcf8)
1*77b55e8cSThomas Abraham /*
2*77b55e8cSThomas Abraham  * Clock Initialization for board based on EXYNOS4210
3*77b55e8cSThomas Abraham  *
4*77b55e8cSThomas Abraham  * Copyright (C) 2013 Samsung Electronics
5*77b55e8cSThomas Abraham  * Rajeshwari Shinde <rajeshwari.s@samsung.com>
6*77b55e8cSThomas Abraham  *
7*77b55e8cSThomas Abraham  * See file CREDITS for list of people who contributed to this
8*77b55e8cSThomas Abraham  * project.
9*77b55e8cSThomas Abraham  *
10*77b55e8cSThomas Abraham  * This program is free software; you can redistribute it and/or
11*77b55e8cSThomas Abraham  * modify it under the terms of the GNU General Public License as
12*77b55e8cSThomas Abraham  * published by the Free Software Foundation; either version 2 of
13*77b55e8cSThomas Abraham  * the License, or (at your option) any later version.
14*77b55e8cSThomas Abraham  *
15*77b55e8cSThomas Abraham  * This program is distributed in the hope that it will be useful,
16*77b55e8cSThomas Abraham  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*77b55e8cSThomas Abraham  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*77b55e8cSThomas Abraham  * GNU General Public License for more details.
19*77b55e8cSThomas Abraham  *
20*77b55e8cSThomas Abraham  * You should have received a copy of the GNU General Public License
21*77b55e8cSThomas Abraham  * along with this program; if not, write to the Free Software
22*77b55e8cSThomas Abraham  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23*77b55e8cSThomas Abraham  * MA 02111-1307 USA
24*77b55e8cSThomas Abraham  */
25*77b55e8cSThomas Abraham 
26*77b55e8cSThomas Abraham #include <common.h>
27*77b55e8cSThomas Abraham #include <config.h>
28*77b55e8cSThomas Abraham #include <asm/io.h>
29*77b55e8cSThomas Abraham #include <asm/arch/cpu.h>
30*77b55e8cSThomas Abraham #include <asm/arch/clk.h>
31*77b55e8cSThomas Abraham #include <asm/arch/clock.h>
32*77b55e8cSThomas Abraham #include "common_setup.h"
33*77b55e8cSThomas Abraham #include "exynos4_setup.h"
34*77b55e8cSThomas Abraham 
35*77b55e8cSThomas Abraham /*
36*77b55e8cSThomas Abraham  * system_clock_init: Initialize core clock and bus clock.
37*77b55e8cSThomas Abraham  * void system_clock_init(void)
38*77b55e8cSThomas Abraham  */
system_clock_init(void)39*77b55e8cSThomas Abraham void system_clock_init(void)
40*77b55e8cSThomas Abraham {
41*77b55e8cSThomas Abraham 	struct exynos4_clock *clk =
42*77b55e8cSThomas Abraham 			(struct exynos4_clock *)samsung_get_base_clock();
43*77b55e8cSThomas Abraham 
44*77b55e8cSThomas Abraham 	writel(CLK_SRC_CPU_VAL, &clk->src_cpu);
45*77b55e8cSThomas Abraham 
46*77b55e8cSThomas Abraham 	sdelay(0x10000);
47*77b55e8cSThomas Abraham 
48*77b55e8cSThomas Abraham 	writel(CLK_SRC_TOP0_VAL, &clk->src_top0);
49*77b55e8cSThomas Abraham 	writel(CLK_SRC_TOP1_VAL, &clk->src_top1);
50*77b55e8cSThomas Abraham 	writel(CLK_SRC_DMC_VAL, &clk->src_dmc);
51*77b55e8cSThomas Abraham 	writel(CLK_SRC_LEFTBUS_VAL, &clk->src_leftbus);
52*77b55e8cSThomas Abraham 	writel(CLK_SRC_RIGHTBUS_VAL, &clk->src_rightbus);
53*77b55e8cSThomas Abraham 	writel(CLK_SRC_FSYS_VAL, &clk->src_fsys);
54*77b55e8cSThomas Abraham 	writel(CLK_SRC_PERIL0_VAL, &clk->src_peril0);
55*77b55e8cSThomas Abraham 	writel(CLK_SRC_CAM_VAL, &clk->src_cam);
56*77b55e8cSThomas Abraham 	writel(CLK_SRC_MFC_VAL, &clk->src_mfc);
57*77b55e8cSThomas Abraham 	writel(CLK_SRC_G3D_VAL, &clk->src_g3d);
58*77b55e8cSThomas Abraham 	writel(CLK_SRC_LCD0_VAL, &clk->src_lcd0);
59*77b55e8cSThomas Abraham 
60*77b55e8cSThomas Abraham 	sdelay(0x10000);
61*77b55e8cSThomas Abraham 
62*77b55e8cSThomas Abraham 	writel(CLK_DIV_CPU0_VAL, &clk->div_cpu0);
63*77b55e8cSThomas Abraham 	writel(CLK_DIV_CPU1_VAL, &clk->div_cpu1);
64*77b55e8cSThomas Abraham 	writel(CLK_DIV_DMC0_VAL, &clk->div_dmc0);
65*77b55e8cSThomas Abraham 	writel(CLK_DIV_DMC1_VAL, &clk->div_dmc1);
66*77b55e8cSThomas Abraham 	writel(CLK_DIV_LEFTBUS_VAL, &clk->div_leftbus);
67*77b55e8cSThomas Abraham 	writel(CLK_DIV_RIGHTBUS_VAL, &clk->div_rightbus);
68*77b55e8cSThomas Abraham 	writel(CLK_DIV_TOP_VAL, &clk->div_top);
69*77b55e8cSThomas Abraham 	writel(CLK_DIV_FSYS1_VAL, &clk->div_fsys1);
70*77b55e8cSThomas Abraham 	writel(CLK_DIV_FSYS2_VAL, &clk->div_fsys2);
71*77b55e8cSThomas Abraham 	writel(CLK_DIV_FSYS3_VAL, &clk->div_fsys3);
72*77b55e8cSThomas Abraham 	writel(CLK_DIV_PERIL0_VAL, &clk->div_peril0);
73*77b55e8cSThomas Abraham 	writel(CLK_DIV_CAM_VAL, &clk->div_cam);
74*77b55e8cSThomas Abraham 	writel(CLK_DIV_MFC_VAL, &clk->div_mfc);
75*77b55e8cSThomas Abraham 	writel(CLK_DIV_G3D_VAL, &clk->div_g3d);
76*77b55e8cSThomas Abraham 	writel(CLK_DIV_LCD0_VAL, &clk->div_lcd0);
77*77b55e8cSThomas Abraham 
78*77b55e8cSThomas Abraham 	/* Set PLL locktime */
79*77b55e8cSThomas Abraham 	writel(PLL_LOCKTIME, &clk->apll_lock);
80*77b55e8cSThomas Abraham 	writel(PLL_LOCKTIME, &clk->mpll_lock);
81*77b55e8cSThomas Abraham 	writel(PLL_LOCKTIME, &clk->epll_lock);
82*77b55e8cSThomas Abraham 	writel(PLL_LOCKTIME, &clk->vpll_lock);
83*77b55e8cSThomas Abraham 
84*77b55e8cSThomas Abraham 	writel(APLL_CON1_VAL, &clk->apll_con1);
85*77b55e8cSThomas Abraham 	writel(APLL_CON0_VAL, &clk->apll_con0);
86*77b55e8cSThomas Abraham 	writel(MPLL_CON1_VAL, &clk->mpll_con1);
87*77b55e8cSThomas Abraham 	writel(MPLL_CON0_VAL, &clk->mpll_con0);
88*77b55e8cSThomas Abraham 	writel(EPLL_CON1_VAL, &clk->epll_con1);
89*77b55e8cSThomas Abraham 	writel(EPLL_CON0_VAL, &clk->epll_con0);
90*77b55e8cSThomas Abraham 	writel(VPLL_CON1_VAL, &clk->vpll_con1);
91*77b55e8cSThomas Abraham 	writel(VPLL_CON0_VAL, &clk->vpll_con0);
92*77b55e8cSThomas Abraham 
93*77b55e8cSThomas Abraham 	sdelay(0x30000);
94*77b55e8cSThomas Abraham }
95