ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / m68knommu / platform / 5307 / MP3 / crt0_ram.S
1 /*****************************************************************************/
2
3 /*
4  *      crt0_ram.S -- startup code for MCF5307 ColdFire based MP3.
5  *
6  *      (C) Copyright 1999-2002, Greg Ungerer (gerg@snapgear.com).
7  *      Copyright (C) 2000-2001  Lineo Inc. (www.lineo.com) 
8  *
9  *      1999/02/24 Modified for the 5307 processor David W. Miller
10  */
11
12 /*****************************************************************************/
13
14 #include "linux/autoconf.h"
15 #include "asm/coldfire.h"
16 #include "asm/mcfsim.h"
17 #include "asm/nettel.h"
18
19 /*****************************************************************************/
20
21 /*
22  *      SnapGear/NETtel board memory setup.
23  */
24 #define MEM_BASE        0x00000000      /* Memory base at address 0 */
25 #define VBR_BASE        MEM_BASE        /* Vector address */
26
27 #if defined(CONFIG_RAM16MB)
28 #define MEM_SIZE        0x01000000      /* Memory size 16Mb */
29 #else
30 #define MEM_SIZE        0x00800000      /* Memory size 8Mb */
31 #endif
32
33 /*****************************************************************************/
34
35 .global _start
36 .global _rambase
37 .global _ramvec
38 .global _ramstart
39 .global _ramend
40
41 /*****************************************************************************/
42
43 .data
44
45 /*
46  *      Set up the usable of RAM stuff. Size of RAM is determined then
47  *      an initial stack set up at the end.
48  */
49 _rambase:
50 .long   0
51 _ramvec:
52 .long   0
53 _ramstart:
54 .long   0
55 _ramend:
56 .long   0
57
58 /*****************************************************************************/
59
60 .text
61
62 /*
63  *      This is the codes first entry point. This is where it all
64  *      begins...
65  */
66
67 _start:
68         nop                                     /* Filler */
69         move.w  #0x2700, %sr                    /* No interrupts */
70
71         /*
72          *      Disable watchdog timer.
73          */
74         move.l  #MCF_MBAR, %a0                  /* Get MBAR address */
75         clr.l   %d0                             /* Disable SWT */
76         move.b  %d0, MCFSIM_SYPCR(%a0)
77         move.b  #0x55, %d0                      /* Clear SWT as well */
78         move.b  %d0, MCFSIM_SWSR(%a0)
79         move.b  #0xaa, %d0
80         move.b  %d0, MCFSIM_SWSR(%a0)
81         move.l  #0xffffffff, %d0                /* Mask out all interrupts */
82         move.l  %d0, MCFSIM_IMR(%a0)
83
84         /*
85          * Setup VBR here, otherwise buserror remap will not work.
86          * if dBug was active before (on my SBC with dBug 1.1 of Dec 16 1996)
87          *
88          * bkr@cut.de 19990306
89          *
90          * Note: this is because dBUG points VBR to ROM, making vectors read
91          * only, so the bus trap can't be changed. (RS)
92          */
93         move.l  #VBR_BASE, %a7                  /* Note VBR can't be read */
94         movec   %a7, %VBR
95         move.l  %a7, _ramvec                    /* Set up vector addr */
96         move.l  %a7, _rambase                   /* Set up base RAM addr */
97
98
99         /*
100          *      Determine size of RAM, then set up initial stack.
101          */
102         move.l  #MEM_SIZE, %a0
103
104         move.l  %a0, %d0                        /* Mem end addr is in a0 */
105         move.l  %d0, %sp                        /* Set up initial stack ptr */
106         move.l  %d0, _ramend                    /* Set end ram addr */
107
108         /*
109          *      Enable CPU internal cache.
110          */
111         move.l  #0x01000000, %d0                /* invalidate whole cache */
112         movec   %d0,%CACR
113         nop
114
115         /* MUST be write-through for DMA to work... */
116         /* This also makes this debugger safe */
117         move.l  #0x0000c000, %d0                /* Set SDRAM cached only */
118         movec   %d0, %ACR0
119         move.l  #0x00000000, %d0                /* No other regions cached */
120         movec   %d0, %ACR1
121
122         /* Enable cache */
123         move.l  #0xa0000200, %d0
124         movec   %d0,%CACR
125         nop
126
127
128 #ifdef CONFIG_ROMFS_FS
129         /*
130          *      Move ROM filesystem above bss :-)
131          */
132         lea.l   _sbss, %a0                      /* Get start of bss */
133         lea.l   _ebss, %a1                      /* Set up destination  */
134         move.l  %a0, %a2                        /* Copy of bss start */
135
136         move.l  8(%a0), %d0                     /* Get size of ROMFS */
137         addq.l  #8, %d0                         /* Allow for rounding */
138         and.l   #0xfffffffc, %d0                /* Whole words */
139
140         add.l   %d0, %a0                        /* Copy from end */
141         add.l   %d0, %a1                        /* Copy from end */
142         move.l  %a1, _ramstart                  /* Set start of ram */
143
144 _copy_romfs:
145         move.l  -(%a0), %d0                     /* Copy dword */
146         move.l  %d0, -(%a1)
147         cmp.l   %a0, %a2                        /* Check if at end */
148         bne     _copy_romfs
149
150 #else /* CONFIG_ROMFS_FS */
151         lea.l   _ebss, %a1
152         move.l  %a1, _ramstart
153 #endif /* CONFIG_ROMFS_FS */
154
155
156         /*
157          *      Zero out the bss region.
158          */
159         lea.l   _sbss, %a0                      /* Get start of bss */
160         lea.l   _ebss, %a1                      /* Get end of bss */
161         clr.l   %d0                             /* Set value */
162 _clear_bss:
163         move.l  %d0, (%a0)+                     /* Clear each word */
164         cmp.l   %a0, %a1                        /* Check if at end */
165         bne     _clear_bss
166
167         /*
168          * load the current task pointer and stack
169          */
170         lea     init_thread_union, %a0
171         lea     0x2000(%a0), %sp
172
173         /*
174          *      Assember start up done, start code proper.
175          */
176         jsr     start_kernel                    /* Start Linux kernel */
177
178 _exit:
179         jmp     _exit                           /* Should never get here */
180
181 /*****************************************************************************/