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

Subversion Repositories openrisc

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