/spare/repo/netdev-2.6 branch 'master'
[deliverable/linux.git] / arch / cris / arch-v10 / kernel / head.S
1 /* $Id: head.S,v 1.10 2005/06/20 05:12:54 starvik Exp $
2 *
3 * Head of the kernel - alter with care
4 *
5 * Copyright (C) 2000, 2001 Axis Communications AB
6 *
7 * Authors: Bjorn Wesen (bjornw@axis.com)
8 *
9 * $Log: head.S,v $
10 * Revision 1.10 2005/06/20 05:12:54 starvik
11 * Remove unnecessary diff to kernel.org tree
12 *
13 * Revision 1.9 2004/12/13 12:21:51 starvik
14 * Added I/O and DMA allocators from Linux 2.4
15 *
16 * Revision 1.8 2004/11/22 11:41:14 starvik
17 * Kernel command line may be supplied to kernel. Not used by Axis but may
18 * be used by customers.
19 *
20 * Revision 1.7 2004/05/14 07:58:01 starvik
21 * Merge of changes from 2.4
22 *
23 * Revision 1.6 2003/04/28 05:31:46 starvik
24 * Added section attributes
25 *
26 * Revision 1.5 2002/12/11 15:42:02 starvik
27 * Extracted v10 (ETRAX 100LX) specific stuff from arch/cris/kernel/*.c
28 *
29 * Revision 1.4 2002/11/07 09:00:44 starvik
30 * Names changed for init sections
31 * init_task_union -> init_thread_union
32 *
33 * Revision 1.3 2002/02/05 15:38:23 bjornw
34 * Oops.. non-CRAMFS_MAGIC should jump over the copying, not into it...
35 *
36 * Revision 1.2 2001/12/18 13:35:19 bjornw
37 * Applied the 2.4.13->2.4.16 CRIS patch to 2.5.1 (is a copy of 2.4.15).
38 *
39 * Revision 1.43 2001/11/08 15:09:43 starvik
40 * Only start MII clock if Ethernet is configured
41 *
42 * Revision 1.42 2001/11/08 14:37:34 starvik
43 * Start MII clock early to make sure that it is running at tranceiver reset
44 *
45 * Revision 1.41 2001/10/29 14:55:58 pkj
46 * Corrected pa$r0 to par0.
47 *
48 * Revision 1.40 2001/10/03 14:59:57 pkj
49 * Added support for resetting the Bluetooth hardware.
50 *
51 * Revision 1.39 2001/10/01 14:45:03 bjornw
52 * Removed underscores and added register prefixes
53 *
54 * Revision 1.38 2001/09/21 07:14:11 jonashg
55 * Made root filesystem (cramfs) use mtdblock driver when booting from flash.
56 *
57 * Revision 1.37 2001/09/11 13:44:29 orjanf
58 * Decouple usage of serial ports for debug and kgdb.
59 *
60 * Revision 1.36 2001/06/29 12:39:31 pkj
61 * Added support for mirroring the first flash to just below the
62 * second one, to make them look consecutive to cramfs.
63 *
64 * Revision 1.35 2001/06/25 14:07:00 hp
65 * Fix review comment.
66 * * head.S: Use IO_STATE, IO_FIELD and IO_MASK constructs instead of
67 * magic numbers. Add comment that -traditional must not be used.
68 * * entry.S (SYMBOL_NAME): Change redefinition to use ## concatenation.
69 * Correct and update comment.
70 * * Makefile (.S.o): Don't use -traditional. Add comment why the
71 * toplevel rule can't be used (now that there's a reason).
72 *
73 * Revision 1.34 2001/05/15 07:08:14 hp
74 * Tweak "notice" to reflect that both r8 r9 are used
75 *
76 * Revision 1.33 2001/05/15 06:40:05 hp
77 * Put bulk of code in .text.init, data in .data.init
78 *
79 * Revision 1.32 2001/05/15 06:18:56 hp
80 * Execute review comment: s/bcc/bhs/g; s/bcs/blo/g
81 *
82 * Revision 1.31 2001/05/15 06:08:40 hp
83 * Add sentence about autodetecting the bit31-MMU-bug
84 *
85 * Revision 1.30 2001/05/15 06:00:05 hp
86 * Update comment: LOW_MAP is not forced on xsim anymore.
87 *
88 * Revision 1.29 2001/04/18 12:51:59 orjanf
89 * * Reverted review change regarding the use of bcs/bcc.
90 * * Removed non-working LED-clearing code.
91 *
92 * Revision 1.28 2001/04/17 13:58:39 orjanf
93 * * Renamed CONFIG_KGDB to CONFIG_ETRAX_KGDB.
94 *
95 * Revision 1.27 2001/04/17 11:42:35 orjanf
96 * Changed according to review:
97 * * Added comment explaining memory map bug.
98 * * Changed bcs and bcc to blo and bhs, respectively.
99 * * Removed mentioning of Stallone and Olga boards.
100 *
101 * Revision 1.26 2001/04/06 12:31:07 jonashg
102 * Check for cramfs in flash before RAM instead of RAM before flash.
103 *
104 * Revision 1.25 2001/04/04 06:23:53 starvik
105 * Initialize DRAM if not already initialized
106 *
107 * Revision 1.24 2001/04/03 11:12:00 starvik
108 * Removed dram init (done by rescue or etrax100boot
109 * Corrected include
110 *
111 * Revision 1.23 2001/04/03 09:53:03 starvik
112 * Include hw_settings.S
113 *
114 * Revision 1.22 2001/03/26 14:23:26 bjornw
115 * Namechange of some config options
116 *
117 * Revision 1.21 2001/03/08 12:14:41 bjornw
118 * * Config name for ETRAX IDE was renamed
119 * * Removed G27 auto-setting when JULIETTE is chosen (need to make this
120 * a new config option later)
121 *
122 * Revision 1.20 2001/02/23 12:47:56 bjornw
123 * MMU regs during LOW_MAP updated to reflect a newer reality
124 *
125 * Revision 1.19 2001/02/19 11:12:07 bjornw
126 * Changed comment header format
127 *
128 * Revision 1.18 2001/02/15 07:25:38 starvik
129 * Added support for synchronous serial ports
130 *
131 * Revision 1.17 2001/02/08 15:53:13 starvik
132 * Last commit removed some important ifdefs
133 *
134 * Revision 1.16 2001/02/08 15:20:38 starvik
135 * Include dram_init.S as inline
136 *
137 * Revision 1.15 2001/01/29 18:12:01 bjornw
138 * Corrected some comments
139 *
140 * Revision 1.14 2001/01/29 13:11:29 starvik
141 * Include dram_init.S (with DRAM/SDRAM initialization)
142 *
143 * Revision 1.13 2001/01/23 14:54:57 markusl
144 * Updated for USB
145 * i.e. added r_gen_config settings
146 *
147 * Revision 1.12 2001/01/19 16:16:29 perf
148 * Added temporary mapping of 0x0c->0x0c to avoid flash loading confusion.
149 * Renamed serial options from ETRAX100 to ETRAX.
150 *
151 * Revision 1.11 2001/01/16 16:31:38 bjornw
152 * * Changed name and semantics of running_from_flash to romfs_in_flash,
153 * set by head.S to indicate to setup.c whether there is a cramfs image
154 * after the kernels BSS or not. Should work for all three boot-cases
155 * (DRAM with cramfs in DRAM, DRAM with cramfs in flash (compressed boot),
156 * and flash with cramfs in flash)
157 *
158 * Revision 1.10 2001/01/16 14:12:21 bjornw
159 * * Check for cramfs start passed in r9 from the decompressor, if all other
160 * cramfs options fail (if we boot from DRAM but don't find a cramfs image
161 * after the kernel in DRAM, it is probably still in the flash)
162 * * Check magic in cramfs detection when booting from flash directly
163 *
164 * Revision 1.9 2001/01/15 17:17:02 bjornw
165 * * Corrected the code that detects the cramfs lengths
166 * * Added a comment saying that the above does not work due to other
167 * reasons..
168 *
169 * Revision 1.8 2001/01/15 16:27:51 jonashg
170 * Made boot after flashing work.
171 * * end destination is __vmlinux_end in RAM.
172 * * _romfs_start moved because of virtual memory.
173 *
174 * Revision 1.7 2000/11/21 13:55:29 bjornw
175 * Use CONFIG_CRIS_LOW_MAP for the low VM map instead of explicit CPU type
176 *
177 * Revision 1.6 2000/10/06 12:36:55 bjornw
178 * Forgot swapper_pg_dir when changing memory map..
179 *
180 * Revision 1.5 2000/10/04 16:49:30 bjornw
181 * * Fixed memory mapping in LX
182 * * Check for cramfs instead of romfs
183 *
184 */
185
186 #include <linux/config.h>
187 #define ASSEMBLER_MACROS_ONLY
188 /* The IO_* macros use the ## token concatenation operator, so
189 -traditional must not be used when assembling this file. */
190 #include <asm/arch/sv_addr_ag.h>
191
192 #define CRAMFS_MAGIC 0x28cd3d45
193 #define RAM_INIT_MAGIC 0x56902387
194 #define COMMAND_LINE_MAGIC 0x87109563
195
196 #define START_ETHERNET_CLOCK IO_STATE(R_NETWORK_GEN_CONFIG, enable, on) |\
197 IO_STATE(R_NETWORK_GEN_CONFIG, phy, mii_clk)
198
199 ;; exported symbols
200
201 .globl etrax_irv
202 .globl romfs_start
203 .globl romfs_length
204 .globl romfs_in_flash
205 .globl swapper_pg_dir
206
207 .text
208
209 ;; This is the entry point of the kernel. We are in supervisor mode.
210 ;; 0x00000000 if Flash, 0x40004000 if DRAM
211 ;; since etrax actually starts at address 2 when booting from flash, we
212 ;; put a nop (2 bytes) here first so we dont accidentally skip the di
213 ;;
214 ;; NOTICE! The registers r8 and r9 are used as parameters carrying
215 ;; information from the decompressor (if the kernel was compressed).
216 ;; They should not be used in the code below until read.
217
218 nop
219 di
220
221 ;; First setup the kseg_c mapping from where the kernel is linked
222 ;; to 0x40000000 (where the actual DRAM resides) otherwise
223 ;; we cannot do very much! See arch/cris/README.mm
224 ;;
225 ;; Notice that since we're potentially running at 0x00 or 0x40 right now,
226 ;; we will get a fault as soon as we enable the MMU if we dont
227 ;; temporarily map those segments linearily.
228 ;;
229 ;; Due to a bug in Etrax-100 LX version 1 we need to map the memory
230 ;; slightly different. The bug is that you can't remap bit 31 of
231 ;; an address. Though we can check the version register for
232 ;; whether the bug is present, some constants would then have to
233 ;; be variables, so we don't. The drawback is that you can "only" map
234 ;; 1G per process with CONFIG_CRIS_LOW_MAP.
235
236 #ifdef CONFIG_CRIS_LOW_MAP
237 ; kseg mappings, temporary map of 0xc0->0x40
238 move.d IO_FIELD (R_MMU_KBASE_HI, base_c, 4) \
239 | IO_FIELD (R_MMU_KBASE_HI, base_b, 0xb) \
240 | IO_FIELD (R_MMU_KBASE_HI, base_9, 9) \
241 | IO_FIELD (R_MMU_KBASE_HI, base_8, 8), $r0
242 move.d $r0, [R_MMU_KBASE_HI]
243
244 ; temporary map of 0x40->0x40 and 0x60->0x40
245 move.d IO_FIELD (R_MMU_KBASE_LO, base_6, 4) \
246 | IO_FIELD (R_MMU_KBASE_LO, base_4, 4), $r0
247 move.d $r0, [R_MMU_KBASE_LO]
248
249 ; mmu enable, segs e,c,b,a,6,5,4,0 segment mapped
250 move.d IO_STATE (R_MMU_CONFIG, mmu_enable, enable) \
251 | IO_STATE (R_MMU_CONFIG, inv_excp, enable) \
252 | IO_STATE (R_MMU_CONFIG, acc_excp, enable) \
253 | IO_STATE (R_MMU_CONFIG, we_excp, enable) \
254 | IO_STATE (R_MMU_CONFIG, seg_f, page) \
255 | IO_STATE (R_MMU_CONFIG, seg_e, seg) \
256 | IO_STATE (R_MMU_CONFIG, seg_d, page) \
257 | IO_STATE (R_MMU_CONFIG, seg_c, seg) \
258 | IO_STATE (R_MMU_CONFIG, seg_b, seg) \
259 | IO_STATE (R_MMU_CONFIG, seg_a, seg) \
260 | IO_STATE (R_MMU_CONFIG, seg_9, page) \
261 | IO_STATE (R_MMU_CONFIG, seg_8, page) \
262 | IO_STATE (R_MMU_CONFIG, seg_7, page) \
263 | IO_STATE (R_MMU_CONFIG, seg_6, seg) \
264 | IO_STATE (R_MMU_CONFIG, seg_5, seg) \
265 | IO_STATE (R_MMU_CONFIG, seg_4, seg) \
266 | IO_STATE (R_MMU_CONFIG, seg_3, page) \
267 | IO_STATE (R_MMU_CONFIG, seg_2, page) \
268 | IO_STATE (R_MMU_CONFIG, seg_1, page) \
269 | IO_STATE (R_MMU_CONFIG, seg_0, seg), $r0
270 move.d $r0, [R_MMU_CONFIG]
271 #else
272 ; kseg mappings
273 move.d IO_FIELD (R_MMU_KBASE_HI, base_e, 8) \
274 | IO_FIELD (R_MMU_KBASE_HI, base_c, 4) \
275 | IO_FIELD (R_MMU_KBASE_HI, base_b, 0xb), $r0
276 move.d $r0, [R_MMU_KBASE_HI]
277
278 ; temporary map of 0x40->0x40 and 0x00->0x00
279 move.d IO_FIELD (R_MMU_KBASE_LO, base_4, 4), $r0
280 move.d $r0, [R_MMU_KBASE_LO]
281
282 ; mmu enable, segs f,e,c,b,4,0 segment mapped
283 move.d IO_STATE (R_MMU_CONFIG, mmu_enable, enable) \
284 | IO_STATE (R_MMU_CONFIG, inv_excp, enable) \
285 | IO_STATE (R_MMU_CONFIG, acc_excp, enable) \
286 | IO_STATE (R_MMU_CONFIG, we_excp, enable) \
287 | IO_STATE (R_MMU_CONFIG, seg_f, seg) \
288 | IO_STATE (R_MMU_CONFIG, seg_e, seg) \
289 | IO_STATE (R_MMU_CONFIG, seg_d, page) \
290 | IO_STATE (R_MMU_CONFIG, seg_c, seg) \
291 | IO_STATE (R_MMU_CONFIG, seg_b, seg) \
292 | IO_STATE (R_MMU_CONFIG, seg_a, page) \
293 | IO_STATE (R_MMU_CONFIG, seg_9, page) \
294 | IO_STATE (R_MMU_CONFIG, seg_8, page) \
295 | IO_STATE (R_MMU_CONFIG, seg_7, page) \
296 | IO_STATE (R_MMU_CONFIG, seg_6, page) \
297 | IO_STATE (R_MMU_CONFIG, seg_5, page) \
298 | IO_STATE (R_MMU_CONFIG, seg_4, seg) \
299 | IO_STATE (R_MMU_CONFIG, seg_3, page) \
300 | IO_STATE (R_MMU_CONFIG, seg_2, page) \
301 | IO_STATE (R_MMU_CONFIG, seg_1, page) \
302 | IO_STATE (R_MMU_CONFIG, seg_0, seg), $r0
303 move.d $r0, [R_MMU_CONFIG]
304 #endif
305
306 ;; Now we need to sort out the segments and their locations in RAM or
307 ;; Flash. The image in the Flash (or in DRAM) consists of 3 pieces:
308 ;; 1) kernel text, 2) kernel data, 3) ROM filesystem image
309 ;; But the linker has linked the kernel to expect this layout in
310 ;; DRAM memory:
311 ;; 1) kernel text, 2) kernel data, 3) kernel BSS
312 ;; (the location of the ROM filesystem is determined by the krom driver)
313 ;; If we boot this from Flash, we want to keep the ROM filesystem in
314 ;; the flash, we want to copy the text and need to copy the data to DRAM.
315 ;; But if we boot from DRAM, we need to move the ROMFS image
316 ;; from its position after kernel data, to after kernel BSS, BEFORE the
317 ;; kernel starts using the BSS area (since its "overlayed" with the ROMFS)
318 ;;
319 ;; In both cases, we start in un-cached mode, and need to jump into a
320 ;; cached PC after we're done fiddling around with the segments.
321 ;;
322 ;; arch/etrax100/etrax100.ld sets some symbols that define the start
323 ;; and end of each segment.
324
325 ;; Check if we start from DRAM or FLASH by testing PC
326
327 move.d $pc,$r0
328 and.d 0x7fffffff,$r0 ; get rid of the non-cache bit
329 cmp.d 0x10000,$r0 ; arbitrary... just something above this code
330 blo _inflash0
331 nop
332
333 jump _inram ; enter cached ram
334
335 ;; Jumpgate for branches.
336 _inflash0:
337 jump _inflash
338
339 ;; Put this in a suitable section where we can reclaim storage
340 ;; after init.
341 .section ".init.text", "ax"
342 _inflash:
343 #ifdef CONFIG_ETRAX_ETHERNET
344 ;; Start MII clock to make sure it is running when tranceiver is reset
345 move.d START_ETHERNET_CLOCK, $r0
346 move.d $r0, [R_NETWORK_GEN_CONFIG]
347 #endif
348
349 ;; Set up waitstates etc according to kernel configuration.
350 #ifndef CONFIG_SVINTO_SIM
351 move.d CONFIG_ETRAX_DEF_R_WAITSTATES, $r0
352 move.d $r0, [R_WAITSTATES]
353
354 move.d CONFIG_ETRAX_DEF_R_BUS_CONFIG, $r0
355 move.d $r0, [R_BUS_CONFIG]
356 #endif
357
358 ;; We need to initialze DRAM registers before we start using the DRAM
359
360 cmp.d RAM_INIT_MAGIC, $r8 ; Already initialized?
361 beq _dram_init_finished
362 nop
363
364 #include "../lib/dram_init.S"
365
366 _dram_init_finished:
367 ;; Copy text+data to DRAM
368 ;; This is fragile - the calculation of r4 as the image size depends
369 ;; on that the labels below actually are the first and last positions
370 ;; in the linker-script.
371 ;;
372 ;; Then the locating of the cramfs image depends on the aforementioned
373 ;; image being located in the flash at 0. This is most often not true,
374 ;; thus the following does not work (normally there is a rescue-block
375 ;; between the physical start of the flash and the flash-image start,
376 ;; and when run with compression, the kernel is actually unpacked to
377 ;; DRAM and we never get here in the first place :))
378
379 moveq 0, $r0 ; source
380 move.d text_start, $r1 ; destination
381 move.d __vmlinux_end, $r2 ; end destination
382 move.d $r2, $r4
383 sub.d $r1, $r4 ; r4=__vmlinux_end in flash, used below
384 1: move.w [$r0+], $r3
385 move.w $r3, [$r1+]
386 cmp.d $r2, $r1
387 blo 1b
388 nop
389
390 ;; We keep the cramfs in the flash.
391 ;; There might be none, but that does not matter because
392 ;; we don't do anything than read some bytes here.
393
394 moveq 0, $r0
395 move.d $r0, [romfs_length] ; default if there is no cramfs
396
397 move.d [$r4], $r0 ; cramfs_super.magic
398 cmp.d CRAMFS_MAGIC, $r0
399 bne 1f
400 nop
401 move.d [$r4 + 4], $r0 ; cramfs_super.size
402 move.d $r0, [romfs_length]
403 #ifdef CONFIG_CRIS_LOW_MAP
404 add.d 0x50000000, $r4 ; add flash start in virtual memory (cached)
405 #else
406 add.d 0xf0000000, $r4 ; add flash start in virtual memory (cached)
407 #endif
408 move.d $r4, [romfs_start]
409 1:
410 moveq 1, $r0
411 move.d $r0, [romfs_in_flash]
412
413 jump _start_it ; enter code, cached this time
414
415 _inram:
416 ;; Move the ROM fs to after BSS end. This assumes that the cramfs
417 ;; second longword contains the length of the cramfs
418
419 moveq 0, $r0
420 move.d $r0, [romfs_length] ; default if there is no cramfs
421
422 ;; The kernel could have been unpacked to DRAM by the loader, but
423 ;; the cramfs image could still be in the Flash directly after the
424 ;; compressed kernel image. The loader passes the address of the
425 ;; byte succeeding the last compressed byte in the flash in the
426 ;; register r9 when starting the kernel. Check if r9 points to a
427 ;; decent cramfs image!
428 ;; (Notice that if this is not booted from the loader, r9 will be
429 ;; garbage but we do sanity checks on it, the chance that it points
430 ;; to a cramfs magic is small.. )
431
432 cmp.d 0x0ffffff8, $r9
433 bhs _no_romfs_in_flash ; r9 points outside the flash area
434 nop
435 move.d [$r9], $r0 ; cramfs_super.magic
436 cmp.d CRAMFS_MAGIC, $r0
437 bne _no_romfs_in_flash
438 nop
439 move.d [$r9+4], $r0 ; cramfs_super.length
440 move.d $r0, [romfs_length]
441 #ifdef CONFIG_CRIS_LOW_MAP
442 add.d 0x50000000, $r9 ; add flash start in virtual memory (cached)
443 #else
444 add.d 0xf0000000, $r9 ; add flash start in virtual memory (cached)
445 #endif
446 move.d $r9, [romfs_start]
447
448 moveq 1, $r0
449 move.d $r0, [romfs_in_flash]
450
451 jump _start_it ; enter code, cached this time
452
453 _no_romfs_in_flash:
454
455 ;; Check if there is a cramfs (magic value).
456 ;; Notice that we check for cramfs magic value - which is
457 ;; the "rom fs" we'll possibly use in 2.4 if not JFFS (which does
458 ;; not need this mechanism anyway)
459
460 move.d __vmlinux_end, $r0; the image will be after the vmlinux end address
461 move.d [$r0], $r1 ; cramfs assumes same endian on host/target
462 cmp.d CRAMFS_MAGIC, $r1; magic value in cramfs superblock
463 bne 2f
464 nop
465
466 ;; Ok. What is its size ?
467
468 move.d [$r0 + 4], $r2 ; cramfs_super.size (again, no need to swapwb)
469
470 ;; We want to copy it to the end of the BSS
471
472 move.d _end, $r1
473
474 ;; Remember values so cramfs and setup can find this info
475
476 move.d $r1, [romfs_start] ; new romfs location
477 move.d $r2, [romfs_length]
478
479 ;; We need to copy it backwards, since they can be overlapping
480
481 add.d $r2, $r0
482 add.d $r2, $r1
483
484 ;; Go ahead. Make my loop.
485
486 lsrq 1, $r2 ; size is in bytes, we copy words
487
488 1: move.w [$r0=$r0-2],$r3
489 move.w $r3,[$r1=$r1-2]
490 subq 1, $r2
491 bne 1b
492 nop
493
494 2:
495 ;; Dont worry that the BSS is tainted. It will be cleared later.
496
497 moveq 0, $r0
498 move.d $r0, [romfs_in_flash]
499
500 jump _start_it ; better skip the additional cramfs check below
501
502 _start_it:
503
504 ;; Check if kernel command line is supplied
505 cmp.d COMMAND_LINE_MAGIC, $r10
506 bne no_command_line
507 nop
508
509 move.d 256, $r13
510 move.d cris_command_line, $r10
511 or.d 0x80000000, $r11 ; Make it virtual
512 1:
513 move.b [$r11+], $r12
514 move.b $r12, [$r10+]
515 subq 1, $r13
516 bne 1b
517 nop
518
519 no_command_line:
520
521 ;; the kernel stack is overlayed with the task structure for each
522 ;; task. thus the initial kernel stack is in the same page as the
523 ;; init_task (but starts in the top of the page, size 8192)
524 move.d init_thread_union + 8192, $sp
525 move.d ibr_start,$r0 ; this symbol is set by the linker script
526 move $r0,$ibr
527 move.d $r0,[etrax_irv] ; set the interrupt base register and pointer
528
529 ;; Clear BSS region, from _bss_start to _end
530
531 move.d __bss_start, $r0
532 move.d _end, $r1
533 1: clear.d [$r0+]
534 cmp.d $r1, $r0
535 blo 1b
536 nop
537
538 #ifdef CONFIG_BLK_DEV_ETRAXIDE
539 ;; disable ATA before enabling it in genconfig below
540 moveq 0,$r0
541 move.d $r0,[R_ATA_CTRL_DATA]
542 move.d $r0,[R_ATA_TRANSFER_CNT]
543 move.d $r0,[R_ATA_CONFIG]
544 #if 0
545 move.d R_PORT_G_DATA, $r1
546 move.d $r0, [$r1]; assert ATA bus-reset
547 nop
548 nop
549 nop
550 nop
551 nop
552 nop
553 move.d 0x08000000,$r0
554 move.d $r0,[$r1]
555 #endif
556 #endif
557
558 #ifdef CONFIG_JULIETTE
559 ;; configure external DMA channel 0 before enabling it in genconfig
560
561 moveq 0,$r0
562 move.d $r0,[R_EXT_DMA_0_ADDR]
563 ; cnt enable, word size, output, stop, size 0
564 move.d IO_STATE (R_EXT_DMA_0_CMD, cnt, enable) \
565 | IO_STATE (R_EXT_DMA_0_CMD, rqpol, ahigh) \
566 | IO_STATE (R_EXT_DMA_0_CMD, apol, ahigh) \
567 | IO_STATE (R_EXT_DMA_0_CMD, rq_ack, burst) \
568 | IO_STATE (R_EXT_DMA_0_CMD, wid, word) \
569 | IO_STATE (R_EXT_DMA_0_CMD, dir, output) \
570 | IO_STATE (R_EXT_DMA_0_CMD, run, stop) \
571 | IO_FIELD (R_EXT_DMA_0_CMD, trf_count, 0),$r0
572 move.d $r0,[R_EXT_DMA_0_CMD]
573
574 ;; reset dma4 and wait for completion
575
576 moveq IO_STATE (R_DMA_CH4_CMD, cmd, reset),$r0
577 move.b $r0,[R_DMA_CH4_CMD]
578 1: move.b [R_DMA_CH4_CMD],$r0
579 and.b IO_MASK (R_DMA_CH4_CMD, cmd),$r0
580 cmp.b IO_STATE (R_DMA_CH4_CMD, cmd, reset),$r0
581 beq 1b
582 nop
583
584 ;; reset dma5 and wait for completion
585
586 moveq IO_STATE (R_DMA_CH5_CMD, cmd, reset),$r0
587 move.b $r0,[R_DMA_CH5_CMD]
588 1: move.b [R_DMA_CH5_CMD],$r0
589 and.b IO_MASK (R_DMA_CH5_CMD, cmd),$r0
590 cmp.b IO_STATE (R_DMA_CH5_CMD, cmd, reset),$r0
591 beq 1b
592 nop
593 #endif
594
595 ;; Etrax product HW genconfig setup
596
597 moveq 0,$r0
598
599 ;; Init interfaces (disable them).
600 or.d IO_STATE (R_GEN_CONFIG, scsi0, disable) \
601 | IO_STATE (R_GEN_CONFIG, ata, disable) \
602 | IO_STATE (R_GEN_CONFIG, par0, disable) \
603 | IO_STATE (R_GEN_CONFIG, ser2, disable) \
604 | IO_STATE (R_GEN_CONFIG, mio, disable) \
605 | IO_STATE (R_GEN_CONFIG, scsi1, disable) \
606 | IO_STATE (R_GEN_CONFIG, scsi0w, disable) \
607 | IO_STATE (R_GEN_CONFIG, par1, disable) \
608 | IO_STATE (R_GEN_CONFIG, ser3, disable) \
609 | IO_STATE (R_GEN_CONFIG, mio_w, disable) \
610 | IO_STATE (R_GEN_CONFIG, usb1, disable) \
611 | IO_STATE (R_GEN_CONFIG, usb2, disable) \
612 | IO_STATE (R_GEN_CONFIG, par_w, disable),$r0
613
614 ;; Init DMA channel muxing (set to unused clients).
615 or.d IO_STATE (R_GEN_CONFIG, dma2, ata) \
616 | IO_STATE (R_GEN_CONFIG, dma3, ata) \
617 | IO_STATE (R_GEN_CONFIG, dma4, scsi1) \
618 | IO_STATE (R_GEN_CONFIG, dma5, scsi1) \
619 | IO_STATE (R_GEN_CONFIG, dma6, unused) \
620 | IO_STATE (R_GEN_CONFIG, dma7, unused) \
621 | IO_STATE (R_GEN_CONFIG, dma8, usb) \
622 | IO_STATE (R_GEN_CONFIG, dma9, usb),$r0
623
624
625 #if defined(CONFIG_ETRAX_DEF_R_PORT_G0_DIR_OUT)
626 or.d IO_STATE (R_GEN_CONFIG, g0dir, out),$r0
627 #endif
628
629 #if defined(CONFIG_ETRAX_DEF_R_PORT_G8_15_DIR_OUT)
630 or.d IO_STATE (R_GEN_CONFIG, g8_15dir, out),$r0
631 #endif
632 #if defined(CONFIG_ETRAX_DEF_R_PORT_G16_23_DIR_OUT)
633 or.d IO_STATE (R_GEN_CONFIG, g16_23dir, out),$r0
634 #endif
635
636 #if defined(CONFIG_ETRAX_DEF_R_PORT_G24_DIR_OUT)
637 or.d IO_STATE (R_GEN_CONFIG, g24dir, out),$r0
638 #endif
639
640 move.d $r0,[genconfig_shadow] ; init a shadow register of R_GEN_CONFIG
641
642 #ifndef CONFIG_SVINTO_SIM
643 move.d $r0,[R_GEN_CONFIG]
644
645 #if 0
646 moveq 4,$r0
647 move.b $r0,[R_DMA_CH6_CMD] ; reset (ser0 dma out)
648 move.b $r0,[R_DMA_CH7_CMD] ; reset (ser0 dma in)
649 1: move.b [R_DMA_CH6_CMD],$r0 ; wait for reset cycle to finish
650 and.b 7,$r0
651 cmp.b 4,$r0
652 beq 1b
653 nop
654 1: move.b [R_DMA_CH7_CMD],$r0 ; wait for reset cycle to finish
655 and.b 7,$r0
656 cmp.b 4,$r0
657 beq 1b
658 nop
659 #endif
660
661 moveq IO_STATE (R_DMA_CH8_CMD, cmd, reset),$r0
662 move.b $r0,[R_DMA_CH8_CMD] ; reset (ser1 dma out)
663 move.b $r0,[R_DMA_CH9_CMD] ; reset (ser1 dma in)
664 1: move.b [R_DMA_CH8_CMD],$r0 ; wait for reset cycle to finish
665 andq IO_MASK (R_DMA_CH8_CMD, cmd),$r0
666 cmpq IO_STATE (R_DMA_CH8_CMD, cmd, reset),$r0
667 beq 1b
668 nop
669 1: move.b [R_DMA_CH9_CMD],$r0 ; wait for reset cycle to finish
670 andq IO_MASK (R_DMA_CH9_CMD, cmd),$r0
671 cmpq IO_STATE (R_DMA_CH9_CMD, cmd, reset),$r0
672 beq 1b
673 nop
674
675 ;; setup port PA and PB default initial directions and data
676 ;; including their shadow registers
677
678 move.b CONFIG_ETRAX_DEF_R_PORT_PA_DIR,$r0
679 #if defined(CONFIG_BLUETOOTH) && defined(CONFIG_BLUETOOTH_RESET_PA7)
680 or.b IO_STATE (R_PORT_PA_DIR, dir7, output),$r0
681 #endif
682 move.b $r0,[port_pa_dir_shadow]
683 move.b $r0,[R_PORT_PA_DIR]
684 move.b CONFIG_ETRAX_DEF_R_PORT_PA_DATA,$r0
685 #if defined(CONFIG_BLUETOOTH) && defined(CONFIG_BLUETOOTH_RESET_PA7)
686 #if defined(CONFIG_BLUETOOTH_RESET_ACTIVE_HIGH)
687 and.b ~(1 << 7),$r0
688 #else
689 or.b (1 << 7),$r0
690 #endif
691 #endif
692 move.b $r0,[port_pa_data_shadow]
693 move.b $r0,[R_PORT_PA_DATA]
694
695 move.b CONFIG_ETRAX_DEF_R_PORT_PB_CONFIG,$r0
696 move.b $r0,[port_pb_config_shadow]
697 move.b $r0,[R_PORT_PB_CONFIG]
698 move.b CONFIG_ETRAX_DEF_R_PORT_PB_DIR,$r0
699 #if defined(CONFIG_BLUETOOTH) && defined(CONFIG_BLUETOOTH_RESET_PB5)
700 or.b IO_STATE (R_PORT_PB_DIR, dir5, output),$r0
701 #endif
702 move.b $r0,[port_pb_dir_shadow]
703 move.b $r0,[R_PORT_PB_DIR]
704 move.b CONFIG_ETRAX_DEF_R_PORT_PB_DATA,$r0
705 #if defined(CONFIG_BLUETOOTH) && defined(CONFIG_BLUETOOTH_RESET_PB5)
706 #if defined(CONFIG_BLUETOOTH_RESET_ACTIVE_HIGH)
707 and.b ~(1 << 5),$r0
708 #else
709 or.b (1 << 5),$r0
710 #endif
711 #endif
712 move.b $r0,[port_pb_data_shadow]
713 move.b $r0,[R_PORT_PB_DATA]
714
715 moveq 0, $r0
716 move.d $r0,[port_pb_i2c_shadow]
717 move.d $r0, [R_PORT_PB_I2C]
718
719 moveq 0,$r0
720 #if defined(CONFIG_BLUETOOTH) && defined(CONFIG_BLUETOOTH_RESET_G10)
721 #if defined(CONFIG_BLUETOOTH_RESET_ACTIVE_HIGH)
722 and.d ~(1 << 10),$r0
723 #else
724 or.d (1 << 10),$r0
725 #endif
726 #endif
727 #if defined(CONFIG_BLUETOOTH) && defined(CONFIG_BLUETOOTH_RESET_G11)
728 #if defined(CONFIG_BLUETOOTH_RESET_ACTIVE_HIGH)
729 and.d ~(1 << 11),$r0
730 #else
731 or.d (1 << 11),$r0
732 #endif
733 #endif
734 move.d $r0,[port_g_data_shadow]
735 move.d $r0,[R_PORT_G_DATA]
736
737 ;; setup the serial port 0 at 115200 baud for debug purposes
738
739 moveq IO_STATE (R_SERIAL0_XOFF, tx_stop, enable) \
740 | IO_STATE (R_SERIAL0_XOFF, auto_xoff, disable) \
741 | IO_FIELD (R_SERIAL0_XOFF, xoff_char, 0),$r0
742 move.d $r0,[R_SERIAL0_XOFF]
743
744 ; 115.2kbaud for both transmit and receive
745 move.b IO_STATE (R_SERIAL0_BAUD, tr_baud, c115k2Hz) \
746 | IO_STATE (R_SERIAL0_BAUD, rec_baud, c115k2Hz),$r0
747 move.b $r0,[R_SERIAL0_BAUD]
748
749 ; Set up and enable the serial0 receiver.
750 move.b IO_STATE (R_SERIAL0_REC_CTRL, dma_err, stop) \
751 | IO_STATE (R_SERIAL0_REC_CTRL, rec_enable, enable) \
752 | IO_STATE (R_SERIAL0_REC_CTRL, rts_, active) \
753 | IO_STATE (R_SERIAL0_REC_CTRL, sampling, middle) \
754 | IO_STATE (R_SERIAL0_REC_CTRL, rec_stick_par, normal) \
755 | IO_STATE (R_SERIAL0_REC_CTRL, rec_par, even) \
756 | IO_STATE (R_SERIAL0_REC_CTRL, rec_par_en, disable) \
757 | IO_STATE (R_SERIAL0_REC_CTRL, rec_bitnr, rec_8bit),$r0
758 move.b $r0,[R_SERIAL0_REC_CTRL]
759
760 ; Set up and enable the serial0 transmitter.
761 move.b IO_FIELD (R_SERIAL0_TR_CTRL, txd, 0) \
762 | IO_STATE (R_SERIAL0_TR_CTRL, tr_enable, enable) \
763 | IO_STATE (R_SERIAL0_TR_CTRL, auto_cts, disabled) \
764 | IO_STATE (R_SERIAL0_TR_CTRL, stop_bits, one_bit) \
765 | IO_STATE (R_SERIAL0_TR_CTRL, tr_stick_par, normal) \
766 | IO_STATE (R_SERIAL0_TR_CTRL, tr_par, even) \
767 | IO_STATE (R_SERIAL0_TR_CTRL, tr_par_en, disable) \
768 | IO_STATE (R_SERIAL0_TR_CTRL, tr_bitnr, tr_8bit),$r0
769 move.b $r0,[R_SERIAL0_TR_CTRL]
770
771 ;; setup the serial port 1 at 115200 baud for debug purposes
772
773 moveq IO_STATE (R_SERIAL1_XOFF, tx_stop, enable) \
774 | IO_STATE (R_SERIAL1_XOFF, auto_xoff, disable) \
775 | IO_FIELD (R_SERIAL1_XOFF, xoff_char, 0),$r0
776 move.d $r0,[R_SERIAL1_XOFF]
777
778 ; 115.2kbaud for both transmit and receive
779 move.b IO_STATE (R_SERIAL1_BAUD, tr_baud, c115k2Hz) \
780 | IO_STATE (R_SERIAL1_BAUD, rec_baud, c115k2Hz),$r0
781 move.b $r0,[R_SERIAL1_BAUD]
782
783 ; Set up and enable the serial1 receiver.
784 move.b IO_STATE (R_SERIAL1_REC_CTRL, dma_err, stop) \
785 | IO_STATE (R_SERIAL1_REC_CTRL, rec_enable, enable) \
786 | IO_STATE (R_SERIAL1_REC_CTRL, rts_, active) \
787 | IO_STATE (R_SERIAL1_REC_CTRL, sampling, middle) \
788 | IO_STATE (R_SERIAL1_REC_CTRL, rec_stick_par, normal) \
789 | IO_STATE (R_SERIAL1_REC_CTRL, rec_par, even) \
790 | IO_STATE (R_SERIAL1_REC_CTRL, rec_par_en, disable) \
791 | IO_STATE (R_SERIAL1_REC_CTRL, rec_bitnr, rec_8bit),$r0
792 move.b $r0,[R_SERIAL1_REC_CTRL]
793
794 ; Set up and enable the serial1 transmitter.
795 move.b IO_FIELD (R_SERIAL1_TR_CTRL, txd, 0) \
796 | IO_STATE (R_SERIAL1_TR_CTRL, tr_enable, enable) \
797 | IO_STATE (R_SERIAL1_TR_CTRL, auto_cts, disabled) \
798 | IO_STATE (R_SERIAL1_TR_CTRL, stop_bits, one_bit) \
799 | IO_STATE (R_SERIAL1_TR_CTRL, tr_stick_par, normal) \
800 | IO_STATE (R_SERIAL1_TR_CTRL, tr_par, even) \
801 | IO_STATE (R_SERIAL1_TR_CTRL, tr_par_en, disable) \
802 | IO_STATE (R_SERIAL1_TR_CTRL, tr_bitnr, tr_8bit),$r0
803 move.b $r0,[R_SERIAL1_TR_CTRL]
804
805
806 #ifdef CONFIG_ETRAX_SERIAL_PORT3
807 ;; setup the serial port 3 at 115200 baud for debug purposes
808
809 moveq IO_STATE (R_SERIAL3_XOFF, tx_stop, enable) \
810 | IO_STATE (R_SERIAL3_XOFF, auto_xoff, disable) \
811 | IO_FIELD (R_SERIAL3_XOFF, xoff_char, 0),$r0
812 move.d $r0,[R_SERIAL3_XOFF]
813
814 ; 115.2kbaud for both transmit and receive
815 move.b IO_STATE (R_SERIAL3_BAUD, tr_baud, c115k2Hz) \
816 | IO_STATE (R_SERIAL3_BAUD, rec_baud, c115k2Hz),$r0
817 move.b $r0,[R_SERIAL3_BAUD]
818
819 ; Set up and enable the serial3 receiver.
820 move.b IO_STATE (R_SERIAL3_REC_CTRL, dma_err, stop) \
821 | IO_STATE (R_SERIAL3_REC_CTRL, rec_enable, enable) \
822 | IO_STATE (R_SERIAL3_REC_CTRL, rts_, active) \
823 | IO_STATE (R_SERIAL3_REC_CTRL, sampling, middle) \
824 | IO_STATE (R_SERIAL3_REC_CTRL, rec_stick_par, normal) \
825 | IO_STATE (R_SERIAL3_REC_CTRL, rec_par, even) \
826 | IO_STATE (R_SERIAL3_REC_CTRL, rec_par_en, disable) \
827 | IO_STATE (R_SERIAL3_REC_CTRL, rec_bitnr, rec_8bit),$r0
828 move.b $r0,[R_SERIAL3_REC_CTRL]
829
830 ; Set up and enable the serial3 transmitter.
831 move.b IO_FIELD (R_SERIAL3_TR_CTRL, txd, 0) \
832 | IO_STATE (R_SERIAL3_TR_CTRL, tr_enable, enable) \
833 | IO_STATE (R_SERIAL3_TR_CTRL, auto_cts, disabled) \
834 | IO_STATE (R_SERIAL3_TR_CTRL, stop_bits, one_bit) \
835 | IO_STATE (R_SERIAL3_TR_CTRL, tr_stick_par, normal) \
836 | IO_STATE (R_SERIAL3_TR_CTRL, tr_par, even) \
837 | IO_STATE (R_SERIAL3_TR_CTRL, tr_par_en, disable) \
838 | IO_STATE (R_SERIAL3_TR_CTRL, tr_bitnr, tr_8bit),$r0
839 move.b $r0,[R_SERIAL3_TR_CTRL]
840 #endif
841
842 #endif /* CONFIG_SVINTO_SIM */
843
844 jump start_kernel ; jump into the C-function start_kernel in init/main.c
845
846 .data
847 etrax_irv:
848 .dword 0
849 romfs_start:
850 .dword 0
851 romfs_length:
852 .dword 0
853 romfs_in_flash:
854 .dword 0
855
856 ;; put some special pages at the beginning of the kernel aligned
857 ;; to page boundaries - the kernel cannot start until after this
858
859 #ifdef CONFIG_CRIS_LOW_MAP
860 swapper_pg_dir = 0x60002000
861 #else
862 swapper_pg_dir = 0xc0002000
863 #endif
864
865 .section ".init.data", "aw"
866 #include "../lib/hw_settings.S"
This page took 0.059447 seconds and 5 git commands to generate.