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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [arm/] [sa11x0/] [cerf/] [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 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):    gthomas
46
// Contributors: gthomas
47
// Date:         2000-05-08
48
// Purpose:      Intel SA1110/Assabet 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 (SA11x0) specific configuration
59
#include CYGBLD_HAL_PLATFORM_H          // Platform specific configuration
60
#include <cyg/hal/hal_sa11x0.h>         // Variant specific hardware definitions
61
#include <cyg/hal/hal_mmu.h>            // MMU definitions
62
#include <cyg/hal/cerf.h>            // Platform specific hardware definitions
63
 
64
#if defined(CYG_HAL_STARTUP_ROM)
65
#define PLATFORM_SETUP1 _platform_setup1
66
#define CYGHWR_HAL_ARM_HAS_MMU
67
 
68
#if (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 59000)
69
#define SA11X0_PLL_CLOCK 0x0        
70
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 73700)
71
#define SA11X0_PLL_CLOCK 0x1
72
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 88500)
73
#define SA11X0_PLL_CLOCK 0x2        
74
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 103200) 
75
#define SA11X0_PLL_CLOCK 0x3        
76
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 118000)
77
#define SA11X0_PLL_CLOCK 0x4        
78
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 132700)
79
#define SA11X0_PLL_CLOCK 0x5        
80
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 147500)
81
#define SA11X0_PLL_CLOCK 0x6        
82
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 162200)
83
#define SA11X0_PLL_CLOCK 0x7        
84
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 176900)
85
#define SA11X0_PLL_CLOCK 0x8        
86
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 191700)
87
#define SA11X0_PLL_CLOCK 0x9        
88
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 206400)
89
#define SA11X0_PLL_CLOCK 0xA        
90
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 221200)
91
#define SA11X0_PLL_CLOCK 0xB        
92
#else
93
#error Invalid processor clock speed
94
#endif
95
 
96
#define CAS0_WAVEFORM_VALUE     0xAAAAAA9F
97
#define CAS1_WAVEFORM_VALUE     0xAAAAAAAA
98
#define CAS2_WAVEFORM_VALUE     0xAAAAAAAA
99
 
100
#define MSC0VALUE                   0xFFFCFFFC
101
#define MSC1VALUE                   0xFFFFFFFF
102
#define MSC2VALUE                   0xFFFFFFFF
103
 
104
#define DRAM_CONFIG_VALUE       0x72547254
105
#define RFSH_CONFIG_VALUE       0x003002D1
106
 
107
// Macros that handle the red debug LED wired to GPIO-1
108
 
109
        .macro    _LED_ON,led
110
        ldr     r1,=SA11X0_GPIO_PIN_OUTPUT_SET
111
        mov     r0,#(1<<\led)
112
        str     r0,[r1]
113
        // Delay        
114
        ldr     r1,=10000
115
10:     sub     r1,r1,#1
116
        cmp     r1,#0
117
        bne     10b
118
        .endm
119
 
120
        .macro    _LED_OFF,led
121
        ldr     r1,=SA11X0_GPIO_PIN_OUTPUT_CLEAR
122
        mov     r0,#(1<<\led)
123
        str     r0,[r1]
124
        // Delay        
125
        ldr     r1,=10000
126
10:     sub     r1,r1,#1
127
        cmp     r1,#0
128
        bne     10b
129
        .endm
130
 
131
// This macro represents the initial startup code for the platform        
132
        .macro  _platform_setup1
133
 
134
        // Disable all interrupts (ICMR not specified on power-up)
135
        ldr     r1,=SA11X0_ICMR
136
        mov     r0,#0
137
        str     r0,[r1]
138
 
139
            // Initialize the CPU.
140
                mov     r0, #0x0                //  Get a zero to turn things off
141
                mcr     p15, 0, r0, c1, c0, 0     //  MMU off
142
                mcr     p15, 0, r0, c8, c7, 0     //  Flush TLB
