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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [arm/] [arm9/] [aaed2000/] [v2_0/] [include/] [hal_platform_setup.h] - Blame information for rev 565

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
#ifndef CYGONCE_HAL_PLATFORM_SETUP_H
2
#define CYGONCE_HAL_PLATFORM_SETUP_H
3
/*=============================================================================
4
//
5
//      hal_platform_setup.h
6
//
7
//      Platform specific support for HAL (assembly code)
8
//
9
//=============================================================================
10
//####ECOSGPLCOPYRIGHTBEGIN####
11
// -------------------------------------------
12
// This file is part of eCos, the Embedded Configurable Operating System.
13
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
14
//
15
// eCos is free software; you can redistribute it and/or modify it under
16
// the terms of the GNU General Public License as published by the Free
17
// Software Foundation; either version 2 or (at your option) any later version.
18
//
19
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
20
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
21
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
22
// for more details.
23
//
24
// You should have received a copy of the GNU General Public License along
25
// with eCos; if not, write to the Free Software Foundation, Inc.,
26
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
27
//
28
// As a special exception, if other files instantiate templates or use macros
29
// or inline functions from this file, or you compile this file and link it
30
// with other works to produce a work based on this file, this file does not
31
// by itself cause the resulting work to be covered by the GNU General Public
32
// License. However the source code for this file must still be made available
33
// in accordance with section (3) of the GNU General Public License.
34
//
35
// This exception does not invalidate any other reasons why a work based on
36
// this file might be covered by the GNU General Public License.
37
//
38
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
39
// at http://sources.redhat.com/ecos/ecos-license/
40
// -------------------------------------------
41
//####ECOSGPLCOPYRIGHTEND####
42
//=============================================================================
43
//#####DESCRIPTIONBEGIN####
44
//
45
// Author(s):    gthomas
46
// Contributors: gthomas
47
// Date:         2001-10-27
48
// Purpose:      ARM9/AAED2000 platform 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_mmu.h>            // MMU definitions
61
#include <cyg/hal/aaed2000.h>           // Platform specific hardware definitions
62
 
63
#if defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_ROMRAM)
64
#define PLATFORM_SETUP1 _platform_setup1
65
#define CYGHWR_HAL_ARM_HAS_MMU
66
#define CYGSEM_HAL_ROM_RESET_USES_JUMP
67
 
68
// We need this here - can't rely on a translation table until MMU has
69
// been initialized
70
        .macro RAW_LED_MACRO x
71
        ldr     r0,=0x30000000
72
        ldr     r1,[r0]
73
        bic     r1,r1,#0xE0000000
74
        orr     r1,r1,#((0x7 & ~(\x))<<29)
75
        str     r1, [r0]
76
        .endm
77
 
78
// This macro represents the initial startup code for the platform        
79
        .macro  _platform_setup1
80
        RAW_LED_MACRO 0
81
#ifndef CYG_HAL_STARTUP_RAM
82
        // Prevent all interrupts
83
        ldr    r0,=AAEC_INT_ENC
84
        mov    r1,#-1
85
        str    r1,[r0]
86
 
87
        // Disable and clear caches
88
        mrc  p15,0,r0,c1,c0,0
89
        bic  r0,r0,#0x1000              // disable ICache
90
        bic  r0,r0,#0x000f              // disable DCache, write buffer,
91
                                        // MMU and alignment faults
92
        mcr  p15,0,r0,c1,c0,0
93
        nop
94
        nop
95
        mov  r0,#0
96
        mcr  p15,0,r0,c7,c6,0           // clear data cache
97
#if 0
98
        mrc  p15,0,r0,c15,c1,0          // disable streaming
99
        orr  r0,r0,#0x80
100
        mcr  p15,0,r0,c15,c1,0
101
#endif
102
 
103
        // Initialize memory controllers
104
 
105
        // Static memory controller
106
        // Area0: Flash: 32bit wide
107
        ldr     r0,=AAEC_SMCBCR0
108
        ldr     r1,=(AAEC_SMCBCR_MW32 | AAEC_SMCBCR_WST(_CS0_WST) | AAEC_SMCBCR_IDCY(_CS0_IDCY))
109
        str     r1,[r0]
110
        // Area1: Ethernet: 16bit wide
111
        ldr     r0,=AAEC_SMCBCR1
112
        ldr     r1,=(AAEC_SMCBCR_MW16 | AAEC_SMCBCR_WST(_CS1_WST) | AAEC_SMCBCR_IDCY(_CS1_IDCY))
113
        str     r1,[r0]
114
        // Area3: GPIO: 32bit wide
115
        ldr     r0,=AAEC_SMCBCR3
116
        ldr     r1,=(AAEC_SMCBCR_MW32 | AAEC_SMCBCR_WST(_CS3_WST) | AAEC_SMCBCR_IDCY(_CS3_IDCY))
117
        str     r1,[r0]
118
        RAW_LED_MACRO 1
119
 
120
        // Set clock frequencies
121
        // First set CPU to synchronous mode
122
        mrc p15, 0, r0, c1, c0, 0
123
        // configure for synchronous mode: FCLK >= HCLK by integer
124
        // multiple
125
        orr r0, r0, #0x40000000
126
        // configure for FastBus mode - FCLK and HCLK *must* be equal
127
        // bic r0, r0, #0x40000000
128
        bic r0, r0, #0x80000000
129
        mcr p15, 0, r0, c1, c0, 0
130
 
131
        ldr    r0,=AAEC_CSC_CLKSET
132
        ldr    r1,=AAEC_CSC_CLKSET_INIT
133
        str    r1,[r0]
134
        // follow clock change by 5 NOPs
135
        nop;nop;nop;nop;nop
136
 
137
 
138
        // Synchronous memory controller (as per table 4-12)
139
 
140
        ldr     r0,=AAEC_SMC_DEV0
141
        ldr     r1,=AAEC_SMC_DEV_INIT
142
        str     r1,[r0]
143
        str     r1,[r0, #4]
144
        str     r1,[r0, #8]
145
        str     r1,[r0, #12]
146
 
147
        // step1: delay 100usecs
148
        ldr     r2,=AAEC_TMR_T1_BASE
149
        ldr     r3,=AAEC_TMR_TxCONTROL_508KHZ_uS(100)
150
        str     r3,[r2, #AAEC_TMR_TxLOAD_OFFSET]
151
        ldr     r3,=(AAEC_TMR_TxCONTROL_ENABLE|AAEC_TMR_TxCONTROL_MODE_FREE|AAEC_TMR_TxCONTROL_508KHZ)
152
        str     r3,[r2, #AAEC_TMR_TxCONTROL_OFFSET]
153
1:      ldr     r3,[r2, #AAEC_TMR_TxVALUE_OFFSET]
154
        cmp     r3,#0
155
        bne     1b
156
        str     r3,[r2, #AAEC_TMR_TxCONTROL_OFFSET]
157
 
158
        // step2: issue NOP command
159
        ldr     r0,=AAEC_SMC_GLOBAL
160
        ldr     r1,=AAEC_SMC_GLOBAL_CMD_NOP
161
        str     r1,[r0]
162
 
163
        // step3: wait 200usecs
164
        ldr     r3,=AAEC_TMR_TxCONTROL_508KHZ_uS(200)
165
        str     r3,[r2, #AAEC_TMR_TxLOAD_OFFSET]
166
        ldr     r3,=(AAEC_TMR_TxCONTROL_ENABLE|AAEC_TMR_TxCONTROL_MODE_FREE|AAEC_TMR_TxCONTROL_508KHZ)
167
        str     r3,[r2, #AAEC_TMR_TxCONTROL_OFFSET]
168
1:      ldr     r3,[r2, #AAEC_TMR_TxVALUE_OFFSET]
169
        cmp     r3,#0
170
        bne     1b
171
        str     r3,[r2, #AAEC_TMR_TxCONTROL_OFFSET]
172
 
173
        // step4: PreCharge All
174
        ldr     r1,=AAEC_SMC_GLOBAL_CMD_PREALL
175
        str     r1,[r0]
176
 
177
        // step5: set refresh time to 10
178
        ldr     r3,=AAEC_SMC_REFRESH_TIME
179
        mov     r4,#10
180
        str     r4,[r3]
181
 
182
        // step6: wait 80 clock cycles, allowing 8 refresh cycles for SDRAM
183
        mov     r3, #100
184
1:      subs    r3, r3, #1
185
        bne     1b
186
 
187
        // step7: set normal refresh count
188
        // We need to do a refresh every 15.6usecs. The counter runs
189
        // at bus clock, so the delay is (15.6usecs*bus speed) or
190
        // (156*(bus speed/10)/1000000).
191
        ldr     r3,=AAEC_SMC_REFRESH_TIME
192
        ldr     r4,=(156*(CYGNUM_HAL_ARM_AAED2000_BUS_CLOCK/10)/1000000)
193
        str     r4,[r3]
194
 
195
        // step8: set mode
196
        ldr     r1,=AAEC_SMC_GLOBAL_CMD_MODE
197
        str     r1,[r0]
198
 
199
        // step9: program mode
200
        // from page 36: SDRAM, WBL=0, TM=0, CAS=3, Sequential, BL=4
201
        ldr     r3,=0xf000c800
202
        ldr     r3,[r3]
203
 
204
        // step10: enable SDRAM
205
        // step8: set mode
206
        ldr     r1,=AAEC_SMC_GLOBAL_CMD_ENABLE
207
        str     r1,[r0]
208
        RAW_LED_MACRO 2
209
#endif
210
#ifdef CYG_HAL_STARTUP_ROMRAM
211
        // Compute [logical] base address of this image in ROM
212
        bl      10f
213
10:     mov     r9,lr
214
        ldr     r8,=~0xFF01FFFF         // Bits to ignore
215
        and     r9,r9,r8
216
        orr     r9,r9,#0x60000000       // Turn into ROM address
217
#endif        
218
 
219
        // Set up a stack [for calling C code]
220
        ldr     r1,=__startup_stack
221
        ldr     r2,=AAED2000_SDRAM_PHYS_BASE
222
        orr     sp,r1,r2
223
 
224
        // Create MMU tables
225
        RAW_LED_MACRO 4
226
        bl      hal_mmu_init
227
        RAW_LED_MACRO 5
228
 
229
        // Enable MMU
230
        ldr     r2,=10f
231
#ifdef CYG_HAL_STARTUP_ROMRAM
232
        ldr     r1,=__exception_handlers
233
        sub     r1,r2,r1
234
        add     r2,r9,r1        // r9 has ROM offset
235
#endif        
236
        ldr     r1,=MMU_Control_Init|MMU_Control_M
237
        mcr     MMU_CP,0,r1,MMU_Control,c0
238
        mov     pc,r2    /* Change address spaces */
239
        nop
240
        nop
241
        nop
242
10:
243
        RAW_LED_MACRO 6
244
 
245
#ifdef CYG_HAL_STARTUP_ROMRAM
246
        mov     r0,r9                     // Relocate FLASH/ROM to RAM
247
        ldr     r1,=__exception_handlers  // ram base & length
248
        ldr     r2,=__rom_data_end
249
20:     ldr     r3,[r0],#4
250
        str     r3,[r1],#4
251
        cmp     r1,r2
252
        bne     20b
253
        ldr     r0,=30f
254
        mov     pc,r0
255
        nop
256
        nop
257
        nop
258
        nop
259
30:
260
#endif
261
        RAW_LED_MACRO 7
262
        .endm
263
 
264
#else // defined(CYG_HAL_STARTUP_RAM)
265
#define PLATFORM_SETUP1
266
#endif
267
 
268
//-----------------------------------------------------------------------------
269
// end of hal_platform_setup.h
270
#endif // CYGONCE_HAL_PLATFORM_SETUP_H

powered by: WebSVN 2.1.0

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