All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] rpi4: enable dram bank initialization
@ 2019-09-06 11:56 matthias.bgg at kernel.org
  2019-09-06 12:11 ` Alexander Graf
  0 siblings, 1 reply; 6+ messages in thread
From: matthias.bgg at kernel.org @ 2019-09-06 11:56 UTC (permalink / raw)
  To: u-boot

From: Matthias Brugger <mbrugger@suse.com>

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.

Signed-off-by: Matthias Brugger <mbrugger@suse.com>
---
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(-)

diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
index fa57d50c95..eea8a69551 100644
--- a/board/raspberrypi/rpi/rpi.c
+++ b/board/raspberrypi/rpi/rpi.c
@@ -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;
diff --git a/configs/rpi_4_defconfig b/configs/rpi_4_defconfig
index da8c960a2a..c639ac93de 100644
--- a/configs/rpi_4_defconfig
+++ b/configs/rpi_4_defconfig
@@ -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
-- 
2.22.0

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

* [U-Boot] [PATCH] rpi4: enable dram bank initialization
  2019-09-06 11:56 [U-Boot] [PATCH] rpi4: enable dram bank initialization matthias.bgg at kernel.org
@ 2019-09-06 12:11 ` Alexander Graf
  2019-09-06 12:58   ` Matthias Brugger
  0 siblings, 1 reply; 6+ messages in thread
From: Alexander Graf @ 2019-09-06 12:11 UTC (permalink / raw)
  To: u-boot


On 06.09.19 13:56, matthias.bgg at kernel.org wrote:
> From: Matthias Brugger <mbrugger@suse.com>
>
> 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.
>
> Signed-off-by: Matthias Brugger <mbrugger@suse.com>
> ---
> 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(-)
>
> diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
> index fa57d50c95..eea8a69551 100644
> --- a/board/raspberrypi/rpi/rpi.c
> +++ b/board/raspberrypi/rpi/rpi.c
> @@ -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

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

* [U-Boot] [PATCH] rpi4: enable dram bank initialization
  2019-09-06 12:11 ` Alexander Graf
@ 2019-09-06 12:58   ` Matthias Brugger
  2019-09-06 13:03     ` Alexander Graf
  2019-09-09  9:42     ` Andrei Gherzan
  0 siblings, 2 replies; 6+ messages in thread
From: Matthias Brugger @ 2019-09-06 12:58 UTC (permalink / raw)
  To: u-boot



On 06/09/2019 14:11, Alexander Graf wrote:
> 
> On 06.09.19 13:56, matthias.bgg at kernel.org wrote:
>> From: Matthias Brugger <mbrugger@suse.com>
>>
>> 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.
>>
>> Signed-off-by: Matthias Brugger <mbrugger@suse.com>
>> ---
>> 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(-)
>>
>> diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
>> index fa57d50c95..eea8a69551 100644
>> --- a/board/raspberrypi/rpi/rpi.c
>> +++ b/board/raspberrypi/rpi/rpi.c
>> @@ -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?
> 

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.

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

* [U-Boot] [PATCH] rpi4: enable dram bank initialization
  2019-09-06 12:58   ` Matthias Brugger
@ 2019-09-06 13:03     ` Alexander Graf
  2019-09-06 13:04       ` Matthias Brugger
  2019-09-09  9:42     ` Andrei Gherzan
  1 sibling, 1 reply; 6+ messages in thread
From: Alexander Graf @ 2019-09-06 13:03 UTC (permalink / raw)
  To: u-boot


On 06.09.19 14:58, Matthias Brugger wrote:
>
> On 06/09/2019 14:11, Alexander Graf wrote:
>> On 06.09.19 13:56, matthias.bgg at kernel.org wrote:
>>> From: Matthias Brugger <mbrugger@suse.com>
>>>
>>> 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.
>>>
>>> Signed-off-by: Matthias Brugger <mbrugger@suse.com>
>>> ---
>>> 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(-)
>>>
>>> diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
>>> index fa57d50c95..eea8a69551 100644
>>> --- a/board/raspberrypi/rpi/rpi.c
>>> +++ b/board/raspberrypi/rpi/rpi.c
>>> @@ -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?
>>
> 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

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

* [U-Boot] [PATCH] rpi4: enable dram bank initialization
  2019-09-06 13:03     ` Alexander Graf
@ 2019-09-06 13:04       ` Matthias Brugger
  0 siblings, 0 replies; 6+ messages in thread
From: Matthias Brugger @ 2019-09-06 13:04 UTC (permalink / raw)
  To: u-boot



On 06/09/2019 15:03, Alexander Graf wrote:
> 
> On 06.09.19 14:58, Matthias Brugger wrote:
>>
>> On 06/09/2019 14:11, Alexander Graf wrote:
>>> On 06.09.19 13:56, matthias.bgg at kernel.org wrote:
>>>> From: Matthias Brugger <mbrugger@suse.com>
>>>>
>>>> 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.
>>>>
>>>> Signed-off-by: Matthias Brugger <mbrugger@suse.com>
>>>> ---
>>>> 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(-)
>>>>
>>>> diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
>>>> index fa57d50c95..eea8a69551 100644
>>>> --- a/board/raspberrypi/rpi/rpi.c
>>>> +++ b/board/raspberrypi/rpi/rpi.c
>>>> @@ -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?
>>>
>> 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.
> 

Sounds like a plan, thanks :)

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

* [U-Boot] [PATCH] rpi4: enable dram bank initialization
  2019-09-06 12:58   ` Matthias Brugger
  2019-09-06 13:03     ` Alexander Graf
@ 2019-09-09  9:42     ` Andrei Gherzan
  1 sibling, 0 replies; 6+ messages in thread
From: Andrei Gherzan @ 2019-09-09  9:42 UTC (permalink / raw)
  To: u-boot

On 06/09/2019 13.58, Matthias Brugger wrote:
>
> On 06/09/2019 14:11, Alexander Graf wrote:
>> On 06.09.19 13:56, matthias.bgg at kernel.org wrote:
>>> From: Matthias Brugger <mbrugger@suse.com>
>>>
>>> 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.
>>>
>>> Signed-off-by: Matthias Brugger <mbrugger@suse.com>
>>> ---
>>> 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(-)
>>>
>>> diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
>>> index fa57d50c95..eea8a69551 100644
>>> --- a/board/raspberrypi/rpi/rpi.c
>>> +++ b/board/raspberrypi/rpi/rpi.c
>>> @@ -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?
>>
> 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.

-- 
Andrei Gherzan
Head Of Devices | balena.io
gpg: rsa4096/D4D94F67AD0E9640 | t: @agherzan

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

end of thread, other threads:[~2019-09-09  9:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-06 11:56 [U-Boot] [PATCH] rpi4: enable dram bank initialization matthias.bgg at kernel.org
2019-09-06 12:11 ` Alexander Graf
2019-09-06 12:58   ` Matthias Brugger
2019-09-06 13:03     ` Alexander Graf
2019-09-06 13:04       ` Matthias Brugger
2019-09-09  9:42     ` Andrei Gherzan

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.