public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Eric Nelson <eric.nelson@boundarydevices.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH V2] imx: Define common routines to set cpu and board environment variables
Date: Wed, 13 Nov 2013 18:16:49 -0700	[thread overview]
Message-ID: <1384391809-9339-1-git-send-email-eric.nelson@boundarydevices.com> (raw)

These can be used in bootcmd to produce DTB file names.

set_board_env() allows over-ride for use when a developing custom
DTB files.

Signed-off-by: Eric Nelson <eric.nelson@boundarydevices.com>
---
V2 adds void to the function declarations and definitions and adds
a blank to keep checkpatch clean.

I'm feeling like I missed something here. Routines in imx-common/cpu.c
are shared between various i.MX processors, but there doesn't appear
to be a common header file.

It seems that arch/arm/include/asm/imx-common.h should be present
but isn't. Am I missing something?

I also think there should be a way we could pull this into multiple
boards without adding a full-up board_late_init() function into
each board file, but tracing the init sequence, I'm not seeing an
architecture-specific spot after env_init.

 arch/arm/imx-common/cpu.c                 | 15 +++++++++++++--
 arch/arm/include/asm/arch-mx6/sys_proto.h |  9 +++++++++
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/arch/arm/imx-common/cpu.c b/arch/arm/imx-common/cpu.c
index 0cd2538..4214946 100644
--- a/arch/arm/imx-common/cpu.c
+++ b/arch/arm/imx-common/cpu.c
@@ -99,8 +99,6 @@ unsigned imx_ddr_size(void)
 }
 #endif
 
-#if defined(CONFIG_DISPLAY_CPUINFO)
-
 const char *get_imx_type(u32 imxtype)
 {
 	switch (imxtype) {
@@ -121,6 +119,19 @@ const char *get_imx_type(u32 imxtype)
 	}
 }
 
+void __weak set_cpu_env(void)
+{
+	setenv("cpu", get_imx_type(cpu_type(get_cpu_rev())));
+}
+
+void __weak set_board_env(void)
+{
+	char *old = getenv("board");
+	if (!old)
+		setenv("board", CONFIG_SYS_BOARD);
+}
+
+#if defined(CONFIG_DISPLAY_CPUINFO)
 int print_cpuinfo(void)
 {
 	u32 cpurev;
diff --git a/arch/arm/include/asm/arch-mx6/sys_proto.h b/arch/arm/include/asm/arch-mx6/sys_proto.h
index 8c21364..f58ebc3 100644
--- a/arch/arm/include/asm/arch-mx6/sys_proto.h
+++ b/arch/arm/include/asm/arch-mx6/sys_proto.h
@@ -27,8 +27,17 @@ u32 get_cpu_rev(void);
 #define is_cpu_type(cpu) (cpu_type(get_cpu_rev()) == cpu)
 
 const char *get_imx_type(u32 imxtype);
+
 unsigned imx_ddr_size(void);
 
+/* Set standard board and cpu environment variables.
+ * for use in loading DTB files.
+ *
+ * Call these in board_late_init if needed
+ */
+void set_cpu_env(void);
+void set_board_env(void);
+
 void set_vddsoc(u32 mv);
 
 /*
-- 
1.8.1.2

             reply	other threads:[~2013-11-14  1:16 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-14  1:16 Eric Nelson [this message]
2013-11-14 21:22 ` [U-Boot] [PATCH V2] imx: Define common routines to set cpu and board environment variables Marek Vasut
2013-11-14 21:38   ` Eric Nelson
2013-11-14 23:30     ` Marek Vasut
2013-11-15  1:33       ` Eric Nelson
2013-11-15  4:23         ` Marek Vasut
2013-11-15 19:15       ` Tom Rini
2013-11-16 16:14         ` Eric Nelson
2013-11-16 14:03     ` Fabio Estevam
2013-11-16 16:16       ` Eric Nelson

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=1384391809-9339-1-git-send-email-eric.nelson@boundarydevices.com \
    --to=eric.nelson@boundarydevices.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