diff options
author | Jesper Nilsson <jesper.nilsson@axis.com> | 2007-11-30 10:40:26 -0500 |
---|---|---|
committer | Jesper Nilsson <jesper.nilsson@axis.com> | 2008-02-08 05:06:26 -0500 |
commit | 247c3c959f5d5a7edd1d5561ffe29906129dab0b (patch) | |
tree | 51ac9e7efa396900d4c5408ec9e83e52a5400986 /arch/cris/arch-v32/boot | |
parent | 5d23ff25b2d406b7fc1eb771d5dc4f1add0f2530 (diff) |
CRIS v32: Update compressed head.S
- Fixes for NAND and NOR flash booting.
- Use assembler macros for common tasks (clocks, general io etc)
- Use (EtraxFS or Artpec-3) machine specific include for dram and hardware init.
Diffstat (limited to 'arch/cris/arch-v32/boot')
-rw-r--r-- | arch/cris/arch-v32/boot/compressed/head.S | 137 |
1 files changed, 39 insertions, 98 deletions
diff --git a/arch/cris/arch-v32/boot/compressed/head.S b/arch/cris/arch-v32/boot/compressed/head.S index 34cea10a8998..f86208caf32d 100644 --- a/arch/cris/arch-v32/boot/compressed/head.S +++ b/arch/cris/arch-v32/boot/compressed/head.S | |||
@@ -2,13 +2,12 @@ | |||
2 | * Code that sets up the DRAM registers, calls the | 2 | * Code that sets up the DRAM registers, calls the |
3 | * decompressor to unpack the piggybacked kernel, and jumps. | 3 | * decompressor to unpack the piggybacked kernel, and jumps. |
4 | * | 4 | * |
5 | * Copyright (C) 1999 - 2003, Axis Communications AB | 5 | * Copyright (C) 1999 - 2006, Axis Communications AB |
6 | */ | 6 | */ |
7 | 7 | ||
8 | #define ASSEMBLER_MACROS_ONLY | 8 | #define ASSEMBLER_MACROS_ONLY |
9 | #include <asm/arch/hwregs/asm/reg_map_asm.h> | 9 | #include <hwregs/asm/reg_map_asm.h> |
10 | #include <asm/arch/hwregs/asm/gio_defs_asm.h> | 10 | #include <asm/arch/mach/startup.inc> |
11 | #include <asm/arch/hwregs/asm/config_defs_asm.h> | ||
12 | 11 | ||
13 | #define RAM_INIT_MAGIC 0x56902387 | 12 | #define RAM_INIT_MAGIC 0x56902387 |
14 | #define COMMAND_LINE_MAGIC 0x87109563 | 13 | #define COMMAND_LINE_MAGIC 0x87109563 |
@@ -22,114 +21,49 @@ start: | |||
22 | di | 21 | di |
23 | 22 | ||
24 | ;; Start clocks for used blocks. | 23 | ;; Start clocks for used blocks. |
25 | move.d REG_ADDR(config, regi_config, rw_clk_ctrl), $r1 | 24 | START_CLOCKS |
26 | move.d [$r1], $r0 | 25 | |
27 | or.d REG_STATE(config, rw_clk_ctrl, cpu, yes) | \ | 26 | ;; Initialize the DRAM registers. |
28 | REG_STATE(config, rw_clk_ctrl, bif, yes) | \ | ||
29 | REG_STATE(config, rw_clk_ctrl, fix_io, yes), $r0 | ||
30 | move.d $r0, [$r1] | ||
31 | |||
32 | ;; If booting from NAND flash we first have to copy some | ||
33 | ;; data from NAND flash to internal RAM to get the code | ||
34 | ;; that initializes the SDRAM. Lets copy 20 KB. This | ||
35 | ;; code executes at 0x38010000 if booting from NAND and | ||
36 | ;; we are guaranted that at least 0x200 bytes are good so | ||
37 | ;; lets start from there. The first 8192 bytes in the nand | ||
38 | ;; flash is spliced with zeroes and is thus 16384 bytes. | ||
39 | move.d 0x38010200, $r10 | ||
40 | move.d 0x14200, $r11 ; Start offset in NAND flash 0x10200 + 16384 | ||
41 | move.d 0x5000, $r12 ; Length of copy | ||
42 | |||
43 | ;; Before this code the tools add a partitiontable so the PC | ||
44 | ;; has an offset from the linked address. | ||
45 | offset1: | ||
46 | lapcq ., $r13 ; get PC | ||
47 | add.d first_copy_complete-offset1, $r13 | ||
48 | |||
49 | #include "../../lib/nand_init.S" | ||
50 | |||
51 | first_copy_complete: | ||
52 | ;; Initialze the DRAM registers. | ||
53 | cmp.d RAM_INIT_MAGIC, $r8 ; Already initialized? | 27 | cmp.d RAM_INIT_MAGIC, $r8 ; Already initialized? |
54 | beq dram_init_finished | 28 | beq dram_init_finished |
55 | nop | 29 | nop |
56 | 30 | ||
57 | #include "../../lib/dram_init.S" | 31 | #include "../../mach/dram_init.S" |
58 | 32 | ||
59 | dram_init_finished: | 33 | dram_init_finished: |
60 | lapcq ., $r13 ; get PC | ||
61 | add.d second_copy_complete-dram_init_finished, $r13 | ||
62 | |||
63 | move.d REG_ADDR(config, regi_config, r_bootsel), $r0 | ||
64 | move.d [$r0], $r0 | ||
65 | and.d REG_MASK(config, r_bootsel, boot_mode), $r0 | ||
66 | cmp.d REG_STATE(config, r_bootsel, boot_mode, nand), $r0 | ||
67 | bne second_copy_complete ; No NAND boot | ||
68 | nop | ||
69 | |||
70 | ;; Copy 2MB from NAND flash to SDRAM (at 2-4MB into the SDRAM) | ||
71 | move.d 0x40204000, $r10 | ||
72 | move.d 0x8000, $r11 | ||
73 | move.d 0x200000, $r12 | ||
74 | ba copy_nand_to_ram | ||
75 | nop | ||
76 | second_copy_complete: | ||
77 | |||
78 | ;; Initiate the PA port. | ||
79 | move.d CONFIG_ETRAX_DEF_GIO_PA_OUT, $r0 | ||
80 | move.d REG_ADDR(gio, regi_gio, rw_pa_dout), $r1 | ||
81 | move.d $r0, [$r1] | ||
82 | |||
83 | move.d CONFIG_ETRAX_DEF_GIO_PA_OE, $r0 | ||
84 | move.d REG_ADDR(gio, regi_gio, rw_pa_oe), $r1 | ||
85 | move.d $r0, [$r1] | ||
86 | 34 | ||
35 | GIO_INIT | ||
87 | ;; Setup the stack to a suitably high address. | 36 | ;; Setup the stack to a suitably high address. |
88 | ;; We assume 8 MB is the minimum DRAM and put | 37 | ;; We assume 8 MB is the minimum DRAM and put |
89 | ;; the SP at the top for now. | 38 | ;; the SP at the top for now. |
90 | 39 | ||
91 | move.d 0x40800000, $sp | 40 | move.d 0x40800000, $sp |
92 | 41 | ||
93 | ;; Figure out where the compressed piggyback image is | 42 | ;; Figure out where the compressed piggyback image is. |
94 | ;; in the flash (since we wont try to copy it to DRAM | 43 | ;; It is either in [NOR] flash (we don't want to copy it |
95 | ;; before unpacking). It is at _edata, but in flash. | 44 | ;; to DRAM before unpacking), or copied to DRAM |
45 | ;; by the [NAND] flash boot loader. | ||
46 | ;; The piggyback image is at _edata, but relative to where the | ||
47 | ;; image is actually located in memory, not where it is linked | ||
48 | ;; (the decompressor is linked at 0x40700000+ and runs there). | ||
96 | ;; Use (_edata - herami) as offset to the current PC. | 49 | ;; Use (_edata - herami) as offset to the current PC. |
97 | 50 | ||
98 | move.d REG_ADDR(config, regi_config, r_bootsel), $r0 | ||
99 | move.d [$r0], $r0 | ||
100 | and.d REG_MASK(config, r_bootsel, boot_mode), $r0 | ||
101 | cmp.d REG_STATE(config, r_bootsel, boot_mode, nand), $r0 | ||
102 | beq hereami2 | ||
103 | nop | ||
104 | hereami: | 51 | hereami: |
105 | lapcq ., $r5 ; get PC | 52 | lapcq ., $r5 ; get PC |
106 | and.d 0x7fffffff, $r5 ; strip any non-cache bit | 53 | and.d 0x7fffffff, $r5 ; strip any non-cache bit |
107 | move.d $r5, $r0 ; save for later - flash address of 'herami' | 54 | move.d $r5, $r0 ; source address of 'herami' |
108 | add.d _edata, $r5 | 55 | add.d _edata, $r5 |
109 | sub.d hereami, $r5 ; r5 = flash address of '_edata' | 56 | sub.d hereami, $r5 ; r5 = flash address of '_edata' |
110 | move.d hereami, $r1 ; destination | 57 | move.d hereami, $r1 ; destination |
111 | ba 2f | 58 | |
112 | nop | ||
113 | hereami2: | ||
114 | lapcq ., $r5 ; get PC | ||
115 | and.d 0x00ffffff, $r5 ; strip any non-cache bit | ||
116 | move.d $r5, $r6 | ||
117 | or.d 0x40200000, $r6 | ||
118 | move.d $r6, $r0 ; save for later - flash address of 'herami' | ||
119 | add.d _edata, $r5 | ||
120 | sub.d hereami2, $r5 ; r5 = flash address of '_edata' | ||
121 | add.d 0x40200000, $r5 | ||
122 | move.d hereami2, $r1 ; destination | ||
123 | 2: | ||
124 | ;; Copy text+data to DRAM | 59 | ;; Copy text+data to DRAM |
125 | 60 | ||
126 | move.d _edata, $r2 ; end destination | 61 | move.d _edata, $r2 ; end destination |
127 | 1: move.w [$r0+], $r3 | 62 | 1: move.w [$r0+], $r3 ; from herami+ source |
128 | move.w $r3, [$r1+] | 63 | move.w $r3, [$r1+] ; to hereami+ destination (linked address) |
129 | cmp.d $r2, $r1 | 64 | cmp.d $r2, $r1 ; finish when destination == _edata |
130 | bcs 1b | 65 | bcs 1b |
131 | nop | 66 | nop |
132 | |||
133 | move.d input_data, $r0 ; for the decompressor | 67 | move.d input_data, $r0 ; for the decompressor |
134 | move.d $r5, [$r0] ; for the decompressor | 68 | move.d $r5, [$r0] ; for the decompressor |
135 | 69 | ||
@@ -144,16 +78,24 @@ hereami2: | |||
144 | nop | 78 | nop |
145 | 79 | ||
146 | ;; Save command line magic and address. | 80 | ;; Save command line magic and address. |
147 | move.d _cmd_line_magic, $r12 | 81 | move.d _cmd_line_magic, $r0 |
148 | move.d $r10, [$r12] | 82 | move.d $r10, [$r0] |
149 | move.d _cmd_line_addr, $r12 | 83 | move.d _cmd_line_addr, $r0 |
150 | move.d $r11, [$r12] | 84 | move.d $r11, [$r0] |
85 | |||
86 | ;; Save boot source indicator | ||
87 | move.d _boot_source, $r0 | ||
88 | move.d $r12, [$r0] | ||
151 | 89 | ||
152 | ;; Do the decompression and save compressed size in _inptr | 90 | ;; Do the decompression and save compressed size in _inptr |
153 | 91 | ||
154 | jsr decompress_kernel | 92 | jsr decompress_kernel |
155 | nop | 93 | nop |
156 | 94 | ||
95 | ;; Restore boot source indicator | ||
96 | move.d _boot_source, $r12 | ||
97 | move.d [$r12], $r12 | ||
98 | |||
157 | ;; Restore command line magic and address. | 99 | ;; Restore command line magic and address. |
158 | move.d _cmd_line_magic, $r10 | 100 | move.d _cmd_line_magic, $r10 |
159 | move.d [$r10], $r10 | 101 | move.d [$r10], $r10 |
@@ -166,11 +108,10 @@ hereami2: | |||
166 | move.d [$r0], $r9 ; flash address of compressed kernel | 108 | move.d [$r0], $r9 ; flash address of compressed kernel |
167 | move.d inptr, $r0 | 109 | move.d inptr, $r0 |
168 | add.d [$r0], $r9 ; size of compressed kernel | 110 | add.d [$r0], $r9 ; size of compressed kernel |
169 | cmp.d 0x40200000, $r9 | 111 | cmp.d 0x40000000, $r9 ; image in DRAM ? |
170 | blo enter_kernel | 112 | blo enter_kernel ; no, must be [NOR] flash, jump |
171 | nop | 113 | nop ; delay slot |
172 | sub.d 0x40200000, $r9 | 114 | and.d 0x001fffff, $r9 ; assume compressed kernel was < 2M |
173 | add.d 0x4000, $r9 | ||
174 | 115 | ||
175 | enter_kernel: | 116 | enter_kernel: |
176 | ;; Enter the decompressed kernel | 117 | ;; Enter the decompressed kernel |
@@ -186,7 +127,7 @@ _cmd_line_magic: | |||
186 | .dword 0 | 127 | .dword 0 |
187 | _cmd_line_addr: | 128 | _cmd_line_addr: |
188 | .dword 0 | 129 | .dword 0 |
189 | is_nand_boot: | 130 | _boot_source: |
190 | .dword 0 | 131 | .dword 0 |
191 | 132 | ||
192 | #include "../../lib/hw_settings.S" | 133 | #include "../../mach/hw_settings.S" |