mpc83xx: Fix the bug of serdes initialization
[oweals/u-boot.git] / board / tqm5200 / tqm5200.c
index cb57a5e269417b459eb14779cc3eb7540463f305..e67145eb5be562eeb4790567b5b43cf225e5f63c 100644 (file)
@@ -31,6 +31,7 @@
 #include <mpc5xxx.h>
 #include <pci.h>
 #include <asm/processor.h>
+#include <libfdt.h>
 
 #ifdef CONFIG_VIDEO_SM501
 #include <sm501.h>
 #include "mt48lc16m16a2-75.h"
 #endif
 
+#ifdef CONFIG_OF_LIBFDT
+#include <fdt_support.h>
+#endif /* CONFIG_OF_LIBFDT */
+
+DECLARE_GLOBAL_DATA_PTR;
+
 #ifdef CONFIG_PS2MULT
 void ps2mult_early_init(void);
 #endif
@@ -97,7 +104,6 @@ static void sdram_start (int hi_addr)
  *           is something else than 0x00000000.
  */
 
-#if defined(CONFIG_MPC5200)
 long int initdram (int board_type)
 {
        ulong dramsize = 0;
@@ -152,10 +158,13 @@ long int initdram (int board_type)
        *(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize + 0x0000001c; /* 512MB */
 
        /* find RAM size using SDRAM CS1 only */
-       sdram_start(0);
-       test1 = get_ram_size((long *)(CFG_SDRAM_BASE + dramsize), 0x20000000);
-       sdram_start(1);
-       test2 = get_ram_size((long *)(CFG_SDRAM_BASE + dramsize), 0x20000000);
+       if (!dramsize)
+               sdram_start(0);
+       test2 = test1 = get_ram_size((long *)(CFG_SDRAM_BASE + dramsize), 0x20000000);
+       if (!dramsize) {
+               sdram_start(1);
+               test2 = get_ram_size((long *)(CFG_SDRAM_BASE + dramsize), 0x20000000);
+       }
        if (test1 > test2) {
                sdram_start(0);
                dramsize2 = test1;
@@ -220,57 +229,6 @@ long int initdram (int board_type)
 #endif /* CONFIG_TQM5200_B */
 }
 
-#elif defined(CONFIG_MGT5100)
-
-long int initdram (int board_type)
-{
-       ulong dramsize = 0;
-#ifndef CFG_RAMBOOT
-       ulong test1, test2;
-
-       /* setup and enable SDRAM chip selects */
-       *(vu_long *)MPC5XXX_SDRAM_START = 0x00000000;
-       *(vu_long *)MPC5XXX_SDRAM_STOP = 0x0000ffff;/* 2G */
-       *(vu_long *)MPC5XXX_ADDECR |= (1 << 22); /* Enable SDRAM */
-       __asm__ volatile ("sync");
-
-       /* setup config registers */
-       *(vu_long *)MPC5XXX_SDRAM_CONFIG1 = SDRAM_CONFIG1;
-       *(vu_long *)MPC5XXX_SDRAM_CONFIG2 = SDRAM_CONFIG2;
-
-       /* address select register */
-       *(vu_long *)MPC5XXX_SDRAM_XLBSEL = SDRAM_ADDRSEL;
-       __asm__ volatile ("sync");
-
-       /* find RAM size */
-       sdram_start(0);
-       test1 = get_ram_size((ulong *)CFG_SDRAM_BASE, 0x80000000);
-       sdram_start(1);
-       test2 = get_ram_size((ulong *)CFG_SDRAM_BASE, 0x80000000);
-       if (test1 > test2) {
-               sdram_start(0);
-               dramsize = test1;
-       } else {
-               dramsize = test2;
-       }
-
-       /* set SDRAM end address according to size */
-       *(vu_long *)MPC5XXX_SDRAM_STOP = ((dramsize - 1) >> 15);
-
-#else /* CFG_RAMBOOT */
-
-       /* Retrieve amount of SDRAM available */
-       dramsize = ((*(vu_long *)MPC5XXX_SDRAM_STOP + 1) << 15);
-
-#endif /* CFG_RAMBOOT */
-
-       return dramsize;
-}
-
-#else
-#error Neither CONFIG_MPC5200 or CONFIG_MGT5100 defined
-#endif
-
 int checkboard (void)
 {
 #if defined(CONFIG_AEVFIFO)
@@ -289,7 +247,7 @@ int checkboard (void)
 #elif defined(CONFIG_TB5200)
 # define CARRIER_NAME  "TB5200"
 #elif defined(CONFIG_CAM5200)
-# define CARRIER_NAME  "Cam5200"
+# define CARRIER_NAME  "CAM5200"
 #elif defined(CONFIG_FO300)
 # define CARRIER_NAME  "FO300"
 #else
@@ -313,10 +271,6 @@ void flash_preinit(void)
         * Note that CS_BOOT cannot be cleared when
         * executing in flash.
         */
-#if defined(CONFIG_MGT5100)
-       *(vu_long *)MPC5XXX_ADDECR &= ~(1 << 25); /* disable CS_BOOT */
-       *(vu_long *)MPC5XXX_ADDECR |= (1 << 16); /* enable CS0 */
-#endif
        *(vu_long *)MPC5XXX_BOOTCS_CFG &= ~0x1; /* clear RO */
 }
 
@@ -332,7 +286,7 @@ void pci_init_board(void)
 }
 #endif
 
-#if defined (CFG_CMD_IDE) && defined (CONFIG_IDE_RESET)
+#if defined(CONFIG_CMD_IDE) && defined(CONFIG_IDE_RESET)
 
 #if defined (CONFIG_MINIFAP)
 #define SM501_POWER_MODE0_GATE         0x00000040UL
@@ -385,7 +339,7 @@ void ide_set_reset (int idereset)
        }
 #endif
 }
