263 Commits

Author SHA1 Message Date
Adrien Thierry
ad00518399 Platform/RaspberryPi: fix pci DT node address in SyncPcie()
To make sure the XHCI controller does not get reset by Linux in DT mode,
we remove its pci parent node from the device tree. However, the pci
node address has been updated in the Raspberry Pi 4 device tree [1] and
no longer matches the one we are trying to remove in SyncPcie(). This
results in the XHCI controller actually being reset by Linux, which
leads to errors during USB initialization:

[    3.563963] xhci_hcd 0000:01:00.0: xHCI Host Controller
[    3.569538] xhci_hcd 0000:01:00.0: new USB bus registered, assigned bus number 1
[    3.577452] xhci_hcd 0000:01:00.0: hcc params 0x002841eb hci version 0x100 quirks 0x0000040000000890
[    3.587725] xhci_hcd 0000:01:00.0: xHCI Host Controller
[    3.593115] xhci_hcd 0000:01:00.0: new USB bus registered, assigned bus number 2
[    3.600693] xhci_hcd 0000:01:00.0: Host supports USB 3.0 SuperSpeed
[    3.608106] hub 1-0:1.0: USB hub found
[    3.612026] hub 1-0:1.0: 1 port detected
[    3.616819] hub 2-0:1.0: USB hub found
[    3.620726] hub 2-0:1.0: 4 ports detected
[    3.875902] usb 1-1: new high-speed USB device number 2 using xhci_hcd
[    4.008123] usb 1-1: device descriptor read/64, error -71
[    4.256088] usb 1-1: device descriptor read/64, error -71
[    4.495882] usb 1-1: new high-speed USB device number 3 using xhci_hcd
[    4.628111] usb 1-1: device descriptor read/64, error -71
[    4.872083] usb 1-1: device descriptor read/64, error -71
[    5.407888] usb 1-1: new high-speed USB device number 4 using xhci_hcd
[    6.023964] xhci_hcd 0000:01:00.0: Setup ERROR: setup address command for slot 1.
[    6.239977] xhci_hcd 0000:01:00.0: Setup ERROR: setup address command for slot 1.

This patch allows matching any address for the pci node, thus working
with both legacy and new device trees.

[1] https://lore.kernel.org/all/20210831125843.1233488-1-nsaenzju@redhat.com/

Fixes: efff29cdcd ("Platform/RaspberryPi: Always use non translating DMA in DT mode")
Signed-off-by: Adrien Thierry <athierry@redhat.com>
Reviewed-by: Jeremy Linton <jeremy.linton@arm.com>
Tested-by: Jeremy Linton <jeremy.linton@arm.com>
2022-10-10 11:14:17 +02:00
Kun Qin
5000d967d1 RaspberryPi: Platform Build: Resolving newly introduced dependency
The new changes in SecureBootVariableLib brought in a new dependency
of PlatformPKProtectionLib.

This change added the new library instance from SecurityPkg to resolve
RaspberryPi platforms build.

Signed-off-by: Kun Qin <kuqin12@gmail.com>
Reviewed-by: Jeremy Linton <jeremy.linton@arm.com>
2022-08-16 19:53:14 +02:00
Sami Mujawar
b8c4f5c787 Platform/RaspberryPi: Update for IORT revision macro renaming
The IORT Specification E.d updates the IORT table revision to 5. To
reflect this change the IORT header file has been updated to rename
the EFI_ACPI_IO_REMAPPING_TABLE_REVISION macro which was at Rev 0 to
EFI_ACPI_IO_REMAPPING_TABLE_REVISION_00.

Therefore, update the usage of EFI_ACPI_IO_REMAPPING_TABLE_REVISION
macro in the IORT table for RaspberryPi platform to
EFI_ACPI_IO_REMAPPING_TABLE_REVISION_00.

Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
Reviewed-by: Jeremy Linton <jeremy.linton@arm.com>
Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>
2022-07-29 19:38:45 +01:00
Michael Kubacki
24164d55ae RaspberryPi: Add VariableFlashInfoLib
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3479

Adds an instance for the library class VariableFlashInfoLib that
was recently introduced in MdeModulePkg. This change is made to
allow the new variable driver to build that has a dependency on
this library class and does not require any further platform
changes.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Jeremy Linton <jeremy.linton@arm.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Tested-by: Jeremy Linton <jeremy.linton@arm.com>
Reviewed-by: Jeremy Linton <jeremy.linton@arm.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
2022-05-19 11:46:19 +08:00
Adrien Thierry
b0f3f90372 Platform/RaspberryPi: Add 'clock-frequency' property for miniuart
Describe the miniuart clock frequency in a _DSD property, so that it can
be read from the Linux driver [1]

The miniuart clock frequency is the core clock frequency on the
Raspberry Pi. It can be modified by the user using the 'core_freq'
property in the config.txt file. So, we fetch it from the underlying
Raspberry Pi firmware.

[1] https://lore.kernel.org/all/20220207232129.402882-1-athierry@redhat.com/

Signed-off-by: Adrien Thierry <athierry@redhat.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
2022-02-08 17:54:47 +01:00
Jeremy Linton
63d520f943 Platform/RaspberryPi: Disconnect/shutdown all drivers before reboot
In theory we should be properly cleaning up all the device drivers before
hitting the big reset. The partition manager will issue flush commands to
attached disks as it goes down. This assures that devices running in WB mode,
which correctly handle flush/sync/etc commands, are persisted to physical
media before reset.

Without this, there are definitely cases where the relevant specifications
don't guarantee persistence of data in their buffers in the face of reset
conditions. We can't really do anything about the many devices that don't
honor persistence requests, but we can start here.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
2021-10-19 09:22:17 +02:00
Jeremy Linton
af649f800e Platform/RaspberryPi: Normal memory should not be marked as uncached
The EFI spec seems to indicate that the EFI uncacheable attribute
should be mapped to device memory rather than normal-nc. This means
that the UEFI mem attribute for the >3G ram doesn't match the remainder
of the RAM in the machine.

So, lets remove the uncacheable attribute to make it more consistent.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
2021-10-19 09:22:17 +02:00
Jeremy Linton
fd988a9e4e Platform/RaspberryPi: Expand locking to cover return data
It appears that the locking for many of the mailbox commands is
incorrect. All UEFI firmware calls to the RPi mailbox share a single
mDmaBuffer. That buffer is used to fill out the command passed to the
vc firmware, and record its response. The buffer is protected by
mMailboxLock, yet in many cases the mailbox response is copied from
the buffer after the lock has been released. This doesn't currently
appear to be causing any problems, but should be fixed anyway.

There are a couple other minor tweaks in this patch that are hard to
justify on their own, one is a bit of whitespace cleanup, and the
other is the addition of a debug message to print the returned clock
rate for the requested clock. This latter print would have immediatly
shown that the vc firmware was returning 0 as the emmc clock rate
rather than something reasonable.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
Reviewed-by: Andrei Warkentin <awarkentin@vmware.com>
2021-10-19 09:22:17 +02:00
Jeremy Linton
ee4be44e01 Platform/RaspberryPi: Fix vfr warning caused by two defaults
The build has been tossing a warning about having two defaults
for a while now, lets fix it.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
Reviewed-by: Andrei Warkentin <awarkentin@vmware.com>
2021-10-19 09:22:17 +02:00
Jeremy Linton
efff29cdcd Platform/RaspberryPi: Always use non translating DMA in DT mode
One of the many issues with the PCIe on this platform is its inbound
DMA is either constrained to the lower 3G, or on later SOC's a
translation may be used. That translation is problematic with some of
the OS's expected to boot on this platform. So, across the board a 3G
DMA limit is enforced during boot when in ACPI mode. This itself
causes problems because the later boards removed the SPI EEPROM used
by the onboard XHCI controller, instead favoring using a block of RAM
to load its firmware. Hence it is the lower level firmware's
responsibility via a mailbox call, to read the bridge
translation/configuration before telling the XHCI controller where it
can find its firmware.

Everything is great in ACPI land. Now it appears that Linux after
reprogramming the bridge to match the DT (when using a translation)
can't actually get the XHCI/quirk/reset to function. Apparently,
because the firmware only reads the bridge configuration the first
time its called(?), or the kernel reset sequence isn't correct. Worse,
with just the DMA ranges corrected, the XHCI/QUIRK itself then causes
the controller to start having what appear to be DMA issues.

Lets simplify the situation and make all DT's provided by this
firmware have a 3G DMA limit on the PCIe bus. Then remove the ability
for Linux/etc to trigger the quirk by remove the DT node attaching the
reset controller to the XHCI. The latter seems somewhat questionable,
since the DT/PCIe host bridge driver is doing what appears to be a
PERST which might then require a firmware reload, but at the
moment seems to work without.

