Merge branch 'master' of git://git.denx.de/u-boot-arm
[oweals/u-boot.git] / board / freescale / mpc8360emds / mpc8360emds.c
index a0114f6c299c478c5bc2bc9f6fed8c38724fc139..5ff9dff5870791aa085426f3f1ebc18c88d22bf0 100644 (file)
@@ -1,14 +1,8 @@
 /*
- * Copyright (C) 2006,2010 Freescale Semiconductor, Inc.
+ * Copyright (C) 2006,2010-2011 Freescale Semiconductor, Inc.
  * Dave Liu <daveliu@freescale.com>
  *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
 #include <i2c.h>
 #include <miiphy.h>
 #include <phy.h>
+#include <fsl_mdio.h>
 #if defined(CONFIG_PCI)
 #include <pci.h>
 #endif
 #include <spd_sdram.h>
 #include <asm/mmu.h>
 #include <asm/io.h>
-#include <asm/fsl_enet.h>
+#include <asm/mmu.h>
 #if defined(CONFIG_OF_LIBFDT)
 #include <libfdt.h>
 #endif
@@ -139,9 +134,20 @@ int board_early_init_f(void)
 
 int board_early_init_r(void)
 {
+       gd_t *gd;
 #ifdef CONFIG_PQ_MDS_PIB
        pib_init();
 #endif
+       /*
+        * BAT6 is used for SDRAM when DDR size is 512MB or larger than 256MB
+        * So re-setup PCI MEM space used BAT5 after relocated to DDR
+        */
+       gd = (gd_t *)(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET);
+       if (gd->ram_size > CONFIG_MAX_MEM_MAPPED) {
+               write_bat(DBAT5, CONFIG_SYS_DBAT6U, CONFIG_SYS_DBAT6L);
+               write_bat(IBAT5, CONFIG_SYS_IBAT6U, CONFIG_SYS_IBAT6L);
+       }
+
        return 0;
 }
 
@@ -160,10 +166,11 @@ int board_eth_init(bd_t *bd)
        if (board_handle_erratum2()) {
                int i;
 
-               for (i = 0; i < ARRAY_SIZE(uec_info); i++)
+               for (i = 0; i < ARRAY_SIZE(uec_info); i++) {
                        uec_info[i].enet_interface_type =
                                PHY_INTERFACE_MODE_RGMII_RXID;
                        uec_info[i].speed = SPEED_1000;
+               }
        }
        return uec_eth_init(bd, uec_info, ARRAY_SIZE(uec_info));
 }
@@ -302,6 +309,19 @@ static int sdram_init(unsigned int base)
        if (rem)
                base = base - rem + sdram_size;
 
+       /*
+        * Setup BAT6 for SDRAM when DDR size is 512MB or larger than 256MB
+        * After relocated to DDR, reuse BAT5 for PCI MEM space
+        */
+       if (base > CONFIG_MAX_MEM_MAPPED) {
+               unsigned long batl = base | BATL_PP_10 | BATL_MEMCOHERENCE;
+               unsigned long batu = base | BATU_BL_64M | BATU_VS | BATU_VP;
+
+               /* Setup the BAT6 for SDRAM */
+               write_bat(DBAT6, batu, batl);
+               write_bat(IBAT6, batu, batl);
+       }
+
        sdram_addr = (uint *)base;
        /*
         * Setup SDRAM Base and Option Registers
@@ -407,7 +427,7 @@ void ft_board_setup(void *blob, bd_t *bd)
                        if (prop) {
                                path = fdt_path_offset(blob, prop);
                                prop = fdt_getprop(blob, path,
-                                                  "phy-connection-type", 0);
+                                                  "phy-connection-type", 0);
                                if (prop && (strcmp(prop, "rgmii-id") == 0))
                                        fdt_fixup_phy_connection(blob, path,
                                                PHY_INTERFACE_MODE_RGMII_RXID);
@@ -419,7 +439,7 @@ void ft_board_setup(void *blob, bd_t *bd)
                        if (prop) {
                                path = fdt_path_offset(blob, prop);
                                prop = fdt_getprop(blob, path,
-                                                  "phy-connection-type", 0);
+                                                  "phy-connection-type", 0);
                                if (prop && (strcmp(prop, "rgmii-id") == 0))
                                        fdt_fixup_phy_connection(blob, path,
                                                PHY_INTERFACE_MODE_RGMII_RXID);