1 /* $NetBSD: smdk2410_start.S,v 1.4.4.3 2004/09/21 13:14:53 skrll Exp $ */
4 * Copyright (c) 2002, 2003 Fujitsu Component Limited
5 * Copyright (c) 2002, 2003 Genetec Corporation
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of The Fujitsu Component Limited nor the name of
17 * Genetec corporation may not be used to endorse or promote products
18 * derived from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY FUJITSU COMPONENT LIMITED AND GENETEC
21 * CORPORATION ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
22 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 * DISCLAIMED. IN NO EVENT SHALL FUJITSU COMPONENT LIMITED OR GENETEC
25 * CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
28 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #include <machine/asm.h>
36 #include <arm/armreg.h>
37 #include <arm/arm32/pte.h>
38 #include <arm/arm32/pmap.h> /* for PMAP_DOMAIN_KERNEL */
40 #include <arm/s3c2xx0/s3c2410reg.h> /* for S3C2410_SDRAM_START */
41 #include "opt_smdk2xx0.h" /* SMDK2XX0_CLOCK_CONFIG */
44 * Kernel start routine for Samsung SMDK2410.
45 * This code is excuted at the very first after the kernel is loaded
51 #define SDRAM_START S3C2410_SDRAM_START
53 #define KERNEL_TEXT_ADDR (SDRAM_START+0x00200000)
55 .global _C_LABEL(smdk2410_start)
56 _C_LABEL(smdk2410_start):
57 /* Disable interrupt */
62 #ifdef SMDK2XX0_CLOCK_CONFIG
63 adr r4, clock_config_data
65 mov r2, #S3C2410_CLKMAN_BASE
66 ldr r1, [r2, #CLKMAN_CLKSLOW]
67 orr r0, r1, #CLKSLOW_SLOW
68 str r0, [r2, #CLKMAN_CLKSLOW]
73 str r0, [r2, #CLKMAN_CLKDIVN]
75 str r3, [r2, #CLKMAN_MPLLCON]
79 str r1, [r2, #CLKMAN_CLKSLOW]
82 /* Are we running on right place ? */
83 adr r0, _C_LABEL(smdk2410_start)
84 ldr r2, =KERNEL_TEXT_ADDR
86 beq smdk2410_start_ram
92 adr r0, _C_LABEL(smdk2410_start)
100 /* src < dest. copy from top */
110 /* src >= dest. copy from bottom */
121 Lcopy_size: .word _edata-_C_LABEL(smdk2410_start)
122 Lstart_off: .word smdk2410_start_ram-_C_LABEL(smdk2410_start)
126 * Kernel is loaded in SDRAM (0x30200000..), and is expected to run
130 /* Disable MMU for a while */
131 mrc p15, 0, r2, c1, c0, 0
132 bic r2, r2, #CPU_CONTROL_MMU_ENABLE
133 mcr p15, 0, r2, c1, c0, 0
139 mov r0,#SDRAM_START /* pagetable */
140 adr r4, mmu_init_table
145 add r3, r3, #(L1_S_SIZE)
149 ldmia r4!, {r1,r2,r3} /* # of sections, PA|attr, VA */
153 mcr p15, 0, r0, c2, c0, 0 /* Set TTB */
154 mcr p15, 0, r0, c8, c7, 0 /* Flush TLB */
156 /* Set the Domain Access register. Very important! */
157 mov r0, #((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2)) | DOMAIN_CLIENT)
158 mcr p15, 0, r0, c3, c0, 0
161 mrc p15, 0, r0, c1, c0, 0
162 orr r0, r0, #CPU_CONTROL_MMU_ENABLE
163 mcr p15, 0, r0, c1, c0, 0
169 /* Jump to kernel code in TRUE VA */
176 .macro clock_data hdivn, pdivn, mdiv, pdiv, sdiv
177 .word (\hdivn)<<1 | \pdivn
178 .word (\mdiv)<<PLLCON_MDIV_SHIFT | (\pdiv)<<PLLCON_PDIV_SHIFT | (\sdiv)<<PLLCON_SDIV_SHIFT
180 #ifdef SMDK2XX0_CLOCK_CONFIG
182 clock_data SMDK2XX0_CLOCK_CONFIG
185 #define MMU_INIT(va,pa,n_sec,attr) \
187 .word 4*((va)>>L1_S_SHIFT) ; \
191 /* fill all table VA==PA */
192 MMU_INIT(0x00000000, 0x00000000, 1<<(32-L1_S_SHIFT), L1_TYPE_S|L1_S_AP(AP_KRW))
193 /* map SDRAM VA==PA, WT cacheable */
194 MMU_INIT(SDRAM_START, SDRAM_START, 64, L1_TYPE_S|L1_S_C|L1_S_AP(AP_KRW))
195 /* map VA 0xc0000000..0xc3ffffff to PA 0x30000000..0x33ffffff */
196 MMU_INIT(0xc0000000, SDRAM_START, 64, L1_TYPE_S|L1_S_C|L1_S_AP(AP_KRW))
198 .word 0 /* end of table */