* [PATCH] initialize barebox_loc on i.MX51 @ 2011-08-15 9:09 Sascha Hauer 2011-08-15 9:09 ` [PATCH 1/3] put env_push_context into postcore_initcall Sascha Hauer ` (3 more replies) 0 siblings, 4 replies; 5+ messages in thread From: Sascha Hauer @ 2011-08-15 9:09 UTC (permalink / raw) To: barebox Sascha Hauer (3): put env_push_context into postcore_initcall ARM i.MX25/35: initialize barebox_loc earlier ARM i.MX51: set barebox_loc according to boot source arch/arm/mach-imx/boot.c | 8 +--- arch/arm/mach-imx/imx51.c | 87 +++++++++++++++++++++++++++++++++++++++++++++ common/env.c | 2 +- 3 files changed, 90 insertions(+), 7 deletions(-) _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] put env_push_context into postcore_initcall 2011-08-15 9:09 [PATCH] initialize barebox_loc on i.MX51 Sascha Hauer @ 2011-08-15 9:09 ` Sascha Hauer 2011-08-15 9:09 ` [PATCH 2/3] ARM i.MX25/35: initialize barebox_loc earlier Sascha Hauer ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: Sascha Hauer @ 2011-08-15 9:09 UTC (permalink / raw) To: barebox env_push_context only needs malloc, so initialize it earlier. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> --- common/env.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/common/env.c b/common/env.c index 47cef05..defb26b 100644 --- a/common/env.c +++ b/common/env.c @@ -81,7 +81,7 @@ int env_push_context(void) return 0; } -device_initcall(env_push_context); +postcore_initcall(env_push_context); /** * FIXME -- 1.7.5.4 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/3] ARM i.MX25/35: initialize barebox_loc earlier 2011-08-15 9:09 [PATCH] initialize barebox_loc on i.MX51 Sascha Hauer 2011-08-15 9:09 ` [PATCH 1/3] put env_push_context into postcore_initcall Sascha Hauer @ 2011-08-15 9:09 ` Sascha Hauer 2011-08-15 9:09 ` [PATCH 3/3] ARM i.MX51: set barebox_loc according to boot source Sascha Hauer 2011-08-17 9:25 ` [PATCH] initialize barebox_loc on i.MX51 Marc Reilly 3 siblings, 0 replies; 5+ messages in thread From: Sascha Hauer @ 2011-08-15 9:09 UTC (permalink / raw) To: barebox Now that env_push_context is in a coredevice_initcall we can initialize barebox_loc earlier so that we can use it inside later initcalls. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> --- arch/arm/mach-imx/boot.c | 8 ++------ 1 files changed, 2 insertions(+), 6 deletions(-) diff --git a/arch/arm/mach-imx/boot.c b/arch/arm/mach-imx/boot.c index b4bf93b..8482b60 100644 --- a/arch/arm/mach-imx/boot.c +++ b/arch/arm/mach-imx/boot.c @@ -41,7 +41,7 @@ * Note also that I suspect that the boot source pins are only sampled at * power up. */ -static int imx_boot_save_loc(void) +static int imx_25_35_boot_save_loc(void) { const char *bareboxloc = NULL; uint32_t reg; @@ -86,10 +86,6 @@ static int imx_boot_save_loc(void) return 0; } -/* - * This can only be called after env_push_context() has been called - * so it is a late_initcall. - */ -late_initcall(imx_boot_save_loc); +coredevice_initcall(imx_25_35_boot_save_loc); #endif -- 1.7.5.4 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 3/3] ARM i.MX51: set barebox_loc according to boot source 2011-08-15 9:09 [PATCH] initialize barebox_loc on i.MX51 Sascha Hauer 2011-08-15 9:09 ` [PATCH 1/3] put env_push_context into postcore_initcall Sascha Hauer 2011-08-15 9:09 ` [PATCH 2/3] ARM i.MX25/35: initialize barebox_loc earlier Sascha Hauer @ 2011-08-15 9:09 ` Sascha Hauer 2011-08-17 9:25 ` [PATCH] initialize barebox_loc on i.MX51 Marc Reilly 3 siblings, 0 replies; 5+ messages in thread From: Sascha Hauer @ 2011-08-15 9:09 UTC (permalink / raw) To: barebox Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> --- arch/arm/mach-imx/imx51.c | 87 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 87 insertions(+), 0 deletions(-) diff --git a/arch/arm/mach-imx/imx51.c b/arch/arm/mach-imx/imx51.c index 8b7c807..f2c886e 100644 --- a/arch/arm/mach-imx/imx51.c +++ b/arch/arm/mach-imx/imx51.c @@ -18,6 +18,7 @@ #include <init.h> #include <common.h> #include <sizes.h> +#include <environment.h> #include <asm/io.h> #include <mach/imx51-regs.h> @@ -89,3 +90,89 @@ static int imx51_init(void) return 0; } coredevice_initcall(imx51_init); + +/* + * Saves the boot source media into the $barebox_loc enviroment variable + * + * This information is useful for barebox init scripts as we can then easily + * use a kernel image stored on the same media that we launch barebox with + * (for example). + * + * imx25 and imx35 can boot into barebox from several media such as + * nand, nor, mmc/sd cards, serial roms. "mmc" is used to represent several + * sources as its impossible to distinguish between them. + * + * Some sources such as serial roms can themselves have 3 different boot + * possibilities (i2c1, i2c2 etc). It is assumed that any board will + * only be using one of these at any one time. + * + * Note also that I suspect that the boot source pins are only sampled at + * power up. + */ + +#define SRC_SBMR 0x4 +#define SBMR_BT_MEM_TYPE_SHIFT 7 +#define SBMR_BT_MEM_CTL_SHIFT 0 +#define SBMR_BMOD_SHIFT 14 + +static int imx51_boot_save_loc(void) +{ + const char *bareboxloc = NULL; + uint32_t reg; + unsigned int ctrl, type; + + /* [CTRL][TYPE] */ + const char *const locations[4][4] = { + { /* CTRL = WEIM */ + "nor", + NULL, + "onenand", + NULL, + }, { /* CTRL == NAND */ + "nand", + "nand", + "nand", + "nand", + }, { /* CTRL == reserved */ + NULL, + NULL, + NULL, + NULL, + }, { /* CTRL == expansion */ + "mmc", + NULL, + "i2c", + "spi", + } + }; + + reg = readl(MX51_SRC_BASE_ADDR + SRC_SBMR); + + switch ((reg >> SBMR_BMOD_SHIFT) & 0x3) { + case 0: + case 2: + /* internal boot */ + ctrl = (reg >> SBMR_BT_MEM_CTL_SHIFT) & 0x3; + type = (reg >> SBMR_BT_MEM_TYPE_SHIFT) & 0x3; + + bareboxloc = locations[ctrl][type]; + break; + case 1: + /* reserved */ + bareboxloc = "unknown"; + break; + case 3: + bareboxloc = "serial"; + break; + + } + + if (bareboxloc) { + setenv("barebox_loc", bareboxloc); + export("barebox_loc"); + } + + return 0; +} + +coredevice_initcall(imx51_boot_save_loc); -- 1.7.5.4 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] initialize barebox_loc on i.MX51 2011-08-15 9:09 [PATCH] initialize barebox_loc on i.MX51 Sascha Hauer ` (2 preceding siblings ...) 2011-08-15 9:09 ` [PATCH 3/3] ARM i.MX51: set barebox_loc according to boot source Sascha Hauer @ 2011-08-17 9:25 ` Marc Reilly 3 siblings, 0 replies; 5+ messages in thread From: Marc Reilly @ 2011-08-17 9:25 UTC (permalink / raw) To: barebox [-- Attachment #1.1: Type: text/plain, Size: 626 bytes --] Hi, On Monday, August 15, 2011 07:09:01 PM Sascha Hauer wrote: > Sascha Hauer (3): > put env_push_context into postcore_initcall > ARM i.MX25/35: initialize barebox_loc earlier > ARM i.MX51: set barebox_loc according to boot source > > arch/arm/mach-imx/boot.c | 8 +--- > arch/arm/mach-imx/imx51.c | 87 > +++++++++++++++++++++++++++++++++++++++++++++ common/env.c | > 2 +- > 3 files changed, 90 insertions(+), 7 deletions(-) For patches 1 and 2: tested-by: marc@cpdesign.com.au For patch 3: Acked-by: marc@cpdesign.com.au (Only have i.MX35 system to test with.) Cheers, Marc [-- Attachment #1.2: Type: text/html, Size: 4860 bytes --] [-- Attachment #2: Type: text/plain, Size: 149 bytes --] _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-08-17 9:22 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2011-08-15 9:09 [PATCH] initialize barebox_loc on i.MX51 Sascha Hauer 2011-08-15 9:09 ` [PATCH 1/3] put env_push_context into postcore_initcall Sascha Hauer 2011-08-15 9:09 ` [PATCH 2/3] ARM i.MX25/35: initialize barebox_loc earlier Sascha Hauer 2011-08-15 9:09 ` [PATCH 3/3] ARM i.MX51: set barebox_loc according to boot source Sascha Hauer 2011-08-17 9:25 ` [PATCH] initialize barebox_loc on i.MX51 Marc Reilly
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox