diff mbox series

[27/40] spl: sandbox: initialise the ram banksize in spl

Message ID 20240724060224.3071065-28-sughosh.ganu@linaro.org
State Superseded
Headers show
Series Make LMB memory map global and persistent | expand

Commit Message

Sughosh Ganu July 24, 2024, 6:02 a.m. UTC
Initialise the ram bank information for sandbox in SPL. This is needed
for initialising the LMB memory map as part of the platform init.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
---
Changes since rfc: New patch

 arch/sandbox/cpu/spl.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

Comments

Simon Glass July 25, 2024, 11:32 p.m. UTC | #1
Hi Sughosh,

On Wed, 24 Jul 2024 at 00:05, Sughosh Ganu <sughosh.ganu@linaro.org> wrote:
>
> Initialise the ram bank information for sandbox in SPL. This is needed
> for initialising the LMB memory map as part of the platform init.

I don't understand what is going on here...you are moving code into a
function and should explain why.

>
> Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
> ---
> Changes since rfc: New patch
>
>  arch/sandbox/cpu/spl.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c
> index 9ad9da686c..22cd916685 100644
> --- a/arch/sandbox/cpu/spl.c
> +++ b/arch/sandbox/cpu/spl.c
> @@ -121,6 +121,15 @@ static int load_from_image(struct spl_image_info *spl_image,
>  }
>  SPL_LOAD_IMAGE_METHOD("sandbox_image", 7, BOOT_DEVICE_BOARD, load_from_image);
>
> +int dram_init_banksize(void)
> +{
> +       /* These are necessary so TFTP can use LMBs to check its load address */
> +       gd->bd->bi_dram[0].start = gd->ram_base;
> +       gd->bd->bi_dram[0].size = get_effective_memsize();
> +
> +       return 0;
> +}
> +
>  void spl_board_init(void)
>  {
>         struct sandbox_state *state = state_get_current();
> @@ -128,10 +137,6 @@ void spl_board_init(void)
>         if (!CONFIG_IS_ENABLED(UNIT_TEST))
>                 return;
>
> -       /* These are necessary so TFTP can use LMBs to check its load address */
> -       gd->bd->bi_dram[0].start = gd->ram_base;
> -       gd->bd->bi_dram[0].size = get_effective_memsize();
> -
>         if (state->run_unittests) {
>                 struct unit_test *tests = UNIT_TEST_ALL_START();
>                 const int count = UNIT_TEST_ALL_COUNT();
> --
> 2.34.1
>

Regards,
Simon
Sughosh Ganu July 29, 2024, 8:49 a.m. UTC | #2
On Fri, 26 Jul 2024 at 05:02, Simon Glass <sjg@chromium.org> wrote:
>
> Hi Sughosh,
>
> On Wed, 24 Jul 2024 at 00:05, Sughosh Ganu <sughosh.ganu@linaro.org> wrote:
> >
> > Initialise the ram bank information for sandbox in SPL. This is needed
> > for initialising the LMB memory map as part of the platform init.
>
> I don't understand what is going on here...you are moving code into a
> function and should explain why.

Will do. The bd struct's dram values need to be set up before the lmb
initialisation happens.

-sughosh

>
> >
> > Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
> > ---
> > Changes since rfc: New patch
> >
> >  arch/sandbox/cpu/spl.c | 13 +++++++++----
> >  1 file changed, 9 insertions(+), 4 deletions(-)
> >
> > diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c
> > index 9ad9da686c..22cd916685 100644
> > --- a/arch/sandbox/cpu/spl.c
> > +++ b/arch/sandbox/cpu/spl.c
> > @@ -121,6 +121,15 @@ static int load_from_image(struct spl_image_info *spl_image,
> >  }
> >  SPL_LOAD_IMAGE_METHOD("sandbox_image", 7, BOOT_DEVICE_BOARD, load_from_image);
> >
> > +int dram_init_banksize(void)
> > +{
> > +       /* These are necessary so TFTP can use LMBs to check its load address */
> > +       gd->bd->bi_dram[0].start = gd->ram_base;
> > +       gd->bd->bi_dram[0].size = get_effective_memsize();
> > +
> > +       return 0;
> > +}
> > +
> >  void spl_board_init(void)
> >  {
> >         struct sandbox_state *state = state_get_current();
> > @@ -128,10 +137,6 @@ void spl_board_init(void)
> >         if (!CONFIG_IS_ENABLED(UNIT_TEST))
> >                 return;
> >
> > -       /* These are necessary so TFTP can use LMBs to check its load address */
> > -       gd->bd->bi_dram[0].start = gd->ram_base;
> > -       gd->bd->bi_dram[0].size = get_effective_memsize();
> > -
> >         if (state->run_unittests) {
> >                 struct unit_test *tests = UNIT_TEST_ALL_START();
> >                 const int count = UNIT_TEST_ALL_COUNT();
> > --
> > 2.34.1
> >
>
> Regards,
> Simon
diff mbox series

Patch

diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c
index 9ad9da686c..22cd916685 100644
--- a/arch/sandbox/cpu/spl.c
+++ b/arch/sandbox/cpu/spl.c
@@ -121,6 +121,15 @@  static int load_from_image(struct spl_image_info *spl_image,
 }
 SPL_LOAD_IMAGE_METHOD("sandbox_image", 7, BOOT_DEVICE_BOARD, load_from_image);
 
+int dram_init_banksize(void)
+{
+	/* These are necessary so TFTP can use LMBs to check its load address */
+	gd->bd->bi_dram[0].start = gd->ram_base;
+	gd->bd->bi_dram[0].size = get_effective_memsize();
+
+	return 0;
+}
+
 void spl_board_init(void)
 {
 	struct sandbox_state *state = state_get_current();
@@ -128,10 +137,6 @@  void spl_board_init(void)
 	if (!CONFIG_IS_ENABLED(UNIT_TEST))
 		return;
 
-	/* These are necessary so TFTP can use LMBs to check its load address */
-	gd->bd->bi_dram[0].start = gd->ram_base;
-	gd->bd->bi_dram[0].size = get_effective_memsize();
-
 	if (state->run_unittests) {
 		struct unit_test *tests = UNIT_TEST_ALL_START();
 		const int count = UNIT_TEST_ALL_COUNT();