* Implement new mechanism to export U-Boot's functions to standalone
[oweals/u-boot.git] / lib_arm / board.c
index 31cdd9ccde24873c48a48f66f969a9ea49569c9f..eebf5e40dd74250236d52dd289e94fe71891fd78 100644 (file)
 
 #include <common.h>
 #include <command.h>
+#include <malloc.h>
 #include <devices.h>
 #include <version.h>
 #include <net.h>
 
+#if (CONFIG_COMMANDS & CFG_CMD_NAND)
+void nand_init (void);
+#endif
+
+ulong monitor_flash_len;
+
+#ifdef CONFIG_HAS_DATAFLASH
+extern int  AT91F_DataflashInit(void);
+extern void dataflash_print_info(void);
+#endif
+
+#ifndef CONFIG_IDENT_STRING
+#define CONFIG_IDENT_STRING ""
+#endif
 
 const char version_string[] =
-       U_BOOT_VERSION" (" __DATE__ " - " __TIME__ ")";
+       U_BOOT_VERSION" (" __DATE__ " - " __TIME__ ")"CONFIG_IDENT_STRING;
 
 #ifdef CONFIG_DRIVER_CS8900
 extern void cs8900_get_enetaddr (uchar * addr);
 #endif
 
+#ifdef CONFIG_DRIVER_LAN91C96
+#include "../drivers/lan91c96.h"
+#endif
 /*
  * Begin and End of memory area for malloc(), and current "brk"
  */
@@ -84,8 +102,7 @@ static int init_baudrate (void)
 
        uchar tmp[64];  /* long enough for environment variables */
        int i = getenv_r ("baudrate", tmp, sizeof (tmp));
-
-       gd->baudrate = (i > 0)
+       gd->bd->bi_baudrate = gd->baudrate = (i > 0)
                        ? (int) simple_strtoul (tmp, NULL, 10)
                        : CONFIG_BAUDRATE;
 
@@ -137,7 +154,6 @@ static void display_flash_config (ulong size)
 }
 
 
-
 /*
  * Breath some life into the board...
  *
@@ -170,10 +186,13 @@ init_fnc_t *init_sequence[] = {
        env_init,               /* initialize environment */
        init_baudrate,          /* initialze baudrate settings */
        serial_init,            /* serial communications setup */
+       console_init_f,         /* stage 1 init of console */
        display_banner,         /* say that we are here */
        dram_init,              /* configure available RAM banks */
        display_dram_config,
-
+#if defined(CONFIG_VCMA9)
+       checkboard,
+#endif
        NULL,
 };
 
@@ -185,16 +204,19 @@ void start_armboot (void)
        gd_t gd_data;
        bd_t bd_data;
        init_fnc_t **init_fnc_ptr;
+       char *s;
 #if defined(CONFIG_VFD)
        unsigned long addr;
 #endif
 
        /* Pointer is writable since we allocated a register for it */
        gd = &gd_data;
-       memset (gd, 0, sizeof (gd_t));
+       memset ((void *)gd, 0, sizeof (gd_t));
        gd->bd = &bd_data;
        memset (gd->bd, 0, sizeof (bd_t));
 
+       monitor_flash_len = _armboot_end_data - _armboot_start;
+
        for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
                if ((*init_fnc_ptr)() != 0) {
                        hang ();
@@ -225,6 +247,15 @@ void start_armboot (void)
        mem_malloc_init (_armboot_real_end);
 #endif /* CONFIG_VFD */
 
+#if (CONFIG_COMMANDS & CFG_CMD_NAND)
+       nand_init();            /* go init the NAND */
+#endif
+
+#ifdef CONFIG_HAS_DATAFLASH
+       AT91F_DataflashInit();
+       dataflash_print_info();
+#endif
+
        /* initialize environment */
        env_relocate ();
 
@@ -253,6 +284,12 @@ void start_armboot (void)
                }
        }
 
+       devices_init ();      /* get the devices list going. */
+
+       jumptable_init ();
+
+       console_init_r ();      /* fully init console as a device */
+
 #if defined(CONFIG_MISC_INIT_R)
        /* miscellaneous platform dependent initialisations */
        misc_init_r ();
@@ -265,12 +302,27 @@ void start_armboot (void)
        cs8900_get_enetaddr (gd->bd->bi_enetaddr);
 #endif
 
+#ifdef CONFIG_DRIVER_LAN91C96
+       if (getenv ("ethaddr")) {
+               smc_set_mac_addr(gd->bd->bi_enetaddr);
+       }
+       /* eth_hw_init(); */
+#endif /* CONFIG_DRIVER_LAN91C96 */
+
+       /* Initialize from environment */
+       if ((s = getenv ("loadaddr")) != NULL) {
+               load_addr = simple_strtoul (s, NULL, 16);
+       }
+#if (CONFIG_COMMANDS & CFG_CMD_NET)
+       if ((s = getenv ("bootfile")) != NULL) {
+               copy_filename (BootFile, s, sizeof (BootFile));
+       }
+#endif /* CFG_CMD_NET */
+
 #ifdef BOARD_POST_INIT
        board_post_init ();
 #endif
 
-printf ("### vfd_type=0x%02X vfd_data_lines_inv=%d\n",gd->vfd_type,gd->vfd_inv_data);
-
        /* main_loop() can return to retry autoboot, if so just run it again. */
        for (;;) {
                main_loop ();