s3c2800_vector.S revision 1.2 1 1.2 christos /* $NetBSD: s3c2800_vector.S,v 1.2 2005/12/11 12:17:09 christos Exp $ */
2 1.1 bsh
3 1.1 bsh /*
4 1.1 bsh * Copyright (c) 2002, 2003 Fujitsu Component Limited
5 1.1 bsh * Copyright (c) 2002, 2003 Genetec Corporation
6 1.1 bsh * All rights reserved.
7 1.1 bsh *
8 1.1 bsh * Redistribution and use in source and binary forms, with or without
9 1.1 bsh * modification, are permitted provided that the following conditions
10 1.1 bsh * are met:
11 1.1 bsh * 1. Redistributions of source code must retain the above copyright
12 1.1 bsh * notice, this list of conditions and the following disclaimer.
13 1.1 bsh * 2. Redistributions in binary form must reproduce the above copyright
14 1.1 bsh * notice, this list of conditions and the following disclaimer in the
15 1.1 bsh * documentation and/or other materials provided with the distribution.
16 1.1 bsh * 3. Neither the name of The Fujitsu Component Limited nor the name of
17 1.1 bsh * Genetec corporation may not be used to endorse or promote products
18 1.1 bsh * derived from this software without specific prior written permission.
19 1.1 bsh *
20 1.1 bsh * THIS SOFTWARE IS PROVIDED BY FUJITSU COMPONENT LIMITED AND GENETEC
21 1.1 bsh * CORPORATION ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
22 1.1 bsh * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 1.1 bsh * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 1.1 bsh * DISCLAIMED. IN NO EVENT SHALL FUJITSU COMPONENT LIMITED OR GENETEC
25 1.1 bsh * CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 1.1 bsh * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 1.1 bsh * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
28 1.1 bsh * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29 1.1 bsh * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 1.1 bsh * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 1.1 bsh * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 1.1 bsh * SUCH DAMAGE.
33 1.1 bsh */
34 1.1 bsh
35 1.1 bsh /*
36 1.1 bsh * Vector and initialize for S3C2800 based systems.
37 1.1 bsh */
38 1.1 bsh
39 1.1 bsh #include <machine/asm.h>
40 1.1 bsh #include <arm/armreg.h>
41 1.1 bsh #include <arm/s3c2xx0/s3c2800reg.h>
42 1.1 bsh
43 1.1 bsh #ifndef PLLCON_MDIV_VAL
44 1.1 bsh /* constans to get 200MHz FCLK */
45 1.1 bsh #if XTAL_CLK == 10000000 || XTAL_CLK == 10
46 1.1 bsh #define PLLCON_MDIV_VAL 0x5c
47 1.1 bsh #define PLLCON_PDIV_VAL 3
48 1.1 bsh #define PLLCON_SDIV_VAL 0
49 1.1 bsh #elif XTAL_CLK == 8000000 || XTAL_CLK == 8
50 1.1 bsh #define PLLCON_MDIV_VAL 0x5c
51 1.1 bsh #define PLLCON_PDIV_VAL 2
52 1.1 bsh #define PLLCON_SDIV_VAL 0
53 1.1 bsh #elif XTAL_CLK == 6000000 || XTAL_CLK == 6
54 1.1 bsh #define PLLCON_MDIV_VAL 0x5c
55 1.1 bsh #define PLLCON_PDIV_VAL 1
56 1.1 bsh #define PLLCON_SDIV_VAL 0
57 1.1 bsh #else
58 1.1 bsh #error define XTAL_CLK to 10, 8 or 6MHz
59 1.1 bsh #endif /* XTAL_CLK */
60 1.1 bsh #endif /* PLLCON_MDIV_VAL */
61 1.1 bsh
62 1.1 bsh #ifndef SDRAM_START
63 1.1 bsh #define SDRAM_START S3C2800_DBANK0_START
64 1.1 bsh #endif
65 1.1 bsh #ifndef SDRAM_SIZE
66 1.1 bsh #define SDRAM_SIZE 0x01000000 /* 16MB */
67 1.1 bsh #endif
68 1.1 bsh
69 1.1 bsh #define TEMP_STACK_SIZE (4*1024)
70 1.1 bsh
71 1.1 bsh
72 1.1 bsh .code 32
73 1.1 bsh .section ".vectors"
74 1.1 bsh
75 1.1 bsh reset_vector:
76 1.1 bsh b __reset_entry
77 1.1 bsh undef:
78 1.1 bsh b .
79 1.1 bsh swi:
80 1.1 bsh b .
81 1.1 bsh abrtp:
82 1.1 bsh b .
83 1.1 bsh abrtd:
84 1.1 bsh b .
85 1.1 bsh resv:
86 1.1 bsh b .
87 1.1 bsh irq:
88 1.1 bsh b .
89 1.1 bsh fiq:
90 1.1 bsh b .
91 1.1 bsh
92 1.1 bsh /*
93 1.1 bsh * Normally this code lives on ROM and runs immediately after reset, but
94 1.1 bsh * it may run on RAM and/or be called after system has been initialized.
95 1.1 bsh */
96 1.1 bsh __reset_entry:
97 1.1 bsh mrs r0, cpsr
98 1.1 bsh /* SVC mode, Disable interrupts */
99 1.1 bsh bic r0, r0, #PSR_MODE
100 1.1 bsh orr r0, r0, #(I32_bit|F32_bit|PSR_SVC32_MODE)
101 1.1 bsh msr cpsr, r0
102 1.1 bsh
103 1.1 bsh /* Disable MMU, Disable cache */
104 1.1 bsh mrc p15, 0, r10, c1, c0, 0
105 1.1 bsh ldr r0, =(CPU_CONTROL_MMU_ENABLE|CPU_CONTROL_DC_ENABLE|CPU_CONTROL_IC_ENABLE)
106 1.1 bsh bic r10, r10, r0
107 1.1 bsh mcr p15, 0, r10, c1, c0, 0
108 1.1 bsh nop
109 1.1 bsh nop
110 1.1 bsh nop
111 1.1 bsh
112 1.1 bsh /* invalidate I-cache */
113 1.1 bsh mcr p15, 0, r2, c7, c5, 0
114 1.1 bsh nop
115 1.1 bsh nop
116 1.1 bsh nop
117 1.1 bsh
118 1.1 bsh /* Enable I-cache */
119 1.1 bsh orr r10, r10, #CPU_CONTROL_IC_ENABLE
120 1.1 bsh mcr p15, 0, r10, c1, c0, 0
121 1.1 bsh nop
122 1.1 bsh nop
123 1.1 bsh nop
124 1.1 bsh
125 1.1 bsh /* Stop WDT */
126 1.1 bsh ldr r0, Lwdt_wtcon_addr
127 1.1 bsh mov r1, #WTCON_WDTSTOP
128 1.1 bsh str r1, [r0]
129 1.1 bsh
130 1.1 bsh /* Disable all interrupts */
131 1.1 bsh ldr r0, Lintctl_intmsk_addr
132 1.1 bsh mov r1, #0x0
133 1.1 bsh str r1, [r0]
134 1.1 bsh
135 1.1 bsh #if 0
136 1.1 bsh ldr r9, =S3C2800_GPIO_BASE
137 1.1 bsh /* LEDs on SMDK2800 */
138 1.1 bsh mov r1, #0x3f
139 1.1 bsh strh r1, [r9, #GPIO_PCONC]
140 1.1 bsh
141 1.1 bsh mov r0, #0xdfff /* set PB7 to AHBCLK out */
142 1.1 bsh strh r0, [r9,GPIO_PCONB]
143 1.1 bsh #endif
144 1.1 bsh
145 1.1 bsh mov r0, pc
146 1.1 bsh cmp r0, #SDRAM_START
147 1.1 bsh bhs running_on_ram
148 1.1 bsh
149 1.1 bsh #ifdef RAM_INIT_HOOK
150 1.1 bsh bl RAM_INIT_HOOK
151 1.1 bsh #endif
152 1.1 bsh ldr r8, =S3C2800_CLKMAN_BASE
153 1.1 bsh ldr r1, [r8,#CLKMAN_CLKCON]
154 1.1 bsh orr r1, r1, #CLKCON_HCLK /* AHB clock = FCLK/2 */
155 1.1 bsh str r1, [r8,#CLKMAN_CLKCON]
156 1.1 bsh
157 1.1 bsh ldr r1, Lclkman_locktime_data
158 1.1 bsh str r1, [r8,#CLKMAN_LOCKTIME]
159 1.1 bsh
160 1.1 bsh /* Initialize PLL */
161 1.1 bsh ldr r1, Lclkman_pllcon_data
162 1.1 bsh str r1, [r8,#CLKMAN_PLLCON]
163 1.1 bsh
164 1.1 bsh running_on_ram:
165 1.1 bsh /* Change Bus mode to Sync */
166 1.1 bsh mrc p15, 0, r0, c1, c0, 0
167 1.1 bsh bic r0, r0, #(1<<31) /* unset iA bit */
168 1.1 bsh orr r0, r0, #(1<<30) /* set nF bit */
169 1.1 bsh mcr p15, 0, r0, c1, c0, 0
170 1.1 bsh nop
171 1.1 bsh nop
172 1.1 bsh nop
173 1.1 bsh
174 1.1 bsh /* set temporary stack */
175 1.1 bsh adr sp, reset_vector
176 1.1 bsh /* do we have a room below? */
177 1.1 bsh ldr r1, =(SDRAM_START+TEMP_STACK_SIZE)
178 1.1 bsh cmp sp, r1
179 1.1 bsh /* otherwise use top area of RAM */
180 1.1 bsh ldrlo sp, =(SDRAM_START+SDRAM_SIZE)
181 1.1 bsh
182 1.1 bsh #ifdef IO_INIT_HOOK
183 1.1 bsh bl IO_INIT_HOOK
184 1.1 bsh #endif
185 1.1 bsh #ifdef SELFCOPY_TO_FLASH
186 1.1 bsh /* Are we running on RAM? */
187 1.1 bsh mov r0, pc
188 1.1 bsh cmp r0, #SDRAM_START
189 1.1 bsh blo 99f /* no, skip */
190 1.1 bsh adr r0, reset_vector
191 1.1 bsh ldr r1, =__rom_size__
192 1.1 bsh b selfcopy_to_flash
193 1.1 bsh 99:
194 1.1 bsh #endif
195 1.1 bsh b start
196 1.1 bsh
197 1.1 bsh Lwdt_wtcon_addr:
198 1.1 bsh .word (S3C2800_WDT_BASE + WDT_WTCON)
199 1.1 bsh
200 1.1 bsh Lintctl_intmsk_addr:
201 1.1 bsh .word (S3C2800_INTCTL_BASE + INTCTL_INTMSK)
202 1.1 bsh
203 1.1 bsh .ltorg
204 1.1 bsh
205 1.1 bsh Lclkman_locktime_data:
206 1.1 bsh .word (0xfff)
207 1.1 bsh
208 1.1 bsh Lclkman_pllcon_data:
209 1.1 bsh .word (PLLCON_MDIV_VAL<<PLLCON_MDIV_SHIFT) | \
210 1.1 bsh (PLLCON_PDIV_VAL<<PLLCON_PDIV_SHIFT) | \
211 1.1 bsh (PLLCON_SDIV_VAL<<PLLCON_SDIV_SHIFT)
212 1.1 bsh
213