Skip to contentSkip to conversation

rpi4: enable dram bank initialization

PATCH Superseded matthias.bgg at kernel.org 4 participants 6 messages Sep 6, 2019 – Sep 9, 2019 Broadcom BCM2711/BCM2835 Arm architecture

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rpi4: enable dram bank initialization

From: Matthias Brugger <[email protected]>

When booting through the efi stub, the memory map get's created by reading the dram bank information. Depending on the version of the RPi4 this information changes. Read the device tree to initialize the dram bank data structure. This way the kernel is able to access the whole range of available memory.

---
This patch is based on basic RPi4 support implemented by series:
https://www.mail-archive.com/u-boot at lists.denx.de/msg335667.html

To actually work correctly we need the series that fixes the libftd:
https://patchwork.ozlabs.org/cover/1158304/

 board/raspberrypi/rpi/rpi.c | 8 ++++++++
 configs/rpi_4_defconfig     | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)
board/raspberrypi/rpi/rpi.c +8 -0
index fa57d50c95..eea8a69551 100644
@@ -312,6 +312,14 @@ int dram_init(void)
 	return 0;
 }
 
+#ifdef CONFIG_BCM2711
+int dram_init_banksize(void)
+{
+	return fdtdec_decode_ram_size(gd->fdt_blob, NULL, 0, NULL,
+				     (phys_size_t *)&gd->ram_size, gd->bd);
+}
+#endif
+
 static void set_fdtfile(void)
 {
 	const char *fdtfile;
configs/rpi_4_defconfig +1 -1
index da8c960a2a..c639ac93de 100644
@@ -4,7 +4,7 @@ CONFIG_SYS_TEXT_BASE=0x00080000
 CONFIG_TARGET_RPI_4=y
 CONFIG_SYS_MALLOC_F_LEN=0x2000
 CONFIG_DISTRO_DEFAULTS=y
-CONFIG_NR_DRAM_BANKS=1
+CONFIG_NR_DRAM_BANKS=2
 # CONFIG_ARCH_FIXUP_FDT_MEMORY is not set
 CONFIG_OF_BOARD=y
 CONFIG_OF_BOARD_SETUP=y
Signature · 1 line
2.22.0
#1 lore raw

PATCH 1/1 rpi4: enable dram bank initialization

Quoted 25 lines · matthias.bgg at kernel.org

From: Matthias Brugger <[email protected]>

When booting through the efi stub, the memory map get's created by reading the dram bank information. Depending on the version of the RPi4 this information changes. Read the device tree to initialize the dram bank data structure. This way the kernel is able to access the whole range of available memory.

---
This patch is based on basic RPi4 support implemented by series:
https://www.mail-archive.com/u-boot at lists.denx.de/msg335667.html

To actually work correctly we need the series that fixes the libftd:
https://patchwork.ozlabs.org/cover/1158304/

  board/raspberrypi/rpi/rpi.c | 8 ++++++++
  configs/rpi_4_defconfig     | 2 +-
  2 files changed, 9 insertions(+), 1 deletion(-)
board/raspberrypi/rpi/rpi.c +0 -0
index fa57d50c95..eea8a69551 100644

board/raspberrypi/rpi/rpi.c int dram_init(void) · line 318

Quoted 7 lines
board/raspberrypi/rpi/rpi.c +4 -0
@@ -312,6 +312,14 @@ int dram_init(void)
  	return 0;
  }
 
+#ifdef CONFIG_BCM2711
+int dram_init_banksize(void)
+{
+	return fdtdec_decode_ram_size(gd->fdt_blob, NULL, 0, NULL,

This also depends on CONFIG_OF_BOARD, no?

Alex

#2 lore raw

PATCH 1/1 rpi4: enable dram bank initialization

Quoted 22 lines · Alexander Graf
Quoted 20 lines · matthias.bgg at kernel.org

From: Matthias Brugger <[email protected]>

When booting through the efi stub, the memory map get's created by reading the dram bank information. Depending on the version of the RPi4 this information changes. Read the device tree to initialize the dram bank data structure. This way the kernel is able to access the whole range of available memory.

---
This patch is based on basic RPi4 support implemented by series:
https://www.mail-archive.com/u-boot at lists.denx.de/msg335667.html

To actually work correctly we need the series that fixes the libftd:
https://patchwork.ozlabs.org/cover/1158304/

  board/raspberrypi/rpi/rpi.c | 8 ++++++++
  configs/rpi_4_defconfig     | 2 +-

  2 files changed, 9 insertions(+), 1 deletion(-)
Quoted 15 lines

board/raspberrypi/rpi/rpi.c int dram_init(void) · line 318

Quoted 11 lines
board/raspberrypi/rpi/rpi.c +0 -0
index fa57d50c95..eea8a69551 100644
@@ -312,6 +312,14 @@ int dram_init(void)
       return 0;
   }

  +#ifdef CONFIG_BCM2711

board/raspberrypi/rpi/rpi.c +3 -0
+int dram_init_banksize(void)
+{
+    return fdtdec_decode_ram_size(gd->fdt_blob, NULL, 0, NULL,

This also depends on CONFIG_OF_BOARD, no?

I would need to double check if at this point gd->fdt_blob is in it's final state or might get updated afterwards.

Actually I think we should change all RPi configs to OF_BOARD, which would also be necessary to implement a single binary for RPi3 and RPi4. But that's another story.

#3 lore raw

PATCH 1/1 rpi4: enable dram bank initialization

Quoted 37 lines · Matthias Brugger
Quoted 21 lines · Alexander Graf
Quoted 20 lines · matthias.bgg at kernel.org

From: Matthias Brugger <[email protected]>

When booting through the efi stub, the memory map get's created by reading the dram bank information. Depending on the version of the RPi4 this information changes. Read the device tree to initialize the dram bank data structure. This way the kernel is able to access the whole range of available memory.

---
This patch is based on basic RPi4 support implemented by series:
https://www.mail-archive.com/u-boot at lists.denx.de/msg335667.html

To actually work correctly we need the series that fixes the libftd:
https://patchwork.ozlabs.org/cover/1158304/

   board/raspberrypi/rpi/rpi.c | 8 ++++++++
   configs/rpi_4_defconfig     | 2 +-
   2 files changed, 9 insertions(+), 1 deletion(-)
Quoted 14 lines

board/raspberrypi/rpi/rpi.c int dram_init(void) · line 317

Quoted 11 lines
board/raspberrypi/rpi/rpi.c +3 -0
index fa57d50c95..eea8a69551 100644
@@ -312,6 +312,14 @@ int dram_init(void)
       return 0;
   }
   +#ifdef CONFIG_BCM2711
+int dram_init_banksize(void)
+{
+    return fdtdec_decode_ram_size(gd->fdt_blob, NULL, 0, NULL,

This also depends on CONFIG_OF_BOARD, no?

Quoted 6 lines

I would need to double check if at this point gd->fdt_blob is in it's final state or might get updated afterwards.

Actually I think we should change all RPi configs to OF_BOARD, which would also be necessary to implement a single binary for RPi3 and RPi4. But that's another story.

Yes, but until then please fail compilation on !OF_BOARD if you know it can't work. Or create a Kconfig dependency.

Alex

#4 lore raw

PATCH 1/1 rpi4: enable dram bank initialization

Quoted 42 lines · Alexander Graf
Quoted 40 lines · Matthias Brugger
Quoted 21 lines · Alexander Graf
Quoted 20 lines · matthias.bgg at kernel.org

From: Matthias Brugger <[email protected]>

When booting through the efi stub, the memory map get's created by reading the dram bank information. Depending on the version of the RPi4 this information changes. Read the device tree to initialize the dram bank data structure. This way the kernel is able to access the whole range of available memory.

---
This patch is based on basic RPi4 support implemented by series:
https://www.mail-archive.com/u-boot at lists.denx.de/msg335667.html

To actually work correctly we need the series that fixes the libftd:
https://patchwork.ozlabs.org/cover/1158304/

   board/raspberrypi/rpi/rpi.c | 8 ++++++++
   configs/rpi_4_defconfig     | 2 +-

   2 files changed, 9 insertions(+), 1 deletion(-)
Quoted 14 lines

board/raspberrypi/rpi/rpi.c int dram_init(void) · line 318

Quoted 11 lines
board/raspberrypi/rpi/rpi.c +0 -0
index fa57d50c95..eea8a69551 100644
@@ -312,6 +312,14 @@ int dram_init(void)
        return 0;
    }

   +#ifdef CONFIG_BCM2711

board/raspberrypi/rpi/rpi.c +3 -0
+int dram_init_banksize(void)
+{
+    return fdtdec_decode_ram_size(gd->fdt_blob, NULL, 0, NULL,

This also depends on CONFIG_OF_BOARD, no?

I would need to double check if at this point gd->fdt_blob is in it's final state or might get updated afterwards.

Quoted 8 lines
Quoted 3 lines

Actually I think we should change all RPi configs to OF_BOARD, which would also be necessary to implement a single binary for RPi3 and RPi4. But that's another story.

Yes, but until then please fail compilation on !OF_BOARD if you know it can't work. Or create a Kconfig dependency.

Sounds like a plan, thanks :)

#5 lore raw

PATCH 1/1 rpi4: enable dram bank initialization

In reply to Matthias Brugger
Quoted 37 lines · Matthias Brugger
Quoted 21 lines · Alexander Graf
Quoted 20 lines · matthias.bgg at kernel.org

From: Matthias Brugger <[email protected]>

When booting through the efi stub, the memory map get's created by reading the dram bank information. Depending on the version of the RPi4 this information changes. Read the device tree to initialize the dram bank data structure. This way the kernel is able to access the whole range of available memory.

---
This patch is based on basic RPi4 support implemented by series:
https://www.mail-archive.com/u-boot at lists.denx.de/msg335667.html

To actually work correctly we need the series that fixes the libftd:
https://patchwork.ozlabs.org/cover/1158304/

  board/raspberrypi/rpi/rpi.c | 8 ++++++++
  configs/rpi_4_defconfig     | 2 +-

  2 files changed, 9 insertions(+), 1 deletion(-)
Quoted 14 lines

board/raspberrypi/rpi/rpi.c int dram_init(void) · line 318

Quoted 11 lines
board/raspberrypi/rpi/rpi.c +0 -0
index fa57d50c95..eea8a69551 100644
@@ -312,6 +312,14 @@ int dram_init(void)
       return 0;
   }

  +#ifdef CONFIG_BCM2711

board/raspberrypi/rpi/rpi.c +3 -0
+int dram_init_banksize(void)
+{
+    return fdtdec_decode_ram_size(gd->fdt_blob, NULL, 0, NULL,

This also depends on CONFIG_OF_BOARD, no?

Quoted 6 lines

I would need to double check if at this point gd->fdt_blob is in it's final state or might get updated afterwards.

Actually I think we should change all RPi configs to OF_BOARD, which would also be necessary to implement a single binary for RPi3 and RPi4. But that's another story.

Looks good to me.

Signature · 3 lines
Andrei Gherzan
Head Of Devices | balena.io
gpg: rsa4096/D4D94F67AD0E9640 | t: @agherzan