1 |
27 |
unneback |
#ifndef CYGONCE_HAL_PLATFORM_SETUP_H
|
2 |
|
|
#define CYGONCE_HAL_PLATFORM_SETUP_H
|
3 |
|
|
|
4 |
|
|
/*=============================================================================
|
5 |
|
|
//
|
6 |
|
|
// hal_platform_setup.h
|
7 |
|
|
//
|
8 |
|
|
// Platform specific support for HAL (assembly code)
|
9 |
|
|
//
|
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.
|
15 |
|
|
//
|
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.
|
19 |
|
|
//
|
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
|
23 |
|
|
// for more details.
|
24 |
|
|
//
|
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.
|
28 |
|
|
//
|
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.
|
35 |
|
|
//
|
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.
|
38 |
|
|
//
|
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####
|
45 |
|
|
//
|
46 |
|
|
// Author(s): gthomas
|
47 |
|
|
// Contributors: gthomas, richard.panton@3glab.com
|
48 |
|
|
// Date: 2001-02-24
|
49 |
|
|
// Purpose: Intel SA1110/iPAQ platform specific support routines
|
50 |
|
|
// Description:
|
51 |
|
|
// Usage: #include <cyg/hal/hal_platform_setup.h>
|
52 |
|
|
// Only used by "vectors.S"
|
53 |
|
|
//
|
54 |
|
|
//####DESCRIPTIONEND####
|
55 |
|
|
//
|
56 |
|
|
//===========================================================================*/
|
57 |
|
|
|
58 |
|
|
#include <pkgconf/system.h> // System-wide configuration info
|
59 |
|
|
#include CYGBLD_HAL_VARIANT_H // Variant (SA11x0) specific configuration
|
60 |
|
|
#include CYGBLD_HAL_PLATFORM_H // Platform specific configuration
|
61 |
|
|
#include <cyg/hal/hal_sa11x0.h> // Variant specific hardware definitions
|
62 |
|
|
#include <cyg/hal/hal_mmu.h> // MMU definitions
|
63 |
|
|
#include <cyg/hal/ipaq.h> // Platform specific hardware definitions
|
64 |
|
|
|
65 |
|
|
#if defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_Compaq) || defined(CYG_HAL_STARTUP_WinCE)
|
66 |
|
|
#define PLATFORM_SETUP1 _platform_setup1
|
67 |
|
|
#define CYGHWR_HAL_ARM_HAS_MMU
|
68 |
|
|
#define CYGSEM_HAL_ROM_RESET_USES_JUMP
|
69 |
|
|
#if defined(CYG_HAL_STARTUP_WinCE)
|
70 |
|
|
#define UNMAPPED(x) (x)+SA11X0_RAM_BANK0_BASE
|
71 |
|
|
#endif
|
72 |
|
|
|
73 |
|
|
#if defined(CYG_HAL_STARTUP_ROM)
|
74 |
|
|
#if (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 59000)
|
75 |
|
|
#define SA11X0_PLL_CLOCK 0x0
|
76 |
|
|
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 73700)
|
77 |
|
|
#define SA11X0_PLL_CLOCK 0x1
|
78 |
|
|
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 88500)
|
79 |
|
|
#define SA11X0_PLL_CLOCK 0x2
|
80 |
|
|
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 103200)
|
81 |
|
|
#define SA11X0_PLL_CLOCK 0x3
|
82 |
|
|
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 118000)
|
83 |
|
|
#define SA11X0_PLL_CLOCK 0x4
|
84 |
|
|
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 132700)
|
85 |
|
|
#define SA11X0_PLL_CLOCK 0x5
|
86 |
|
|
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 147500)
|
87 |
|
|
#define SA11X0_PLL_CLOCK 0x6
|
88 |
|
|
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 162200)
|
89 |
|
|
#define SA11X0_PLL_CLOCK 0x7
|
90 |
|
|
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 176900)
|
91 |
|
|
#define SA11X0_PLL_CLOCK 0x8
|
92 |
|
|
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 191700)
|
93 |
|
|
#define SA11X0_PLL_CLOCK 0x9
|
94 |
|
|
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 206400)
|
95 |
|
|
#define SA11X0_PLL_CLOCK 0xA
|
96 |
|
|
#elif (CYGHWR_HAL_ARM_SA11X0_PROCESSOR_CLOCK == 221200)
|
97 |
|
|
#define SA11X0_PLL_CLOCK 0xB
|
98 |
|
|
#else
|
99 |
|
|
#error Invalid processor clock speed
|
100 |
|
|
#endif
|
101 |
|
|
#endif
|
102 |
|
|
|
103 |
|
|
//#define DEBUG_INIT
|
104 |
|
|
|
105 |
|
|
// Special image header - required when run via Parrot loader
|
106 |
|
|
#ifdef CYGSEM_HAL_PARROT_BOOT
|
107 |
|
|
#define PLATFORM_PREAMBLE _platform_preamble
|
108 |
|
|
.macro _platform_preamble
|
109 |
|
|
b 100f
|
110 |
|
|
.org 0x40
|
111 |
|
|
.long 0x43454345 // CECE
|
112 |
|
|
.long 0x8C0B3000 // Unknown magic
|
113 |
|
|
.org 0x1000
|
114 |
|
|
100:
|
115 |
|
|
.endm
|
116 |
|
|
#endif
|
117 |
|
|
|
118 |
|
|
.macro InitUART3
|
119 |
|
|
#define EGPIOBase 0x49000000
|
120 |
|
|
#define EGPIO_BITSY_RS232_ON (1 << 7) /* UART3 transceiver force on. Active high. */
|
121 |
|
|
|
122 |
|
|
#define SA1100_UTCR0 0x00
|
123 |
|
|
#define SA1100_UTCR1 0x04
|
124 |
|
|
#define SA1100_UTCR2 0x08
|
125 |
|
|
#define SA1100_UTCR3 0x0C
|
126 |
|
|
#define SA1100_UTDR 0x14
|
127 |
|
|
#define SA1100_UTSR0 0x1c
|
128 |
|
|
#define SA1100_UTSR1 0x20
|
129 |
|
|
|
130 |
|
|
#define SA1100_UTCR0_PE (1 << 0) /* parity enable */
|
131 |
|
|
#define SA1100_UTCR0_OES (1 << 1) /* 1 for even parity */
|
132 |
|
|
#define SA1100_UTCR0_2STOP (1 << 2) /* 1 for 2 stop bits */
|
133 |
|
|
#define SA1100_UTCR0_8BIT (1 << 3) /* 1 for 8 bit data */
|
134 |
|
|
#define SA1100_UTCR0_SCE (1 << 4) /* sample clock enable */
|
135 |
|
|
#define SA1100_UTCR0_RCE (1 << 5) /* receive clock edge select */
|
136 |
|
|
#define SA1100_UTCR0_TCE (1 << 6) /* transmit clock edge select */
|
137 |
|
|
|
138 |
|
|
#define SA1100_UTCR1_BRDHIMASK 0xF
|
139 |
|
|
#define SA1100_UTCR2_BRDLoMASK 0xFF
|
140 |
|
|
|
141 |
|
|
#define SA1100_UTCR3_RXE (1 << 0) /* receiver enable */
|
142 |
|
|
#define SA1100_UTCR3_TXE (1 << 1) /* transmit enable */
|
143 |
|
|
#define SA1100_UTCR3_BRK (1 << 2) /* send a BRK */
|
144 |
|
|
#define SA1100_UTCR3_RIE (1 << 3) /* receive FIFO interrupt enable */
|
145 |
|
|
#define SA1100_UTCR3_TIE (1 << 4) /* transmit FIFO interrupt enable */
|
146 |
|
|
#define SA1100_UTCR3_LBM (1 << 5) /* loopback mode */
|
147 |
|
|
|
148 |
|
|
/* [1] 11.11.6 */
|
149 |
|
|
#define SA1100_UTDR_PRE (1 << 8) /* parity error */
|
150 |
|
|
#define SA1100_UTDR_FRE (1 << 9) /* framing error */
|
151 |
|
|
#define SA1100_UTDR_ROR (1 << 10) /* receiver overrun */
|
152 |
|
|
|
153 |
|
|
/* [1] 11.11.7 */
|
154 |
|
|
#define SA1100_UTSR0_TFS (1 << 0) /* transmit FIFO service request */
|
155 |
|
|
|
156 |
|
|
/* [1] 11.11.8 */
|
157 |
|
|
#define SA1100_UTSR1_TBY (1 << 0) /* transmit FIFO busy */
|
158 |
|
|
#define SA1100_UTSR1_RNE (1 << 1) /* receive FIFO not empty */
|
159 |
|
|
#define SA1100_UTSR1_TNF (1 << 2) /* transmit FIFO not full */
|
160 |
|
|
#define SA1100_UTSR1_PRE (1 << 3) /* parity error */
|
161 |
|
|
#define SA1100_UTSR1_FRE (1 << 4) /* framing error */
|
162 |
|
|
#define SA1100_UTSR1_ROR (1 << 5) /* receiver overrun */
|
163 |
|
|
|
164 |
|
|
#define SA1100_UTSR1_ERROR_MASK 0x38
|
165 |
|
|
|
166 |
|
|
#define SA1100_UART3BASE 0x80050000
|
167 |
|
|
|
168 |
|
|
/*
|
169 |
|
|
;; ********************************************************************
|
170 |
|
|
;; InitUART3 - Initialize Serial Communications
|
171 |
|
|
;; ********************************************************************
|
172 |
|
|
;; Following reset, the UART is disabled. So, we do the following:
|
173 |
|
|
*/
|
174 |
|
|
|
175 |
|
|
ldr r1, =SA1100_UART3BASE
|
176 |
|
|
/* disable the UART */
|
177 |
|
|
mov r2, #0x00
|
178 |
|
|
str r2, [r1, #SA1100_UTCR3] /* UART1 Control Reg. 3 */
|
179 |
|
|
/* Now clear all 'sticky' bits in serial I registers, cf. [1] 11.11 */
|
180 |
|
|
mov r2, #0xFF
|
181 |
|
|
str r2, [r1, #SA1100_UTSR0] /* UART1 Status Reg. 0 */
|
182 |
|
|
|
183 |
|
|
/* Set the serial port to sensible defaults: no break, no interrupts, */
|
184 |
|
|
/* no parity, 8 databits, 1 stopbit. */
|
185 |
|
|
mov r2, #SA1100_UTCR0_8BIT
|
186 |
|
|
str r2, [r1, #SA1100_UTCR0] /* UART1 Control Reg. 0 */
|
187 |
|
|
|
188 |
|
|
/* Set BRD to 1, for a baudrate of 115K2 ([1] 11.11.4.1) */
|
189 |
|
|
/* Set BRD to 3, for a baudrate of 57k6 ([1] 11.11.4.1) */
|
190 |
|
|
/* Set BRD to 5, for a baudrate of 38k4 ([1] 11.11.4.1) */
|
191 |
|
|
/* Set BRD to 23, for a baudrate of 9k6 ([1] 11.11.4.1) */
|
192 |
|
|
mov r2, #0x00
|
193 |
|
|
str r2, [r1, #SA1100_UTCR1]
|
194 |
|
|
mov r2, #SA11X0_UART_BAUD_RATE_DIVISOR(CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_BAUD)
|
195 |
|
|
str r2, [r1, #SA1100_UTCR2]
|
196 |
|
|
/* enable the UART TX and RX */
|
197 |
|
|
//InitUart3Enable:
|
198 |
|
|
mov r2, #(SA1100_UTCR3_RXE|SA1100_UTCR3_TXE)
|
199 |
|
|
str r2, [r1, #SA1100_UTCR3]
|
200 |
|
|
|
201 |
|
|
ldr r3, =EGPIOBase
|
202 |
|
|
mov r2, #EGPIO_BITSY_RS232_ON
|
203 |
|
|
str r2, [r3, #0]
|
204 |
|
|
ldr r2, [r3, #0]
|
205 |
|
|
|
206 |
|
|
// Give a little pause to let the thing settle
|
207 |
|
|
ldr r1,=1000000
|
208 |
|
|
10: sub r1,r1,#1
|
209 |
|
|
cmp r1,#0
|
210 |
|
|
bne 10b
|
211 |
|
|
|
212 |
|
|
.endm
|
213 |
|
|
|
214 |
|
|
.macro PutC c
|
215 |
|
|
ldr r8,=\c
|
216 |
|
|
PutCh r8
|
217 |
|
|
.endm
|
218 |
|
|
|
219 |
|
|
.macro PutCh c
|
220 |
|
|
ldr r9,=SA1100_UART3BASE
|
221 |
|
|
str \c,[r9,#SA1100_UTDR]
|
222 |
|
|
77: ldr \c,[r9,#SA1100_UTSR1]
|
223 |
|
|
tst \c,#SA1100_UTSR1_TNF // Tx FIFO not full
|
224 |
|
|
beq 77b
|
225 |
|
|
.endm
|
226 |
|
|
|
227 |
|
|
.macro PutNibble n
|
228 |
|
|
and \n,\n,#0x0F
|
229 |
|
|
cmp \n,#0x0A
|
230 |
|
|
blt 78f
|
231 |
|
|
add \n,\n,#'A'-'0'-0x0A
|
232 |
|
|
78: add \n,\n,#'0'
|
233 |
|
|
PutCh \n
|
234 |
|
|
.endm
|
235 |
|
|
|
236 |
|
|
.macro PutHex1 h
|
237 |
|
|
mov r0,\h,LSR #4
|
238 |
|
|
PutNibble r0
|
239 |
|
|
PutNibble \h
|
240 |
|
|
.endm
|
241 |
|
|
|
242 |
|
|
.macro PutHex2 h
|
243 |
|
|
mov r1,\h,LSR #8
|
244 |
|
|
PutHex1 r1
|
245 |
|
|
PutHex1 \h
|
246 |
|
|
.endm
|
247 |
|
|
|
248 |
|
|
.macro PutHex4 h
|
249 |
|
|
PutC '0'
|
250 |
|
|
PutC 'x'
|
251 |
|
|
mov r2,\h,LSR #16
|
252 |
|
|
PutHex2 r2
|
253 |
|
|
PutHex2 \h
|
254 |
|
|
.endm
|
255 |
|
|
|
256 |
|
|
// This macro represents the initial startup code for the platform
|
257 |
|
|
.macro _platform_setup1
|
258 |
|
|
|
259 |
|
|
#ifdef DEBUG_INIT
|
260 |
|
|
b 54f
|
261 |
|
|
// Dump hex memory
|
262 |
|
|
// R5 - base address
|
263 |
|
|
// R4 - length
|
264 |
|
|
// R0..R6 destroyed
|
265 |
|
|
dump:
|
266 |
|
|
PutC '\r'
|
267 |
|
|
PutC '\n'
|
268 |
|
|
50: mov r6,r5
|
269 |
|
|
PutHex4 r6
|
270 |
|
|
PutC ' '
|
271 |
|
|
ldr r3,=8
|
272 |
|
|
52: PutC ' '
|
273 |
|
|
ldr r6,[r5],#4
|
274 |
|
|
PutHex4 r6
|
275 |
|
|
sub r3,r3,#1
|
276 |
|
|
cmp r3,#0
|
277 |
|
|
bne 52b
|
278 |
|
|
PutC '\n'
|
279 |
|
|
PutC '\r'
|
280 |
|
|
sub r4,r4,#1
|
281 |
|
|
cmp r4,#0
|
282 |
|
|
bne 50b
|
283 |
|
|
mov pc,lr
|
284 |
|
|
|
285 |
|
|
hexR6:
|
286 |
|
|
PutHex4 r6
|
287 |
|
|
PutC ' '
|
288 |
|
|
mov pc,lr
|
289 |
|
|
54:
|
290 |
|
|
#endif // DEBUG_INIT
|
291 |
|
|
|
292 |
|
|
// Disable all interrupts
|
293 |
|
|
ldr r1,=SA11X0_ICMR
|
294 |
|
|
mov r0,#0
|
295 |
|
|
str r0,[r1]
|
296 |
|
|
|
297 |
|
|
// Make sure MMU is OFF
|
298 |
|
|
mov r0,#0xE0000000 // Force cache writeback by reloading
|
299 |
|
|
add r2,r0,#0x4000 // cache from the zeros bank
|
300 |
|
|
123: ldr r1,[r0],#32
|
301 |
|
|
cmp r0, r2
|
302 |
|
|
bne 123b
|
303 |
|
|
mov r0,#0
|
304 |
|
|
mov r1,#0x0070 // MMU Control System bit
|
305 |
|
|
mcr p15,0,r0,c7,c7,0 // Flush data and instruction cache
|
306 |
|
|
mcr p15,0,r0,c8,c7,0 // Flush ID TLBs
|
307 |
|
|
mcr p15,0,r0,c9,c0,0 // Flush Read-Buffer
|
308 |
|
|
mcr p15,0,r0,c7,c10,4 // Drain write buffer
|
309 |
|
|
mcr p15,0,r0,c13,c0,0 // Disable virtual ID mapping
|
310 |
|
|
mcr p15,0,r1,c1,c0,0 // Write MMU control register
|
311 |
|
|
nop; nop; nop; nop
|
312 |
|
|
|
313 |
|
|
InitUART3
|
314 |
|
|
#ifdef DEBUG_INIT
|
315 |
|
|
mov r7,#5
|
316 |
|
|
05: PutC '\n'
|
317 |
|
|
PutC '\r'
|
318 |
|
|
sub r7,r7,#1
|
319 |
|
|
cmp r7,#0
|
320 |
|
|
bne 05b
|
321 |
|
|
|
322 |
|
|
mrs r6,cpsr
|
323 |
|
|
bl hexR6
|
324 |
|
|
#endif // DEBUG_INIT
|
325 |
|
|
|
326 |
|
|
#if 0 // This made no difference
|
327 |
|
|
ldr r1,=10f
|
328 |
|
|
ldr r2,=SA11X0_RAM_BANK0_BASE
|
329 |
|
|
add r1,r1,r2
|
330 |
|
|
mov r0,#(CPSR_IRQ_DISABLE|CPSR_FIQ_DISABLE|CPSR_SUPERVISOR_MODE)
|
331 |
|
|
msr cpsr,r0
|
332 |
|
|
msr spsr,r0
|
333 |
|
|
movs pc,r1
|
334 |
|
|
10:
|
335 |
|
|
#else
|
336 |
|
|
|
337 |
|
|
mov r0,#(CPSR_IRQ_DISABLE|CPSR_FIQ_DISABLE|CPSR_SUPERVISOR_MODE)
|
338 |
|
|
msr cpsr,r0
|
339 |
|
|
#endif
|
340 |
|
|
#ifdef DEBUG_INIT
|
341 |
|
|
mrs r6,cpsr
|
342 |
|
|
bl hexR6
|
343 |
|
|
|
344 |
|
|
ldr r5,=0x00000000
|
345 |
|
|
ldr r4,=0x100/32
|
346 |
|
|
bl dump
|
347 |
|
|
#endif // DEBUG_INIT
|
348 |
|
|
|
349 |
|
|
// Initialise extended GPIO
|
350 |
|
|
ldr r0,=SA1110_EGPIO
|
351 |
|
|
ldr r4,=SA1110_EIO_MIN
|
352 |
|
|
|
353 |
|
|
// Initialize pin directions
|
354 |
|
|
ldr r1,=SA11X0_GPIO_PIN_DIRECTION
|
355 |
|
|
ldr r2,=0x0401F3FC
|
356 |
|
|
str r2,[r1]
|
357 |
|
|
|
358 |
|
|
ldr r2,[r1,#4]
|
359 |
|
|
tst r2,#0x08000000 // Look for expansion pack
|
360 |
|
|
orreq r4,r4,#0x01B0 // Power it up if there
|
361 |
|
|
str r4,[r0]
|
362 |
|
|
|
363 |
|
|
#if defined(CYG_HAL_STARTUP_ROM)
|
364 |
|
|
// Disable clock switching
|
365 |
|
|
mcr p15,0,r0,\
|
366 |
|
|
SA11X0_TEST_CLOCK_AND_IDLE_REGISTER,\
|
367 |
|
|
SA11X0_DISABLE_CLOCK_SWITCHING_RM,\
|
368 |
|
|
SA11X0_DISABLE_CLOCK_SWITCHING_OPCODE
|
369 |
|
|
|
370 |
|
|
// Set up processor clock
|
371 |
|
|
ldr r1,=SA11X0_PWR_MGR_PLL_CONFIG
|
372 |
|
|
ldr r2,=SA11X0_PLL_CLOCK
|
373 |
|
|
str r2,[r1]
|
374 |
|
|
|
375 |
|
|
// Turn clock switching back on
|
376 |
|
|
mcr p15,0,r0,\
|
377 |
|
|
SA11X0_TEST_CLOCK_AND_IDLE_REGISTER,\
|
378 |
|
|
SA11X0_ENABLE_CLOCK_SWITCHING_RM,\
|
379 |
|
|
SA11X0_ENABLE_CLOCK_SWITCHING_OPCODE
|
380 |
|
|
nop
|
381 |
|
|
nop
|
382 |
|
|
#endif
|
383 |
|
|
|
384 |
|
|
// Pause
|
385 |
|
|
ldr r1,=100000
|
386 |
|
|
10: sub r1,r1,#1
|
387 |
|
|
cmp r1,#0
|
388 |
|
|
bne 10b
|
389 |
|
|
|
390 |
|
|
#ifdef CYGBLD_HAL_STARTUP_ROM_INIT_DRAM
|
391 |
|
|
|
392 |
|
|
// Initialize DRAM controller
|
393 |
|
|
bl 19f
|
394 |
|
|
// DRAM controller initialization
|
395 |
|
|
dram_table:
|
396 |
|
|
.word SA11X0_DRAM0_CAS_0, 0xAAAAAAA7
|
397 |
|
|
.word SA11X0_DRAM0_CAS_1, 0xAAAAAAAA
|
398 |
|
|
.word SA11X0_DRAM0_CAS_2, 0xAAAAAAAA
|
399 |
|
|
// .word SA11X0_STATIC_CONTROL_0, 0x4B384B38
|
400 |
|
|
// .word SA11X0_STATIC_CONTROL_1, 0x22212419
|
401 |
|
|
.word SA11X0_EXP_BUS_CONFIGURATION, 0x994A994A // 0x90E790E7
|
402 |
|
|
.word SA11X0_REFRESH_CONFIGURATION, 0x00302001
|
403 |
|
|
.word SA11X0_DRAM2_CAS_0, 0xAAAAAAA7
|
404 |
|
|
.word SA11X0_DRAM2_CAS_1, 0xAAAAAAAA
|
405 |
|
|
.word SA11X0_DRAM2_CAS_2, 0xAAAAAAAA
|
406 |
|
|
// .word SA11X0_STATIC_CONTROL_2, 0x42194449
|
407 |
|
|
.word SA11X0_SMROM_CONFIGURATION, 0x00000000 // 0xAFCCAFCC
|
408 |
|
|
.word SA11X0_DRAM_CONFIGURATION, 0x0000F354 // 0x72547254 // Disabled
|
409 |
|
|
.word 0, 0
|
410 |
|
|
|
411 |
|
|
19: mov r1,lr // Points to 'dram_table'
|
412 |
|
|
ldr r2,[r1],#4 // First control register
|
413 |
|
|
20: ldr r3,[r1],#4
|
414 |
|
|
str r3,[r2]
|
415 |
|
|
ldr r2,[r1],#4 // Next control register
|
416 |
|
|
cmp r2,#0
|
417 |
|
|
bne 20b
|
418 |
|
|
|
419 |
|
|
// Enable UART
|
420 |
|
|
ldr r1,=SA1110_GPCLK_CONTROL_0
|
421 |
|
|
ldr r2,=SA1110_GPCLK_SUS_UART
|
422 |
|
|
str r2,[r1]
|
423 |
|
|
|
424 |
|
|
// Release DRAM hold (set by RESET)
|
425 |
|
|
ldr r1,=SA11X0_PWR_MGR_SLEEP_STATUS
|
426 |
|
|
ldr r2,=SA11X0_DRAM_CONTROL_HOLD
|
427 |
|
|
str r2,[r1]
|
428 |
|
|
|
429 |
|
|
// Perform 8 reads from unmapped/unenabled DRAM
|
430 |
|
|
ldr r1,=SA11X0_RAM_BANK0_BASE
|
431 |
|
|
ldr r2,[r1]
|
432 |
|
|
ldr r2,[r1]
|
433 |
|
|
ldr r2,[r1]
|
434 |
|
|
ldr r2,[r1]
|
435 |
|
|
ldr r2,[r1]
|
436 |
|
|
ldr r2,[r1]
|
437 |
|
|
ldr r2,[r1]
|
438 |
|
|
ldr r2,[r1]
|
439 |
|
|
|
440 |
|
|
// Enable DRAM controller
|
441 |
|
|
ldr r1,=SA11X0_DRAM_CONFIGURATION
|
442 |
|
|
ldr r2,=0x0000F355 // 0x72547255
|
443 |
|
|
str r2,[r1]
|
444 |
|
|
|
445 |
|
|
#endif // CYGBLD_HAL_STARTUP_ROM_INIT_DRAM
|
446 |
|
|
|
447 |
|
|
// Release peripheral hold (set by RESET)
|
448 |
|
|
ldr r1,=SA11X0_PWR_MGR_SLEEP_STATUS
|
449 |
|
|
ldr r2,=SA11X0_PERIPHERAL_CONTROL_HOLD
|
450 |
|
|
str r2,[r1]
|
451 |
|
|
|
452 |
|
|
// Wakeup (via power/resume button)
|
453 |
|
|
ldr r1,=SA11X0_RESET_STATUS
|
454 |
|
|
ldr r2,[r1]
|
455 |
|
|
cmp r2,#SA11X0_SLEEP_MODE_RESET
|
456 |
|
|
bne 45f
|
457 |
|
|
ldr r1,=SA11X0_PWR_MGR_SCRATCHPAD
|
458 |
|
|
ldr r1,[r1]
|
459 |
|
|
mov pc,r1
|
460 |
|
|
nop
|
461 |
|
|
45: nop
|
462 |
|
|
|
463 |
|
|
// Set up a stack [for calling C code]
|
464 |
|
|
ldr r1,=__startup_stack
|
465 |
|
|
ldr r2,=SA11X0_RAM_BANK0_BASE
|
466 |
|
|
orr sp,r1,r2
|
467 |
|
|
|
468 |
|
|
#ifdef DEBUG_INIT
|
469 |
|
|
mrc p15,0,r6,c1,c0,0
|
470 |
|
|
bl hexR6
|
471 |
|
|
mrc p15,0,r6,c2,c0,0
|
472 |
|
|
bl hexR6
|
473 |
|
|
mrc p15,0,r6,c3,c0,0
|
474 |
|
|
bl hexR6
|
475 |
|
|
|
476 |
|
|
mrc p15,0,r5,c2,c0,0
|
477 |
|
|
ldr r6,=0xFFFFC000
|
478 |
|
|
and r5,r5,r6
|
479 |
|
|
ldr r4,=0x100/32
|
480 |
|
|
bl dump
|
481 |
|
|
#endif // DEBUG_INIT
|
482 |
|
|
|
483 |
|
|
// Create MMU tables
|
484 |
|
|
bl hal_mmu_init
|
485 |
|
|
|
486 |
|
|
#ifdef DEBUG_INIT
|
487 |
|
|
ldr r5,=0x00000000
|
488 |
|
|
ldr r4,=0x100/32
|
489 |
|
|
bl dump
|
490 |
|
|
|
491 |
|
|
ldr r5,=0xC0020000
|
492 |
|
|
ldr r4,=0x100/32
|
493 |
|
|
bl dump
|
494 |
|
|
|
495 |
|
|
mrc p15,0,r5,c2,c0,0
|
496 |
|
|
ldr r6,=0xFFFFC000
|
497 |
|
|
and r5,r5,r6
|
498 |
|
|
// ldr r4,=0x4000/32
|
499 |
|
|
ldr r4,=0x100/32
|
500 |
|
|
bl dump
|
501 |
|
|
#endif // DEBUG_INIT
|
502 |
|
|
|
503 |
|
|
// Enable MMU
|
504 |
|
|
ldr r2,=10f
|
505 |
|
|
ldr r1,=MMU_Control_Init|MMU_Control_M
|
506 |
|
|
mcr MMU_CP,0,r1,MMU_Control,c0
|
507 |
|
|
mov pc,r2
|
508 |
|
|
mcr MMU_CP,0,r0,MMU_InvalidateCache,c7,0 // Flush data and instruction cache
|
509 |
|
|
mcr MMU_CP,0,r0,MMU_TLB,c7,0 // Flush ID TLBs
|
510 |
|
|
10:
|
511 |
|
|
nop
|
512 |
|
|
nop
|
513 |
|
|
nop
|
514 |
|
|
|
515 |
|
|
#ifdef DEBUG_INIT
|
516 |
|
|
ldr r5,=0x00022000
|
517 |
|
|
ldr r4,=0xDEADDEAD
|
518 |
|
|
str r4,[r5],#4
|
519 |
|
|
str r4,[r5],#4
|
520 |
|
|
str r4,[r5],#4
|
521 |
|
|
str r4,[r5],#4
|
522 |
|
|
|
523 |
|
|
ldr r5,=0x00022000
|
524 |
|
|
ldr r4,=0x100/32
|
525 |
|
|
bl dump
|
526 |
|
|
#endif // DEBUG_INIT
|
527 |
|
|
|
528 |
|
|
// Save shadow copy of BCR
|
529 |
|
|
ldr r1,=_ipaq_EGPIO
|
530 |
|
|
#ifdef DEGUG_INIT
|
531 |
|
|
ldr r4,=SA1110_EIO_MIN
|
532 |
|
|
#endif // DEBUG_INIT
|
533 |
|
|
str r4,[r1]
|
534 |
|
|
.endm
|
535 |
|
|
|
536 |
|
|
#if defined(CYG_HAL_STARTUP_Compaq)
|
537 |
|
|
#define CYG_HAL_STARTUP_ROM
|
538 |
|
|
#define CYG_HAL_ROM_RESET_USES_JUMP
|
539 |
|
|
#endif
|
540 |
|
|
|
541 |
|
|
#else // defined(CYG_HAL_STARTUP_ROM)
|
542 |
|
|
#define PLATFORM_SETUP1
|
543 |
|
|
#endif
|
544 |
|
|
|
545 |
|
|
#define PLATFORM_VECTORS _platform_vectors
|
546 |
|
|
.macro _platform_vectors
|
547 |
|
|
.globl _ipaq_EGPIO
|
548 |
|
|
_ipaq_EGPIO: .long 0 // Extended GPIO shadow
|
549 |
|
|
|
550 |
|
|
.globl _ipaq_LCD_params
|
551 |
|
|
_ipaq_LCD_params:
|
552 |
|
|
.short 0,0,0,0 // Coordinates used by virtual keyboard
|
553 |
|
|
.short 0,0,0,0
|
554 |
|
|
.short 0 // Checksum of above
|
555 |
|
|
.endm
|
556 |
|
|
|
557 |
|
|
/*---------------------------------------------------------------------------*/
|
558 |
|
|
/* end of hal_platform_setup.h */
|
559 |
|
|
#endif /* CYGONCE_HAL_PLATFORM_SETUP_H */
|