Skip to contentSkip to conversation

arm: socfpga: arria10: Add save_boot_params()

PATCH Superseded Ley Foon Tan 4 participants 13 messages Feb 26, 2020 – Mar 6, 2020

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: socfpga: arria10: Add save_boot_params()

Add save_boot_params() to save reset status value from bootrom.

Bootrom will clear the status register in reset manager and stores the reset status value in shared memory. Bootrom stores shared data at last 2KB of onchip RAM.

This function save reset status provided by BootROM to rst_mgr_status. More information about reset status register value can be found in reset manager register description.

When running in debugger without Bootrom, r0 to r3 are random values. So, skip save the value when r0 is not BootROM shared data address.

---
 arch/arm/mach-socfpga/spl_a10.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
arch/arm/mach-socfpga/spl_a10.c +30 -0
index d9ef851054..867b1c906e 100644
@@ -33,6 +33,36 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#define BOOTROM_SHARED_MEM_ADDR		(CONFIG_SYS_INIT_RAM_ADDR + 0x40000 \
+					 - 0x800)
+#define RST_STATUS_SHARED_ADDR		(BOOTROM_SHARED_MEM_ADDR + 0x438)
+u32 rst_mgr_status __section(.data);
+
+/*
+ * Bootrom will clear the status register in reset manager and stores the
+ * reset status value in shared memory. Bootrom stores shared data at last
+ * 2KB of onchip RAM.
+ * This function save reset status provided by BootROM to rst_mgr_status.
+ * More information about reset status register value can be found in reset
+ * manager register description.
+ * When running in debugger without Bootrom, r0 to r3 are random values.
+ * So, skip save the value when r0 is not BootROM shared data address.
+ *
+ * r0 - Contains the pointer to the shared memory block. The shared
+ *	memory block is located in the top 2 KB of on-chip RAM.
+ * r1 - contains the length of the shared memory.
+ * r2 - unused and set to 0x0.
+ * r3 - points to the version block.
+ */
+void save_boot_params(unsigned long r0, unsigned long r1, unsigned long r2,
+		      unsigned long r3)
+{
+	if (r0 == BOOTROM_SHARED_MEM_ADDR)
+		rst_mgr_status = readl(RST_STATUS_SHARED_ADDR);
+
+	save_boot_params_ret();
+}
+
 u32 spl_boot_device(void)
 {
 	const u32 bsel = readl(socfpga_get_sysmgr_addr() + SYSMGR_A10_BOOTINFO);
Signature · 1 line
2.19.0
#1 lore raw

PATCH 1/1 arm: socfpga: arria10: Add save_boot_params()

On 2/26/20 8:01 PM, Ley Foon Tan wrote:
[...]

arch/arm/mach-socfpga/spl_a10.c line 38

Quoted 3 lines
arch/arm/mach-socfpga/spl_a10.c +3 -0
+#define BOOTROM_SHARED_MEM_ADDR		(CONFIG_SYS_INIT_RAM_ADDR + 0x40000 \
+					 - 0x800)
+#define RST_STATUS_SHARED_ADDR		(BOOTROM_SHARED_MEM_ADDR + 0x438)

Are all these magic values needed or is there some more descriptive macro name available for them ?

Quoted 1 line

+u32 rst_mgr_status __section(.data);

static u32 ... ?

