]> git.sur5r.net Git - u-boot/blobdiff - lib_arm/board.c
[new uImage] Disable debuging output in preparation for merge with master
[u-boot] / lib_arm / board.c
index a3588d693ed3ff6a6cb6555bb44e2823e189e77b..22d573a39834e1c2a813bf73c672e3818b8b4660 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 2002
+ * (C) Copyright 2002-2006
  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  *
  * (C) Copyright 2002
  * MA 02111-1307 USA
  */
 
+/*
+ * To match the U-Boot user interface on ARM platforms to the U-Boot
+ * standard (as on PPC platforms), some messages with debug character
+ * are removed from the default U-Boot build.
+ *
+ * Define DEBUG here if you want additional info as shown below
+ * printed upon startup:
+ *
+ * U-Boot code: 00F00000 -> 00F3C774  BSS: -> 00FC3274
+ * IRQ Stack: 00ebff7c
+ * FIQ Stack: 00ebef7c
+ */
+
 #include <common.h>
 #include <command.h>
 #include <malloc.h>
 #include <net.h>
 
 #ifdef CONFIG_DRIVER_SMC91111
-#include "../drivers/smc91111.h"
+#include "../drivers/net/smc91111.h"
 #endif
 #ifdef CONFIG_DRIVER_LAN91C96
-#include "../drivers/lan91c96.h"
+#include "../drivers/net/lan91c96.h"
 #endif
 
-#if (CONFIG_COMMANDS & CFG_CMD_NAND)
+DECLARE_GLOBAL_DATA_PTR;
+
+#if defined(CONFIG_CMD_NAND)
 void nand_init (void);
 #endif
 
+#if defined(CONFIG_CMD_ONENAND)
+void onenand_init(void);
+#endif
+
 ulong monitor_flash_len;
 
 #ifdef CONFIG_HAS_DATAFLASH
@@ -65,6 +84,11 @@ extern void cs8900_get_enetaddr (uchar * addr);
 extern void rtl8019_get_enetaddr (uchar * addr);
 #endif
 
+#if defined(CONFIG_HARD_I2C) || \
+    defined(CONFIG_SOFT_I2C)
+#include <i2c.h>
+#endif
+
 /*
  * Begin and End of memory area for malloc(), and current "brk"
  */
@@ -96,6 +120,26 @@ void *sbrk (ptrdiff_t increment)
        return ((void *) old);
 }
 
+/************************************************************************
+ * Coloured LED functionality
+ ************************************************************************
+ * May be supplied by boards if desired
+ */
+void inline __coloured_LED_init (void) {}
+void inline coloured_LED_init (void) __attribute__((weak, alias("__coloured_LED_init")));
+void inline __red_LED_on (void) {}
+void inline red_LED_on (void) __attribute__((weak, alias("__red_LED_on")));
+void inline __red_LED_off(void) {}
+void inline red_LED_off(void)       __attribute__((weak, alias("__red_LED_off")));
+void inline __green_LED_on(void) {}
+void inline green_LED_on(void) __attribute__((weak, alias("__green_LED_on")));
+void inline __green_LED_off(void) {}
+void inline green_LED_off(void)__attribute__((weak, alias("__green_LED_off")));
+void inline __yellow_LED_on(void) {}
+void inline yellow_LED_on(void)__attribute__((weak, alias("__yellow_LED_on")));
+void inline __yellow_LED_off(void) {}
+void inline yellow_LED_off(void)__attribute__((weak, alias("__yellow_LED_off")));
+
 /************************************************************************
  * Init Utilities                                                      *
  ************************************************************************
@@ -106,9 +150,7 @@ void *sbrk (ptrdiff_t increment)
 
 static int init_baudrate (void)
 {
-       DECLARE_GLOBAL_DATA_PTR;
-
-       uchar tmp[64];  /* long enough for environment variables */
+       char tmp[64];   /* long enough for environment variables */
        int i = getenv_r ("baudrate", tmp, sizeof (tmp));
        gd->bd->bi_baudrate = gd->baudrate = (i > 0)
                        ? (int) simple_strtoul (tmp, NULL, 10)
@@ -120,14 +162,14 @@ static int init_baudrate (void)
 static int display_banner (void)
 {
        printf ("\n\n%s\n\n", version_string);
-       printf ("U-Boot code: %08lX -> %08lX  BSS: -> %08lX\n",
-               _armboot_start, _bss_start, _bss_end);
+       debug ("U-Boot code: %08lX -> %08lX  BSS: -> %08lX\n",
+              _armboot_start, _bss_start, _bss_end);
 #ifdef CONFIG_MODEM_SUPPORT
-       puts ("Modem Support enabled\n");
+       debug ("Modem Support enabled\n");
 #endif
 #ifdef CONFIG_USE_IRQ
-       printf ("IRQ Stack: %08lx\n", IRQ_STACK_START);
-       printf ("FIQ Stack: %08lx\n", FIQ_STACK_START);
+       debug ("IRQ Stack: %08lx\n", IRQ_STACK_START);
+       debug ("FIQ Stack: %08lx\n", FIQ_STACK_START);
 #endif
 
        return (0);
@@ -142,25 +184,45 @@ static int display_banner (void)
  */
 static int display_dram_config (void)
 {
-       DECLARE_GLOBAL_DATA_PTR;
        int i;
 
+#ifdef DEBUG
        puts ("RAM Configuration:\n");
 
        for(i=0; i<CONFIG_NR_DRAM_BANKS; i++) {
                printf ("Bank #%d: %08lx ", i, gd->bd->bi_dram[i].start);
                print_size (gd->bd->bi_dram[i].size, "\n");
        }
+#else
+       ulong size = 0;
+
+       for (i=0; i<CONFIG_NR_DRAM_BANKS; i++) {
+               size += gd->bd->bi_dram[i].size;
+       }
+       puts("DRAM:  ");
+       print_size(size, "\n");
+#endif
 
        return (0);
 }
 
+#ifndef CFG_NO_FLASH
 static void display_flash_config (ulong size)
 {
        puts ("Flash: ");
        print_size (size, "\n");
 }
+#endif /* CFG_NO_FLASH */
 
+#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
+static int init_func_i2c (void)
+{
+       puts ("I2C:   ");
+       i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
+       puts ("ready\n");
+       return (0);
+}
+#endif
 
 /*
  * Breathe some life into the board...
@@ -187,6 +249,8 @@ static void display_flash_config (ulong size)
  */
 typedef int (init_fnc_t) (void);
 
+int print_cpuinfo (void); /* test-only */
+
 init_fnc_t *init_sequence[] = {
        cpu_init,               /* basic cpu dependent setup */
        board_init,             /* basic board dependent setup */
@@ -196,21 +260,27 @@ init_fnc_t *init_sequence[] = {
        serial_init,            /* serial communications setup */
        console_init_f,         /* stage 1 init of console */
        display_banner,         /* say that we are here */
+#if defined(CONFIG_DISPLAY_CPUINFO)
+       print_cpuinfo,          /* display cpu info (and speed) */
+#endif
+#if defined(CONFIG_DISPLAY_BOARDINFO)
+       checkboard,             /* display board info */
+#endif
+#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
+       init_func_i2c,
+#endif
        dram_init,              /* configure available RAM banks */
        display_dram_config,
-#if defined(CONFIG_VCMA9) || defined (CONFIG_CMC_PU2)
-       checkboard,
-#endif
        NULL,
 };
 
 void start_armboot (void)
 {
-       DECLARE_GLOBAL_DATA_PTR;
-
-       ulong size;
        init_fnc_t **init_fnc_ptr;
        char *s;
+#ifndef CFG_NO_FLASH
+       ulong size;
+#endif
 #if defined(CONFIG_VFD) || defined(CONFIG_LCD)
        unsigned long addr;
 #endif
@@ -232,9 +302,11 @@ void start_armboot (void)
                }
        }
 
+#ifndef CFG_NO_FLASH
        /* configure available FLASH banks */
        size = flash_init ();
        display_flash_config (size);
+#endif /* CFG_NO_FLASH */
 
 #ifdef CONFIG_VFD
 #      ifndef PAGE_SIZE
@@ -265,11 +337,15 @@ void start_armboot (void)
        /* armboot_start is defined in the board-specific linker script */
        mem_malloc_init (_armboot_start - CFG_MALLOC_LEN);
 
-#if (CONFIG_COMMANDS & CFG_CMD_NAND)
-       puts ("NAND:");
+#if defined(CONFIG_CMD_NAND)
+       puts ("NAND:  ");
        nand_init();            /* go init the NAND */
 #endif
 
+#if defined(CONFIG_CMD_ONENAND)
+       onenand_init();
+#endif
+
 #ifdef CONFIG_HAS_DATAFLASH
        AT91F_DataflashInit();
        dataflash_print_info();
@@ -283,6 +359,10 @@ void start_armboot (void)
        drv_vfd_init();
 #endif /* CONFIG_VFD */
 
+#ifdef CONFIG_SERIAL_MULTI
+       serial_initialize();
+#endif
+
        /* IP Address */
        gd->bd->bi_ip_addr = getenv_IPaddr ("ipaddr");
 
@@ -291,7 +371,7 @@ void start_armboot (void)
                int i;
                ulong reg;
                char *s, *e;
-               uchar tmp[64];
+               char tmp[64];
 
                i = getenv_r ("ethaddr", tmp, sizeof (tmp));
                s = (i > 0) ? tmp : NULL;
@@ -301,6 +381,17 @@ void start_armboot (void)
                        if (s)
                                s = (*e) ? e + 1 : e;
                }
+
+#ifdef CONFIG_HAS_ETH1
+               i = getenv_r ("eth1addr", tmp, sizeof (tmp));
+               s = (i > 0) ? tmp : NULL;
+
+               for (reg = 0; reg < 6; ++reg) {
+                       gd->bd->bi_enet1addr[reg] = s ? simple_strtoul (s, &e, 16) : 0;
+                       if (s)
+                               s = (*e) ? e + 1 : e;
+               }
+#endif
        }
 
        devices_init ();        /* get the devices list going. */
@@ -322,6 +413,13 @@ void start_armboot (void)
        enable_interrupts ();
 
        /* Perform network card initialisation if necessary */
+#ifdef CONFIG_DRIVER_TI_EMAC
+extern void dm644x_eth_set_mac_addr (const u_int8_t *addr);
+       if (getenv ("ethaddr")) {
+               dm644x_eth_set_mac_addr(gd->bd->bi_enetaddr);
+       }
+#endif
+
 #ifdef CONFIG_DRIVER_CS8900
        cs8900_get_enetaddr (gd->bd->bi_enetaddr);
 #endif
@@ -336,18 +434,24 @@ void start_armboot (void)
        if ((s = getenv ("loadaddr")) != NULL) {
                load_addr = simple_strtoul (s, NULL, 16);
        }
-#if (CONFIG_COMMANDS & CFG_CMD_NET)
+#if defined(CONFIG_CMD_NET)
        if ((s = getenv ("bootfile")) != NULL) {
                copy_filename (BootFile, s, sizeof (BootFile));
        }
-#endif /* CFG_CMD_NET */
+#endif
 
 #ifdef BOARD_LATE_INIT
        board_late_init ();
 #endif
-#if (CONFIG_COMMANDS & CFG_CMD_NET) && defined(CONFIG_NET_MULTI)
+#if defined(CONFIG_CMD_NET)
+#if defined(CONFIG_NET_MULTI)
        puts ("Net:   ");
+#endif
        eth_initialize(gd->bd);
+#if defined(CONFIG_RESET_PHY_R)
+       debug ("Reset Ethernet PHY\n");
+       reset_phy();
+#endif
 #endif
        /* main_loop() can return to retry autoboot, if so just run it again. */
        for (;;) {
@@ -364,6 +468,8 @@ void hang (void)
 }
 
 #ifdef CONFIG_MODEM_SUPPORT
+static inline void mdm_readline(char *buf, int bufsiz);
+
 /* called from main loop (common/main.c) */
 extern void  dbg(const char *fmt, ...);
 int mdm_init (void)
@@ -372,7 +478,6 @@ int mdm_init (void)
        char *init_str;
        int i;
        extern char console_buffer[];
-       static inline void mdm_readline(char *buf, int bufsiz);
        extern void enable_putc(void);
        extern int hwflow_onoff(int);