Merge branch 'master' of rsync://rsync.denx.de/git/u-boot
[platform/kernel/u-boot.git] / lib_m68k / board.c
index 06b3bd5..e25833b 100644 (file)
 #endif
 #include <version.h>
 
+#if defined(CONFIG_HARD_I2C) || \
+    defined(CONFIG_SOFT_I2C)
+#include <i2c.h>
+#endif
+
+DECLARE_GLOBAL_DATA_PTR;
+
 static char *failed = "*** failed ***\n";
 
 #ifdef CONFIG_PCU_E
@@ -106,8 +113,6 @@ static      ulong   mem_malloc_brk   = 0;
  */
 static void mem_malloc_init (void)
 {
-       DECLARE_GLOBAL_DATA_PTR;
-
        ulong dest_addr = CFG_MONITOR_BASE + gd->reloc_off;
 
        mem_malloc_end = dest_addr;
@@ -172,8 +177,6 @@ typedef int (init_fnc_t) (void);
 
 static int init_baudrate (void)
 {
-       DECLARE_GLOBAL_DATA_PTR;
-
        uchar tmp[64];  /* long enough for environment variables */
        int i = getenv_r ("baudrate", tmp, sizeof (tmp));
 
@@ -187,8 +190,6 @@ static int init_baudrate (void)
 
 static int init_func_ram (void)
 {
-       DECLARE_GLOBAL_DATA_PTR;
-
        int board_type = 0;     /* use dummy arg */
        puts ("DRAM:  ");
 
@@ -202,6 +203,18 @@ static int init_func_ram (void)
 
 /***********************************************************************/
 
+#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
+
+/***********************************************************************/
+
 /************************************************************************
  * Initialization sequence                                             *
  ************************************************************************
@@ -215,6 +228,9 @@ init_fnc_t *init_sequence[] = {
        display_options,
        checkcpu,
        checkboard,
+#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
+       init_func_i2c,
+#endif
        init_func_ram,
 #if defined(CFG_DRAM_TEST)
        testdram,
@@ -243,8 +259,6 @@ init_fnc_t *init_sequence[] = {
 void
 board_init_f (ulong bootflag)
 {
-    DECLARE_GLOBAL_DATA_PTR;
-
        bd_t *bd;
        ulong len, addr, addr_sp;
        gd_t *id;
@@ -257,6 +271,8 @@ board_init_f (ulong bootflag)
 
        /* Pointer is writable since we allocated a register for it */
        gd = (gd_t *) (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET);
+       /* compiler optimization barrier needed for GCC >= 3.4 */
+       __asm__ __volatile__("": : :"memory");
 
        /* Clear initial global data */
        memset ((void *) gd, 0, sizeof (gd_t));
@@ -392,7 +408,6 @@ board_init_f (ulong bootflag)
  */
 void board_init_r (gd_t *id, ulong dest_addr)
 {
-       DECLARE_GLOBAL_DATA_PTR;
        cmd_tbl_t *cmdtp;
        char *s, *e;
        bd_t *bd;
@@ -559,6 +574,11 @@ void board_init_r (gd_t *id, ulong dest_addr)
        /* Initialize the console (after the relocation and devices init) */
        console_init_r ();
 
+#if defined(CONFIG_MISC_INIT_R)
+       /* miscellaneous platform dependent initialisations */
+       misc_init_r ();
+#endif
+
 #if (CONFIG_COMMANDS & CFG_CMD_KGDB)
        WATCHDOG_RESET ();
        puts ("KGDB:  ");