The first part of this patch also appears to fix a problem with
OpenBSD which interprets the DT as describing how the firmware
has configured the device, and makes no attempt to reconfigure it.
Hence the newer SOC's implementing a translation fail to boot
since the DT being passed to the OS doesn't match the translation
the firmware has setup.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
2021-10-19 09:22:05 +02:00
Mark Kettenis
ab6fcc28fd Platform/RaspberryPi: Remove TypeTranslation attribute
The MMIO host bridge window isn't translated as both the primary
and secondary side are MMIO.  So remove the incorrect
TypeTranslation attribute.

Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
2021-10-10 23:07:44 +02:00
Pete Batard
901d3c52ed Platform/RaspberryPi/RPi4: Add _DSM ACPI method for 32-bit MMIO xHCI access
With the upcoming release of Windows 11, Microsoft has introduced a new USB
Device-Specific Method (_DSM) function to enforce 64-bit xHCI registers to
be accessed through two sequential 32-bit requests. The new function (Query
controller register access type - Function 6) is documented at:
https://docs.microsoft.com/en-us/windows-hardware/drivers/bringup/usb-device-specific-method---dsm-

Support for this feature is required on the Raspberry Pi 4 where there is
a bug/limitation in the xHCI stack that prevents full range 64-bit access
from working correctly. It should be noted that an equivalent for this _DSM
is not required on Linux, as 64-bit xHCI register access is already broken
down into 2x32-bit by the drivers there.

With this _DSM, and unlike what is the case for Windows 10, Windows 11 can
now be installed on the Raspberry Pi 4 without having to alter any of the
installation files, as we were able to validate using the latest Windows 11
Build 22000 Insider image.

Signed-off-by: Pete Batard <pete@akeo.ie>
Tested-by: Pete Batard <pete@akeo.ie>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
2021-09-01 19:29:58 +02:00
Grzegorz Bernacki
6895992e55 Platform/RaspberryPi: Enable Boot Discovery Policy.
Modify platform boot to check the value of BootDiscoveryPolicy variable
and use BootPolicyManager Protocol to connect devices specified by the
variable.

Signed-off-by: Grzegorz Bernacki <gjb@semihalf.com>
Reviewed-by: Sunny Wang <sunny.wang@arm.com>
Reviewed-by: Pete Batard <pete@akeo.ie>
Tested-by: Pete Batard <pete@akeo.ie>
2021-09-01 19:21:55 +02:00
Jeremy Linton
46026ad759 Platform/RaspberryPi: Add Linux quirk support
Linux, for the time being has refused to support the Arm
standard SMCCC for PCIe configuration. Instead they
want to continue to maintain per device "quirks".

As the RPI isn't really ECAM this is a bit more
involved because the MCFG can't really describe
the root port+config registers situation. Further
platforms which support the SMCCC shouldn't have
a MCFG, so we need an additional way to tell linux
what it needs to know about this platform.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
Reviewed-by: Andrei Warkentin <awarkentin@vmware.com>
Reviewed-By: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
2021-08-22 15:55:32 +02:00
Jeremy Linton
5a6706e679 Platform/RaspberryPi: Enable NVMe boot on CM4
The CM4 has a number of carrier boards with PCIe
slots. With the PCIe changes in place its quite
possible to utilize a NVMe root device. Lets allow
people to boot from it.

Reviewed-by: Andrei Warkentin <awarkentin@vmware.com>
Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
Reviewed-By: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
2021-08-22 15:55:26 +02:00
Jeremy Linton
fc4eb72f88 Platform/RaspberryPi: Add PCIe SSDT
Since we plan on toggling between XHCI and PCI the PCI
root needs to be in its own SSDT. This is all thats needed
of UEFI. The SMC conduit is provided directly to the running
OS. When the OS detects this PCIe port on a machine without
a MCFG it attempts to connect to the SMC conduit. The RPi
definition doesn't have any power mgmt, and only provides
a description of the root port.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
Tested-by: Jared McNeill <jmcneill@invisible.ca>
2021-08-22 15:54:45 +02:00
Jeremy Linton
5cf33c71cb Platform/RaspberryPi: Break XHCI into its own SSDT
Lets prepare to switch between XHCI and PCI by moving
the XHCI definition into its own SSDT. That way we can
select it based on the menu settings. The resource
producer/consumer flag is also corrected.

