tizen 2.3.1 release
[platform/kernel/u-boot.git] / board / samsung / smdk6442 / lowlevel_init.S
1 /*
2  * Copyright (C) 2009 Samsung Electronics
3  * Kyungmin Park <kyungmin.park@samsung.com>
4  * Minkyu Kang <mk7.kang@samsung.com>
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
25 #include <config.h>
26 #include <version.h>
27 #include <asm/arch/cpu.h>
28 #include <asm/arch/power.h>
29
30 /*
31  * Register usages:
32  *
33  * r5 has zero always
34  */
35
36 _TEXT_BASE:
37         .word   TEXT_BASE
38
39         .globl lowlevel_init
40 lowlevel_init:
41         mov     r9, lr
42
43         /* r5 has always zero */
44         mov     r5, #0
45
46         ldr     r8, =S5P6442_GPIO_BASE                  @0xE0200000
47
48         /* IO retension release */
49         ldr     r0, =S5P6442_OTHERS                     @0xE010E000
50         ldr     r1, [r0]
51         ldr     r2, =(1 << 31)                          @IO_RET_REL
52         orr     r1, r1, r2
53         str     r1, [r0]
54
55 #ifndef CONFIG_PRELOADER
56         /* Disable Watchdog */
57         ldr     r0, =S5P6442_WATCHDOG_BASE              @0xEA200000
58         orr     r0, r0, #0x0
59         str     r5, [r0]
60
61         /* setting SRAM */
62         ldr     r0, =S5P6442_SROMC_BASE                 @0xE7000000
63         ldr     r1, =0x9
64         str     r1, [r0]
65 #endif
66
67         /* S5P6442 has 3 groups of interrupt sources */
68         ldr     r0, =S5P6442_VIC0_BASE                  @0xE4000000
69         add     r1, r0, #0x00100000
70         add     r2, r0, #0x00200000
71
72         /* Disable all interrupts (VIC0, VIC1 and VIC2) */
73         mvn     r3, #0x0
74         str     r3, [r0, #0x14]                         @INTENCLEAR
75         str     r3, [r1, #0x14]                         @INTENCLEAR
76         str     r3, [r2, #0x14]                         @INTENCLEAR
77
78 #ifndef CONFIG_PRELOADER
79         /* Set all interrupts as IRQ */
80         str     r5, [r0, #0xc]                          @INTSELECT
81         str     r5, [r1, #0xc]                          @INTSELECT
82         str     r5, [r2, #0xc]                          @INTSELECT
83
84         /* Pending Interrupt Clear */
85         str     r5, [r0, #0xf00]                        @INTADDRESS
86         str     r5, [r1, #0xf00]                        @INTADDRESS
87         str     r5, [r2, #0xf00]                        @INTADDRESS
88 #endif
89
90 #ifndef CONFIG_PRELOADER
91         /* for UART */
92         bl uart_asm_init
93 #endif
94
95 #ifdef CONFIG_PRELOADER
96         /* init system clock */
97         bl      system_clock_init
98
99         bl      mem_ctrl_asm_init
100
101         /* OneNAND Sync Read Support at S5PC110 only
102          * RM[15]       : Sync Read
103          * BRWL[14:12]  : 7 CLK
104          * BL[11:9]     : Continuous
105          * VHF[3]       : Very High Frequency Enable (Over 83MHz)
106          * HF[2]        : High Frequency Enable (Over 66MHz)
107          */
108         ldr     r1, =0xE00C
109
110         ldr     r0, =0xB001E442
111         strh    r1, [r0]
112
113         ldr     r0, =0xB0600000
114         str     r1, [r0, #0x100]                        @ ONENAND_IF_CTRL
115
116         /* Wakeup support. Don't know if it's going to be used, untested. */
117         ldr     r0, =S5P6442_RST_STAT
118         ldr     r1, [r0]
119         bic     r1, r1, #0xfffffff7
120         cmp     r1, #0x8
121         beq     wakeup_reset
122 #endif
123
124 1:
125         mov     lr, r9
126         mov     pc, lr
127
128 #ifdef CONFIG_PRELOADER
129 wakeup_reset:
130
131         /* Clear wakeup status register */
132         ldr     r0, =S5P6442_WAKEUP_STAT
133         ldr     r1, [r0]
134         str     r1, [r0]
135
136         /* Load return address and jump to kernel */
137         ldr     r0, =S5P6442_INFORM0
138
139         /* r1 = physical address of s5p6442_cpu_resume function */
140         ldr     r1, [r0]
141
142         /* Jump to kernel (sleep.S) */
143         mov     pc, r1
144         nop
145         nop
146 #endif
147
148 /*
149  * system_clock_init: Initialize core clock and bus clock.
150  * void system_clock_init(void)
151  */
152 system_clock_init:
153         ldr     r8, =S5P64XX_CLOCK_BASE         @ 0xE0100000
154
155         /* Set Lock Time */
156         ldr     r1, =0xe10                      @ Locktime : 0xe10 = 3600
157         str     r1, [r8, #0x000]                @ APLL_LOCK
158         str     r1, [r8, #0x008]                @ MPLL_LOCK
159         str     r1, [r8, #0x010]                @ EPLL_LOCK
160         str     r1, [r8, #0x020]                @ VPLL_LOCK
161
162         /* APLL_CON */
163         ldr     r1, =0x829b0c01         @ SDIV 1, PDIV 0xc, MDIV 0x29b
164         str     r1, [r8, #0x100]
165         /* MPLL_CON */
166         ldr     r1, =0x810a0303         @ SDIV 3, PDIV 3, MDIV 0x10a
167         str     r1, [r8, #0x108]
168         /* EPLL_CON */
169         ldr     r1, =0x80600303         @ SDIV 3, PDIV 3, MDIV 0x60
170         str     r1, [r8, #0x110]
171         /* VPLL_CON */
172         ldr     r1, =0x806c0303         @ SDIV 3, PDIV 3, MDIV 0x6c
173         str     r1, [r8, #0x120]
174
175         /* Set Source Clock */
176         ldr     r1, =0x1111                     @ A, M, E, VPLL Muxing
177         str     r1, [r8, #0x200]                @ CLK_SRC0
178
179         /* Set Clock divider */
180         ldr     r1, =0x10100000
181         str     r1, [r8, #0x300]
182
183         /* wait at least 200us to stablize all clock */
184         mov     r2, #0x10000
185 1:      subs    r2, r2, #1
186         bne     1b
187
188         mov     pc, lr
189
190 #ifndef CONFIG_PRELOADER
191 /*
192  * uart_asm_init: Initialize UART's pins
193  */
194 uart_asm_init:
195         mov     r0, r8
196         ldr     r1, =0x22222222
197         str     r1, [r0, #0x0]                  @ GPA0_CON
198         ldr     r1, =0x00000022
199         str     r1, [r0, #0x20]                 @ GPA1_CON
200
201         mov     pc, lr
202 #endif