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