ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / m68knommu / platform / 5307 / NETtel / crt0_ram.S
1 /*****************************************************************************/
2
3 /*
4  *      crt0_ram.S -- startup code for MCF5307 ColdFire based NETtel.
5  *
6  *      (C) Copyright 1999-2002, Greg Ungerer (gerg@snapgear.com).
7  *      Copyright (C) 2000  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 #elif defined(CONFIG_RAM8MB)
30 #define MEM_SIZE        0x00800000      /* Memory size 8Mb */
31 #else
32 #define MEM_SIZE        0x00400000      /* Memory size 4Mb */
33 #endif
34
35 /*****************************************************************************/
36
37 .global _start
38 .global _rambase
39 .global _ramvec
40 .global _ramstart
41 .global _ramend
42
43 /*****************************************************************************/
44
45 .data
46
47 /*
48  *      Set up the usable of RAM stuff. Size of RAM is determined then
49  *      an initial stack set up at the end.
50  */
51 _rambase:
52 .long   0
53 _ramvec:
54 .long   0
55 _ramstart:
56 .long   0
57 _ramend:
58 .long   0
59
60 /*****************************************************************************/
61
62 /*
63  *      The NETtel platform has some funky LEDs!
64  */
65 .global ppdata
66 ppdata:
67 .short  0x0000
68
69 .global ledbank
70 ledbank:
71 .byte   0xff
72
73 /*****************************************************************************/
74
75 .text
76
77 /*
78  *      This is the codes first entry point. This is where it all
79  *      begins...
80  */
81
82 _start:
83         nop                                     /* Filler */
84         move.w  #0x2700, %sr                    /* No interrupts */
85
86         /*
87          *      Set LEDs to known startup state.
88          */
89         move.l  #NETtel_LEDADDR, %a5            /* Addr of LED bank */
90         move.b  #0xff, (%a5)                    /* Turn them all off */
91
92
93         /*
94          *      Disable watchdog timer.
95          */
96         move.l  #MCF_MBAR, %a0                  /* Get MBAR address */
97         clr.l   %d0                             /* Disable SWT */
98         move.b  %d0, MCFSIM_SYPCR(%a0)
99         move.b  #0x55, %d0                      /* Clear SWT as well */
100         move.b  %d0, MCFSIM_SWSR(%a0)
101         move.b  #0xaa, %d0
102         move.b  %d0, MCFSIM_SWSR(%a0)
103         move.l  #0xffffffff, %d0                /* Mask out all interrupts */
104         move.l  %d0, MCFSIM_IMR(%a0)
105
106         /*
107          * Setup VBR here, otherwise buserror remap will not work.
108          * if dBug was active before (on my SBC with dBug 1.1 of Dec 16 1996)
109          *
110          * bkr@cut.de 19990306
111          *
112          * Note: this is because dBUG points VBR to ROM, making vectors read
113          * only, so the bus trap can't be changed. (RS)
114          */
115         move.l  #VBR_BASE, %a7                  /* Note VBR can't be read */
116         movec   %a7, %VBR
117         move.l  %a7, _ramvec                    /* Set up vector addr */
118         move.l  %a7, _rambase                   /* Set up base RAM addr */
119
120
121         /*
122          *      Determine size of RAM, then set up initial stack.
123          */
124         move.l  #MEM_SIZE, %a0
125
126         move.l  %a0, %d0                        /* Mem end addr is in a0 */
127         move.l  %d0, %sp                        /* Set up initial stack ptr */
128         move.l  %d0, _ramend                    /* Set end ram addr */
129
130         /*
131          *      Enable CPU internal cache.
132          */
133         move.l  #0x01000000, %d0                /* invalidate whole cache */
134         movec   %d0,%CACR
135         nop
136 #ifdef DEBUGGER_COMPATIBLE_CACHE
137         move.l  #0x0000c000, %d0                /* Set SDRAM cached only */
138 #else
139         move.l  #0x0000c020, %d0                /* Set SDRAM cached only (copyback) */
140 #endif
141         movec   %d0, %ACR0
142         move.l  #0x00000000, %d0                /* No other regions cached */
143         movec   %d0, %ACR1
144
145         /* Enable cache */
146         move.l  #0xa0000200, %d0
147         movec   %d0,%CACR
148         nop
149
150
151 #ifdef CONFIG_ROMFS_FS
152         /*
153          *      Move ROM filesystem above bss :-)
154          */
155         lea.l   _sbss, %a0                      /* Get start of bss */
156         lea.l   _ebss, %a1                      /* Set up destination  */
157         move.l  %a0, %a2                        /* Copy of bss start */
158
159         move.l  8(%a0), %d0                     /* Get size of ROMFS */
160         addq.l  #8, %d0                         /* Allow for rounding */
161         and.l   #0xfffffffc, %d0                /* Whole words */
162
163         add.l   %d0, %a0                        /* Copy from end */
164         add.l   %d0, %a1                        /* Copy from end */
165         move.l  %a1, _ramstart                  /* Set start of ram */
166
167 _copy_romfs:
168         move.l  -(%a0), %d0                     /* Copy dword */
169         move.l  %d0, -(%a1)
170         cmp.l   %a0, %a2                        /* Check if at end */
171         bne     _copy_romfs
172
173 #else /* CONFIG_ROMFS_FS */
174         lea.l   _ebss, %a1
175         move.l  %a1, _ramstart
176 #endif /* CONFIG_ROMFS_FS */
177
178
179         /*
180          *      Zero out the bss region.
181          */
182         lea.l   _sbss, %a0                      /* Get start of bss */
183         lea.l   _ebss, %a1                      /* Get end of bss */
184         clr.l   %d0                             /* Set value */
185 _clear_bss:
186         move.l  %d0, (%a0)+                     /* Clear each word */
187         cmp.l   %a0, %a1                        /* Check if at end */
188         bne     _clear_bss
189
190         /*
191          * load the current task pointer and stack
192          */
193         lea     init_thread_union, %a0
194         lea     0x2000(%a0), %sp
195
196         /*
197          *      Assember start up done, start code proper.
198          */
199         jsr     start_kernel                    /* Start Linux kernel */
200
201 _exit:
202         jmp     _exit                           /* Should never get here */
203
204 /*****************************************************************************/