]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - lib_ppc/board.c
Patch by Travis Sawyer, 30 Dec 2003:
[people/ms/u-boot.git] / lib_ppc / board.c
index daa2a6df44852ab926d6237ae19651bd8336d3e4..d7cee2b5215f60e545bcee638369b4453931297e 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
 #include <command.h>
 #include <malloc.h>
 #include <devices.h>
-#include <syscall.h>
 #ifdef CONFIG_8xx
 #include <mpc8xx.h>
 #endif
 #ifdef CONFIG_5xx
 #include <mpc5xx.h>
 #endif
+#ifdef CONFIG_MPC5XXX
+#include <mpc5xxx.h>
+#endif
 #if (CONFIG_COMMANDS & CFG_CMD_IDE)
 #include <ide.h>
 #endif
@@ -47,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);
@@ -153,37 +161,6 @@ char *strmhz (char *buf, long hz)
        return (buf);
 }
 
-static void syscalls_init (void)
-{
-       ulong *addr;
-
-       syscall_tbl[SYSCALL_MALLOC] = (void *) malloc;
-       syscall_tbl[SYSCALL_FREE] = (void *) free;
-
-       syscall_tbl[SYSCALL_INSTALL_HDLR] = (void *) irq_install_handler;
-       syscall_tbl[SYSCALL_FREE_HDLR] = (void *) irq_free_handler;
-       syscall_tbl[SYSCALL_GET_TIMER] = (void *)get_timer;
-       syscall_tbl[SYSCALL_UDELAY] = (void *)udelay;
-
-       addr = (ulong *) 0xc00;         /* syscall ISR addr */
-
-       /* patch ISR code */
-       *addr++ |= (ulong) syscall_tbl >> 16;
-       *addr++ |= (ulong) syscall_tbl & 0xFFFF;
-       *addr++ |= NR_SYSCALLS >> 16;
-       *addr++ |= NR_SYSCALLS & 0xFFFF;
-
-#ifndef CONFIG_5XX
-       flush_cache (0x0C00, 0x10);
-#endif
-       /* Initialize syscalls stack pointer                                 */
-       addr = (ulong *) 0xCFC;
-       *addr = (ulong)addr;
-#ifndef CONFIG_5xx
-       flush_cache ((ulong)addr, 0x10);
-#endif
-}
-
 /*
  * All attempts to come up with a "common" initialization sequence
  * that works for all boards and architectures failed: some of the
@@ -280,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
@@ -295,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,
@@ -304,13 +288,12 @@ init_fnc_t *init_sequence[] = {
        prt_8260_clks,
 #endif /* CONFIG_8260 */
        checkcpu,
+#if defined(CONFIG_MPC5XXX)
+       prt_mpc5xxx_clks,
+#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
@@ -366,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
@@ -480,33 +463,40 @@ 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)
+       bd->bi_mbar_base = CFG_MBAR;    /* base of internal registers */
+#endif
 
        bd->bi_bootflags = bootflag;    /* boot / reboot flag (for LynxOS)    */
 
        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)
+       bd->bi_ipbfreq = gd->ipb_clk;
+       bd->bi_pcifreq = gd->pci_clk;
+#endif /* CONFIG_MPC5XXX */
        bd->bi_baudrate = gd->baudrate; /* Console Baudrate     */
 
 #ifdef CFG_EXTBDINFO
@@ -517,6 +507,14 @@ 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;
 #endif
 #endif
 
@@ -531,7 +529,7 @@ void board_init_f (ulong bootflag)
 
        WATCHDOG_RESET();
 
-       memcpy (id, gd, sizeof (gd_t));
+       memcpy (id, (void *)gd, sizeof (gd_t));
 
        relocate_code (addr_sp, id, addr);
 
@@ -574,6 +572,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;
@@ -626,6 +628,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
@@ -652,7 +658,7 @@ void board_init_r (gd_t *id, ulong dest_addr)
        puts ("FLASH: ");
 
        if ((flash_size = flash_init ()) > 0) {
-#ifdef CFG_FLASH_CHECKSUM
+# ifdef CFG_FLASH_CHECKSUM
                print_size (flash_size, "");
                /*
                 * Compute and print flash CRC if flashchecksum is set to 'y'
@@ -668,9 +674,9 @@ void board_init_r (gd_t *id, ulong dest_addr)
                                        );
                }
                putc ('\n');
-#else
+# else /* !CFG_FLASH_CHECKSUM */
                print_size (flash_size, "\n");
-#endif /* CFG_FLASH_CHECKSUM */
+# endif /* CFG_FLASH_CHECKSUM */
        } else {
                puts (failed);
                hang ();
@@ -678,14 +684,14 @@ void board_init_r (gd_t *id, ulong dest_addr)
 
        bd->bi_flashstart = CFG_FLASH_BASE;     /* update start of FLASH memory    */
        bd->bi_flashsize = flash_size;  /* size of FLASH memory (final value) */
-#if defined(CONFIG_PCU_E) || defined(CONFIG_OXC)
+# if defined(CONFIG_PCU_E) || defined(CONFIG_OXC)
        bd->bi_flashoffset = 0;
-#elif CFG_MONITOR_BASE == CFG_FLASH_BASE
+# elif CFG_MONITOR_BASE == CFG_FLASH_BASE
        bd->bi_flashoffset = monitor_flash_len; /* reserved area for startup monitor  */
-#else
+# else
        bd->bi_flashoffset = 0;
-#endif
-#else
+# endif
+#else  /* CFG_NO_FLASH */
 
        bd->bi_flashsize = 0;
        bd->bi_flashstart = 0;
@@ -742,7 +748,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");
@@ -753,11 +760,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)
@@ -765,6 +777,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)
@@ -786,13 +812,11 @@ void board_init_r (gd_t *id, ulong dest_addr)
        /* Initialize devices */
        devices_init ();
 
-       /* allocate syscalls table (console_init_r will fill it in */
-       syscall_tbl = (void **) malloc (NR_SYSCALLS * sizeof (void *));
+       /* Initialize the jump table for applications */
+       jumptable_init ();
 
        /* Initialize the console (after the relocation and devices init) */
        console_init_r ();
-/** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **/
-       syscalls_init ();
 
 #if defined(CONFIG_CCM)                || \
     defined(CONFIG_COGENT)     || \
@@ -822,6 +846,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)   )
@@ -887,6 +912,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
 
@@ -898,10 +924,6 @@ void board_init_r (gd_t *id, ulong dest_addr)
 
 #ifdef CONFIG_POST
        post_run (NULL, POST_RAM | post_bootmode_get(0));
-       if (post_bootmode_get(0) & POST_POWERFAIL) {
-               post_bootmode_clear();
-               board_poweroff();
-       }
 #endif
 
 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA) && !(CONFIG_COMMANDS & CFG_CMD_IDE)
@@ -963,6 +985,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;