public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [v2 1/1] wandboard: fix dtb file names.
@ 2016-07-19 17:23 Adam Duskett
  2016-07-19 17:32 ` Fabio Estevam
  2016-07-19 17:47 ` Wolfgang Denk
  0 siblings, 2 replies; 12+ messages in thread
From: Adam Duskett @ 2016-07-19 17:23 UTC (permalink / raw)
  To: u-boot

With the previous suggestion from Wolfgang Denk, this patch removes
the findfdt function from wandboard.h and instead replaces it with
some simple logic in wandboard.c.

The new function "set_fdtfile" is called in board_late_init.  This
function simply finds the length of the dtb file name, allocates
enough space for that string, and sets the fdtfile name to that string.

This results in slightly shorter / faster script code as well.

Dear Adam Duskett,

In message <BLU436-SMTP46BCB8C63151CD3166FBD1B9360@phx.gbl> you wrote:
> With the release of kernel 4.1.15 for the imx6 line of processors,
> wandboard now uses imx6q-wandboard-revc1.dtb and imx6dl-wandboard-revc1.dtb.
> This patch fixes the naming convention to work with kernel 4.1.15
>
> Signed-off-by: Adam Duskett <adamduskett@outlook.com>
> ---
> include/configs/wandboard.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/configs/wandboard.h b/include/configs/wandboard.h
> index 99f5c0c..d41b600 100644
> --- a/include/configs/wandboard.h
> +++ b/include/configs/wandboard.h
> @@ -135,9 +135,9 @@
> "setenv bootargs ${bootargs} ${fbmem}\0" \
> "findfdt="\
> "if test $board_name = C1 && test $board_rev = MX6Q ; then " \
> -	"setenv fdtfile imx6q-wandboard.dtb; fi; " \
> +	"setenv fdtfile imx6q-wandboard-revc1.dtb; fi; " \
> "if test $board_name = C1 && test $board_rev = MX6DL ; then " \
> -	"setenv fdtfile imx6dl-wandboard.dtb; fi; " \
> +	"setenv fdtfile imx6dl-wandboard-revc1.dtb; fi; " \
> "if test $board_name = B1 && test $board_rev = MX6Q ; then " \
> "setenv fdtfile imx6q-wandboard-revb1.dtb; fi; " \
> "if test $board_name = B1 && test $board_rev = MX6DL ; then " \

Instead of adding to an ever growing list of names, would it not make
sense to solve this programmatically, like by concatenating "i" +
tolower($board_rev) + "-wandboard-rev" + tolower($board_name) + ".dtb"?

I guess this would also result in shorter / faster script code?

Best regards,

Wolfgang Denk

Signed-off-by: Adam Duskett <Adamduskett@outlook.com>
---
Changes:

v1 - v2:
 - Removed findfdt from h file and moved it to init code.

 
 board/wandboard/wandboard.c | 20 ++++++++++++++++++++
 include/configs/wandboard.h | 12 ------------
 2 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/board/wandboard/wandboard.c b/board/wandboard/wandboard.c
index 4ce74cd..a1037ed 100644
--- a/board/wandboard/wandboard.c
+++ b/board/wandboard/wandboard.c
@@ -29,6 +29,8 @@
 #include <phy.h>
 #include <input.h>
 #include <i2c.h>
+#include <linux/ctype.h>
+#include <malloc.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -377,6 +379,22 @@ static bool is_revc1(void)
 		return false;
 }
 
+static void set_fdtfile(void)
+{
+	char *fdtfile;
+	int i;
+	int length = strlen(getenv("board_rev")) + strlen("-wandboard-rev") +
+		     strlen(getenv("board_name")) + strlen(".dtb") + 1;
+	fdtfile = malloc(length);
+	sprintf(fdtfile, "i%s-wandboard-rev%s.dtb", getenv("board_rev"), getenv("board_name"));
+	for (i = 0; i < length; i++){
+		fdtfile[i] = tolower(fdtfile[i]);
+	}
+
+	setenv("fdtfile", fdtfile);
+	free(fdtfile);
+}
+
 int board_late_init(void)
 {
 #ifdef CONFIG_CMD_BMODE
@@ -393,6 +411,8 @@ int board_late_init(void)
 		setenv("board_name", "C1");
 	else
 		setenv("board_name", "B1");
+
+	set_fdtfile();
 #endif
 	return 0;
 }
diff --git a/include/configs/wandboard.h b/include/configs/wandboard.h
index 99f5c0c..778c3f5 100644
--- a/include/configs/wandboard.h
+++ b/include/configs/wandboard.h
@@ -133,17 +133,6 @@
 			"echo '- no FWBADAPT-7WVGA-LCD-F07A-0102 display';" \
 		"fi; " \
 		"setenv bootargs ${bootargs} ${fbmem}\0" \
-	"findfdt="\
-		"if test $board_name = C1 && test $board_rev = MX6Q ; then " \
-			"setenv fdtfile imx6q-wandboard.dtb; fi; " \
-		"if test $board_name = C1 && test $board_rev = MX6DL ; then " \
-			"setenv fdtfile imx6dl-wandboard.dtb; fi; " \
-		"if test $board_name = B1 && test $board_rev = MX6Q ; then " \
-			"setenv fdtfile imx6q-wandboard-revb1.dtb; fi; " \
-		"if test $board_name = B1 && test $board_rev = MX6DL ; then " \
-			"setenv fdtfile imx6dl-wandboard-revb1.dtb; fi; " \
-		"if test $fdtfile = undefined; then " \
-			"echo WARNING: Could not determine dtb to use; fi; \0" \
 	"kernel_addr_r=" __stringify(CONFIG_LOADADDR) "\0" \
 	"pxefile_addr_r=" __stringify(CONFIG_LOADADDR) "\0" \
 	"ramdisk_addr_r=0x13000000\0" \
@@ -159,7 +148,6 @@
 	func(DHCP, dhcp, na)
 
 #define CONFIG_BOOTCOMMAND \
-	   "run findfdt; " \
 	   "run distro_bootcmd"
 
 #include <config_distro_bootcmd.h>
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2016-07-20 14:52 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-19 17:23 [U-Boot] [v2 1/1] wandboard: fix dtb file names Adam Duskett
2016-07-19 17:32 ` Fabio Estevam
2016-07-19 17:40   ` Adam Duskett
2016-07-19 17:46     ` Fabio Estevam
2016-07-19 17:51       ` Adam Duskett
2016-07-20 14:52         ` Stefano Babic
2016-07-19 17:43   ` Tom Rini
2016-07-19 17:51     ` Fabio Estevam
2016-07-19 17:58       ` Adam Duskett
2016-07-19 18:05         ` Fabio Estevam
2016-07-19 18:04       ` Tom Rini
2016-07-19 17:47 ` Wolfgang Denk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox