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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [arm/] [ebsa285/] [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):    hmt
46
// Contributors: hmt
47
// Date:         1999-04-21
48
// Purpose:      Intel EBSA285 platform specific support routines
49
// Description:
50
// Usage:       #include <cyg/hal/hal_platform_setup.h>
51
//
52
//####DESCRIPTIONEND####
53
//
54
//===========================================================================*/
55
 
56
#include <pkgconf/system.h>             // System-wide configuration info
57
#include CYGBLD_HAL_PLATFORM_H          // Platform specific configuration
58
#include CYGHWR_MEMORY_LAYOUT_H         // Location of the ROM
59
#include <cyg/hal/hal_ebsa285.h>        // Platform specific hardware definitions
60
#include <cyg/hal/hal_mmu.h>            // MMU definitions
61
 
62
// Note that we do NOT define CYGHWR_HAL_ARM_HAS_MMU so that at reset we
63
// jump straight into the ROM; this makes it unnecessary to take any
64
// special steps to switch from executing in the ROM alias at low
65
// addresses.  Make no difference for RAM start. For ROMRAM startup the
66
// application is linked with RAM addresses, but we have to jump to
67
// the ROM address at startup. Diddle the UNMAPPED macro to do this
68
 
69
#if defined (CYG_HAL_STARTUP_ROMRAM)
70
#define UNMAPPED(x) (x + CYGMEM_REGION_rom)
71
#endif
72
 
73
// Define macro used to diddle the LEDs during early initialization.
74
// Can use r0+r1.  Argument in \x.
75
#define CYGHWR_LED_MACRO                                                  \
76
        ldr     r0,=0x42000148    /* SA110_XBUS_CYCLE_ARBITER */          ;\
77
        ldr     r0,[r0]                                                   ;\
78
        tsts    r0,#0x00800000 /* SA110_XBUS_CYCLE_ARBITER_ENABLED */     ;\
79
        bne     667f              /* Don't touch if PCI arbiter enabled */;\
80
        ldr     r0,=0x40012800    /* SA110_XBUS_XCS2 */                   ;\
81
        mov     r1,#7&(~(\x))                                             ;\
82
        str     r1,[r0]                                                   ;\
83
667:
84
 
85
// The main useful output of this file is PLATFORM_SETUP1: it invokes lots
86
// of other stuff (may depend on RAM or ROM start).  The other stuff is
87
// divided into further macros to make it easier to manage what's enabled
88
// when.
89
 
90
#if defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_ROMRAM) || \
91
    defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS) ||      \
92
    !defined(CYGSEM_HAL_USE_ROM_MONITOR)
93
 
94
// Dependence on ROM/RAM start removed when meminit code fixed up.
95
// But it re-emerged when RedBoot's desire to live over RAM app
96
// initialization asserted itself.
97
//
98
// The correct thing is to re-initialize everything if any of:
99
//  o You are in ROM (duh!)
100
//  o You include your own stubs (ergo rule the world)
101
//  o You do not cooperate with a ROM Monitor
102
//
103
// [The latter two probably mean the same thing, but this way also lets us
104
//  support a standalone RAM startup app with no stubs in it. ]
105
// Hence the more complex conditional above.  See comments in the ChangeLog
106
// and plf_io.h wrt initializing the PCI bus world.
107
 
108
#define PLATFORM_SETUP1                         \
109
        PLATFORM_FLUSH_DISABLE_CACHES           \
110
        INIT_XBUS_ACCESS                        \
111
        ALLOW_CLOCK_SWITCHING                   \
112
        CALL_MEMINIT_CODE                       \
113
        ROMRAM_COPY                             \
114
        BASIC_PCI_SETUP
115
#else
116
#define PLATFORM_SETUP1
117
#endif
118
 
119
 
120
// Discard and disable all caches: we are about to be writing vectors...
121
#define PLATFORM_FLUSH_DISABLE_CACHES                                      \
122
        /* flush and disable the caches */                                 \
123
        mrc     p15,0,r1,c1,c0,0                                           ;\
124
        bic     r1,r1,#0x1000   /* ICache off */                           ;\
125
        bic     r1,r1,#0x000D   /* DCache off and MM off */                ;\
126
        mcr     p15,0,r1,c1,c0,0                                           ;\
127
        mov     r1, #0                                                     ;\
128
        mcr     p15,0,r1,c7,c6,0 /* DCache invalidate (discard) */         ;\
129
        mcr     p15,0,r1,c7,c5,0 /* ICache invalidate */                   ;\
130
        mcr     p15,0,r1,c8,c6,0 /* DCache TLB invalidate */               ;\
131
        mcr     p15,0,r1,c8,c5,0 /* ICache TLB invalidate */               ;\
132
        nop                                                                ;\
133
        nop     /* be sure invalidate "takes" before doing owt else */     ;\
134
        nop                                                                ;
135
 
136
 
137
// Allow clock switching: very early in the startup
138
#define ALLOW_CLOCK_SWITCHING                                              \
139
        mov     r0, #0                                                     ;\
140
        mcr     p15,0,r0,c15,c1,2                                          ;\
141
 
142
 
143
// Depending on jumper settings, either ignore or initialize the XBus.
144
#define INIT_XBUS_ACCESS                                                    \
145
        ldr     r1, =SA110_XBUS_CYCLE_ARBITER                              ;\
146
        ldr     r0, [r1]                                                   ;\
147
        tsts    r0, #SA110_XBUS_CYCLE_ARBITER_ENABLED                      ;\
148
        beq     777f                                                       ;\
149
        /* PCI arbiter enabled, so don't touch the XBus */                 ;\
150
        ldr     r0, =SA110_CONTROL                                         ;\
151
        ldr     r1, =0x04aa0000                                            ;\
152
        str     r1, [r0]                                                   ;\
153
        b       778f                                                       ;\
154
                                                                           ;\
155
        /* set up XBus so we can read switch and write to LEDs */          ;\
156
777:    ldr     r0, =SA110_CONTROL                                         ;\
157
        ldr     r1, =0x64aa0000                                            ;\
158
        str     r1, [r0]                                                   ;\
159
        ldr     r0, =SA110_XBUS_CYCLE_ARBITER                              ;\
160
        ldr     r1, =0x100016db                                            ;\
161
        str     r1, [r0]                                                   ;\
162
        ldr     r0, =SA110_XBUS_IO_STROBE_MASK                             ;\
163
        ldr     r1, =0xfcfcfcfc                                            ;\
164
        str     r1, [r0]                                                   ;\
165
778:                                                                       ;\
166
 
167
// Save lr and call mem init code
168
#define CALL_MEMINIT_CODE                                                 \
169
        mov     r10, lr       /* preserve lr */                           ;\
170
        bl      __mem285_init                                             ;\
171
        ldr     r1, =hal_dram_size  /* [see hal_intr.h] */                ;\
172
        str     r0, [ r1 ]    /* store the top of memory address */       ;\
173
        mov     lr, r10       /* in hal_dram_size for future use */       ;\
174
 
175
// If we are doing a ROMRAM startup copy all sections up to the start of 
176
// the data section to RAM.
177
#if defined(CYG_HAL_STARTUP_ROMRAM)
178
#define ROMRAM_COPY                                                      \
179
        ldr     r0,=(CYGMEM_REGION_rom)                                  ;\
180
        ldr     r1,=0                                                    ;\
181
        ldr     r2,=0x40                                                 ;\
182
810:    ldr     r3,[r0],#4                                               ;\
183
        str     r3,[r1],#4                                               ;\
184
        cmp     r1,r2                                                    ;\
185
        bne     810b                                                     ;\
186
        ldr     r0,=(CYGMEM_REGION_rom+reset_vector)                     ;\
187
        ldr     r1,=(reset_vector)                                       ;\
188
        ldr     r2,=(CYGMEM_REGION_rom_SIZE)                             ;\
189
820:    ldr     r3,[r0],#4                                               ;\
190
        str     r3,[r1],#4                                               ;\
191
        cmp     r1,r2                                                    ;\
192
        bne     820b                                                     ;\
193
        ldr     r0,=830f                                                 ;\
194
        mov     pc,r0                                                    ;\
195
830:
196
#else
197
#define ROMRAM_COPY                                                      
198
#endif
199
 
200
#define BASIC_PCI_SETUP                                                   \
201
        /**************************************************************** \
202
         *  Basic PCI setup.                                              \
203
         ****************************************************************/\
204
        ldr     r0, =SA110_CONTROL_STATUS_BASE                            ;\
205
                                                                          ;\
206
        /* Disable PCI Outbound interrupts */                             ;\
207
        mov     r1, #12                                                   ;\
208
        str     r1, [r0, #SA110_OUT_INT_MASK_o]                           ;\
209
                                                                          ;\
210
        /* Disable Doorbells */                                           ;\
211
        mov     r1, #0                                                    ;\
212
        str     r1, [r0, #SA110_DOORBELL_PCI_MASK_o]                      ;\
213
        str     r1, [r0, #SA110_DOORBELL_SA_MASK_o]                       ;\
214
                                                                          ;\
215
        /* Map high PCI address bits to 0 */                              ;\
216
        str     r1, [r0, #SA110_PCI_ADDR_EXT_o]                           ;\
217
                                                                          ;\
218
        /* Interrupt ID to 1 */                                           ;\
219
        mov     r1, #0x100                                                ;\
220
        str     r1, [r0, #SA110_PCI_CFG_INT_LINE_o]                       ;\
221
                                                                          ;\
222
        /* Remove PCI_reset */                                            ;\
223
        ldr     r1, [r0, #SA110_CONTROL_o]                                ;\
224
        orr     r1, r1, #0x200                                            ;\
225
        str     r1, [r0, #SA110_CONTROL_o]                                ;\
226
                                                                          ;\
227
        /* Open a 2MB window */                                           ;\
228
        mov     r1, #0x1c0000                                             ;\
229
        str     r1,[r0, #SA110_SDRAM_BASE_ADDRESS_MASK_o]                 ;\
230
        mov     r1, #0xe00000                                             ;\
231
        str     r1,[r0, #SA110_SDRAM_BASE_ADDRESS_OFFSET_o]               ;\
232
                                                                          ;\
233
        /* Only init PCI if central function is set and */                ;\
234
        /* standalone bit is cleared                    */                ;\
235
        ldr     r1, [r0, #SA110_CONTROL_o]                                ;\
236
        tst     r1, #SA110_CONTROL_CFN                                    ;\
237
        beq     1f                                                        ;\
238
                                                                          ;\
239
        ldr     r1, =0x40012000                                           ;\
240
        ldr     r1, [r1]                                                  ;\
241
        tst     r1, #0x40                                                 ;\
242
        bne     1f                                                        ;\
243
                                                                          ;\
244
        /* Don't respond to any commands */                               ;\
245
        mov     r1, #0                                                    ;\
246
        str     r1, [r0, #SA110_PCI_CFG_COMMAND_o]                        ;\
247
                                                                          ;\
248
        str     r1, [r0, #SA110_PCI_CFG_SDRAM_BAR_o]                      ;\
249
        mov     r1, #0x40000000                                           ;\
250
        str     r1, [r0, #SA110_PCI_CFG_CSR_MEM_BAR_o]                    ;\
251
        mov     r1, #0xf000                                               ;\
252
        str     r1, [r0, #SA110_PCI_CFG_CSR_IO_BAR_o]                     ;\
253
                                                                          ;\
254
        /* respond to I/O space & Memory transactions. */                 ;\
255
        mov     r1, #0x17                                                 ;\
256
        str     r1, [r0, #SA110_PCI_CFG_COMMAND_o]                        ;\
257
    1:                                                                    ;\
258
        /* Signal PCI_init_complete */                                    ;\
259
        ldr     r1, [r0, #SA110_CONTROL_o]                                ;\
260
        orr     r1, r1, #SA110_CONTROL_INIT_COMPLETE                      ;\
261
        str     r1, [r0, #SA110_CONTROL_o]                                ;\
262
 
263
 
264
/*---------------------------------------------------------------------------*/
265
/* end of hal_platform_setup.h                                               */
266
#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.