ppc: Clean up calling of misc_init_r() during init
[platform/kernel/u-boot.git] / lib_ppc / board.c
index 6dd4d56..c6fb6fe 100644 (file)
@@ -136,47 +136,12 @@ ulong monitor_flash_len;
 #include <bedbug/type.h>
 #endif
 
-/*
- * Begin and End of memory area for malloc(), and current "brk"
- */
-static ulong   mem_malloc_start = 0;
-static ulong   mem_malloc_end   = 0;
-static ulong   mem_malloc_brk   = 0;
-
 /************************************************************************
  * Utilities                                                           *
  ************************************************************************
  */
 
 /*
- * The Malloc area is immediately below the monitor copy in DRAM
- */
-static void mem_malloc_init (void)
-{
-#if !defined(CONFIG_RELOC_FIXUP_WORKS)
-       mem_malloc_end = CONFIG_SYS_MONITOR_BASE + gd->reloc_off;
-#endif
-       mem_malloc_start = mem_malloc_end - TOTAL_MALLOC_LEN;
-       mem_malloc_brk = mem_malloc_start;
-
-       memset ((void *) mem_malloc_start,
-               0,
-               mem_malloc_end - mem_malloc_start);
-}
-
-void *sbrk (ptrdiff_t increment)
-{
-       ulong old = mem_malloc_brk;
-       ulong new = old + increment;
-
-       if ((new < mem_malloc_start) || (new > mem_malloc_end)) {
-               return (NULL);
-       }
-       mem_malloc_brk = new;
-       return ((void *) old);
-}
-
-/*
  * All attempts to come up with a "common" initialization sequence
  * that works for all boards and architectures failed: some of the
  * requirements are just _too_ different. To get rid of the resulting
@@ -291,6 +256,9 @@ init_fnc_t *init_sequence[] = {
        board_early_init_f,
 #endif
 
+#if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)
+       probecpu,
+#endif
 #if !defined(CONFIG_8xx_CPUCLK_DEFAULT)
        get_clocks,             /* get CPU and bus clocks (etc.) */
 #if defined(CONFIG_TQM8xxL) && !defined(CONFIG_TQM866M) \
@@ -666,6 +634,7 @@ void board_init_r (gd_t *id, ulong dest_addr)
 #ifndef CONFIG_ENV_IS_NOWHERE
        extern char * env_name_spec;
 #endif
+       ulong malloc_start;
 
 #ifndef CONFIG_SYS_NO_FLASH
        ulong flash_size;
@@ -676,11 +645,18 @@ void board_init_r (gd_t *id, ulong dest_addr)
 
        gd->flags |= GD_FLG_RELOC;      /* tell others: relocation done */
 
+       /* The Malloc area is immediately below the monitor copy in DRAM */
 #if defined(CONFIG_RELOC_FIXUP_WORKS)
        gd->reloc_off = 0;
-       mem_malloc_end = dest_addr;
+       malloc_start = dest_addr - TOTAL_MALLOC_LEN;
 #else
        gd->reloc_off = dest_addr - CONFIG_SYS_MONITOR_BASE;
+       malloc_start = CONFIG_SYS_MONITOR_BASE + gd->reloc_off -
+                       TOTAL_MALLOC_LEN;
+#endif
+
+#if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)
+       gd->cpu += gd->reloc_off;
 #endif
 
 #ifdef CONFIG_SERIAL_MULTI
@@ -775,8 +751,7 @@ void board_init_r (gd_t *id, ulong dest_addr)
 
        asm ("sync ; isync");
 
-       /* initialize malloc() area */
-       mem_malloc_init ();
+       mem_malloc_init (malloc_start, TOTAL_MALLOC_LEN);
        malloc_bin_reloc ();
 
 #if !defined(CONFIG_SYS_NO_FLASH)
@@ -946,17 +921,7 @@ 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_CCM)                || \
-    defined(CONFIG_COGENT)     || \
-    defined(CONFIG_CPCI405)    || \
-    defined(CONFIG_EVB64260)   || \
-    defined(CONFIG_KUP4K)      || \
-    defined(CONFIG_KUP4X)      || \
-    defined(CONFIG_LWMON)      || \
-    defined(CONFIG_PCU_E)      || \
-    defined(CONFIG_SC3)                || \
-    defined(CONFIG_W7O)                || \
-    defined(CONFIG_MISC_INIT_R)
+#if defined(CONFIG_MISC_INIT_R)
        /* miscellaneous platform dependent initialisations */
        misc_init_r ();
 #endif