]> git.ipfire.org Git - people/ms/u-boot.git/blame - arch/m68k/lib/board.c
Merge branch 'u-boot-tegra/master' into 'u-boot-arm/master'
[people/ms/u-boot.git] / arch / m68k / lib / board.c
CommitLineData
4e5ca3eb 1/*
bf9e3b38
WD
2 * (C) Copyright 2003
3 * Josef Baumgartner <josef.baumgartner@telex.de>
4 *
5 * (C) Copyright 2000-2002
4e5ca3eb
WD
6 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
7 *
1a459660 8 * SPDX-License-Identifier: GPL-2.0+
4e5ca3eb
WD
9 */
10
11#include <common.h>
12#include <watchdog.h>
13#include <command.h>
14#include <malloc.h>
52cb4d4f 15#include <stdio_dev.h>
c59ac903 16#include <linux/compiler.h>
bf9e3b38 17
8ae158cd 18#include <asm/immap.h>
bf9e3b38 19
7def6b34 20#if defined(CONFIG_CMD_IDE)
4e5ca3eb
WD
21#include <ide.h>
22#endif
7def6b34 23#if defined(CONFIG_CMD_SCSI)
4e5ca3eb
WD
24#include <scsi.h>
25#endif
7def6b34 26#if defined(CONFIG_CMD_KGDB)
4e5ca3eb
WD
27#include <kgdb.h>
28#endif
29#ifdef CONFIG_STATUS_LED
30#include <status_led.h>
31#endif
32#include <net.h>
b71190f3 33#include <serial.h>
6d0f6bcf 34#ifdef CONFIG_SYS_ALLOC_DPRAM
4e5ca3eb
WD
35#include <commproc.h>
36#endif
37#include <version.h>
38
e2c22d78 39#if defined(CONFIG_HARD_I2C) || \
ea818dbb 40 defined(CONFIG_SYS_I2C)
e2c22d78
SR
41#include <i2c.h>
42#endif
43
a7323bba
TL
44#ifdef CONFIG_CMD_SPI
45#include <spi.h>
46#endif
47
310cecb8
LCM
48#ifdef CONFIG_BITBANGMII
49#include <miiphy.h>
50#endif
51
ab6ba842
TL
52#include <nand.h>
53
d87080b7
WD
54DECLARE_GLOBAL_DATA_PTR;
55
4e5ca3eb
WD
56static char *failed = "*** failed ***\n";
57
bf9e3b38
WD
58#include <environment.h>
59
bf9e3b38 60extern ulong __init_end;
3929fb0a 61extern ulong __bss_end;
bf9e3b38 62
bf9e3b38 63#if defined(CONFIG_WATCHDOG)
a6741bce 64# undef INIT_FUNC_WATCHDOG_INIT
bf9e3b38
WD
65# define INIT_FUNC_WATCHDOG_INIT watchdog_init,
66# define WATCHDOG_DISABLE watchdog_disable
67
68extern int watchdog_init(void);
69extern int watchdog_disable(void);
70#else
71# define INIT_FUNC_WATCHDOG_INIT /* undef */
72# define WATCHDOG_DISABLE /* undef */
73#endif /* CONFIG_WATCHDOG */
74
75ulong monitor_flash_len;
76
4e5ca3eb
WD
77/************************************************************************
78 * Utilities *
79 ************************************************************************
80 */
81
bf9e3b38
WD
82/*
83 * All attempts to come up with a "common" initialization sequence
84 * that works for all boards and architectures failed: some of the
85 * requirements are just _too_ different. To get rid of the resulting
86 * mess of board dependend #ifdef'ed code we now make the whole
87 * initialization sequence configurable to the user.
88 *
89 * The requirements for any new initalization function is simple: it
90 * receives a pointer to the "global data" structure as it's only
91 * argument, and returns an integer return code, where 0 means
92 * "continue" and != 0 means "fatal error, hang the system".
93 */
94typedef int (init_fnc_t) (void);
95
96/************************************************************************
8ae158cd 97 * Init Utilities
bf9e3b38
WD
98 ************************************************************************
99 * Some of this code should be moved into the core functions,
100 * but let's get it working (again) first...
101 */
102
103static int init_baudrate (void)
4e5ca3eb 104{
77b8f203
SG
105 gd->baudrate = getenv_ulong("baudrate", 10, CONFIG_BAUDRATE);
106 return 0;
bf9e3b38 107}
4e5ca3eb 108
bf9e3b38 109/***********************************************************************/
4e5ca3eb 110
bf9e3b38
WD
111static int init_func_ram (void)
112{
bf9e3b38
WD
113 int board_type = 0; /* use dummy arg */
114 puts ("DRAM: ");
4e5ca3eb 115
bf9e3b38
WD
116 if ((gd->ram_size = initdram (board_type)) > 0) {
117 print_size (gd->ram_size, "\n");
118 return (0);
119 }
120 puts (failed);
121 return (1);
4e5ca3eb
WD
122}
123
bf9e3b38
WD
124/***********************************************************************/
125
ea818dbb 126#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C)
e2c22d78
SR
127static int init_func_i2c (void)
128{
129 puts ("I2C: ");
3f4978c7
HS
130#ifdef CONFIG_SYS_I2C
131 i2c_init_all();
132#else
6d0f6bcf 133 i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
3f4978c7 134#endif
e2c22d78
SR
135 puts ("ready\n");
136 return (0);
137}
138#endif
139
a7323bba
TL
140#if defined(CONFIG_HARD_SPI)
141static int init_func_spi (void)
142{
143 puts ("SPI: ");
144 spi_init ();
145 puts ("ready\n");
146 return (0);
147}
148#endif
149
e2c22d78
SR
150/***********************************************************************/
151
bf9e3b38
WD
152/************************************************************************
153 * Initialization sequence *
154 ************************************************************************
155 */
156
157init_fnc_t *init_sequence[] = {
d61ea148 158 get_clocks,
bf9e3b38
WD
159 env_init,
160 init_baudrate,
161 serial_init,
162 console_init_f,
163 display_options,
164 checkcpu,
165 checkboard,
ea818dbb 166#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C)
e2c22d78 167 init_func_i2c,
a7323bba
TL
168#endif
169#if defined(CONFIG_HARD_SPI)
170 init_func_spi,
e2c22d78 171#endif
bf9e3b38 172 init_func_ram,
6d0f6bcf 173#if defined(CONFIG_SYS_DRAM_TEST)
bf9e3b38 174 testdram,
6d0f6bcf 175#endif /* CONFIG_SYS_DRAM_TEST */
bf9e3b38
WD
176 INIT_FUNC_WATCHDOG_INIT
177 NULL, /* Terminate this list */
178};
179
180
4e5ca3eb
WD
181/************************************************************************
182 *
183 * This is the first part of the initialization sequence that is
184 * implemented in C, but still running from ROM.
185 *
186 * The main purpose is to provide a (serial) console interface as
187 * soon as possible (so we can see any error messages), and to
188 * initialize the RAM so that we can relocate the monitor code to
189 * RAM.
190 *
191 * Be aware of the restrictions: global data is read-only, BSS is not
192 * initialized, and stack space is limited to a few kB.
193 *
194 ************************************************************************
195 */
196
bf9e3b38
WD
197void
198board_init_f (ulong bootflag)
4e5ca3eb 199{
4e5ca3eb 200 bd_t *bd;
bf9e3b38 201 ulong len, addr, addr_sp;
483a0cf8 202 ulong *paddr;
bf9e3b38
WD
203 gd_t *id;
204 init_fnc_t **init_fnc_ptr;
205#ifdef CONFIG_PRAM
bf9e3b38 206 ulong reg;
bf9e3b38 207#endif
4e5ca3eb 208
bf9e3b38 209 /* Pointer is writable since we allocated a register for it */
6d0f6bcf 210 gd = (gd_t *) (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET);
93f6a677
WD
211 /* compiler optimization barrier needed for GCC >= 3.4 */
212 __asm__ __volatile__("": : :"memory");
4e5ca3eb 213
bf9e3b38
WD
214 /* Clear initial global data */
215 memset ((void *) gd, 0, sizeof (gd_t));
4e5ca3eb 216
bf9e3b38
WD
217 for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
218 if ((*init_fnc_ptr)() != 0) {
219 hang ();
220 }
4e5ca3eb 221 }
4e5ca3eb
WD
222
223 /*
224 * Now that we have DRAM mapped and working, we can
225 * relocate the code and continue running from DRAM.
226 *
227 * Reserve memory at end of RAM for (top down in that order):
bf9e3b38
WD
228 * - protected RAM
229 * - LCD framebuffer
230 * - monitor code
231 * - board info struct
4e5ca3eb 232 */
3929fb0a 233 len = (ulong)&__bss_end - CONFIG_SYS_MONITOR_BASE;
4e5ca3eb 234
6d0f6bcf 235 addr = CONFIG_SYS_SDRAM_BASE + gd->ram_size;
4e5ca3eb 236
bf9e3b38
WD
237#ifdef CONFIG_LOGBUFFER
238 /* reserve kernel log buffer */
239 addr -= (LOGBUFF_RESERVE);
240 debug ("Reserving %dk for kernel logbuffer at %08lx\n", LOGBUFF_LEN, addr);
241#endif
242
243#ifdef CONFIG_PRAM
244 /*
245 * reserve protected RAM
246 */
77b8f203 247 reg = getenv_ulong("pram", 10, CONFIG_PRAM);
bf9e3b38
WD
248 addr -= (reg << 10); /* size is in kB */
249 debug ("Reserving %ldk for protected RAM at %08lx\n", reg, addr);
250#endif /* CONFIG_PRAM */
4e5ca3eb 251
1552af70
TL
252 /* round down to next 4 kB limit */
253 addr &= ~(4096 - 1);
254 debug ("Top of RAM usable for U-Boot at: %08lx\n", addr);
255
256#ifdef CONFIG_LCD
d32a1a4c
MK
257#ifdef CONFIG_FB_ADDR
258 gd->fb_base = CONFIG_FB_ADDR;
259#else
1552af70
TL
260 /* reserve memory for LCD display (always full pages) */
261 addr = lcd_setmem (addr);
262 gd->fb_base = addr;
d32a1a4c 263#endif /* CONFIG_FB_ADDR */
1552af70
TL
264#endif /* CONFIG_LCD */
265
bf9e3b38
WD
266 /*
267 * reserve memory for U-Boot code, data & bss
268 * round down to next 4 kB limit
269 */
4e5ca3eb 270 addr -= len;
bf9e3b38
WD
271 addr &= ~(4096 - 1);
272
273 debug ("Reserving %ldk for U-Boot at: %08lx\n", len >> 10, addr);
4e5ca3eb
WD
274
275 /*
bf9e3b38 276 * reserve memory for malloc() arena
4e5ca3eb 277 */
bf9e3b38
WD
278 addr_sp = addr - TOTAL_MALLOC_LEN;
279 debug ("Reserving %dk for malloc() at: %08lx\n",
280 TOTAL_MALLOC_LEN >> 10, addr_sp);
4e5ca3eb 281
bf9e3b38
WD
282 /*
283 * (permanently) allocate a Board Info struct
284 * and a permanent copy of the "global" data
285 */
286 addr_sp -= sizeof (bd_t);
287 bd = (bd_t *) addr_sp;
288 gd->bd = bd;
b64f190b 289 debug ("Reserving %zu Bytes for Board Info at: %08lx\n",
bf9e3b38
WD
290 sizeof (bd_t), addr_sp);
291 addr_sp -= sizeof (gd_t);
292 id = (gd_t *) addr_sp;
b64f190b 293 debug ("Reserving %zu Bytes for Global Data at: %08lx\n",
bf9e3b38
WD
294 sizeof (gd_t), addr_sp);
295
53677ef1 296 /* Reserve memory for boot params. */
6d0f6bcf 297 addr_sp -= CONFIG_SYS_BOOTPARAMS_LEN;
bf9e3b38
WD
298 bd->bi_boot_params = addr_sp;
299 debug ("Reserving %dk for boot parameters at: %08lx\n",
6d0f6bcf 300 CONFIG_SYS_BOOTPARAMS_LEN >> 10, addr_sp);
4e5ca3eb 301
bf9e3b38
WD
302 /*
303 * Finally, we set up a new (bigger) stack.
304 *
305 * Leave some safety gap for SP, force alignment on 16 byte boundary
306 * Clear initial stack frame
307 */
308 addr_sp -= 16;
309 addr_sp &= ~0xF;
483a0cf8
MB
310
311 paddr = (ulong *)addr_sp;
312 *paddr-- = 0;
313 *paddr-- = 0;
314 addr_sp = (ulong)paddr;
977b50f8 315
bf9e3b38 316 debug ("Stack Pointer at: %08lx\n", addr_sp);
4e5ca3eb 317
bf9e3b38
WD
318 /*
319 * Save local variables to board info struct
320 */
6d0f6bcf 321 bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; /* start of DRAM memory */
bf9e3b38 322 bd->bi_memsize = gd->ram_size; /* size of DRAM memory in bytes */
6d0f6bcf
JCPV
323#ifdef CONFIG_SYS_INIT_RAM_ADDR
324 bd->bi_sramstart = CONFIG_SYS_INIT_RAM_ADDR; /* start of SRAM memory */
553f0982 325 bd->bi_sramsize = CONFIG_SYS_INIT_RAM_SIZE; /* size of SRAM memory */
8e585f02 326#endif
6d0f6bcf 327 bd->bi_mbar_base = CONFIG_SYS_MBAR; /* base of internal registers */
bf9e3b38
WD
328
329 bd->bi_bootflags = bootflag; /* boot / reboot flag (for LynxOS) */
330
331 WATCHDOG_RESET ();
332 bd->bi_intfreq = gd->cpu_clk; /* Internal Freq, in Hz */
333 bd->bi_busfreq = gd->bus_clk; /* Bus Freq, in Hz */
8ae158cd
TL
334#ifdef CONFIG_PCI
335 bd->bi_pcifreq = gd->pci_clk; /* PCI Freq in Hz */
336#endif
337#ifdef CONFIG_EXTRA_CLOCK
7e2592fd
SG
338 bd->bi_inpfreq = gd->arch.inp_clk; /* input Freq in Hz */
339 bd->bi_vcofreq = gd->arch.vco_clk; /* vco Freq in Hz */
340 bd->bi_flbfreq = gd->arch.flb_clk; /* flexbus Freq in Hz */
8ae158cd 341#endif
4e5ca3eb 342
6d0f6bcf 343#ifdef CONFIG_SYS_EXTBDINFO
4e5ca3eb 344 strncpy (bd->bi_s_version, "1.2", sizeof (bd->bi_s_version));
bf9e3b38
WD
345 strncpy (bd->bi_r_version, U_BOOT_VERSION, sizeof (bd->bi_r_version));
346#endif
347
348 WATCHDOG_RESET ();
4e5ca3eb 349
bf9e3b38
WD
350#ifdef CONFIG_POST
351 post_bootmode_init();
352 post_run (NULL, POST_ROM | post_bootmode_get(0));
4e5ca3eb
WD
353#endif
354
bf9e3b38 355 WATCHDOG_RESET();
4e5ca3eb 356
bf9e3b38
WD
357 memcpy (id, (void *)gd, sizeof (gd_t));
358
6d0f6bcf 359 debug ("Start relocate of code from %08x to %08lx\n", CONFIG_SYS_MONITOR_BASE, addr);
bf9e3b38 360 relocate_code (addr_sp, id, addr);
4e5ca3eb 361
bf9e3b38
WD
362 /* NOTREACHED - jump_to_ram() does not return */
363}
4e5ca3eb
WD
364
365/************************************************************************
366 *
367 * This is the next part if the initialization sequence: we are now
368 * running from RAM and have a "normal" C environment, i. e. global
369 * data can be written, BSS has been cleared, the stack size in not
370 * that critical any more, etc.
371 *
372 ************************************************************************
373 */
bf9e3b38 374void board_init_r (gd_t *id, ulong dest_addr)
4e5ca3eb 375{
c59ac903 376 char *s __maybe_unused;
4e5ca3eb
WD
377 bd_t *bd;
378
93f6d725 379#ifndef CONFIG_ENV_IS_NOWHERE
bf9e3b38
WD
380 extern char * env_name_spec;
381#endif
6d0f6bcf 382#ifndef CONFIG_SYS_NO_FLASH
bf9e3b38
WD
383 ulong flash_size;
384#endif
385 gd = id; /* initialize RAM version of global data */
4e5ca3eb 386 bd = gd->bd;
bf9e3b38
WD
387
388 gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */
389
bf9e3b38
WD
390 WATCHDOG_RESET ();
391
6d0f6bcf 392 gd->reloc_off = dest_addr - CONFIG_SYS_MONITOR_BASE;
bf9e3b38 393
fd70aa41 394 serial_initialize();
395
aea5eee1
JSBE
396 debug("Now running in RAM - U-Boot at: %08lx\n", dest_addr);
397
bf9e3b38
WD
398 monitor_flash_len = (ulong)&__init_end - dest_addr;
399
2e5167cc 400#if defined(CONFIG_NEEDS_MANUAL_RELOC)
bf9e3b38
WD
401 /*
402 * We have to relocate the command table manually
403 */
6c7c946c
MV
404 fixup_cmdtable(ll_entry_start(cmd_tbl_t, cmd),
405 ll_entry_count(cmd_tbl_t, cmd));
2e5167cc 406#endif /* defined(CONFIG_NEEDS_MANUAL_RELOC) */
bf9e3b38 407
bf9e3b38 408 /* there are some other pointer constants we must deal with */
93f6d725 409#ifndef CONFIG_ENV_IS_NOWHERE
bf9e3b38
WD
410 env_name_spec += gd->reloc_off;
411#endif
412
413 WATCHDOG_RESET ();
414
415#ifdef CONFIG_LOGBUFFER
416 logbuff_init_ptrs ();
417#endif
418#ifdef CONFIG_POST
419 post_output_backlog ();
420 post_reloc ();
421#endif
422 WATCHDOG_RESET();
423
424#if 0
425 /* instruction cache enabled in cpu_init_f() for faster relocation */
426 icache_enable (); /* it's time to enable the instruction cache */
427#endif
4e5ca3eb
WD
428
429 /*
430 * Setup trap handlers
431 */
6d0f6bcf 432 trap_init (CONFIG_SYS_SDRAM_BASE);
4e5ca3eb 433
d4e8ada0 434 /* The Malloc area is immediately below the monitor copy in DRAM */
a483a167
PT
435 mem_malloc_init (CONFIG_SYS_MONITOR_BASE + gd->reloc_off -
436 TOTAL_MALLOC_LEN, TOTAL_MALLOC_LEN);
c790b04d 437
6d0f6bcf 438#if !defined(CONFIG_SYS_NO_FLASH)
eddf52b5 439 puts ("Flash: ");
4e5ca3eb
WD
440
441 if ((flash_size = flash_init ()) > 0) {
6d0f6bcf 442# ifdef CONFIG_SYS_FLASH_CHECKSUM
bf9e3b38 443 print_size (flash_size, "");
4e5ca3eb
WD
444 /*
445 * Compute and print flash CRC if flashchecksum is set to 'y'
446 *
bf9e3b38 447 * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
4e5ca3eb 448 */
ec8a252c 449 if (getenv_yesno("flashchecksum") == 1) {
11d88b26 450 printf (" CRC: %08X",
bf9e3b38 451 crc32 (0,
6d0f6bcf 452 (const unsigned char *) CONFIG_SYS_FLASH_BASE,
bf9e3b38
WD
453 flash_size)
454 );
4e5ca3eb
WD
455 }
456 putc ('\n');
6d0f6bcf 457# else /* !CONFIG_SYS_FLASH_CHECKSUM */
bf9e3b38 458 print_size (flash_size, "\n");
6d0f6bcf 459# endif /* CONFIG_SYS_FLASH_CHECKSUM */
4e5ca3eb
WD
460 } else {
461 puts (failed);
462 hang ();
463 }
464
6d0f6bcf 465 bd->bi_flashstart = CONFIG_SYS_FLASH_BASE; /* update start of FLASH memory */
bf9e3b38
WD
466 bd->bi_flashsize = flash_size; /* size of FLASH memory (final value) */
467 bd->bi_flashoffset = 0;
6d0f6bcf 468#else /* CONFIG_SYS_NO_FLASH */
bf9e3b38
WD
469 bd->bi_flashsize = 0;
470 bd->bi_flashstart = 0;
471 bd->bi_flashoffset = 0;
6d0f6bcf 472#endif /* !CONFIG_SYS_NO_FLASH */
4e5ca3eb
WD
473
474 WATCHDOG_RESET ();
475
476 /* initialize higher level parts of CPU like time base and timers */
477 cpu_init_r ();
478
479 WATCHDOG_RESET ();
480
4e5ca3eb 481#ifdef CONFIG_SPI
bb1f8b4f 482# if !defined(CONFIG_ENV_IS_IN_EEPROM)
4e5ca3eb
WD
483 spi_init_f ();
484# endif
485 spi_init_r ();
486#endif
487
3f4978c7
HS
488#if defined(CONFIG_SYS_I2C)
489 /* Adjust I2C subsystem pointers after relocation */
490 i2c_reloc_fixup();
491#endif
492
4e5ca3eb
WD
493 /* relocate environment function pointers etc. */
494 env_relocate ();
495
4e5ca3eb
WD
496 WATCHDOG_RESET ();
497
8e585f02
TL
498#if defined(CONFIG_PCI)
499 /*
500 * Do pci configuration
501 */
502 pci_init ();
503#endif
4e5ca3eb 504
bf9e3b38 505 /** leave this here (after malloc(), environment and PCI are working) **/
52cb4d4f
JCPV
506 /* Initialize stdio devices */
507 stdio_init ();
4e5ca3eb 508
bf9e3b38
WD
509 /* Initialize the jump table for applications */
510 jumptable_init ();
4e5ca3eb 511
bf9e3b38
WD
512 /* Initialize the console (after the relocation and devices init) */
513 console_init_r ();
4e5ca3eb 514
e2c22d78
SR
515#if defined(CONFIG_MISC_INIT_R)
516 /* miscellaneous platform dependent initialisations */
517 misc_init_r ();
518#endif
519
7def6b34 520#if defined(CONFIG_CMD_KGDB)
4e5ca3eb
WD
521 WATCHDOG_RESET ();
522 puts ("KGDB: ");
523 kgdb_init ();
524#endif
525
bf9e3b38
WD
526 debug ("U-Boot relocated to %08lx\n", dest_addr);
527
4e5ca3eb
WD
528 /*
529 * Enable Interrupts
530 */
531 interrupt_init ();
bf9e3b38
WD
532
533 /* Must happen after interrupts are initialized since
534 * an irq handler gets installed
535 */
536 timer_init();
537
bf9e3b38
WD
538#ifdef CONFIG_STATUS_LED
539 status_led_set (STATUS_LED_BOOT, STATUS_LED_BLINKING);
540#endif
541
4e5ca3eb 542 udelay (20);
bf9e3b38 543
4e5ca3eb
WD
544 /* Insert function pointers now that we have relocated the code */
545
546 /* Initialize from environment */
77b8f203 547 load_addr = getenv_ulong("loadaddr", 16, load_addr);
4e5ca3eb
WD
548
549 WATCHDOG_RESET ();
550
7def6b34 551#if defined(CONFIG_CMD_DOC)
bf9e3b38
WD
552 WATCHDOG_RESET ();
553 puts ("DOC: ");
554 doc_init ();
555#endif
556
7def6b34 557#if defined(CONFIG_CMD_NAND)
4e5ca3eb 558 WATCHDOG_RESET ();
d860c34f 559 puts ("NAND: ");
bf9e3b38
WD
560 nand_init(); /* go init the NAND */
561#endif
562
310cecb8
LCM
563#ifdef CONFIG_BITBANGMII
564 bb_miiphy_init();
565#endif
d61ea148 566#if defined(CONFIG_CMD_NET)
bf9e3b38 567 WATCHDOG_RESET();
8e585f02 568#if defined(FEC_ENET)
bf9e3b38
WD
569 eth_init(bd);
570#endif
8e585f02 571 puts ("Net: ");
ab77bc54 572 eth_initialize (bd);
8e585f02 573#endif
bf9e3b38
WD
574
575#ifdef CONFIG_POST
576 post_run (NULL, POST_RAM | post_bootmode_get(0));
4e5ca3eb
WD
577#endif
578
d61ea148
SR
579#if defined(CONFIG_CMD_PCMCIA) \
580 && !defined(CONFIG_CMD_IDE)
8e585f02
TL
581 WATCHDOG_RESET ();
582 puts ("PCMCIA:");
583 pcmcia_init ();
584#endif
585
d61ea148 586#if defined(CONFIG_CMD_IDE)
8e585f02
TL
587 WATCHDOG_RESET ();
588 puts ("IDE: ");
589 ide_init ();
d61ea148 590#endif
8e585f02 591
4e5ca3eb
WD
592#ifdef CONFIG_LAST_STAGE_INIT
593 WATCHDOG_RESET ();
594 /*
595 * Some parts can be only initialized if all others (like
596 * Interrupts) are up and running (i.e. the PC-style ISA
597 * keyboard).
598 */
599 last_stage_init ();
600#endif
601
bf9e3b38 602#if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER)
4e5ca3eb
WD
603 /*
604 * Export available size of memory for Linux,
605 * taking into account the protected RAM at top of memory
606 */
607 {
77b8f203 608 ulong pram = 0;
a5466651 609 char memsz[32];
4e5ca3eb 610
77b8f203
SG
611#ifdef CONFIG_PRAM
612 pram = getenv_ulong("pram", 10, CONFIG_PRAM);
bf9e3b38
WD
613#endif
614#ifdef CONFIG_LOGBUFFER
615 /* Also take the logbuffer into account (pram is in kB) */
616 pram += (LOGBUFF_LEN+LOGBUFF_OVERHEAD)/1024;
617#endif
4e5ca3eb
WD
618 sprintf (memsz, "%ldk", (bd->bi_memsize / 1024) - pram);
619 setenv ("mem", memsz);
620 }
621#endif
622
bf9e3b38
WD
623#ifdef CONFIG_WATCHDOG
624 /* disable watchdog if environment is set */
625 if ((s = getenv ("watchdog")) != NULL) {
626 if (strncmp (s, "off", 3) == 0) {
627 WATCHDOG_DISABLE ();
628 }
629 }
630#endif /* CONFIG_WATCHDOG*/
631
632
4e5ca3eb
WD
633 /* Initialization complete - start the monitor */
634
635 /* main_loop() can return to retry autoboot, if so just run it again. */
636 for (;;) {
637 WATCHDOG_RESET ();
638 main_loop ();
639 }
640
641 /* NOTREACHED - no way out of command loop except booting */
642}