-#endif /* defined (CFG_CMD_IDE) && defined (CONFIG_IDE_RESET) */
+#endif
 
 #ifdef CONFIG_POST
 /*
@@ -438,15 +392,24 @@ ulong post_word_load (void)
 }
 #endif /* CONFIG_POST || CONFIG_LOGBUFFER*/
 
-#ifdef CONFIG_PS2MULT
 #ifdef CONFIG_BOARD_EARLY_INIT_R
 int board_early_init_r (void)
 {
+
+       extern int usb_cpu_init(void);
+
+#ifdef CONFIG_PS2MULT
        ps2mult_early_init();
+#endif /* CONFIG_PS2MULT */
+
+#if defined(CONFIG_USB_OHCI_NEW) && defined(CFG_USB_OHCI_CPU_INIT)
+       /* Low level USB init, required for proper kernel operation */
+       usb_cpu_init();
+#endif
+
        return (0);
 }
 #endif
-#endif /* CONFIG_PS2MULT */
 
 #ifdef CONFIG_FO300
 int silent_boot (void)
@@ -476,8 +439,6 @@ int silent_boot (void)
 
 int board_early_init_f (void)
 {
-       DECLARE_GLOBAL_DATA_PTR;
-
        if (silent_boot())
                gd->flags |= GD_FLG_SILENT;
 
@@ -542,6 +503,7 @@ int last_stage_init (void)
                __asm__ volatile ("sync");
        }
 
+#ifndef CONFIG_TQM5200S        /* The TQM5200S has no SM501 grafic controller */
        /*
         * Check for Grafic Controller
         */
@@ -583,6 +545,7 @@ int last_stage_init (void)
                disable_ctrlc(1);
        }
 #endif
+#endif /* !CONFIG_TQM5200S */
 
        return 0;
 }
@@ -775,3 +738,11 @@ int board_get_height (void)
 }
 
 #endif /* CONFIG_VIDEO_SM501 */
+
+#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
+void ft_board_setup(void *blob, bd_t *bd)
+{
+       ft_cpu_setup(blob, bd);
+       fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
+}
+#endif /* defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) */