1 |
27 |
unneback |
##=============================================================================
|
2 |
|
|
##
|
3 |
|
|
## platform.S
|
4 |
|
|
##
|
5 |
|
|
## MIPS REF4955-TX4955 platform code
|
6 |
|
|
##
|
7 |
|
|
##=============================================================================
|
8 |
|
|
#####ECOSGPLCOPYRIGHTBEGIN####
|
9 |
|
|
## -------------------------------------------
|
10 |
|
|
## This file is part of eCos, the Embedded Configurable Operating System.
|
11 |
|
|
## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
12 |
|
|
##
|
13 |
|
|
## eCos is free software; you can redistribute it and/or modify it under
|
14 |
|
|
## the terms of the GNU General Public License as published by the Free
|
15 |
|
|
## Software Foundation; either version 2 or (at your option) any later version.
|
16 |
|
|
##
|
17 |
|
|
## eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
18 |
|
|
## WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
19 |
|
|
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
20 |
|
|
## for more details.
|
21 |
|
|
##
|
22 |
|
|
## You should have received a copy of the GNU General Public License along
|
23 |
|
|
## with eCos; if not, write to the Free Software Foundation, Inc.,
|
24 |
|
|
## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
25 |
|
|
##
|
26 |
|
|
## As a special exception, if other files instantiate templates or use macros
|
27 |
|
|
## or inline functions from this file, or you compile this file and link it
|
28 |
|
|
## with other works to produce a work based on this file, this file does not
|
29 |
|
|
## by itself cause the resulting work to be covered by the GNU General Public
|
30 |
|
|
## License. However the source code for this file must still be made available
|
31 |
|
|
## in accordance with section (3) of the GNU General Public License.
|
32 |
|
|
##
|
33 |
|
|
## This exception does not invalidate any other reasons why a work based on
|
34 |
|
|
## this file might be covered by the GNU General Public License.
|
35 |
|
|
##
|
36 |
|
|
## Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
37 |
|
|
## at http://sources.redhat.com/ecos/ecos-license/
|
38 |
|
|
## -------------------------------------------
|
39 |
|
|
#####ECOSGPLCOPYRIGHTEND####
|
40 |
|
|
##=============================================================================
|
41 |
|
|
#######DESCRIPTIONBEGIN####
|
42 |
|
|
##
|
43 |
|
|
## Author(s): nickg
|
44 |
|
|
## Contributors:nickg, jskov
|
45 |
|
|
## Date: 2000-05-09
|
46 |
|
|
## Purpose: MIPS REF4955-TX4955 platform code
|
47 |
|
|
## Description: Platform specific code for REF4955-TX4955 board.
|
48 |
|
|
##
|
49 |
|
|
######DESCRIPTIONEND####
|
50 |
|
|
##
|
51 |
|
|
##=============================================================================
|
52 |
|
|
|
53 |
|
|
.set noreorder
|
54 |
|
|
|
55 |
|
|
#include
|
56 |
|
|
#include
|
57 |
|
|
|
58 |
|
|
#ifdef CYGPKG_KERNEL
|
59 |
|
|
# include
|
60 |
|
|
#endif
|
61 |
|
|
|
62 |
|
|
#include
|
63 |
|
|
#include
|
64 |
|
|
|
65 |
|
|
##-----------------------------------------------------------------------------
|
66 |
|
|
## ISR springboard.
|
67 |
|
|
## This routine decodes the interrupt from the various interrupt controllers
|
68 |
|
|
## and vectors to it.
|
69 |
|
|
|
70 |
|
|
# On entry:
|
71 |
|
|
# a0 = MIPS status register interrupt number (1,2 or 3)
|
72 |
|
|
# a1 = ISR data value (= interrupt controller reg address)
|
73 |
|
|
# a2 = saved reg dump ptr
|
74 |
|
|
# s0 = saved reg dump ptr
|
75 |
|
|
# s1 = vector table offset
|
76 |
|
|
# s2 = interrupt number
|
77 |
|
|
# a3,v0,v1 etc available for use
|
78 |
|
|
|
79 |
|
|
.text
|
80 |
|
|
|
81 |
|
|
FUNC_START(hal_isr_springboard_pci)
|
82 |
|
|
lbu v0,0(a1)
|
83 |
|
|
nor v0,v0,v0
|
84 |
|
|
la a1,CYGARC_REG_PCI_MASK
|
85 |
|
|
lbu a2,0(a1)
|
86 |
|
|
and v0,v0,a2
|
87 |
|
|
addi a2,$0,CYGNUM_HAL_INTERRUPT_INTC_PCI_base
|
88 |
|
|
b hal_isr_springboard
|
89 |
|
|
nop
|
90 |
|
|
FUNC_END(hal_isr_springboard_pci)
|
91 |
|
|
|
92 |
|
|
FUNC_START(hal_isr_springboard_io)
|
93 |
|
|
lbu v0,0(a1)
|
94 |
|
|
nor v0,v0,v0
|
95 |
|
|
la a1,CYGARC_REG_IO_MASK
|
96 |
|
|
lbu a2,0(a1)
|
97 |
|
|
and v0,v0,a2
|
98 |
|
|
addi a2,$0,CYGNUM_HAL_INTERRUPT_INTC_IO_base
|
99 |
|
|
b hal_isr_springboard
|
100 |
|
|
nop
|
101 |
|
|
FUNC_END(hal_isr_springboard_io)
|
102 |
|
|
|
103 |
|
|
hal_isr_springboard_v320usc:
|
104 |
|
|
lw v0,0(a1)
|
105 |
|
|
la a1,CYGARC_REG_INT_CFG0
|
106 |
|
|
lw v1,0(a1)
|
107 |
|
|
lw a2,4(a1) # CFG1
|
108 |
|
|
or v1,v1,a2
|
109 |
|
|
lw a2,8(a1) # CFG2
|
110 |
|
|
or v1,v1,a2
|
111 |
|
|
la a1,CYGARC_REG_INT_CFG3
|
112 |
|
|
lw a2,0(a1)
|
113 |
|
|
or v1,v1,a2
|
114 |
|
|
and v0,v0,v1
|
115 |
|
|
addi a2,$0,CYGNUM_HAL_INTERRUPT_INTC_V320USC_base
|
116 |
|
|
|
117 |
|
|
FUNC_START(hal_isr_springboard)
|
118 |
|
|
|
119 |
|
|
# The following code implements an ls bit index algorithm similar
|
120 |
|
|
# to that in hal_lsbit_index() in hal_misc.c.
|
121 |
|
|
negu v1,v0 # v1 = -v0
|
122 |
|
|
and v1,v1,v0 # v1 &= v0 [isolate ls bit]
|
123 |
|
|
sll v0,v1,16 # v0 = v1<<16
|
124 |
|
|
subu v1,v0,v1 # v1 = v0 - v1
|
125 |
|
|
sll a0,v1,6 # a0 = v1<<6
|
126 |
|
|
addu v1,v1,a0 # v1 += a0
|
127 |
|
|
sll a1,v1,4 # a1 = v1<<4
|
128 |
|
|
addu v1,v1,a1 # v1 += a1
|
129 |
|
|
la v0,hal_isr_springboard_table # v0 = table address
|
130 |
|
|
srl v1,v1,26 # v1 = v1>>26
|
131 |
|
|
addu v1,v1,v0 # v1 = table entry address
|
132 |
|
|
lb a0,0(v1) # a0 = intc isr number
|
133 |
|
|
|
134 |
|
|
add s2,a0,a2 # s2 = eCos isr number
|
135 |
|
|
#ifdef CYGIMP_HAL_COMMON_INTERRUPTS_CHAIN
|
136 |
|
|
hal_isr_springboard_chaining:
|
137 |
|
|
# This serves as the __default_interrupt_isr entry-point in
|
138 |
|
|
# chaning mode, thus ensuring that all interrupts from
|
139 |
|
|
# vectors 0-5 eventually end up on the special CHAINING vector.
|
140 |
|
|
# (See the hal_interrupt_handlers table)
|
141 |
|
|
ori s1,zero,CYGNUM_HAL_INTERRUPT_CHAINING*4 # s1 = chaining isr ix
|
142 |
|
|
#else
|
143 |
|
|
sll s1,s2,2 # s1 = isr table index
|
144 |
|
|
#endif
|
145 |
|
|
|
146 |
|
|
la v1,hal_interrupt_handlers
|
147 |
|
|
add v1,v1,s1 # v1 = isr handler address
|
148 |
|
|
lw v1,0(v1) # v1 = isr handler
|
149 |
|
|
|
150 |
|
|
la a1,hal_interrupt_data
|
151 |
|
|
add a1,a1,s1 # a1 = address of data ptr
|
152 |
|
|
lw a1,0(a1) # a1 = data pointer
|
153 |
|
|
|
154 |
|
|
move a0,s2 # pass interrupt number
|
155 |
|
|
|
156 |
|
|
jr v1 # jump to handler, return is to
|
157 |
|
|
# default vsr already in ra
|
158 |
|
|
nop
|
159 |
|
|
|
160 |
|
|
FUNC_END(hal_isr_springboard)
|
161 |
|
|
|
162 |
|
|
|
163 |
|
|
hal_isr_springboard_table:
|
164 |
|
|
.byte -1, 0, 1, 12, 2, 6, 0, 13
|
165 |
|
|
.byte 3, 0, 7, 0, 0, 0, 0, 14
|
166 |
|
|
.byte 10, 4, 0, 0, 8, 0, 0, 25
|
167 |
|
|
.byte 0, 0, 0, 0, 0, 21, 27, 15
|
168 |
|
|
.byte 31, 11, 5, 0, 0, 0, 0, 0
|
169 |
|
|
.byte 9, 0, 0, 24, 0, 0, 20, 26
|
170 |
|
|
.byte 30, 0, 0, 0, 0, 23, 0, 19
|
171 |
|
|
.byte 29, 0, 22, 18, 28, 17, 16, 0
|
172 |
|
|
|
173 |
|
|
|
174 |
|
|
##-----------------------------------------------------------------------------
|
175 |
|
|
## MEMC initialization.
|
176 |
|
|
## This also initializes the PCI bus and ISA bus bridge, so at the end of this
|
177 |
|
|
## we should have full access to all the memory and devices we need.
|
178 |
|
|
## This code is table driven, which is somewhat more compact that coding it all.
|
179 |
|
|
## Table entries consist of an address and a value to store in that address.
|
180 |
|
|
## A zero address terminates the table. Two special address values modify the
|
181 |
|
|
## behaviour:
|
182 |
|
|
## DELAY_LOOP loops for the number of iterations in the value field.
|
183 |
|
|
## WRITE16 treats the next 2 words as an address and value to be written
|
184 |
|
|
## with a 16 bit write cycle.
|
185 |
|
|
|
186 |
|
|
#if !defined(CYG_HAL_STARTUP_RAM)
|
187 |
|
|
|
188 |
|
|
#define DELAY_LOOP 1
|
189 |
|
|
#define WRITE16 2
|
190 |
|
|
|
191 |
|
|
FUNC_START(hal_memc_setup)
|
192 |
|
|
|
193 |
|
|
lar t0,hal_memc_setup_table
|
194 |
|
|
la t1,0xbfc00000
|
195 |
|
|
la t2,DELAY_LOOP
|
196 |
|
|
la t3,WRITE16
|
197 |
|
|
1:
|
198 |
|
|
lw a0,0(t0) # next table entry
|
199 |
|
|
lw a1,4(t0) # value to write
|
200 |
|
|
addiu t0,8 # go to next entry
|
201 |
|
|
beq a0,t2,2f # Check for delay
|
202 |
|
|
nop
|
203 |
|
|
beq a0,t3,3f # Check for 16 bit write
|
204 |
|
|
nop
|
205 |
|
|
beqz a0,9f # zero terminates loop
|
206 |
|
|
nop
|
207 |
|
|
sw a1,0(a0) # write it
|
208 |
|
|
lw zero,0(t1) # uncached read to flush write buffer
|
209 |
|
|
b 1b
|
210 |
|
|
nop
|
211 |
|
|
2:
|
212 |
|
|
lw zero,0(t1) # uncached read to flush write buffer
|
213 |
|
|
bnez a1,2b # count down by value in a1
|
214 |
|
|
addiu a1,-1 # decrement in delay slot
|
215 |
|
|
b 1b # go back to loop
|
216 |
|
|
nop
|
217 |
|
|
3:
|
218 |
|
|
lw a3,0(t0) # get next word
|
219 |
|
|
addiu t0,4 # skip it
|
220 |
|
|
sh a3,0(a1) # store halfword
|
221 |
|
|
lw zero,0(t1) # uncached read to flush write buffer
|
222 |
|
|
b 1b
|
223 |
|
|
nop
|
224 |
|
|
9:
|
225 |
|
|
jr ra
|
226 |
|
|
nop
|
227 |
|
|
|
228 |
|
|
FUNC_END(hal_memc_setup)
|
229 |
|
|
|
230 |
|
|
|
231 |
|
|
##-----------------------------------------------------------------------------
|
232 |
|
|
## The initialization table
|
233 |
|
|
|
234 |
|
|
#define USC_LB_BUS_CFG 0xb800007c
|
235 |
|
|
#define USC_SDRAM_MA_CMD 0xb8000088
|
236 |
|
|
|
237 |
|
|
hal_memc_setup_table:
|
238 |
|
|
|
239 |
|
|
.long DELAY_LOOP, 10000 # Wait for HW to settle
|
240 |
|
|
|
241 |
|
|
#ifdef CYGPKG_HAL_MIPS_MSBFIRST
|
242 |
|
|
# V320SC : big-endian, max bus watch timer
|
243 |
|
|
.long USC_LB_BUS_CFG, 0x04010ff0
|
244 |
|
|
#else
|
245 |
|
|
.long USC_LB_BUS_CFG, 0x04000ff0
|
246 |
|
|
#endif
|
247 |
|
|
.long USC_SDRAM_MA_CMD, 0x00a70000
|
248 |
|
|
.long USC_SDRAM_MA_CMD, 0x00e70220
|
249 |
|
|
|
250 |
|
|
.long 0, 0
|
251 |
|
|
|
252 |
|
|
#endif // !CYG_HAL_STARTUP_RAM
|
253 |
|
|
|
254 |
|
|
##-----------------------------------------------------------------------------
|
255 |
|
|
## ISR tables.
|
256 |
|
|
|
257 |
|
|
.extern hal_default_isr
|
258 |
|
|
|
259 |
|
|
.data
|
260 |
|
|
|
261 |
|
|
#ifdef CYGIMP_HAL_COMMON_INTERRUPTS_CHAIN
|
262 |
|
|
.globl hal_interrupt_handlers
|
263 |
|
|
hal_interrupt_handlers:
|
264 |
|
|
# These first 6 vectors all go through a springboard for further
|
265 |
|
|
# interrupt controller vector decoding before ending up on the
|
266 |
|
|
# special chaining vector below.
|
267 |
|
|
.long hal_isr_springboard_v320usc
|
268 |
|
|
.long hal_isr_springboard_pci
|
269 |
|
|
.long hal_isr_springboard_chaining
|
270 |
|
|
.long hal_isr_springboard_chaining
|
271 |
|
|
.long hal_isr_springboard_io
|
272 |
|
|
.long hal_isr_springboard_chaining
|
273 |
|
|
|
274 |
|
|
.long hal_default_isr # chaining vector
|
275 |
|
|
|
276 |
|
|
.globl hal_interrupt_data
|
277 |
|
|
hal_interrupt_data:
|
278 |
|
|
.long CYGARC_REG_INT_STAT
|
279 |
|
|
.long CYGARC_REG_PCI_STAT
|
280 |
|
|
.long 0
|
281 |
|
|
.long 0
|
282 |
|
|
.long CYGARC_REG_IO_STAT
|
283 |
|
|
.long 0
|
284 |
|
|
|
285 |
|
|
.long 0 # chaining vector data
|
286 |
|
|
|
287 |
|
|
.globl hal_interrupt_objects
|
288 |
|
|
hal_interrupt_objects:
|
289 |
|
|
.long 0
|
290 |
|
|
.long 0
|
291 |
|
|
.long 0
|
292 |
|
|
.long 0
|
293 |
|
|
.long 0
|
294 |
|
|
.long 0
|
295 |
|
|
|
296 |
|
|
.long 0 # chaining vector object
|
297 |
|
|
|
298 |
|
|
.globl cyg_hal_interrupt_level
|
299 |
|
|
cyg_hal_interrupt_level:
|
300 |
|
|
.rept CYGNUM_HAL_ISR_COUNT
|
301 |
|
|
.byte 0
|
302 |
|
|
.endr
|
303 |
|
|
|
304 |
|
|
#else // CYGIMP_HAL_COMMON_INTERRUPTS_CHAIN
|
305 |
|
|
|
306 |
|
|
.globl hal_interrupt_handlers
|
307 |
|
|
hal_interrupt_handlers:
|
308 |
|
|
.long hal_isr_springboard_v320usc
|
309 |
|
|
.long hal_isr_springboard_pci
|
310 |
|
|
.long hal_default_isr
|
311 |
|
|
.long hal_default_isr
|
312 |
|
|
.long hal_isr_springboard_io
|
313 |
|
|
.long hal_default_isr
|
314 |
|
|
|
315 |
|
|
.rept CYGNUM_HAL_ISR_COUNT-6
|
316 |
|
|
.long hal_default_isr
|
317 |
|
|
.endr
|
318 |
|
|
|
319 |
|
|
.globl hal_interrupt_data
|
320 |
|
|
hal_interrupt_data:
|
321 |
|
|
.long CYGARC_REG_INT_STAT
|
322 |
|
|
.long CYGARC_REG_PCI_STAT
|
323 |
|
|
.long 0
|
324 |
|
|
.long 0
|
325 |
|
|
.long CYGARC_REG_IO_STAT
|
326 |
|
|
.long 0
|
327 |
|
|
|
328 |
|
|
.rept CYGNUM_HAL_ISR_COUNT-6
|
329 |
|
|
.long 0
|
330 |
|
|
.endr
|
331 |
|
|
|
332 |
|
|
.globl hal_interrupt_objects
|
333 |
|
|
hal_interrupt_objects:
|
334 |
|
|
.rept CYGNUM_HAL_ISR_COUNT
|
335 |
|
|
.long 0
|
336 |
|
|
.endr
|
337 |
|
|
|
338 |
|
|
.globl cyg_hal_interrupt_level
|
339 |
|
|
cyg_hal_interrupt_level:
|
340 |
|
|
.rept CYGNUM_HAL_ISR_COUNT
|
341 |
|
|
.byte 0
|
342 |
|
|
.endr
|
343 |
|
|
|
344 |
|
|
#endif // CYGIMP_HAL_COMMON_INTERRUPTS_CHAIN
|
345 |
|
|
|
346 |
|
|
##-----------------------------------------------------------------------------
|
347 |
|
|
## end of platform.S
|