]> git.sur5r.net Git - u-boot/blobdiff - lib_arm/board.c
Fix problems with I2C support for mpc5200
[u-boot] / lib_arm / board.c
index 47dc53ce1b254d461065226b04f9272232735fca..493112d55ed1a35212e82b4b72871e6a8e1e33c2 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"
  */
@@ -46,7 +64,8 @@ static ulong mem_malloc_start = 0;
 static ulong mem_malloc_end = 0;
 static ulong mem_malloc_brk = 0;
 
-static void mem_malloc_init (ulong dest_addr)
+static
+void mem_malloc_init (ulong dest_addr)
 {
        mem_malloc_start = dest_addr;
        mem_malloc_end = dest_addr + CFG_MALLOC_LEN;
@@ -83,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;
 
@@ -136,11 +154,10 @@ static void display_flash_config (ulong size)
 }
 
 
-
 /*
  * Breath some life into the board...
  *
- * Initialize an SMC for serial comms, and carry out some hardware
+ * Initialize a serial port as console, and carry out some hardware
  * tests.
  *
  * The first part of initialization is running from Flash memory;
@@ -169,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,
 };
 
@@ -184,16 +204,19 @@ void start_armboot (void)
        gd_t gd_data;
        bd_t bd_data;
        init_fnc_t **init_fnc_ptr;
-#ifdef CONFIG_VFD
+       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 ();
@@ -205,9 +228,9 @@ void start_armboot (void)
        display_flash_config (size);
 
 #ifdef CONFIG_VFD
-#ifndef PAGE_SIZE
-#define PAGE_SIZE 4096
-#endif
+#  ifndef PAGE_SIZE
+#   define PAGE_SIZE 4096
+#  endif
        /*
         * reserve memory for VFD display (always full pages)
         */
@@ -224,12 +247,23 @@ void start_armboot (void)
        mem_malloc_init (_armboot_real_end);
 #endif /* CONFIG_VFD */
 
+#if (CONFIG_COMMANDS & CFG_CMD_NAND)
+       puts ("NAND:");
+       nand_init();            /* go init the NAND */
+#endif
+
+#ifdef CONFIG_HAS_DATAFLASH
+       AT91F_DataflashInit();
+       dataflash_print_info();
+#endif
+
+       /* initialize environment */
+       env_relocate ();
+
 #ifdef CONFIG_VFD
        /* must do this after the framebuffer is allocated */
        drv_vfd_init();
 #endif
-       /* initialize environment */
-       env_relocate ();
 
        /* IP Address */
        bd_data.bi_ip_addr = getenv_IPaddr ("ipaddr");
@@ -251,6 +285,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 ();
@@ -260,11 +300,26 @@ void start_armboot (void)
        enable_interrupts ();
 
 #ifdef CONFIG_DRIVER_CS8900
-       if (!getenv ("ethaddr")) {
-               cs8900_get_enetaddr (gd->bd->bi_enetaddr);
-       }
+       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