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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [arm/] [sa11x0/] [assabet/] [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/assabet.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
 
97
// This macro represents the initial startup code for the platform        
98
        .macro  _platform_setup1
99
 
100
        // Turn off LEDs
101
        ldr     r1,=SA1110_BOARD_CONTROL
102
        ldr     r2,=SA1110_BCR_MIN
103
        orr     r2,r2,#SA1110_BCR_RED_LED
104
        orr     r2,r2,#SA1110_BCR_GREEN_LED
105
        str     r2,[r1]
106
 
107
        // Set up GPIO to read hardware configuration
108
        ldr     r1,=SA11X0_GPIO_PIN_DIRECTION
109
        ldr     r2,=0x0807A7FC
110
        str     r2,[r1]
111
        ldr     r3,=SA11X0_GPIO_PIN_OUTPUT_SET
112
        ldr     r2,=0x2FC               // Bits 2..9
113
        str     r2,[r3]                 // Requests hardware configuration
114
        ldr     r2,=0x0807A400          // Reconfigure 2..9 as inputs
115
        str     r2,[r1]
116
        ldr     r3,=SA11X0_GPIO_PIN_LEVEL
117
        mov     r2,#100
118
10:     ldr     r9,[r3]                 // Read multiple times to settle
119
        subs    r2,r2,#1
120
        bne     10b
121
        ldr     r2,=0x0807A7FC          // Restore proper pin configuration
122
        str     r2,[r1]
123
        ldr     r3,=SA11X0_GPIO_PIN_OUTPUT_SET
124
        ldr     r2,=0x10000             // Enable high power mode
125
        str     r2,[r3]
126
 
127
        // Disable clock switching
128
        mcr     p15,0,r0,\
129
                SA11X0_TEST_CLOCK_AND_IDLE_REGISTER,\
130
                SA11X0_DISABLE_CLOCK_SWITCHING_RM,\
131
                SA11X0_DISABLE_CLOCK_SWITCHING_OPCODE
132
 
133
        // Set up processor clock
134
        ldr     r1,=SA11X0_PWR_MGR_PLL_CONFIG
135
        ldr     r2,=SA11X0_PLL_CLOCK
136
        str     r2,[r1]
137
 
138
        // Turn clock switching back on
139
        mcr     p15,0,r0,\
140
                SA11X0_TEST_CLOCK_AND_IDLE_REGISTER,\
141
                SA11X0_ENABLE_CLOCK_SWITCHING_RM,\
142
                SA11X0_ENABLE_CLOCK_SWITCHING_OPCODE
143
        nop
144
        nop
145
 
146
        // Turn on Red LED
147
        ldr     r1,=SA1110_BOARD_CONTROL
148
        ldr     r2,=SA1110_BCR_MIN
149
        bic     r2,r2,#SA1110_BCR_RED_LED
150
        orr     r2,r2,#SA1110_BCR_GREEN_LED
151
        str     r2,[r1]
152
 
153
        // Pause
154
        ldr     r1,=100000
155
10:     sub     r1,r1,#1
156
        cmp     r1,#0
157
        bne     10b
158
 
159
        // Initialize DRAM controller
160
        ldr     r1,=dram_table
161
        ldr     r2,=__exception_handlers
162
        sub     r1,r1,r2
163
        ldr     r2,[r1],#4                      // First control register
164
10:     ldr     r3,[r1],#4
165
        str     r3,[r2]
166
        ldr     r2,[r1],#4                      // Next control register
167
        cmp     r2,#0
168
        bne     10b
169
 
170
        ldr     r1,=SA1110_BOARD_CONTROL
171
        ldr     r2,=SA1110_BCR_MIN
172
        orr     r2,r2,#SA1110_BCR_RED_LED
173
        bic     r2,r2,#SA1110_BCR_GREEN_LED
174
        str     r2,[r1]
175
 
176
        // Enable UART
177
        ldr     r1,=SA1110_GPCLK_CONTROL_0
178
        ldr     r2,=SA1110_GPCLK_SUS_UART
179
        str     r2,[r1]
180
 
181
        // Release DRAM hold (set by RESET)
182
        ldr     r1,=SA11X0_PWR_MGR_SLEEP_STATUS
183
        ldr     r2,=SA11X0_DRAM_CONTROL_HOLD
184
        str     r2,[r1]
185
 
186
        // Perform 8 reads from unmapped/unenabled DRAM
187
        ldr     r1,=SA11X0_RAM_BANK0_BASE
188
        ldr     r2,[r1]
189
        ldr     r2,[r1]
190
        ldr     r2,[r1]
191
        ldr     r2,[r1]
192
        ldr     r2,[r1]
193
        ldr     r2,[r1]
194
        ldr     r2,[r1]
195
        ldr     r2,[r1]
196
 
197
        // Enable DRAM controller
198
        ldr     r1,=SA11X0_DRAM_CONFIGURATION
199
        ldr     r2,=0x72547255
200
        str     r2,[r1]
201
 
202
        b       19f
203
 
204
// DRAM controller initialization        
205
dram_table:
206
        .word   SA11X0_DRAM0_CAS_0,           0xAAAAAA7F
207
        .word   SA11X0_DRAM0_CAS_1,           0xAAAAAAAA
208
        .word   SA11X0_DRAM0_CAS_2,           0xAAAAAAAA
209
#ifdef CYGSEM_HAL_ARM_SA11X0_ASSABET_NEPONSET_TIMINGS
210
        .word   SA11X0_STATIC_CONTROL_0,      0x4B384370
211
        .word   SA11X0_STATIC_CONTROL_1,      0x22212419
212
#endif
213
        .word   SA11X0_EXP_BUS_CONFIGURATION, 0x994A994A
214
        .word   SA11X0_REFRESH_CONFIGURATION, 0x49FC0327
215
        .word   SA11X0_DRAM2_CAS_0,           0xAAAAAA7F
216
        .word   SA11X0_DRAM2_CAS_1,           0xAAAAAAAA
217
        .word   SA11X0_DRAM2_CAS_2,           0xAAAAAAAA
218
#ifdef CYGSEM_HAL_ARM_SA11X0_ASSABET_NEPONSET_TIMINGS
219
        .word   SA11X0_STATIC_CONTROL_2,      0x42196669
220
#endif
221
        .word   SA11X0_SMROM_CONFIGURATION,   0xAFCCAFCC
222
        .word   SA11X0_DRAM_CONFIGURATION,    0x72547254        // Disabled
223
        .word   0, 0
224
19:
225
 
226
        // Wakeup from deep sleep mode
227
        ldr     r1,=SA11X0_RESET_STATUS
228
        ldr     r2,[r1]
229
        cmp     r2,#SA11X0_SLEEP_MODE_RESET
230
        bne     45f
231
        ldr     r1,=SA11X0_PWR_MGR_SCRATCHPAD
232
        ldr     r1,[r1]
233
        mov     pc,r1
234
        nop
235
45:     nop
236
 
237
        // Release peripheral hold (set by RESET)
238
        ldr     r1,=SA11X0_PWR_MGR_SLEEP_STATUS
239
        ldr     r2,=SA11X0_PERIPHERAL_CONTROL_HOLD
240
        str     r2,[r1]
241
 
242
        // Set up a stack [for calling C code]
243
        ldr     r1,=__startup_stack
244
        ldr     r2,=SA11X0_RAM_BANK0_BASE
245
        orr     sp,r1,r2
246
 
247
        // Create MMU tables
248
        bl      hal_mmu_init
249
 
250
        // Turn on green LED
251
        ldr     r1,=SA1110_BOARD_CONTROL
252
        ldr     r2,=SA1110_BCR_MIN
253
        orr     r2,r2,#SA1110_BCR_RED_LED
254
        bic     r2,r2,#SA1110_BCR_GREEN_LED
255
        str     r2,[r1]
256
 
257
        // Enable MMU
258
        ldr     r2,=10f
259
        ldr     r1,=MMU_Control_Init|MMU_Control_M
260
        mcr     MMU_CP,0,r1,MMU_Control,c0
261
        mov     pc,r2    /* Change address spaces */
262
        nop
263
        nop
264
        nop
265
10:
266
 
267
        // Turn on both LEDs
268
        ldr     r1,=SA1110_BOARD_CONTROL
269
        ldr     r2,=SA1110_BCR_MIN
270
        bic     r2,r2,#SA1110_BCR_RED_LED
271
        bic     r2,r2,#SA1110_BCR_GREEN_LED
272
        str     r2,[r1]
273
 
274
        // Save shadow copy of BCR, also hardware configuration
275
        ldr     r1,=_assabet_BCR
276
        str     r2,[r1]
277
        ldr     r1,=_assabet_CFG
278
        str     r9,[r1]                // Saved far above...
279
        .endm
280
 
281
#else // defined(CYG_HAL_STARTUP_ROM)
282
#define PLATFORM_SETUP1
283
#endif
284
 
285
#define PLATFORM_VECTORS         _platform_vectors
286
        .macro  _platform_vectors
287
        .globl  _assabet_BCR, _assabet_CFG
288
_assabet_BCR:   .long   0       // Board Control register shadow
289
_assabet_CFG:   .long   0       // Board Configuration (read at RESET)
290
        .endm
291
 
292
/*---------------------------------------------------------------------------*/
293
/* end of hal_platform_setup.h                                               */
294
#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.