2 * board/linkstation/early_init.S
4 * Begin at some arbitrary location in RAM or Flash
5 * Initialize core registers
6 * Configure memory controller (Not executing from RAM)
8 * Simple RAM test (currently suspended)
10 * Copyright (C) 2006 Mihai Georgian <u-boot@linuxnotincluded.org.uk>
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation; either version 2 of
15 * the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 * Modified for U-Boot from arch/ppc/boot/linkstation/head.S from
28 * the GPL code for the Buffalo Terastation, derived in its turn from:
30 * arch/ppc/boot/sandpoint/head.S
32 * Initial board bringup code for Motorola SPS Sandpoint test platform
34 * Author: Mark A. Greer
36 * Derived from arch/ppc/boot/pcore/head.S (mporter@mvista.com)
38 * Copyright 2001 MontaVista Software Inc.
42 #include <ppc_asm.tmpl>
45 #include <asm/cache.h>
47 #if defined(CONFIG_LAN) || defined(CONFIG_HLAN)
48 #define RAM_SIZE 0x04000000
49 #elif defined(CONFIG_HGLAN) || defined(CONFIG_HTGL)
50 #define RAM_SIZE 0x08000000
53 #define UART1 0x80004500
54 #define UART1_IER 0x80004501
55 #define UART1_FCR 0x80004502
56 #define UART1_LCR 0x80004503
57 #define UART1_DCR 0x80004511
58 #define UART2 0x80004600
59 #define UART2_IER 0x80004601
60 #define UART2_FCR 0x80004602
61 #define UART2_LCR 0x80004603
62 #define UART2_DCR 0x80004611
64 #define WM32(address,data) \
66 ori r3, r3, address@l; \
73 #define WM16(address,data) \
75 ori r3, r3, address@l; \
81 #define WM8(address,data) \
83 ori r3, r3, address@l; \
94 * Configure core registers
97 /* Establish default MSR value, exception prefix 0xFFF */
123 /* Set segment registers */
146 /* Disable L1 icache/dcache */
153 /* Flash Invalidate L1 icache/dcache */
162 /* Older cores need to manually clear ICFI bit */
168 #if !defined(CFG_RAMBOOT)
170 /* --- CPU Configration registor setting for LinkStation --- */
171 WM32(0x80041020,0x000000a0) /* Reset EPIC */
173 /* errata for latency timer */
174 WM32(0xFEC00000,0x0d000080)
177 WM32(0xFEC00000,0x0c000080)
179 /* PCI configuration command register */
180 WM32(0xFEC00000,0x04000080)
181 WM16(0xFEE00000,0x0600)
182 /* Processor interface configuration register 1 */
183 WM32(0xFEC00000,0xa8000080)
184 /* WM32(0xFEE00000,0xd8131400) */
186 ori r3, r3, 0xFEE00000@l
188 lwz r5, 0(r3) /* load PCIR1 Config */
191 and r5, r4, r5 /* Get Bit20(RCS0) */
194 ori r4, r4, 0xd8130400@l
195 or r4, r4, r5 /* Save (RCS0) */
201 /* Processor interface configuration register 2 */
202 WM32(0xFEC00000,0xac000080)
203 WM32(0xFEE00000,0x00000004)
204 /* Embeded Utility Memory Block Base Address register */
205 WM32(0xFEC00000,0x78000080)
206 WM32(0xFEE00000,0x00000080)
207 /* Address map B option register */
208 WM32(0xFEC00000,0xe0000080)
209 WM8(0xFEE00000,0x20) /* DLL_RESET on */
211 /* Address map B option register */
212 WM32(0xFEC00000,0xe0000080)
214 /* PCI arbiter control register */
215 WM32(0xFEC00000,0x46000080)
216 WM16(0xFEE00002,0x00c0)
218 /* Added to use the high drive strength for the memory selects & addressing */
219 WM32(0xFEC00000,0x73000080)
220 /* WM8(0xFEE00003,0x15) */ /*0x17*/
221 /* Motorola Errata refer to User's Manual Errata#19 */
222 /* WM8(0xFEE00003,0xD5) */
225 /* set miscellaneous I/O control register 1 */
226 WM32(0xFEC00000,0x76000080)
227 WM8(0xFEE00002,0x00) /*0x02*/
228 /* set miscellaneous I/O control register 2 */
229 WM32(0xFEC00000,0x77000080)
230 WM8(0xFEE00003,0x30) /* 0x30 */
232 /* init memory controller */
233 WM32(0xFEC00000,0x80000080)
234 WM32(0xFEE00000,0x00FFFFFF)
236 WM32(0xFEC00000,0x84000080)
237 WM32(0xFEE00000,0xFFFFFFFF)
239 WM32(0xFEC00000,0x90000080)
240 #if defined(CONFIG_LAN) || defined(CONFIG_HLAN)
241 WM32(0xFEE00000,0x3FFFFFFF) /* 64MB */
242 #elif defined(CONFIG_HGLAN) || defined(CONFIG_HTGL)
243 WM32(0xFEE00000,0x7FFFFFFF) /* 128MB */
246 WM32(0xFEC00000,0x94000080)
247 WM32(0xFEE00000,0xFFFFFFFF)
249 WM32(0xFEC00000,0x88000080)
250 WM32(0xFEE00000,0x00030303)
252 WM32(0xFEC00000,0x8C000080)
253 WM32(0xFEE00000,0x03030303)
255 WM32(0xFEC00000,0x98000080)
256 WM32(0xFEE00000,0x00030303)
258 WM32(0xFEC00000,0x9C000080)
259 WM32(0xFEE00000,0x03030303)
262 WM32(0xFEC00000,0xf0000080)
263 #if defined(CONFIG_LAN) || defined(CONFIG_HLAN)
264 WM32(0xFEE00000,0x0200E005) /* bank 0 13xnx4 */
265 #elif defined(CONFIG_HGLAN) || defined(CONFIG_HTGL)
266 WM32(0xFEE00000,0x0200E005) /* bank 0 13xnx4 */
269 WM32(0xFEC00000,0xf4000080)
270 #if defined(CONFIG_LAN) || defined(CONFIG_HLAN)
271 WM32(0xFEE00000,0xe0150000) /* 100MHz Memory bus */
272 #elif defined(CONFIG_HGLAN) || defined(CONFIG_HTGL)
273 WM32(0xFEE00000,0x80150000) /* 133MHz Memory bus */
276 WM32(0xFEC00000,0xf8000080)
277 WM32(0xFEE00000,0x00000077) /* BSTOPRE_M =7 / REFREC=8 */
280 WM32(0xFEC00000,0xfc000080)
281 #if defined(CONFIG_LAN) || defined(CONFIG_HLAN)
282 WM32(0xFEE00000,0x29233222) /* CAS latency=2, burst length=8, Ext Rom=eable */
283 #elif defined(CONFIG_HGLAN) || defined(CONFIG_HTGL)
284 WM32(0xFEE00000,0x29323222) /* CAS latency=3, burst length=4, Ext Rom=eable */
287 /* Output driver control register */
288 WM32(0xFEC00000,0x73000080)
289 WM8(0xFEE00003,0x15) /* for all 40 ohm */
290 /* CLK driver Control Register */
291 WM32(0xFEC00000,0x74000080)
292 WM16(0xFEE00000,0x7078)
294 WM32(0xFEC00000,0xa0000080)
295 WM8(0xFEE00000, 0x01)
297 WM32(0xFEC00000,0xa3000080)
298 #if defined(CONFIG_LAN) || defined(CONFIG_HLAN)
299 WM8(0xFEE00003,0xF2) /* PGMAX = 242 */
300 #elif defined(CONFIG_HGLAN) || defined(CONFIG_HTGL)
301 WM8(0xFEE00003,0xC9) /* PGMAX = 201 */
304 WM32(0xFEC00000,0xd0000080) /* ; select ERCR1 */
305 WM32(0xFEE00000,0xffffff85)
306 WM32(0xFEC00000,0xd4000080) /* ; select ERCR2 */
307 WM32(0xFEE00000,0xffffff05)
308 WM32(0xFEC00000,0xd8000080) /* ; select ERCR3 */
309 WM32(0xFEE00000,0x0000f80f)
310 WM32(0xFEC00000,0xdc000080) /* ; select ERCR4 */
311 WM32(0xFEE00000,0x0e000000)
314 WM32(0xFEC00000,0xf0000080)
315 WM32(0xFEE00000,0x0200E805) /* 11 + 3 clock wait MEMGO on */
317 /* Init UART for AVR */
318 WM8(UART1_LCR,0x00) /* clear LCR */
319 WM8(UART1_IER,0x00) /* disable interrupt */
320 WM8(UART1_LCR,0x80) /* set LCR[DLAB] bit */
321 WM8(UART1_DCR,0x01) /* set DUART mode */
322 #if defined(CONFIG_LAN) || defined(CONFIG_HLAN)
323 WM8(UART1, 0x8B) /* set DLL(baudrate 9600bps, 100MHz) */
324 WM8(UART1_IER,0x02) /* set DLM(baudrate 9600bps, 100MHz) */
325 #elif defined(CONFIG_HGLAN) || defined(CONFIG_HTGL)
326 WM8(UART1, 0x61) /* set DLL(baudrate 9600bps, 133MHz) */
327 WM8(UART1_IER,0x03) /* set DLM(baudrate 9600bps, 133MHz) */
329 WM8(UART1_LCR,0x1b) /* set 8data, 1stop, even parity */
330 WM8(UART1, 0x00) /* clear MCR */
331 WM8(UART1_FCR,0x07) /* clear & enable FIFO */
333 /* Init UART for CONSOLE */
334 WM8(UART2_LCR,0x00) /* clear LCR */
335 WM8(UART2_IER,0x00) /* disable interrupt */
336 WM8(UART2_LCR,0x80) /* set LCR[DLAB] bit */
337 WM8(UART1_DCR,0x01) /* set DUART mode */
338 #if defined(CONFIG_LAN) || defined(CONFIG_HLAN)
339 WM8(UART2, 0x6C) /* set DLL(baudrate 57600bps, 100MHz) */
340 WM8(UART2_IER,0x00) /* set DLM(baudrate 57600bps, 100MHz) */
341 #elif defined(CONFIG_HGLAN) || defined(CONFIG_HTGL)
342 WM8(UART2, 0x90) /* set DLL(baudrate 57600bps, 133MHz) */
343 WM8(UART2_IER,0x00) /* set DLM(baudrate 57600bps, 133MHz) */
345 WM8(UART2_LCR,0x03) /* set 8data, 1stop, non parity */
346 WM8(UART2, 0x00) /* clear MCR */
347 WM8(UART2_FCR,0x07) /* clear & enable FIFO */
348 #endif /* !defined (CFG_RAMBOOT)
350 /* PCI Command Register initialize */
366 #if !defined(CFG_RAMBOOT)
368 /* Wait 1 sec for AVR become enable */
371 mulli r4,r3,1000 /* nanoseconds */
373 li r5,40 /* 40ns if for 100 Mhz bus */
374 divw r4,r4,r5 /* BUS ticks */
379 bne 1b /* Get [synced] base time */
380 addc r9,r6,r4 /* Compute end time */
393 /* set start address(0x00000000) */
396 ori r5, r5, RAM_SIZE@l
397 lis r6, 0xaaaa /* mask pattern a */
399 lis r7, 0x5555 /* mask pattern b */
401 lis r8, 0x0000 /* check step size */
421 #if defined(CONFIG_LAN)
422 WM8(UART1,0x39) /* ram error */
423 #elif defined(CONFIG_HGLAN) ||defined(CONFIG_HLAN) || defined(CONFIG_HTGL)
424 WM8(UART1,0x6F) /* ram error */
429 #endif /* !defined (CFG_RAMBOOT) */
431 /* The instruction cache is enabled and the data cache is disabled */