omap4: emif: fix error in driver
[oweals/u-boot.git] / arch / arm / cpu / armv7 / omap-common / hwinit-common.c
index 2ab16bfebf65955c288f043cdcba843685b7605b..f65705db12329f54fcca00f4aa3da358d91dea14 100644 (file)
 #include <common.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/sizes.h>
-#include <asm/arch/emif.h>
+#include <asm/emif.h>
+#include <asm/omap_common.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
+/*
+ * This is used to verify if the configuration header
+ * was executed by rom code prior to control of transfer
+ * to the bootloader. SPL is responsible for saving and
+ * passing the boot_params pointer to the u-boot.
+ */
+struct omap_boot_parameters boot_params __attribute__ ((section(".data")));
+
 #ifdef CONFIG_SPL_BUILD
 /*
  * We use static variables because global data is not ready yet.
@@ -41,12 +50,11 @@ DECLARE_GLOBAL_DATA_PTR;
  * We would not typically need to save these parameters in regular
  * U-Boot. This is needed only in SPL at the moment.
  */
-u32 omap_bootdevice = BOOT_DEVICE_MMC1;
 u32 omap_bootmode = MMCSD_MODE_FAT;
 
 u32 omap_boot_device(void)
 {
-       return omap_bootdevice;
+       return (u32) (boot_params.omap_bootdevice);
 }
 
 u32 omap_boot_mode(void)
@@ -71,12 +79,16 @@ static void set_mux_conf_regs(void)
                set_muxconf_regs_essential();
                break;
        case OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL:
+#ifdef CONFIG_SYS_ENABLE_PADS_ALL
                set_muxconf_regs_non_essential();
+#endif
                break;
        case OMAP_INIT_CONTEXT_UBOOT_FROM_NOR:
        case OMAP_INIT_CONTEXT_UBOOT_AFTER_CH:
                set_muxconf_regs_essential();
+#ifdef CONFIG_SYS_ENABLE_PADS_ALL
                set_muxconf_regs_non_essential();
+#endif
                break;
        }
 }
@@ -103,6 +115,13 @@ void omap_rev_string(char *omap_rev_string)
                minor_rev);
 }
 
+#ifdef CONFIG_SPL_BUILD
+static void init_boot_params(void)
+{
+       boot_params_ptr = (u32 *) &boot_params;
+}
+#endif
+
 /*
  * Routine: s_init
  * Description: Does early system init of watchdog, muxing,  andclocks
@@ -131,6 +150,7 @@ void s_init(void)
 #ifdef CONFIG_SPL_BUILD
        /* For regular u-boot sdram_init() is called from dram_init() */
        sdram_init();
+       init_boot_params();
 #endif
 }
 
@@ -169,19 +189,21 @@ void watchdog_init(void)
 u32 omap_sdram_size(void)
 {
        u32 section, i, total_size = 0, size, addr;
+
        for (i = 0; i < 4; i++) {
-               section = __raw_readl(OMAP44XX_DMM_LISA_MAP_BASE + i*4);
-               addr = section & OMAP44XX_SYS_ADDR_MASK;
+               section = __raw_readl(DMM_BASE + i*4);
+               addr = section & EMIF_SYS_ADDR_MASK;
                /* See if the address is valid */
-               if ((addr >= OMAP44XX_DRAM_ADDR_SPACE_START) &&
-                   (addr < OMAP44XX_DRAM_ADDR_SPACE_END)) {
-                       size    = ((section & OMAP44XX_SYS_SIZE_MASK) >>
-                                  OMAP44XX_SYS_SIZE_SHIFT);
-                       size    = 1 << size;
-                       size    *= SZ_16M;
+               if ((addr >= DRAM_ADDR_SPACE_START) &&
+                   (addr < DRAM_ADDR_SPACE_END)) {
+                       size = ((section & EMIF_SYS_SIZE_MASK) >>
+                                  EMIF_SYS_SIZE_SHIFT);
+                       size = 1 << size;
+                       size *= SZ_16M;
                        total_size += size;
                }
        }
+
        return total_size;
 }