diff mbox series

[v2,1/2] rockchip: spl: do full dram_init instead of only probing

Message ID 20200525175725.3638830-1-heiko@sntech.de
State New
Headers show
Series [v2,1/2] rockchip: spl: do full dram_init instead of only probing | expand

Commit Message

Heiko Stuebner May 25, 2020, 5:57 p.m. UTC
From: Heiko Stuebner <heiko.stuebner at 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 at 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(-)

Comments

Kever Yang May 31, 2020, 12:51 p.m. UTC | #1
On 2020/5/26 ??1:57, Heiko Stuebner wrote:
> From: Heiko Stuebner <heiko.stuebner at 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 at theobroma-systems.com>

Reviewed-by: Kever Yang <kever.yang at 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();
>   }
Kever Yang May 31, 2020, 1:34 p.m. UTC | #2
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();
diff mbox series

Patch

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();
 }