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

Subversion Repositories openrisc

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