143
                mcr     p15, 0, r0, c7, c7, 0     //  Flush caches
144
                nop
145
                nop
146
                nop
147
        nop
148
 
149
        // Disable IRQs and FIQs
150
        mov     r0, #(CPSR_IRQ_DISABLE | \
151
                      CPSR_FIQ_DISABLE | \
152
                      CPSR_SUPERVISOR_MODE)
153
        msr     cpsr, r0
154
 
155
            // Set up GPIOs (LED1 off)
156
        ldr     r1,=SA11X0_GPIO_PIN_DIRECTION
157
        ldr     r2,=0x0320000f          // Set LT1348,DREN,RXEN,CF and LEDs to be output
158
        str     r2,[r1]
159
        ldr     r3,=SA11X0_GPIO_PIN_OUTPUT_SET
160
        ldr     r2,=0x0300000f          // Set the LT1348,DREN,RXEN and LEDs to 1.
161
        str     r2,[r3]
162
        ldr     r3,=SA11X0_GPIO_PIN_OUTPUT_CLEAR
163
        ldr     r2,=0x0020000f          // Set CF reset,LEDS OFF
164
        str     r2,[r3]
165
 
166
        // Turn on LED 0
167
        _LED_ON 0
168
 
169
        // Disable clock switching
170
        mcr     p15,0,r0,\
171
                SA11X0_TEST_CLOCK_AND_IDLE_REGISTER,\
172
                SA11X0_DISABLE_CLOCK_SWITCHING_RM,\
173
                SA11X0_DISABLE_CLOCK_SWITCHING_OPCODE
174
 
175
        // Set up processor clock
176
        ldr     r1,=SA11X0_PWR_MGR_PLL_CONFIG
177
        ldr     r2,=SA11X0_PLL_CLOCK
178
        str     r2,[r1]
179
 
180
        // Turn clock switching back on
181
        mcr     p15,0,r0,\
182
                SA11X0_TEST_CLOCK_AND_IDLE_REGISTER,\
183
                SA11X0_ENABLE_CLOCK_SWITCHING_RM,\
184
                SA11X0_ENABLE_CLOCK_SWITCHING_OPCODE
185
        nop
186
        nop
187
 
188
        // Let the PLL settle down      
189
        ldr     r1,=20000
190
10:     sub     r1,r1,#1
191
        cmp     r1,#0
192
        bne     10b
193
 
194
        // Turn on LED 1
195
        _LED_ON 1
196
 
197
        // Initialize DRAM controller
198
        ldr     r1,=dram_table
199
        ldr     r2,=__exception_handlers
200
        sub     r1,r1,r2
201
        ldr     r2,[r1],#4                      // First control register
202
10:     ldr     r3,[r1],#4
203
        str     r3,[r2]
204
        ldr     r2,[r1],#4                      // Next control register
205
        cmp     r2,#0
206
        bne     10b
207
 
208
        // Turn on LED 2
209
        _LED_ON 2
210
 
211
        // Enable UART
212
        ldr     r1,=SA1110_GPCLK_CONTROL_0
213
        ldr     r2,=SA1110_GPCLK_SUS_UART
214
        str     r2,[r1]
215
 
216
        // Release DRAM hold (set by RESET)
217
        ldr     r1,=SA11X0_PWR_MGR_SLEEP_STATUS
218
        ldr     r2,=SA11X0_DRAM_CONTROL_HOLD
219
        str     r2,[r1]
220
 
221
        // Perform 8 reads from unmapped/unenabled DRAM
222
        ldr     r1,=SA11X0_RAM_BANK0_BASE
223
            ldr     r2,[r1]
224
        ldr     r2,[r1]
225
        ldr     r2,[r1]
226
        ldr     r2,[r1]
227
        ldr     r2,[r1]
228
        ldr     r2,[r1]
229
        ldr     r2,[r1]
230
        ldr     r2,[r1]
231
 
232
            // Enable DRAM bank 0
233
        ldr     r1,=SA11X0_DRAM_CONFIGURATION
234
        ldr     r2,=DRAM_CONFIG_VALUE
235
            ldr     r3,=0x00030003
236
        orr     r2, r2, r3
237
        str     r2,[r1]
238
 
239
            // Wait for the DRAM to come up.
240
        mov     r1, #0x400
241
0:           subs    r1, r1, #1
242
        bne     0b
243
 
244
            // Turn on LED 3
245
        _LED_ON 3
246
 
247
        b       19f
248
 
249
// DRAM controller initialization        
250
dram_table:
251
        .word   SA11X0_DRAM0_CAS_0,           CAS0_WAVEFORM_VALUE
252
        .word   SA11X0_DRAM0_CAS_1,           CAS1_WAVEFORM_VALUE
253
        .word   SA11X0_DRAM0_CAS_2,           CAS2_WAVEFORM_VALUE
254
        .word   SA11X0_DRAM2_CAS_0,           CAS0_WAVEFORM_VALUE
255
        .word   SA11X0_DRAM2_CAS_1,           CAS1_WAVEFORM_VALUE
256
        .word   SA11X0_DRAM2_CAS_2,           CAS2_WAVEFORM_VALUE
257
        .word   SA11X0_REFRESH_CONFIGURATION, RFSH_CONFIG_VALUE
258
        .word   SA11X0_DRAM_CONFIGURATION,    DRAM_CONFIG_VALUE
259
            .word   SA11X0_STATIC_CONTROL_0,      MSC0VALUE
260
            .word   SA11X0_STATIC_CONTROL_1,      MSC1VALUE
261
            .word   SA11X0_STATIC_CONTROL_2,      MSC2VALUE
262
            .word   0, 0
263
 
264
19:
265
        // Wakeup from deep sleep mode
266
        ldr     r1,=SA11X0_RESET_STATUS
267
        ldr     r2,[r1]
268
        cmp     r2,#SA11X0_SLEEP_MODE_RESET
269
        bne     45f
270
        ldr     r1,=SA11X0_PWR_MGR_SCRATCHPAD
271
        ldr     r1,[r1]
272
        mov     pc,r1
273
        nop
274
45:     nop
275
 
276
        // Release peripheral hold (set by RESET)
277
        ldr     r1,=SA11X0_PWR_MGR_SLEEP_STATUS
278
        ldr     r2,=SA11X0_PERIPHERAL_CONTROL_HOLD
279
        str     r2,[r1]
280
 
281
        // Set up a stack [for calling C code]
282
        ldr     r1,=__startup_stack
283
        ldr     r2,=SA11X0_RAM_BANK0_BASE
284
        orr     sp,r1,r2
285
 
286
        // Create MMU tables
287
        bl      hal_mmu_init
288
 
289
        // Turn OFF LED 0 
290
        _LED_OFF 0
291
 
292
        // Enable MMU
293
        ldr     r2,=10f
294
        ldr         r1,=MMU_Control_Init|MMU_Control_M
295
            mcr     MMU_CP,0,r1,MMU_Control,c0
296
            mov     pc,r2    /* Change address spaces */
297
            nop
298
            nop
299
            nop
300
 
301
10:
302
        // Turn OFF LED 1 
303
        _LED_OFF 1
304
 
305
        // Save shadow copy of BCR, also hardware configuration
306
        ldr     r1,=_cerf_BCR
307
        str     r2,[r1]
308
        .endm
309
 
310
#else // defined(CYG_HAL_STARTUP_ROM)
311
#define PLATFORM_SETUP1
312
#endif
313
 
314
#define PLATFORM_VECTORS         _platform_vectors
315
        .macro  _platform_vectors
316
        .globl  _cerf_BCR
317
_cerf_BCR:   .long   0       // Board Control register shadow
318
        .endm
319
 
320
/*---------------------------------------------------------------------------*/
321
/* end of hal_platform_setup.h                                               */
322
#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.