]> git.sur5r.net Git - u-boot/blobdiff - cpu/arm925t/start.S
Merge branch 'master' of git://git.denx.de/u-boot-ppc4xx
[u-boot] / cpu / arm925t / start.S
index 2115fb30e9ab92df6101a9056ea4f462152f1f20..567e80479e2f68fdd5f75cf1052bd1aa57121e9f 100644 (file)
@@ -7,9 +7,9 @@
  *
  *  Copyright (c) 2001 Marius Gröger <mag@sysgo.de>
  *  Copyright (c) 2002 Alex Züpke <azu@sysgo.de>
- *  Copyright (c) 2002 Gary Jennejohn <gj@denx.de>
+ *  Copyright (c) 2002 Gary Jennejohn <garyj@denx.de>
  *  Copyright (c) 2003 Richard Woodruff <r-woodruff2@ti.com>
- *  Copyright (c) 2003 Kshitij          <kshitij@ti.com>
+ *  Copyright (c) 2003 Kshitij  <kshitij@ti.com>
  *
  * See file CREDITS for list of people who contributed to this
  * project.
@@ -31,7 +31,6 @@
  */
 
 
-
 #include <config.h>
 #include <version.h>
 
@@ -82,9 +81,6 @@ _fiq:                 .word fiq
  *************************************************************************
  */
 
-/*
- * CFG_MEM_END is in the board dependent config-file (configs/config_BOARD.h)
- */
 _TEXT_BASE:
        .word   TEXT_BASE
 
@@ -93,24 +89,15 @@ _armboot_start:
        .word _start
 
 /*
- * Note: _armboot_end_data and _armboot_end are defined
- * by the (board-dependent) linker script.
- * _armboot_end_data is the first usable FLASH address after armboot
+ * These are defined in the board-specific linker script.
  */
-.globl _armboot_end_data
-_armboot_end_data:
-       .word armboot_end_data
-.globl _armboot_end
-_armboot_end:
-       .word armboot_end
+.globl _bss_start
+_bss_start:
+       .word __bss_start
 
-/*
- * _armboot_real_end is the first usable RAM address behind armboot
- * and the various stacks
- */
-.globl _armboot_real_end
-_armboot_real_end:
-       .word 0x0badc0de
+.globl _bss_end
+_bss_end:
+       .word _end
 
 #ifdef CONFIG_USE_IRQ
 /* IRQ stack memory (calculated at run-time) */
@@ -137,14 +124,14 @@ reset:
        bic     r0,r0,#0x1f
        orr     r0,r0,#0xd3
        msr     cpsr,r0
-       
+
        /*
         * Set up 925T mode
         */
        mov r1, #0x81               /* Set ARM925T configuration. */
        mcr p15, 0, r1, c15, c1, 0  /* Write ARM925T configuration register. */
 
-       /* 
+       /*
         * turn off the watchdog, unlock/diable sequence
         */
        mov  r1, #0xF5
@@ -162,9 +149,9 @@ reset:
        ldr r0, =REG_IHL2_MIR
        str r1, [r0]
 
-       /* 
+       /*
         * wait for dpll to lock
-        */       
+        */
        ldr  r0, =CK_DPLL1
        mov  r1, #0x10
        strh r1, [r0]
@@ -172,34 +159,53 @@ poll1:
        ldrh r1, [r0]
        ands r1, r1, #0x01
        beq poll1
-       bl  cpu_init_crit
 
-relocate:
        /*
-        * relocate armboot to RAM
+        * we do sys-critical inits only at reboot,
+        * not when booting from ram!
         */
-       adr     r0, _start              /* r0 <- current position of code */
+#ifndef CONFIG_SKIP_LOWLEVEL_INIT
+       bl  cpu_init_crit
+#endif
+
+#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 */
+       cmp     r0, r1                  /* don't reloc during debug         */
+       beq     stack_setup
+
        ldr     r2, _armboot_start
-       ldr     r3, _armboot_end
-       sub     r2, r3, r2              /* r2 <- size of armboot */
-       ldr     r1, _TEXT_BASE          /* r1 <- destination address */
-       add     r2, r0, r2              /* r2 <- source end address */
+       ldr     r3, _bss_start
+       sub     r2, r3, r2              /* r2 <- size of armboot            */
+       add     r2, r0, r2              /* r2 <- source end address         */
 
-       /*
-        * r0 = source address
-        * r1 = target address
-        * r2 = source end address
-        */
 copy_loop:
-       ldmia   r0!, {r3-r10}
-       stmia   r1!, {r3-r10}
-       cmp     r0, r2
+       ldmia   r0!, {r3-r10}           /* copy from source address [r0]    */
+       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 */
 
