public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Fabio Estevam <festevam@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 5/5] mx6cuboxi: Load the correct 'fdt_file' variable
Date: Fri, 24 Apr 2015 08:46:55 -0300	[thread overview]
Message-ID: <1429876015-22540-5-git-send-email-festevam@gmail.com> (raw)
In-Reply-To: <1429876015-22540-1-git-send-email-festevam@gmail.com>

From: Fabio Estevam <fabio.estevam@freescale.com>

Instead of hardcoding the 'fdt_file' variable, let's detect the SoC and
board variant on the fly and change the dtb name.

Based on a patch from Rabeeh Khoury.

Signed-off-by: Rabeeh Khoury <rabeeh@solid-run.com>
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
Changes since v2:
- Add Rabeeh's Signed-off-by
Changes since v1:
- Attribute the credit to Rabeeh
- Create a U-boot command for checking if the board is hummingboard

 board/solidrun/mx6cuboxi/mx6cuboxi.c | 30 ++++++++++++++++++++++++++++++
 include/configs/mx6cuboxi.h          | 12 ++++++++++--
 2 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c b/board/solidrun/mx6cuboxi/mx6cuboxi.c
index 83410b2..4ea6081 100644
--- a/board/solidrun/mx6cuboxi/mx6cuboxi.c
+++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c
@@ -212,6 +212,36 @@ int checkboard(void)
 	return 0;
 }
 
+static const char *build_dts_prefix(void)
+{
+	if (is_cpu_type(MXC_CPU_MX6Q) || is_cpu_type(MXC_CPU_MX6D))
+		return "imx6q";
+	else if (is_cpu_type(MXC_CPU_MX6DL) || is_cpu_type(MXC_CPU_MX6SOLO))
+		return "imx6dl";
+
+	return "unknown";
+}
+
+static int do_is_hummingboard(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	if (is_hummingboard())
+		return CMD_RET_SUCCESS;
+	else
+		return CMD_RET_FAILURE;
+}
+
+U_BOOT_CMD(
+	is_hummingboard, 1, 1, do_is_hummingboard,
+	"detect if it is a Hummingboard or Cubox-i",
+	""
+);
+
+int misc_init_r(void)
+{
+	setenv("dts_prefix", build_dts_prefix());
+	return 0;
+}
+
 #ifdef CONFIG_SPL_BUILD
 #include <asm/arch/mx6-ddr.h>
 static const struct mx6dq_iomux_ddr_regs mx6q_ddr_ioregs = {
diff --git a/include/configs/mx6cuboxi.h b/include/configs/mx6cuboxi.h
index 5d58b16..c3cf633 100644
--- a/include/configs/mx6cuboxi.h
+++ b/include/configs/mx6cuboxi.h
@@ -29,6 +29,7 @@
 
 #define CONFIG_SYS_MALLOC_LEN		(2 * SZ_1M)
 #define CONFIG_BOARD_EARLY_INIT_F
+#define CONFIG_MISC_INIT_R
 #define CONFIG_MXC_GPIO
 #define CONFIG_MXC_UART
 #define CONFIG_CMD_FUSE
@@ -81,14 +82,19 @@
 #define CONFIG_MXC_UART_BASE	UART1_BASE
 #define CONFIG_CONSOLE_DEV	"ttymxc0"
 #define CONFIG_MMCROOT		"/dev/mmcblk0p2"
-#define CONFIG_DEFAULT_FDT_FILE	"imx6q-hummingboard.dtb"
 #define CONFIG_SYS_FSL_USDHC_NUM	1
 #define CONFIG_SYS_MMC_ENV_DEV		0	/* SDHC2 */
 
 #define CONFIG_EXTRA_ENV_SETTINGS \
 	"script=boot.scr\0" \
 	"image=zImage\0" \
-	"fdt_file=" CONFIG_DEFAULT_FDT_FILE "\0" \
+	"check_suffix=" \
+		"if is_hummingboard; then " \
+			"setenv dts_suffix -hummingboard.dtb;" \
+		"else " \
+			"setenv dts_suffix -cubox-i.dtb;" \
+		"fi; "\
+	"setenv fdt_file ${dts_prefix}${dts_suffix};" \
 	"fdt_addr=0x18000000\0" \
 	"boot_fdt=try\0" \
 	"ip_dyn=yes\0" \
@@ -119,6 +125,7 @@
 	"loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}\0" \
 	"loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}\0" \
 	"mmcboot=echo Booting from mmc ...; " \
+		"run check_suffix; "\
 		"run mmcargs; " \
 		"if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \
 			"if run loadfdt; then " \
@@ -137,6 +144,7 @@
 		"root=/dev/nfs " \
 		"ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp\0" \
 	"netboot=echo Booting from net ...; " \
+		"run check_suffix; "\
 		"run netargs; " \
 		"if test ${ip_dyn} = yes; then " \
 			"setenv get_cmd dhcp; " \
-- 
1.9.1

  parent reply	other threads:[~2015-04-24 11:46 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-24 11:46 [U-Boot] [PATCH v3 1/5] mx6cuboxi: Fix the defconfig name Fabio Estevam
2015-04-24 11:46 ` [U-Boot] [PATCH v3 2/5] mx6cuboxi: Prepare for multi SoC support Fabio Estevam
2015-04-24 11:46 ` [U-Boot] [PATCH v3 3/5] mx6cuboxi: Introduce multi-SoC support Fabio Estevam
2015-04-24 12:27   ` Stefano Babic
2015-04-24 12:29     ` Fabio Estevam
2015-04-24 11:46 ` [U-Boot] [PATCH v3 4/5] mx6cuboxi: Differentiate Cubox-i and Hummingboard Fabio Estevam
2015-04-24 11:46 ` Fabio Estevam [this message]
2015-04-24 23:47   ` [U-Boot] [U-Boot, v3, 5/5] mx6cuboxi: Load the correct 'fdt_file' variable Vagrant Cascadian
2015-04-25  6:05     ` Stefano Babic
2015-04-25 15:30       ` Fabio Estevam
2015-04-25 17:02         ` Vagrant Cascadian
2015-04-25 16:22       ` Vagrant Cascadian
2015-04-25 16:58   ` [U-Boot] [PATCH v3 " Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1429876015-22540-5-git-send-email-festevam@gmail.com \
    --to=festevam@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox