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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [arm/] [sa11x0/] [cerfpda/] [v2_0/] [include/] [hal_platform_setup.h] - Blame information for rev 27

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
//
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 Red Hat, 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 version.
19
//
20
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
21
// 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 along
26
// with eCos; if not, write to the Free Software Foundation, Inc.,
27
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
28
//
29
// As a special exception, if other files instantiate templates or use macros
30
// or inline functions from this file, or you compile this file and link it
31
// with other works to produce a work based on this file, this file does not
32
// by itself cause the resulting work to be covered by the GNU General Public
33
// License. However the source code for this file must still be made available
34
// in accordance with section (3) of the GNU General Public License.
35
//
36
// This exception does not invalidate any other reasons why a work based on
37
// this file might be covered by the GNU General Public License.
38
//
39
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
40
// at http://sources.redhat.com/ecos/ecos-license/
41
// -------------------------------------------
42
//####ECOSGPLCOPYRIGHTEND####
43
//=============================================================================
44
//#####DESCRIPTIONBEGIN####
45
//
46
// Author(s):    gthomas
47
// Contributors: gthomas
48
// Date:         2000-05-08
49
// Purpose:      Intel SA1110/Assabet platform specific support routines
50
// Description:
51
// Usage:        #include <cyg/hal/hal_platform_setup.h>
52
//     Only used by "vectors.S"
53
//
54
//####DESCRIPTIONEND####
55
//
56
//===========================================================================*/
57
 
58
#include <pkgconf/system.h>             // System-wide configuration info
59
#include CYGBLD_HAL_VARIANT_H           // Variant (SA11x0) specific configuration
60
#include CYGBLD_HAL_PLATFORM_H          // Platform specific configuration
61
#include <cyg/hal/hal_sa11x0.h>         // Variant specific hardware definitions
62
#include <cyg/hal/hal_mmu.h>            // MMU definitions
63
#include <cyg/hal/cerfpda.h>            // Platform specific hardware definitions
64
 
65
#if defined(CYG_HAL_STARTUP_ROM)
66
#define PLATFORM_SETUP1 _platform_setup1
67
#define CYGHWR_HAL_ARM_HAS_MMU
68
 
69
#if (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 59000)
70
#define SA11X0_PLL_CLOCK 0x0        
71
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 73700)
72
#define SA11X0_PLL_CLOCK 0x1
73
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 88500)
74
#define SA11X0_PLL_CLOCK 0x2        
75
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 103200) 
76
#define SA11X0_PLL_CLOCK 0x3        
77
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 118000)
78
#define SA11X0_PLL_CLOCK 0x4        
79
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 132700)
80
#define SA11X0_PLL_CLOCK 0x5        
81
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 147500)
82
#define SA11X0_PLL_CLOCK 0x6        
83
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 162200)
84
#define SA11X0_PLL_CLOCK 0x7        
85
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 176900)
86
#define SA11X0_PLL_CLOCK 0x8        
87
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 191700)
88
#define SA11X0_PLL_CLOCK 0x9        
89
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 206400)
90
#define SA11X0_PLL_CLOCK 0xA        
91
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 221200)
92
#define SA11X0_PLL_CLOCK 0xB        
93
#else
94
#error Invalid processor clock speed
95
#endif
96
 
97
 
98
#define CAS0_WAVEFORM_VALUE     0xAAAAAA9F
99
#define CAS1_WAVEFORM_VALUE     0xAAAAAAAA
100
#define CAS2_WAVEFORM_VALUE     0xAAAAAAAA
101
 
102
#define MSC0VALUE           0xFFFCFFF8
103
#define MSC1VALUE           0xFFFFFFFF
104
#define MSC2VALUE           0xFFFFFFFF
105
 
106
#define DRAM_CONFIG_VALUE   0x72647264
107
#define RFSH_CONFIG_VALUE   0x00300161
108
 
109
// Macros that handle the red debug LED wired to GPIO-1
110
 
111
        .macro    _LED_ON,led
112
        ldr     r1,=SA11X0_GPIO_PIN_OUTPUT_SET
113
        mov     r0,#(1<<\led)
114
        str     r0,[r1]
115
        // Delay        
116
        ldr     r1,=10000
117
10:     sub     r1,r1,#1
118
        cmp     r1,#0
119
        bne     10b
120
        .endm
121
 
122
        .macro    _LED_OFF,led
123
        ldr     r1,=SA11X0_GPIO_PIN_OUTPUT_CLEAR
124
        mov     r0,#(1<<\led)
125
        str     r0,[r1]
126
        // Delay        
127
        ldr     r1,=10000
128
10:     sub     r1,r1,#1
129
        cmp     r1,#0
130
        bne     10b
131
        .endm
132
 
133
// This macro represents the initial startup code for the platform        
134
        .macro  _platform_setup1
135
 
136
        // Disable all interrupts (ICMR not specified on power-up)
137
        ldr     r1,=SA11X0_ICMR
138
        mov     r0,#0
139
        str     r0,[r1]
140
 
141
        // Initialize the CPU.
142
        mov     r0, #0x0                //  Get a zero to turn things off
143
        mcr     p15, 0, r0, c1, c0, 0     //  MMU off
144
        mcr     p15, 0, r0, c8, c7, 0     //  Flush TLB
145
        mcr     p15, 0, r0, c7, c7, 0     //  Flush caches
146
        nop
147
        nop
148
        nop
149
        nop
150
 
151
        // Disable IRQs and FIQs
152
        mov     r0, #(CPSR_IRQ_DISABLE | \
153
                      CPSR_FIQ_DISABLE | \
154
                      CPSR_SUPERVISOR_MODE)
155
        msr     cpsr, r0
156
 
157
            // Set up GPIOs (LED1 off)
158
        ldr     r1,=SA11X0_GPIO_PIN_DIRECTION
159
        ldr     r2,=0x0320000f          // Set LT1348,DREN,RXEN,CF and LEDs to be output
160
        str     r2,[r1]
161
        ldr     r3,=SA11X0_GPIO_PIN_OUTPUT_SET
162
        ldr     r2,=0x0300000f          // Set the LT1348,DREN,RXEN and LEDs to 1.
163
        str     r2,[r3]
164
        ldr     r3,=SA11X0_GPIO_PIN_OUTPUT_CLEAR
165
        ldr     r2,=0x0020000f          // Set CF reset,LEDS OFF
166
        str     r2,[r3]
167
 
168
        // Turn on LED 0
169
        _LED_ON 0
170
 
171
        // Disable clock switching
172
        mcr     p15,0,r0,\
173
                SA11X0_TEST_CLOCK_AND_IDLE_REGISTER,\
174
                SA11X0_DISABLE_CLOCK_SWITCHING_RM,\
175
                SA11X0_DISABLE_CLOCK_SWITCHING_OPCODE
176
 
177
        // Set up processor clock
178
        ldr     r1,=SA11X0_PWR_MGR_PLL_CONFIG
179
        ldr     r2,=SA11X0_PLL_CLOCK
180
        str     r2,[r1]
181
 
182
        // Turn clock switching back on
183
        mcr     p15,0,r0,\
184
                SA11X0_TEST_CLOCK_AND_IDLE_REGISTER,\
185
                SA11X0_ENABLE_CLOCK_SWITCHING_RM,\
186
                SA11X0_ENABLE_CLOCK_SWITCHING_OPCODE
187
        nop
188
        nop
189
 
190
        // Let the PLL settle down      
191
        ldr     r1,=20000
192
10:     sub     r1,r1,#1
193
        cmp     r1,#0
194
        bne     10b
195
 
196
        // Turn on LED 1
197
        _LED_ON 1
198
 
199
        // Initialize DRAM controller
200
        ldr     r1,=dram_table
201
        ldr     r2,=__exception_handlers
202
        sub     r1,r1,r2
203
        ldr     r2,[r1],#4                      // First control register
204
10:     ldr     r3,[r1],#4
205
        str     r3,[r2]
206
        ldr     r2,[r1],#4                      // Next control register
207
        cmp     r2,#0
208
        bne     10b
209
 
210
        // Turn on LED 2
211
        _LED_ON 2
212
 
213
        // Enable UART
214
        ldr     r1,=SA1110_GPCLK_CONTROL_0
215
        ldr     r2,=SA1110_GPCLK_SUS_UART
216
        str     r2,[r1]
217
 
218
        // Release DRAM hold (set by RESET)
219
        ldr     r1,=SA11X0_PWR_MGR_SLEEP_STATUS
220
        ldr     r2,=SA11X0_DRAM_CONTROL_HOLD
221
        str     r2,[r1]
222
 
223
        // Perform 8 reads from unmapped/unenabled DRAM
224
        ldr     r1,=SA11X0_RAM_BANK0_BASE
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
        ldr     r2,[r1]
232
        ldr     r2,[r1]
233
 
234
            // Enable DRAM bank 0
235
        ldr     r1,=SA11X0_DRAM_CONFIGURATION
236
        ldr     r2,=DRAM_CONFIG_VALUE
237
            ldr     r3,=0x00030003
238
        orr     r2, r2, r3
239
        str     r2,[r1]
240
 
241
            // Wait for the DRAM to come up.
242
        mov     r1, #0x400
243
0:           subs    r1, r1, #1
244
        bne     0b
245
 
246
        // Turn on LED 3
247
        _LED_ON 3
248
 
249
        b       19f
250
 
251
// DRAM controller initialization        
252
dram_table:
253
        .word   SA11X0_DRAM0_CAS_0,           CAS0_WAVEFORM_VALUE
254
        .word   SA11X0_DRAM0_CAS_1,           CAS1_WAVEFORM_VALUE
255
        .word   SA11X0_DRAM0_CAS_2,           CAS2_WAVEFORM_VALUE
256
        .word   SA11X0_DRAM2_CAS_0,           CAS0_WAVEFORM_VALUE
257
        .word   SA11X0_DRAM2_CAS_1,           CAS1_WAVEFORM_VALUE
258
        .word   SA11X0_DRAM2_CAS_2,           CAS2_WAVEFORM_VALUE
259
        .word   SA11X0_REFRESH_CONFIGURATION, RFSH_CONFIG_VALUE
260
        .word   SA11X0_DRAM_CONFIGURATION,    DRAM_CONFIG_VALUE
261
        .word   SA11X0_STATIC_CONTROL_0,      MSC0VALUE
262
        .word   SA11X0_STATIC_CONTROL_1,      MSC1VALUE
263
        .word   SA11X0_STATIC_CONTROL_2,      MSC2VALUE
264
        .word   0, 0
265
 
266
19:
267
        // Wakeup from deep sleep mode
268
        ldr     r1,=SA11X0_RESET_STATUS
269
        ldr     r2,[r1]
270
        cmp     r2,#SA11X0_SLEEP_MODE_RESET
271
        bne     45f
272
        ldr     r1,=SA11X0_PWR_MGR_SCRATCHPAD
273
        ldr     r1,[r1]
274
        mov     pc,r1
275
        nop
276
45:     nop
277
 
278
        // Release peripheral hold (set by RESET)
279
        ldr     r1,=SA11X0_PWR_MGR_SLEEP_STATUS
280
        ldr     r2,=SA11X0_PERIPHERAL_CONTROL_HOLD
281
        str     r2,[r1]
282
 
283
        // Set up a stack [for calling C code]
284
        ldr     r1,=__startup_stack
285
        ldr     r2,=SA11X0_RAM_BANK0_BASE
286
        orr     sp,r1,r2
287
 
288
        // Create MMU tables
289
        bl      hal_mmu_init
290
 
291
        // Turn OFF LED 0 
292
        _LED_OFF 0
293
 
294
        // Enable MMU
295
        ldr     r2,=10f
296
        ldr         r1,=MMU_Control_Init|MMU_Control_M
297
            mcr     MMU_CP,0,r1,MMU_Control,c0
298
            mov     pc,r2    /* Change address spaces */
299
            nop
300
            nop
301
            nop
302
 
303
10:
304
        // Turn OFF LED 1 
305
        _LED_OFF 1
306
 
307
        // Save shadow copy of BCR, also hardware configuration
308
        ldr     r1,=_cerfpda_BCR
309
        str     r2,[r1]
310
        .endm
311
 
312
#else // defined(CYG_HAL_STARTUP_ROM)
313
#define PLATFORM_SETUP1
314
#endif
315
 
316
#define PLATFORM_VECTORS         _platform_vectors
317
        .macro  _platform_vectors
318
        .globl  _cerfpda_BCR
319
_cerfpda_BCR:   .long   0       // Board Control register shadow
320
        .endm
321
 
322
/*---------------------------------------------------------------------------*/
323
/* end of hal_platform_setup.h                                               */
324
#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.