-       /* set up the stack */
-       ldr     r0, _armboot_end
-       add     r0, r0, #CONFIG_STACKSIZE
-       sub     sp, r0, #12             /* leave 3 words for abort-stack */
+       /* Set up the stack                                                 */
+stack_setup:
+       ldr     r0, _TEXT_BASE          /* upper 128 KiB: relocated uboot   */
+       sub     r0, r0, #CONFIG_SYS_MALLOC_LEN  /* malloc area                      */
+       sub     r0, r0, #CONFIG_SYS_GBL_DATA_SIZE /* bdinfo                        */
+#ifdef CONFIG_USE_IRQ
+       sub     r0, r0, #(CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ)
+#endif
+       sub     sp, r0, #12             /* leave 3 words for abort-stack    */
+
+clear_bss:
+       ldr     r0, _bss_start          /* find start of bss segment        */
+       ldr     r1, _bss_end            /* stop here                        */
+       mov     r2, #0x00000000         /* clear                            */
+
+clbss_l:str    r2, [r0]                /* clear loop...                    */
+       add     r0, r0, #4
+       cmp     r0, r1
+       ble     clbss_l
 
        ldr     pc, _start_armboot
 
@@ -240,7 +246,7 @@ cpu_init_crit:
         * Go setup Memory and board specific bits prior to relocation.
         */
        mov     ip, lr          /* perserve link reg across call */
-       bl      platformsetup   /* go setup pll,mux,memory */
+       bl      lowlevel_init   /* go setup pll,mux,memory */
        mov     lr, ip          /* restore link */
        mov     pc, lr          /* back to my caller */
 /*
@@ -288,9 +294,9 @@ cpu_init_crit:
        sub     sp, sp, #S_FRAME_SIZE           @ carve out a frame on current user stack
        stmia   sp, {r0 - r12}                  @ Save user registers (now in svc mode) r0-r12
 
-       ldr     r2, _armboot_end                @ find top of stack
-       add     r2, r2, #CONFIG_STACKSIZE       @ find base of normal stack
-       sub     r2, r2, #8                      @ set base 2 words into abort stack
+       ldr     r2, _armboot_start
+       sub     r2, r2, #(CONFIG_STACKSIZE+CONFIG_SYS_MALLOC_LEN)
+       sub     r2, r2, #(CONFIG_SYS_GBL_DATA_SIZE+8)  @ set base 2 words into abort stack
        ldmia   r2, {r2 - r3}                   @ get values for "aborted" pc and cpsr (into parm regs)
        add     r0, sp, #S_FRAME_SIZE           @ grab pointer to old stack
 
@@ -321,9 +327,9 @@ cpu_init_crit:
        .endm
 
        .macro get_bad_stack
-       ldr     r13, _armboot_end               @ get bottom of stack (into sp by by user stack pointer).
-       add     r13, r13, #CONFIG_STACKSIZE     @ head to reserved words at the top of the stack
-       sub     r13, r13, #8                    @ reserved a couple spots in abort stack
+       ldr     r13, _armboot_start             @ setup our mode stack
+       sub     r13, r13, #(CONFIG_STACKSIZE+CONFIG_SYS_MALLOC_LEN)
+       sub     r13, r13, #(CONFIG_SYS_GBL_DATA_SIZE+8) @ reserved a couple spots in abort stack
 
        str     lr, [r13]                       @ save caller lr in position 0 of saved stack
        mrs     lr, spsr                        @ get the spsr
@@ -351,31 +357,31 @@ cpu_init_crit:
 undefined_instruction:
        get_bad_stack
        bad_save_user_regs
-       bl      do_undefined_instruction
+       bl      do_undefined_instruction
 
        .align  5
 software_interrupt:
        get_bad_stack
        bad_save_user_regs
-       bl      do_software_interrupt
+       bl      do_software_interrupt
 
        .align  5
 prefetch_abort:
        get_bad_stack
        bad_save_user_regs
-       bl      do_prefetch_abort
+       bl      do_prefetch_abort
 
        .align  5
 data_abort:
        get_bad_stack
        bad_save_user_regs
-       bl      do_data_abort
+       bl      do_data_abort
 
        .align  5
 not_used:
        get_bad_stack
        bad_save_user_regs
-       bl      do_not_used
+       bl      do_not_used
 
 #ifdef CONFIG_USE_IRQ
 
@@ -383,7 +389,7 @@ not_used:
 irq:
        get_irq_stack
        irq_save_user_regs
-       bl      do_irq
+       bl      do_irq
        irq_restore_user_regs
 
        .align  5
@@ -391,7 +397,7 @@ fiq:
        get_fiq_stack
        /* someone ought to write a more effiction fiq_save_user_regs */
        irq_save_user_regs
-       bl      do_fiq
+       bl      do_fiq
        irq_restore_user_regs
 
 #else
@@ -400,13 +406,13 @@ fiq:
 irq:
        get_bad_stack
        bad_save_user_regs
-       bl      do_irq
+       bl      do_irq
 
        .align  5
 fiq:
        get_bad_stack
        bad_save_user_regs
-       bl      do_fiq
+       bl      do_fiq
 
 #endif
 
@@ -414,10 +420,9 @@ fiq:
 .globl reset_cpu
 reset_cpu:
        ldr     r1, rstctl1     /* get clkm1 reset ctl */
-       mov     r3, #0x0        
-       strh    r3, [r1]        /* clear it */
-       mov     r3, #0x8
-       strh    r3, [r1]        /* force dsp+arm reset */
+       mov     r3, #0x3        /* dsp_en + arm_rst = global reset */
+       strh    r3, [r1]        /* force reset */
+       mov     r0, r0
 _loop_forever:
        b       _loop_forever
 rstctl1: