1 #ifndef CYGONCE_HAL_PLATFORM_SETUP_H
2 #define CYGONCE_HAL_PLATFORM_SETUP_H
4 /*=============================================================================
6 // hal_platform_setup.h
8 // Platform specific support for HAL (assembly code)
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.
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.
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
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.
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.
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.
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####
49 // Purpose: Intel EBSA285 platform specific support routines
51 // Usage: #include <cyg/hal/hal_platform_setup.h>
53 //####DESCRIPTIONEND####
55 //===========================================================================*/
57 #include <pkgconf/system.h> // System-wide configuration info
58 #include CYGBLD_HAL_PLATFORM_H // Platform specific configuration
59 #include CYGHWR_MEMORY_LAYOUT_H // Location of the ROM
60 #include <cyg/hal/hal_ebsa285.h> // Platform specific hardware definitions
61 #include <cyg/hal/hal_mmu.h> // MMU definitions
63 // Note that we do NOT define CYGHWR_HAL_ARM_HAS_MMU so that at reset we
64 // jump straight into the ROM; this makes it unnecessary to take any
65 // special steps to switch from executing in the ROM alias at low
66 // addresses. Make no difference for RAM start. For ROMRAM startup the
67 // application is linked with RAM addresses, but we have to jump to
68 // the ROM address at startup. Diddle the UNMAPPED macro to do this
70 #if defined (CYG_HAL_STARTUP_ROMRAM)
71 #define UNMAPPED(x) (x + CYGMEM_REGION_rom)
74 // Define macro used to diddle the LEDs during early initialization.
75 // Can use r0+r1. Argument in \x.
76 #define CYGHWR_LED_MACRO \
77 ldr r0,=0x42000148 /* SA110_XBUS_CYCLE_ARBITER */ ;\
79 tsts r0,#0x00800000 /* SA110_XBUS_CYCLE_ARBITER_ENABLED */ ;\
80 bne 667f /* Don't touch if PCI arbiter enabled */;\
81 ldr r0,=0x40012800 /* SA110_XBUS_XCS2 */ ;\
86 // The main useful output of this file is PLATFORM_SETUP1: it invokes lots
87 // of other stuff (may depend on RAM or ROM start). The other stuff is
88 // divided into further macros to make it easier to manage what's enabled
91 #if defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_ROMRAM) || \
92 defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS) || \
93 !defined(CYGSEM_HAL_USE_ROM_MONITOR)
95 // Dependence on ROM/RAM start removed when meminit code fixed up.
96 // But it re-emerged when RedBoot's desire to live over RAM app
97 // initialization asserted itself.
99 // The correct thing is to re-initialize everything if any of:
100 // o You are in ROM (duh!)
101 // o You include your own stubs (ergo rule the world)
102 // o You do not cooperate with a ROM Monitor
104 // [The latter two probably mean the same thing, but this way also lets us
105 // support a standalone RAM startup app with no stubs in it. ]
106 // Hence the more complex conditional above. See comments in the ChangeLog
107 // and plf_io.h wrt initializing the PCI bus world.
109 #define PLATFORM_SETUP1 \
110 PLATFORM_FLUSH_DISABLE_CACHES \
112 ALLOW_CLOCK_SWITCHING \
117 #define PLATFORM_SETUP1
121 // Discard and disable all caches: we are about to be writing vectors...
122 #define PLATFORM_FLUSH_DISABLE_CACHES \
123 /* flush and disable the caches */ \
124 mrc p15,0,r1,c1,c0,0 ;\
125 bic r1,r1,#0x1000 /* ICache off */ ;\
126 bic r1,r1,#0x000D /* DCache off and MM off */ ;\
127 mcr p15,0,r1,c1,c0,0 ;\
129 mcr p15,0,r1,c7,c6,0 /* DCache invalidate (discard) */ ;\
130 mcr p15,0,r1,c7,c5,0 /* ICache invalidate */ ;\
131 mcr p15,0,r1,c8,c6,0 /* DCache TLB invalidate */ ;\
132 mcr p15,0,r1,c8,c5,0 /* ICache TLB invalidate */ ;\
134 nop /* be sure invalidate "takes" before doing owt else */ ;\
138 // Allow clock switching: very early in the startup
139 #define ALLOW_CLOCK_SWITCHING \
141 mcr p15,0,r0,c15,c1,2 ;\
144 // Depending on jumper settings, either ignore or initialize the XBus.
145 #define INIT_XBUS_ACCESS \
146 ldr r1, =SA110_XBUS_CYCLE_ARBITER ;\
148 tsts r0, #SA110_XBUS_CYCLE_ARBITER_ENABLED ;\
150 /* PCI arbiter enabled, so don't touch the XBus */ ;\
151 ldr r0, =SA110_CONTROL ;\
152 ldr r1, =0x04aa0000 ;\
156 /* set up XBus so we can read switch and write to LEDs */ ;\
157 777: ldr r0, =SA110_CONTROL ;\
158 ldr r1, =0x64aa0000 ;\
160 ldr r0, =SA110_XBUS_CYCLE_ARBITER ;\
161 ldr r1, =0x100016db ;\
163 ldr r0, =SA110_XBUS_IO_STROBE_MASK ;\
164 ldr r1, =0xfcfcfcfc ;\
168 // Save lr and call mem init code
169 #define CALL_MEMINIT_CODE \
170 mov r10, lr /* preserve lr */ ;\
172 ldr r1, =hal_dram_size /* [see hal_intr.h] */ ;\
173 str r0, [ r1 ] /* store the top of memory address */ ;\
174 mov lr, r10 /* in hal_dram_size for future use */ ;\
176 // If we are doing a ROMRAM startup copy all sections up to the start of
177 // the data section to RAM.
178 #if defined(CYG_HAL_STARTUP_ROMRAM)
179 #define ROMRAM_COPY \
180 ldr r0,=(CYGMEM_REGION_rom) ;\
183 810: ldr r3,[r0],#4 ;\
187 ldr r0,=(CYGMEM_REGION_rom+reset_vector) ;\
188 ldr r1,=(reset_vector) ;\
189 ldr r2,=(CYGMEM_REGION_rom_SIZE) ;\
190 820: ldr r3,[r0],#4 ;\
201 #define BASIC_PCI_SETUP \
202 /**************************************************************** \
204 ****************************************************************/\
205 ldr r0, =SA110_CONTROL_STATUS_BASE ;\
207 /* Disable PCI Outbound interrupts */ ;\
209 str r1, [r0, #SA110_OUT_INT_MASK_o] ;\
211 /* Disable Doorbells */ ;\
213 str r1, [r0, #SA110_DOORBELL_PCI_MASK_o] ;\
214 str r1, [r0, #SA110_DOORBELL_SA_MASK_o] ;\
216 /* Map high PCI address bits to 0 */ ;\
217 str r1, [r0, #SA110_PCI_ADDR_EXT_o] ;\
219 /* Interrupt ID to 1 */ ;\
221 str r1, [r0, #SA110_PCI_CFG_INT_LINE_o] ;\
223 /* Remove PCI_reset */ ;\
224 ldr r1, [r0, #SA110_CONTROL_o] ;\
225 orr r1, r1, #0x200 ;\
226 str r1, [r0, #SA110_CONTROL_o] ;\
228 /* Open a 2MB window */ ;\
230 str r1,[r0, #SA110_SDRAM_BASE_ADDRESS_MASK_o] ;\
232 str r1,[r0, #SA110_SDRAM_BASE_ADDRESS_OFFSET_o] ;\
234 /* Only init PCI if central function is set and */ ;\
235 /* standalone bit is cleared */ ;\
236 ldr r1, [r0, #SA110_CONTROL_o] ;\
237 tst r1, #SA110_CONTROL_CFN ;\
240 ldr r1, =0x40012000 ;\
245 /* Don't respond to any commands */ ;\
247 str r1, [r0, #SA110_PCI_CFG_COMMAND_o] ;\
249 str r1, [r0, #SA110_PCI_CFG_SDRAM_BAR_o] ;\
250 mov r1, #0x40000000 ;\
251 str r1, [r0, #SA110_PCI_CFG_CSR_MEM_BAR_o] ;\
253 str r1, [r0, #SA110_PCI_CFG_CSR_IO_BAR_o] ;\
255 /* respond to I/O space & Memory transactions. */ ;\
257 str r1, [r0, #SA110_PCI_CFG_COMMAND_o] ;\
259 /* Signal PCI_init_complete */ ;\
260 ldr r1, [r0, #SA110_CONTROL_o] ;\
261 orr r1, r1, #SA110_CONTROL_INIT_COMPLETE ;\
262 str r1, [r0, #SA110_CONTROL_o] ;\
265 /*---------------------------------------------------------------------------*/
266 /* end of hal_platform_setup.h */
267 #endif /* CYGONCE_HAL_PLATFORM_SETUP_H */