18 Commits

Author SHA1 Message Date
Grzegorz Bernacki
f24aa7708d Platform/RaspberryPi: Remove unnecessary files
Commit 2f0188b56e ("Revert "Platform/RaspberryPi: Setup option for...")
mistakenly introduced to files which are residues from a
conflict resolution. Fix that.

Signed-off-by: Grzegorz Bernacki <gjb@semihalf.com>
2021-08-17 16:00:37 +02:00
Grzegorz Bernacki
2f0188b56e Revert "Platform/RaspberryPi: Setup option for disabling Fast Boot"
This reverts commit efdc159ef7.

This commit is not longer required as Boot Discovery Policy has been
implemented for Raspberry Pi.

Signed-off-by: Grzegorz Bernacki <gjb@semihalf.com>
Reviewed-by: Sunny Wang <sunny.wang@arm.com>
Reviewed-by: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
Reviewed-by: Pete Batard <pete@akeo.ie>
Tested-by: Pete Batard <pete@akeo.ie>
2021-08-03 18:37:04 +02:00
Mario Bălănică
d2339f3c5f Platform/RaspberryPi: Fix mini UART clock divisor calculation
The VPU clock divisor has changed in this commit:
https://github.com/raspberrypi/firmware/commit/1e5456a, thus breaking
the mini UART clock divisor calculation on the Pi 4.

Fix this by reading the core clock from the mailbox instead.

Signed-off-by: Mario Bălănică <mariobalanica02@gmail.com>
Reviewed-by: Pete Batard <pete@akeo.ie>
Tested-by: Pete Batard <pete@akeo.ie>
2021-04-08 14:12:37 +02:00
Leif Lindholm
5d2d48eb8f Platform/RaspberryPi: remove unused variable GpuIndex from PlatformLib
Commit 678f6bff3c ("RPi4: reserve/map memory above 4GB when present")
removed the only user of the GpuIndex variable in
ArmPlatformGetVirtualMemoryMap, which causes a build error of NOOPT
profile with gcc 8.3. Delete the variable, and its initialization.

Cc: Andrei Warkentin <andrey.warkentin@gmail.com>
Cc: Pete Batard <pete@akeo.ie>
Signed-off-by: Leif Lindholm <leif@nuviainc.com>
Reviewed-by: Pete Batard <pete@akeo.ie>
2020-07-14 14:02:03 +01:00
Andrei Warkentin
678f6bff3c RPi4: reserve/map memory above 4GB when present
This makes all 8GB usable on the Pi 4 8GB variant.

Like RAM in the 3-4GB range, this is still gated by the
option to limit RAM to 3GB.

Tested on 4GB and 8GB boards, with and without 3GB limit.

Signed-off-by: Andrei Warkentin <andrey.warkentin@gmail.com>
Reviewed-by: Pete Batard <pete@akeo.ie>
2020-06-08 19:39:47 +02:00
Ard Biesheuvel
043ee2e65b Platform/RaspberryPi: query firmware for 16550 input clock at boot on RPi3
Query the firmware for the clock rate that is used to drive the
16550 baud clock, so that we can program the correct baud rate.

Co-authored-by: Pete Batard <pete@akeo.ie>
Co-authored-by: Andrei Warkentin <andrey.warkentin@gmail.com>
Co-authored-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
Signed-off-by: Pete Batard <pete@akeo.ie>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
Reviewed-by: Pete Batard <pete@akeo.ie>
Tested-by: Pete Batard <pete@akeo.ie>
2020-05-06 18:15:18 +02:00
Andrei Warkentin
35a5402a71 Platform/RaspberryPi: Fortify mailbox code
As part of the analysis done in:
https://github.com/raspberrypi/firmware/issues/1376:
* Bump up max tries, to avoid command time-outs.
* Macro-ify RaspberryPiHelper.S some more to make code more maintainable.
* Add ".align 4" before every command buffer.

Co-authored-by: Pete Batard <pete@akeo.ie>
Co-authored-by: Andrei Warkentin <andrey.warkentin@gmail.com>
Signed-off-by: Pete Batard <pete@akeo.ie>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
2020-05-06 14:39:12 +02:00
Andrei Warkentin
90e73225b0 RPi3/RPi4: fix RPi 3 VPU-passed FDT handling by unifying with RPi4 implementation
A rev-up of start.elf VPU firmware meant that the previous scheme of
loading the DTB over top of RPI_EFI.FD no longer works - the DT is now
loaded way before the armstub, so any overlap means the DT is overridden.

This change re-arranges a few items in the FD, allowing the DTB to loaded
directly after the FD in physical memory.

Unlike the Pi 4 implementation, we can't move the UEFI image down in memory,
as that needs a TF-A changem so it just reduces the size by 0x10000. The
same base address (0x1f0000) is used as on the Pi 4.

The Pi 3 FDF can be further unified with Pi 4 after work on TF-A to move
to a single BL32-based Pi 3 TF-A implementation.

Tested: Pi 3A+, Pi 2B v1.2, Pi 4B (4GB).

Signed-off-by: Andrei Warkentin <andrey.warkentin@gmail.com>
Reviewed-by: Pete Batard <pete@akeo.ie>
2020-05-01 12:22:39 +02:00
Andrei Warkentin
828fcbf96a Platform/RaspberryPi: fix FDT handling for RPi4
A rev-up of start4.elf VPU firmware meant that the previous scheme of
loading the DTB over top of RPI_EFI.FD no longer works - the DT is now
loaded way before the armstub, so any overlap means the DT is overridden.

This change re-arranges a few items in the FD, allowing the DTB to loaded
directly after the FD in physical memory.

This moves UEFI image down by 0x10000, and reduces the FD image size by
0x10000, leaving space for a DTB to be loaded by config.txt at 0x1f0000.

You need a matching "rev RPi4 TF-A for DTB fix" patch to edk2-non-osi,
as it requires a TF-A build with these options:

PRELOADED_BL33_BASE=0x20000 RPI3_PRELOADED_DTB_BASE=0x1f0000

Note: the same problem still affects the Pi 3, and will be
fixed in a separate change.

Signed-off-by: Andrei Warkentin <andrey.warkentin@gmail.com>
Reviewed-by: Pete Batard <pete@akeo.ie>
Tested-by: Pete Batard <pete@akeo.ie>
2020-03-06 17:47:05 +01:00
Andrei Warkentin
91ed4f904e Platform/RaspberryPi/RPi4: gain 2MB of RAM back
The RPi4 TF-A is much smaller than RPi3 TF-A, and doesn't need
an extra 2MB region.

Note: this depends on the edk2 ArmPlatformPkg/PrePi: fix IS_XIP.

Signed-off-by: Andrei Warkentin <awarkentin@vmware.com>
Reviewed-by: Pete Batard <pete@akeo.ie>
Tested-by:  Pete Batard <pete@akeo.ie>
2020-03-06 17:42:48 +01:00
Andrei Warkentin
4fb91581cf Platform/RPi: Separate RAM descriptors between 0-3 GB and 3+ GB
Splitting the RAM descriptors is required so that we can make the 3 to 4 GB
segment of the Raspberry Pi 4 a user-configurable option.

This also removes the need for the PcdAcpiBasicMode PCD.

Signed-off-by: Pete Batard <pete@akeo.ie>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
2020-03-03 15:06:38 +01:00
Ard Biesheuvel
e9395c53ba Platform/RPi4: Add ACPI basic mode build option
Add an ACPI_BASIC_MODE_ENABLE flag to produces builds intended to run in
ACPI mode without any additional requirements (memory limits, acpi=force,
etc).

This flag is disabled by default.

Signed-off-by: Pete Batard <pete@akeo.ie>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
2019-12-19 18:49:25 +02:00
Ard Biesheuvel
70a8cb5933 Platform/RPi: Don't describe MMIO regions as memory
When using ACPI OpRegions to poke device registers, Linux will use
the UEFI memory map to decide which memory attributes to use, and
so they should not be described as cacheable memory.

Since MMIO regions that don't require an OS virtual mapping at runtime
don't really belong in the UEFI memory map to begin with, omit them
entirely.

Signed-off-by: Pete Batard <pete@akeo.ie>
Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
2019-12-11 17:14:43 +01:00
Ard Biesheuvel
adef211920 Platform/RPi: Fix overlap of SoC registers and RAM
Having RAM and SoC register regions overlap is problematic for MMIO,
since, at the very least, we don't want these regions to be declared
as cacheable.

Signed-off-by: Pete Batard <pete@akeo.ie>
Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
2019-12-11 17:13:18 +01:00
Pete Batard
61b6c05bdf Platform/RPi: Clean up and improve early memory init
This patch improves memory initialization for the Raspberry Pi Platform by:

Using VideoCore mailbox data to reserve only the regions that are actually
mapped. Especially, besides the base RAM size, which was already set using
VideoCore data, we can set the GPU/VideoCore base address as well as the
extended RAM, which is the memory beyond 1 GB that is available on models
such as the Raspberry Pi 4 (for the 2GB or 4GB versions).

Introducing a new PcdExtendedMemoryBase PCD for the base address of the
extended memory region, which currently cannot be retrieved from VideoCore
(MBOX_GET_ARM_MEMSIZE still only returns a single region on Bcm2711).

Introducing a new RpiPlatformGetVirtualMemoryInfo() companion call to
ArmPlatformGetVirtualMemoryMap() that allows us greatly simplify the
registration of each segment in MemoryPeim() as well as making it easier
to maintain for future models.

We also fix SoC register space that should have been marked as reserved
but wasn't until now and remove the unreferenced mSystemMemoryEnd extern
in MemoryInitPeiLib.c.

RaspberryPiMem.c incorporates some code from ArmJunoMem.c.

Signed-off-by: Pete Batard <pete@akeo.ie>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
2019-11-19 18:17:55 +00:00
Pete Batard
24cc66af82 Platform/RPi: Read more variables from VideoCore during early init
Besides the base memory size, we can read the GPU/VideoCore base as
well as the model during early init, which we'll need for improving
the memory mapping.

This patch adds the retrieval of these variables, as well as some
early debug display of their values (which can be useful) and also
removes unused variables such as mGPUMemoryBase and mGPUMemoryLength.

Signed-off-by: Pete Batard <pete@akeo.ie>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
2019-11-19 18:17:09 +00:00
Samer El-Haj-Mahmoud
e46085f14e Platform/RPi: Replace Bcm283x SoC base register address with a PCD
Define BCM2836_SOC_REGISTERS from PcdBcm283xRegistersAddress. This is
needed in preparation for adding Raspberry Pi 4 support, since the two
Pi's have a different base addresses for the Bcm283x specific registers.

Signed-off-by: Pete Batard <pete@akeo.ie>
Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
2019-11-19 18:13:57 +00:00
Pete Batard
03f36b8fcf Platforms/RPi3: Restructure platform in preparation for Pi 4
In preparation for adding Raspberry Pi 4 support, the Pi 3 platform
is restructured by factorizing all the drivers and libraries that are
going to be commonly used by the two platforms.

Because much of the Pi 4 SoC is an extension of the Pi 3 one this
means that almost everything, except the ACPI tables, is moved up
into a new common RaspberryPi/ subdirectory that will serve both
platforms. The .dec is also moved to this directory, under a new
RaspberryPi.dec name, and existing references to it are updated.

This commit requires the edk2-non-osi in use to contain commit 243e55f622ea
in order to build.

Signed-off-by: Pete Batard <pete@akeo.ie>
Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
2019-10-21 15:32:32 +01:00