1 |
786 |
skrzyp |
#ifndef CYGONCE_HAL_PLATFORM_SETUP_H
|
2 |
|
|
#define CYGONCE_HAL_PLATFORM_SETUP_H
|
3 |
|
|
//==========================================================================
|
4 |
|
|
//
|
5 |
|
|
// hal_platform_setup.h
|
6 |
|
|
//
|
7 |
|
|
//
|
8 |
|
|
//
|
9 |
|
|
//==========================================================================
|
10 |
|
|
// ####ECOSGPLCOPYRIGHTBEGIN####
|
11 |
|
|
// -------------------------------------------
|
12 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
13 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
|
14 |
|
|
//
|
15 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
16 |
|
|
// the terms of the GNU General Public License as published by the Free
|
17 |
|
|
// Software Foundation; either version 2 or (at your option) any later
|
18 |
|
|
// version.
|
19 |
|
|
//
|
20 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT
|
21 |
|
|
// ANY 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
|
26 |
|
|
// along with eCos; if not, write to the Free Software Foundation, Inc.,
|
27 |
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
28 |
|
|
//
|
29 |
|
|
// As a special exception, if other files instantiate templates or use
|
30 |
|
|
// macros or inline functions from this file, or you compile this file
|
31 |
|
|
// and link it with other works to produce a work based on this file,
|
32 |
|
|
// this file does not by itself cause the resulting work to be covered by
|
33 |
|
|
// the GNU General Public License. However the source code for this file
|
34 |
|
|
// must still be made available in accordance with section (3) of the GNU
|
35 |
|
|
// General Public License v2.
|
36 |
|
|
//
|
37 |
|
|
// This exception does not invalidate any other reasons why a work based
|
38 |
|
|
// on this file might be covered by the GNU General Public License.
|
39 |
|
|
// -------------------------------------------
|
40 |
|
|
// ####ECOSGPLCOPYRIGHTEND####
|
41 |
|
|
//==========================================================================
|
42 |
|
|
//#####DESCRIPTIONBEGIN####
|
43 |
|
|
//
|
44 |
|
|
// Author(s): gthomas
|
45 |
|
|
// Contributors: gthomas, jskov, rcassebohm
|
46 |
|
|
// Grant Edwards <grante@visi.com>
|
47 |
|
|
// Date: 2001-07-31
|
48 |
|
|
// Purpose:
|
49 |
|
|
// Description:
|
50 |
|
|
//
|
51 |
|
|
//####DESCRIPTIONEND####
|
52 |
|
|
//
|
53 |
|
|
//========================================================================*/
|
54 |
|
|
|
55 |
|
|
#include <cyg/hal/plf_io.h>
|
56 |
|
|
|
57 |
|
|
.macro LED_MACRO x
|
58 |
|
|
|
59 |
|
|
ldr r0,=KS32C_IOPDATA
|
60 |
|
|
ldr r1,[r0]
|
61 |
|
|
and r1,r1,#(~0x7)
|
62 |
|
|
orr r1,r1,#((0x7 & (~(\x))))
|
63 |
|
|
str r1,[r0]
|
64 |
|
|
#ifdef CYGSEM_HAL_LED_WITH_DELAY
|
65 |
|
|
ldr r1,=0x80000
|
66 |
|
|
1: sub r1,r1,#1
|
67 |
|
|
cmp r1,#0
|
68 |
|
|
bne 1b
|
69 |
|
|
#endif
|
70 |
|
|
.endm
|
71 |
|
|
|
72 |
|
|
#define CYGHWR_LED_MACRO \
|
73 |
|
|
LED_MACRO (\x)
|
74 |
|
|
|
75 |
|
|
|
76 |
|
|
// Use relative branch since we are going to switch the address space
|
77 |
|
|
// around.
|
78 |
|
|
#define CYGSEM_HAL_ROM_RESET_USES_JUMP
|
79 |
|
|
|
80 |
|
|
.macro PLATFORM_RELOCATE
|
81 |
|
|
|
82 |
|
|
ldr r1,=KS32C_IOPMOD
|
83 |
|
|
ldr r2,=0x07 /* set led display to output */
|
84 |
|
|
str r2,[r1]
|
85 |
|
|
|
86 |
|
|
LED 0x0
|
87 |
|
|
|
88 |
|
|
/* Check that it worked, otherwise try Sync DRAM setup */
|
89 |
|
|
ldr r1,=0x00000000
|
90 |
|
|
str r1,[r1]
|
91 |
|
|
ldr r2,[r1]
|
92 |
|
|
cmp r2,r1
|
93 |
|
|
beq 99f
|
94 |
|
|
|
95 |
|
|
/* Sync DRAM mode */
|
96 |
|
|
LED 0x1
|
97 |
|
|
|
98 |
|
|
ldr r3, =0xe7ffff90 /* sdram c+wb disabled, regs @ 0x03ff0000 */
|
99 |
|
|
ldr r0, =KS32C_SYSCFG
|
100 |
|
|
str r3,[r0]
|
101 |
|
|
1: mov r1,pc /* actual address */
|
102 |
|
|
sub r1,r1,#8 /* + 8 */
|
103 |
|
|
ldr r0,=1b /* address off 1: after remap */
|
104 |
|
|
sub r1,r1,r0
|
105 |
|
|
ldr r0,=40f
|
106 |
|
|
add r0,r0,r1
|
107 |
|
|
|
108 |
|
|
#ifdef CYG_HAL_STARTUP_ROMRAM
|
109 |
|
|
ldr lr,=4f
|
110 |
|
|
add lr,lr,r1
|
111 |
|
|
ldr r1,=AIM711_ROM0_LA_START
|
112 |
|
|
add lr,lr,r1
|
113 |
|
|
#else
|
114 |
|
|
ldr lr,=99f
|
115 |
|
|
#endif
|
116 |
|
|
|
117 |
|
|
ldmia r0,{r1-r12}
|
118 |
|
|
ldr r0,=KS32C_EXTDBWTH
|
119 |
|
|
stmia r0,{r1-r12}
|
120 |
|
|
mov pc,lr
|
121 |
|
|
|
122 |
|
|
#ifdef CYG_HAL_STARTUP_ROMRAM
|
123 |
|
|
4:
|
124 |
|
|
/* Relocate text segment */
|
125 |
|
|
ldr r2,=__exception_handlers
|
126 |
|
|
ldr r3,=AIM711_ROM0_LA_START
|
127 |
|
|
cmp r2,r3
|
128 |
|
|
beq 6f
|
129 |
|
|
ldr r4,=__rom_data_end
|
130 |
|
|
5:
|
131 |
|
|
ldr r0,[r3],#4
|
132 |
|
|
str r0,[r2],#4
|
133 |
|
|
cmp r2,r4
|
134 |
|
|
bne 5b
|
135 |
|
|
6:
|
136 |
|
|
ldr lr,=99f
|
137 |
|
|
mov pc,lr
|
138 |
|
|
nop
|
139 |
|
|
nop
|
140 |
|
|
nop
|
141 |
|
|
#endif
|
142 |
|
|
|
143 |
|
|
/* The below are set with a store-multiple instruction */
|
144 |
|
|
|
145 |
|
|
/* Sync DRAM setup */
|
146 |
|
|
/* Flash is 8 bit, DRAM is 32 bit and EXTIO is 8 bit */
|
147 |
|
|
/* .long KS32C_EXTDBWTH */
|
148 |
|
|
40: .long ( (KS32C_EXTDBWTH_8BIT<<KS32C_EXTDBWTH_DSR0_shift) \
|
149 |
|
|
|(KS32C_EXTDBWTH_32BIT<<KS32C_EXTDBWTH_DSD0_shift) \
|
150 |
|
|
|(KS32C_EXTDBWTH_8BIT<<KS32C_EXTDBWTH_DSX0_shift) \
|
151 |
|
|
|(KS32C_EXTDBWTH_8BIT<<KS32C_EXTDBWTH_DSX2_shift) )
|
152 |
|
|
/* Flash at 0x02000000-0x02100000, 5 cycles, 7 cycles */
|
153 |
|
|
/* .long KS32C_ROMCON0 */
|
154 |
|
|
.long ( (KS32C_ROMCON_PMC_ROM) \
|
155 |
|
|
|(KS32C_ROMCON_TPA_5C) \
|
156 |
|
|
|(KS32C_ROMCON_TACC_7C) \
|
157 |
|
|
|((AIM711_ROM0_LA_START >> 16) << KS32C_ROMCON_BASE_shift) \
|
158 |
|
|
|((AIM711_ROM0_LA_END >> 16) << KS32C_ROMCON_NEXT_shift))
|
159 |
|
|
/* .long KS32C_ROMCON1 */
|
160 |
|
|
.long ( (KS32C_ROMCON_PMC_ROM) \
|
161 |
|
|
|(KS32C_ROMCON_TPA_5C) \
|
162 |
|
|
|(KS32C_ROMCON_TACC_5C) \
|
163 |
|
|
|((0x00000000 >> 16) << KS32C_ROMCON_BASE_shift) \
|
164 |
|
|
|((0x00000000 >> 16) << KS32C_ROMCON_NEXT_shift))
|
165 |
|
|
/* .long KS32C_ROMCON2 */
|
166 |
|
|
.long ( (KS32C_ROMCON_PMC_ROM) \
|
167 |
|
|
|(KS32C_ROMCON_TPA_5C) \
|
168 |
|
|
|(KS32C_ROMCON_TACC_5C) \
|
169 |
|
|
|((0x00000000 >> 16) << KS32C_ROMCON_BASE_shift) \
|
170 |
|
|
|((0x00000000 >> 16) << KS32C_ROMCON_NEXT_shift))
|
171 |
|
|
/* .long KS32C_ROMCON3 */
|
172 |
|
|
.long ( (KS32C_ROMCON_PMC_ROM) \
|
173 |
|
|
|(KS32C_ROMCON_TPA_5C) \
|
174 |
|
|
|(KS32C_ROMCON_TACC_5C) \
|
175 |
|
|
|((0x00000000 >> 16) << KS32C_ROMCON_BASE_shift) \
|
176 |
|
|
|((0x00000000 >> 16) << KS32C_ROMCON_NEXT_shift))
|
177 |
|
|
/* .long KS32C_ROMCON4 */
|
178 |
|
|
.long ( (KS32C_ROMCON_PMC_ROM) \
|
179 |
|
|
|(KS32C_ROMCON_TPA_5C) \
|
180 |
|
|
|(KS32C_ROMCON_TACC_5C) \
|
181 |
|
|
|((0x00000000 >> 16) << KS32C_ROMCON_BASE_shift) \
|
182 |
|
|
|((0x00000000 >> 16) << KS32C_ROMCON_NEXT_shift))
|
183 |
|
|
/* .long KS32C_ROMCON5 */
|
184 |
|
|
.long ( (KS32C_ROMCON_PMC_ROM) \
|
185 |
|
|
|(KS32C_ROMCON_TPA_5C) \
|
186 |
|
|
|(KS32C_ROMCON_TACC_5C) \
|
187 |
|
|
|((0x00000000 >> 16) << KS32C_ROMCON_BASE_shift) \
|
188 |
|
|
|((0x00000000 >> 16) << KS32C_ROMCON_NEXT_shift))
|
189 |
|
|
/* .long KS32C_DRAMCON0 */
|
190 |
|
|
.long ( (KS32C_DRAMCON_RESERVED) \
|
191 |
|
|
|(KS32C_DRAMCON_CAN_8) \
|
192 |
|
|
|(KS32C_DRAMCON_TRP_4C) \
|
193 |
|
|
|(KS32C_DRAMCON_TRC_2C) \
|
194 |
|
|
|((AIM711_DRAM_LA_START >> 16) << KS32C_DRAMCON_BASE_shift) \
|
195 |
|
|
|((AIM711_DRAM_LA_END >> 16) << KS32C_DRAMCON_NEXT_shift))
|
196 |
|
|
/* .long KS32C_DRAMCON1 */
|
197 |
|
|
.long ( (KS32C_DRAMCON_RESERVED) \
|
198 |
|
|
|(KS32C_DRAMCON_CAN_8) \
|
199 |
|
|
|(KS32C_DRAMCON_TRP_2C) \
|
200 |
|
|
|(KS32C_DRAMCON_TRC_2C) \
|
201 |
|
|
|((0x00000000 >> 16) << KS32C_DRAMCON_BASE_shift) \
|
202 |
|
|
|((0x00000000 >> 16) << KS32C_DRAMCON_NEXT_shift))
|
203 |
|
|
/* .long KS32C_DRAMCON2 */
|
204 |
|
|
.long ( (KS32C_DRAMCON_RESERVED) \
|
205 |
|
|
|(KS32C_DRAMCON_CAN_8) \
|
206 |
|
|
|(KS32C_DRAMCON_TRP_2C) \
|
207 |
|
|
|(KS32C_DRAMCON_TRC_2C) \
|
208 |
|
|
|((0x00000000 >> 16) << KS32C_DRAMCON_BASE_shift) \
|
209 |
|
|
|((0x00000000 >> 16) << KS32C_DRAMCON_NEXT_shift))
|
210 |
|
|
/* .long KS32C_DRAMCON3 */
|
211 |
|
|
.long ( (KS32C_DRAMCON_RESERVED) \
|
212 |
|
|
|(KS32C_DRAMCON_CAN_8) \
|
213 |
|
|
|(KS32C_DRAMCON_TRP_2C) \
|
214 |
|
|
|(KS32C_DRAMCON_TRC_2C) \
|
215 |
|
|
|((0x00000000 >> 16) << KS32C_DRAMCON_BASE_shift) \
|
216 |
|
|
|((0x00000000 >> 16) << KS32C_DRAMCON_NEXT_shift))
|
217 |
|
|
/* .long KS32C_REFEXTCON */
|
218 |
|
|
.long (((2048+1-(8*CYGNUM_HAL_CPUCLOCK/1000000)) << KS32C_REFEXTCON_RCV_shift) \
|
219 |
|
|
|(KS32C_REFEXTCON_TRC_4C) \
|
220 |
|
|
|(KS32C_REFEXTCON_REN) \
|
221 |
|
|
|(KS32C_REFEXTCON_VSF) \
|
222 |
|
|
|(AIM711_EXT0_LA_START >> 16) )
|
223 |
|
|
#if 0
|
224 |
|
|
50:
|
225 |
|
|
.long 0x07113001 /* ROM half-word, RAM word, EXT-IO */
|
226 |
|
|
.long 0x21080060 /* ROM 32 - 33 MByte */
|
227 |
|
|
.long 0
|
228 |
|
|
.long 0
|
229 |
|
|
.long 0
|
230 |
|
|
.long 0
|
231 |
|
|
.long 0
|
232 |
|
|
.long 0x0800038e /* RAM 0 - 8 MByte */
|
233 |
|
|
.long 0
|
234 |
|
|
.long 0
|
235 |
|
|
.long 0
|
236 |
|
|
.long 0xc01583fd /* Reactivate external Bus */
|
237 |
|
|
#endif
|
238 |
|
|
|
239 |
|
|
99: LED 0x2
|
240 |
|
|
ldr r3,=0x00000000
|
241 |
|
|
str r3,[r3]
|
242 |
|
|
ldr r4,[r3]
|
243 |
|
|
cmp r4,r3
|
244 |
|
|
beq 15f
|
245 |
|
|
11: LED 0x3
|
246 |
|
|
b 11b
|
247 |
|
|
15: LED 0x4
|
248 |
|
|
|
249 |
|
|
.endm
|
250 |
|
|
|
251 |
|
|
#if defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_ROMRAM)
|
252 |
|
|
#define PLATFORM_SETUP1 \
|
253 |
|
|
PLATFORM_RELOCATE
|
254 |
|
|
#else
|
255 |
|
|
#define PLATFORM_SETUP1
|
256 |
|
|
#endif
|
257 |
|
|
|
258 |
|
|
//-----------------------------------------------------------------------------
|
259 |
|
|
// end of hal_platform_setup.h
|
260 |
|
|
#endif // CYGONCE_HAL_PLATFORM_SETUP_H
|