Root/qiboot/src/cpu/s3c2442/start.S

1/*
2 * (C) Copyright 2007 OpenMoko, Inc.
3 *
4 * Configuation settings for the OPENMOKO Neo GTA02 Linux GSM phone
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of
9 * the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
19 * MA 02111-1307 USA
20 */
21
22#define __ASM_MODE__
23#define __ASSEMBLY__
24
25#include <neo_gta02.h>
26
27#define S3C2410_MISCCR_nEN_SCLK0 (1 << 17)
28#define S3C2410_MISCCR_nEN_SCLK1 (1 << 18)
29#define S3C2410_MISCCR_nEN_SCLKE (1 << 19)
30
31
32.globl _start, processor_id, is_jtag
33
34_start: b start_code
35/* if we are injected by JTAG, the script sets _istag content to nonzero */
36is_jtag:
37    .word 0
38
39/* it's at a fixed address (+0x8) so we can breakpoint it in the JTAG script
40 * we need to go through this hassle because before this moment, SDRAM is not
41 * working so we can't prep it from JTAG
42 */
43
44_steppingstone_done:
45    ldr pc, _start_armboot
46
47_start_armboot:
48    .word start_qi
49
50_TEXT_BASE:
51    .word TEXT_BASE
52
53/*
54 * These are defined in the board-specific linker script.
55 */
56.globl _bss_start
57_bss_start:
58    .word __bss_start
59
60.globl _bss_end
61_bss_end:
62    .word _end
63/*
64 * we have a stack in steppingstone because we can want to run full memory
65 * memory tests
66 */
67
68    .fill 128
69.globl _ss_stack
70_ss_stack:
71
72
73start_code:
74    /*
75     * set the cpu to SVC32 mode
76     */
77    mrs r0,cpsr
78    bic r0,r0,#0x1f
79    orr r0,r0,#0xd3
80    msr cpsr,r0
81
82# define pWTCON 0x53000000
83
84    ldr r0, =pWTCON
85    mov r1, #0x0
86    str r1, [r0]
87
88    /*
89     * mask all IRQs by setting all bits in the INTMR - default
90     */
91# define INTMSK 0x4A000008 /* Interupt-Controller base addresses */
92# define INTSUBMSK 0x4A00001C
93# define INTSUBMSK_val 0x0000ffff
94
95    mov r1, #0xffffffff
96    ldr r0, =INTMSK
97    str r1, [r0]
98
99    ldr r1, =INTSUBMSK_val
100    ldr r0, =INTSUBMSK
101    str r1, [r0]
102
103
104    /* Make sure we get FCLK:HCLK:PCLK = 1:3:6 */
105# define CAMDIVN 0x4C000018
106
107    ldr r0, =CAMDIVN
108    mov r1, #0
109    str r1, [r0]
110
111    /* Clock asynchronous mode */
112    mrc p15, 0, r1, c1, c0, 0
113    orr r1, r1, #0xc0000000
114    mcr p15, 0, r1, c1, c0, 0
115
116#define LOCKTIME 0x4c000000
117
118    ldr r0, =LOCKTIME
119    mov r1, #0xffffff
120    str r1, [r0]
121    
122# define UPLLCON 0x4c000008
123# define MPLLCON_val ((142 << 12) + (7 << 4) + 1)
124# define UPLLCON_val (( 88 << 12) + (8 << 4) + 2)
125    
126    ldr r0, =UPLLCON
127    ldr r1, =UPLLCON_val
128    str r1, [r0]
129
130    /* Page 7-19, seven nops between UPLL and MPLL */
131    nop
132    nop
133    nop
134    nop
135    nop
136    nop
137    nop
138
139    ldr r1, =MPLLCON_val
140    str r1, [r0, #-4] /* MPLLCON */
141
142# define CLKDIVN 0x4C000014 /* clock divisor register */
143# define CLKDIVN_val 7 /* FCLK:HCLK:PCLK = 1:3:6 */
144
145    /* FCLK:HCLK:PCLK = 1:3:6 */
146    ldr r0, =CLKDIVN
147    mov r1, #CLKDIVN_val
148    str r1, [r0]
149
150    /* enable only CPU peripheral block clocks we actually use */
151    ldr r0, =0x4c00000c /* clkcon */
152    ldr r1, =0x3f10 /* uart, pwm, gpio, nand, sdi clocks on */
153    str r1, [r0]
154
155    /* gpio UART2 init, H port */
156    ldr r0, =0x56000070
157    ldr r1, =0x001AAAAA
158    str r1, [r0]
159
160    /* enable KEEPACT(GPJ8) to make sure PMU keeps us alive */
161    ldr r0, =0x56000000 /* GPJ base */
162    ldr r1, [r0, #0xd0] /* GPJCON */
163    orr r1, r1, #(1 << 16)
164    str r1, [r0, #0xd0]
165
166    ldr r1, [r0, #0xd4] /* GPJDAT */
167    orr r1, r1, #(1 << 8)
168    str r1, [r0, #0xd4]
169
170
171    /* init uart2 */
172    ldr r0, =0x50008000
173    mov r1, #0x03
174    str r1, [r0]
175    ldr r1, =0x245
176    str r1, [r0, #0x04]
177    mov r1, #0x00
178    str r1, [r0, #0x08]
179    mov r1, #0x00
180    str r1, [r0, #0x0c]
181    mov r1, #0x11
182    str r1, [r0, #0x28]
183
184    ldr r0, =0x50008000
185    ldr r1, =0x54
186    str r1, [r0, #0x20]
187
188/* reset nand controller, or it is dead to us */
189
190        mov r1, #0x4E000000
191        ldr r2, =0xfff0 @ initial value tacls=3,rph0=7,rph1=7
192        ldr r3, [r1, #0]
193        orr r3, r3, r2
194        str r3, [r1, #0]
195
196        ldr r3, [r1, #4]
197        orr r3, r3, #1 @ enable nand controller
198        str r3, [r1, #4]
199
200
201    /* take sdram out of power down */
202    ldr r0, =0x56000080 /* misccr */
203    ldr r1, [ r0 ]
204    bic r1, r1, #(S3C2410_MISCCR_nEN_SCLK0 | S3C2410_MISCCR_nEN_SCLK1 | S3C2410_MISCCR_nEN_SCLKE)
205    str r1, [ r0 ]
206
207    /* ensure signals stabalise */
208    mov r1, #128
2091: subs r1, r1, #1
210    bpl 1b
211
212    bl cpu_init_crit
213
214    /* ensure some refresh has happened */
215    ldr r1, =0xfffff
2161: subs r1, r1, #1
217    bpl 1b
218
219    /* capture full EINT situation into gstatus 4 */
220
221    ldr r0, =0x4A000000 /* SRCPND */
222    ldr r1, [ r0 ]
223    and r1, r1, #0xf
224
225    ldr r0, =0x560000BC /* gstatus4 */
226    str r1, [ r0 ]
227
228    ldr r0, =0x560000A8 /* EINTPEND */
229    ldr r1, [ r0 ]
230    ldr r0, =0xfff0
231    and r1, r1, r0
232    ldr r0, =0x560000BC /* gstatus4 */
233    ldr r0, [ r0 ]
234    orr r1, r1, r0
235    ldr r0, =0x560000BC /* gstatus4 */
236    str r1, [ r0 ]
237
238    /* test for resume */
239
240    ldr r1, =0x560000B4 /* gstatus2 */
241    ldr r0, [ r1 ]
242    tst r0, #0x02 /* is this resume from power down */
243                    /* well, if it was, we are going to jump to
244                     * whatever address we stashed in gstatus3,
245                     * and gstatus4 will hold the wake interrupt
246                     * source for the OS to look at
247                     */
248    ldrne pc, [r1, #4]
249
250
251                                /* >> CFG_VIDEO_LOGO_MAX_SIZE */
252#define CFG_GBL_DATA_SIZE 128 /* size in bytes reserved for initial data */
253
254stack_setup:
255    ldr r0, _TEXT_BASE /* upper 128 KiB: relocated uboot */
256    sub r0, r0, #CFG_GBL_DATA_SIZE /* bdinfo */
257    sub sp, r0, #12 /* leave 3 words for abort-stack */
258
259clear_bss:
260    ldr r0, _bss_start /* find start of bss segment */
261    ldr r1, _bss_end /* stop here */
262    mov r2, #0x00000000 /* clear */
263
264clbss_l:
265    str r2, [r0] /* clear loop... */
266    add r0, r0, #4
267    cmp r0, r1
268    ble clbss_l
269
270/* we are going to jump into the C part of the init now */
271spin:
272    b _steppingstone_done
273
274/*
275 *************************************************************************
276 *
277 * CPU_init_critical registers
278 *
279 * setup important registers
280 * setup memory timing
281 *
282 *************************************************************************
283 */
284
285cpu_init_crit:
286
287    /*
288     * flush v4 I/D caches
289     */
290    mov r0, #0
291    mcr p15, 0, r0, c7, c7, 0 /* flush v3/v4 cache */
292    mcr p15, 0, r0, c8, c7, 0 /* flush v4 TLB */
293
294    /*
295     * disable MMU stuff and caches
296     */
297    mrc p15, 0, r0, c1, c0, 0
298    bic r0, r0, #0x00002300 @ clear bits 13, 9:8 (--V- --RS)
299    bic r0, r0, #0x00000087 @ clear bits 7, 2:0 (B--- -CAM)
300    orr r0, r0, #0x00000002 @ set bit 2 (A) Align
301    orr r0, r0, #0x00005000 @ set bits 14, 12 D and I-Cache
302    mcr p15, 0, r0, c1, c0, 0
303
304    /*
305     * before relocating, we have to setup RAM timing
306     * because memory timing is board-dependend, you will
307     * find a lowlevel_init.S in your board directory.
308     */
309    mov ip, lr
310 
311    bl lowlevel_init
312
313    mov lr, ip
314    mov pc, lr
315
316

Archive Download this file



interactive