]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - arch/arm/cpu/armv7/omap-common/hwinit-common.c
Merge remote-tracking branch 'u-boot-samsung/master'
[karo-tx-uboot.git] / arch / arm / cpu / armv7 / omap-common / hwinit-common.c
index 9ef10bdf2da272bc63482c939b4a6f153f4f1099..5f50a1980157d646b1308bf8d98b529009d40d1e 100644 (file)
@@ -9,29 +9,16 @@
  *     Aneesh V        <aneesh@ti.com>
  *     Steve Sakoman   <steve@sakoman.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.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 #include <common.h>
 #include <spl.h>
 #include <asm/arch/sys_proto.h>
-#include <asm/sizes.h>
+#include <linux/sizes.h>
 #include <asm/emif.h>
+#include <asm/omap_common.h>
+#include <linux/compiler.h>
+#include <asm/system.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -51,16 +38,10 @@ 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;
        }
 }
@@ -76,29 +57,44 @@ u32 cortex_rev(void)
        return rev;
 }
 
-void omap_rev_string(void)
+static void omap_rev_string(void)
 {
        u32 omap_rev = omap_revision();
+       u32 soc_variant = (omap_rev & 0xF0000000) >> 28;
        u32 omap_variant = (omap_rev & 0xFFFF0000) >> 16;
        u32 major_rev = (omap_rev & 0x00000F00) >> 8;
        u32 minor_rev = (omap_rev & 0x000000F0) >> 4;
 
-       printf("OMAP%x ES%x.%x\n", omap_variant, major_rev,
-               minor_rev);
+       if (soc_variant)
+               printf("OMAP");
+       else
+               printf("DRA");
+       printf("%x ES%x.%x\n", omap_variant, major_rev,
+              minor_rev);
 }
 
 #ifdef CONFIG_SPL_BUILD
-static void init_boot_params(void)
-{
-       boot_params_ptr = (u32 *) &boot_params;
-}
-
 void spl_display_print(void)
 {
        omap_rev_string();
 }
 #endif
 
+void __weak srcomp_enable(void)
+{
+}
+
+#ifdef CONFIG_ARCH_CPU_INIT
+/*
+ * SOC specific cpu init
+ */
+int arch_cpu_init(void)
+{
+       save_omap_boot_params();
+       return 0;
+}
+#endif /* CONFIG_ARCH_CPU_INIT */
+
 /*
  * Routine: s_init
  * Description: Does early system init of watchdog, muxing,  andclocks
@@ -115,7 +111,17 @@ void spl_display_print(void)
  */
 void s_init(void)
 {
+       /*
+        * Save the boot parameters passed from romcode.
+        * We cannot delay the saving further than this,
+        * to prevent overwrites.
+        */
+#ifdef CONFIG_SPL_BUILD
+       save_omap_boot_params();
+#endif
        init_omap_revision();
+       hw_data_init();
+
 #ifdef CONFIG_SPL_BUILD
        if (warm_reset() && (omap_revision() <= OMAP5430_ES1_0))
                force_emif_self_refresh();
@@ -123,6 +129,7 @@ void s_init(void)
        watchdog_init();
        set_mux_conf_regs();
 #ifdef CONFIG_SPL_BUILD
+       srcomp_enable();
        setup_clocks_for_console();
 
        gd = &gdata;
@@ -132,11 +139,8 @@ void s_init(void)
 #endif
        prcm_init();
 #ifdef CONFIG_SPL_BUILD
-       timer_init();
-
        /* For regular u-boot sdram_init() is called from dram_init() */
        sdram_init();
-       init_boot_params();
 #endif
 }
 
@@ -176,7 +180,7 @@ u32 omap_sdram_size(void)
 {
        u32 section, i, valid;
        u64 sdram_start = 0, sdram_end = 0, addr,
-           size, total_size = 0, trap_size = 0;
+           size, total_size = 0, trap_size = 0, trap_start = 0;
 
        for (i = 0; i < 4; i++) {
                section = __raw_readl(DMM_BASE + i*4);
@@ -185,8 +189,8 @@ u32 omap_sdram_size(void)
                addr = section & EMIF_SYS_ADDR_MASK;
 
                /* See if the address is valid */
-               if ((addr >= DRAM_ADDR_SPACE_START) &&
-                   (addr < DRAM_ADDR_SPACE_END)) {
+               if ((addr >= TI_ARMV7_DRAM_ADDR_SPACE_START) &&
+                   (addr < TI_ARMV7_DRAM_ADDR_SPACE_END)) {
                        size = ((section & EMIF_SYS_SIZE_MASK) >>
                                   EMIF_SYS_SIZE_SHIFT);
                        size = 1 << size;
@@ -199,12 +203,15 @@ u32 omap_sdram_size(void)
                                        sdram_end = addr + size;
                        } else {
                                trap_size = size;
+                               trap_start = addr;
                        }
-
                }
-
        }
-       total_size = (sdram_end - sdram_start) - (trap_size);
+
+       if ((trap_start >= sdram_start) && (trap_start < sdram_end))
+               total_size = (sdram_end - sdram_start) - (trap_size);
+       else
+               total_size = sdram_end - sdram_start;
 
        return total_size;
 }
@@ -235,13 +242,11 @@ int checkboard(void)
  */
 u32 get_device_type(void)
 {
-       struct omap_sys_ctrl_regs *ctrl =
-                     (struct omap_sys_ctrl_regs *) SYSCTRL_GENERAL_CORE_BASE;
-
-       return (readl(&ctrl->control_status) &
+       return (readl((*ctrl)->control_status) &
                                      (DEVICE_TYPE_MASK)) >> DEVICE_TYPE_SHIFT;
 }
 
+#if defined(CONFIG_DISPLAY_CPUINFO)
 /*
  * Print CPU information
  */
@@ -252,10 +257,4 @@ int print_cpuinfo(void)
 
        return 0;
 }
-#ifndef CONFIG_SYS_DCACHE_OFF
-void enable_caches(void)
-{
-       /* Enable D-cache. I-cache is already enabled in start.S */
-       dcache_enable();
-}
 #endif