Skip to contentSkip to conversation

ARM: mxs: make lowlevel_init() weak

PATCH New Mans Rullgard 4 participants 15 messages Apr 21, 2018 – May 7, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/5 ARM: mxs: make lowlevel_init() weak

With the full SPL framework enabled, lowlevel_init() is required. Make the empty stub weak so boards can override it.

---
 arch/arm/cpu/arm926ejs/mxs/mxs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/cpu/arm926ejs/mxs/mxs.c +1 -1
index 7a68a8f3ca74..5c7817074fd6 100644
@@ -24,7 +24,7 @@
 DECLARE_GLOBAL_DATA_PTR;
 
 /* Lowlevel init isn't used on i.MX28, so just have a dummy here */
-void lowlevel_init(void) {}
+__weak void lowlevel_init(void) {}
 
 void reset_cpu(ulong ignored) __attribute__((noreturn));
 
Signature · 1 line
2.17.0
#1 lore raw

PATCH 2/5 ARM: arm926ejs: fix lowlevel_init call

The code attempts to preserve the value of LR by storing it in R12/IP across the lowevel_init() call. However, this register is not saved by the callee. Use a register that guaranteed to be preserved instead.

---
 arch/arm/cpu/arm926ejs/start.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/cpu/arm926ejs/start.S +2 -2
index 959d1ed86d8a..a6f0bdb70345 100644
@@ -105,9 +105,9 @@ flush_dcache:
 	/*
 	 * Go setup Memory and board specific bits prior to relocation.
 	 */
-	mov	ip, lr		/* perserve link reg across call */
+	mov	r4, lr		/* perserve link reg across call */
 	bl	lowlevel_init	/* go setup pll,mux,memory */
-	mov	lr, ip		/* restore link */
+	mov	lr, r4		/* restore link */
 #endif
 	mov	pc, lr		/* back to my caller */
 #endif /* CONFIG_SKIP_LOWLEVEL_INIT */
Signature · 1 line
2.17.0
#2 lore raw

PATCH 2/5 ARM: arm926ejs: fix lowlevel_init call

Quoted 16 lines · Mans Rullgard

The code attempts to preserve the value of LR by storing it in R12/IP across the lowevel_init() call. However, this register is not saved by the callee. Use a register that guaranteed to be preserved instead.

---
 arch/arm/cpu/arm926ejs/start.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/cpu/arm926ejs/start.S +0 -0
index 959d1ed86d8a..a6f0bdb70345 100644
@@ -105,9 +105,9 @@ flush_dcache:
 	/*

arch/arm/cpu/arm926ejs/start.S flush_dcache: · line 113

Quoted 10 lines
arch/arm/cpu/arm926ejs/start.S +2 -2
 	 * Go setup Memory and board specific bits prior to relocation.
 	 */
-	mov	ip, lr		/* perserve link reg across call */
+	mov	r4, lr		/* perserve link reg across call */
 	bl	lowlevel_init	/* go setup pll,mux,memory */
-	mov	lr, ip		/* restore link */
+	mov	lr, r4		/* restore link */
 #endif
 	mov	pc, lr		/* back to my caller */
 #endif /* CONFIG_SKIP_LOWLEVEL_INIT */

Applied to u-boot-imx, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#3 lore raw

PATCH 2/5 ARM: arm926ejs: fix lowlevel_init call

Hi Mans, Stefano,

Quoted 11 lines · Stefano Babic

Review

Quoted 10 lines · Mans Rullgard

The code attempts to preserve the value of LR by storing it in R12/IP across the lowevel_init() call. However, this register is not saved by the callee. Use a register that guaranteed to be preserved instead.

---
 arch/arm/cpu/arm926ejs/start.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/arch/arm/cpu/arm926ejs/start.S

Quoted 10 lines
Quoted 10 lines

index 959d1ed86d8a..a6f0bdb70345 100644

