Merge branch 'master' of git://git.denx.de/u-boot-spi
[oweals/u-boot.git] / arch / arm / mach-omap2 / hwinit-common.c
index 7324d522ee6e06a61a9fc8f8860f4295bfbae9a5..772b4c4db5dc495f5f30f43657eb9742a21a9f37 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  *
  * Common functions for OMAP4/5 based boards
@@ -8,11 +9,10 @@
  * Author :
  *     Aneesh V        <aneesh@ti.com>
  *     Steve Sakoman   <steve@sakoman.com>
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 #include <common.h>
 #include <debug_uart.h>
+#include <fdtdec.h>
 #include <spl.h>
 #include <asm/arch/sys_proto.h>
 #include <linux/sizes.h>
@@ -20,6 +20,7 @@
 #include <asm/omap_common.h>
 #include <linux/compiler.h>
 #include <asm/system.h>
+#include <dm/root.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -66,7 +67,7 @@ static void omap_rev_string(void)
        u32 major_rev = (omap_rev & 0x00000F00) >> 8;
        u32 minor_rev = (omap_rev & 0x000000F0) >> 4;
 
-       const char *sec_s;
+       const char *sec_s, *package = NULL;
 
        switch (get_device_type()) {
        case TST_DEVICE:
@@ -85,11 +86,29 @@ static void omap_rev_string(void)
                sec_s = "?";
        }
 
+#if defined(CONFIG_DRA7XX)
+       if (is_dra76x()) {
+               switch (omap_rev & 0xF) {
+               case DRA762_ABZ_PACKAGE:
+                       package = "ABZ";
+                       break;
+               case DRA762_ACD_PACKAGE:
+               default:
+                       package = "ACD";
+                       break;
+               }
+       }
+#endif
+
        if (soc_variant)
                printf("OMAP");
        else
                printf("DRA");
-       printf("%x-%s ES%x.%x\n", omap_variant, sec_s, major_rev, minor_rev);
+       printf("%x-%s ES%x.%x", omap_variant, sec_s, major_rev, minor_rev);
+       if (package)
+               printf(" %s package\n", package);
+       else
+               puts("\n");
 }
 
 #ifdef CONFIG_SPL_BUILD
@@ -127,6 +146,16 @@ void s_init(void)
 {
 }
 
+/**
+ * init_package_revision() - Initialize package revision
+ *
+ * Function to get the pacakage information. This is expected to be
+ * overridden in the SoC family file where desired.
+ */
+void __weak init_package_revision(void)
+{
+}
+
 /**
  * early_system_init - Does Early system initialization.
  *
@@ -144,8 +173,13 @@ void s_init(void)
  */
 void early_system_init(void)
 {
+#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_MULTI_DTB_FIT)
+       int ret;
+       int rescan;
+#endif
        init_omap_revision();
        hw_data_init();
+       init_package_revision();
 
 #ifdef CONFIG_SPL_BUILD
        if (warm_reset())
@@ -158,6 +192,7 @@ void early_system_init(void)
        do_io_settings();
 #endif
        setup_early_clocks();
+
 #ifdef CONFIG_SPL_BUILD
        /*
         * Save the boot parameters passed from romcode.
@@ -168,6 +203,20 @@ void early_system_init(void)
        spl_early_init();
 #endif
        do_board_detect();
+
+#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_MULTI_DTB_FIT)
+       /*
+        * Board detection has been done.
+        * Let us see if another dtb wouldn't be a better match
+        * for our board
+        */
+       ret = fdtdec_resetup(&rescan);
+       if (!ret && rescan) {
+               dm_uninit();
+               dm_init_and_scan(true);
+       }
+#endif
+
        vcores_init();
 #ifdef CONFIG_DEBUG_UART_OMAP
        debug_uart_init();