All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] rockchip: spl: do full dram_init instead of only probing
@ 2020-05-25 17:57 Heiko Stuebner
  2020-05-25 17:57 ` [PATCH v2 2/2] spl: add fixed memory node in target fdt also when loading ATF Heiko Stuebner
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Heiko Stuebner @ 2020-05-25 17:57 UTC (permalink / raw)
  To: u-boot

From: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>

Parts of later SPL may need RAM information as well, so do full
dram_init() call, which includes the existing dram probing but also
initializes the ram information in gd.

dram_init() from sdram.c does the following steps:
- uclass_get_device(UCLASS_RAM, ...) like the current code
- ret = ram_get_info(dev, &ram);
- gd->ram_size = ram.size;

CONFIG_SPL_RAM already makes sure that sdram.c gets compiled
and thus no other variant of dram_init() can exist.

So it's the same functionality as before and only adds that the
SPL now aquires knowledge about the amount of available ram,
which it didn't know about before.

Signed-off-by: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
---
changes in v2:
- dropped changeid
- expanded commit message on how this does not change functionality

 arch/arm/mach-rockchip/spl.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-rockchip/spl.c b/arch/arm/mach-rockchip/spl.c
index 0b76af6080..0eda2c3485 100644
--- a/arch/arm/mach-rockchip/spl.c
+++ b/arch/arm/mach-rockchip/spl.c
@@ -135,13 +135,15 @@ void board_init_f(ulong dummy)
 	/* Init ARM arch timer in arch/arm/cpu/armv7/arch_timer.c */
 	timer_init();
 #endif
-#if !defined(CONFIG_TPL) || defined(CONFIG_SPL_OS_BOOT)
+#if !defined(CONFIG_TPL) || defined(CONFIG_SPL_RAM)
 	debug("\nspl:init dram\n");
-	ret = uclass_get_device(UCLASS_RAM, 0, &dev);
+	ret = dram_init();
 	if (ret) {
 		printf("DRAM init failed: %d\n", ret);
 		return;
 	}
+	gd->ram_top = gd->ram_base + get_effective_memsize();
+	gd->ram_top = board_get_usable_ram_top(gd->ram_size);
 #endif
 	preloader_console_init();
 }
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/2] spl: add fixed memory node in target fdt also when loading ATF
  2020-05-25 17:57 [PATCH v2 1/2] rockchip: spl: do full dram_init instead of only probing Heiko Stuebner
@ 2020-05-25 17:57 ` Heiko Stuebner
  2020-05-25 20:45   ` Philipp Tomsich
  2020-05-31 12:51 ` [PATCH v2 1/2] rockchip: spl: do full dram_init instead of only probing Kever Yang
  2020-05-31 13:34 ` Kever Yang
  2 siblings, 1 reply; 5+ messages in thread
From: Heiko Stuebner @ 2020-05-25 17:57 UTC (permalink / raw)
  To: u-boot

From: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>

In a loading chain SPL -> ATF (->OP-TEE) -> U-Boot, ATF and a subsequent
OP-TEE will re-use the same fdt as the U-Boot target and may need the
information about usable memory ranges.

Especially OP-TEE needs this to initialize dynamic shared memory
(the only type U-Boot implements when talking to OP-TEE).

So allow spl_fixup_fdt() to take a fdt_blob argument, falling back to
the existing CONFIG_SYS_SPL_ARGS_ADDR if needed and call it from the
ATF path as well.

Signed-off-by: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
---
changes in v2:
- dropped changeid
- added Kever's review

 common/spl/spl.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index b0f0e1557b..90d8bfd058 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -58,7 +58,8 @@ static bd_t bdata __attribute__ ((section(".data")));
  */
 __weak void show_boot_progress(int val) {}
 
-#if defined(CONFIG_SPL_OS_BOOT) || CONFIG_IS_ENABLED(HANDOFF)
+#if defined(CONFIG_SPL_OS_BOOT) || CONFIG_IS_ENABLED(HANDOFF) || \
+    defined(CONFIG_SPL_ATF)
 /* weak, default platform-specific function to initialize dram banks */
 __weak int dram_init_banksize(void)
 {
@@ -100,12 +101,14 @@ void __weak spl_perform_fixups(struct spl_image_info *spl_image)
 {
 }
 
-void spl_fixup_fdt(void)
+void spl_fixup_fdt(void *fdt_blob)
 {
-#if defined(CONFIG_SPL_OF_LIBFDT) && defined(CONFIG_SYS_SPL_ARGS_ADDR)
-	void *fdt_blob = (void *)CONFIG_SYS_SPL_ARGS_ADDR;
+#if defined(CONFIG_SPL_OF_LIBFDT)
 	int err;
 
+	if (!fdt_blob)
+		return;
+
 	err = fdt_check_header(fdt_blob);
 	if (err < 0) {
 		printf("fdt_root: %s\n", fdt_strerror(err));
@@ -638,7 +641,8 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 	initr_watchdog();
 #endif
 
-	if (IS_ENABLED(CONFIG_SPL_OS_BOOT) || CONFIG_IS_ENABLED(HANDOFF))
+	if (IS_ENABLED(CONFIG_SPL_OS_BOOT) || CONFIG_IS_ENABLED(HANDOFF) ||
+	    IS_ENABLED(CONFIG_SPL_ATF))
 		dram_init_banksize();
 
 	bootcount_inc();
@@ -680,6 +684,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 #if CONFIG_IS_ENABLED(ATF)
 	case IH_OS_ARM_TRUSTED_FIRMWARE:
 		debug("Jumping to U-Boot via ARM Trusted Firmware\n");
+		spl_fixup_fdt(spl_image.fdt_addr);
 		spl_invoke_atf(&spl_image);
 		break;
 #endif
@@ -699,7 +704,9 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 #ifdef CONFIG_SPL_OS_BOOT
 	case IH_OS_LINUX:
 		debug("Jumping to Linux\n");
-		spl_fixup_fdt();
+#if defined(CONFIG_SYS_SPL_ARGS_ADDR)
+		spl_fixup_fdt((void *)CONFIG_SYS_SPL_ARGS_ADDR);
+#endif
 		spl_board_prepare_for_linux();
 		jump_to_image_linux(&spl_image);
 #endif
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/2] spl: add fixed memory node in target fdt also when loading ATF
  2020-05-25 17:57 ` [PATCH v2 2/2] spl: add fixed memory node in target fdt also when loading ATF Heiko Stuebner
@ 2020-05-25 20:45   ` Philipp Tomsich
  0 siblings, 0 replies; 5+ messages in thread
From: Philipp Tomsich @ 2020-05-25 20:45 UTC (permalink / raw)
  To: u-boot



> On 25.05.2020, at 19:57, Heiko Stuebner <heiko@sntech.de> wrote:
> 
> From: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
> 
> In a loading chain SPL -> ATF (->OP-TEE) -> U-Boot, ATF and a subsequent
> OP-TEE will re-use the same fdt as the U-Boot target and may need the
> information about usable memory ranges.
> 
> Especially OP-TEE needs this to initialize dynamic shared memory
> (the only type U-Boot implements when talking to OP-TEE).
> 
> So allow spl_fixup_fdt() to take a fdt_blob argument, falling back to
> the existing CONFIG_SYS_SPL_ARGS_ADDR if needed and call it from the
> ATF path as well.
> 
> Signed-off-by: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
> Reviewed-by: Kever Yang <kever.yang@rock-chips.com>

Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/2] rockchip: spl: do full dram_init instead of only probing
  2020-05-25 17:57 [PATCH v2 1/2] rockchip: spl: do full dram_init instead of only probing Heiko Stuebner
  2020-05-25 17:57 ` [PATCH v2 2/2] spl: add fixed memory node in target fdt also when loading ATF Heiko Stuebner
@ 2020-05-31 12:51 ` Kever Yang
  2020-05-31 13:34 ` Kever Yang
  2 siblings, 0 replies; 5+ messages in thread
From: Kever Yang @ 2020-05-31 12:51 UTC (permalink / raw)
  To: u-boot


On 2020/5/26 ??1:57, Heiko Stuebner wrote:
> From: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
>
> Parts of later SPL may need RAM information as well, so do full
> dram_init() call, which includes the existing dram probing but also
> initializes the ram information in gd.
>
> dram_init() from sdram.c does the following steps:
> - uclass_get_device(UCLASS_RAM, ...) like the current code
> - ret = ram_get_info(dev, &ram);
> - gd->ram_size = ram.size;
>
> CONFIG_SPL_RAM already makes sure that sdram.c gets compiled
> and thus no other variant of dram_init() can exist.
>
> So it's the same functionality as before and only adds that the
> SPL now aquires knowledge about the amount of available ram,
> which it didn't know about before.
>
> Signed-off-by: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>

Reviewed-by: Kever Yang <kever.yang@rock-chips.com>

Thanks,
- Kever
> ---
> changes in v2:
> - dropped changeid
> - expanded commit message on how this does not change functionality
>
>   arch/arm/mach-rockchip/spl.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/mach-rockchip/spl.c b/arch/arm/mach-rockchip/spl.c
> index 0b76af6080..0eda2c3485 100644
> --- a/arch/arm/mach-rockchip/spl.c
> +++ b/arch/arm/mach-rockchip/spl.c
> @@ -135,13 +135,15 @@ void board_init_f(ulong dummy)
>   	/* Init ARM arch timer in arch/arm/cpu/armv7/arch_timer.c */
>   	timer_init();
>   #endif
> -#if !defined(CONFIG_TPL) || defined(CONFIG_SPL_OS_BOOT)
> +#if !defined(CONFIG_TPL) || defined(CONFIG_SPL_RAM)
>   	debug("\nspl:init dram\n");
> -	ret = uclass_get_device(UCLASS_RAM, 0, &dev);
> +	ret = dram_init();
>   	if (ret) {
>   		printf("DRAM init failed: %d\n", ret);
>   		return;
>   	}
> +	gd->ram_top = gd->ram_base + get_effective_memsize();
> +	gd->ram_top = board_get_usable_ram_top(gd->ram_size);
>   #endif
>   	preloader_console_init();
>   }

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/2] rockchip: spl: do full dram_init instead of only probing
  2020-05-25 17:57 [PATCH v2 1/2] rockchip: spl: do full dram_init instead of only probing Heiko Stuebner
  2020-05-25 17:57 ` [PATCH v2 2/2] spl: add fixed memory node in target fdt also when loading ATF Heiko Stuebner
  2020-05-31 12:51 ` [PATCH v2 1/2] rockchip: spl: do full dram_init instead of only probing Kever Yang
@ 2020-05-31 13:34 ` Kever Yang
  2 siblings, 0 replies; 5+ messages in thread
From: Kever Yang @ 2020-05-31 13:34 UTC (permalink / raw)
  To: u-boot

Hi Heiko,

 ??? Below error happen when build:

+arch/arm/mach-rockchip/spl.c: In function 'board_init_f':
690 
<https://gitlab.denx.de/u-boot/custodians/u-boot-rockchip/-/jobs/103576#L690>+arch/arm/mach-rockchip/spl.c:112:18: 
error: unused variable 'dev' [-Werror=unused-variable]

 ??? I will fix it when apply, but please make sure all the boards can 
pass the build next time.

Thanks,
- Kever
On 2020/5/26 ??1:57, Heiko Stuebner wrote:
> -	ret = uclass_get_device(UCLASS_RAM, 0, &dev);
> +	ret = dram_init();

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-05-31 13:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-25 17:57 [PATCH v2 1/2] rockchip: spl: do full dram_init instead of only probing Heiko Stuebner
2020-05-25 17:57 ` [PATCH v2 2/2] spl: add fixed memory node in target fdt also when loading ATF Heiko Stuebner
2020-05-25 20:45   ` Philipp Tomsich
2020-05-31 12:51 ` [PATCH v2 1/2] rockchip: spl: do full dram_init instead of only probing Kever Yang
2020-05-31 13:34 ` Kever Yang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.