Merge branch 'master' of git://git.denx.de/u-boot-arm
[platform/kernel/u-boot.git] / board / freescale / mpc8536ds / mpc8536ds.c
index 6fed4ea..8c5984b 100644 (file)
@@ -27,7 +27,7 @@
 #include <asm/mmu.h>
 #include <asm/cache.h>
 #include <asm/immap_85xx.h>
-#include <asm/immap_fsl_pci.h>
+#include <asm/fsl_pci.h>
 #include <asm/fsl_ddr_sdram.h>
 #include <asm/io.h>
 #include <spd.h>
 #include <fdt_support.h>
 #include <tsec.h>
 #include <netdev.h>
+#include <sata.h>
 
 #include "../common/pixis.h"
 #include "../common/sgmii_riser.h"
 
-#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
-extern void ddr_enable_ecc(unsigned int dram_size);
-#endif
-
 phys_size_t fixed_sdram(void);
 
+int board_early_init_f (void)
+{
+#ifdef CONFIG_MMC
+       volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
+
+       setbits_be32(&gur->pmuxcr,
+                       (MPC85xx_PMUXCR_SD_DATA |
+                        MPC85xx_PMUXCR_SDHC_CD |
+                        MPC85xx_PMUXCR_SDHC_WP));
+
+#endif
+       return 0;
+}
+
 int checkboard (void)
 {
-       printf ("Board: MPC8536DS, System ID: 0x%02x, "
-               "System Version: 0x%02x, FPGA Version: 0x%02x\n",
-               in8(PIXIS_BASE + PIXIS_ID), in8(PIXIS_BASE + PIXIS_VER),
-               in8(PIXIS_BASE + PIXIS_PVER));
+       u8 vboot;
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
+
+       puts("Board: MPC8536DS ");
+#ifdef CONFIG_PHYS_64BIT
+       puts("(36-bit addrmap) ");
+#endif
+
+       printf ("Sys ID: 0x%02x, "
+               "Sys Ver: 0x%02x, FPGA Ver: 0x%02x, ",
+               in_8(pixis_base + PIXIS_ID), in_8(pixis_base + PIXIS_VER),
+               in_8(pixis_base + PIXIS_PVER));
+
+       vboot = in_8(pixis_base + PIXIS_VBOOT);
+       switch ((vboot & PIXIS_VBOOT_LBMAP) >> 5) {
+               case PIXIS_VBOOT_LBMAP_NOR0:
+                       puts ("vBank: 0\n");
+                       break;
+               case PIXIS_VBOOT_LBMAP_NOR1:
+                       puts ("vBank: 1\n");
+                       break;
+               case PIXIS_VBOOT_LBMAP_NOR2:
+                       puts ("vBank: 2\n");
+                       break;
+               case PIXIS_VBOOT_LBMAP_NOR3:
+                       puts ("vBank: 3\n");
+                       break;
+               case PIXIS_VBOOT_LBMAP_PJET:
+                       puts ("Promjet\n");
+                       break;
+               case PIXIS_VBOOT_LBMAP_NAND:
+                       puts ("NAND\n");
+                       break;
+       }
+
        return 0;
 }
 
@@ -65,20 +107,12 @@ initdram(int board_type)
 
 #ifdef CONFIG_SPD_EEPROM
        dram_size = fsl_ddr_sdram();
-
-       dram_size = setup_ddr_tlbs(dram_size / 0x100000);
-
-       dram_size *= 0x100000;
 #else
        dram_size = fixed_sdram();
 #endif
+       dram_size = setup_ddr_tlbs(dram_size / 0x100000);
+       dram_size *= 0x100000;
 
-#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
-       /*
-        * Initialize and enable DDR ECC.
-        */
-       ddr_enable_ecc(dram_size);
-#endif
        puts("    DDR: ");
        return dram_size;
 }
@@ -155,9 +189,6 @@ static struct pci_controller pcie2_hose;
 static struct pci_controller pcie3_hose;
 #endif
 
-extern int fsl_pci_setup_inbound_windows(struct pci_region *r);
-extern void fsl_pci_init(struct pci_controller *hose);
-
 int first_free_busno=0;
 
 void