arch/arm/cpu/arm926ejs/start.S +1 -1
@@ -105,9 +105,9 @@ flush_dcache:
      /*
       * Go setup Memory and board specific bits prior to relocation.
       */
-     mov     ip, lr          /* perserve link reg across call */
+     mov     r4, lr          /* perserve link reg across call */
      bl      lowlevel_init   /* go setup pll,mux,memory */
Quoted 8 lines

arch/arm/cpu/arm926ejs/start.S flush_dcache: · line 113

Quoted 6 lines
arch/arm/cpu/arm926ejs/start.S +1 -1
-     mov     lr, ip          /* restore link */
+     mov     lr, r4          /* restore link */
 #endif
      mov     pc, lr          /* back to my caller */
 #endif /* CONFIG_SKIP_LOWLEVEL_INIT */

Applied to u-boot-imx, thanks !

I think this might be causing me a problem on a Marvell Kirkwood board I'm working on getting into upstream. It may also be problematic for orion5x boards. Both of these use r4 in lowlevel_init.

Obviously I can fix the board that I'm working on. Is there some expectation as to which registers can be clobbered?

#4 lore raw

PATCH 2/5 ARM: arm926ejs: fix lowlevel_init call

Quoted 39 lines · Chris Packham

Hi Mans, Stefano,

Quoted 11 lines · Stefano Babic

Review

Quoted 10 lines · Mans Rullgard

The code attempts to preserve the value of LR by storing it in R12/IP across the lowevel_init() call. However, this register is not saved by the callee. Use a register that guaranteed to be preserved instead.

---
arch/arm/cpu/arm926ejs/start.S | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/arch/arm/cpu/arm926ejs/start.S

Quoted 10 lines
Quoted 10 lines

index 959d1ed86d8a..a6f0bdb70345 100644

arch/arm/cpu/arm926ejs/start.S +1 -1
@@ -105,9 +105,9 @@ flush_dcache:
     /*
      * Go setup Memory and board specific bits prior to relocation.
      */
-     mov     ip, lr          /* perserve link reg across call */
+     mov     r4, lr          /* perserve link reg across call */
     bl      lowlevel_init   /* go setup pll,mux,memory */
Quoted 8 lines

arch/arm/cpu/arm926ejs/start.S flush_dcache: · line 113

Quoted 6 lines
arch/arm/cpu/arm926ejs/start.S +1 -1
-     mov     lr, ip          /* restore link */
+     mov     lr, r4          /* restore link */
 #endif
     mov     pc, lr          /* back to my caller */
 #endif /* CONFIG_SKIP_LOWLEVEL_INIT */

Applied to u-boot-imx, thanks !

Quoted 6 lines

I think this might be causing me a problem on a Marvell Kirkwood board I'm working on getting into upstream. It may also be problematic for orion5x boards. Both of these use r4 in lowlevel_init.

Obviously I can fix the board that I'm working on. Is there some expectation as to which registers can be clobbered?

The "Procedure Call Standard for the ARM® Architecture” may help:
http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042f/IHI0042F_aapcs.pdf
Page 15

A subroutine must preserve the contents of the registers r4-r8, r10, r11 and SP (and r9 in PCS variants that designate r9 as v6).

So for thumb r1-r3 and r12 should be usable without taking any care of them. Maybe r13 depending if you already have a stack or not.

Regards,
Klaus

#5 lore raw

PATCH 2/5 ARM: arm926ejs: fix lowlevel_init call

Hi Klaus,

Quoted 10 lines · On Mon, May 7, 2018 at 8:48 PM <[email protected]> wrote:
Quoted 10 lines · Chris Packham

Hi Mans, Stefano,

Quoted 4 lines · Stefano Babic
Quoted 3 lines · Mans Rullgard

The code attempts to preserve the value of LR by storing it in R12/IP across the lowevel_init() call. However, this register is not saved by the callee. Use a register that guaranteed to be preserved

instead.

Quoted 25 lines
Quoted 25 lines
Quoted 7 lines

Review

Quoted 7 lines

