2 * (C) Copyright 2000-2006
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28 #include <stdio_dev.h>
38 #if defined(CONFIG_CMD_IDE)
41 #if defined(CONFIG_CMD_SCSI)
44 #if defined(CONFIG_CMD_KGDB)
47 #ifdef CONFIG_STATUS_LED
48 #include <status_led.h>
51 #ifdef CONFIG_GENERIC_MMC
55 #ifdef CONFIG_SYS_ALLOC_DPRAM
56 #if !defined(CONFIG_CPM2)
61 #if defined(CONFIG_BAB7xx)
65 #if defined(CONFIG_POST)
68 #if defined(CONFIG_LOGBUFFER)
71 #if defined(CONFIG_SYS_INIT_RAM_LOCK) && defined(CONFIG_E500)
72 #include <asm/cache.h>
78 #ifdef CONFIG_ADDR_MAP
86 #ifdef CONFIG_SYS_UPDATE_FLASH_SIZE
87 extern int update_flash_size (int flash_size);
90 #if defined(CONFIG_SC3)
91 extern void sc3_read_eeprom(void);
94 #if defined(CONFIG_CMD_DOC)
97 #if defined(CONFIG_HARD_I2C) || \
98 defined(CONFIG_SOFT_I2C)
104 static char *failed = "*** failed ***\n";
106 #if defined(CONFIG_OXC) || defined(CONFIG_PCU_E) || defined(CONFIG_RMU)
107 extern flash_info_t flash_info[];
110 #if defined(CONFIG_START_IDE)
111 extern int board_start_ide(void);
113 #include <environment.h>
115 DECLARE_GLOBAL_DATA_PTR;
117 #if defined(CONFIG_ENV_IS_EMBEDDED)
118 #define TOTAL_MALLOC_LEN CONFIG_SYS_MALLOC_LEN
119 #elif ( ((CONFIG_ENV_ADDR+CONFIG_ENV_SIZE) < CONFIG_SYS_MONITOR_BASE) || \
120 (CONFIG_ENV_ADDR >= (CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN)) ) || \
121 defined(CONFIG_ENV_IS_IN_NVRAM)
122 #define TOTAL_MALLOC_LEN (CONFIG_SYS_MALLOC_LEN + CONFIG_ENV_SIZE)
124 #define TOTAL_MALLOC_LEN CONFIG_SYS_MALLOC_LEN
127 #if !defined(CONFIG_SYS_MEM_TOP_HIDE)
128 #define CONFIG_SYS_MEM_TOP_HIDE 0
131 extern ulong __init_end;
133 ulong monitor_flash_len;
135 #if defined(CONFIG_CMD_BEDBUG)
136 #include <bedbug/type.h>
139 /************************************************************************
141 ************************************************************************
145 * The Malloc area is immediately below the monitor copy in DRAM
147 static void mem_malloc_init(ulong start, ulong size)
149 mem_malloc_start = start;
150 mem_malloc_end = start + size;
151 mem_malloc_brk = start;
153 memset ((void *)mem_malloc_start, 0, size);
157 * All attempts to come up with a "common" initialization sequence
158 * that works for all boards and architectures failed: some of the
159 * requirements are just _too_ different. To get rid of the resulting
160 * mess of board dependend #ifdef'ed code we now make the whole
161 * initialization sequence configurable to the user.
163 * The requirements for any new initalization function is simple: it
164 * receives a pointer to the "global data" structure as it's only
165 * argument, and returns an integer return code, where 0 means
166 * "continue" and != 0 means "fatal error, hang the system".
168 typedef int (init_fnc_t) (void);
170 /************************************************************************
172 ************************************************************************
173 * Some of this code should be moved into the core functions,
174 * but let's get it working (again) first...
177 static int init_baudrate (void)
179 char tmp[64]; /* long enough for environment variables */
180 int i = getenv_r ("baudrate", tmp, sizeof (tmp));
182 gd->baudrate = (i > 0)
183 ? (int) simple_strtoul (tmp, NULL, 10)
188 /***********************************************************************/
190 void __board_add_ram_info(int use_default)
192 /* please define platform specific board_add_ram_info() */
194 void board_add_ram_info(int) __attribute__((weak, alias("__board_add_ram_info")));
197 static int init_func_ram (void)
199 #ifdef CONFIG_BOARD_TYPES
200 int board_type = gd->board_type;
202 int board_type = 0; /* use dummy arg */
206 if ((gd->ram_size = initdram (board_type)) > 0) {
207 print_size (gd->ram_size, "");
208 board_add_ram_info(0);
216 /***********************************************************************/
218 #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
219 static int init_func_i2c (void)
222 i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
228 #if defined(CONFIG_HARD_SPI)
229 static int init_func_spi (void)
238 /***********************************************************************/
240 #if defined(CONFIG_WATCHDOG)
241 static int init_func_watchdog_init (void)
243 puts (" Watchdog enabled\n");
247 # define INIT_FUNC_WATCHDOG_INIT init_func_watchdog_init,
249 static int init_func_watchdog_reset (void)
254 # define INIT_FUNC_WATCHDOG_RESET init_func_watchdog_reset,
256 # define INIT_FUNC_WATCHDOG_INIT /* undef */
257 # define INIT_FUNC_WATCHDOG_RESET /* undef */
258 #endif /* CONFIG_WATCHDOG */
260 /************************************************************************
261 * Initialization sequence *
262 ************************************************************************
265 init_fnc_t *init_sequence[] = {
267 #if defined(CONFIG_BOARD_EARLY_INIT_F)
271 #if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)
274 #if !defined(CONFIG_8xx_CPUCLK_DEFAULT)
275 get_clocks, /* get CPU and bus clocks (etc.) */
276 #if defined(CONFIG_TQM8xxL) && !defined(CONFIG_TQM866M) \
277 && !defined(CONFIG_TQM885D)
278 adjust_sdram_tbs_8xx,
282 #ifdef CONFIG_SYS_ALLOC_DPRAM
283 #if !defined(CONFIG_CPM2)
287 #if defined(CONFIG_BOARD_POSTCLK_INIT)
291 #if defined(CONFIG_8xx_CPUCLK_DEFAULT)
292 get_clocks_866, /* get CPU and bus clocks according to the environment variable */
293 sdram_adjust_866, /* adjust sdram refresh rate according to the new clock */
300 #if defined(CONFIG_8260)
303 #endif /* CONFIG_8260 */
304 #if defined(CONFIG_MPC83xx)
308 #if defined(CONFIG_MPC5xxx)
310 #endif /* CONFIG_MPC5xxx */
311 #if defined(CONFIG_MPC8220)
315 INIT_FUNC_WATCHDOG_INIT
316 #if defined(CONFIG_MISC_INIT_F)
319 INIT_FUNC_WATCHDOG_RESET
320 #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
323 #if defined(CONFIG_HARD_SPI)
329 INIT_FUNC_WATCHDOG_RESET
331 #if defined(CONFIG_SYS_DRAM_TEST)
333 #endif /* CONFIG_SYS_DRAM_TEST */
334 INIT_FUNC_WATCHDOG_RESET
336 NULL, /* Terminate this list */
339 ulong get_effective_memsize(void)
341 #ifndef CONFIG_VERY_BIG_RAM
344 /* limit stack to what we can reasonable map */
345 return ((gd->ram_size > CONFIG_MAX_MEM_MAPPED) ?
346 CONFIG_MAX_MEM_MAPPED : gd->ram_size);
350 /************************************************************************
352 * This is the first part of the initialization sequence that is
353 * implemented in C, but still running from ROM.
355 * The main purpose is to provide a (serial) console interface as
356 * soon as possible (so we can see any error messages), and to
357 * initialize the RAM so that we can relocate the monitor code to
360 * Be aware of the restrictions: global data is read-only, BSS is not
361 * initialized, and stack space is limited to a few kB.
363 ************************************************************************
366 #ifdef CONFIG_LOGBUFFER
367 unsigned long logbuffer_base(void)
369 return CONFIG_SYS_SDRAM_BASE + get_effective_memsize() - LOGBUFF_LEN;
373 void board_init_f (ulong bootflag)
376 ulong len, addr, addr_sp;
379 init_fnc_t **init_fnc_ptr;
383 uchar tmp[64]; /* long enough for environment variables */
386 /* Pointer is writable since we allocated a register for it */
387 gd = (gd_t *) (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET);
388 /* compiler optimization barrier needed for GCC >= 3.4 */
389 __asm__ __volatile__("": : :"memory");
391 #if !defined(CONFIG_CPM2) && !defined(CONFIG_MPC83xx) && \
392 !defined(CONFIG_MPC85xx) && !defined(CONFIG_MPC86xx)
393 /* Clear initial global data */
394 memset ((void *) gd, 0, sizeof (gd_t));
397 for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
398 if ((*init_fnc_ptr) () != 0) {
404 * Now that we have DRAM mapped and working, we can
405 * relocate the code and continue running from DRAM.
407 * Reserve memory at end of RAM for (top down in that order):
408 * - area that won't get touched by U-Boot and Linux (optional)
409 * - kernel log buffer
413 * - board info struct
415 len = (ulong)&_end - CONFIG_SYS_MONITOR_BASE;
418 * Subtract specified amount of memory to hide so that it won't
419 * get "touched" at all by U-Boot. By fixing up gd->ram_size
420 * the Linux kernel should now get passed the now "corrected"
421 * memory size and won't touch it either. This should work
422 * for arch/ppc and arch/powerpc. Only Linux board ports in
423 * arch/powerpc with bootwrapper support, that recalculate the
424 * memory size from the SDRAM controller setup will have to
427 gd->ram_size -= CONFIG_SYS_MEM_TOP_HIDE;
429 addr = CONFIG_SYS_SDRAM_BASE + get_effective_memsize();
431 #if defined(CONFIG_MP) && (defined(CONFIG_MPC86xx) || defined(CONFIG_E500))
433 * We need to make sure the location we intend to put secondary core
434 * boot code is reserved and not used by any part of u-boot
436 if (addr > determine_mp_bootpg()) {
437 addr = determine_mp_bootpg();
438 debug ("Reserving MP boot page to %08lx\n", addr);
442 #ifdef CONFIG_LOGBUFFER
443 #ifndef CONFIG_ALT_LB_ADDR
444 /* reserve kernel log buffer */
445 addr -= (LOGBUFF_RESERVE);
446 debug ("Reserving %dk for kernel logbuffer at %08lx\n", LOGBUFF_LEN, addr);
452 * reserve protected RAM
454 i = getenv_r ("pram", (char *)tmp, sizeof (tmp));
455 reg = (i > 0) ? simple_strtoul ((const char *)tmp, NULL, 10) : CONFIG_PRAM;
456 addr -= (reg << 10); /* size is in kB */
457 debug ("Reserving %ldk for protected RAM at %08lx\n", reg, addr);
458 #endif /* CONFIG_PRAM */
460 /* round down to next 4 kB limit */
462 debug ("Top of RAM usable for U-Boot at: %08lx\n", addr);
465 /* reserve memory for LCD display (always full pages) */
466 addr = lcd_setmem (addr);
468 #endif /* CONFIG_LCD */
470 #if defined(CONFIG_VIDEO) && defined(CONFIG_8xx)
471 /* reserve memory for video display (always full pages) */
472 addr = video_setmem (addr);
474 #endif /* CONFIG_VIDEO */
477 * reserve memory for U-Boot code, data & bss
478 * round down to next 4 kB limit
483 /* round down to next 64 kB limit so that IVPR stays aligned */
484 addr &= ~(65536 - 1);
487 debug ("Reserving %ldk for U-Boot at: %08lx\n", len >> 10, addr);
489 #ifdef CONFIG_AMIGAONEG3SE
490 gd->relocaddr = addr;
494 * reserve memory for malloc() arena
496 addr_sp = addr - TOTAL_MALLOC_LEN;
497 debug ("Reserving %dk for malloc() at: %08lx\n",
498 TOTAL_MALLOC_LEN >> 10, addr_sp);
501 * (permanently) allocate a Board Info struct
502 * and a permanent copy of the "global" data
504 addr_sp -= sizeof (bd_t);
505 bd = (bd_t *) addr_sp;
507 debug ("Reserving %zu Bytes for Board Info at: %08lx\n",
508 sizeof (bd_t), addr_sp);
509 addr_sp -= sizeof (gd_t);
510 id = (gd_t *) addr_sp;
511 debug ("Reserving %zu Bytes for Global Data at: %08lx\n",
512 sizeof (gd_t), addr_sp);
515 * Finally, we set up a new (bigger) stack.
517 * Leave some safety gap for SP, force alignment on 16 byte boundary
518 * Clear initial stack frame
522 s = (ulong *)addr_sp;
526 debug ("Stack Pointer at: %08lx\n", addr_sp);
529 * Save local variables to board info struct
532 bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; /* start of DRAM memory */
533 bd->bi_memsize = gd->ram_size; /* size of DRAM memory in bytes */
536 bd->bi_sramstart = SRAM_BASE; /* start of SRAM memory */
537 bd->bi_sramsize = SRAM_SIZE; /* size of SRAM memory */
538 #elif defined CONFIG_MPC8220
539 bd->bi_sramstart = CONFIG_SYS_SRAM_BASE; /* start of SRAM memory */
540 bd->bi_sramsize = CONFIG_SYS_SRAM_SIZE; /* size of SRAM memory */
542 bd->bi_sramstart = 0; /* FIXME */ /* start of SRAM memory */
543 bd->bi_sramsize = 0; /* FIXME */ /* size of SRAM memory */
546 #if defined(CONFIG_8xx) || defined(CONFIG_8260) || defined(CONFIG_5xx) || \
547 defined(CONFIG_E500) || defined(CONFIG_MPC86xx)
548 bd->bi_immr_base = CONFIG_SYS_IMMR; /* base of IMMR register */
550 #if defined(CONFIG_MPC5xxx)
551 bd->bi_mbar_base = CONFIG_SYS_MBAR; /* base of internal registers */
553 #if defined(CONFIG_MPC83xx)
554 bd->bi_immrbar = CONFIG_SYS_IMMR;
556 #if defined(CONFIG_MPC8220)
557 bd->bi_mbar_base = CONFIG_SYS_MBAR; /* base of internal registers */
558 bd->bi_inpfreq = gd->inp_clk;
559 bd->bi_pcifreq = gd->pci_clk;
560 bd->bi_vcofreq = gd->vco_clk;
561 bd->bi_pevfreq = gd->pev_clk;
562 bd->bi_flbfreq = gd->flb_clk;
564 /* store bootparam to sram (backward compatible), here? */
566 u32 *sram = (u32 *)CONFIG_SYS_SRAM_BASE;
567 *sram++ = gd->ram_size;
568 *sram++ = gd->bus_clk;
569 *sram++ = gd->inp_clk;
570 *sram++ = gd->cpu_clk;
571 *sram++ = gd->vco_clk;
572 *sram++ = gd->flb_clk;
573 *sram++ = 0xb8c3ba11; /* boot signature */
577 bd->bi_bootflags = bootflag; /* boot / reboot flag (for LynxOS) */
580 bd->bi_intfreq = gd->cpu_clk; /* Internal Freq, in Hz */
581 bd->bi_busfreq = gd->bus_clk; /* Bus Freq, in Hz */
582 #if defined(CONFIG_CPM2)
583 bd->bi_cpmfreq = gd->cpm_clk;
584 bd->bi_brgfreq = gd->brg_clk;
585 bd->bi_sccfreq = gd->scc_clk;
586 bd->bi_vco = gd->vco_out;
587 #endif /* CONFIG_CPM2 */
588 #if defined(CONFIG_MPC512X)
589 bd->bi_ipsfreq = gd->ips_clk;
590 #endif /* CONFIG_MPC512X */
591 #if defined(CONFIG_MPC5xxx)
592 bd->bi_ipbfreq = gd->ipb_clk;
593 bd->bi_pcifreq = gd->pci_clk;
594 #endif /* CONFIG_MPC5xxx */
595 bd->bi_baudrate = gd->baudrate; /* Console Baudrate */
597 #ifdef CONFIG_SYS_EXTBDINFO
598 strncpy ((char *)bd->bi_s_version, "1.2", sizeof (bd->bi_s_version));
599 strncpy ((char *)bd->bi_r_version, U_BOOT_VERSION, sizeof (bd->bi_r_version));
601 bd->bi_procfreq = gd->cpu_clk; /* Processor Speed, In Hz */
602 bd->bi_plb_busfreq = gd->bus_clk;
603 #if defined(CONFIG_405GP) || defined(CONFIG_405EP) || \
604 defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
605 defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
606 bd->bi_pci_busfreq = get_PCI_freq ();
607 bd->bi_opbfreq = get_OPB_freq ();
608 #elif defined(CONFIG_XILINX_405)
609 bd->bi_pci_busfreq = get_PCI_freq ();
613 debug ("New Stack Pointer is: %08lx\n", addr_sp);
618 post_bootmode_init();
619 post_run (NULL, POST_ROM | post_bootmode_get(0));
624 memcpy (id, (void *)gd, sizeof (gd_t));
626 relocate_code (addr_sp, id, addr);
628 /* NOTREACHED - relocate_code() does not return */
631 /************************************************************************
633 * This is the next part if the initialization sequence: we are now
634 * running from RAM and have a "normal" C environment, i. e. global
635 * data can be written, BSS has been cleared, the stack size in not
636 * that critical any more, etc.
638 ************************************************************************
640 void board_init_r (gd_t *id, ulong dest_addr)
645 extern void malloc_bin_reloc (void);
646 #ifndef CONFIG_ENV_IS_NOWHERE
647 extern char * env_name_spec;
651 #ifndef CONFIG_SYS_NO_FLASH
655 gd = id; /* initialize RAM version of global data */
658 gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */
660 #if defined(CONFIG_RELOC_FIXUP_WORKS)
662 malloc_start = dest_addr - TOTAL_MALLOC_LEN;
664 gd->reloc_off = dest_addr - CONFIG_SYS_MONITOR_BASE;
665 malloc_start = CONFIG_SYS_MONITOR_BASE + gd->reloc_off -
669 #ifdef CONFIG_SERIAL_MULTI
673 debug ("Now running in RAM - U-Boot at: %08lx\n", dest_addr);
678 * Setup trap handlers
680 trap_init (dest_addr);
682 #ifdef CONFIG_ADDR_MAP
686 #if defined(CONFIG_BOARD_EARLY_INIT_R)
687 board_early_init_r ();
690 monitor_flash_len = (ulong)&__init_end - dest_addr;
693 * We have to relocate the command table manually
695 for (cmdtp = &__u_boot_cmd_start; cmdtp != &__u_boot_cmd_end; cmdtp++) {
697 addr = (ulong) (cmdtp->cmd) + gd->reloc_off;
699 printf ("Command \"%s\": 0x%08lx => 0x%08lx\n",
700 cmdtp->name, (ulong) (cmdtp->cmd), addr);
703 (int (*)(struct cmd_tbl_s *, int, int, char *[]))addr;
705 addr = (ulong)(cmdtp->name) + gd->reloc_off;
706 cmdtp->name = (char *)addr;
709 addr = (ulong)(cmdtp->usage) + gd->reloc_off;
710 cmdtp->usage = (char *)addr;
712 #ifdef CONFIG_SYS_LONGHELP
714 addr = (ulong)(cmdtp->help) + gd->reloc_off;
715 cmdtp->help = (char *)addr;
719 /* there are some other pointer constants we must deal with */
720 #ifndef CONFIG_ENV_IS_NOWHERE
721 env_name_spec += gd->reloc_off;
726 #ifdef CONFIG_LOGBUFFER
727 logbuff_init_ptrs ();
730 post_output_backlog ();
736 #if defined(CONFIG_SYS_DELAYED_ICACHE) || defined(CONFIG_MPC83xx)
737 icache_enable (); /* it's time to enable the instruction cache */
740 #if defined(CONFIG_SYS_INIT_RAM_LOCK) && defined(CONFIG_E500)
741 unlock_ram_in_cache(); /* it's time to unlock D-cache in e500 */
744 #if defined(CONFIG_BAB7xx) || defined(CONFIG_CPC45)
746 * Do PCI configuration on BAB7xx and CPC45 _before_ the flash
747 * gets initialised, because we need the ISA resp. PCI_to_LOCAL bus
752 #if defined(CONFIG_BAB7xx)
754 * Initialise the ISA bridge
756 initialise_w83c553f ();
759 asm ("sync ; isync");
761 /* initialize malloc() area */
762 mem_malloc_init (malloc_start, TOTAL_MALLOC_LEN);
765 #if !defined(CONFIG_SYS_NO_FLASH)
768 if ((flash_size = flash_init ()) > 0) {
769 # ifdef CONFIG_SYS_FLASH_CHECKSUM
770 print_size (flash_size, "");
772 * Compute and print flash CRC if flashchecksum is set to 'y'
774 * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
776 s = getenv ("flashchecksum");
777 if (s && (*s == 'y')) {
778 printf (" CRC: %08X",
779 crc32 (0, (const unsigned char *) CONFIG_SYS_FLASH_BASE, flash_size)
783 # else /* !CONFIG_SYS_FLASH_CHECKSUM */
784 print_size (flash_size, "\n");
785 # endif /* CONFIG_SYS_FLASH_CHECKSUM */
791 bd->bi_flashstart = CONFIG_SYS_FLASH_BASE; /* update start of FLASH memory */
792 bd->bi_flashsize = flash_size; /* size of FLASH memory (final value) */
794 #if defined(CONFIG_SYS_UPDATE_FLASH_SIZE)
795 /* Make a update of the Memctrl. */
796 update_flash_size (flash_size);
800 # if defined(CONFIG_PCU_E) || defined(CONFIG_OXC) || defined(CONFIG_RMU)
801 /* flash mapped at end of memory map */
802 bd->bi_flashoffset = TEXT_BASE + flash_size;
803 # elif CONFIG_SYS_MONITOR_BASE == CONFIG_SYS_FLASH_BASE
804 bd->bi_flashoffset = monitor_flash_len; /* reserved area for startup monitor */
806 bd->bi_flashoffset = 0;
808 #else /* CONFIG_SYS_NO_FLASH */
810 bd->bi_flashsize = 0;
811 bd->bi_flashstart = 0;
812 bd->bi_flashoffset = 0;
813 #endif /* !CONFIG_SYS_NO_FLASH */
817 /* initialize higher level parts of CPU like time base and timers */
823 # if !defined(CONFIG_ENV_IS_IN_EEPROM)
829 #if defined(CONFIG_CMD_NAND)
832 nand_init(); /* go init the NAND */
835 /* relocate environment function pointers etc. */
839 * Fill in missing fields of bd_info.
840 * We do this here, where we have "normal" access to the
841 * environment; we used to do this still running from ROM,
842 * where had to use getenv_r(), which can be pretty slow when
843 * the environment is in EEPROM.
846 #if defined(CONFIG_SYS_EXTBDINFO)
847 #if defined(CONFIG_405GP) || defined(CONFIG_405EP)
848 #if defined(CONFIG_I2CFAST)
850 * set bi_iic_fast for linux taking environment variable
851 * "i2cfast" into account
854 char *s = getenv ("i2cfast");
855 if (s && ((*s == 'y') || (*s == 'Y'))) {
856 bd->bi_iic_fast[0] = 1;
857 bd->bi_iic_fast[1] = 1;
859 bd->bi_iic_fast[0] = 0;
860 bd->bi_iic_fast[1] = 0;
864 bd->bi_iic_fast[0] = 0;
865 bd->bi_iic_fast[1] = 0;
866 #endif /* CONFIG_I2CFAST */
867 #endif /* CONFIG_405GP, CONFIG_405EP */
868 #endif /* CONFIG_SYS_EXTBDINFO */
870 #if defined(CONFIG_SC3)
874 #if defined (CONFIG_ID_EEPROM) || defined (CONFIG_SYS_I2C_MAC_OFFSET)
875 mac_read_from_eeprom();
879 if ((gd->board_type >> 16) == 2)
880 bd->bi_ethspeed = gd->board_type & 0xFFFF;
882 bd->bi_ethspeed = 0xFFFF;
885 #ifdef CONFIG_CMD_NET
886 /* kept around for legacy kernels only ... ignore the next section */
887 eth_getenv_enetaddr("ethaddr", bd->bi_enetaddr);
888 #ifdef CONFIG_HAS_ETH1
889 eth_getenv_enetaddr("eth1addr", bd->bi_enet1addr);
891 #ifdef CONFIG_HAS_ETH2
892 eth_getenv_enetaddr("eth2addr", bd->bi_enet2addr);
894 #ifdef CONFIG_HAS_ETH3
895 eth_getenv_enetaddr("eth3addr", bd->bi_enet3addr);
897 #ifdef CONFIG_HAS_ETH4
898 eth_getenv_enetaddr("eth4addr", bd->bi_enet4addr);
900 #ifdef CONFIG_HAS_ETH5
901 eth_getenv_enetaddr("eth5addr", bd->bi_enet5addr);
903 #endif /* CONFIG_CMD_NET */
906 bd->bi_ip_addr = getenv_IPaddr ("ipaddr");
910 #if defined(CONFIG_PCI) && !defined(CONFIG_BAB7xx) && !defined(CONFIG_CPC45)
912 * Do pci configuration
917 /** leave this here (after malloc(), environment and PCI are working) **/
918 /* Initialize stdio devices */
921 /* Initialize the jump table for applications */
924 #if defined(CONFIG_API)
929 /* Initialize the console (after the relocation and devices init) */
932 #if defined(CONFIG_CCM) || \
933 defined(CONFIG_COGENT) || \
934 defined(CONFIG_CPCI405) || \
935 defined(CONFIG_EVB64260) || \
936 defined(CONFIG_KUP4K) || \
937 defined(CONFIG_KUP4X) || \
938 defined(CONFIG_LWMON) || \
939 defined(CONFIG_PCU_E) || \
940 defined(CONFIG_SC3) || \
941 defined(CONFIG_W7O) || \
942 defined(CONFIG_MISC_INIT_R)
943 /* miscellaneous platform dependent initialisations */
948 if (bd->bi_ethspeed != 0xFFFF)
949 hermes_start_lxt980 ((int) bd->bi_ethspeed);
952 #if defined(CONFIG_CMD_KGDB)
958 debug ("U-Boot relocated to %08lx\n", dest_addr);
965 /* Must happen after interrupts are initialized since
966 * an irq handler gets installed
968 #ifdef CONFIG_SERIAL_SOFTWARE_FIFO
969 serial_buffered_init();
972 #if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
973 status_led_set (STATUS_LED_BOOT, STATUS_LED_BLINKING);
980 /* Initialize from environment */
981 if ((s = getenv ("loadaddr")) != NULL) {
982 load_addr = simple_strtoul (s, NULL, 16);
984 #if defined(CONFIG_CMD_NET)
985 if ((s = getenv ("bootfile")) != NULL) {
986 copy_filename (BootFile, s, sizeof (BootFile));
992 #if defined(CONFIG_DTT) /* Digital Thermometers and Thermostats */
995 #if defined(CONFIG_CMD_SCSI)
1001 #ifdef CONFIG_GENERIC_MMC
1004 mmc_initialize (bd);
1007 #if defined(CONFIG_CMD_DOC)
1013 #if defined(CONFIG_CMD_NET)
1014 #if defined(CONFIG_NET_MULTI)
1018 eth_initialize (bd);
1021 #if defined(CONFIG_CMD_NET) && ( \
1022 defined(CONFIG_CCM) || \
1023 defined(CONFIG_ELPT860) || \
1024 defined(CONFIG_EP8260) || \
1025 defined(CONFIG_IP860) || \
1026 defined(CONFIG_IVML24) || \
1027 defined(CONFIG_IVMS8) || \
1028 defined(CONFIG_MPC8260ADS) || \
1029 defined(CONFIG_MPC8266ADS) || \
1030 defined(CONFIG_MPC8560ADS) || \
1031 defined(CONFIG_PCU_E) || \
1032 defined(CONFIG_RPXSUPER) || \
1033 defined(CONFIG_STXGP3) || \
1034 defined(CONFIG_SPD823TS) || \
1035 defined(CONFIG_RESET_PHY_R) )
1038 debug ("Reset Ethernet PHY\n");
1043 post_run (NULL, POST_RAM | post_bootmode_get(0));
1046 #if defined(CONFIG_CMD_PCMCIA) \
1047 && !defined(CONFIG_CMD_IDE)
1053 #if defined(CONFIG_CMD_IDE)
1055 # ifdef CONFIG_IDE_8xx_PCCARD
1060 #if defined(CONFIG_START_IDE)
1061 if (board_start_ide())
1068 #ifdef CONFIG_LAST_STAGE_INIT
1071 * Some parts can be only initialized if all others (like
1072 * Interrupts) are up and running (i.e. the PC-style ISA
1078 #if defined(CONFIG_CMD_BEDBUG)
1083 #if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER)
1085 * Export available size of memory for Linux,
1086 * taking into account the protected RAM at top of memory
1094 if ((s = getenv ("pram")) != NULL) {
1095 pram = simple_strtoul (s, NULL, 10);
1102 #ifdef CONFIG_LOGBUFFER
1103 #ifndef CONFIG_ALT_LB_ADDR
1104 /* Also take the logbuffer into account (pram is in kB) */
1105 pram += (LOGBUFF_LEN+LOGBUFF_OVERHEAD)/1024;
1108 sprintf ((char *)memsz, "%ldk", (bd->bi_memsize / 1024) - pram);
1109 setenv ("mem", (char *)memsz);
1113 #ifdef CONFIG_PS2KBD
1118 #ifdef CONFIG_MODEM_SUPPORT
1120 extern int do_mdm_init;
1121 do_mdm_init = gd->do_mdm_init;
1125 /* Initialization complete - start the monitor */
1127 /* main_loop() can return to retry autoboot, if so just run it again. */
1133 /* NOTREACHED - no way out of command loop except booting */
1138 puts ("### ERROR ### Please RESET the board ###\n");
1139 show_boot_progress(-30);
1144 #if 0 /* We could use plain global data, but the resulting code is bigger */
1146 * Pointer to initial global data area
1148 * Here we initialize it.
1150 #undef XTRN_DECLARE_GLOBAL_DATA_PTR
1151 #define XTRN_DECLARE_GLOBAL_DATA_PTR /* empty = allocate here */
1152 DECLARE_GLOBAL_DATA_PTR = (gd_t *) (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET);
1155 /************************************************************************/