@@ -204,14 +235,14 @@ pci_init_board(void)
 
                /* outbound memory */
                pci_set_region(r++,
-                              CONFIG_SYS_PCIE3_MEM_BASE,
+                              CONFIG_SYS_PCIE3_MEM_BUS,
                               CONFIG_SYS_PCIE3_MEM_PHYS,
                               CONFIG_SYS_PCIE3_MEM_SIZE,
                               PCI_REGION_MEM);
 
                /* outbound io */
                pci_set_region(r++,
-                              CONFIG_SYS_PCIE3_IO_BASE,
+                              CONFIG_SYS_PCIE3_IO_BUS,
                               CONFIG_SYS_PCIE3_IO_PHYS,
                               CONFIG_SYS_PCIE3_IO_SIZE,
                               PCI_REGION_IO);
@@ -259,22 +290,22 @@ pci_init_board(void)
 
                /* outbound memory */
                pci_set_region(r++,
-                              CONFIG_SYS_PCIE1_MEM_BASE,
+                              CONFIG_SYS_PCIE1_MEM_BUS,
                               CONFIG_SYS_PCIE1_MEM_PHYS,
                               CONFIG_SYS_PCIE1_MEM_SIZE,
                               PCI_REGION_MEM);
 
                /* outbound io */
                pci_set_region(r++,
-                              CONFIG_SYS_PCIE1_IO_BASE,
+                              CONFIG_SYS_PCIE1_IO_BUS,
                               CONFIG_SYS_PCIE1_IO_PHYS,
                               CONFIG_SYS_PCIE1_IO_SIZE,
                               PCI_REGION_IO);
 
-#ifdef CONFIG_SYS_PCIE1_MEM_BASE2
+#ifdef CONFIG_SYS_PCIE1_MEM_BUS2
                /* outbound memory */
                pci_set_region(r++,
-                              CONFIG_SYS_PCIE1_MEM_BASE2,
+                              CONFIG_SYS_PCIE1_MEM_BUS2,
                               CONFIG_SYS_PCIE1_MEM_PHYS2,
                               CONFIG_SYS_PCIE1_MEM_SIZE2,
                               PCI_REGION_MEM);
@@ -322,22 +353,22 @@ pci_init_board(void)
 
                /* outbound memory */
                pci_set_region(r++,
-                              CONFIG_SYS_PCIE2_MEM_BASE,
+                              CONFIG_SYS_PCIE2_MEM_BUS,
                               CONFIG_SYS_PCIE2_MEM_PHYS,
                               CONFIG_SYS_PCIE2_MEM_SIZE,
                               PCI_REGION_MEM);
 
                /* outbound io */
                pci_set_region(r++,
-                              CONFIG_SYS_PCIE2_IO_BASE,
+                              CONFIG_SYS_PCIE2_IO_BUS,
                               CONFIG_SYS_PCIE2_IO_PHYS,
                               CONFIG_SYS_PCIE2_IO_SIZE,
                               PCI_REGION_IO);
 
-#ifdef CONFIG_SYS_PCIE2_MEM_BASE2
+#ifdef CONFIG_SYS_PCIE2_MEM_BUS2
                /* outbound memory */
                pci_set_region(r++,
-                              CONFIG_SYS_PCIE2_MEM_BASE2,
+                              CONFIG_SYS_PCIE2_MEM_BUS2,
                               CONFIG_SYS_PCIE2_MEM_PHYS2,
                               CONFIG_SYS_PCIE2_MEM_SIZE2,
                               PCI_REGION_MEM);
@@ -390,22 +421,22 @@ pci_init_board(void)
 
                /* outbound memory */
                pci_set_region(r++,
-                              CONFIG_SYS_PCI1_MEM_BASE,
+                              CONFIG_SYS_PCI1_MEM_BUS,
                               CONFIG_SYS_PCI1_MEM_PHYS,
                               CONFIG_SYS_PCI1_MEM_SIZE,
                               PCI_REGION_MEM);
 
                /* outbound io */
                pci_set_region(r++,
-                              CONFIG_SYS_PCI1_IO_BASE,
+                              CONFIG_SYS_PCI1_IO_BUS,
                               CONFIG_SYS_PCI1_IO_PHYS,
                               CONFIG_SYS_PCI1_IO_SIZE,
                               PCI_REGION_IO);
 
-#ifdef CONFIG_SYS_PCI1_MEM_BASE2
+#ifdef CONFIG_SYS_PCI1_MEM_BUS2
                /* outbound memory */
                pci_set_region(r++,
-                              CONFIG_SYS_PCI1_MEM_BASE2,
+                              CONFIG_SYS_PCI1_MEM_BUS2,
                               CONFIG_SYS_PCI1_MEM_PHYS2,
                               CONFIG_SYS_PCI1_MEM_SIZE2,
                               PCI_REGION_MEM);
