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

Subversion Repositories openrisc_me

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