Quoted 30 lines
arch/arm/mach-socfpga/spl_a10.c +26 -0
+
+/*
+ * Bootrom will clear the status register in reset manager and stores the
+ * reset status value in shared memory. Bootrom stores shared data at last
+ * 2KB of onchip RAM.
+ * This function save reset status provided by BootROM to rst_mgr_status.
+ * More information about reset status register value can be found in reset
+ * manager register description.
+ * When running in debugger without Bootrom, r0 to r3 are random values.
+ * So, skip save the value when r0 is not BootROM shared data address.
+ *
+ * r0 - Contains the pointer to the shared memory block. The shared
+ *	memory block is located in the top 2 KB of on-chip RAM.
+ * r1 - contains the length of the shared memory.
+ * r2 - unused and set to 0x0.
+ * r3 - points to the version block.
+ */
+void save_boot_params(unsigned long r0, unsigned long r1, unsigned long r2,
+		      unsigned long r3)
+{
+	if (r0 == BOOTROM_SHARED_MEM_ADDR)
+		rst_mgr_status = readl(RST_STATUS_SHARED_ADDR);
+
+	save_boot_params_ret();
+}
+
 u32 spl_boot_device(void)
 {
 	const u32 bsel = readl(socfpga_get_sysmgr_addr() + SYSMGR_A10_BOOTINFO);
Signature · 2 lines
Best regards,
Marek Vasut
#2 lore raw

PATCH 1/1 arm: socfpga: arria10: Add save_boot_params()

Quoted 13 lines

-----Original Message-----
From: Marek Vasut <[email protected]>
Sent: Sunday, March 1, 2020 11:12 PM
To: Tan, Ley Foon <[email protected]>; u-boot at lists.denx.de
Cc: Simon Goldschmidt <[email protected]>; Ley Foon Tan <[email protected]>; See, Chin Liang <[email protected]>; Chee, Tien Fong <[email protected]>
Subject: Re: [PATCH] arm: socfpga: arria10: Add save_boot_params()

On 2/26/20 8:01 PM, Ley Foon Tan wrote:
[...]

Quoted 8 lines
Quoted 1 line

+#define BOOTROM_SHARED_MEM_ADDR

	(CONFIG_SYS_INIT_RAM_ADDR + 0x40000 \

Review

Quoted 2 lines
(quoted diff) +2 -0
+					 - 0x800)
+#define RST_STATUS_SHARED_ADDR
	(BOOTROM_SHARED_MEM_ADDR + 0x438)

Are all these magic values needed or is there some more descriptive macro name available for them ?

0x40000 is onchip ram size and 0x800 is 2KB size.
I can convert these to 2 macos.

Quoted 4 lines
Quoted 2 lines

+u32 rst_mgr_status __section(.data);

static u32 ... ?

Other files might want to use this.

Thanks.

Regards
Ley Foon

#3 lore raw

PATCH 1/1 arm: socfpga: arria10: Add save_boot_params()

On 3/2/20 8:20 AM, Tan, Ley Foon wrote:
Hi,

[...]

Quoted 4 lines
Quoted 4 lines · Ley Foon Tan

[...]

Quoted 1 line

+#define BOOTROM_SHARED_MEM_ADDR

	(CONFIG_SYS_INIT_RAM_ADDR + 0x40000 \
Quoted 8 lines
Quoted 6 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+					 - 0x800)
+#define RST_STATUS_SHARED_ADDR
	(BOOTROM_SHARED_MEM_ADDR + 0x438)

Are all these magic values needed or is there some more descriptive macro name available for them ?

0x40000 is onchip ram size and 0x800 is 2KB size.
I can convert these to 2 macos.

Aren't those already defined in include/configs/socfpga_common.h ?

Quoted 4 lines
Quoted 3 lines
Quoted 1 line

+u32 rst_mgr_status __section(.data);

static u32 ... ?

Other files might want to use this.

But they currently don't ? If others want to use it, they can remove the static then.

#4 lore raw

PATCH 1/1 arm: socfpga: arria10: Add save_boot_params()

Quoted 12 lines · Marek Vasut

On 3/2/20 8:20 AM, Tan, Ley Foon wrote:
Hi,

[...]

Quoted 6 lines
Quoted 6 lines · Ley Foon Tan

[...]

Quoted 1 line

+#define BOOTROM_SHARED_MEM_ADDR

     (CONFIG_SYS_INIT_RAM_ADDR + 0x40000 \
Quoted 2 lines
(quoted diff) +2 -0
+                                    - 0x800)
+#define RST_STATUS_SHARED_ADDR
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
     (BOOTROM_SHARED_MEM_ADDR + 0x438)

Are all these magic values needed or is there some more descriptive macro name available for them ?

0x40000 is onchip ram size and 0x800 is 2KB size.
I can convert these to 2 macos.

Aren't those already defined in include/configs/socfpga_common.h ?

socfpga_common.h have this:
#define CONFIG_SYS_INIT_RAM_SIZE (0x40000 - CONFIG_SYS_SPL_MALLOC_SIZE)

But, we can't use it here.

Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines

+u32 rst_mgr_status __section(.data);

static u32 ... ?

Other files might want to use this.

But they currently don't ? If others want to use it, they can remove the static then.

Okay.

Regards
Ley Foon

#5 lore raw

PATCH 1/1 arm: socfpga: arria10: Add save_boot_params()

Quoted 17 lines · Ley Foon Tan
Quoted 16 lines · Marek Vasut

On 3/2/20 8:20 AM, Tan, Ley Foon wrote:
Hi,

[...]

Quoted 10 lines
Quoted 10 lines · Ley Foon Tan

[...]

Quoted 1 line

+#define BOOTROM_SHARED_MEM_ADDR

     (CONFIG_SYS_INIT_RAM_ADDR + 0x40000 \

Review

Quoted 2 lines
(quoted diff) +2 -0
+                                    - 0x800)
+#define RST_STATUS_SHARED_ADDR
     (BOOTROM_SHARED_MEM_ADDR + 0x438)

Are all these magic values needed or is there some more descriptive macro name available for them ?

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

0x40000 is onchip ram size and 0x800 is 2KB size.
I can convert these to 2 macos.

Aren't those already defined in include/configs/socfpga_common.h ?

socfpga_common.h have this:
#define CONFIG_SYS_INIT_RAM_SIZE (0x40000 - CONFIG_SYS_SPL_MALLOC_SIZE)

But, we can't use it here.

Why ?

[...]

#6 lore raw

PATCH 1/1 arm: socfpga: arria10: Add save_boot_params()

Quoted 32 lines

-----Original Message-----
From: Marek Vasut <[email protected]>
Sent: Tuesday, March 3, 2020 8:13 PM
To: Ley Foon Tan <[email protected]>
Cc: Tan, Ley Foon <[email protected]>; u-boot at lists.denx.de; Simon Goldschmidt <[email protected]>; See, Chin Liang <[email protected]>; Chee, Tien Fong <[email protected]>
Subject: Re: [PATCH] arm: socfpga: arria10: Add save_boot_params()

Quoted 20 lines · Ley Foon Tan
Quoted 19 lines · Marek Vasut

On 3/2/20 8:20 AM, Tan, Ley Foon wrote:
Hi,

[...]

Quoted 12 lines
Quoted 10 lines · Ley Foon Tan

[...]

Quoted 1 line

+#define BOOTROM_SHARED_MEM_ADDR

     (CONFIG_SYS_INIT_RAM_ADDR + 0x40000 \

Review

Quoted 2 lines
(quoted diff) +2 -0
+                                    - 0x800) #define
+RST_STATUS_SHARED_ADDR
     (BOOTROM_SHARED_MEM_ADDR + 0x438)

Are all these magic values needed or is there some more descriptive macro name available for them ?

0x40000 is onchip ram size and 0x800 is 2KB size.
I can convert these to 2 macos.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Aren't those already defined in include/configs/socfpga_common.h ?

socfpga_common.h have this:
#define CONFIG_SYS_INIT_RAM_SIZE (0x40000 -

CONFIG_SYS_SPL_MALLOC_SIZE)

Quoted 2 lines

But, we can't use it here.

Why ?

CONFIG_SYS_INIT_RAM_SIZE is minus with CONFIG_SYS_SPL_MALLOC_SIZE, not 256KB (0x40000).

Regards
Ley Foon

#7 lore raw

PATCH 1/1 arm: socfpga: arria10: Add save_boot_params()

Quoted 33 lines · Ley Foon
Quoted 33 lines

-----Original Message-----
From: Marek Vasut <[email protected]>
Sent: Tuesday, March 3, 2020 8:13 PM
To: Ley Foon Tan <[email protected]>
Cc: Tan, Ley Foon <[email protected]>; u-boot at lists.denx.de; Simon Goldschmidt <[email protected]>; See, Chin Liang <[email protected]>; Chee, Tien Fong <[email protected]>
Subject: Re: [PATCH] arm: socfpga: arria10: Add save_boot_params()

Quoted 21 lines · Ley Foon Tan
Quoted 20 lines · Marek Vasut

On 3/2/20 8:20 AM, Tan, Ley Foon wrote:
Hi,

[...]

Quoted 4 lines
Quoted 4 lines · Ley Foon Tan

[...]

Quoted 1 line

+#define BOOTROM_SHARED_MEM_ADDR

     (CONFIG_SYS_INIT_RAM_ADDR + 0x40000 \
Quoted 8 lines
Quoted 6 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+                                    - 0x800) #define
+RST_STATUS_SHARED_ADDR
     (BOOTROM_SHARED_MEM_ADDR + 0x438)

