Tizen 2.0 Release
[platform/kernel/u-boot.git] / board / samsung / trats / lowlevel_init.S
1 /*
2  * Lowlevel setup for universal board based on EXYNOS4210
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  * Kyungmin Park <kyungmin.park@samsung.com>
6  *
7  * See file CREDITS for list of people who contributed to this
8  * project.
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License as
12  * published by the Free Software Foundation; either version 2 of
13  * the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23  * MA 02111-1307 USA
24  */
25
26 #include <config.h>
27 #include <version.h>
28 #include <asm/arch/cpu.h>
29 #include <asm/arch/clock.h>
30 #include <asm/arch/power.h>
31
32 /*
33  * Register usages:
34  *
35  * r5 has zero always
36  * r7 has GPIO part1 base 0x11400000
37  * r6 has GPIO part2 base 0x11000000
38  */
39
40         .globl lowlevel_init
41 lowlevel_init:
42         mov     r11, lr
43
44         /* r5 has always zero */
45         mov     r5, #0
46
47         ldr     r7, =EXYNOS4_GPIO_PART1_BASE
48         ldr     r6, =EXYNOS4_GPIO_PART2_BASE
49
50         /* System Timer */
51         ldr     r0, =EXYNOS4_MCT_BASE
52         ldr     r1, =0x100
53         str     r1, [r0, #0x240]
54
55         /* Workaround: PMIC manual reset */
56         /* nPOWER: XEINT_23: GPX2[7] */
57         add     r0, r6, #0xC40                  @ EXYNOS4_GPIO_X2_OFFSET
58         ldr     r1, [r0, #0x0]
59         bic     r1, r1, #(0xf << 28)            @ 28 = 7 * 4-bit
60         orr     r1, r1, #(0x1 << 28)            @ Output
61         str     r1, [r0, #0x0]
62
63         ldr     r1, [r0, #0x4]
64         orr     r1, r1, #(1 << 7)               @ 7 = 7 * 1-bit
65         str     r1, [r0, #0x4]
66
67         /* init system clock */
68         bl      system_clock_init
69
70         /* Disable Watchdog */
71         ldr     r0, =EXYNOS4_WDT_BASE
72         str     r5, [r0]
73
74         /* UART */
75         bl      uart_asm_init
76
77         /* PMU init */
78         bl      system_power_init
79
80         bl      tzpc_init
81
82 #if 0
83         /* Enable NEON. Don't change the register r0 */
84         ldr     r0, =0x00F00000
85         mcr     p15, 0, r0, c1, c0, 2
86         ldr     r0, =0x40000000
87         .word   0xeee80a10      /* VMSR_FPSCR_r0 */
88         .word   0xeef80a10      /* VMRS_r0_FPSCR */
89 #endif
90
91         mov     lr, r11
92         mov     pc, lr
93         nop
94         nop
95         nop
96
97 /*
98  * uart_asm_init: Initialize UART's pins
99  */
100 uart_asm_init:
101         /*
102          * setup UART0-UART4 GPIOs (part1)
103          * GPA1CON[3] = I2C_3_SCL (3)
104          * GPA1CON[2] = I2C_3_SDA (3)
105          */
106         mov     r0, r7
107         ldr     r1, =0x22222222
108         str     r1, [r0, #0x00]                 @ EXYNOS4_GPIO_A0_OFFSET
109         ldr     r1, =0x00223322
110         str     r1, [r0, #0x20]                 @ EXYNOS4_GPIO_A1_OFFSET
111
112         /* UART_SEL GPY4[7] (part2) at EXYNOS4210 */
113         add     r0, r6, #0x1A0                  @ EXYNOS4_GPIO_Y4_OFFSET
114         ldr     r1, [r0, #0x0]
115         bic     r1, r1, #(0xf << 28)            @ 28 = 7 * 4-bit
116         orr     r1, r1, #(0x1 << 28)
117         str     r1, [r0, #0x0]
118
119         ldr     r1, [r0, #0x8]
120         bic     r1, r1, #(0x3 << 14)            @ 14 = 7 * 2-bit
121         orr     r1, r1, #(0x3 << 14)            @ Pull-up enabled
122         str     r1, [r0, #0x8]
123
124         ldr     r1, [r0, #0x4]
125         orr     r1, r1, #(1 << 7)               @ 7 = 7 * 1-bit
126         str     r1, [r0, #0x4]
127
128 #if 0
129         ldr     r0, =0x13800000                 @ EXYNOS4_PA_UART
130         orr     r0, r0, #0x20000                @ UART2
131         mov     r1, #0x3
132         str     r1, [r0, #0x000]                @ ULCON
133         ldr     r1, =0x3c5
134         str     r1, [r0, #0x004]                @ UCON
135         mov     r1, #0x2B
136         str     r1, [r0, #0x028]                @ UBRDIV
137         mov     r1, #0xC
138         str     r1, [r0, #0x02C]                @ UFRACVAL
139
140         mov     r2, #'W'
141         strb    r2, [r0, #0x020]                @ UTXH
142 1001:
143         ldrb    r3, [r0, #0x010]                @ UTRSTAT
144         tst     r3, #(1 << 2)
145         beq     1001b
146 #endif
147
148         mov     pc, lr
149         nop
150         nop
151         nop
152
153 system_clock_init:
154         ldr     r0, =EXYNOS4_CLOCK_BASE
155
156         /* APLL(1), MPLL(1), CORE(0), HPM(0) */
157         ldr     r1, =0x0101
158         ldr     r2, =0x14200                    @ CLK_SRC_CPU
159         str     r1, [r0, r2]
160
161         /* wait ?us */
162         mov     r1, #0x10000
163 1:      subs    r1, r1, #1
164         bne     1b
165
166         /*
167          * CLK_SRC_TOP0
168          * MUX_ONENAND_SEL[28]  0: DOUT133, 1: DOUT166
169          * MUX_VPLL_SEL[8]      0: FINPLL,  1: FOUTVPLL
170          * MUX_EPLL_SEL[4]      0: FINPLL,  1: FOUTEPLL
171          */
172         ldr     r1, =0x10000110
173         ldr     r2, =0x0C210                    @ CLK_SRC_TOP
174         str     r1, [r0, r2]
175
176         /* SATA: SCLKMPLL(0), MMC[0:4]: SCLKMPLL(6) */
177         ldr     r1, =0x0066666
178         ldr     r2, =0x0C240                    @ CLK_SRC_FSYS
179         str     r1, [r0, r2]
180         /* UART[0:5], PWM: SCLKMPLL(6) */
181         ldr     r1, =0x6666666
182         ldr     r2, =0x0C250                    @ CLK_SRC_PERIL0_OFFSET
183         str     r1, [r0, r2]
184
185         /* CPU0: CORE, COREM0, COREM1, PERI, ATB, PCLK_DBG, APLL */
186         ldr     r1, =0x0133730
187         ldr     r2, =0x14500                    @ CLK_DIV_CPU0
188         str     r1, [r0, r2]
189         /* CPU1: COPY, HPM */
190         ldr     r1, =0x03
191         ldr     r2, =0x14504                    @ CLK_DIV_CPU1
192         str     r1, [r0, r2]
193         /* DMC0: ACP, ACP_PCLK, DPHY, DMC, DMCD, DMCP, COPY2 CORE_TIMER */
194         ldr     r1, =0x13111113
195         ldr     r2, =0x10500                    @ CLK_DIV_DMC0
196         str     r1, [r0, r2]
197         /* DMC1: PWI, DVSEM, DPM */
198         ldr     r1, =0x01010100
199         ldr     r2, =0x10504                    @ CLK_DIV_DMC1
200         str     r1, [r0, r2]
201         /* LEFTBUS: GDL, GPL */
202         ldr     r1, =0x13
203         ldr     r2, =0x04500                    @ CLK_DIV_LEFTBUS
204         str     r1, [r0, r2]
205         /* RIGHHTBUS: GDR, GPR */
206         ldr     r1, =0x13
207         ldr     r2, =0x08500                    @ CLK_DIV_RIGHTBUS
208         str     r1, [r0, r2]
209         /*
210          * CLK_DIV_TOP
211          * ONENAND_RATIOD[18:16]: 0 SCLK_ONENAND = MOUTONENAND / (n + 1)
212          * ACLK_200, ACLK_100, ACLK_160, ACLK_133,
213          */
214         ldr     r1, =0x00005473
215         ldr     r2, =0x0C510                    @ CLK_DIV_TOP
216         str     r1, [r0, r2]
217         /* MMC[0:1] */
218         ldr     r1, =0x000f000f                 /* 800(MPLL) / (15 + 1) */
219         ldr     r2, =0x0C544                    @ CLK_DIV_FSYS1
220         str     r1, [r0, r2]
221         /* MMC[2:3] */
222         ldr     r1, =0x000f000f                 /* 800(MPLL) / (15 + 1) */
223         ldr     r2, =0x0C548                    @ CLK_DIV_FSYS2
224         str     r1, [r0, r2]
225         /* MMC4 */
226         ldr     r1, =0x0003                     /* 800(MPLL) / (3 + 1) */
227         ldr     r2, =0x0C54C                    @ CLK_DIV_FSYS3
228         str     r1, [r0, r2]
229         /* UART[0:5] */
230         ldr     r1, =0x774777
231         ldr     r2, =0x0C550                    @ CLK_DIV_PERIL0
232         str     r1, [r0, r2]
233         /* SLIMBUS: ???, PWM */
234         ldr     r1, =0x8
235         ldr     r2, =0x0C55C                    @ CLK_DIV_PERIL3
236         str     r1, [r0, r2]
237
238         /* PLL Setting */
239         ldr     r1, =0x1C20
240         ldr     r2, =0x14000                    @ APLL_LOCK
241         str     r1, [r0, r2]
242         ldr     r2, =0x14008                    @ MPLL_LOCK
243         str     r1, [r0, r2]
244         ldr     r2, =0x0C010                    @ EPLL_LOCK
245         str     r1, [r0, r2]
246         ldr     r2, =0x0C020                    @ VPLL_LOCK
247         str     r1, [r0, r2]
248
249         /* APLL */
250         ldr     r1, =0x8000001c
251         ldr     r2, =0x14104                    @ APLL_CON1
252         str     r1, [r0, r2]
253         ldr     r1, =0x80c80601                 @ 800MHz
254         ldr     r2, =0x14100                    @ APLL_CON0
255         str     r1, [r0, r2]
256         /* MPLL */
257         ldr     r1, =0x8000001C
258         ldr     r2, =0x1410C                    @ MPLL_CON1
259         str     r1, [r0, r2]
260         ldr     r1, =0x80c80601                 @ 800MHz
261         ldr     r2, =0x14108                    @ MPLL_CON0
262         str     r1, [r0, r2]
263         /* EPLL */
264         ldr     r1, =0x0
265         ldr     r2, =0x0C114                    @ EPLL_CON1
266         str     r1, [r0, r2]
267         ldr     r1, =0x80300302                 @ 96MHz
268         ldr     r2, =0x0C110                    @ EPLL_CON0
269         str     r1, [r0, r2]
270         /* VPLL */
271         ldr     r1, =0x11000400
272         ldr     r2, =0x0C124                    @ VPLL_CON1
273         str     r1, [r0, r2]
274         ldr     r1, =0x80350302                 @ 108MHz
275         ldr     r2, =0x0C120                    @ VPLL_CON0
276         str     r1, [r0, r2]
277
278 #if 0
279         /*
280          * SMMUJPEG[11], JPEG[6], CSIS1[5]              : 0111 1001
281          * Turn off all
282          */
283         ldr     r1, =0xFFF80000
284         ldr     r2, =0x0C920                    @ CLK_GATE_IP_CAM
285         str     r1, [r0, r2]
286
287         /* Turn off all */
288         ldr     r1, =0xFFFFFFC0
289         ldr     r2, =0x0C924                    @ CLK_GATE_IP_VP
290         str     r1, [r0, r2]
291
292         /* Turn off all */
293         ldr     r1, =0xFFFFFFFE
294         ldr     r2, =0x0C928                    @ CLK_GATE_IP_MFC
295         str     r1, [r0, r2]
296
297         /* Turn off all */
298         ldr     r1, =0xFFFFFFFE
299         ldr     r2, =0x0C92C                    @ CLK_GATE_IP_G3D
300         str     r1, [r0, r2]
301
302         /* Turn off all */
303         ldr     r1, =0xFFFFFC00
304         ldr     r2, =0x0C930                    @ CLK_GATE_IP_IMAGE
305         str     r1, [r0, r2]
306
307         /* DSIM0[3], MDNIE0[2], MIE0[1]                 : 0001 */
308         ldr     r1, =0xFFFFFFF1
309         ldr     r2, =0x0C934                    @ CLK_GATE_IP_LCD0
310         str     r1, [r0, r2]
311
312         /* Turn off all */
313         ldr     r1, =0xFFFFFFC0
314         ldr     r2, =0x0C938                    @ CLK_GATE_IP_LCD1
315         str     r1, [r0, r2]
316
317         /*
318          * SMMUPCIE[18], NFCON[16]                      : 1111 1010
319          * ONENAND[15], PCIE[14], SATA[10], SDMMC43[9:8]: 0011 1000
320          * SDMMC1[6], TSI[4], SATAPHY[3], PCIEPHY[2]    : 1010 0011
321          */
322         ldr     r1, =0xFFFA38A3
323         ldr     r2, =0x0C940                    @ CLK_GATE_IP_FSYS
324         str     r1, [r0, r2]
325
326         /* Turn off all */
327         ldr     r1, =0xFFFFFFFE
328         ldr     r2, =0x0C94C                    @ CLK_GATE_IP_GPS
329         str     r1, [r0, r2]
330
331         /*
332          * AC97[27], SPDIF[26], SLIMBUS[25]             : 1111 0001
333          * I2C2[8]                                      : 1111 1110
334          */
335         ldr     r1, =0xF1FFFEFF
336         ldr     r2, =0x0C950                    @ CLK_GATE_IP_PERIL
337         str     r1, [r0, r2]
338
339         /*
340          * KEYIF[16]                                    : 1111 1110
341          */
342         ldr     r1, =0xFFFEFFFF
343         ldr     r2, =0x0C960                    @ CLK_GATE_IP_PERIR
344         str     r1, [r0, r2]
345
346         /* GPS[7], LCD1[5], G3D[3], MFC[2], TV[1]       : 0101 0001 */
347         ldr     r1, =0xFFFFFF51
348         ldr     r2, =0x0C970                    @ CLK_GATE_BLOCK
349         str     r1, [r0, r2]
350 #endif
351         mov     pc, lr
352         nop
353         nop
354         nop
355
356 system_power_init:
357         ldr     r0, =EXYNOS4_POWER_BASE         @ 0x10020000
358
359         ldr     r2, =0x330C                     @ PS_HOLD_CONTROL
360         ldr     r1, [r0, r2]
361         orr     r1, r1, #(0x3 << 8)             @ Data High, Output En
362         str     r1, [r0, r2]
363
364         /* Power Down */
365         add     r2, r0, #0x3000
366         @str    r5, [r2, #0xC00]                @ CAM_CONFIGURATION
367         str     r5, [r2, #0xC20]                @ TV_CONFIGURATION
368         str     r5, [r2, #0xC40]                @ MFC_CONFIGURATION
369         str     r5, [r2, #0xC60]                @ G3D_CONFIGURATION
370         str     r5, [r2, #0xCA0]                @ LCD1_CONFIGURATION
371         /* FIXME Don't turn off MAUDIO why??? */
372         @str    r5, [r2, #0xCC0]                @ MAUDIO_CONFIGURATION
373         str     r5, [r2, #0xCE0]                @ GPS_CONFIGURATION
374         str     r5, [r2, #0xD00]                @ GPS_ALIVE_CONFIGURATION
375
376         mov     pc, lr
377         nop
378         nop
379         nop
380
381 tzpc_init:
382         ldr     r0, =0x10110000
383         mov     r1, #0x0
384         str     r1, [r0]
385         mov     r1, #0xff
386         str     r1, [r0, #0x0804]
387         str     r1, [r0, #0x0810]
388         str     r1, [r0, #0x081C]
389         str     r1, [r0, #0x0828]
390
391         ldr     r0, =0x10120000
392         str     r1, [r0, #0x0804]
393         str     r1, [r0, #0x0810]
394         str     r1, [r0, #0x081C]
395         str     r1, [r0, #0x0828]
396
397         ldr     r0, =0x10130000
398         str     r1, [r0, #0x0804]
399         str     r1, [r0, #0x0810]
400         str     r1, [r0, #0x081C]
401         str     r1, [r0, #0x0828]
402
403         ldr     r0, =0x10140000
404         str     r1, [r0, #0x0804]
405         str     r1, [r0, #0x0810]
406         str     r1, [r0, #0x081C]
407         str     r1, [r0, #0x0828]
408
409         ldr     r0, =0x10150000
410         str     r1, [r0, #0x0804]
411         str     r1, [r0, #0x0810]
412         str     r1, [r0, #0x081C]
413         str     r1, [r0, #0x0828]
414
415         mov     pc, lr