Reviewed-by: Andrei Warkentin <awarkentin@vmware.com>
Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
Tested-by: Jared McNeill <jmcneill@invisible.ca>
2021-08-22 15:54:38 +02:00
Jeremy Linton
63a54c6f40 Platform/RaspberryPi: Add XHCI/PCI selection menu
Arm has standardized a PCI SMC conduit that can be used
to access the PCI config space in a standardized way. This
functionality doesn't yet exist in many OS/Distro's. Lets
add another advanced config item that allows the user
to toggle between presenting the XHCI on the base RPi4
as a platform device, or presenting this newer PCIe
conduit. The CM4 doesn't have an attached XHCI controller
soldered to the PCIe, so PCIe mode is the default.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
Reviewed-by: Andrei Warkentin <awarkentin@vmware.com>
Reviewed-By: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
Tested-by: Jared McNeill <jmcneill@invisible.ca>
2021-08-22 15:54:28 +02:00
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
Jeremy Linton
b291607503 Platform/RaspberryPi: Increase genet dma window
The genet is capable of addressing the entire memory space
on the RPI4. Lets allow it to dma into those regions.
This solves intermittent issues with grub/etc being able
to communicate when the 3G limit is lifted on 8G boards.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
Reviewed-by: Jared McNeill <jmcneill@invisible.ca>
2021-08-16 09:21:31 +02:00
Grzegorz Bernacki
5ba08a9b75 Platform/RaspberryPi: Enable default Secure Boot variables initialization
This commit allows to initialize Secure Boot default key
and databases from data embedded in firmware binary.

Signed-off-by: Grzegorz Bernacki <gjb@semihalf.com>
Reviewed-by: Sunny Wang <sunny.wang@arm.com>
Reviewed-by: Pete Batard <pete@akeo.ie>
Tested-by: Pete Batard <pete@akeo.ie> # on Raspberry Pi 4
2021-08-04 14:32:33 +02:00
Grzegorz Bernacki
6196d93328 Platform: add SecureBootVariableLib resolution to various ARM platforms
The edk2 patch
  SecurityPkg: Create library for setting Secure Boot variables.

removes generic functions from SecureBootConfigDxe and places
them into SecureBootVariableLib. This patch adds SecureBootVariableLib
mapping for each ARM platform which uses SecureBootConfigDxe.

Signed-off-by: Grzegorz Bernacki <gjb@semihalf.com>
Reviewed-by: Graeme Gregory <graeme@nuviainc.com> #SbsaQemu
Reviewed by: Sami Mujawar <sami.mujawar@arm.com>  #ArmVExpress
2021-08-04 14:29:32 +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
Grzegorz Bernacki
2e87ce84dc Platform/RaspberryPi: Enable Boot Discovery Policy.
Modify platform boot to check the value of BootDiscoveryPolicy variable
and use BootPolicyManager Protocol to connect devices specified by the
variable.

Signed-off-by: Grzegorz Bernacki <gjb@semihalf.com>
Reviewed-by: Sunny Wang <sunny.wang@arm.com>
Reviewed-by: Pete Batard <pete@akeo.ie>
Tested-by: Pete Batard <pete@akeo.ie>
2021-08-03 18:05:18 +02:00
Samer El-Haj-Mahmoud
1942692232 Platform/RaspberryPi/RPi4: Fix non-standard ACPI CIDs
Remove non-standard RPI ACPI _CIDs that are not needed.
This also fixes the FWTS failure reported in
https://github.com/pftf/RPi4/issues/67

The windows drivers at https://github.com/raspberrypi/windows-drivers
are still able to match the ACPI objects using the HIDs which
are supported in the drivers, with these two recent changes needed:
6469702898789e555c6947e50216a3f79e0ddeb9
and
5c5e2742b4c983b3001c473b168b0dae2fcba0c2

Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Pete Batard <pete@akeo.ie>
Cc: Andrei Warkentin <awarkentin@vmware.com>
Cc: Mario Bălănică <mariobalanica02@gmail.com>
Signed-off-by: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
Tested-by: Mario Bălănică <mariobalanica02@gmail.com>
Reviewed-by: Sunny Wang <sunny.wang@arm.com>
Tested-by: Sunny Wang <sunny.wang@arm.com>
Reviewed-by: Andrei Warkentin <awarkentin@vmware.com>
2021-07-22 12:38:18 +02:00