Home | History | Annotate | Line # | Download | only in board
      1  1.2  christos /*	$NetBSD: s3c2410_vector.S,v 1.2 2005/12/11 12:17:09 christos Exp $	*/
      2  1.1   mycroft 
      3  1.1   mycroft /*
      4  1.1   mycroft  * Copyright (c) 2003 By Noon Software, Inc.  All rights reserved.
      5  1.1   mycroft  *
      6  1.1   mycroft  * Redistribution and use in source and binary forms, with or without
      7  1.1   mycroft  * modification, are permitted provided that the following conditions
      8  1.1   mycroft  * are met:
      9  1.1   mycroft  * 1. Redistributions of source code must retain the above copyright
     10  1.1   mycroft  *    notice, this list of conditions and the following disclaimer.
     11  1.1   mycroft  * 2. Redistributions in binary form must reproduce the above copyright
     12  1.1   mycroft  *    notice, this list of conditions and the following disclaimer in the
     13  1.1   mycroft  *    documentation and/or other materials provided with the distribution.
     14  1.1   mycroft  * 3. The names of the authors may not be used to endorse or promote products
     15  1.1   mycroft  *    derived from this software without specific prior written permission.
     16  1.1   mycroft  *
     17  1.1   mycroft  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
     18  1.1   mycroft  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19  1.1   mycroft  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20  1.1   mycroft  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
     21  1.1   mycroft  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     22  1.1   mycroft  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23  1.1   mycroft  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24  1.1   mycroft  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25  1.1   mycroft  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     26  1.1   mycroft  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27  1.1   mycroft  */
     28  1.1   mycroft 
     29  1.1   mycroft /*
     30  1.1   mycroft  * Vector and initialize for S3C2410 based systems.
     31  1.1   mycroft  */
     32  1.1   mycroft 
     33  1.1   mycroft #include <machine/asm.h>
     34  1.1   mycroft #include <arm/armreg.h>
     35  1.1   mycroft #include <arm/s3c2xx0/s3c2410reg.h>
     36  1.1   mycroft 
     37  1.1   mycroft 
     38  1.1   mycroft #define TEMP_STACK_SIZE	(4*1024)
     39  1.1   mycroft 
     40  1.1   mycroft 	.code 32
     41  1.1   mycroft 	.section ".vectors"
     42  1.1   mycroft 
     43  1.1   mycroft reset_vector:
     44  1.1   mycroft 	b	__reset_entry
     45  1.1   mycroft undef:
     46  1.1   mycroft 	b	.
     47  1.1   mycroft swi:
     48  1.1   mycroft 	b	.
     49  1.1   mycroft abrtp:
     50  1.1   mycroft 	b	.
     51  1.1   mycroft abrtd:
     52  1.1   mycroft 	b	.
     53  1.1   mycroft resv:
     54  1.1   mycroft 	b	.
     55  1.1   mycroft irq:
     56  1.1   mycroft 	b	.
     57  1.1   mycroft fiq:
     58  1.1   mycroft 	b	.
     59  1.1   mycroft 
     60  1.1   mycroft /*
     61  1.1   mycroft  * Normally this code lives on ROM and runs immediately after reset, but
     62  1.1   mycroft  * it may run on RAM and/or be called after system has been initialized.
     63  1.1   mycroft  */
     64  1.1   mycroft __reset_entry:
     65  1.1   mycroft 	mrs	r0, cpsr
     66  1.1   mycroft 	/* SVC mode, Disable interrupts */
     67  1.1   mycroft 	bic	r0, r0, #PSR_MODE
     68  1.1   mycroft 	orr	r0, r0, #(I32_bit|F32_bit|PSR_SVC32_MODE)
     69  1.1   mycroft 	msr	cpsr, r0
     70  1.1   mycroft 
     71  1.1   mycroft 	/* Disable MMU, Disable cache */
     72  1.1   mycroft 	mrc	p15, 0, r10, c1, c0, 0
     73  1.1   mycroft 	ldr	r0, =(CPU_CONTROL_MMU_ENABLE|CPU_CONTROL_DC_ENABLE|CPU_CONTROL_IC_ENABLE)
     74  1.1   mycroft 	bic	r10, r10, r0
     75  1.1   mycroft 	mcr	p15, 0, r10, c1, c0, 0
     76  1.1   mycroft 	nop
     77  1.1   mycroft 	nop
     78  1.1   mycroft 	nop
     79  1.1   mycroft 
     80  1.1   mycroft 	/* invalidate I-cache */
     81  1.1   mycroft 	mcr	p15, 0, r2, c7, c5, 0
     82  1.1   mycroft 	nop
     83  1.1   mycroft 	nop
     84  1.1   mycroft 	nop
     85  1.1   mycroft 
     86  1.1   mycroft 	/* Enable I-cache */
     87  1.1   mycroft 	orr	r10, r10, #CPU_CONTROL_IC_ENABLE
     88  1.1   mycroft 	mcr	p15, 0, r10, c1, c0, 0
     89  1.1   mycroft 	nop
     90  1.1   mycroft 	nop
     91  1.1   mycroft 	nop
     92  1.1   mycroft 
     93  1.1   mycroft 	/* Stop WDT */
     94  1.1   mycroft 	ldr	r0, Lwdt_wtcon_addr
     95  1.1   mycroft 	mov	r1, #WTCON_WDTSTOP
     96  1.1   mycroft 	str	r1, [r0]
     97  1.1   mycroft 
     98  1.1   mycroft 	/* Disable all interrupts */
     99  1.1   mycroft 	ldr	r0, Lintctl_intmsk_addr
    100  1.1   mycroft 	mov	r1, #0x0
    101  1.1   mycroft 	str	r1, [r0]
    102  1.1   mycroft 
    103  1.1   mycroft 	ldr	r9, =S3C2410_GPIO_BASE
    104  1.1   mycroft 	/* LEDs on SMDK2410 */
    105  1.1   mycroft 	mov	r1, #0x5500
    106  1.1   mycroft 	str	r1, [r9, #GPIO_PFCON]
    107  1.1   mycroft 	mov	r1, #0xe0
    108  1.1   mycroft 	str	r1, [r9, #GPIO_PFDAT]
    109  1.1   mycroft 
    110  1.1   mycroft 	mov	r0, pc
    111  1.1   mycroft 	cmp	r0, #S3C2410_SDRAM_START
    112  1.1   mycroft 	bhs	running_on_ram
    113  1.1   mycroft 
    114  1.1   mycroft 	ldr	r8, =S3C2410_CLKMAN_BASE
    115  1.1   mycroft 	ldr	r1, [r8,#CLKMAN_CLKDIVN]
    116  1.1   mycroft 	orr	r1, r1, #CLKDIVN_HDIVN|CLKDIVN_PDIVN
    117  1.1   mycroft 	str	r1, [r8,#CLKMAN_CLKDIVN]
    118  1.1   mycroft 
    119  1.1   mycroft 	ldr	r1, Lclkman_locktime_data
    120  1.1   mycroft 	str	r1, [r8,#CLKMAN_LOCKTIME]
    121  1.1   mycroft 
    122  1.1   mycroft 	/* Initialize PLL */
    123  1.1   mycroft 	ldr	r1, Lclkman_mpllcon_data
    124  1.1   mycroft 	str	r1, [r8,#CLKMAN_MPLLCON]
    125  1.1   mycroft 	ldr	r1, Lclkman_upllcon_data
    126  1.1   mycroft 	str	r1, [r8,#CLKMAN_UPLLCON]
    127  1.1   mycroft 
    128  1.1   mycroft 	ldr	r9, =S3C2410_GPIO_BASE
    129  1.1   mycroft 	mov	r1, #0xd0
    130  1.1   mycroft 	str	r1, [r9, #GPIO_PFDAT]
    131  1.1   mycroft 
    132  1.1   mycroft #ifdef RAM_INIT_HOOK
    133  1.1   mycroft 	bl	RAM_INIT_HOOK
    134  1.1   mycroft #endif
    135  1.1   mycroft 
    136  1.1   mycroft running_on_ram:
    137  1.1   mycroft 	/* Change Bus mode to Sync */
    138  1.1   mycroft 	mrc	p15, 0, r0, c1, c0, 0
    139  1.1   mycroft 	bic	r0, r0, #(1<<31)		/* unset iA bit */
    140  1.1   mycroft 	orr	r0, r0, #(1<<30)		/* set nF bit */
    141  1.1   mycroft 	mcr	p15, 0, r0, c1, c0, 0
    142  1.1   mycroft 	nop
    143  1.1   mycroft 	nop
    144  1.1   mycroft 	nop
    145  1.1   mycroft 
    146  1.1   mycroft 	ldr	r9, =S3C2410_GPIO_BASE
    147  1.1   mycroft 	mov	r1, #0xb0
    148  1.1   mycroft 	str	r1, [r9, #GPIO_PFDAT]
    149  1.1   mycroft 
    150  1.1   mycroft 	/* set temporary stack */
    151  1.1   mycroft 	adr	sp, reset_vector
    152  1.1   mycroft 	/* do we have a room below? */
    153  1.1   mycroft 	ldr	r1, =(S3C2410_SDRAM_START+TEMP_STACK_SIZE)
    154  1.1   mycroft 	cmp	sp, r1
    155  1.1   mycroft 	/* otherwise use top area of RAM */
    156  1.1   mycroft 	ldrlo	sp, =(S3C2410_SDRAM_START+SDRAM_SIZE)
    157  1.1   mycroft 
    158  1.1   mycroft #ifdef IO_INIT_HOOK
    159  1.1   mycroft 	bl	IO_INIT_HOOK
    160  1.1   mycroft #endif
    161  1.1   mycroft 
    162  1.1   mycroft 	ldr	r9, =S3C2410_GPIO_BASE
    163  1.1   mycroft 	mov	r1, #0x70
    164  1.1   mycroft 	str	r1, [r9, #GPIO_PFDAT]
    165  1.1   mycroft 
    166  1.1   mycroft 	b	start
    167  1.1   mycroft 
    168  1.1   mycroft Lwdt_wtcon_addr:
    169  1.1   mycroft 	.word	(S3C2410_WDT_BASE + WDT_WTCON)
    170  1.1   mycroft 
    171  1.1   mycroft Lintctl_intmsk_addr:
    172  1.1   mycroft 	.word	(S3C2410_INTCTL_BASE + INTCTL_INTMSK)
    173  1.1   mycroft 
    174  1.1   mycroft 	.ltorg
    175  1.1   mycroft 
    176  1.1   mycroft Lclkman_locktime_data:
    177  1.1   mycroft 	.word	(0xffffff)
    178  1.1   mycroft 
    179  1.1   mycroft Lclkman_mpllcon_data:
    180  1.1   mycroft #if XTAL_CLK == 12000000 && FCLK == 180000000
    181  1.1   mycroft 	.word	0x00052011	/* M=82, P=1, S=1 */
    182  1.1   mycroft #else
    183  1.1   mycroft #error	illegal XTAL_CLK/FCLK combination
    184  1.1   mycroft #endif
    185  1.1   mycroft Lclkman_upllcon_data:
    186  1.1   mycroft 	.word	0x00078023	/* M=120, P=2, S=3 */
    187