OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [arm/] [xscale/] [xsengine/] [current/] [include/] [hal_platform_setup.h] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
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, 2005 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):    Kurt Stremerch
46
// Contributors: Gary Thomas
47
// Date:         2003-02-23
48
//
49
//####DESCRIPTIONEND####
50
 
51
#include <pkgconf/system.h>          // System-wide configuration info
52
#include CYGBLD_HAL_VARIANT_H        // Variant specific configuration
53
#include CYGBLD_HAL_PLATFORM_H       // Platform specific configuration
54
#include <cyg/hal/hal_pxa2x0.h>      // Variant specific hardware definitions
55
#include <cyg/hal/hal_mmu.h>         // MMU definitions
56
#include <cyg/hal/hal_mm.h>          // more MMU definitions
57
#include <cyg/hal/xsengine.h>        // Platform specific hardware definitions
58
#include <cyg/hal/hal_spd.h>
59
 
60
#define MDCNFG_VALUE   0x000009C9
61
#define MDMRS_VALUE    0x00220022
62
#define MDREFR_VALUE_1 0x00018018
63
#define MDREFR_VALUE_2 0x00000000
64
#define MDREFR_VALUE_3 0x00000000
65
 
66
#define GPCR0_VALUE 0xFFFFFFFF
67
#define GPCR1_VALUE 0xFFFFFFFF
68
#define GPCR2_VALUE 0xFFFFFFFF
69
 
70
#define GPSR0_VALUE 0x0000A000
71
#define GPSR1_VALUE 0x00020000
72
#define GPSR2_VALUE 0x0000C000
73
 
74
#define GPDR0_VALUE 0x0000A000
75
#define GPDR1_VALUE 0x00022A80
76
#define GPDR2_VALUE 0x0000C000
77
 
78
#define GAFR0_L_VALUE 0x80000000
79
#define GAFR0_U_VALUE 0x00000010
80
#define GAFR1_L_VALUE 0x09988050
81
#define GAFR1_U_VALUE 0x00000008
82
#define GAFR2_L_VALUE 0xA0000000
83
#define GAFR2_U_VALUE 0x00000000
84
 
85
#define PSSR_VALUE          0x20
86
#define MSC0_VALUE_NONBURST 0x25F425F0
87
#define MSC0_VALUE_BURST    0x25F425F0
88
 
89
#define MDCNFG_DE0 0x00000001
90
#define MDCNFG_DE1 0x00000002
91
#define MDCNFG_DE2 0x00010000
92
#define MDCNFG_DE3 0x00020000
93
 
94
#undef XSDEBUG
95
 
96
#if defined(CYG_HAL_STARTUP_ROM)
97
#define PLATFORM_SETUP1  _platform_setup1
98
#define CYGHWR_HAL_ARM_HAS_MMU
99
#define CYGSEM_HAL_ROM_RESET_USES_JUMP
100
 
101
// This macro represents the initial startup code for the platform        
102
  .macro _platform_setup1
103
  // This is where we wind up immediately after reset. At this point, we
104
  // are executing from the boot address (0x00000000), not the eventual
105
  // flash address. Do some basic setup using position independent code
106
  // then switch to real flash address
107
 
108
// FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME 
109
// This is a quick and dirty workaround to an apparent gas/ld
110
// bug. The computed UNMAPPED_PTR(reset_vector) is off by 0x20.
111
  .rept 0x20/4
112
  nop
113
  .endr
114
// FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME 
115
 
116
#if defined(XSDEBUG)
117
  ldr     r0,=PXA2X0_GPDR1    /* GPIO as output */
118
  ldr     r1,=0x80
119
  str     r1,[r0]
120
  ldr     r0,=PXA2X0_GAFR1_L  /* GPIO as decated BTUART */
121
  ldr     r1,=0x0088000
122
  str     r1,[r0]
123
  ldr     r0,=PXA2X0_FFLCR    /* 8bit char + DLAB(Divisor access) */
124
  ldr     r1,=0x83
125
  str     r1,[r0]
126
  ldr     r0,=PXA2X0_FFDLL    /* Divisor to 115200 */
127
  ldr     r1,=8
128
  str     r1,[r0]
129
  ldr     r0,=PXA2X0_FFLCR    /* DLAB off */
130
  ldr     r1,=0x3
131
  str     r1,[r0]
132
  ldr     r0,=PXA2X0_FFIER    /* enable UART */
133
  ldr     r1,=0x40
134
  str     r1,[r0]
135
  ldr     r0,=PXA2X0_FFTHR    /* send char A */
136
  ldr     r1,=0x41
137
  str     r1,[r0]
138
#endif
139
 
140
  // Disable interrupts, by setting the Interrupt Mask Registers to all 0's
141
  ldr     r1,=PXA2X0_ICMR
142
  mov     r0,#0
143
  str     r0,[r1]
144
 
145
  // disable MMU
146
  mov     r0, #0x0
147
  mcr     p15, 0, r0, c1, c0, 0
148
 
149
  // flush TLB
150
  mov     r0, #0x0
151
  mcr     p15, 0, r0, c8, c7, 0   //  Flush TLB
152
 
153
  // flush I&D caches and BTB
154
  mov     r0, #0x0
155
  mcr     p15, 0, r0, c7, c7, 0   //  Flush caches
156
 
157
  CPWAIT r0
158
 
159
  // Enables access to coprocessor 0 (The only extra coprocessor on the PXA250)
160
  ldr     r0, =0x00000001
161
  mcr     p15, 0, r0, c15, c1, 0
162
 
163
  // Disable the IRQ's and FIQ's in the program status register and 
164
  // enable supervisor mode 
165
  ldr     r0,=(CPSR_IRQ_DISABLE|CPSR_FIQ_DISABLE|CPSR_SUPERVISOR_MODE)
166
  msr     cpsr, r0
167
 
168
  // Set TURBO mode
169
 
170
  ldr     r2, =0x00000321
171
  ldr     r1, =PXA2X0_CCCR
172
  str     r2,[r1]
173
 
174
  ldr     r1, =0x00000003
175
  mcr     p14, 0, r1, c6, c0, 0
176
 
177
  // Set-up memory according to Eyxs specs
178
  // Set Refresh Values
179
  ldr     r1,=PXA2X0_MDREFR
180
  ldr     r2,=MDREFR_VALUE_1
181
  str     r2,[r1]
182
 
183
  //fetch platform value SDRAM
184
  ldr     r1,=PXA2X0_MDCNFG
185
  ldr     r2,=MDCNFG_VALUE
186
 
187
  bic     r2,r2,#(MDCNFG_DE0|MDCNFG_DE1)
188
  bic     r2,r2,#(MDCNFG_DE2|MDCNFG_DE3)
189
 
190
  str     r2,[r1]
191
 
192
  // pause for 200 uSecs
193
  ldr r3, =PXA2X0_OSCR
194
  mov r2, #0
195
  str r2, [r3]
196
  ldr r4, =0x300
197
1:
198
  ldr r2, [r3]
199
  cmp r4, r2
200
  bgt 1b
201
 
202
  ldr     r2,=PXA2X0_RAM_BANK0_BASE
203
  str     r2,[r2]
204
  str     r2,[r2]
205
  str     r2,[r2]
206
  str     r2,[r2]
207
  str     r2,[r2]
208
  str     r2,[r2]
209
  str     r2,[r2]
210
  str     r2,[r2]
211
 
212
  ldr     r1,=PXA2X0_MDCNFG
213
  ldr     r2,=MDCNFG_VALUE
214
  str     r2,[r1]
215
 
216
  ldr     r1,=PXA2X0_MDMRS
217
  ldr     r2,=MDMRS_VALUE
218
  str     r2,[r1]
219
 
220
#if defined(XSDEBUG)
221
  ldr     r0,=PXA2X0_FFTHR    /* send char B */
222
  ldr     r1,=0x42
223
  str     r1,[r0]
224
#endif
225
 
226
  // Set Static memory registers
227
  ldr     r1,=PXA2X0_MSC0
228
  ldr     r2,=MSC0_VALUE_NONBURST
229
  str     r2,[r1]
230
 
231
  // Setup GPIO clear registers
232
  ldr r1, =PXA2X0_GPCR0
233
  ldr r2, =(GPCR0_VALUE)
234
  str r2, [r1]
235
 
236
  ldr r1, =PXA2X0_GPCR1
237
  ldr r2, =(GPCR1_VALUE)
238
  str r2, [r1]
239
 
240
  ldr r1, =PXA2X0_GPCR2
241
  ldr r2, =(GPCR2_VALUE)
242
  str r2, [r1]
243
 
244
  // Setup GPIO set registers
245
  ldr r1, =PXA2X0_GPSR0
246
  ldr r2, =(GPSR0_VALUE)
247
  str r2, [r1]
248
 
249
  ldr r1, =PXA2X0_GPSR1
250
  ldr r2, =(GPSR1_VALUE)
251
  str r2, [r1]
252
 
253
  ldr r1, =PXA2X0_GPSR2
254
  ldr r2, =(GPSR2_VALUE)
255
  str r2, [r1]
256
 
257
  // Setup GPIO direction registers
258
  ldr r1, =PXA2X0_GPDR0
259
  ldr r2, =(GPDR0_VALUE)
260
  str r2, [r1]
261
 
262
  ldr r1, =PXA2X0_GPDR1
263
  ldr r2, =(GPDR1_VALUE)
264
  str r2, [r1]
265
 
266
  ldr r1, =PXA2X0_GPDR2
267
  ldr r2, =(GPDR2_VALUE)
268
  str r2, [r1]
269
 
270
  // Setup GPIO alternate function registers
271
  ldr r1, =PXA2X0_GAFR0_L
272
  ldr r2, =(GAFR0_L_VALUE)
273
  str r2, [r1]
274
 
275
  ldr r1, =PXA2X0_GAFR0_U
276
  ldr r2, =(GAFR0_U_VALUE)
277
  str r2, [r1]
278
 
279
  ldr r1, =PXA2X0_GAFR1_L
280
  ldr r2, =(GAFR1_L_VALUE)
281
  str r2, [r1]
282
 
283
  ldr r1, =PXA2X0_GAFR1_U
284
  ldr r2, =(GAFR1_U_VALUE)
285
  str r2, [r1]
286
 
287
  ldr r1, =PXA2X0_GAFR2_L
288
  ldr r2, =(GAFR2_L_VALUE)
289
  str r2, [r1]
290
 
291
  ldr r1, =PXA2X0_GAFR2_U
292
  ldr r2, =(GAFR2_U_VALUE)
293
  str r2, [r1]
294
 
295
  ldr r1, =PXA2X0_PSSR
296
  ldr r2, =(PSSR_VALUE)
297
  str r2, [r1]
298
 
299
  // Enable the Icache
300
  mrc     p15, 0, r0, c1, c0, 0
301
  orr     r0, r0, #MMU_Control_I
302
  mcr     p15, 0, r0, c1, c0, 0
303
  CPWAIT  r0
304
 
305
#if defined(XSDEBUG)
306
  ldr     r0,=PXA2X0_FFTHR    /* send char C */
307
  ldr     r1,=0x43
308
  str     r1,[r0]
309
#endif
310
 
311
  // Set up a stack [for calling C code]
312
  ldr     r1,=__startup_stack
313
  ldr     r2,=PXA2X0_RAM_BANK0_BASE
314
  orr     sp,r1,r2
315
 
316
  // Create MMU tables
317
  bl      hal_mmu_init
318
 
319
#if defined(XSDEBUG)
320
  ldr     r0,=PXA2X0_FFTHR    /* send char D */
321
  ldr     r1,=0x44
322
  str     r1,[r0]
323
#endif
324
 
325
  // Enable MMU
326
  ldr     r2,=10f
327
  ldr     r1,=MMU_Control_Init|MMU_Control_M
328
  mcr     MMU_CP,0,r1,MMU_Control,c0
329
  mov     pc, r2
330
  nop
331
  nop
332
  nop
333
 
334
10:
335
#if defined(XSDEBUG)
336
  ldr     r0,=PXA2X0_FFTHR    /* send char E */
337
  ldr     r1,=0x45
338
  str     r1,[r0]
339
#endif
340
 
341
  .endm
342
 
343
#else // defined(CYG_HAL_STARTUP_ROM)
344
#define PLATFORM_SETUP1
345
#endif
346
 
347
#define PLATFORM_VECTORS         _platform_vectors
348
  .macro  _platform_vectors
349
  .globl  hal_pcsr_cfg_retry
350
  hal_pcsr_cfg_retry:   .long   0  // Boot-time value of PCSR Retry bit.
351
  .endm
352
 
353
/*---------------------------------------------------------------------------*/
354
/* end of hal_platform_setup.h                                               */
355
#endif /* CYGONCE_HAL_PLATFORM_SETUP_H */

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.