|
835
|
1 #ifndef CYGONCE_HAL_PLATFORM_SETUP_H |
|
|
2 #define CYGONCE_HAL_PLATFORM_SETUP_H |
|
|
3 |
|
|
4 /*============================================================================= |
|
|
5 // |
|
|
6 // hal_platform_setup.h |
|
|
7 // |
|
|
8 // Platform specific support for HAL (assembly code) |
|
|
9 // |
|
|
10 //============================================================================= |
|
|
11 //####ECOSGPLCOPYRIGHTBEGIN#### |
|
|
12 // ------------------------------------------- |
|
|
13 // This file is part of eCos, the Embedded Configurable Operating System. |
|
1744
|
14 // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004 Red Hat, Inc. |
|
835
|
15 // |
|
|
16 // eCos is free software; you can redistribute it and/or modify it under |
|
|
17 // the terms of the GNU General Public License as published by the Free |
|
|
18 // Software Foundation; either version 2 or (at your option) any later version. |
|
|
19 // |
|
|
20 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY |
|
|
21 // WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
|
22 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
|
23 // for more details. |
|
|
24 // |
|
|
25 // You should have received a copy of the GNU General Public License along |
|
|
26 // with eCos; if not, write to the Free Software Foundation, Inc., |
|
|
27 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
|
|
28 // |
|
|
29 // As a special exception, if other files instantiate templates or use macros |
|
|
30 // or inline functions from this file, or you compile this file and link it |
|
|
31 // with other works to produce a work based on this file, this file does not |
|
|
32 // by itself cause the resulting work to be covered by the GNU General Public |
|
|
33 // License. However the source code for this file must still be made available |
|
|
34 // in accordance with section (3) of the GNU General Public License. |
|
|
35 // |
|
|
36 // This exception does not invalidate any other reasons why a work based on |
|
|
37 // this file might be covered by the GNU General Public License. |
|
|
38 // |
|
|
39 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. |
|
|
40 // at http://sources.redhat.com/ecos/ecos-license/ |
|
|
41 // ------------------------------------------- |
|
|
42 //####ECOSGPLCOPYRIGHTEND#### |
|
|
43 //============================================================================= |
|
|
44 //#####DESCRIPTIONBEGIN#### |
|
|
45 // |
|
|
46 // Author(s): msalter |
|
|
47 // Contributors: msalter |
|
|
48 // Date: 2002-12-10 |
|
|
49 // Purpose: Intel XScale IXPD specific support routines |
|
|
50 // Description: |
|
|
51 // Usage: #include <cyg/hal/hal_platform_setup.h> |
|
|
52 // Only used by "vectors.S" |
|
|
53 // |
|
|
54 //####DESCRIPTIONEND#### |
|
|
55 // |
|
|
56 //===========================================================================*/ |
|
|
57 |
|
|
58 #include <pkgconf/system.h> // System-wide configuration info |
|
|
59 #include CYGBLD_HAL_VARIANT_H // Variant specific configuration |
|
|
60 #include CYGBLD_HAL_PLATFORM_H // Platform specific configuration |
|
|
61 #include <cyg/hal/hal_ixp425.h> // Variant specific hardware definitions |
|
|
62 #include <cyg/hal/hal_mmu.h> // MMU definitions |
|
|
63 #include <cyg/hal/hal_mm.h> // more MMU definitions |
|
|
64 #include <cyg/hal/ixdp425.h> // Platform specific hardware definitions |
|
|
65 |
|
1744
|
66 // ------------------------------------------------------------------------ |
|
|
67 // Convenience macros for setting up page table |
|
|
68 // |
|
|
69 .macro IXP_MAP_SDRAM va, c, b, x, p |
|
|
70 XSCALE_MMU_SECTION SDRAM_PHYS_BASE>>20, \va>>20, SDRAM_SIZE>>20, \c, \b, 3, \x, \p |
|
|
71 .endm |
|
|
72 |
|
|
73 .macro IXP_MAP_EXP_V n, va, sz, c, b, x, p |
|
|
74 XSCALE_MMU_SECTION (0x500 + ((IXP425_EXP_CS_SIZE * \n) >> 20)), \va>>20, \sz>>20, \c, \b, 3, \x, \p |
|
|
75 .endm |
|
|
76 |
|
|
77 .macro IXP_MAP_EXP n, sz, c, b, x, p |
|
|
78 IXP_MAP_EXP_V \n, (0x50000000 + (IXP425_EXP_CS_SIZE * \n)), \sz, \c, \b, \x, \p |
|
|
79 .endm |
|
|
80 |
|
|
81 .macro IXP_MAP_IO addr, sz |
|
|
82 XSCALE_MMU_SECTION \addr>>20, \addr>>20, \sz>>20, 0, 0, 3, 0, 0 |
|
|
83 .endm |
|
|
84 |
|
|
85 |
|
1748
|
86 #if defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_ROMRAM) |
|
835
|
87 #define PLATFORM_SETUP1 _platform_setup1 |
|
|
88 #define CYGHWR_HAL_ARM_HAS_MMU |
|
|
89 |
|
|
90 // ------------------------------------------------------------------------ |
|
|
91 // Define macro used to diddle the LEDs during early initialization. |
|
|
92 // Can use r0+r1. Argument in \x. |
|
|
93 #define CYGHWR_LED_MACRO DISPLAY \x, r0, r1 |
|
|
94 |
|
|
95 // Delay a bit |
|
|
96 .macro DELAY cycles, reg0 |
|
|
97 ldr \reg0, =\cycles |
|
|
98 subs \reg0, \reg0, #1 |
|
|
99 subne pc, pc, #0xc |
|
|
100 .endm |
|
|
101 |
|
|
102 // ------------------------------------------------------------------------ |
|
|
103 // This macro represents the initial startup code for the platform |
|
|
104 .macro _platform_setup1 |
|
|
105 |
|
1744
|
106 #ifdef CYGHWR_HAL_ARM_BIGENDIAN |
|
835
|
107 // set big-endian |
|
|
108 mrc p15, 0, r0, c1, c0, 0 |
|
|
109 orr r0, r0, #0x80 |
|
|
110 mcr p15, 0, r0, c1, c0, 0 |
|
|
111 CPWAIT r0 |
|
|
112 #endif |
|
|
113 |
|
|
114 ldr r0,=(CPSR_IRQ_DISABLE|CPSR_FIQ_DISABLE|CPSR_SUPERVISOR_MODE) |
|
|
115 msr cpsr, r0 |
|
|
116 |
|
|
117 // invalidate I & D caches & BTB |
|
|
118 mcr p15, 0, r0, c7, c7, 0 |
|
|
119 CPWAIT r0 |
|
|
120 |
|
|
121 // invalidate I & Data TLB |
|
|
122 mcr p15, 0, r0, c8, c7, 0 |
|
|
123 CPWAIT r0 |
|
|
124 |
|
|
125 // drain write and fill buffers |
|
|
126 mcr p15, 0, r0, c7, c10, 4 |
|
|
127 CPWAIT r0 |
|
|
128 |
|
|
129 // disable write buffer coalescing |
|
|
130 mrc p15, 0, r0, c1, c0, 1 |
|
|
131 orr r0, r0, #1 |
|
|
132 mcr p15, 0, r0, c1, c0, 1 |
|
|
133 CPWAIT r0 |
|
|
134 |
|
|
135 // Setup chip selects |
|
|
136 ldr r1, =IXP425_EXP_CFG_BASE |
|
|
137 #ifdef IXP425_EXP_CS0_INIT |
|
|
138 ldr r0, =IXP425_EXP_CS0_INIT |
|
|
139 str r0, [r1, #IXP425_EXP_CS0] |
|
|
140 #endif |
|
|
141 #ifdef IXP425_EXP_CS1_INIT |
|
|
142 ldr r0, =IXP425_EXP_CS1_INIT |
|
|
143 str r0, [r1, #IXP425_EXP_CS1] |
|
|
144 #endif |
|
|
145 #ifdef IXP425_EXP_CS2_INIT |
|
|
146 ldr r0, =IXP425_EXP_CS2_INIT |
|
|
147 str r0, [r1, #IXP425_EXP_CS2] |
|
|
148 #endif |
|
|
149 #ifdef IXP425_EXP_CS3_INIT |
|
|
150 ldr r0, =IXP425_EXP_CS3_INIT |
|
|
151 str r0, [r1, #IXP425_EXP_CS3] |
|
|
152 #endif |
|
|
153 #ifdef IXP425_EXP_CS4_INIT |
|
|
154 ldr r0, =IXP425_EXP_CS4_INIT |
|
|
155 str r0, [r1, #IXP425_EXP_CS4] |
|
|
156 #endif |
|
|
157 #ifdef IXP425_EXP_CS5_INIT |
|
|
158 ldr r0, =IXP425_EXP_CS5_INIT |
|
|
159 str r0, [r1, #IXP425_EXP_CS5] |
|
|
160 #endif |
|
|
161 #ifdef IXP425_EXP_CS6_INIT |
|
|
162 ldr r0, =IXP425_EXP_CS6_INIT |
|
|
163 str r0, [r1, #IXP425_EXP_CS6] |
|
|
164 #endif |
|
|
165 #ifdef IXP425_EXP_CS7_INIT |
|
|
166 ldr r0, =IXP425_EXP_CS7_INIT |
|
|
167 str r0, [r1, #IXP425_EXP_CS7] |
|
|
168 #endif |
|
|
169 |
|
|
170 DISPLAY 0x1001, r7, r8 |
|
|
171 |
|
|
172 // Enable the Icache |
|
|
173 mrc p15, 0, r0, c1, c0, 0 |
|
|
174 orr r0, r0, #MMU_Control_I |
|
|
175 mcr p15, 0, r0, c1, c0, 0 |
|
|
176 CPWAIT r0 |
|
|
177 |
|
|
178 DISPLAY 0x1002, r7, r8 |
|
|
179 |
|
|
180 // Setup SDRAM controller |
|
|
181 |
|
|
182 ldr r0, =IXP425_SDRAM_CFG_BASE |
|
|
183 |
|
|
184 ldr r1, =IXP425_SDRAM_CONFIG_INIT |
|
|
185 str r1, [r0, #IXP425_SDRAM_CONFIG] |
|
|
186 |
|
|
187 // disable refresh cycles |
|
|
188 mov r1, #0 |
|
|
189 str r1, [r0, #IXP425_SDRAM_REFRESH] |
|
|
190 |
|
|
191 // send nop command |
|
|
192 mov r1, #SDRAM_IR_NOP |
|
|
193 str r1, [r0, #IXP425_SDRAM_IR] |
|
|
194 DELAY 0x10000, r1 |
|
|
195 |
|
|
196 // set SDRAM internal refresh val |
|
|
197 ldr r1, =IXP425_SDRAM_REFRESH_CNT |
|
|
198 str r1, [r0, #IXP425_SDRAM_REFRESH] |
|
|
199 DELAY 0x10000, r1 |
|
|
200 |
|
|
201 // send precharge-all command to close all open banks |
|
|
202 mov r1, #SDRAM_IR_PRECHARGE |
|
|
203 str r1, [r0, #IXP425_SDRAM_IR] |
|
|
204 DELAY 0x10000, r1 |
|
|
205 |
|
|
206 // provide 8 auto-refresh cycles |
|
|
207 mov r1, #SDRAM_IR_AUTO_REFRESH |
|
|
208 mov r2, #8 |
|
|
209 1: |
|
|
210 str r1, [r0, #IXP425_SDRAM_IR] |
|
|
211 DELAY 0x800, r3 |
|
|
212 subs r2, r2, #1 |
|
|
213 bne 1b |
|
|
214 |
|
|
215 // set mode register in sdram |
|
|
216 mov r1, #IXP425_SDRAM_SET_MODE_CMD |
|
|
217 str r1, [r0, #IXP425_SDRAM_IR] |
|
|
218 DELAY 0x10000, r1 |
|
|
219 |
|
|
220 // start normal operation |
|
|
221 mov r1, #SDRAM_IR_NORMAL |
|
|
222 str r1, [r0, #IXP425_SDRAM_IR] |
|
|
223 DELAY 0x10000, r1 |
|
|
224 |
|
|
225 DISPLAY 0x1003, r7, r8 |
|
|
226 |
|
1744
|
227 // Enable byte swapping control via page table P bit. |
|
|
228 ldr r2, =IXP425_EXP_CFG_BASE |
|
|
229 ldr r1, [r2, #IXP425_EXP_CNFG1] |
|
|
230 orr r1, r1, #EXP_CNFG1_BYTE_SWAP_EN |
|
|
231 str r1, [r2, #IXP425_EXP_CNFG1] |
|
|
232 |
|
835
|
233 // value to load into pc to jump to real runtime address |
|
|
234 ldr r0, =1f |
|
1748
|
235 #if defined(CYG_HAL_STARTUP_ROMRAM) |
|
|
236 // R0 holds a RAM address for ROMRAM startup, |
|
|
237 // so convert to a flash address. |
|
|
238 orr r0, r0, #IXDP_FLASH_BASE |
|
|
239 #endif |
|
835
|
240 |
|
|
241 // Setup EXP_CNFG0 value to switch EXP bus out of low memory |
|
|
242 ldr r2, =IXP425_EXP_CFG_BASE |
|
|
243 ldr r1, [r2, #IXP425_EXP_CNFG0] |
|
|
244 bic r1, r1, #EXP_CNFG0_MEM_MAP |
|
|
245 ldr r3, =0xFFFF |
|
|
246 ldr r4, =IXDP425_LED_DATA |
|
|
247 |
|
1748
|
248 |
|
835
|
249 b icache_boundary |
|
|
250 .p2align 5 |
|
|
251 icache_boundary: |
|
|
252 // Here is where we switch from boot address (0x000000000) to the |
|
|
253 // actual flash runtime address. We align to cache boundary so we |
|
|
254 // execute from cache during the switchover. Cachelines are 8 words. |
|
|
255 str r1, [r2, #IXP425_EXP_CNFG0] // make the EXP bus switch |
|
|
256 nop |
|
|
257 nop |
|
|
258 nop |
|
|
259 nop |
|
|
260 mov pc, r0 |
|
|
261 strh r3, [r4] // We should never reach this point. If we do, |
|
|
262 // display FFFF and loop forever. |
|
|
263 0: b 0b |
|
|
264 1: |
|
|
265 |
|
|
266 DISPLAY 0x1004, r7, r8 |
|
|
267 |
|
1748
|
268 #if defined(CYG_HAL_STARTUP_ROMRAM) |
|
|
269 mov r0, #IXDP_FLASH_BASE |
|
|
270 mov r1, #SDRAM_PHYS_BASE |
|
|
271 ldr r2, =__ram_data_end |
|
|
272 20: ldr r3, [r0],#4 |
|
|
273 str r3, [r1],#4 |
|
|
274 cmp r1, r2 |
|
|
275 bne 20b |
|
|
276 |
|
|
277 // start executing from RAM |
|
|
278 ldr r0, =30f |
|
|
279 mov pc, r0 |
|
|
280 30: |
|
|
281 #endif |
|
|
282 |
|
1744
|
283 // Build mmu tables into RAM so page table walks by the cpu |
|
835
|
284 // don't interfere with FLASH programming. |
|
|
285 mov r1, #SDRAM_PHYS_BASE |
|
|
286 orr r1, r1, #0x4000 // RAM tables |
|
1744
|
287 add r2, r1, #0x4000 // End of tables |
|
835
|
288 |
|
1744
|
289 // First clear table |
|
|
290 mov r0, #0 |
|
835
|
291 1: |
|
1744
|
292 str r0, [r1], #4 |
|
|
293 cmp r1, r2 |
|
835
|
294 bne 1b |
|
|
295 |
|
1744
|
296 // Build section mappings |
|
|
297 IXP_MAP_SDRAM SDRAM_BASE, 1, 0, 0, 0 // Cached SDRAM |
|
|
298 IXP_MAP_SDRAM SDRAM_ALIAS_BASE, 1, 0, 0, 0 // Cached SDRAM alias |
|
|
299 IXP_MAP_SDRAM SDRAM_UNCACHED_BASE, 0, 0, 0, 0 // Uncached SDRAM |
|
|
300 IXP_MAP_SDRAM SDRAM_DC_BASE, 1, 0, 0, 1 // Cached data coherent SDRAM |
|
|
301 |
|
|
302 IXP_MAP_EXP 0, IXDP_FLASH_SIZE, 1, 0, 0, 0 // Flash |
|
|
303 IXP_MAP_EXP 2, IXDP425_LED_SIZE, 0, 0, 0, 0 // LED |
|
|
304 IXP_MAP_EXP 4, (1 << 20), 0, 0, 0, 0 // NPE use |
|
|
305 IXP_MAP_EXP 5, (1 << 20), 0, 0, 0, 0 // NPE use |
|
|
306 |
|
|
307 IXP_MAP_EXP_V 0, IXDP_FLASH_DC_BASE, IXDP_FLASH_SIZE, 1, 0, 0, 1 // data coherent flash |
|
|
308 |
|
|
309 IXP_MAP_IO IXP425_PCI_WINDOW_BASE, IXP425_PCI_WINDOW_SIZE |
|
|
310 IXP_MAP_IO IXP425_QMGR_BASE, IXP425_QMGR_SIZE |
|
|
311 IXP_MAP_IO IXP425_PCI_CFG_BASE, IXP425_PCI_CFG_SIZE |
|
|
312 IXP_MAP_IO IXP425_EXP_CFG_BASE, IXP425_EXP_CFG_SIZE |
|
|
313 IXP_MAP_IO IXP425_MISC_CFG_BASE, IXP425_MISC_CFG_SIZE |
|
|
314 IXP_MAP_IO IXP425_SDRAM_CFG_BASE, IXP425_SDRAM_CFG_SIZE |
|
|
315 |
|
835
|
316 DISPLAY 0x1005, r7, r8 |
|
|
317 |
|
|
318 mcr p15, 0, r0, c7, c10, 4 // drain the write & fill buffers |
|
|
319 CPWAIT r0 |
|
|
320 |
|
|
321 // Set the TTB register to DRAM mmu_table |
|
|
322 ldr r0, =(SDRAM_PHYS_BASE | 0x4000) // RAM tables |
|
|
323 mcr p15, 0, r0, c2, c0, 0 // load page table pointer |
|
|
324 CPWAIT r0 |
|
|
325 |
|
|
326 // enable permission checks in all domains |
|
|
327 ldr r0, =0x55555555 |
|
|
328 mcr p15, 0, r0, c3, c0, 0 |
|
|
329 CPWAIT r0 |
|
|
330 |
|
|
331 DISPLAY 0x1006, r7, r8 |
|
|
332 |
|
|
333 // enable mmu |
|
|
334 mrc p15, 0, r0, c1, c0, 0 |
|
|
335 orr r0, r0, #MMU_Control_M |
|
|
336 orr r0, r0, #MMU_Control_R |
|
|
337 mcr p15, 0, r0, c1, c0, 0 |
|
|
338 CPWAIT r0 |
|
|
339 |
|
|
340 DISPLAY 0x1007, r7, r8 |
|
|
341 |
|
|
342 // enable D cache |
|
|
343 mrc p15, 0, r0, c1, c0, 0 |
|
|
344 orr r0, r0, #MMU_Control_C |
|
|
345 mcr p15, 0, r0, c1, c0, 0 |
|
|
346 CPWAIT r0 |
|
|
347 |
|
|
348 DISPLAY 0x1008, r7, r8 |
|
|
349 |
|
|
350 // Enable branch target buffer |
|
|
351 mrc p15, 0, r0, c1, c0, 0 |
|
|
352 orr r0, r0, #MMU_Control_BTB |
|
|
353 mcr p15, 0, r0, c1, c0, 0 |
|
|
354 CPWAIT r0 |
|
|
355 |
|
|
356 DISPLAY 0x1009, r7, r8 |
|
|
357 |
|
|
358 mcr p15, 0, r0, c7, c10, 4 // drain the write & fill buffers |
|
|
359 CPWAIT r0 |
|
|
360 |
|
|
361 mcr p15, 0, r0, c7, c7, 0 // flush Icache, Dcache and BTB |
|
|
362 CPWAIT r0 |
|
|
363 |
|
|
364 mcr p15, 0, r0, c8, c7, 0 // flush instuction and data TLBs |
|
|
365 CPWAIT r0 |
|
|
366 |
|
|
367 mcr p15, 0, r0, c7, c10, 4 // drain the write & fill buffers |
|
|
368 CPWAIT r0 |
|
|
369 |
|
|
370 DISPLAY 0x100A, r7, r8 |
|
|
371 |
|
|
372 // save SDRAM size |
|
|
373 ldr r1, =hal_dram_size /* [see hal_intr.h] */ |
|
|
374 mov r8, #SDRAM_SIZE |
|
|
375 str r8, [r1] |
|
|
376 |
|
|
377 DISPLAY 0x100B, r7, r8 |
|
|
378 |
|
|
379 .endm // _platform_setup1 |
|
|
380 |
|
|
381 #else // defined(CYG_HAL_STARTUP_ROM) |
|
|
382 #define PLATFORM_SETUP1 |
|
|
383 #endif |
|
|
384 |
|
|
385 #define PLATFORM_VECTORS _platform_vectors |
|
|
386 .macro _platform_vectors |
|
|
387 .endm |
|
|
388 |
|
|
389 /*---------------------------------------------------------------------------*/ |
|
|
390 /* end of hal_platform_setup.h */ |
|
|
391 #endif /* CYGONCE_HAL_PLATFORM_SETUP_H */ |