diff mbox series

[U-Boot,4/5] ARM: mxs: move spl data

Message ID 20180421151110.20423-4-mans@mansr.com
State Accepted
Commit 33ea119382d820294e22bc99c4ea32cb5fac1a71
Delegated to: Stefano Babic
Headers show
Series [U-Boot,1/5] ARM: mxs: make lowlevel_init() weak | expand

Commit Message

Måns Rullgård April 21, 2018, 3:11 p.m. UTC
With full SPL enabled, the loaded image overwrites the mxs_spl_data
location.  Moving it a slightly lower address fixes this.

Signed-off-by: Mans Rullgard <mans@mansr.com>
---
 arch/arm/cpu/arm926ejs/mxs/mxs.c          | 6 ++----
 arch/arm/cpu/arm926ejs/mxs/spl_boot.c     | 3 +--
 arch/arm/include/asm/arch-mxs/sys_proto.h | 2 ++
 3 files changed, 5 insertions(+), 6 deletions(-)

Comments

Stefano Babic April 27, 2018, 8:59 a.m. UTC | #1
On 21/04/2018 17:11, Mans Rullgard wrote:
> With full SPL enabled, the loaded image overwrites the mxs_spl_data
> location.  Moving it a slightly lower address fixes this.
> 
> Signed-off-by: Mans Rullgard <mans@mansr.com>
> ---
>  arch/arm/cpu/arm926ejs/mxs/mxs.c          | 6 ++----
>  arch/arm/cpu/arm926ejs/mxs/spl_boot.c     | 3 +--
>  arch/arm/include/asm/arch-mxs/sys_proto.h | 2 ++
>  3 files changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/arm/cpu/arm926ejs/mxs/mxs.c b/arch/arm/cpu/arm926ejs/mxs/mxs.c
> index 5c7817074fd6..09b5c04cc9d2 100644
> --- a/arch/arm/cpu/arm926ejs/mxs/mxs.c
> +++ b/arch/arm/cpu/arm926ejs/mxs/mxs.c
> @@ -178,8 +178,7 @@ const char *get_imx_type(u32 imxtype)
>  int print_cpuinfo(void)
>  {
>  	u32 cpurev;
> -	struct mxs_spl_data *data = (struct mxs_spl_data *)
> -		((CONFIG_SYS_TEXT_BASE - sizeof(struct mxs_spl_data)) & ~0xf);
> +	struct mxs_spl_data *data = MXS_SPL_DATA;
>  
>  	cpurev = get_cpu_rev();
>  	printf("CPU:   Freescale i.MX%s rev%d.%d at %d MHz\n",
> @@ -277,8 +276,7 @@ void imx_get_mac_from_fuse(int dev_id, unsigned char *mac)
>  
>  int mxs_dram_init(void)
>  {
> -	struct mxs_spl_data *data = (struct mxs_spl_data *)
> -		((CONFIG_SYS_TEXT_BASE - sizeof(struct mxs_spl_data)) & ~0xf);
> +	struct mxs_spl_data *data = MXS_SPL_DATA;
>  
>  	if (data->mem_dram_size == 0) {
>  		printf("MXS:\n"
> diff --git a/arch/arm/cpu/arm926ejs/mxs/spl_boot.c b/arch/arm/cpu/arm926ejs/mxs/spl_boot.c
> index d9d1d73d1af4..0c3925640dc9 100644
> --- a/arch/arm/cpu/arm926ejs/mxs/spl_boot.c
> +++ b/arch/arm/cpu/arm926ejs/mxs/spl_boot.c
> @@ -120,8 +120,7 @@ void mxs_common_spl_init(const uint32_t arg, const uint32_t *resptr,
>  			 const iomux_cfg_t *iomux_setup,
>  			 const unsigned int iomux_size)
>  {
> -	struct mxs_spl_data *data = (struct mxs_spl_data *)
> -		((CONFIG_SYS_TEXT_BASE - sizeof(struct mxs_spl_data)) & ~0xf);
> +	struct mxs_spl_data *data = MXS_SPL_DATA;
>  	uint8_t bootmode = mxs_get_bootmode_index();
>  	gd = &gdata;
>  
> diff --git a/arch/arm/include/asm/arch-mxs/sys_proto.h b/arch/arm/include/asm/arch-mxs/sys_proto.h
> index 609676375b55..b23ee6d88768 100644
> --- a/arch/arm/include/asm/arch-mxs/sys_proto.h
> +++ b/arch/arm/include/asm/arch-mxs/sys_proto.h
> @@ -85,6 +85,8 @@ static const struct mxs_pair mxs_boot_modes[] = {
>  #define MXS_BM_SDMMC1_3V3		0x0a
>  #define MXS_BM_SDMMC1_1V8		0x1a
>  
> +#define MXS_SPL_DATA ((struct mxs_spl_data *)(CONFIG_SYS_TEXT_BASE - 0x200))
> +
>  struct mxs_spl_data {
>  	uint8_t		boot_mode_idx;
>  	uint32_t	mem_dram_size;
> 

Applied to u-boot-imx, thanks !

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/arch/arm/cpu/arm926ejs/mxs/mxs.c b/arch/arm/cpu/arm926ejs/mxs/mxs.c
index 5c7817074fd6..09b5c04cc9d2 100644
--- a/arch/arm/cpu/arm926ejs/mxs/mxs.c
+++ b/arch/arm/cpu/arm926ejs/mxs/mxs.c
@@ -178,8 +178,7 @@  const char *get_imx_type(u32 imxtype)
 int print_cpuinfo(void)
 {
 	u32 cpurev;
-	struct mxs_spl_data *data = (struct mxs_spl_data *)
-		((CONFIG_SYS_TEXT_BASE - sizeof(struct mxs_spl_data)) & ~0xf);
+	struct mxs_spl_data *data = MXS_SPL_DATA;
 
 	cpurev = get_cpu_rev();
 	printf("CPU:   Freescale i.MX%s rev%d.%d at %d MHz\n",
@@ -277,8 +276,7 @@  void imx_get_mac_from_fuse(int dev_id, unsigned char *mac)
 
 int mxs_dram_init(void)
 {
-	struct mxs_spl_data *data = (struct mxs_spl_data *)
-		((CONFIG_SYS_TEXT_BASE - sizeof(struct mxs_spl_data)) & ~0xf);
+	struct mxs_spl_data *data = MXS_SPL_DATA;
 
 	if (data->mem_dram_size == 0) {
 		printf("MXS:\n"
diff --git a/arch/arm/cpu/arm926ejs/mxs/spl_boot.c b/arch/arm/cpu/arm926ejs/mxs/spl_boot.c
index d9d1d73d1af4..0c3925640dc9 100644
--- a/arch/arm/cpu/arm926ejs/mxs/spl_boot.c
+++ b/arch/arm/cpu/arm926ejs/mxs/spl_boot.c
@@ -120,8 +120,7 @@  void mxs_common_spl_init(const uint32_t arg, const uint32_t *resptr,
 			 const iomux_cfg_t *iomux_setup,
 			 const unsigned int iomux_size)
 {
-	struct mxs_spl_data *data = (struct mxs_spl_data *)
-		((CONFIG_SYS_TEXT_BASE - sizeof(struct mxs_spl_data)) & ~0xf);
+	struct mxs_spl_data *data = MXS_SPL_DATA;
 	uint8_t bootmode = mxs_get_bootmode_index();
 	gd = &gdata;
 
diff --git a/arch/arm/include/asm/arch-mxs/sys_proto.h b/arch/arm/include/asm/arch-mxs/sys_proto.h
index 609676375b55..b23ee6d88768 100644
--- a/arch/arm/include/asm/arch-mxs/sys_proto.h
+++ b/arch/arm/include/asm/arch-mxs/sys_proto.h
@@ -85,6 +85,8 @@  static const struct mxs_pair mxs_boot_modes[] = {
 #define MXS_BM_SDMMC1_3V3		0x0a
 #define MXS_BM_SDMMC1_1V8		0x1a
 
+#define MXS_SPL_DATA ((struct mxs_spl_data *)(CONFIG_SYS_TEXT_BASE - 0x200))
+
 struct mxs_spl_data {
 	uint8_t		boot_mode_idx;
 	uint32_t	mem_dram_size;