1 |
27 |
unneback |
##=============================================================================
|
2 |
|
|
##
|
3 |
|
|
## ts1000.S
|
4 |
|
|
##
|
5 |
|
|
## TS1000 board hardware setup
|
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 |
|
|
## Copyright (C) 2002 Gary Thomas
|
13 |
|
|
##
|
14 |
|
|
## eCos is free software; you can redistribute it and/or modify it under
|
15 |
|
|
## the terms of the GNU General Public License as published by the Free
|
16 |
|
|
## Software Foundation; either version 2 or (at your option) any later version.
|
17 |
|
|
##
|
18 |
|
|
## eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
19 |
|
|
## WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
20 |
|
|
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
21 |
|
|
## for more details.
|
22 |
|
|
##
|
23 |
|
|
## You should have received a copy of the GNU General Public License along
|
24 |
|
|
## with eCos; if not, write to the Free Software Foundation, Inc.,
|
25 |
|
|
## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
26 |
|
|
##
|
27 |
|
|
## As a special exception, if other files instantiate templates or use macros
|
28 |
|
|
## or inline functions from this file, or you compile this file and link it
|
29 |
|
|
## with other works to produce a work based on this file, this file does not
|
30 |
|
|
## by itself cause the resulting work to be covered by the GNU General Public
|
31 |
|
|
## License. However the source code for this file must still be made available
|
32 |
|
|
## in accordance with section (3) of the GNU General Public License.
|
33 |
|
|
##
|
34 |
|
|
## This exception does not invalidate any other reasons why a work based on
|
35 |
|
|
## this file might be covered by the GNU General Public License.
|
36 |
|
|
##
|
37 |
|
|
## Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
38 |
|
|
## at http://sources.redhat.com/ecos/ecos-license/
|
39 |
|
|
## -------------------------------------------
|
40 |
|
|
#####ECOSGPLCOPYRIGHTEND####
|
41 |
|
|
##=============================================================================
|
42 |
|
|
#######DESCRIPTIONBEGIN####
|
43 |
|
|
##
|
44 |
|
|
## Author(s): hmt
|
45 |
|
|
## Contributors:hmt, gthomas
|
46 |
|
|
## Date: 1999-06-08
|
47 |
|
|
## Purpose: TS1000 board hardware setup
|
48 |
|
|
## Description: This file contains any code needed to initialize the
|
49 |
|
|
## hardware on an Allied Telesyn TS1000 (PPC855T) board.
|
50 |
|
|
##
|
51 |
|
|
######DESCRIPTIONEND####
|
52 |
|
|
##
|
53 |
|
|
##=============================================================================
|
54 |
|
|
|
55 |
|
|
#include
|
56 |
|
|
|
57 |
|
|
#include /* register symbols et al */
|
58 |
|
|
#include /* on-chip resource layout, special */
|
59 |
|
|
/* registers, IMM layout... */
|
60 |
|
|
#include /* more of the same */
|
61 |
|
|
|
62 |
|
|
#------------------------------------------------------------------------------
|
63 |
|
|
# this is controlled with one define for tidiness:
|
64 |
|
|
# (and it is undefined by default)
|
65 |
|
|
|
66 |
|
|
//#define CYGPRI_RAM_START_PROGRAMS_UPMS
|
67 |
|
|
|
68 |
|
|
#if defined(CYG_HAL_STARTUP_ROM) \
|
69 |
|
|
|| defined(CYG_HAL_STARTUP_ROMRAM) \
|
70 |
|
|
|| defined(CYGPRI_RAM_START_PROGRAMS_UPMS)
|
71 |
|
|
# define CYGPRI_DO_PROGRAM_UPMS
|
72 |
|
|
#endif
|
73 |
|
|
|
74 |
|
|
/* The intention is that we only set up the UPMs in ROM start, be it actual
|
75 |
|
|
* ROM application start or Stub ROMs that we built from the same sources.
|
76 |
|
|
*
|
77 |
|
|
* The alternative approach - in which we have reliability doubts - is to
|
78 |
|
|
* program the UPMs with *old* timing data in StubROM start, then
|
79 |
|
|
* *reprogram* them with *new* timing data in RAM start - and of course
|
80 |
|
|
* program with *new* timing data in plain ROM application start.
|
81 |
|
|
* (Re-programming from new to new timing data fails - hence the suspicion
|
82 |
|
|
* of reprogramming _at_all_, hence this private configuration)
|
83 |
|
|
*
|
84 |
|
|
* With CYGPRI_RAM_START_PROGRAMS_UPMS left undefined, the former behaviour
|
85 |
|
|
* - programming the UPMs exactly once - is obtained. Define it to get the
|
86 |
|
|
* latter, untrusted behaviour.
|
87 |
|
|
*/
|
88 |
|
|
|
89 |
|
|
#------------------------------------------------------------------------------
|
90 |
|
|
|
91 |
|
|
//
|
92 |
|
|
// Macros to build BR/OR registers
|
93 |
|
|
//
|
94 |
|
|
#define _BR(_reg,_BA,_PS,_MS,_V) \
|
95 |
|
|
.long CYGARC_REG_IMM_BASE+_reg, ((_BA&0xFFFF8000)|(_PS<<10)|(_MS<<6)|_V)
|
96 |
|
|
// Port size
|
97 |
|
|
#define _PS_32 0x00 // 32 bits
|
98 |
|
|
#define _PS_8 0x01 // 8 bits
|
99 |
|
|
#define _PS_16 0x02 // 16 bits
|
100 |
|
|
// Machine select
|
101 |
|
|
#define _MS_GPCM 0x00
|
102 |
|
|
#define _MS_UPMA 0x02
|
103 |
|
|
#define _MS_UPMB 0x03
|
104 |
|
|
|
105 |
|
|
#define _OR_GPCM(_reg,_AM,_CSNT,_ACS,_BIH,_SCY,_SETA,_TRLX,_EHTR) \
|
106 |
|
|
.long CYGARC_REG_IMM_BASE+_reg, ((_AM&0xFFFF8000)|(_CSNT<<11)|(_ACS<<9)|(_BIH<<8)|(_SCY<<4)|(_SETA<<3)|(_TRLX<<2)|(_EHTR<<1))
|
107 |
|
|
|
108 |
|
|
// GPCM - Chip select negation time
|
109 |
|
|
#define _CSNT_0 0
|
110 |
|
|
#define _CSNT_1 1
|
111 |
|
|
|
112 |
|
|
// GPCM - Address setup time
|
113 |
|
|
#define _ACS_0 0x00 // !CS asserted with address lines
|
114 |
|
|
#define _ACS_4 0x02 // !CS asserted 1/4 clock after address lines
|
115 |
|
|
#define _ACS_2 0x03 // !CS asserted 1/2 clock after address lines
|
116 |
|
|
|
117 |
|
|
// Burst Inhibit
|
118 |
|
|
#define _BIH_0 0 // Bursting supported
|
119 |
|
|
#define _BIH_1 1 // Bursting disabled
|
120 |
|
|
|
121 |
|
|
// GPCM - Address setup times
|
122 |
|
|
#define _SCY_0 0x0 // No additional wait states
|
123 |
|
|
#define _SCY_1 0x1 // 1 additional wait states
|
124 |
|
|
#define _SCY_2 0x2 // 2 additional wait states
|
125 |
|
|
#define _SCY_3 0x3 // 3 additional wait states
|
126 |
|
|
#define _SCY_4 0x4 // 4 additional wait states
|
127 |
|
|
#define _SCY_5 0x5 // 5 additional wait states
|
128 |
|
|
#define _SCY_6 0x6 // 6 additional wait states
|
129 |
|
|
#define _SCY_7 0x7 // 7 additional wait states
|
130 |
|
|
#define _SCY_8 0x8 // 8 additional wait states
|
131 |
|
|
#define _SCY_9 0x9 // 9 additional wait states
|
132 |
|
|
#define _SCY_10 0xA // 10 additional wait states
|
133 |
|
|
#define _SCY_11 0xB // 11 additional wait states
|
134 |
|
|
#define _SCY_12 0xC // 12 additional wait states
|
135 |
|
|
#define _SCY_13 0xD // 13 additional wait states
|
136 |
|
|
#define _SCY_14 0xE // 14 additional wait states
|
137 |
|
|
#define _SCY_15 0xF // 15 additional wait states
|
138 |
|
|
|
139 |
|
|
// GPCM - external transfer acknowledge
|
140 |
|
|
#define _SETA_0 0 // No external acknowledge
|
141 |
|
|
#define _SETA_1 1 // External acknowledge
|
142 |
|
|
|
143 |
|
|
// GPCM - relaxed timing
|
144 |
|
|
#define _TRLX_0 0 // Strict timing
|
145 |
|
|
#define _TRLX_1 1 // Relaxed timing (wait states doubled)
|
146 |
|
|
|
147 |
|
|
// GPCM - external hold time
|
148 |
|
|
#define _EHTR_0 0 // Strict timing
|
149 |
|
|
#define _EHTR_1 1 // One wait state needed when switching banks
|
150 |
|
|
|
151 |
|
|
#define _OR_UPM(_reg,_AM,_SAM,_G5LA,_G5LS,_BIH)\
|
152 |
|
|
.long CYGARC_REG_IMM_BASE+_reg,((_AM&0xFFFF8000)|(_SAM<<11)|(_G5LA<<10)|(_G5LS<<9)|(_BIH<<8))
|
153 |
|
|
|
154 |
|
|
#define _SAM_0 0 // Address lines are not multiplexed
|
155 |
|
|
#define _SAM_1 1 // Address lines are multiplexed by controller
|
156 |
|
|
|
157 |
|
|
#define _G5LA_0 0 // Use GPLB5 for GPL5
|
158 |
|
|
#define _G5LA_1 1 // Use GPLA5 for GPL5
|
159 |
|
|
|
160 |
|
|
#define _G5LS_0 0 // !GPL5 asserted on low edge
|
161 |
|
|
#define _G5LS_1 1 // !GPL5 asserted on high edge
|
162 |
|
|
|
163 |
|
|
#------------------------------------------------------------------------------
|
164 |
|
|
|
165 |
|
|
//
|
166 |
|
|
// PTA field is (System Clock in MHz * Refresh rate in us) / Prescale
|
167 |
|
|
// e.g. ((14*3.6864)*62.5)/32 => 100.8 => 101
|
168 |
|
|
//
|
169 |
|
|
// Since the processor is clocked using the EXTCLK signal, the PLL
|
170 |
|
|
// should always run 1-1
|
171 |
|
|
//
|
172 |
|
|
#define PLPRCR_PTX 0x000
|
173 |
|
|
#define MAMR_PTA 98
|
174 |
|
|
|
175 |
|
|
//
|
176 |
|
|
// Special MPC8xx cache control
|
177 |
|
|
//
|
178 |
|
|
#define CACHE_UNLOCKALL 0x0a00
|
179 |
|
|
#define CACHE_DISABLE 0x0400
|
180 |
|
|
#define CACHE_INVALIDATEALL 0x0c00
|
181 |
|
|
#define CACHE_ENABLE 0x0200
|
182 |
|
|
#define CACHE_ENABLEBIT 0x8000
|
183 |
|
|
|
184 |
|
|
#define CACHE_FORCEWRITETHROUGH 0x0100
|
185 |
|
|
#define CACHE_NOWRITETHROUGH 0x0300
|
186 |
|
|
#define CACHE_CLEAR_LE_SWAP 0x0700
|
187 |
|
|
|
188 |
|
|
|
189 |
|
|
#------------------------------------------------------------------------------
|
190 |
|
|
|
191 |
|
|
// LED macro uses r23, r25: r4 assumed to point to IMMR
|
192 |
|
|
#define LED( x ) \
|
193 |
|
|
lhz r25,PADAT(r4) ; \
|
194 |
|
|
andi. r25,r25,(~0x3C&0xFFFF) ; \
|
195 |
|
|
ori r25,r25,(x<<2) ; \
|
196 |
|
|
sth r25,PADAT(r4) ; \
|
197 |
|
|
|
198 |
|
|
#------------------------------------------------------------------------------
|
199 |
|
|
|
200 |
|
|
FUNC_START( hal_hardware_init )
|
201 |
|
|
|
202 |
|
|
mflr r30 // Save original return address
|
203 |
|
|
|
204 |
|
|
# Throughout this routine, r4 is the base address of the control
|
205 |
|
|
# registers. r3 and r5 are scratch in general.
|
206 |
|
|
|
207 |
|
|
lwi r4,CYGARC_REG_IMM_BASE # base address of control registers
|
208 |
|
|
mtspr CYGARC_REG_IMMR,r4
|
209 |
|
|
|
210 |
|
|
//
|
211 |
|
|
// Set up GPIO port A - used to drive LEDs.
|
212 |
|
|
//
|
213 |
|
|
lhz r3,PAODR(r4) // paodr &= ~0x803C
|
214 |
|
|
andi. r3,r3,(~0x803C&0xFFFF)
|
215 |
|
|
sth r3,PAODR(r4)
|
216 |
|
|
lhz r3,PADIR(r4) // padir |= 0x803C -- all outputs
|
217 |
|
|
ori r3,r3,0x803C
|
218 |
|
|
sth r3,PADIR(r4)
|
219 |
|
|
lhz r3,PAPAR(r4) // papar &= ~0x803C
|
220 |
|
|
andi. r3,r3,(~0x803C&0xFFFF)
|
221 |
|
|
sth r3,PAPAR(r4)
|
222 |
|
|
#ifdef CYG_HAL_STARTUP_RAM
|
223 |
|
|
lhz r3,PADAT(r4) // Turn off all LEDs, preserve PHY state
|
224 |
|
|
ori r3,r3,0x003C
|
225 |
|
|
#else
|
226 |
|
|
lwi r3,0x803C // Turn off all LEDS, reset PHY
|
227 |
|
|
#endif
|
228 |
|
|
sth r3,PADAT(r4)
|
229 |
|
|
|
230 |
|
|
LED( 0 ) # turn all LEDs off
|
231 |
|
|
|
232 |
|
|
# DATA CACHE
|
233 |
|
|
mfspr r3,CYGARC_REG_DC_CST /* clear error bits */
|
234 |
|
|
lis r3,CACHE_UNLOCKALL
|
235 |
|
|
sync
|
236 |
|
|
mtspr CYGARC_REG_DC_CST,r3 /* unlock all lines */
|
237 |
|
|
|
238 |
|
|
lis r3,CACHE_INVALIDATEALL
|
239 |
|
|
sync
|
240 |
|
|
mtspr CYGARC_REG_DC_CST,r3 /* invalidate all lines */
|
241 |
|
|
|
242 |
|
|
lis r3,CACHE_DISABLE
|
243 |
|
|
sync
|
244 |
|
|
mtspr CYGARC_REG_DC_CST,r3 /* disable */
|
245 |
|
|
|
246 |
|
|
lis r3,CACHE_FORCEWRITETHROUGH
|
247 |
|
|
sync
|
248 |
|
|
mtspr CYGARC_REG_DC_CST,r3 /* set force-writethrough mode */
|
249 |
|
|
|
250 |
|
|
lis r3,CACHE_CLEAR_LE_SWAP
|
251 |
|
|
sync
|
252 |
|
|
mtspr CYGARC_REG_DC_CST,r3 /* clear little-endian swap mode */
|
253 |
|
|
# INSTRUCTION CACHE (no writeback modes)
|
254 |
|
|
mfspr r3,CYGARC_REG_IC_CST /* clear error bits */
|
255 |
|
|
lis r3,CACHE_UNLOCKALL
|
256 |
|
|
mtspr CYGARC_REG_IC_CST,r3 /* unlock all lines */
|
257 |
|
|
isync
|
258 |
|
|
lis r3,CACHE_INVALIDATEALL
|
259 |
|
|
mtspr CYGARC_REG_IC_CST,r3 /* invalidate all lines */
|
260 |
|
|
isync
|
261 |
|
|
lis r3,CACHE_DISABLE
|
262 |
|
|
mtspr CYGARC_REG_IC_CST,r3 /* disable */
|
263 |
|
|
isync
|
264 |
|
|
|
265 |
|
|
sync
|
266 |
|
|
|
267 |
|
|
LED( 0x01 )
|
268 |
|
|
|
269 |
|
|
#ifdef CYG_HAL_STARTUP_ROMRAM
|
270 |
|
|
// Need to set the PC into the FLASH (ROM) before the address map changes
|
271 |
|
|
lwi r3,10f
|
272 |
|
|
lwi r5,0xFE000000
|
273 |
|
|
or r3,r3,r5
|
274 |
|
|
mtctr r3
|
275 |
|
|
bctr
|
276 |
|
|
10:
|
277 |
|
|
#endif
|
278 |
|
|
|
279 |
|
|
/*
|
280 |
|
|
* SIU Initialization.
|
281 |
|
|
*/
|
282 |
|
|
lwi r3,0x00610400
|
283 |
|
|
stw r3,SIUMCR(r4)
|
284 |
|
|
|
285 |
|
|
/*
|
286 |
|
|
* Enable bus monitor. Disable Watchdog timer.
|
287 |
|
|
*/
|
288 |
|
|
lwi r3,0xffffff88
|
289 |
|
|
stw r3,SYPCR(r4)
|
290 |
|
|
|
291 |
|
|
/*
|
292 |
|
|
* Clear REFA & REFB. Enable but freeze timebase.
|
293 |
|
|
*/
|
294 |
|
|
lwi r3,0x0000 // FIXME: should this be 0x0000 or 0x00C2
|
295 |
|
|
sth r3,TBSCR(r4)
|
296 |
|
|
|
297 |
|
|
/*
|
298 |
|
|
* Unlock some RTC registers (see section 5.11.2)
|
299 |
|
|
*/
|
300 |
|
|
lwi r3,0x55ccaa33
|
301 |
|
|
stw r3,RTCSCK(r4)
|
302 |
|
|
stw r3,RTCK(r4)
|
303 |
|
|
stw r3,RTSECK(r4)
|
304 |
|
|
stw r3,RTCALK(r4)
|
305 |
|
|
|
306 |
|
|
/*
|
307 |
|
|
* Clear SERC & ALR. RTC runs on freeze. Enable RTC.
|
308 |
|
|
*/
|
309 |
|
|
li r3,0x0000 // FIXME: should this be 0x0000 or 0x00C3
|
310 |
|
|
sth r3,RTCSC(r4)
|
311 |
|
|
|
312 |
|
|
/*
|
313 |
|
|
* Clear periodic timer interrupt status.
|
314 |
|
|
* Enable periodic timer and stop it on freeze.
|
315 |
|
|
*/
|
316 |
|
|
li r3,0x0001 // FIXME: should this be 0x0001 or 0x0083
|
317 |
|
|
sth r3,PISCR(r4)
|
318 |
|
|
|
319 |
|
|
LED( 0x02 )
|
320 |
|
|
|
321 |
|
|
/*
|
322 |
|
|
* Perform UPM programming by writing to its 64 RAM locations.
|
323 |
|
|
* Note that UPM initialization must be done before the Bank Register
|
324 |
|
|
* initialization. Otherwise, system may hang when writing to Bank
|
325 |
|
|
* Registers in certain cases.
|
326 |
|
|
*/
|
327 |
|
|
#ifdef CYGPRI_DO_PROGRAM_UPMS
|
328 |
|
|
lwi r5,__upmtbl_start
|
329 |
|
|
lwi r6,__upmtbl_end
|
330 |
|
|
sub r7,r6,r5 /* size of table */
|
331 |
|
|
srawi r7,r7,2 /* in words */
|
332 |
|
|
|
333 |
|
|
lwi r6,0x00800000 /* Command - OP=Write, UPMB, MAD=0 */
|
334 |
|
|
or r7,r7,r6
|
335 |
|
|
1:
|
336 |
|
|
lwz r3,0(r5) /* get data from table */
|
337 |
|
|
stw r3,MDR(r4) /* store the data to MD register */
|
338 |
|
|
stw r6,MCR(r4) /* issue command to MCR register */
|
339 |
|
|
addi r5,r5,4 /* next entry in the table */
|
340 |
|
|
addi r6,r6,1 /* next MAD address */
|
341 |
|
|
cmpw r6,r7 /* done yet ? */
|
342 |
|
|
blt 1b
|
343 |
|
|
#endif // CYGPRI_DO_PROGRAM_UPMS
|
344 |
|
|
|
345 |
|
|
LED( 0x03 )
|
346 |
|
|
|
347 |
|
|
/*
|
348 |
|
|
* Set refresh timer prescaler to divide by 8.
|
349 |
|
|
*/
|
350 |
|
|
li r3,PTP_DIV32
|
351 |
|
|
sth r3,MPTPR(r4)
|
352 |
|
|
|
353 |
|
|
/*
|
354 |
|
|
* See Table 15-16 MPC860 User's Manual.
|
355 |
|
|
*
|
356 |
|
|
// Set the value of Machine A Mode Register (MAMR) to $5E802114.
|
357 |
|
|
// Field PTA (bits 0-7) = 94
|
358 |
|
|
// Field PTAE (bit 8) = 1
|
359 |
|
|
// Field AMA (bits 9-11) = 0
|
360 |
|
|
// Field Reserved (bit 12) = 0
|
361 |
|
|
// Field DSA (bits 13-14) = 0
|
362 |
|
|
// Field Reserved (bit 15) = 0
|
363 |
|
|
// Field G0CLA (bits 16-18) = 1
|
364 |
|
|
// Field GPL_A4DIS (bit 19) = 0
|
365 |
|
|
// Field RLFA (bits 20-23) = 1
|
366 |
|
|
// Field WLFA (bits 24-27) = 1
|
367 |
|
|
// Field TLFA (bits 28-31) = 4
|
368 |
|
|
*/
|
369 |
|
|
lwi r3,0x00802114|(MAMR_PTA<<24)
|
370 |
|
|
stw r3,MAMR(r4)
|
371 |
|
|
stw r3,MBMR(r4)
|
372 |
|
|
|
373 |
|
|
/*
|
374 |
|
|
* Base Register initialization.
|
375 |
|
|
*/
|
376 |
|
|
|
377 |
|
|
//
|
378 |
|
|
// Memory map (device addressing) layout
|
379 |
|
|
//
|
380 |
|
|
bl 10f
|
381 |
|
|
mc_regs:
|
382 |
|
|
// CS0 - FLASH - 0xFE000000..0xFE7FFFFF, 9 wait states, no bursting
|
383 |
|
|
_OR_GPCM(OR0, 0xFF800000, _CSNT_1, _ACS_2, \
|
384 |
|
|
_BIH_1, _SCY_9, _SETA_0, _TRLX_1, _EHTR_1)
|
385 |
|
|
_BR(BR0, 0xFE000000, _PS_16, _MS_GPCM, 1)
|
386 |
|
|
|
387 |
|
|
// CS1 - DRAM - 0x00000000..0x00FFFFFF,
|
388 |
|
|
_BR(BR1, 0x00000000, _PS_32, _MS_UPMB, 1)
|
389 |
|
|
_OR_UPM(OR1, 0xFF000000, _SAM_1, _G5LA_0, _G5LS_0, _BIH_0)
|
390 |
|
|
|
391 |
|
|
// CS2 - FPGA Loading - 0x80020000..0x80027FFF, 7 wait states, no bursting
|
392 |
|
|
_BR(BR2, 0x80020000, _PS_32, _MS_GPCM, 1)
|
393 |
|
|
_OR_GPCM(OR2, 0xFFFF8000, _CSNT_1, _ACS_2, \
|
394 |
|
|
_BIH_1, _SCY_7, _SETA_0, _TRLX_1, _EHTR_1)
|
395 |
|
|
|
396 |
|
|
// CS3 - FPGA - 0x80030000..0x80037FFF, 7 wait states, no bursting
|
397 |
|
|
_OR_GPCM(OR3, 0xFFFF8000, _CSNT_1, _ACS_2, \
|
398 |
|
|
_BIH_1, _SCY_7, _SETA_0, _TRLX_1, _EHTR_1)
|
399 |
|
|
_BR(BR3, 0x80030000, _PS_32, _MS_GPCM, 1)
|
400 |
|
|
|
401 |
|
|
// CS4 - DS3 - 0x80040000..0x80047FFF, 7 wait states, no bursting
|
402 |
|
|
_OR_GPCM(OR4, 0xFFFF8000, _CSNT_1, _ACS_2, \
|
403 |
|
|
_BIH_1, _SCY_7, _SETA_0, _TRLX_1, _EHTR_1)
|
404 |
|
|
_BR(BR4, 0x80040000, _PS_32, _MS_GPCM, 1)
|
405 |
|
|
|
406 |
|
|
// CS5 - DS1 - 0x80050000..0x80057FFF, 7 wait states, no bursting
|
407 |
|
|
_OR_GPCM(OR5, 0xFFFF8000, _CSNT_1, _ACS_2, \
|
408 |
|
|
_BIH_1, _SCY_7, _SETA_0, _TRLX_1, _EHTR_1)
|
409 |
|
|
_BR(BR5, 0x80050000, _PS_32, _MS_GPCM, 1)
|
410 |
|
|
|
411 |
|
|
.long 0 // End of table
|
412 |
|
|
|
413 |
|
|
//
|
414 |
|
|
// Program memory controller registers (using table above)
|
415 |
|
|
//
|
416 |
|
|
10: mflr r3 // Points to table
|
417 |
|
|
subi r3,r3,4
|
418 |
|
|
20: lwzu r5,4(r3) // Next address
|
419 |
|
|
cmpi 0,r5,0
|
420 |
|
|
beq 30f // done?
|
421 |
|
|
lwzu r6,4(r3) // value
|
422 |
|
|
lwzu r7,4(r3) // second part of address/value pair
|
423 |
|
|
lwzu r8,4(r3)
|
424 |
|
|
stw r6,0(r5) // store pair in order
|
425 |
|
|
stw r8,0(r7)
|
426 |
|
|
b 20b
|
427 |
|
|
30:
|
428 |
|
|
|
429 |
|
|
/*
|
430 |
|
|
* SYSTEM CLOCK CONTROL REGISTER
|
431 |
|
|
// Set the value of System Clock and Reset Control Register (SCCR) to $00400000.
|
432 |
|
|
// Field Reserved (bit 0) = 0
|
433 |
|
|
// Field COM (bits 1-2) = 0
|
434 |
|
|
// Field Reserved (bits 3-5) = 0
|
435 |
|
|
// Field TBS (bit 6) = 0
|
436 |
|
|
// Field RTDIV (bit 7) = 0
|
437 |
|
|
// Field RTSEL (bit 8) = 0
|
438 |
|
|
// Field CRQEN (bit 9) = 1
|
439 |
|
|
// Field PRQEN (bit 10) = 0
|
440 |
|
|
// Field Reserved (bits 11-12) = 0
|
441 |
|
|
// Field EBDF (bits 13-14) = 0
|
442 |
|
|
// Field Reserved (bits 15-16) = 0
|
443 |
|
|
// Field DFSYNC (bits 17-18) = 0
|
444 |
|
|
// Field DFBRG (bits 19-20) = 0
|
445 |
|
|
// Field DFNL (bits 21-23) = 0
|
446 |
|
|
// Field DFNH (bits 24-26) = 0
|
447 |
|
|
// Field Reserved (bits 27-31) = 0
|
448 |
|
|
*/
|
449 |
|
|
lwi r3,0x00400000
|
450 |
|
|
stw r3,SCCR(r4)
|
451 |
|
|
|
452 |
|
|
LED( 0x04 )
|
453 |
|
|
|
454 |
|
|
/*
|
455 |
|
|
* PLL, LOW POWER, AND RESET CONTROL REGISTER
|
456 |
|
|
// Set the value of PLL, Low Power and Reset Control Register (PLPRCR) to $00C04000.
|
457 |
|
|
// Field MF (bits 0-11) = 12
|
458 |
|
|
// Field Reserved (bits 12-15) = 0
|
459 |
|
|
// Field SPLSS (bit 16) = 0
|
460 |
|
|
// Field TEXPS (bit 17) = 1
|
461 |
|
|
// Field Reserved (bit 18) = 0
|
462 |
|
|
// Field TMIST (bit 19) = 0
|
463 |
|
|
// Field Reserved (bit 20) = 0
|
464 |
|
|
// Field CSRC (bit 21) = 0
|
465 |
|
|
// Field LPM (bits 22-23) = 0
|
466 |
|
|
// Field CSR (bit 24) = 0
|
467 |
|
|
// Field LOLRE (bit 25) = 0
|
468 |
|
|
// Field FIOPD (bit 26) = 0
|
469 |
|
|
// Field Reserved (bits 27-31) = 0
|
470 |
|
|
*/
|
471 |
|
|
lwi r3,0x04000|(PLPRCR_PTX<<20)
|
472 |
|
|
stw r3,PLPRCR(r4)
|
473 |
|
|
|
474 |
|
|
lwi r3,0x40000
|
475 |
|
|
mtctr r3
|
476 |
|
|
10: nop
|
477 |
|
|
bdnz 10b
|
478 |
|
|
|
479 |
|
|
/* SDRAM Initialization Sequence, UPMB, CS1 */
|
480 |
|
|
li r3,0
|
481 |
|
|
stw r3,MAR(r4)
|
482 |
|
|
|
483 |
|
|
lwi r3,0x80802115; /* run precharge from loc 21 (0x15) */
|
484 |
|
|
stw r3,MCR(r4)
|
485 |
|
|
|
486 |
|
|
lwi r3,0x80802830; /* run refresh 8 times */
|
487 |
|
|
stw r3,MCR(r4)
|
488 |
|
|
|
489 |
|
|
lwi r3,0x22<<2; // Mode register setting
|
490 |
|
|
stw r3,MAR(r4)
|
491 |
|
|
|
492 |
|
|
lwi r3,0x80802116; /* run MRS pattern from loc 22 (0x16) */
|
493 |
|
|
stw r3,MCR(r4)
|
494 |
|
|
|
495 |
|
|
# mask interrupt sources in the SIU
|
496 |
|
|
lis r2,0
|
497 |
|
|
lwi r3,CYGARC_REG_IMM_SIMASK
|
498 |
|
|
stw r2,0(r3)
|
499 |
|
|
|
500 |
|
|
# set the decrementer to maxint
|
501 |
|
|
lwi r2,0
|
502 |
|
|
not r2,r2
|
503 |
|
|
mtdec r2
|
504 |
|
|
|
505 |
|
|
# and enable the timebase and decrementer to make sure
|
506 |
|
|
li r2,1 # TBEnable and not TBFreeze
|
507 |
|
|
lwi r3,CYGARC_REG_IMM_TBSCR
|
508 |
|
|
sth r2,0(r3)
|
509 |
|
|
|
510 |
|
|
LED( 0x05 )
|
511 |
|
|
|
512 |
|
|
#ifdef CYG_HAL_STARTUP_ROM
|
513 |
|
|
# move return address to where the ROM is
|
514 |
|
|
mflr r3
|
515 |
|
|
lwi r4,0x00FFFFFF // CAUTION!! Assumes only low 16M for ROM
|
516 |
|
|
and r3,r3,r4
|
517 |
|
|
oris r3,r3,CYGMEM_REGION_rom>>16
|
518 |
|
|
mtlr r3
|
519 |
|
|
#endif
|
520 |
|
|
|
521 |
|
|
#ifdef CYG_HAL_STARTUP_ROMRAM
|
522 |
|
|
// Copy image from ROM to RAM
|
523 |
|
|
LED(0x06)
|
524 |
|
|
lwi r4,0xFE000000
|
525 |
|
|
lwi r5,0x01FFFFFF // ROM/FLASH base
|
526 |
|
|
and r3,r30,r5 // segment relative
|
527 |
|
|
lwi r30,_hal_hardware_init_done
|
528 |
|
|
sub r6,r3,r30 // Absolute address
|
529 |
|
|
add r6,r6,r4 // FLASH address
|
530 |
|
|
lwi r7,0 // where to copy to
|
531 |
|
|
lwi r8,__ram_data_end
|
532 |
|
|
10: lwz r5,0(r6)
|
533 |
|
|
stw r5,0(r7)
|
534 |
|
|
addi r6,r6,4
|
535 |
|
|
addi r7,r7,4
|
536 |
|
|
cmplw r7,r8
|
537 |
|
|
bne 10b
|
538 |
|
|
#endif
|
539 |
|
|
|
540 |
|
|
LED(0x0F)
|
541 |
|
|
|
542 |
|
|
mtlr r30 // Restore original link address
|
543 |
|
|
blr
|
544 |
|
|
FUNC_END( hal_hardware_init )
|
545 |
|
|
|
546 |
|
|
|
547 |
|
|
#ifdef CYGPRI_DO_PROGRAM_UPMS
|
548 |
|
|
# -------------------------------------------------------------------------
|
549 |
|
|
# this table initializes the User Programmable Machine (UPM) nastiness
|
550 |
|
|
# in the QUICC to control DRAM timing.
|
551 |
|
|
|
552 |
|
|
__upmtbl_start:
|
553 |
|
|
|
554 |
|
|
// UPM 0x00: single read
|
555 |
|
|
.long 0x0f0dfc04, 0x0ffffc04, 0x00bf7c04, 0x0ff5fc00
|
556 |
|
|
.long 0x1ffffc05, 0xfffffc04, 0xfffffc04, 0xfffffc04
|
557 |
|
|
// UPM 0x08: burst read
|
558 |
|
|
.long 0x0f0dfc04, 0x0ffffc04, 0x00bf7c04, 0x00fffc00
|
559 |
|
|
.long 0x00fffc00, 0x00fffc00, 0x0ff5fc00, 0x1ffffc05
|
560 |
|
|
.long 0xfffffc04, 0xfffffc04, 0xfffffc04, 0xfffffc04
|
561 |
|
|
.long 0xfffffc04
|
562 |
|
|
// UPM 0x15: initial precharge cycles
|
563 |
|
|
.long 0x1ff5fc35
|
564 |
|
|
// UPM 0x16: program mode register
|
565 |
|
|
.long 0xefcabc34, 0x1f357c35 // 0x1fb57c35 or 0xfffffc04
|
566 |
|
|
// UPM 0x18: single write
|
567 |
|
|
.long 0x0f0dfc04, 0x0ffffc00, 0x00b77c04, 0x0ffffc04
|
568 |
|
|
.long 0x0ff5fc04, 0x1ffffc05, 0xfffffc04, 0xfffffc04
|
569 |
|
|
// UPM 0x20: burst write
|
570 |
|
|
.long 0x0f0dfc04, 0x0ffffc00, 0x00b77c00, 0x00fffc00
|
571 |
|
|
.long 0x00fffc00, 0x00fffc04, 0x0ffffc04, 0x0ff5fc04
|
572 |
|
|
.long 0x1ffffc05, 0xfffffc04, 0xfffffc04, 0xfffffc04
|
573 |
|
|
.long 0xfffffc04, 0xfffffc04, 0xfffffc04, 0xfffffc04
|
574 |
|
|
// UPM 0x30: refresh
|
575 |
|
|
.long 0x0ff5fc00, 0x0ffffc00, 0x0ffd7c80, 0x0ffffc00
|
576 |
|
|
.long 0x0ffffc00, 0x0ffffc80, 0x3ffffc07, 0xfffffc04
|
577 |
|
|
.long 0xfffffc04, 0xfffffc04, 0xfffffc04, 0xfffffc04
|
578 |
|
|
// UPM 0x3C: exception
|
579 |
|
|
.long 0xfffffc27, 0xfffffc04, 0xfffffc04, 0xfffffc04
|
580 |
|
|
|
581 |
|
|
__upmtbl_end:
|
582 |
|
|
#endif // CYGPRI_DO_PROGRAM_UPMS
|
583 |
|
|
|
584 |
|
|
FUNC_START(hal_ts1000_set_led)
|
585 |
|
|
lwi r4,CYGARC_REG_IMM_BASE # base address of control registers
|
586 |
|
|
lhz r5,PADAT(r4)
|
587 |
|
|
andi. r5,r5,(~0x3C&0xFFFF)
|
588 |
|
|
andi. r3,r3,0x0F
|
589 |
|
|
slwi r3,r3,2
|
590 |
|
|
or r5,r5,r3
|
591 |
|
|
sth r5,PADAT(r4)
|
592 |
|
|
lwi r5,_hold_led
|
593 |
|
|
stw r3,0(r5)
|
594 |
|
|
blr
|
595 |
|
|
FUNC_END(hal_ts1000_set_led)
|
596 |
|
|
.data
|
597 |
|
|
_hold_led:
|
598 |
|
|
.long 0
|
599 |
|
|
.text
|
600 |
|
|
|
601 |
|
|
FUNC_START(hal_ts1000_get_led)
|
602 |
|
|
lwi r5,_hold_led
|
603 |
|
|
lwz r3,0(r5)
|
604 |
|
|
blr
|
605 |
|
|
FUNC_END(hal_ts1000_get_led)
|
606 |
|
|
|
607 |
|
|
|
608 |
|
|
#------------------------------------------------------------------------------
|
609 |
|
|
# end of ts1000.S
|