]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - lib_ppc/board.c
Code cleanup; make several boards compile & link.
[karo-tx-uboot.git] / lib_ppc / board.c
index 8308969c35ac339750c5af7ec1950037ce0a20ea..a85425c312b9828f21391bb6eda0d8039c4cfdcb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 2000-2002
+ * (C) Copyright 2000-2004
  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  *
  * See file CREDITS for list of people who contributed to this
@@ -32,7 +32,7 @@
 #ifdef CONFIG_5xx
 #include <mpc5xx.h>
 #endif
-#ifdef CONFIG_MPC5XXX
+#ifdef CONFIG_MPC5xxx
 #include <mpc5xxx.h>
 #endif
 #if (CONFIG_COMMANDS & CFG_CMD_IDE)
@@ -49,7 +49,7 @@
 #endif
 #include <net.h>
 #ifdef CFG_ALLOC_DPRAM
-#if !defined(CONFIG_8260)
+#if !(defined(CONFIG_8260)||defined(CONFIG_MPC8560))
 #include <commproc.h>
 #endif
 #endif
 #if defined(CONFIG_LOGBUFFER)
 #include <logbuff.h>
 #endif
+#if defined(CFG_INIT_RAM_LOCK) && defined(CONFIG_E500)
+#include <asm/cache.h>
+#endif
+#ifdef CONFIG_PS2KBD
+#include <keyboard.h>
+#endif
 
 #if (CONFIG_COMMANDS & CFG_CMD_DOC)
 void doc_init (void);
@@ -251,14 +257,16 @@ static int init_func_watchdog_reset (void)
 
 init_fnc_t *init_sequence[] = {
 
-#if defined(CONFIG_BOARD_PRE_INIT)
-       board_pre_init,         /* very early board init code (fpga boot, etc.) */
+#if defined(CONFIG_BOARD_EARLY_INIT_F)
+       board_early_init_f,
 #endif
 
+#if !defined(CONFIG_TQM866M)
        get_clocks,             /* get CPU and bus clocks (etc.) */
        init_timebase,
+#endif
 #ifdef CFG_ALLOC_DPRAM
-#if !defined(CONFIG_8260)
+#if !(defined(CONFIG_8260) || defined(CONFIG_MPC8560))
        dpram_init,
 #endif
 #endif
@@ -266,6 +274,11 @@ init_fnc_t *init_sequence[] = {
        board_postclk_init,
 #endif
        env_init,
+#if defined(CONFIG_TQM866M)
+       get_clocks_866,         /* get CPU and bus clocks according to the environment variable */
+       sdram_adjust_866,       /* adjust sdram refresh rate according to the new clock */
+       init_timebase,
+#endif
        init_baudrate,
        serial_init,
        console_init_f,
@@ -275,16 +288,12 @@ init_fnc_t *init_sequence[] = {
        prt_8260_clks,
 #endif /* CONFIG_8260 */
        checkcpu,
-#if defined(CONFIG_MPC5XXX)
+#if defined(CONFIG_MPC5xxx)
        prt_mpc5xxx_clks,
-#endif /* CONFIG_MPC5XXX */
+#endif /* CONFIG_MPC5xxx */
        checkboard,
        INIT_FUNC_WATCHDOG_INIT
-#if defined(CONFIG_BMW)                || \
-    defined(CONFIG_COGENT)     || \
-    defined(CONFIG_HYMOD)      || \
-    defined(CONFIG_RSD_PROTO)  || \
-    defined(CONFIG_W7O)
+#if defined(CONFIG_MISC_INIT_F)
        misc_init_f,
 #endif
        INIT_FUNC_WATCHDOG_RESET
@@ -340,7 +349,7 @@ void 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);
 
-#ifndef CONFIG_8260
+#if !(defined(CONFIG_8260) || defined(CONFIG_MPC8560))
        /* Clear initial global data */
        memset ((void *) gd, 0, sizeof (gd_t));
 #endif
@@ -454,21 +463,22 @@ void board_init_f (ulong bootflag)
         * Save local variables to board info struct
         */
 
-       bd->bi_memstart  = CFG_SDRAM_BASE;      /* start of  DRAM memory      */
+       bd->bi_memstart  = CFG_SDRAM_BASE;      /* start of  DRAM memory        */
        bd->bi_memsize   = gd->ram_size;        /* size  of  DRAM memory in bytes */
 
 #ifdef CONFIG_IP860
-       bd->bi_sramstart = SRAM_BASE;   /* start of  SRAM memory      */
-       bd->bi_sramsize  = SRAM_SIZE;   /* size  of  SRAM memory      */
+       bd->bi_sramstart = SRAM_BASE;   /* start of  SRAM memory        */
+       bd->bi_sramsize  = SRAM_SIZE;   /* size  of  SRAM memory        */
 #else
-       bd->bi_sramstart = 0;           /* FIXME */ /* start of  SRAM memory      */
-       bd->bi_sramsize  = 0;           /* FIXME */ /* size  of  SRAM memory      */
+       bd->bi_sramstart = 0;           /* FIXME */ /* start of  SRAM memory    */
+       bd->bi_sramsize  = 0;           /* FIXME */ /* size  of  SRAM memory    */
 #endif
 
-#if defined(CONFIG_8xx) || defined(CONFIG_8260) || defined(CONFIG_5xx)
+#if defined(CONFIG_8xx) || defined(CONFIG_8260) || defined(CONFIG_5xx) || \
+    defined(CONFIG_E500)
        bd->bi_immr_base = CFG_IMMR;    /* base  of IMMR register     */
 #endif
-#if defined(CONFIG_MPC5XXX)
+#if defined(CONFIG_MPC5xxx)
        bd->bi_mbar_base = CFG_MBAR;    /* base of internal registers */
 #endif
 
@@ -477,16 +487,16 @@ void board_init_f (ulong bootflag)
        WATCHDOG_RESET ();
        bd->bi_intfreq = gd->cpu_clk;   /* Internal Freq, in Hz */
        bd->bi_busfreq = gd->bus_clk;   /* Bus Freq,      in Hz */
-#if defined(CONFIG_8260)
+#if defined(CONFIG_8260) || defined(CONFIG_MPC8560)
        bd->bi_cpmfreq = gd->cpm_clk;
        bd->bi_brgfreq = gd->brg_clk;
        bd->bi_sccfreq = gd->scc_clk;
        bd->bi_vco     = gd->vco_out;
 #endif /* CONFIG_8260 */
-#if defined(CONFIG_MPC5XXX)
+#if defined(CONFIG_MPC5xxx)
        bd->bi_ipbfreq = gd->ipb_clk;
        bd->bi_pcifreq = gd->pci_clk;
-#endif /* CONFIG_MPC5XXX */
+#endif /* CONFIG_MPC5xxx */
        bd->bi_baudrate = gd->baudrate; /* Console Baudrate     */
 
 #ifdef CFG_EXTBDINFO
@@ -497,6 +507,16 @@ void board_init_f (ulong bootflag)
        bd->bi_plb_busfreq = gd->bus_clk;
 #if defined(CONFIG_405GP) || defined(CONFIG_405EP)
        bd->bi_pci_busfreq = get_PCI_freq ();
+
+#ifdef CFG_OPB_FREQ
+       bd->bi_opbfreq = CFG_OPB_FREQ;
+#else
+       bd->bi_opbfreq = 50000000;
+#endif
+       bd->bi_iic_fast[0] = 0;
+       bd->bi_iic_fast[1] = 0;
+#elif defined(CONFIG_XILINX_ML300)
+       bd->bi_pci_busfreq = get_PCI_freq ();
 #endif
 #endif
 
@@ -554,6 +574,10 @@ void board_init_r (gd_t *id, ulong dest_addr)
 
        WATCHDOG_RESET ();
 
+#if defined(CONFIG_BOARD_EARLY_INIT_R)
+       board_early_init_r ();
+#endif
+
        gd->reloc_off = dest_addr - CFG_MONITOR_BASE;
 
        monitor_flash_len = (ulong)&__init_end - dest_addr;
@@ -606,6 +630,10 @@ void board_init_r (gd_t *id, ulong dest_addr)
        icache_enable ();       /* it's time to enable the instruction cache */
 #endif
 
+#if defined(CFG_INIT_RAM_LOCK) && defined(CONFIG_E500)
+       unlock_ram_in_cache();  /* it's time to unlock D-cache in e500 */
+#endif
+
 #if defined(CONFIG_BAB7xx) || defined(CONFIG_CPC45)
        /*
         * Do PCI configuration on BAB7xx and CPC45 _before_ the flash
@@ -722,7 +750,8 @@ void board_init_r (gd_t *id, ulong dest_addr)
        load_sernum_ethaddr ();
 #endif
 
-#if defined(CFG_GT_6426x) || defined(CONFIG_PN62)
+#if defined(CFG_GT_6426x) || defined(CONFIG_PN62) || defined(CONFIG_PPCHAMELEONEVB) || \
+    defined(CONFIG_MPC8540ADS) || defined(CONFIG_MPC8560ADS) || defined(CONFIG_440_GX)
        /* handle the 2nd ethernet address */
 
        s = getenv ("eth1addr");
@@ -733,11 +762,16 @@ void board_init_r (gd_t *id, ulong dest_addr)
                        s = (*e) ? e + 1 : e;
        }
 #endif
-#if defined(CFG_GT_6426x)
+#if defined(CFG_GT_6426x) || defined(CONFIG_MPC8540ADS) || defined(CONFIG_MPC8560ADS) || \
+       defined(CONFIG_440_GX)
        /* handle the 3rd ethernet address */
 
        s = getenv ("eth2addr");
-
+#if defined(CONFIG_XPEDITE1K)
+       if (s == NULL)
+               board_get_enetaddr(bd->bi_enet2addr);
+       else
+#endif
        for (i = 0; i < 6; ++i) {
                bd->bi_enet2addr[i] = s ? simple_strtoul (s, &e, 16) : 0;
                if (s)
@@ -745,6 +779,20 @@ void board_init_r (gd_t *id, ulong dest_addr)
        }
 #endif
 
+#if defined(CONFIG_440_GX)
+       /* handle 4th ethernet address */
+       s = getenv("eth3addr");
+#if defined(CONFIG_XPEDITE1K)
+       if (s == NULL)
+               board_get_enetaddr(bd->bi_enet3addr);
+       else
+#endif
+       for (i = 0; i < 6; ++i) {
+               bd->bi_enet3addr[i] = s ? simple_strtoul (s, &e, 16) : 0;
+               if (s)
+                       s = (*e) ? e + 1 : e;
+       }
+#endif
 
 #if defined(CONFIG_TQM8xxL) || defined(CONFIG_TQM8260) || \
     defined(CONFIG_CCM)
@@ -800,6 +848,7 @@ void board_init_r (gd_t *id, ulong dest_addr)
     defined(CONFIG_LWMON)      || \
     defined(CONFIG_MPC8260ADS) || \
     defined(CONFIG_MPC8266ADS) || \
+    defined(CONFIG_MPC8560ADS) || \
     defined(CONFIG_PCU_E)      || \
     defined(CONFIG_RPXSUPER)   || \
     defined(CONFIG_SPD823TS)   )
@@ -865,6 +914,7 @@ void board_init_r (gd_t *id, ulong dest_addr)
 
 #if (CONFIG_COMMANDS & CFG_CMD_NAND)
        WATCHDOG_RESET ();
+       puts ("NAND:");
        nand_init();            /* go init the NAND */
 #endif
 
@@ -937,6 +987,11 @@ void board_init_r (gd_t *id, ulong dest_addr)
        }
 #endif
 
+#ifdef CONFIG_PS2KBD
+       puts ("PS/2:  ");
+       kbd_init();
+#endif
+
 #ifdef CONFIG_MODEM_SUPPORT
  {
         extern int do_mdm_init;
@@ -958,6 +1013,9 @@ 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 (;;);
 }