imx: Define common routines to set cpu and board environment variables
Subsystems (2)
PATCH v2 1/1 imx: Define common routines to set cpu and board environment variables
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.
---
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(-)
arch/arm/imx-common/cpu.c +13 -2
@@ -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;
arch/arm/include/asm/arch-mx6/sys_proto.h +9 -0
@@ -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);/*
Signature · 1 line
1.8.1.2
PATCH v2 1/1 imx: Define common routines to set cpu and board environment variables
Dear Eric Nelson,
+Albert, Tom
Quoted 40 lines
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 <[email protected]>---
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.care 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.hshould 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 afterenv_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(-)arch/arm/imx-common/cpu.c +0
-2@@ -99,8 +99,6 @@ unsigned imx_ddr_size(void) }#endif -#if defined(CONFIG_DISPLAY_CPUINFO ) -const char *get_imx_type (u32 imxtype) {switch (imxtype) {
arch/arm/imx-common/cpu.c const char *get_imx_type(u32 imxtype) · line 125
Quoted 7 lines
arch/arm/imx-common/cpu.c +4
-0@@ -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 ()))); +}
I'd say we should have a U-Boot wide thing here + CPU-specific overrides where applicable.
arch/arm/imx-common/cpu.c const char *get_imx_type(u32 imxtype) · line 132
Quoted 6 lines
arch/arm/imx-common/cpu.c +6
-0+void __weak set_board_env (void ) +{ +char *old =getenv ("board" ); +if (!old) +setenv ("board" ,CONFIG_SYS_BOARD ); +}
This might go into arch/FOO/lib/board.c ?
[...]
PATCH v2 1/1 imx: Define common routines to set cpu and board environment variables
Thanks Marek,
Quoted 47 lines · Marek Vasut
Dear Eric Nelson,
+Albert, Tom
Quoted 43 lines
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 <[email protected]>---
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.care 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.hshould 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 afterenv_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(-)arch/arm/imx-common/cpu.c +0
-2@@ -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) } }
Quoted 8 lines
arch/arm/imx-common/cpu.c const char *get_imx_type(u32 imxtype) · line 125
Quoted 4 lines
arch/arm/imx-common/cpu.c +4
-0+void __weak set_cpu_env (void ) +{ +setenv ("cpu" ,get_imx_type (cpu_type (get_cpu_rev ()))); +}I'd say we should have a U-Boot wide thing here + CPU-specific overrides where applicable.
I'll follow your lead on this.
I'm just hoping to get a trivial amount of machinery so a boot script can figure out which of a set of DTBs to load:
imx6q-nitrogen6x.dtb,
imx6dl-nitrogen6x.dtb, or
imx6s-nitrogen6x.dtb
Fabio's recent patch for SABRE SD showed the same need.
This could be even easier on i.MX6 if we had more formalized (and lower-case) strings returned by get_imx_type(), but I wanted this to be very small.
I'm not sure how consistent the DTB naming is for other machines or if there's always the equivalent of get_imx_type().
Regards,
Eric
PATCH v2 1/1 imx: Define common routines to set cpu and board environment variables
Hi Eric,
Quoted 64 lines
Thanks Marek,
Quoted 53 lines · Marek Vasut
Dear Eric Nelson,
+Albert, Tom
Quoted 49 lines
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 <[email protected]>---
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.care 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.hshould 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 afterenv_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(-)arch/arm/imx-common/cpu.c +0
-2@@ -99,8 +99,6 @@ unsigned imx_ddr_size(void) }#endif -#if defined(CONFIG_DISPLAY_CPUINFO ) -const char *get_imx_type (u32 imxtype){ switch (imxtype) {arch/arm/imx-common/cpu.c +0
-0@@ -121,6 +119,19 @@ const char *get_imx_type(u32 imxtype) } }Quoted 7 lines
arch/arm/imx-common/cpu.c const char *get_imx_type(u32 imxtype) · line 125
Quoted 4 lines
arch/arm/imx-common/cpu.c +4
-0+void __weak set_cpu_env (void ) +{ +setenv ("cpu" ,get_imx_type (cpu_type (get_cpu_rev ()))); +}I'd say we should have a U-Boot wide thing here + CPU-specific overrides where applicable.
Quoted 1 line
I'll follow your lead on this.
I'd wait for Tom's/Albert's opinion on this one too btw.
Quoted 8 lines
I'm just hoping to get a trivial amount of machinery so a boot script can figure out which of a set of DTBs to load:
imx6q-nitrogen6x.dtb,
imx6dl-nitrogen6x.dtb, or
imx6s-nitrogen6x.dtbFabio's recent patch for SABRE SD showed the same need.
Full agreement here.
Quoted 6 lines
This could be even easier on i.MX6 if we had more formalized (and lower-case) strings returned by
get_imx_type(), but I wanted this to be very small.I'm not sure how consistent the DTB naming is for other machines or if there's always the equivalent of
get_imx_type().
In the worst-case scenario, you might end up with some mapping function full of strcmp()s ;-)
PATCH v2 1/1 imx: Define common routines to set cpu and board environment variables
Quoted 22 lines · Marek Vasut
Hi Eric,
Quoted 3 lines
Thanks Marek,
Quoted 1 line · Marek Vasut
Dear Eric Nelson,
<snip>
Quoted 8 lines
I'm just hoping to get a trivial amount of machinery so a boot script can figure out which of a set of DTBs to load:
imx6q-nitrogen6x.dtb,
imx6dl-nitrogen6x.dtb, or
imx6s-nitrogen6x.dtbFabio's recent patch for SABRE SD showed the same need.
Full agreement here.
Quoted 4 lines
This could be even easier on i.MX6 if we had more formalized (and lower-case) strings returned by
get_imx_type(), but I wanted this to be very small.
Quoted 6 lines
Quoted 2 lines
I'm not sure how consistent the DTB naming is for other machines or if there's always the equivalent of
get_imx_type().In the worst-case scenario, you might end up with some mapping function full of strcmp()s ;-)
This is much easier for us to do, since we defer much of the scripting into a boot script.
It will be harder for Fabio to shoe-horn in until we get environment settings in an external file...
PATCH v2 1/1 imx: Define common routines to set cpu and board environment variables
Dear Eric Nelson,
Quoted 28 lines · Marek Vasut
Quoted 27 lines
Hi Eric,
Quoted 4 lines
Thanks Marek,
Quoted 1 line · Marek Vasut
Dear Eric Nelson,
<snip>
Quoted 8 lines
I'm just hoping to get a trivial amount of machinery so a boot
script can figure out which of a set of DTBs to load:
imx6q-nitrogen6x.dtb, imx6dl-nitrogen6x.dtb, or imx6s-nitrogen6x.dtbFabio's recent patch for SABRE SD showed the same need.
Full agreement here.
Quoted 6 lines
This could be even easier on i.MX6 if we had more formalized (and lower-case) strings returned by
get_imx_type(), but I wanted this to be very small.I'm not sure how consistent the DTB naming is for other machines or if there's always the equivalent of
get_imx_type().
Quoted 8 lines
Quoted 2 lines
In the worst-case scenario, you might end up with some mapping function full of strcmp()s ;-)
This is much easier for us to do, since we defer much of the scripting into a boot script.
It will be harder for Fabio to shoe-horn in until we get environment settings in an external file...
Yeah, patching the env unto u-boot is the way to go here I guess. What's the progress on this anyway, Tom ?
Best regards,
Marek Vasut
PATCH v2 1/1 imx: Define common routines to set cpu and board environment variables
In reply to Marek VasutQuoted 66 lines · Marek Vasut
Hi Eric,
Quoted 64 lines
Thanks Marek,
Quoted 60 lines · Marek Vasut
Dear Eric Nelson,
+Albert, Tom
Quoted 44 lines
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 <[email protected]>---
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.care 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.hshould 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 afterenv_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(-)arch/arm/imx-common/cpu.c +0
-2@@ -99,8 +99,6 @@ unsigned imx_ddr_size(void) }#endif -#if defined(CONFIG_DISPLAY_CPUINFO ) -const char *get_imx_type (u32 imxtype){ switch (imxtype) {arch/arm/imx-common/cpu.c const char *get_imx_type(u32 imxtype) · line 127
Quoted 9 lines
arch/arm/imx-common/cpu.c +4
-0@@ -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 ()))); +}I'd say we should have a U-Boot wide thing here + CPU-specific overrides where applicable.
Quoted 3 lines
Quoted 1 line
I'll follow your lead on this.
I'd wait for Tom's/Albert's opinion on this one too btw.
So, CONFIG_ENV_VARS_UBOOT_CONFIG says that these variables are _build_time_. If you want to whack their values, update the README on CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG to say so. Having the i.MX code that updates this at run-time is fine to live in the i.MX code area.
[snip]
Quoted 9 lines
Quoted 6 lines
This could be even easier on i.MX6 if we had more formalized (and lower-case) strings returned by
get_imx_type(), but I wanted this to be very small.I'm not sure how consistent the DTB naming is for other machines or if there's always the equivalent of
get_imx_type().In the worst-case scenario, you might end up with some mapping function full of strcmp()s ;-)
Note that in TI-land we do this with 'findfdt' in the environment and yes, some string compares. But we set board_name in C so that we can do what we need to, to determine the board. Maybe something like that would help here?
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20131115/8d6b431e/attachment.pgp>
PATCH v2 1/1 imx: Define common routines to set cpu and board environment variables
Thanks Tom,
Quoted 67 lines · Tom Rini
Quoted 66 lines · Marek Vasut
Hi Eric,
Quoted 64 lines
Thanks Marek,
Quoted 60 lines · Marek Vasut
Dear Eric Nelson,
+Albert, Tom
Quoted 44 lines
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 <[email protected]>---
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.care 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.hshould 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 afterenv_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(-)arch/arm/imx-common/cpu.c +0
-2@@ -99,8 +99,6 @@ unsigned imx_ddr_size(void) }#endif -#if defined(CONFIG_DISPLAY_CPUINFO ) -const char *get_imx_type (u32 imxtype){ switch (imxtype) {arch/arm/imx-common/cpu.c const char *get_imx_type(u32 imxtype) · line 127
Quoted 9 lines
arch/arm/imx-common/cpu.c +4
-0@@ -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 ()))); +}I'd say we should have a U-Boot wide thing here + CPU-specific overrides where applicable.
Quoted 9 lines
Quoted 3 lines
Quoted 1 line
I'll follow your lead on this.
I'd wait for Tom's/Albert's opinion on this one too btw.
So,
CONFIG_ENV_VARS_UBOOT_CONFIGsays that these variables are _build_time_. If you want to whack their values, update the README onCONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIGto say so. Having the i.MX code that updates this at run-time is fine to live in the i.MX code area.
I wasn't aware of these two options, and they seem useful.
They also suggest that using "cpu" and "board" are probably wrong, since CONFIG_SYS_CPU and environment "cpu" are already set to "armv7" and "board" is configured with the build-time board name.
Overriding "board_name" seems to be in-line with the README if we can just figure out the right spot for initialization.
Some other variable ("cpu_name" or "imx_type" perhaps?) should probably be used for the CPU variant.
Chasing down how "board_name" is initialized in get_board_revision() leads me to arch_misc_init() is the right place for this on i.MX, since it's called after the environment is initialized.
Quoted 8 lines
[snip]
Quoted 7 lines
Quoted 6 lines
This could be even easier on i.MX6 if we had more formalized (and lower-case) strings returned by
get_imx_type(), but I wanted this to be very small.I'm not sure how consistent the DTB naming is for other machines or if there's always the equivalent of
get_imx_type().
Quoted 8 lines
Quoted 2 lines
In the worst-case scenario, you might end up with some mapping function full of strcmp()s ;-)
Note that in TI-land we do this with 'findfdt' in the environment and yes, some string compares. But we set
board_namein C so that we can do what we need to, to determine the board. Maybe something like that would help here?
Thanks. That does help.
Regards,
Eric
Fabio Estevam
reviewerPATCH v2 1/1 imx: Define common routines to set cpu and board environment variables
In reply to Eric NelsonHi Eric,
Quoted 6 lines · Eric Nelson
I'm just hoping to get a trivial amount of machinery so a boot script can figure out which of a set of DTBs to load:
imx6q-nitrogen6x.dtb,
imx6dl-nitrogen6x.dtb, or
imx6s-nitrogen6x.dtb
imx6dl-nitrogen6x.dtb should cover both dl and solo variants, so no need for a imx6s-nitrogen6x.dtb version.
Regards,
Fabio Estevam
PATCH v2 1/1 imx: Define common routines to set cpu and board environment variables
Quoted 8 lines · Fabio Estevam
Hi Eric,
Quoted 3 lines · Eric Nelson
I'm just hoping to get a trivial amount of machinery so a boot script can figure out which of a set of DTBs to load:
Quoted 7 lines
Quoted 3 lines
imx6q-nitrogen6x.dtb,
imx6dl-nitrogen6x.dtb, or
imx6s-nitrogen6x.dtbimx6dl-nitrogen6x.dtb should cover both dl and solo variants, so no need for a imx6s-nitrogen6x.dtb version.
Thanks Fabio.