]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - lib_arm/board.c
ColdFire: Fix compilation issue caused by a missing function
[karo-tx-uboot.git] / lib_arm / board.c
index babc2543ebf34fd81eab1115c4d04c0291615ffd..a09386046c3c78624e254c9e51fb77e878a3091f 100644 (file)
 #include <devices.h>
 #include <version.h>
 #include <net.h>
+#include <serial.h>
+#include <nand.h>
+#include <onenand_uboot.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
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#if (CONFIG_COMMANDS & CFG_CMD_NAND)
-void nand_init (void);
-#endif
-
 ulong monitor_flash_len;
 
 #ifdef CONFIG_HAS_DATAFLASH
@@ -80,6 +79,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"
  */
@@ -111,6 +115,40 @@ void *sbrk (ptrdiff_t increment)
        return ((void *) old);
 }
 
+char *strmhz(char *buf, long hz)
+{
+       long l, n;
+       long m;
+
+       n = hz / 1000000L;
+       l = sprintf (buf, "%ld", n);
+       m = (hz % 1000000L) / 1000L;
+       if (m != 0)
+               sprintf (buf + l, ".%03ld", m);
+       return (buf);
+}
+
+
+/************************************************************************
+ * 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                                                      *
  ************************************************************************
@@ -185,6 +223,27 @@ static void display_flash_config (ulong size)
 }
 #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
+
+#ifdef CONFIG_SKIP_RELOCATE_UBOOT
+/*
+ * This routine sets the relocation done flag, because even if
+ * relocation is skipped, the flag is used by other generic code.
+ */
+static int reloc_init(void)
+{
+       gd->flags |= GD_FLG_RELOC;
+       return 0;
+}
+#endif
 
 /*
  * Breathe some life into the board...
@@ -215,6 +274,11 @@ int print_cpuinfo (void); /* test-only */
 
 init_fnc_t *init_sequence[] = {
        cpu_init,               /* basic cpu dependent setup */
+#if defined(CONFIG_SKIP_RELOCATE_UBOOT)
+       reloc_init,             /* Set the relocation done flag, must
+                                  do this AFTER cpu_init(), but as soon
+                                  as possible */
+#endif
        board_init,             /* basic board dependent setup */
        interrupt_init,         /* set up exceptions */
        env_init,               /* initialize environment */
@@ -227,6 +291,9 @@ init_fnc_t *init_sequence[] = {
 #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,
@@ -237,7 +304,7 @@ void start_armboot (void)
 {
        init_fnc_t **init_fnc_ptr;
        char *s;
-#ifndef CFG_NO_FLASH
+#if !defined(CFG_NO_FLASH) || defined (CONFIG_VFD) || defined(CONFIG_LCD)
        ulong size;
 #endif
 #if defined(CONFIG_VFD) || defined(CONFIG_LCD)
@@ -281,26 +348,33 @@ void start_armboot (void)
 #endif /* CONFIG_VFD */
 
 #ifdef CONFIG_LCD
-#      ifndef PAGE_SIZE
-#        define PAGE_SIZE 4096
-#      endif
-       /*
-        * reserve memory for LCD display (always full pages)
-        */
-       /* bss_end is defined in the board-specific linker script */
-       addr = (_bss_end + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1);
-       size = lcd_setmem (addr);
-       gd->fb_base = addr;
+       /* board init may have inited fb_base */
+       if (!gd->fb_base) {
+#              ifndef PAGE_SIZE
+#                define PAGE_SIZE 4096
+#              endif
+               /*
+                * reserve memory for LCD display (always full pages)
+                */
+               /* bss_end is defined in the board-specific linker script */
+               addr = (_bss_end + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1);
+               size = lcd_setmem (addr);
+               gd->fb_base = addr;
+       }
 #endif /* CONFIG_LCD */
 
        /* armboot_start is defined in the board-specific linker script */
        mem_malloc_init (_armboot_start - CFG_MALLOC_LEN);
 
-#if (CONFIG_COMMANDS & CFG_CMD_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();
@@ -314,6 +388,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");
 
@@ -364,6 +442,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
@@ -378,20 +463,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)
+#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 (;;) {