@@ -445,7 +476,7 @@ int board_early_init_r(void)
        /* invalidate existing TLB entry for flash + promjet */
        disable_tlb(flash_esel);
 
-       set_tlb(1, flashbase, flashbase,                /* tlb, epn, rpn */
+       set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS,       /* tlb, epn, rpn */
                MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, /* perms, wimge */
                0, flash_esel, BOOKE_PAGESZ_256M, 1);   /* ts, esel, tsize, iprot */
 
@@ -498,20 +529,24 @@ ics307_clk_freq (unsigned char cw0, unsigned char cw1, unsigned char cw2)
 unsigned long
 get_board_sys_clk(ulong dummy)
 {
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
+
        return ics307_clk_freq (
-           in8(PIXIS_BASE + PIXIS_VSYSCLK0),
-           in8(PIXIS_BASE + PIXIS_VSYSCLK1),
-           in8(PIXIS_BASE + PIXIS_VSYSCLK2)
+           in_8(pixis_base + PIXIS_VSYSCLK0),
+           in_8(pixis_base + PIXIS_VSYSCLK1),
+           in_8(pixis_base + PIXIS_VSYSCLK2)
        );
 }
 
 unsigned long
 get_board_ddr_clk(ulong dummy)
 {
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
+
        return ics307_clk_freq (
-           in8(PIXIS_BASE + PIXIS_VDDRCLK0),
-           in8(PIXIS_BASE + PIXIS_VDDRCLK1),
-           in8(PIXIS_BASE + PIXIS_VDDRCLK2)
+           in_8(pixis_base + PIXIS_VDDRCLK0),
+           in_8(pixis_base + PIXIS_VDDRCLK1),
+           in_8(pixis_base + PIXIS_VDDRCLK2)
        );
 }
 #else
@@ -520,8 +555,9 @@ get_board_sys_clk(ulong dummy)
 {
        u8 i;
        ulong val = 0;
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
 
-       i = in8(PIXIS_BASE + PIXIS_SPD);
+       i = in_8(pixis_base + PIXIS_SPD);
        i &= 0x07;
 
        switch (i) {
@@ -559,8 +595,9 @@ get_board_ddr_clk(ulong dummy)
 {
        u8 i;
        ulong val = 0;
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
 
-       i = in8(PIXIS_BASE + PIXIS_SPD);
+       i = in_8(pixis_base + PIXIS_SPD);
        i &= 0x38;
        i >>= 3;
 
@@ -594,15 +631,15 @@ get_board_ddr_clk(ulong dummy)
 }
 #endif
 
-int is_sata_supported(void)
+int sata_initialize(void)
 {
        volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
        uint sdrs2_io_sel =
                (gur->pordevsr & MPC85xx_PORDEVSR_SRDS2_IO_SEL) >> 27;
        if (sdrs2_io_sel & 0x04)
-               return 0;
+               return 1;
 
-       return 1;
+       return __sata_initialize();
 }
 
 int board_eth_init(bd_t *bis)
@@ -636,8 +673,10 @@ int board_eth_init(bd_t *bis)
                return 0;
        }
 
+#ifdef CONFIG_FSL_SGMII_RISER
        if ((sdrs2_io_sel == 4) || (sdrs2_io_sel == 6))
                fsl_sgmii_riser_init(tsec_info, num);
+#endif
 
        tsec_eth_init(bis, tsec_info, num);
 #endif
@@ -645,9 +684,6 @@ int board_eth_init(bd_t *bis)
 }
 
 #if defined(CONFIG_OF_BOARD_SETUP)
-extern void ft_fsl_pci_setup(void *blob, const char *pci_alias,
-                       struct pci_controller *hose);
-
 void ft_board_setup(void *blob, bd_t *bd)
 {
        ft_cpu_setup(blob, bd);
@@ -664,5 +700,8 @@ void ft_board_setup(void *blob, bd_t *bd)
 #ifdef CONFIG_PCIE1
        ft_fsl_pci_setup(blob, "pci3", &pcie3_hose);
 #endif
+#ifdef CONFIG_FSL_SGMII_RISER
+       fsl_sgmii_riser_fdt_fixup(blob);
+#endif
 }
 #endif