]> git.sur5r.net Git - u-boot/blobdiff - lib_ppc/board.c
[MIPS] Initialize CP0 Cause before setting up CP0 Status register
[u-boot] / lib_ppc / board.c
index 80baab89203fb024c0fca1e4e2baa5900ae62643..ee0213e1acac8748330015fac23f659d6191e9b4 100644 (file)
@@ -87,6 +87,9 @@ void doc_init (void);
     defined(CONFIG_SOFT_I2C)
 #include <i2c.h>
 #endif
+#if defined(CONFIG_HARD_SPI)
+#include <spi.h>
+#endif
 #if defined(CONFIG_CMD_NAND)
 void nand_init (void);
 #endif
@@ -209,9 +212,12 @@ static int init_baudrate (void)
 
 /***********************************************************************/
 
-#ifdef CONFIG_ADD_RAM_INFO
-void board_add_ram_info(int);
-#endif
+void __board_add_ram_info(int use_default)
+{
+       /* please define platform specific board_add_ram_info() */
+}
+void board_add_ram_info(int) __attribute__((weak, alias("__board_add_ram_info")));
+
 
 static int init_func_ram (void)
 {
@@ -224,9 +230,7 @@ static int init_func_ram (void)
 
        if ((gd->ram_size = initdram (board_type)) > 0) {
                print_size (gd->ram_size, "");
-#ifdef CONFIG_ADD_RAM_INFO
                board_add_ram_info(0);
-#endif
                putc('\n');
                return (0);
        }
@@ -246,6 +250,16 @@ static int init_func_i2c (void)
 }
 #endif
 
+#if defined(CONFIG_HARD_SPI)
+static int init_func_spi (void)
+{
+       puts ("SPI:   ");
+       spi_init ();
+       puts ("ready\n");
+       return (0);
+}
+#endif
+
 /***********************************************************************/
 
 #if defined(CONFIG_WATCHDOG)
@@ -309,7 +323,9 @@ init_fnc_t *init_sequence[] = {
        prt_8260_rsr,
        prt_8260_clks,
 #endif /* CONFIG_8260 */
-
+#if defined(CONFIG_MPC83XX)
+       prt_83xx_rsr,
+#endif
        checkcpu,
 #if defined(CONFIG_MPC5xxx)
        prt_mpc5xxx_clks,
@@ -326,6 +342,9 @@ init_fnc_t *init_sequence[] = {
 #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
        init_func_i2c,
 #endif
+#if defined(CONFIG_HARD_SPI)
+       init_func_spi,
+#endif
 #if defined(CONFIG_DTT)                /* Digital Thermometers and Thermostats */
        dtt_init,
 #endif
@@ -342,6 +361,20 @@ init_fnc_t *init_sequence[] = {
        NULL,                   /* Terminate this list */
 };
 
+#ifndef CONFIG_MAX_MEM_MAPPED
+#define CONFIG_MAX_MEM_MAPPED (256 << 20)
+#endif
+ulong get_effective_memsize(void)
+{
+#ifndef        CONFIG_VERY_BIG_RAM
+       return gd->ram_size;
+#else
+       /* limit stack to what we can reasonable map */
+       return ((gd->ram_size > CONFIG_MAX_MEM_MAPPED) ?
+                CONFIG_MAX_MEM_MAPPED : gd->ram_size);
+#endif
+}
+
 /************************************************************************
  *
  * This is the first part of the initialization sequence that is
@@ -376,7 +409,7 @@ void board_init_f (ulong bootflag)
        /* compiler optimization barrier needed for GCC >= 3.4 */
        __asm__ __volatile__("": : :"memory");
 
-#if !defined(CONFIG_CPM2)
+#if !defined(CONFIG_CPM2) && !defined(CONFIG_MPC83XX)
        /* Clear initial global data */
        memset ((void *) gd, 0, sizeof (gd_t));
 #endif
@@ -400,19 +433,15 @@ void board_init_f (ulong bootflag)
         */
        len = (ulong)&_end - CFG_MONITOR_BASE;
 
-#ifndef        CONFIG_VERY_BIG_RAM
-       addr = CFG_SDRAM_BASE + gd->ram_size;
-#else
-       /* only allow stack below 256M */
-       addr = CFG_SDRAM_BASE +
-              (gd->ram_size > 256 << 20) ? 256 << 20 : gd->ram_size;
-#endif
+       addr = CFG_SDRAM_BASE + get_effective_memsize();
 
 #ifdef CONFIG_LOGBUFFER
+#ifndef CONFIG_ALT_LB_ADDR
        /* reserve kernel log buffer */
        addr -= (LOGBUFF_RESERVE);
        debug ("Reserving %dk for kernel logbuffer at %08lx\n", LOGBUFF_LEN, addr);
 #endif
+#endif
 
 #ifdef CONFIG_PRAM
        /*
@@ -552,6 +581,9 @@ void board_init_f (ulong bootflag)
        bd->bi_sccfreq = gd->scc_clk;
        bd->bi_vco     = gd->vco_out;
 #endif /* CONFIG_CPM2 */
+#if defined(CONFIG_MPC512X)
+       bd->bi_ipsfreq = gd->ips_clk;
+#endif /* CONFIG_MPC512X */
 #if defined(CONFIG_MPC5xxx)
        bd->bi_ipbfreq = gd->ipb_clk;
        bd->bi_pcifreq = gd->pci_clk;
@@ -829,6 +861,11 @@ void board_init_r (gd_t *id, ulong dest_addr)
 #if defined(CONFIG_SC3)
        sc3_read_eeprom();
 #endif
+
+#ifdef CFG_ID_EEPROM
+       mac_read_from_eeprom();
+#endif
+
        s = getenv ("ethaddr");
 #if defined (CONFIG_MBX) || \
     defined (CONFIG_RPXCLASSIC) || \
@@ -896,13 +933,10 @@ void board_init_r (gd_t *id, ulong dest_addr)
        }
 #endif
 
-#ifdef CFG_ID_EEPROM
-       mac_read_from_eeprom();
-#endif
-
 #if defined(CONFIG_TQM8xxL) || defined(CONFIG_TQM8260) || \
     defined(CONFIG_TQM8272) || \
-    defined(CONFIG_CCM) || defined(CONFIG_KUP4K) || defined(CONFIG_KUP4X)
+    defined(CONFIG_CCM) || defined(CONFIG_KUP4K) || \
+    defined(CONFIG_KUP4X) || defined(CONFIG_PCS440EP)
        load_sernum_ethaddr ();
 #endif
        /* IP Address */
@@ -924,6 +958,11 @@ void board_init_r (gd_t *id, ulong dest_addr)
        /* Initialize the jump table for applications */
        jumptable_init ();
 
+#if defined(CONFIG_API)
+       /* Initialize API */
+       api_init ();
+#endif
+
        /* Initialize the console (after the relocation and devices init) */
        console_init_r ();
 
@@ -967,7 +1006,7 @@ void board_init_r (gd_t *id, ulong dest_addr)
        serial_buffered_init();
 #endif
 
-#ifdef CONFIG_STATUS_LED
+#if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
        status_led_set (STATUS_LED_BOOT, STATUS_LED_BLINKING);
 #endif
 
@@ -1089,8 +1128,10 @@ void board_init_r (gd_t *id, ulong dest_addr)
                pram=0;
 #endif
 #ifdef CONFIG_LOGBUFFER
+#ifndef CONFIG_ALT_LB_ADDR
                /* Also take the logbuffer into account (pram is in kB) */
                pram += (LOGBUFF_LEN+LOGBUFF_OVERHEAD)/1024;
+#endif
 #endif
                sprintf ((char *)memsz, "%ldk", (bd->bi_memsize / 1024) - pram);
                setenv ("mem", (char *)memsz);
@@ -1123,9 +1164,7 @@ void board_init_r (gd_t *id, ulong dest_addr)
 void hang (void)
 {
        puts ("### ERROR ### Please RESET the board ###\n");
-#ifdef CONFIG_SHOW_BOOT_PROGRESS
        show_boot_progress(-30);
-#endif
        for (;;);
 }