Merge branch 'master' of git://www.denx.de/git/u-boot-video
[oweals/u-boot.git] / cpu / arm920t / start.S
index f3481936425902d27c19bf12b53c8b4adff6a8ec..acc00ad9706309be4e0bdb4d564e61903fb688bd 100644 (file)
@@ -27,7 +27,7 @@
 
 #include <config.h>
 #include <version.h>
-
+#include <status_led.h>
 
 /*
  *************************************************************************
@@ -39,7 +39,7 @@
 
 
 .globl _start
-_start:        b       reset
+_start:        b       start_code
        ldr     pc, _undefined_instruction
        ldr     pc, _software_interrupt
        ldr     pc, _prefetch_abort
@@ -62,7 +62,7 @@ _fiq:                 .word fiq
 /*
  *************************************************************************
  *
- * Startup Code (reset vector)
+ * Startup Code (called from the ARM reset exception vector)
  *
  * do important init only if we don't start from memory!
  * relocate armboot to ram
@@ -104,10 +104,10 @@ FIQ_STACK_START:
 
 
 /*
- * the actual reset code
+ * the actual start code
  */
 
-reset:
+start_code:
        /*
         * set the cpu to SVC32 mode
         */
@@ -116,19 +116,37 @@ reset:
        orr     r0,r0,#0xd3
        msr     cpsr,r0
 
-/* turn off the watchdog */
-#if defined(CONFIG_S3C2400)
-# define pWTCON                0x15300000
-# define INTMSK                0x14400008      /* Interupt-Controller base addresses */
-# define CLKDIVN       0x14800014      /* clock divisor register */
-#elif defined(CONFIG_S3C2410)
-# define pWTCON                0x53000000
-# define INTMSK                0x4A000008      /* Interupt-Controller base addresses */
-# define INTSUBMSK     0x4A00001C
-# define CLKDIVN       0x4C000014      /* clock divisor register */
+       bl coloured_LED_init
+       bl red_LED_on
+
+#if    defined(CONFIG_AT91RM9200DK) || defined(CONFIG_AT91RM9200EK) || defined(CONFIG_AT91RM9200DF)
+       /*
+        * relocate exception table
+        */
+       ldr     r0, =_start
+       ldr     r1, =0x0
+       mov     r2, #16
+copyex:
+       subs    r2, r2, #1
+       ldr     r3, [r0], #4
+       str     r3, [r1], #4
+       bne     copyex
 #endif
 
 #if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410)
+       /* turn off the watchdog */
+
+# if defined(CONFIG_S3C2400)
+#  define pWTCON               0x15300000
+#  define INTMSK               0x14400008      /* Interupt-Controller base addresses */
+#  define CLKDIVN      0x14800014      /* clock divisor register */
+#else
+#  define pWTCON               0x53000000
+#  define INTMSK               0x4A000008      /* Interupt-Controller base addresses */
+#  define INTSUBMSK    0x4A00001C
+#  define CLKDIVN      0x4C000014      /* clock divisor register */
+# endif
+
        ldr     r0, =pWTCON
        mov     r1, #0x0
        str     r1, [r0]
@@ -156,10 +174,13 @@ reset:
         * we do sys-critical inits only at reboot,
         * not when booting from ram!
         */
-#ifdef CONFIG_INIT_CRITICAL
+#ifndef CONFIG_SKIP_LOWLEVEL_INIT
        bl      cpu_init_crit
 #endif
 
+#ifndef        CONFIG_AT91RM9200
+
+#ifndef CONFIG_SKIP_RELOCATE_UBOOT
 relocate:                              /* relocate U-Boot to RAM           */
        adr     r0, _start              /* r0 <- current position of code   */
        ldr     r1, _TEXT_BASE          /* test if we run from flash or RAM */
@@ -176,7 +197,8 @@ copy_loop:
        stmia   r1!, {r3-r10}           /* copy to   target address [r1]    */
        cmp     r0, r2                  /* until source end addreee [r2]    */
        ble     copy_loop
-
+#endif /* CONFIG_SKIP_RELOCATE_UBOOT */
+#endif
        /* Set up the stack                                                 */
 stack_setup:
        ldr     r0, _TEXT_BASE          /* upper 128 KiB: relocated uboot   */
@@ -197,27 +219,6 @@ clbss_l:str        r2, [r0]                /* clear loop...                    */
        cmp     r0, r1
        ble     clbss_l
 