Are all these magic values needed or is there some more descriptive macro name available for them ?

0x40000 is onchip ram size and 0x800 is 2KB size.
I can convert these to 2 macos.

Aren't those already defined in include/configs/socfpga_common.h ?

Quoted 8 lines
Quoted 7 lines
Quoted 2 lines

socfpga_common.h have this:
#define CONFIG_SYS_INIT_RAM_SIZE (0x40000 -

CONFIG_SYS_SPL_MALLOC_SIZE)

Quoted 2 lines

But, we can't use it here.

Why ?

CONFIG_SYS_INIT_RAM_SIZE is minus with CONFIG_SYS_SPL_MALLOC_SIZE, not 256KB (0x40000).

Then define the init ram size macro somewhere in arch/arm/mach-socfpga/include and use it in both the configs/ and your code ? :)

#8 lore raw

PATCH 1/1 arm: socfpga: arria10: Add save_boot_params()

Quoted 39 lines · Marek Vasut
Quoted 37 lines · Ley Foon
Quoted 37 lines

-----Original Message-----
From: Marek Vasut <[email protected]>
Sent: Tuesday, March 3, 2020 8:13 PM
To: Ley Foon Tan <[email protected]>
Cc: Tan, Ley Foon <[email protected]>; u-boot at lists.denx.de; Simon Goldschmidt <[email protected]>; See, Chin Liang <[email protected]>; Chee, Tien Fong <[email protected]>
Subject: Re: [PATCH] arm: socfpga: arria10: Add save_boot_params()

Quoted 15 lines · Ley Foon Tan
Quoted 14 lines · Marek Vasut

On 3/2/20 8:20 AM, Tan, Ley Foon wrote:
Hi,

[...]

Quoted 8 lines
Quoted 8 lines · Ley Foon Tan

[...]

Quoted 1 line

+#define BOOTROM_SHARED_MEM_ADDR

     (CONFIG_SYS_INIT_RAM_ADDR + 0x40000 \

Review

Quoted 2 lines
(quoted diff) +2 -0
+                                    - 0x800) #define
+RST_STATUS_SHARED_ADDR
     (BOOTROM_SHARED_MEM_ADDR + 0x438)
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Are all these magic values needed or is there some more descriptive macro name available for them ?

0x40000 is onchip ram size and 0x800 is 2KB size.
I can convert these to 2 macos.

Aren't those already defined in include/configs/socfpga_common.h ?

socfpga_common.h have this:
#define CONFIG_SYS_INIT_RAM_SIZE (0x40000 -

CONFIG_SYS_SPL_MALLOC_SIZE)

Quoted 1 line
Quoted 8 lines
Quoted 4 lines
Quoted 3 lines
Quoted 1 line

But, we can't use it here.

Why ?

CONFIG_SYS_INIT_RAM_SIZE is minus with CONFIG_SYS_SPL_MALLOC_SIZE, not 256KB (0x40000).

Then define the init ram size macro somewhere in arch/arm/mach-socfpga/include and use it in both the configs/ and your code ? :)

Look at existing header files under arch/arm/mach-socfpga/include/, can add to base_addr_a10.h.

Regards
Ley Foon

#9 lore raw

PATCH 1/1 arm: socfpga: arria10: Add save_boot_params()

On 3/5/20 9:56 AM, Ley Foon Tan wrote:
Hi,

[...]

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Aren't those already defined in include/configs/socfpga_common.h ?

socfpga_common.h have this:
#define CONFIG_SYS_INIT_RAM_SIZE (0x40000 -

CONFIG_SYS_SPL_MALLOC_SIZE)

Quoted 2 lines

But, we can't use it here.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Quoted 1 line

Why ?

CONFIG_SYS_INIT_RAM_SIZE is minus with CONFIG_SYS_SPL_MALLOC_SIZE, not 256KB (0x40000).

Then define the init ram size macro somewhere in arch/arm/mach-socfpga/include and use it in both the configs/ and your code ? :)

Look at existing header files under arch/arm/mach-socfpga/include/, can add to base_addr_a10.h.

Isn't that base address common to A10 and CV/AV ?

#10 lore raw

PATCH 1/1 arm: socfpga: arria10: Add save_boot_params()

Quoted 27 lines

-----Original Message-----
From: Marek Vasut <[email protected]>
Sent: Thursday, March 5, 2020 8:23 PM
To: Ley Foon Tan <[email protected]>
Cc: Tan, Ley Foon <[email protected]>; u-boot at lists.denx.de; Simon Goldschmidt <[email protected]>; See, Chin Liang <[email protected]>; Chee, Tien Fong <[email protected]>
Subject: Re: [PATCH] arm: socfpga: arria10: Add save_boot_params()

On 3/5/20 9:56 AM, Ley Foon Tan wrote:
Hi,

[...]

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Aren't those already defined in include/configs/socfpga_common.h ?

socfpga_common.h have this:
#define CONFIG_SYS_INIT_RAM_SIZE (0x40000 -

CONFIG_SYS_SPL_MALLOC_SIZE)

Quoted 2 lines

But, we can't use it here.

Why ?

CONFIG_SYS_INIT_RAM_SIZE is minus with

CONFIG_SYS_SPL_MALLOC_SIZE, not 256KB (0x40000).

Quoted 1 line
Quoted 1 line
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Then define the init ram size macro somewhere in arch/arm/mach-socfpga/include and use it in both the configs/ and your code ? :)

Look at existing header files under arch/arm/mach-socfpga/include/, can add to base_addr_a10.h.

Isn't that base address common to A10 and CV/AV ?

No, CV/AV uses base_addr_ac5.h.

Regards
Ley Foon

#11 lore raw

PATCH 1/1 arm: socfpga: arria10: Add save_boot_params()

On 3/6/20 1:33 AM, Tan, Ley Foon wrote:
[...]

Quoted 11 lines
Quoted 11 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Aren't those already defined in include/configs/socfpga_common.h ?

socfpga_common.h have this:
#define CONFIG_SYS_INIT_RAM_SIZE (0x40000 -

CONFIG_SYS_SPL_MALLOC_SIZE)

Quoted 2 lines

But, we can't use it here.

Why ?

CONFIG_SYS_INIT_RAM_SIZE is minus with

CONFIG_SYS_SPL_MALLOC_SIZE, not 256KB (0x40000).

Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Then define the init ram size macro somewhere in arch/arm/mach-socfpga/include and use it in both the configs/ and your code ? :)

Look at existing header files under arch/arm/mach-socfpga/include/, can add to base_addr_a10.h.

Isn't that base address common to A10 and CV/AV ?

No, CV/AV uses base_addr_ac5.h.

Then it might make sense to define the macro in both.

#12 lore raw

PATCH 1/1 arm: socfpga: arria10: Add save_boot_params()

Quoted 29 lines

-----Original Message-----
From: Marek Vasut <[email protected]>
Sent: Friday, March 6, 2020 8:43 AM
To: Tan, Ley Foon <[email protected]>; Ley Foon Tan <[email protected]>
Cc: u-boot at lists.denx.de; Simon Goldschmidt <[email protected]>; See, Chin Liang <[email protected]>; Chee, Tien Fong <[email protected]>
Subject: Re: [PATCH] arm: socfpga: arria10: Add save_boot_params()

On 3/6/20 1:33 AM, Tan, Ley Foon wrote:
[...]

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Aren't those already defined in

include/configs/socfpga_common.h ?

Quoted 13 lines
Quoted 13 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines

socfpga_common.h have this:
#define CONFIG_SYS_INIT_RAM_SIZE (0x40000 -

CONFIG_SYS_SPL_MALLOC_SIZE)

Quoted 2 lines

But, we can't use it here.

Why ?

CONFIG_SYS_INIT_RAM_SIZE is minus with

CONFIG_SYS_SPL_MALLOC_SIZE, not 256KB (0x40000).

Quoted 4 lines
Quoted 4 lines

Then define the init ram size macro somewhere in arch/arm/mach-socfpga/include and use it in both the configs/ and your code ? :)

Quoted 7 lines
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines

Look at existing header files under arch/arm/mach-socfpga/include/, can add to base_addr_a10.h.

Isn't that base address common to A10 and CV/AV ?

No, CV/AV uses base_addr_ac5.h.

Then it might make sense to define the macro in both.

Okay.

Regards
Ley Foon