Merge branch 'master' of git://www.denx.de/git/u-boot-ppc4xx
[platform/kernel/u-boot.git] / board / freescale / mpc8641hpcn / mpc8641hpcn.c
index 931be9f..915fb58 100644 (file)
 #include <asm/processor.h>
 #include <asm/immap_86xx.h>
 #include <asm/immap_fsl_pci.h>
-#include <spd.h>
+#include <spd_sdram.h>
 #include <asm/io.h>
-
-#if defined(CONFIG_OF_FLAT_TREE)
-#include <ft_build.h>
-extern void ft_cpu_setup(void *blob, bd_t *bd);
-#endif
+#include <libfdt.h>
+#include <fdt_support.h>
 
 #include "../common/pixis.h"
 
@@ -39,10 +36,6 @@ extern void ft_cpu_setup(void *blob, bd_t *bd);
 extern void ddr_enable_ecc(unsigned int dram_size);
 #endif
 
-#if defined(CONFIG_SPD_EEPROM)
-#include "spd_sdram.h"
-#endif
-
 void sdram_init(void);
 long int fixed_sdram(void);
 
@@ -88,42 +81,6 @@ initdram(int board_type)
 }
 
 
-#if defined(CFG_DRAM_TEST)
-int
-testdram(void)
-{
-       uint *pstart = (uint *) CFG_MEMTEST_START;
-       uint *pend = (uint *) CFG_MEMTEST_END;
-       uint *p;
-
-       puts("SDRAM test phase 1:\n");
-       for (p = pstart; p < pend; p++)
-               *p = 0xaaaaaaaa;
-
-       for (p = pstart; p < pend; p++) {
-               if (*p != 0xaaaaaaaa) {
-                       printf("SDRAM test fails at: %08x\n", (uint) p);
-                       return 1;
-               }
-       }
-
-       puts("SDRAM test phase 2:\n");
-       for (p = pstart; p < pend; p++)
-               *p = 0x55555555;
-
-       for (p = pstart; p < pend; p++) {
-               if (*p != 0x55555555) {
-                       printf("SDRAM test fails at: %08x\n", (uint) p);
-                       return 1;
-               }
-       }
-
-       puts("SDRAM test passed.\n");
-       return 0;
-}
-#endif
-
-
 #if !defined(CONFIG_SPD_EEPROM)
 /*
  * Fixed sdram init -- doesn't use serial presence detect.
@@ -137,7 +94,7 @@ fixed_sdram(void)
 
        ddr->cs0_bnds = CFG_DDR_CS0_BNDS;
        ddr->cs0_config = CFG_DDR_CS0_CONFIG;
-       ddr->ext_refrec = CFG_DDR_EXT_REFRESH;
+       ddr->timing_cfg_3 = CFG_DDR_TIMING_3;
        ddr->timing_cfg_0 = CFG_DDR_TIMING_0;
        ddr->timing_cfg_1 = CFG_DDR_TIMING_1;
        ddr->timing_cfg_2 = CFG_DDR_TIMING_2;
@@ -209,7 +166,8 @@ void pci_init_board(void)
        volatile immap_t *immap = (immap_t *) CFG_CCSRBAR;
        volatile ccsr_gur_t *gur = &immap->im_gur;
        uint devdisr = gur->devdisr;
-       uint io_sel = (gur->pordevsr & MPC86xx_PORDEVSR_IO_SEL) >> 16;
+       uint io_sel = (gur->pordevsr & MPC8641_PORDEVSR_IO_SEL)
+               >> MPC8641_PORDEVSR_IO_SEL_SHIFT;
 
 #ifdef CONFIG_PCI1
 {
@@ -217,7 +175,8 @@ void pci_init_board(void)
        extern void fsl_pci_init(struct pci_controller *hose);
        struct pci_controller *hose = &pci1_hose;
 #ifdef DEBUG
-       uint host1_agent = (gur->porbmsr & MPC86xx_PORBMSR_HA) >> 17;
+       uint host1_agent = (gur->porbmsr & MPC8641_PORBMSR_HA)
+               >> MPC8641_PORBMSR_HA_SHIFT;
        uint pex1_agent = (host1_agent == 0) || (host1_agent == 1);
 #endif
        if ((io_sel == 2 || io_sel == 3 || io_sel == 5
@@ -324,36 +283,35 @@ void pci_init_board(void)
 
 }
 
-#if defined(CONFIG_OF_FLAT_TREE) && defined(CONFIG_OF_BOARD_SETUP)
+
+#if defined(CONFIG_OF_BOARD_SETUP)
+
 void
 ft_board_setup(void *blob, bd_t *bd)
 {
-       u32 *p;
-       int len;
+       int node, tmp[2];
+       const char *path;
 
        ft_cpu_setup(blob, bd);
 
-       p = ft_get_prop(blob, "/memory/reg", &len);
-       if (p != NULL) {
-               *p++ = cpu_to_be32(bd->bi_memstart);
-               *p = cpu_to_be32(bd->bi_memsize);
-       }
+       node = fdt_path_offset(blob, "/aliases");
+       tmp[0] = 0;
+       if (node >= 0) {
 #ifdef CONFIG_PCI1
-       p = (u32 *)ft_get_prop(blob, "/" OF_SOC "/pcie@8000/bus-range", &len);
-       if (p != NULL) {
-               p[0] = 0;
-               p[1] = pci1_hose.last_busno - pci1_hose.first_busno;
-               debug("PCI@8000 first_busno=%d last_busno=%d\n",p[0],p[1]);
-       }
+               path = fdt_getprop(blob, node, "pci0", NULL);
+               if (path) {
+                       tmp[1] = pci1_hose.last_busno - pci1_hose.first_busno;
+                       do_fixup_by_path(blob, path, "bus-range", &tmp, 8, 1);
+               }
 #endif
 #ifdef CONFIG_PCI2
-       p = (u32 *)ft_get_prop(blob, "/" OF_SOC "/pcie@9000/bus-range", &len);
-       if (p != NULL) {
-               p[0] = 0;
-               p[1] = pci2_hose.last_busno - pci2_hose.first_busno;
-               debug("PCI@9000 first_busno=%d last_busno=%d\n",p[0],p[1]);
-       }
+               path = fdt_getprop(blob, node, "pci1", NULL);
+               if (path) {
+                       tmp[1] = pci2_hose.last_busno - pci2_hose.first_busno;
+                       do_fixup_by_path(blob, path, "bus-range", &tmp, 8, 1);
+               }
 #endif
+       }
 }
 #endif