]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
ARM: at91: sama5d3xek: use a $dtb_name to load dtb
authorWu, Josh <Josh.wu@atmel.com>
Wed, 19 Aug 2015 11:11:19 +0000 (19:11 +0800)
committerLothar Waßmann <LW@KARO-electronics.de>
Thu, 10 Sep 2015 08:30:33 +0000 (10:30 +0200)
Since sama5d3xek boards has different type of dtb blobs, so we need to detect
the cpu type in runtime.

So we add a new variable $dtb_name. if $dtb_name is not defined, we just use
at91-${board_name}.dtb

as the $dtb_name. Otherwise, we will just load the dtb with
$dtb_name.

For sama5d3xek, we will detect cpu type and make up $dtb_name in
runtime.

Signed-off-by: Josh Wu <josh.wu@atmel.com>
board/atmel/sama5d3xek/sama5d3xek.c
include/configs/at91-sama5_common.h
include/configs/sama5d3xek.h

index 2bd436a2d837dedf6ac3302d68f5b5b929f84643..7c95f33590ed87596ca269b576171ba9bc48cb2c 100644 (file)
@@ -15,6 +15,7 @@
 #include <asm/arch/gpio.h>
 #include <asm/arch/clk.h>
 #include <lcd.h>
+#include <linux/ctype.h>
 #include <atmel_hlcdc.h>
 #include <atmel_mci.h>
 #include <phy.h>
@@ -369,6 +370,25 @@ void spi_cs_deactivate(struct spi_slave *slave)
 }
 #endif /* CONFIG_ATMEL_SPI */
 
+#ifdef CONFIG_BOARD_LATE_INIT
+int board_late_init(void)
+{
+#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
+       const int MAX_STR_LEN = 32;
+       char name[MAX_STR_LEN], *p;
+       int i;
+
+       strncpy(name, get_cpu_name(), MAX_STR_LEN);
+       for (i = 0, p = name; (*p) && (i < MAX_STR_LEN); p++, i++)
+               *p = tolower(*p);
+
+       strcat(name, "ek.dtb");
+       setenv("dtb_name", name);
+#endif
+       return 0;
+}
+#endif
+
 /* SPL */
 #ifdef CONFIG_SPL_BUILD
 void spl_board_init(void)
index bb737a1fe847d8542507f2654a01dc05f69ab8a6..0fe0852821a2e2cdb5024febf0b3c5dae22844e4 100644 (file)
 #define FAT_ENV_FILE           "uboot.env"
 #define CONFIG_ENV_SIZE                0x4000
 
-#define CONFIG_BOOTCOMMAND     "fatload mmc 0:1 0x21000000 at91-${board_name}.dtb; " \
+#define CONFIG_BOOTCOMMAND     "if test ! -n ${dtb_name}; then "       \
+                                   "setenv dtb_name at91-${board_name}.dtb; " \
+                               "fi; "                                  \
+                               "fatload mmc 0:1 0x21000000 ${dtb_name}; " \
                                "fatload mmc 0:1 0x22000000 zImage; "   \
                                "bootz 0x22000000 - 0x21000000"
 #define CONFIG_BOOTARGS                                                        \
index 5c7b722da386448321c3690b5886bbcc590ec3e3..7b2f69a27b39cab100379a15d245632467109fb6 100644 (file)
@@ -19,6 +19,9 @@
  */
 #include "at91-sama5_common.h"
 
+#define CONFIG_BOARD_LATE_INIT
+#define CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
+
 /* serial console */
 #define CONFIG_ATMEL_USART
 #define CONFIG_USART_BASE              ATMEL_BASE_DBGU