-#if 0
-       /* try doing this stuff after the relocation */
-       ldr     r0, =pWTCON
-       mov     r1, #0x0
-       str     r1, [r0]
-
-       /*
-        * mask all IRQs by setting all bits in the INTMR - default
-        */
-       mov     r1, #0xffffffff
-       ldr     r0, =INTMR
-       str     r1, [r0]
-
-       /* FCLK:HCLK:PCLK = 1:2:4 */
-       /* default FCLK is 120 MHz ! */
-       ldr     r0, =CLKDIVN
-       mov     r1, #3
-       str     r1, [r0]
-       /* END stuff after relocation */
-#endif
-
        ldr     pc, _start_armboot
 
 _start_armboot:        .word start_armboot
@@ -235,6 +236,7 @@ _start_armboot:     .word start_armboot
  */
 
 
+#ifndef CONFIG_SKIP_LOWLEVEL_INIT
 cpu_init_crit:
        /*
         * flush v4 I/D caches
@@ -253,18 +255,20 @@ cpu_init_crit:
        orr     r0, r0, #0x00001000     @ set bit 12 (I) I-Cache
        mcr     p15, 0, r0, c1, c0, 0
 
-
        /*
         * before relocating, we have to setup RAM timing
         * because memory timing is board-dependend, you will
-        * find a memsetup.S in your board directory.
+        * find a lowlevel_init.S in your board directory.
         */
        mov     ip, lr
-       bl      memsetup
-       mov     lr, ip
+#if    defined(CONFIG_AT91RM9200DK) || defined(CONFIG_AT91RM9200EK) || defined(CONFIG_AT91RM9200DF)
 
+#else
+       bl      lowlevel_init
+#endif
+       mov     lr, ip
        mov     pc, lr
-
+#endif /* CONFIG_SKIP_LOWLEVEL_INIT */
 
 /*
  *************************************************************************
@@ -325,12 +329,12 @@ cpu_init_crit:
        .macro  irq_save_user_regs
        sub     sp, sp, #S_FRAME_SIZE
        stmia   sp, {r0 - r12}                  @ Calling r0-r12
-       add     r8, sp, #S_PC
-       stmdb   r8, {sp, lr}^                   @ Calling SP, LR
-       str     lr, [r8, #0]                    @ Save calling PC
+       add     r7, sp, #S_PC
+       stmdb   r7, {sp, lr}^                   @ Calling SP, LR
+       str     lr, [r7, #0]                    @ Save calling PC
        mrs     r6, spsr
-       str     r6, [r8, #4]                    @ Save CPSR
-       str     r0, [r8, #8]                    @ Save OLD_R0
+       str     r6, [r7, #4]                    @ Save CPSR
+       str     r0, [r7, #8]                    @ Save OLD_R0
        mov     r0, sp
        .endm
 
@@ -431,39 +435,3 @@ fiq:
        bl      do_fiq
 
 #endif
-
-       .align  5
-.globl reset_cpu
-reset_cpu:
-#ifdef CONFIG_S3C2400
-       bl      disable_interrupts
-# ifdef CONFIG_TRAB
-       bl      disable_vfd
-# endif
-       ldr     r1, _rWTCON
-       ldr     r2, _rWTCNT
-       /* Disable watchdog */
-       mov     r3, #0x0000
-       str     r3, [r1]
-       /* Initialize watchdog timer count register */
-       mov     r3, #0x0001
-       str     r3, [r2]
-       /* Enable watchdog timer; assert reset at timer timeout */
-       mov     r3, #0x0021
-       str     r3, [r1]
-_loop_forever:
-       b       _loop_forever
-_rWTCON:
-       .word   0x15300000
-_rWTCNT:
-       .word   0x15300008
-#else /* ! CONFIG_S3C2400 */
-       mov     ip, #0
-       mcr     p15, 0, ip, c7, c7, 0           @ invalidate cache
-       mcr     p15, 0, ip, c8, c7, 0           @ flush TLB (v4)
-       mrc     p15, 0, ip, c1, c0, 0           @ get ctrl register
-       bic     ip, ip, #0x000f                 @ ............wcam
-       bic     ip, ip, #0x2100                 @ ..v....s........
-       mcr     p15, 0, ip, c1, c0, 0           @ ctrl register
-       mov     pc, r0
-#endif /* CONFIG_S3C2400 */