---
arch/arm/cpu/arm926ejs/start.S | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/arch/arm/cpu/arm926ejs/start.S

Quoted 16 lines
Quoted 16 lines

index 959d1ed86d8a..a6f0bdb70345 100644

arch/arm/cpu/arm926ejs/start.S +2 -2
@@ -105,9 +105,9 @@ flush_dcache:
     /*
      * Go setup Memory and board specific bits prior to relocation.
      */
-     mov     ip, lr          /* perserve link reg across call */
+     mov     r4, lr          /* perserve link reg across call */
     bl      lowlevel_init   /* go setup pll,mux,memory */
-     mov     lr, ip          /* restore link */
+     mov     lr, r4          /* restore link */
 #endif
     mov     pc, lr          /* back to my caller */
 #endif /* CONFIG_SKIP_LOWLEVEL_INIT */
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

Applied to u-boot-imx, thanks !

I think this might be causing me a problem on a Marvell Kirkwood board

I'm

Quoted 7 lines
Quoted 5 lines

working on getting into upstream. It may also be problematic for orion5x boards. Both of these use r4 in lowlevel_init.

Obviously I can fix the board that I'm working on. Is there some expectation as to which registers can be clobbered?

The "Procedure Call Standard for the ARM® Architecture” may help:

http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042f/IHI0042F_aapcs.pdf

Quoted 3 lines

Page 15

A subroutine must preserve the contents of the registers r4-r8, r10,

r11 and

Quoted 3 lines

SP (and r9 in PCS variants that designate r9 as v6).

So for thumb r1-r3 and r12 should be usable without taking any care of

them.

Quoted 1 line

Maybe r13 depending if you already have a stack or not.

Thanks. I figured there was probably some document that described this. I started looking at EABI docs but didn't find anything last night.

#6 lore raw

PATCH 2/5 ARM: arm926ejs: fix lowlevel_init call

In reply to Chris Packham
Quoted 35 lines · Chris Packham

Hi Mans, Stefano,

Quoted 11 lines · Stefano Babic

Review

Quoted 10 lines · Mans Rullgard

The code attempts to preserve the value of LR by storing it in R12/IP across the lowevel_init() call. However, this register is not saved by the callee. Use a register that guaranteed to be preserved instead.

---
 arch/arm/cpu/arm926ejs/start.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/arch/arm/cpu/arm926ejs/start.S

Quoted 10 lines
Quoted 10 lines

index 959d1ed86d8a..a6f0bdb70345 100644

arch/arm/cpu/arm926ejs/start.S +1 -1
@@ -105,9 +105,9 @@ flush_dcache:
      /*
       * Go setup Memory and board specific bits prior to relocation.
       */
-     mov     ip, lr          /* perserve link reg across call */
+     mov     r4, lr          /* perserve link reg across call */
      bl      lowlevel_init   /* go setup pll,mux,memory */
Quoted 8 lines

arch/arm/cpu/arm926ejs/start.S flush_dcache: · line 113

Quoted 6 lines
arch/arm/cpu/arm926ejs/start.S +1 -1
-     mov     lr, ip          /* restore link */
+     mov     lr, r4          /* restore link */
 #endif
      mov     pc, lr          /* back to my caller */
 #endif /* CONFIG_SKIP_LOWLEVEL_INIT */

Applied to u-boot-imx, thanks !

Quoted 3 lines

I think this might be causing me a problem on a Marvell Kirkwood board I'm working on getting into upstream. It may also be problematic for orion5x boards. Both of these use r4 in lowlevel_init.

I've just sent an untested patch for orion5x.

Signature · 1 line
Måns Rullgård
#7 lore raw

PATCH 2/5 ARM: arm926ejs: fix lowlevel_init call

Quoted 10 lines · Måns Rullgård
Quoted 8 lines · Chris Packham

Hi Mans, Stefano,

Quoted 4 lines · Stefano Babic
Quoted 3 lines · Mans Rullgard

The code attempts to preserve the value of LR by storing it in R12/IP across the lowevel_init() call. However, this register is not saved by the callee. Use a register that guaranteed to be preserved

instead.

Quoted 25 lines
Quoted 25 lines
Quoted 7 lines

Review

Quoted 7 lines
---
 arch/arm/cpu/arm926ejs/start.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/arch/arm/cpu/arm926ejs/start.S

Quoted 16 lines
Quoted 16 lines

index 959d1ed86d8a..a6f0bdb70345 100644

arch/arm/cpu/arm926ejs/start.S +2 -2
@@ -105,9 +105,9 @@ flush_dcache:
      /*
       * Go setup Memory and board specific bits prior to relocation.
       */
-     mov     ip, lr          /* perserve link reg across call */
+     mov     r4, lr          /* perserve link reg across call */
      bl      lowlevel_init   /* go setup pll,mux,memory */
-     mov     lr, ip          /* restore link */
+     mov     lr, r4          /* restore link */
 #endif
      mov     pc, lr          /* back to my caller */
 #endif /* CONFIG_SKIP_LOWLEVEL_INIT */
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

Applied to u-boot-imx, thanks !

I think this might be causing me a problem on a Marvell Kirkwood board

I'm

Quoted 4 lines
Quoted 2 lines

working on getting into upstream. It may also be problematic for orion5x boards. Both of these use r4 in lowlevel_init.

I've just sent an untested patch for orion5x.

Thanks for that.

#8 lore raw

PATCH 3/5 ARM: spl: include arm/thumb glue sections

In reply to Mans Rullgard

When building in Thumb mode, the linker might generate mode switching stubs in .glue sections. Include these in the final link.

---
 arch/arm/cpu/u-boot-spl.lds | 1 +
 1 file changed, 1 insertion(+)
arch/arm/cpu/u-boot-spl.lds +1 -0
index 65f7b68861e2..38fc9b44c8c7 100644
@@ -21,6 +21,7 @@ SECTIONS
 		*(.vectors)
 		CPUDIR/start.o (.text*)
 		*(.text*)
+		*(.glue*)
 	}
 
 	. = ALIGN(4);
Signature · 1 line
2.17.0
#9 lore raw

PATCH 3/5 ARM: spl: include arm/thumb glue sections

Quoted 14 lines · Mans Rullgard

When building in Thumb mode, the linker might generate mode switching stubs in .glue sections. Include these in the final link.

---
 arch/arm/cpu/u-boot-spl.lds | 1 +
 1 file changed, 1 insertion(+)
arch/arm/cpu/u-boot-spl.lds +0 -0
index 65f7b68861e2..38fc9b44c8c7 100644

arch/arm/cpu/u-boot-spl.lds SECTIONS · line 27

Quoted 7 lines
arch/arm/cpu/u-boot-spl.lds +1 -0
@@ -21,6 +21,7 @@ SECTIONS
 		*(.vectors)
 		CPUDIR/start.o (.text*)
 		*(.text*)
+		*(.glue*)
 	}
 
 	. = ALIGN(4);

Applied to u-boot-imx, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#10 lore raw

PATCH 4/5 ARM: mxs: move spl data

In reply to Mans Rullgard

With full SPL enabled, the loaded image overwrites the mxs_spl_data location. Moving it a slightly lower address fixes this.

---
 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(-)
arch/arm/cpu/arm926ejs/mxs/mxs.c +2 -4
index 5c7817074fd6..09b5c04cc9d2 100644
@@ -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"
arch/arm/cpu/arm926ejs/mxs/spl_boot.c +1 -2
index d9d1d73d1af4..0c3925640dc9 100644
@@ -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;
 
arch/arm/include/asm/arch-mxs/sys_proto.h +2 -0
index 609676375b55..b23ee6d88768 100644
@@ -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;
Signature · 1 line
2.17.0
#11 lore raw

PATCH 4/5 ARM: mxs: move spl data

Quoted 54 lines · Mans Rullgard

With full SPL enabled, the loaded image overwrites the mxs_spl_data location. Moving it a slightly lower address fixes this.

---
 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(-)
arch/arm/cpu/arm926ejs/mxs/mxs.c +2 -4
index 5c7817074fd6..09b5c04cc9d2 100644
@@ -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"
arch/arm/cpu/arm926ejs/mxs/spl_boot.c +1 -2
index d9d1d73d1af4..0c3925640dc9 100644
@@ -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;
 
arch/arm/include/asm/arch-mxs/sys_proto.h +0 -0
index 609676375b55..b23ee6d88768 100644

arch/arm/include/asm/arch-mxs/sys_proto.h static const struct mxs_pair mxs_boot_modes[] = { · line 92

Quoted 8 lines
arch/arm/include/asm/arch-mxs/sys_proto.h +2 -0
@@ -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

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#12 lore raw

PATCH 5/5 ARM: mxs: support full SPL framework

In reply to Mans Rullgard

This allows using the full SPL framework on mxs devices. In this mode, the u-boot.sb image loaded by the boot ROM contains only the SPL which then loads U-Boot proper or a kernel in falcon mode.

---
 arch/arm/Kconfig                                 | 2 +-
 arch/arm/cpu/arm926ejs/mxs/Makefile              | 4 ++--
 arch/arm/cpu/arm926ejs/mxs/mxsimage-spl.mx23.cfg | 5 +++++
 arch/arm/cpu/arm926ejs/mxs/mxsimage-spl.mx28.cfg | 6 ++++++
 arch/arm/cpu/arm926ejs/mxs/spl_boot.c            | 2 ++
 include/configs/mxs.h                            | 2 ++
 6 files changed, 18 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/cpu/arm926ejs/mxs/mxsimage-spl.mx23.cfg
 create mode 100644 arch/arm/cpu/arm926ejs/mxs/mxsimage-spl.mx28.cfg
arch/arm/Kconfig +1 -1
index 7212fc5afa72..0acdd162b4b3 100644
@@ -1352,7 +1352,7 @@ source "arch/arm/Kconfig.debug"
 endmenu
 
 config SPL_LDSCRIPT
-        default "arch/arm/cpu/arm926ejs/mxs/u-boot-spl.lds" if ARCH_MX23 || ARCH_MX28
+        default "arch/arm/cpu/arm926ejs/mxs/u-boot-spl.lds" if (ARCH_MX23 || ARCH_MX28) && !SPL_FRAMEWORK
         default "arch/arm/cpu/arm1136/u-boot-spl.lds" if CPU_ARM1136
 	default "arch/arm/cpu/armv8/u-boot-spl.lds" if ARM64
 
arch/arm/cpu/arm926ejs/mxs/Makefile +2 -2
index 71c2c0e7b40c..83b05acfa4eb 100644
@@ -14,8 +14,8 @@ obj-y	+= spl_boot.o spl_lradc_init.o spl_mem_init.o spl_power_init.o
 endif
 
 # Specify the target for use in elftosb call
-MKIMAGE_TARGET-$(CONFIG_MX23) = mxsimage.mx23.cfg
-MKIMAGE_TARGET-$(CONFIG_MX28) = mxsimage.mx28.cfg
+MKIMAGE_TARGET-$(CONFIG_MX23) = mxsimage$(CONFIG_SPL_FRAMEWORK:%=-spl).mx23.cfg
+MKIMAGE_TARGET-$(CONFIG_MX28) = mxsimage$(CONFIG_SPL_FRAMEWORK:%=-spl).mx28.cfg
 
 # Generate HAB-capable IVT
 #
arch/arm/cpu/arm926ejs/mxs/mxsimage-spl.mx23.cfg new file +5 -0
new file mode 100644
index 000000000000..ab2183ed3795
@@ -0,0 +1,5 @@
+DISPLAYPROGRESS
+SECTION 0x0 BOOTABLE
+ TAG LAST
+ LOAD     0x1000     spl/u-boot-spl.bin
+ CALL     0x1000     0x0
arch/arm/cpu/arm926ejs/mxs/mxsimage-spl.mx28.cfg new file +6 -0
new file mode 100644
index 000000000000..0d95064ff7f1
@@ -0,0 +1,6 @@
+DISPLAYPROGRESS
+SECTION 0x0 BOOTABLE
+ TAG LAST
+ LOAD     0x1000     spl/u-boot-spl.bin
+ LOAD IVT 0x8000     0x1000
+ CALL HAB 0x8000     0x0
arch/arm/cpu/arm926ejs/mxs/spl_boot.c +2 -0
index 0c3925640dc9..bc39465fc4e0 100644
@@ -146,6 +146,7 @@ void mxs_common_spl_init(const uint32_t arg, const uint32_t *resptr,
 	}
 }
 
