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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [arm/] [sa11x0/] [flexanet/] [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):    Jordi Colomer <jco@ict.es>
47
// Contributors: Jordi Colomer <jco@ict.es>
48
// Date:         2001-06-15
49
// Purpose:      SA1110/Flexanet 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/flexanet.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
#define CYGSEM_HAL_ROM_RESET_USES_JUMP
69
 
70
#if (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 59000)
71
#define SA11X0_PLL_CLOCK 0x0        
72
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 73700)
73
#define SA11X0_PLL_CLOCK 0x1
74
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 88500)
75
#define SA11X0_PLL_CLOCK 0x2        
76
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 103200) 
77
#define SA11X0_PLL_CLOCK 0x3        
78
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 118000)
79
#define SA11X0_PLL_CLOCK 0x4        
80
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 132700)
81
#define SA11X0_PLL_CLOCK 0x5        
82
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 147500)
83
#define SA11X0_PLL_CLOCK 0x6        
84
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 162200)
85
#define SA11X0_PLL_CLOCK 0x7        
86
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 176900)
87
#define SA11X0_PLL_CLOCK 0x8        
88
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 191700)
89
#define SA11X0_PLL_CLOCK 0x9        
90
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 206400)
91
#define SA11X0_PLL_CLOCK 0xA        
92
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 221200)
93
#define SA11X0_PLL_CLOCK 0xB        
94
#else
95
#error Invalid processor clock speed
96
#endif                
97
 
98
// DRAM settings
99
 
100
// Banks configured for 256-Mbit SDRAM devices (15 row x 9 col)
101
// Initially disabled.
102
// CAS latency = 3, 32-bit bus width, TWR = 1, TRP = 2
103
#define DRAM_CONFIG_VALUE       0x72647264
104
 
105
// SMROM settings (disabled in all banks)
106
#define SMROM_CONFIG_VALUE      0xAFCCAFCC      
107
 
108
// CAS waveforms
109
//#define CAS0_WAVEFORM_VALUE   0xAAAAAA7F
110
#define CAS0_WAVEFORM_VALUE     0xAAAAAAA7
111
#define CAS1_WAVEFORM_VALUE     0xAAAAAAAA
112
#define CAS2_WAVEFORM_VALUE     0xAAAAAAAA
113
 
114
// Expansion memory (PCMCIA) settings (MECR)
115
#define EXPMEM_CONFIG_VALUE     0x994A994A
116
 
117
// DRAM refresh configuration
118
 
119
// CAS before RAS = 7
120
// f(SDCLK) = f(mem) = 1/2 f(cpu) = 103 MHz, ok for PC-133 SDRAMs
121
// If PC-100 are installed, may be better to run the CPU at 192 MHz
122
// and still clock the SDRAM at 1/2 f(cpu) = 96 MHz.
123
// No auto-power-down,
124
// Refresh period for 8192 rows = 64 ms (25 memory cycles)
125
// DRI = 64 ms * 103 MHz / (8192 * 32) = 25
126
// (longest burst access time not considered by now)
127
#define RFSH_CONFIG_VALUE       0x00340197
128
 
129
// Static memory configuration
130
 
131
// CS0/1 : RDF=14, RDN=4 , RRR=2, 32 bits Flash
132
// Suitable for 128-Mbit StrataFlash (Tcyc = 150 ns)
133
#define STATIC_0_CONFIG_VALUE   0x44704470
134
 
135
// CS2   : RDF=0, RDN=0 , RRR=0, 32 bits SRAM
136
// CS3   : RDF=5, RDN=12, RRR=1, 32 bits SRAM
137
#define STATIC_1_CONFIG_VALUE   0x2C290001
138
 
139
 
140
// Macros that handle the red debug LED wired to GPIO-1
141
 
142
        .macro    _red_led_on
143
 
144
        // Turn on the red LED on GPIO-1
145
        ldr     r3,=SA11X0_GPIO_PIN_OUTPUT_SET
146
        ldr     r2,=0x02
147
        str     r2,[r3]
148
        .endm
149
 
150
        .macro    _red_led_off
151
 
152
        // Turn off the red LED on GPIO-1
153
        ldr     r3,=SA11X0_GPIO_PIN_OUTPUT_CLEAR
154
        ldr     r2,=0x02
155
        str     r2,[r3]
156
        .endm
157
 
158
 
159
// This macro represents the initial startup code for the platform,
160
// when the startup is ROM.
161
 
162
// Red LED is turned on during redboot execution and turned off
163
// right before entering the operating system.
164
 
165
// Green LED is turned off during the redboot execution and
166
// on right before entering the operating system on a reset
167
// (not on a wake-up).
168
 
169
        .macro  _platform_setup1
170
 
171
        // Disable all interrupts (ICMR not specified on power-up)
172
        ldr     r1,=SA11X0_ICMR
173
        mov     r0,#0
174
        str     r0,[r1]
175
 
176
        // Disable IRQs and FIQs
177
        mov     r0, #(CPSR_IRQ_DISABLE | \
178
                      CPSR_FIQ_DISABLE | \
179
                      CPSR_SUPERVISOR_MODE)
180
        msr     cpsr, r0
181
 
182
        // Reset the BCR (green LED off)
183
        ldr     r1,=SA1110_BOARD_CONTROL
184
        ldr     r2,=SA1110_BCR_MIN
185
        str     r2,[r1]
186
 
187
        // Set up GPIOs (red LED off)
188
        ldr     r1,=SA11X0_GPIO_PIN_DIRECTION
189
        ldr     r2,=SA1110_GPIO_DIR
190
        str     r2,[r1]
191
 
192
        ldr     r1,=SA11X0_GPIO_ALTERNATE_FUNCTION
193
        ldr     r2,=SA1110_GPIO_ALT
194
        str     r2,[r1]
195
 
196
        ldr     r1,=SA11X0_GPIO_PIN_OUTPUT_CLEAR
197
        ldr     r2,=SA1110_GPIO_CLR
198
        str     r2,[r1]
199
 
200
        ldr     r1,=SA11X0_GPIO_PIN_OUTPUT_SET
201
        ldr     r2,=SA1110_GPIO_SET
202
        str     r2,[r1]
203
 
204
        // Turn on the red LED
205
        _red_led_on
206
 
207
        // Disable clock switching
208
        mcr     p15,0,r0,\
209
                SA11X0_TEST_CLOCK_AND_IDLE_REGISTER,\
210
                SA11X0_DISABLE_CLOCK_SWITCHING_RM,\
211
                SA11X0_DISABLE_CLOCK_SWITCHING_OPCODE
212
 
213
        // Set up processor clock
214
        ldr     r1,=SA11X0_PWR_MGR_PLL_CONFIG
215
        ldr     r2,=SA11X0_PLL_CLOCK
216
        str     r2,[r1]
217
 
218
        // Turn clock switching back on
219
        mcr     p15,0,r0,\
220
                SA11X0_TEST_CLOCK_AND_IDLE_REGISTER,\
221
                SA11X0_ENABLE_CLOCK_SWITCHING_RM,\
222
                SA11X0_ENABLE_CLOCK_SWITCHING_OPCODE
223
        nop
224
        nop
225
 
226
        // Let the PLL settle down      
227
        ldr     r1,=20000
228
10:     sub     r1,r1,#1
229
        cmp     r1,#0
230
        bne     10b
231
 
232
        // Initialize DRAM controller. See table below.
233
        // The DRAM banks are set to disabled.
234
 
235
        ldr     r1,=dram_table
236
        ldr     r2,=__exception_handlers
237
        sub     r1,r1,r2
238
        ldr     r2,[r1],#4                      // First control register
239
11:     ldr     r3,[r1],#4
240
        str     r3,[r2]
241
        ldr     r2,[r1],#4                      // Next control register
242
        cmp     r2,#0
243
        bne     11b
244
 
245
        // Enable UART
246
        ldr     r1,=SA1110_GPCLK_CONTROL_0
247
        ldr     r2,=SA1110_GPCLK_SUS_UART
248
        str     r2,[r1]
249
 
250
        // Release DRAM hold (PSSR register, bit DH)
251
 
252
        // This bit is set upon exit from sleep mode and indicates that the 
253
        // nRAS/nSDCS 3:0 and nCAS/DQM 3:0 continue to be held low and that 
254
        // the DRAMs are still in self-refresh mode. This bit should be cleared 
255
        // by the processor (by writing a one to it) after the DRAM interface 
256
        // has been configured but before any DRAM access is attempted. 
257
        // The nRAS/nSDCS and nCAS/DQM lines are released when this bit is
258
        // cleared. This bit is cleared on hardware reset.
259
 
260
        ldr     r1,=SA11X0_PWR_MGR_SLEEP_STATUS
261
        ldr     r2,=SA11X0_DRAM_CONTROL_HOLD
262
        str     r2,[r1]
263
 
264
        // On hardware reset in systems containing DRAM or SDRAM, 
265
        // trigger a number (typically eight) of refresh cycles by attempting 
266
        // nonburst read or write accesses to any disabled DRAM bank. 
267
        // Each such access causes a simultaneous CBR for all four banks.
268
 
269
        ldr     r1,=SA11X0_RAM_BANK0_BASE
270
        ldr     r2,[r1]
271
        ldr     r2,[r1]
272
        ldr     r2,[r1]
273
        ldr     r2,[r1]
274
        ldr     r2,[r1]
275
        ldr     r2,[r1]
276
        ldr     r2,[r1]
277
        ldr     r2,[r1]
278
 
279
        // Enable DRAM bank 0
280
        ldr     r1,=SA11X0_DRAM_CONFIGURATION
281
        ldr     r2,=DRAM_CONFIG_VALUE
282
        orr     r2, r2, #0x01
283
        str     r2,[r1]
284
 
285
        b       19f
286
 
287
        // Memory controller settings (register, value)        
288
 
289
dram_table:
290
 
291
        .word   SA11X0_DRAM0_CAS_0,           CAS0_WAVEFORM_VALUE
292
        .word   SA11X0_DRAM0_CAS_1,           CAS1_WAVEFORM_VALUE
293
        .word   SA11X0_DRAM0_CAS_2,           CAS2_WAVEFORM_VALUE
294
        .word   SA11X0_EXP_BUS_CONFIGURATION, EXPMEM_CONFIG_VALUE
295
        .word   SA11X0_REFRESH_CONFIGURATION, RFSH_CONFIG_VALUE
296
        .word   SA11X0_DRAM2_CAS_0,           CAS0_WAVEFORM_VALUE
297
        .word   SA11X0_DRAM2_CAS_1,           CAS1_WAVEFORM_VALUE
298
        .word   SA11X0_DRAM2_CAS_2,           CAS2_WAVEFORM_VALUE
299
        .word   SA11X0_SMROM_CONFIGURATION,   SMROM_CONFIG_VALUE
300
        .word   SA11X0_DRAM_CONFIGURATION,    DRAM_CONFIG_VALUE
301
        .word   SA11X0_STATIC_CONTROL_0,      STATIC_0_CONFIG_VALUE
302
        .word   SA11X0_STATIC_CONTROL_1,      STATIC_1_CONFIG_VALUE
303
        .word   0, 0
304
19:
305
 
306
        // If waking up from sleep, jump to the resume function
307
        // pointed by the scratchpad register.
308
        ldr     r1,=SA11X0_RESET_STATUS
309
        ldr     r2,[r1]
310
        cmp     r2,#SA11X0_SLEEP_MODE_RESET
311
        bne     20f
312
        ldr     r1,=SA11X0_PWR_MGR_SCRATCHPAD
313
        ldr     r1,[r1]
314
 
315
        _red_led_off
316
 
317
        mov     pc,r1
318
        nop
319
20:     nop
320
 
321
        // Set up a stack [for calling C code]
322
        ldr     r1,=__startup_stack
323
        ldr     r2,=SA11X0_RAM_BANK0_BASE
324
        orr     sp,r1,r2
325
 
326
        // Create MMU tables
327
        bl      hal_mmu_init
328
 
329
        // Enable MMU
330
        ldr     r2,=10f
331
        ldr     r1,=MMU_Control_Init|MMU_Control_M
332
        mcr     MMU_CP,0,r1,MMU_Control,c0
333
        mov     pc,r2    /* Change address spaces */
334
        nop
335
        nop
336
        nop
337
10:
338
 
339
        // Save shadow copy of BCR
340
        ldr     r1,=_flexanet_BCR
341
        str     r2,[r1]
342
 
343
        // Turn on green LED
344
        ldr     r1,=SA1110_BOARD_CONTROL
345
        ldr     r2,=SA1110_BCR_MIN
346
        orr     r2,r2,#SA1110_BCR_LED_GREEN
347
        str     r2,[r1]
348
 
349
        // Turn off red LED
350
        _red_led_off
351
 
352
        .endm
353
 
354
 
355
#else // defined(CYG_HAL_STARTUP_ROM)
356
#define PLATFORM_SETUP1
357
#endif
358
 
359
#define PLATFORM_VECTORS         _platform_vectors
360
        .macro  _platform_vectors
361
        .globl  _flexanet_BCR
362
_flexanet_BCR:  .long   0       // Board Control register shadow
363
        .endm
364
 
365
/*---------------------------------------------------------------------------*/
366
/* end of hal_platform_setup.h                                               */
367
#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.