1 |
1254 |
phoenix |
##
|
2 |
|
|
#=============================================================================
|
3 |
|
|
## platform.S
|
4 |
|
|
##
|
5 |
|
|
## MIPS Atlas 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): dmoseley
|
44 |
|
|
## Contributors: dmoseley
|
45 |
|
|
## Date: 2000-06-06
|
46 |
|
|
## Purpose: MIPS Atlas platform code
|
47 |
|
|
## Description: Platform specific code for Atlas board.
|
48 |
|
|
##
|
49 |
|
|
##
|
50 |
|
|
##
|
51 |
|
|
##
|
52 |
|
|
######DESCRIPTIONEND####
|
53 |
|
|
##
|
54 |
|
|
##=============================================================================
|
55 |
|
|
|
56 |
|
|
#include
|
57 |
|
|
#include
|
58 |
|
|
|
59 |
|
|
#ifdef CYGPKG_KERNEL
|
60 |
|
|
# include
|
61 |
|
|
#endif
|
62 |
|
|
|
63 |
|
|
#include
|
64 |
|
|
#include
|
65 |
|
|
#include
|
66 |
|
|
|
67 |
|
|
##-----------------------------------------------------------------------------
|
68 |
|
|
|
69 |
|
|
##-----------------------------------------------------------------------------
|
70 |
|
|
# Platform Initialization.
|
71 |
|
|
# This code performs platform specific initialization.
|
72 |
|
|
|
73 |
|
|
##-----------------------------------------------------------------------------
|
74 |
|
|
## MEMC initialization.
|
75 |
|
|
##
|
76 |
|
|
|
77 |
|
|
#if defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_ROMRAM)
|
78 |
|
|
|
79 |
|
|
.text
|
80 |
|
|
.set noreorder
|
81 |
|
|
|
82 |
|
|
|
83 |
|
|
.macro MASK_WRITE_PCI_REG regnum, devnum, mask
|
84 |
|
|
.set noreorder
|
85 |
|
|
# First, read the appropriate register
|
86 |
|
|
li t0, HAL_GALILEO_PCI0_CONFIG_ADDR_ConfigEn | \regnum | \devnum
|
87 |
|
|
sw t0, HAL_GALILEO_PCI0_CONFIG_ADDR_OFFSET(s7)
|
88 |
|
|
lw t1, HAL_GALILEO_PCI0_CONFIG_DATA_OFFSET(s7)
|
89 |
|
|
|
90 |
|
|
# Now, mask in the appropriate bits
|
91 |
|
|
li t2, \mask
|
92 |
|
|
or t1, t2
|
93 |
|
|
|
94 |
|
|
# Write the updated value
|
95 |
|
|
li t0, HAL_GALILEO_PCI0_CONFIG_ADDR_ConfigEn | \regnum | \devnum
|
96 |
|
|
sw t0, HAL_GALILEO_PCI0_CONFIG_ADDR_OFFSET(s7)
|
97 |
|
|
sw t1, HAL_GALILEO_PCI0_CONFIG_DATA_OFFSET(s7)
|
98 |
|
|
.endm
|
99 |
|
|
|
100 |
|
|
.macro WRITE_PCI_REG regnum, devnum, base
|
101 |
|
|
.set noreorder
|
102 |
|
|
li t0, HAL_GALILEO_PCI0_CONFIG_ADDR_ConfigEn | \regnum | \devnum
|
103 |
|
|
li t1, \base
|
104 |
|
|
sw t0, HAL_GALILEO_PCI0_CONFIG_ADDR_OFFSET(s7)
|
105 |
|
|
sw t1, HAL_GALILEO_PCI0_CONFIG_DATA_OFFSET(s7)
|
106 |
|
|
.endm
|
107 |
|
|
|
108 |
|
|
#define NO_MASK 0
|
109 |
|
|
#define NO_ERROR_CHECK 0
|
110 |
|
|
#define ERROR_CHECK 1
|
111 |
|
|
.macro READ_SPD_VALUE func, mask, ret_reg, err_check
|
112 |
|
|
.set noreorder
|
113 |
|
|
jal read_spd_value
|
114 |
|
|
li a0, \func # delay slot
|
115 |
|
|
.if \err_check
|
116 |
|
|
beq v0, zero, error
|
117 |
|
|
nop
|
118 |
|
|
.endif
|
119 |
|
|
move \ret_reg, v0
|
120 |
|
|
.if \mask
|
121 |
|
|
and \ret_reg, \mask
|
122 |
|
|
.endif
|
123 |
|
|
.endm
|
124 |
|
|
|
125 |
|
|
##-----------------------------------------------------------------------------
|
126 |
|
|
##
|
127 |
|
|
## Initialize the RAM.
|
128 |
|
|
##
|
129 |
|
|
## To do that, we need to first initialize the Galileo PCI stuff to gain access
|
130 |
|
|
## to the SAA9730.
|
131 |
|
|
## From there, use the I2C bus of the SAA9730 to read the SPD SDRAM
|
132 |
|
|
## config data. We then setup the Galileo SDRAM configuration
|
133 |
|
|
##
|
134 |
|
|
## Returns
|
135 |
|
|
## v0 = Error Code
|
136 |
|
|
## v1 = SDRAM size
|
137 |
|
|
##
|
138 |
|
|
FUNC_START(hal_atlas_init_sdram)
|
139 |
|
|
|
140 |
|
|
.set noreorder
|
141 |
|
|
|
142 |
|
|
# Save the return address
|
143 |
|
|
move s8, ra
|
144 |
|
|
|
145 |
|
|
# Setup the base address registers
|
146 |
|
|
li s7, CYGARC_UNCACHED_ADDRESS(HAL_GALILEO_REGISTER_BASE)
|
147 |
|
|
|
148 |
|
|
# Setup the Galileo controller Endian configuration
|
149 |
|
|
li t0, (HAL_GALILEO_BYTE_SWAP)
|
150 |
|
|
sw t0, HAL_GALILEO_PCI_INTERNAL_COMMAND_OFFSET(s7)
|
151 |
|
|
|
152 |
|
|
# Setup the PCI_0 Timeout and retry configuration
|
153 |
|
|
li t0, HAL_GALILEO_PCI0_TIMEOUT_RETRY_VALUE
|
154 |
|
|
sw t0, HAL_GALILEO_PCI0_TIMEOUT_RETRY_OFFSET(s7)
|
155 |
|
|
|
156 |
|
|
# Setup Galileo as PCI Master
|
157 |
|
|
MASK_WRITE_PCI_REG HAL_GALILEO_PCI0_STATUS_COMMAND_REGNUM, HAL_ATLAS_NULL_DEVNUM, \
|
158 |
|
|
(HAL_GALILEO_PCI0_CONFIG_MEMEn | HAL_GALILEO_PCI0_CONFIG_MasEn | HAL_GALILEO_PCI0_CONFIG_SErrEn)
|
159 |
|
|
|
160 |
|
|
# Setup Galileo PCI latency timer
|
161 |
|
|
MASK_WRITE_PCI_REG HAL_GALILEO_PCI0_BIST_REGNUM, HAL_ATLAS_NULL_DEVNUM, \
|
162 |
|
|
HAL_GALILEO_PCI0_LAT_TIMER_VAL
|
163 |
|
|
|
164 |
|
|
# Setup base address for SAA9730
|
165 |
|
|
WRITE_PCI_REG HAL_GALILEO_PCI0_SCS32_BASE_REGNUM, HAL_ATLAS_SAA9730_DEVNUM, \
|
166 |
|
|
CYGARC_PHYSICAL_ADDRESS(HAL_GALILEO_PCI0_MEM0_BASE)
|
167 |
|
|
|
168 |
|
|
# Setup SAA9730 command and status register
|
169 |
|
|
MASK_WRITE_PCI_REG HAL_GALILEO_PCI0_STATUS_COMMAND_REGNUM, HAL_ATLAS_SAA9730_DEVNUM, \
|
170 |
|
|
(HAL_GALILEO_PCI0_CONFIG_MEMEn | HAL_GALILEO_PCI0_CONFIG_SErrEn)
|
171 |
|
|
|
172 |
|
|
# Init the I2C controller
|
173 |
|
|
li t0, HAL_SAA9730_I2CSC_I2CCC_6400
|
174 |
|
|
li t1, CYGARC_UNCACHED_ADDRESS(HAL_GALILEO_PCI0_MEM0_BASE)
|
175 |
|
|
sw t0, HAL_SAA9730_I2CSC_OFFSET(t1)
|
176 |
|
|
|
177 |
|
|
##=====================================================================================
|
178 |
|
|
##
|
179 |
|
|
## Read the SPD device parameters and determine memory size
|
180 |
|
|
##
|
181 |
|
|
READ_SPD_VALUE HAL_SPD_GET_NUM_ROW_BITS, 0xf, s0, ERROR_CHECK
|
182 |
|
|
READ_SPD_VALUE HAL_SPD_GET_NUM_COL_BITS, 0xf, s1, ERROR_CHECK
|
183 |
|
|
READ_SPD_VALUE HAL_SPD_GET_NUM_DEVICE_BANKS, NO_MASK, s2, ERROR_CHECK
|
184 |
|
|
|
185 |
|
|
READ_SPD_VALUE HAL_SPD_GET_SDRAM_WIDTH, 0x7f, s3, ERROR_CHECK
|
186 |
|
|
READ_SPD_VALUE HAL_SPD_GET_NUM_MODULE_BANKS, NO_MASK, s4, ERROR_CHECK
|
187 |
|
|
READ_SPD_VALUE HAL_SPD_GET_ROW_DENSITY, NO_MASK, s5, ERROR_CHECK
|
188 |
|
|
|
189 |
|
|
#
|
190 |
|
|
# Determine Size
|
191 |
|
|
# SIZE = SDRAM_WIDTH * NUM_DEVICE_BANKS * 2 ^ (NUM_ROW_BITS + NUM_COL_BITS)
|
192 |
|
|
#
|
193 |
|
|
addu t0, s0, s1 # t0 = (NUM_ROW_BITS + NUM_COL_BITS)
|
194 |
|
|
li t1, 1 # t1 = 2 ^ 0
|
195 |
|
|
sll t1, t0 # t1 = 2 ^ (NUM_ROW_BITS + NUM_COL_BITS)
|
196 |
|
|
multu s2, t1
|
197 |
|
|
mflo s6 # s6 = NUM_DEVICE_BANKS * 2 ^ (NUM_ROW_BITS + NUM_COL_BITS)
|
198 |
|
|
nop
|
199 |
|
|
nop
|
200 |
|
|
nop
|
201 |
|
|
multu s6, s3
|
202 |
|
|
mflo s6 # s6 = SDRAM_WIDTH * NUM_DEVICE_BANKS * 2 ^ (NUM_ROW_BITS + NUM_COL_BITS)
|
203 |
|
|
nop
|
204 |
|
|
nop
|
205 |
|
|
nop
|
206 |
|
|
|
207 |
|
|
#
|
208 |
|
|
# Determine size of Bank 0
|
209 |
|
|
#
|
210 |
|
|
li s0, HAL_ATLAS_MAX_BANKSIZE
|
211 |
|
|
0:
|
212 |
|
|
and t1, s5, BIT7
|
213 |
|
|
bnez t1, 8f
|
214 |
|
|
sll s5, 1
|
215 |
|
|
b 0b
|
216 |
|
|
srl s0, 1
|
217 |
|
|
8:
|
218 |
|
|
|
219 |
|
|
#
|
220 |
|
|
# Determine if Bank 1 exists
|
221 |
|
|
#
|
222 |
|
|
li t0, 1
|
223 |
|
|
beq s4, t0, 8f
|
224 |
|
|
move s1, zero
|
225 |
|
|
#
|
226 |
|
|
# Determine if Bank 1 is different than Bank 0
|
227 |
|
|
#
|
228 |
|
|
and t1, s5, 0xFF
|
229 |
|
|
beq t1, zero, 8f
|
230 |
|
|
move s1, s0
|
231 |
|
|
#
|
232 |
|
|
# Determine size of Bank 1
|
233 |
|
|
#
|
234 |
|
|
li s1, HAL_ATLAS_MAX_BANKSIZE
|
235 |
|
|
0:
|
236 |
|
|
and t1, s5, BIT7
|
237 |
|
|
bnez t1, 8f
|
238 |
|
|
sll s5, 1
|
239 |
|
|
b 0b
|
240 |
|
|
srl s1, 1
|
241 |
|
|
8:
|
242 |
|
|
|
243 |
|
|
#
|
244 |
|
|
# FIXME: We should probably do some validation on the various
|
245 |
|
|
# memory parameters here at some point.
|
246 |
|
|
#
|
247 |
|
|
|
248 |
|
|
#
|
249 |
|
|
# Set the base SDRAM bank configuration value.
|
250 |
|
|
# All other fields are zero, and the proper value is masked
|
251 |
|
|
# in when they are known
|
252 |
|
|
#
|
253 |
|
|
li s5, HAL_GALILEO_SDRAM_SRAS_TO_SCAS_DELAY_3C | \
|
254 |
|
|
HAL_GALILEO_SDRAM_WIDTH_64BIT | \
|
255 |
|
|
HAL_GALILEO_SDRAM_SRAS_PRECHARGE_3C
|
256 |
|
|
|
257 |
|
|
#
|
258 |
|
|
# Setup the CASLAT value.
|
259 |
|
|
# Support only CASLAT = 2
|
260 |
|
|
#
|
261 |
|
|
READ_SPD_VALUE HAL_SPD_GET_CAS_LAT, NO_MASK, v0, NO_ERROR_CHECK
|
262 |
|
|
and t0, v0, 2
|
263 |
|
|
beqz t0, error
|
264 |
|
|
nop
|
265 |
|
|
ori s5, HAL_GALILEO_SDRAM_BANK0_CASLAT_2
|
266 |
|
|
|
267 |
|
|
#
|
268 |
|
|
# Setup SDRAM device size
|
269 |
|
|
#
|
270 |
|
|
li t0, SZ_16M
|
271 |
|
|
beq s6, t0, 8f
|
272 |
|
|
nop
|
273 |
|
|
ori s5, HAL_GALILEO_SDRAM_BANK0_SZ_64M
|
274 |
|
|
8:
|
275 |
|
|
|
276 |
|
|
#
|
277 |
|
|
# Setup burst length: Support only 8
|
278 |
|
|
#
|
279 |
|
|
READ_SPD_VALUE HAL_SPD_GET_BURST_LENGTH, NO_MASK, v0, NO_ERROR_CHECK
|
280 |
|
|
and t0, v0, 8
|
281 |
|
|
beqz t0, error
|
282 |
|
|
nop
|
283 |
|
|
|
284 |
|
|
#
|
285 |
|
|
# Setup Parity.
|
286 |
|
|
# Only support Parity/Noparity. Don't support ECC.
|
287 |
|
|
#
|
288 |
|
|
READ_SPD_VALUE HAL_SPD_GET_CONFIG_TYPE, NO_MASK, v0, NO_ERROR_CHECK
|
289 |
|
|
li t0, HAL_SPD_CONFIG_TYPE_PARITY
|
290 |
|
|
beq t0, v0, 0f
|
291 |
|
|
nop
|
292 |
|
|
li t0, HAL_SPD_CONFIG_TYPE_ECC
|
293 |
|
|
beq t0, v0, error
|
294 |
|
|
nop
|
295 |
|
|
b 8f
|
296 |
|
|
li v1, 0
|
297 |
|
|
0:
|
298 |
|
|
ori s5, HAL_GALILEO_SDRAM_BANK0_PARITY
|
299 |
|
|
li v1, 1
|
300 |
|
|
8:
|
301 |
|
|
|
302 |
|
|
#
|
303 |
|
|
# Setup number of device banks
|
304 |
|
|
# Only support 2 or 4 banks
|
305 |
|
|
#
|
306 |
|
|
li t0, 2
|
307 |
|
|
beq s2, t0, 8f
|
308 |
|
|
nop
|
309 |
|
|
li t0, 4
|
310 |
|
|
beq s2, t0, 0f
|
311 |
|
|
nop
|
312 |
|
|
b error
|
313 |
|
|
nop
|
314 |
|
|
0:
|
315 |
|
|
ori s5, HAL_GALILEO_SDRAM_NUM_BANKS_4
|
316 |
|
|
8:
|
317 |
|
|
|
318 |
|
|
#
|
319 |
|
|
# Now actually store the bank config register
|
320 |
|
|
#
|
321 |
|
|
sw s5, HAL_GALILEO_SDRAM_BANK0_OFFSET(s7)
|
322 |
|
|
sw s5, HAL_GALILEO_SDRAM_BANK2_OFFSET(s7)
|
323 |
|
|
|
324 |
|
|
#
|
325 |
|
|
# Setup the SDRAM configuration register
|
326 |
|
|
# All other fields are zero, and the proper value is masked
|
327 |
|
|
# in when they are known
|
328 |
|
|
#
|
329 |
|
|
li s5, HAL_GALILEO_SDRAM_DUPLICATE_BANK_ADDR | HAL_GALILEO_SDRAM_BANK_INTERLEAVE_DIS
|
330 |
|
|
|
331 |
|
|
#
|
332 |
|
|
# Setup the Refresh Rate
|
333 |
|
|
#
|
334 |
|
|
READ_SPD_VALUE HAL_SPD_GET_REFRESH_RATE, 0x7f, v0, NO_ERROR_CHECK
|
335 |
|
|
|
336 |
|
|
li t0, HAL_SPD_REFRESH_RATE_125
|
337 |
|
|
beq t0, v0, 8f
|
338 |
|
|
li t0, HAL_SPD_REFRESH_COUNTER_125
|
339 |
|
|
|
340 |
|
|
li t0, HAL_SPD_REFRESH_RATE_62_5
|
341 |
|
|
beq t0, v0, 8f
|
342 |
|
|
li t0, HAL_SPD_REFRESH_COUNTER_62_5
|
343 |
|
|
|
344 |
|
|
li t0, HAL_SPD_REFRESH_RATE_31_3
|
345 |
|
|
beq t0, v0, 8f
|
346 |
|
|
li t0, HAL_SPD_REFRESH_COUNTER_31_3
|
347 |
|
|
|
348 |
|
|
li t0, HAL_SPD_REFRESH_RATE_15_625
|
349 |
|
|
beq t0, v0, 8f
|
350 |
|
|
li t0, HAL_SPD_REFRESH_COUNTER_15_625
|
351 |
|
|
|
352 |
|
|
li t0, HAL_SPD_REFRESH_RATE_7_8
|
353 |
|
|
beq t0, v0, 8f
|
354 |
|
|
li t0, HAL_SPD_REFRESH_COUNTER_7_8
|
355 |
|
|
|
356 |
|
|
# Unknown: assume 3.9 microseconds
|
357 |
|
|
li t0, HAL_SPD_REFRESH_COUNTER_3_9
|
358 |
|
|
8:
|
359 |
|
|
|
360 |
|
|
or s5, t0
|
361 |
|
|
|
362 |
|
|
#
|
363 |
|
|
# Setup RAM_WIDTH
|
364 |
|
|
#
|
365 |
|
|
beqz v1, 8f
|
366 |
|
|
nop
|
367 |
|
|
READ_SPD_VALUE HAL_SPD_GET_ERROR_CHECK_WIDTH, 0x7f, v0, NO_ERROR_CHECK
|
368 |
|
|
beq v0, zero, 8f
|
369 |
|
|
nop
|
370 |
|
|
ori s5, HAL_GALILEO_SDRAM_CFG_RAM_WIDTH
|
371 |
|
|
8:
|
372 |
|
|
|
373 |
|
|
#
|
374 |
|
|
# Store the SDRAM configuration register
|
375 |
|
|
#
|
376 |
|
|
sw s5, HAL_GALILEO_SDRAM_CONFIG_OFFSET(s7)
|
377 |
|
|
|
378 |
|
|
#
|
379 |
|
|
# Reset SAA9730 now that we are done with the I2C unit.
|
380 |
|
|
# This allows the generic PCI library to start with a clean
|
381 |
|
|
# slate of devices on the PCI bus.
|
382 |
|
|
#
|
383 |
|
|
li a0, CYGARC_UNCACHED_ADDRESS(HAL_GALILEO_PCI0_MEM0_BASE)
|
384 |
|
|
li t0, HAL_SAA9730_SYSRESET_ALL
|
385 |
|
|
sw t0, HAL_SAA9730_SYSRESET_OFFSET(a0)
|
386 |
|
|
|
387 |
|
|
#
|
388 |
|
|
# Change the Galileo Base address to HAL_ATLAS_CONTROLLER_BASE
|
389 |
|
|
#
|
390 |
|
|
li t0, HAL_ATLAS_CONTROLLER_BASE_ISD_CONFIG
|
391 |
|
|
sw t0, HAL_GALILEO_INT_SPACE_DECODE_OFFSET(s7)
|
392 |
|
|
li s7, CYGARC_UNCACHED_ADDRESS(HAL_ATLAS_CONTROLLER_BASE)
|
393 |
|
|
|
394 |
|
|
#
|
395 |
|
|
# Setup SDRAM Bank 0 Address Decoding
|
396 |
|
|
#
|
397 |
|
|
li a0, CYGARC_PHYSICAL_ADDRESS(HAL_ATLAS_RAM_BASE) # Physical bottom of Bank 0
|
398 |
|
|
add a1, s0, a0
|
399 |
|
|
subu a1, 1 # Physical top of Bank 0
|
400 |
|
|
|
401 |
|
|
srl t0, a0, HAL_GALILEO_CPU_DECODE_SHIFT # Setup SCS[1:0]
|
402 |
|
|
srl t1, a1, HAL_GALILEO_CPU_DECODE_SHIFT # First level decoding
|
403 |
|
|
sw t0, HAL_GALILEO_SCS10_LD_OFFSET(s7) # (ie Processor Decode Region)
|
404 |
|
|
sw t1, HAL_GALILEO_SCS10_HD_OFFSET(s7) #
|
405 |
|
|
|
406 |
|
|
srl t0, a0, HAL_GALILEO_DEV_DECODE_SHIFT # Setup SCS0
|
407 |
|
|
srl t1, a1, HAL_GALILEO_DEV_DECODE_SHIFT # Second level decoding
|
408 |
|
|
sw t0, HAL_GALILEO_SCS0_LD_OFFSET(s7) # (ie Device Sub-decode Region)
|
409 |
|
|
sw t1, HAL_GALILEO_SCS0_HD_OFFSET(s7) #
|
410 |
|
|
|
411 |
|
|
#
|
412 |
|
|
# Setup SDRAM Bank 1 Address Decoding
|
413 |
|
|
#
|
414 |
|
|
add a0, s0, CYGARC_PHYSICAL_ADDRESS(HAL_ATLAS_RAM_BASE) # Physical bottom of Bank 1
|
415 |
|
|
add a1, a0, s1
|
416 |
|
|
subu a1, 1 # Physical top of Bank 1
|
417 |
|
|
|
418 |
|
|
srl t0, a0, HAL_GALILEO_CPU_DECODE_SHIFT # Setup SCS[3:2]
|
419 |
|
|
srl t1, a1, HAL_GALILEO_CPU_DECODE_SHIFT # First level decoding
|
420 |
|
|
sw t0, HAL_GALILEO_SCS32_LD_OFFSET(s7) # (ie Processor Decode Region)
|
421 |
|
|
sw t1, HAL_GALILEO_SCS32_HD_OFFSET(s7) #
|
422 |
|
|
|
423 |
|
|
srl t0, a0, HAL_GALILEO_DEV_DECODE_SHIFT # Setup SCS2
|
424 |
|
|
srl t1, a1, HAL_GALILEO_DEV_DECODE_SHIFT # Second level decoding
|
425 |
|
|
sw t0, HAL_GALILEO_SCS2_LD_OFFSET(s7) # (ie Device Sub-decode Region)
|
426 |
|
|
sw t1, HAL_GALILEO_SCS2_HD_OFFSET(s7) #
|
427 |
|
|
|
428 |
|
|
#
|
429 |
|
|
# Setup PCI windows
|
430 |
|
|
#
|
431 |
|
|
li a0, CYGARC_PHYSICAL_ADDRESS(HAL_ATLAS_PCI_MEM0_BASE)
|
432 |
|
|
add a1, a0, HAL_ATLAS_PCI_MEM0_SIZE
|
433 |
|
|
subu a1, 1 # Physical top of Bank 1
|
434 |
|
|
srl t0, a0, HAL_GALILEO_CPU_DECODE_SHIFT
|
435 |
|
|
srl t1, a1, HAL_GALILEO_CPU_DECODE_SHIFT
|
436 |
|
|
sw t0, HAL_GALILEO_PCIMEM0_LD_OFFSET(s7)
|
437 |
|
|
sw t1, HAL_GALILEO_PCIMEM0_HD_OFFSET(s7)
|
438 |
|
|
|
439 |
|
|
li a0, CYGARC_PHYSICAL_ADDRESS(HAL_ATLAS_PCI_MEM1_BASE)
|
440 |
|
|
add a1, a0, HAL_ATLAS_PCI_MEM1_SIZE
|
441 |
|
|
subu a1, 1 # Physical top of Bank 1
|
442 |
|
|
srl t0, a0, HAL_GALILEO_CPU_DECODE_SHIFT
|
443 |
|
|
srl t1, a1, HAL_GALILEO_CPU_DECODE_SHIFT
|
444 |
|
|
sw t0, HAL_GALILEO_PCIMEM1_LD_OFFSET(s7)
|
445 |
|
|
sw t1, HAL_GALILEO_PCIMEM1_HD_OFFSET(s7)
|
446 |
|
|
|
447 |
|
|
li a0, CYGARC_PHYSICAL_ADDRESS(HAL_ATLAS_PCI_IO_BASE)
|
448 |
|
|
add a1, a0, HAL_ATLAS_PCI_IO_SIZE
|
449 |
|
|
subu a1, 1 # Physical top of Bank 1
|
450 |
|
|
srl t0, a0, HAL_GALILEO_CPU_DECODE_SHIFT
|
451 |
|
|
srl t1, a1, HAL_GALILEO_CPU_DECODE_SHIFT
|
452 |
|
|
sw t0, HAL_GALILEO_PCIIO_LD_OFFSET(s7)
|
453 |
|
|
sw t1, HAL_GALILEO_PCIIO_HD_OFFSET(s7)
|
454 |
|
|
|
455 |
|
|
#
|
456 |
|
|
# Setup FLASH Address Decoding
|
457 |
|
|
#
|
458 |
|
|
li a0, CYGARC_PHYSICAL_ADDRESS(HAL_ATLAS_FLASH_BASE) # Physical bottom of Flash Bank
|
459 |
|
|
add a1, a0, HAL_ATLAS_FLASH_SIZE
|
460 |
|
|
subu a1, 1 # Physical top of Flash Bank
|
461 |
|
|
|
462 |
|
|
srl t0, a0, HAL_GALILEO_CPU_DECODE_SHIFT # Setup CS[2:0]
|
463 |
|
|
srl t1, a1, HAL_GALILEO_CPU_DECODE_SHIFT # First level decoding
|
464 |
|
|
sw t0, HAL_GALILEO_CS20_LD_OFFSET(s7) # (ie Processor Decode Region)
|
465 |
|
|
sw t1, HAL_GALILEO_CS20_HD_OFFSET(s7) #
|
466 |
|
|
|
467 |
|
|
srl t0, a0, HAL_GALILEO_DEV_DECODE_SHIFT # Setup CS0
|
468 |
|
|
srl t1, a1, HAL_GALILEO_DEV_DECODE_SHIFT # Second level decoding
|
469 |
|
|
sw t0, HAL_GALILEO_CS0_LD_OFFSET(s7) # (ie Device Sub-decode Region)
|
470 |
|
|
sw t1, HAL_GALILEO_CS0_HD_OFFSET(s7) #
|
471 |
|
|
|
472 |
|
|
#
|
473 |
|
|
# Now disable all unused decodes
|
474 |
|
|
# (SCS1, SCS3, PCI1xx, CS1, CS2)
|
475 |
|
|
#
|
476 |
|
|
li t0, 0xffff
|
477 |
|
|
move t1, zero
|
478 |
|
|
sw t0, HAL_GALILEO_SCS1_LD_OFFSET(s7)
|
479 |
|
|
sw t1, HAL_GALILEO_SCS1_HD_OFFSET(s7)
|
480 |
|
|
sw t0, HAL_GALILEO_SCS3_LD_OFFSET(s7)
|
481 |
|
|
sw t1, HAL_GALILEO_SCS3_HD_OFFSET(s7)
|
482 |
|
|
sw t0, HAL_GALILEO_PCI1IO_LD_OFFSET(s7)
|
483 |
|
|
sw t1, HAL_GALILEO_PCI1IO_HD_OFFSET(s7)
|
484 |
|
|
sw t0, HAL_GALILEO_PCI1MEM0_LD_OFFSET(s7)
|
485 |
|
|
sw t1, HAL_GALILEO_PCI1MEM0_HD_OFFSET(s7)
|
486 |
|
|
sw t0, HAL_GALILEO_PCI1MEM1_LD_OFFSET(s7)
|
487 |
|
|
sw t1, HAL_GALILEO_PCI1MEM1_HD_OFFSET(s7)
|
488 |
|
|
sw t0, HAL_GALILEO_CS1_LD_OFFSET(s7)
|
489 |
|
|
sw t1, HAL_GALILEO_CS1_HD_OFFSET(s7)
|
490 |
|
|
sw t0, HAL_GALILEO_CS2_LD_OFFSET(s7)
|
491 |
|
|
sw t1, HAL_GALILEO_CS2_HD_OFFSET(s7)
|
492 |
|
|
|
493 |
|
|
noerror:
|
494 |
|
|
move v0, zero
|
495 |
|
|
add v1, s0, s1
|
496 |
|
|
move ra, s8
|
497 |
|
|
jr ra
|
498 |
|
|
nop
|
499 |
|
|
|
500 |
|
|
error:
|
501 |
|
|
li v0, HAL_ATLAS_MEMERROR
|
502 |
|
|
move ra, s8
|
503 |
|
|
jr ra
|
504 |
|
|
nop
|
505 |
|
|
|
506 |
|
|
FUNC_END(hal_atlas_init_sdram)
|
507 |
|
|
|
508 |
|
|
##
|
509 |
|
|
## Read a value from the SDRAM SPD device.
|
510 |
|
|
##
|
511 |
|
|
## Parameters: a0 = subaddress
|
512 |
|
|
## Returns: v0 = SPD value read
|
513 |
|
|
##
|
514 |
|
|
FUNC_START(read_spd_value)
|
515 |
|
|
#
|
516 |
|
|
# Setup a base address register
|
517 |
|
|
#
|
518 |
|
|
li a1, CYGARC_UNCACHED_ADDRESS(HAL_GALILEO_PCI0_MEM0_BASE)
|
519 |
|
|
|
520 |
|
|
#
|
521 |
|
|
# Write the I2C command
|
522 |
|
|
#
|
523 |
|
|
sll a0, 16
|
524 |
|
|
li t0, (HAL_SAA9730_I2CTFR_ATTR1_CONT | \
|
525 |
|
|
((0xa0 << 24) | HAL_SAA9730_I2CTFR_ATTR2_START) | \
|
526 |
|
|
((0xa1 << 8) | HAL_SAA9730_I2CTFR_ATTR0_START))
|
527 |
|
|
or a0, t0
|
528 |
|
|
sw a0, HAL_SAA9730_I2CTFR_OFFSET(a1)
|
529 |
|
|
1: lw t0, HAL_SAA9730_I2CTFR_OFFSET(a1)
|
530 |
|
|
and t0, 0x1
|
531 |
|
|
bnez t0, 1b
|
532 |
|
|
nop
|
533 |
|
|
|
534 |
|
|
#
|
535 |
|
|
# Read the SPD value
|
536 |
|
|
#
|
537 |
|
|
li a0, HAL_SAA9730_I2CTFR_ATTR2_STOP
|
538 |
|
|
sw a0, HAL_SAA9730_I2CTFR_OFFSET(a1)
|
539 |
|
|
1: lw t0, HAL_SAA9730_I2CTFR_OFFSET(a1)
|
540 |
|
|
and t0, 0x1
|
541 |
|
|
bnez t0, 1b
|
542 |
|
|
nop
|
543 |
|
|
|
544 |
|
|
#
|
545 |
|
|
# Setup the return value.
|
546 |
|
|
#
|
547 |
|
|
lw v0, HAL_SAA9730_I2CTFR_OFFSET(a1)
|
548 |
|
|
srl v0, 24
|
549 |
|
|
|
550 |
|
|
jr ra
|
551 |
|
|
nop
|
552 |
|
|
FUNC_END(read_spd_value)
|
553 |
|
|
#endif /* defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_ROMRAM) */
|
554 |
|
|
|
555 |
|
|
##-----------------------------------------------------------------------------
|
556 |
|
|
# Interrupt vector tables.
|
557 |
|
|
# These tables contain the isr, data and object pointers used to deliver
|
558 |
|
|
# interrupts to user code.
|
559 |
|
|
|
560 |
|
|
.extern hal_default_isr
|
561 |
|
|
|
562 |
|
|
.data
|
563 |
|
|
|
564 |
|
|
.globl hal_interrupt_handlers
|
565 |
|
|
hal_interrupt_handlers:
|
566 |
|
|
.rept 25
|
567 |
|
|
.long hal_default_isr
|
568 |
|
|
.endr
|
569 |
|
|
|
570 |
|
|
.globl hal_interrupt_data
|
571 |
|
|
hal_interrupt_data:
|
572 |
|
|
.rept 25
|
573 |
|
|
.long 0
|
574 |
|
|
.endr
|
575 |
|
|
|
576 |
|
|
.globl hal_interrupt_objects
|
577 |
|
|
hal_interrupt_objects:
|
578 |
|
|
.rept 25
|
579 |
|
|
.long 0
|
580 |
|
|
.endr
|
581 |
|
|
|
582 |
|
|
|
583 |
|
|
##-----------------------------------------------------------------------------
|
584 |
|
|
## end of platform.S
|