+#ifndef CONFIG_SPL_FRAMEWORK
 /* Support aparatus */
 inline void board_init_f(unsigned long bootflag)
 {
@@ -158,3 +159,4 @@ inline void board_init_r(gd_t *id, ulong dest_addr)
 	for (;;)
 		;
 }
+#endif
include/configs/mxs.h +2 -0
index f07f81c8415c..0fe0770e13f0 100644
@@ -44,8 +44,10 @@
 /* Startup hooks */
 
 /* SPL */
+#ifndef CONFIG_SPL_FRAMEWORK
 #define CONFIG_SPL_NO_CPU_SUPPORT_CODE
 #define CONFIG_SPL_START_S_PATH	"arch/arm/cpu/arm926ejs/mxs"
+#endif
 
 /* Memory sizes */
 #define CONFIG_SYS_MALLOC_LEN		0x00400000	/* 4 MB for malloc */
Signature · 1 line
2.17.0
#13 lore raw

PATCH 5/5 ARM: mxs: support full SPL framework

Quoted 90 lines · Mans Rullgard

This allows using the full SPL framework on mxs devices. In this mode, the u-boot.sb image loaded by the boot ROM contains only the SPL which then loads U-Boot proper or a kernel in falcon mode.

---
 arch/arm/Kconfig                                 | 2 +-
 arch/arm/cpu/arm926ejs/mxs/Makefile              | 4 ++--
 arch/arm/cpu/arm926ejs/mxs/mxsimage-spl.mx23.cfg | 5 +++++
 arch/arm/cpu/arm926ejs/mxs/mxsimage-spl.mx28.cfg | 6 ++++++
 arch/arm/cpu/arm926ejs/mxs/spl_boot.c            | 2 ++
 include/configs/mxs.h                            | 2 ++
 6 files changed, 18 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/cpu/arm926ejs/mxs/mxsimage-spl.mx23.cfg
 create mode 100644 arch/arm/cpu/arm926ejs/mxs/mxsimage-spl.mx28.cfg
arch/arm/Kconfig +1 -1
index 7212fc5afa72..0acdd162b4b3 100644
@@ -1352,7 +1352,7 @@ source "arch/arm/Kconfig.debug"
 endmenu
 
 config SPL_LDSCRIPT
-        default "arch/arm/cpu/arm926ejs/mxs/u-boot-spl.lds" if ARCH_MX23 || ARCH_MX28
+        default "arch/arm/cpu/arm926ejs/mxs/u-boot-spl.lds" if (ARCH_MX23 || ARCH_MX28) && !SPL_FRAMEWORK
         default "arch/arm/cpu/arm1136/u-boot-spl.lds" if CPU_ARM1136
 	default "arch/arm/cpu/armv8/u-boot-spl.lds" if ARM64
 
arch/arm/cpu/arm926ejs/mxs/Makefile +2 -2
index 71c2c0e7b40c..83b05acfa4eb 100644
@@ -14,8 +14,8 @@ obj-y	+= spl_boot.o spl_lradc_init.o spl_mem_init.o spl_power_init.o
 endif
 
 # Specify the target for use in elftosb call
-MKIMAGE_TARGET-$(CONFIG_MX23) = mxsimage.mx23.cfg
-MKIMAGE_TARGET-$(CONFIG_MX28) = mxsimage.mx28.cfg
+MKIMAGE_TARGET-$(CONFIG_MX23) = mxsimage$(CONFIG_SPL_FRAMEWORK:%=-spl).mx23.cfg
+MKIMAGE_TARGET-$(CONFIG_MX28) = mxsimage$(CONFIG_SPL_FRAMEWORK:%=-spl).mx28.cfg
 
 # Generate HAB-capable IVT
 #
arch/arm/cpu/arm926ejs/mxs/mxsimage-spl.mx23.cfg new file +5 -0
new file mode 100644
index 000000000000..ab2183ed3795
@@ -0,0 +1,5 @@
+DISPLAYPROGRESS
+SECTION 0x0 BOOTABLE
+ TAG LAST
+ LOAD     0x1000     spl/u-boot-spl.bin
+ CALL     0x1000     0x0
arch/arm/cpu/arm926ejs/mxs/mxsimage-spl.mx28.cfg new file +6 -0
new file mode 100644
index 000000000000..0d95064ff7f1
@@ -0,0 +1,6 @@
+DISPLAYPROGRESS
+SECTION 0x0 BOOTABLE
+ TAG LAST
+ LOAD     0x1000     spl/u-boot-spl.bin
+ LOAD IVT 0x8000     0x1000
+ CALL HAB 0x8000     0x0
arch/arm/cpu/arm926ejs/mxs/spl_boot.c +2 -0
index 0c3925640dc9..bc39465fc4e0 100644
@@ -146,6 +146,7 @@ void mxs_common_spl_init(const uint32_t arg, const uint32_t *resptr,
 	}
 }
 
+#ifndef CONFIG_SPL_FRAMEWORK
 /* Support aparatus */
 inline void board_init_f(unsigned long bootflag)
 {
@@ -158,3 +159,4 @@ inline void board_init_r(gd_t *id, ulong dest_addr)
 	for (;;)
 		;
 }
+#endif
include/configs/mxs.h +0 -0
index f07f81c8415c..0fe0770e13f0 100644

include/configs/mxs.h line 53

Quoted 10 lines
include/configs/mxs.h +2 -0
@@ -44,8 +44,10 @@
 /* Startup hooks */
 
 /* SPL */
+#ifndef CONFIG_SPL_FRAMEWORK
 #define CONFIG_SPL_NO_CPU_SUPPORT_CODE
 #define CONFIG_SPL_START_S_PATH	"arch/arm/cpu/arm926ejs/mxs"
+#endif
 
 /* Memory sizes */
 #define CONFIG_SYS_MALLOC_LEN		0x00400000	/* 4 MB for malloc */

Applied to u-boot-imx, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#14 lore raw

PATCH 1/5 ARM: mxs: make lowlevel_init() weak

In reply to Mans Rullgard
Quoted 14 lines · Mans Rullgard

With the full SPL framework enabled, lowlevel_init() is required. Make the empty stub weak so boards can override it.

---
 arch/arm/cpu/arm926ejs/mxs/mxs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/cpu/arm926ejs/mxs/mxs.c +0 -0
index 7a68a8f3ca74..5c7817074fd6 100644

arch/arm/cpu/arm926ejs/mxs/mxs.c line 30

Quoted 8 lines
arch/arm/cpu/arm926ejs/mxs/mxs.c +1 -1
@@ -24,7 +24,7 @@
 DECLARE_GLOBAL_DATA_PTR;
 
 /* Lowlevel init isn't used on i.MX28, so just have a dummy here */
-void lowlevel_init(void) {}
+__weak void lowlevel_init(void) {}
 
 void reset_cpu(ulong ignored) __attribute__((noreturn));
 

Applied to u-boot-imx, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================