From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.17557.1610490433938903119 for ; Tue, 12 Jan 2021 14:27:14 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: jeremy.linton@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4FF1C1063; Tue, 12 Jan 2021 14:27:12 -0800 (PST) Received: from mammon-tx2.austin.arm.com (mammon-tx2.austin.arm.com [10.118.28.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 47F873F719; Tue, 12 Jan 2021 14:27:12 -0800 (PST) From: "Jeremy Linton" To: devel@edk2.groups.io Cc: pete@akeo.ie, awarkentin@vmware.com, samer.el-haj-mahmoud@arm.com, leif@nuviainc.com, ard.biesheuvel@arm.com, Jeremy Linton Subject: [RFC 1/3] rpi4: Add XHCI/PCI selection menu Date: Tue, 12 Jan 2021 16:27:06 -0600 Message-Id: <20210112222708.1757044-2-jeremy.linton@arm.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210112222708.1757044-1-jeremy.linton@arm.com> References: <20210112222708.1757044-1-jeremy.linton@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable ARM has standardized a SMC PCI 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. Signed-off-by: Jeremy Linton --- Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c | 32 ++++++++++++++++++= ++++ .../RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf | 3 ++ .../RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni | 5 ++++ .../RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr | 13 +++++++++ Platform/RaspberryPi/Include/ConfigVars.h | 4 +++ Platform/RaspberryPi/RPi3/RPi3.dsc | 9 ++++++ Platform/RaspberryPi/RPi4/RPi4.dsc | 11 ++++++++ Platform/RaspberryPi/RaspberryPi.dec | 3 ++ 8 files changed, 80 insertions(+) diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c b/Platform/= RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c index 6fcbdcdd17..7a3b8e9068 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c @@ -266,6 +266,38 @@ SetupVariables ( ASSERT_EFI_ERROR (Status);=0D }=0D =0D + if (mModelFamily >=3D 4) {=0D + Size =3D sizeof (UINT32);=0D + Status =3D gRT->GetVariable (L"XhciPci",=0D + &gConfigDxeFormSetGuid,=0D + NULL, &Size, &Var32);=0D + if (EFI_ERROR (Status) || (Var32 !=3D 2)) {=0D + // enable Xhci by default=0D + Status =3D PcdSet32S (PcdXhciPci, 1);=0D + ASSERT_EFI_ERROR (Status);=0D + Status =3D PcdSet32S (PcdXhci, 1);=0D + ASSERT_EFI_ERROR (Status);=0D + Status =3D PcdSet32S (PcdPci, 0);=0D + ASSERT_EFI_ERROR (Status);=0D + } else {=0D + // enable PCIe=0D + Status =3D PcdSet32S (PcdXhciPci, 2);=0D + ASSERT_EFI_ERROR (Status);=0D + Status =3D PcdSet32S (PcdXhci, 0);=0D + ASSERT_EFI_ERROR (Status);=0D + Status =3D PcdSet32S (PcdPci, 1);=0D + ASSERT_EFI_ERROR (Status);=0D + }=0D + } else {=0D + // disable pcie and xhci=0D + Status =3D PcdSet32S (PcdXhciPci, 0);=0D + ASSERT_EFI_ERROR (Status);=0D + Status =3D PcdSet32S (PcdXhci, 0);=0D + ASSERT_EFI_ERROR (Status);=0D + Status =3D PcdSet32S (PcdPci, 0);=0D + ASSERT_EFI_ERROR (Status);=0D + }=0D +=0D Size =3D sizeof (AssetTagVar);=0D Status =3D gRT->GetVariable (L"AssetTag",=0D &gConfigDxeFormSetGuid,=0D diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf b/Platfor= m/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf index 544e3b3e10..aa0fbc7e25 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf @@ -92,6 +92,9 @@ gRaspberryPiTokenSpaceGuid.PcdRamLimitTo3GB=0D gRaspberryPiTokenSpaceGuid.PcdFanOnGpio=0D gRaspberryPiTokenSpaceGuid.PcdFanTemp=0D + gRaspberryPiTokenSpaceGuid.PcdXhciPci=0D + gRaspberryPiTokenSpaceGuid.PcdXhci=0D + gRaspberryPiTokenSpaceGuid.PcdPci=0D =0D [Depex]=0D gPcdProtocolGuid AND gRaspberryPiFirmwareProtocolGuid=0D diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni b/Plat= form/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni index 2afe8f32ae..34efb82f57 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni @@ -57,6 +57,11 @@ #string STR_ADVANCED_FANTEMP_PROMPT #language en-US "ACPI fan temperatur= e"=0D #string STR_ADVANCED_FANTEMP_HELP #language en-US "Cycle a fan at C"=0D =0D +#string STR_ADVANCED_XHCIPCI_PROMPT #language en-US "ACPI XHCI/PCIe"=0D +#string STR_ADVANCED_XHCIPCI_HELP #language en-US "OS sees XHCI USB pl= atform device or PCIe bridge"=0D +#string STR_ADVANCED_XHCIPCI_XHCI #language en-US "XHCI"=0D +#string STR_ADVANCED_XHCIPCI_PCIE #language en-US "PCIe"=0D +=0D #string STR_ADVANCED_ASSET_TAG_PROMPT #language en-US "Asset Tag"=0D #string STR_ADVANCED_ASSET_TAG_HELP #language en-US "Set the system Asse= t Tag"=0D =0D diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr b/Plat= form/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr index de5e43471a..4d5876eb24 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr @@ -56,6 +56,11 @@ formset name =3D FanTemp,=0D guid =3D CONFIGDXE_FORM_SET_GUID;=0D =0D + efivarstore ADVANCED_XHCIPCI_VARSTORE_DATA,=0D + attribute =3D EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME= _ACCESS | EFI_VARIABLE_NON_VOLATILE,=0D + name =3D XhciPci,=0D + guid =3D CONFIGDXE_FORM_SET_GUID;=0D +=0D efivarstore SYSTEM_TABLE_MODE_VARSTORE_DATA,=0D attribute =3D EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME= _ACCESS | EFI_VARIABLE_NON_VOLATILE,=0D name =3D SystemTableMode,=0D @@ -207,6 +212,14 @@ formset default =3D 60,=0D endnumeric;=0D endif;=0D +=0D + oneof varid =3D XhciPci.Value,=0D + prompt =3D STRING_TOKEN(STR_ADVANCED_XHCIPCI_PROMPT),=0D + help =3D STRING_TOKEN(STR_ADVANCED_XHCIPCI_HELP),=0D + flags =3D NUMERIC_SIZE_4 | INTERACTIVE | RESET_REQUIRED,= =0D + option text =3D STRING_TOKEN(STR_ADVANCED_XHCIPCI_XHCI), value= =3D 1, flags =3D DEFAULT;=0D + option text =3D STRING_TOKEN(STR_ADVANCED_XHCIPCI_PCIE), value= =3D 2, flags =3D 0;=0D + endoneof;=0D #endif=0D string varid =3D AssetTag.AssetTag,=0D prompt =3D STRING_TOKEN(STR_ADVANCED_ASSET_TAG_PROMPT),=0D diff --git a/Platform/RaspberryPi/Include/ConfigVars.h b/Platform/Raspberry= Pi/Include/ConfigVars.h index c185bfe28b..eb08ad8987 100644 --- a/Platform/RaspberryPi/Include/ConfigVars.h +++ b/Platform/RaspberryPi/Include/ConfigVars.h @@ -77,6 +77,10 @@ typedef struct { } ADVANCED_FANTEMP_VARSTORE_DATA;=0D =0D typedef struct {=0D + UINT32 Value;=0D +} ADVANCED_XHCIPCI_VARSTORE_DATA;=0D +=0D +typedef struct {=0D #define SYSTEM_TABLE_MODE_ACPI 0=0D #define SYSTEM_TABLE_MODE_BOTH 1=0D #define SYSTEM_TABLE_MODE_DT 2=0D diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc b/Platform/RaspberryPi/RPi3= /RPi3.dsc index 530b42796a..0aeb27d69d 100644 --- a/Platform/RaspberryPi/RPi3/RPi3.dsc +++ b/Platform/RaspberryPi/RPi3/RPi3.dsc @@ -514,6 +514,15 @@ =0D gRaspberryPiTokenSpaceGuid.PcdPlatformResetDelay|L"ResetDelay"|gRaspberr= yPiTokenSpaceGuid|0x0|0=0D =0D + # Select XHCI/PCIe mode (not valid on rpi3)=0D + #=0D + # 0 - DISABLED=0D + #=0D + gRaspberryPiTokenSpaceGuid.PcdXhciPci|L"XhciPci"|gConfigDxeFormSetGuid|0= x0|0=0D + # SSDT selectors=0D + gRaspberryPiTokenSpaceGuid.PcdXhci|L"Xhci"|gConfigDxeFormSetGuid|0x0|0=0D + gRaspberryPiTokenSpaceGuid.PcdPci|L"Pci"|gConfigDxeFormSetGuid|0x0|0=0D +=0D #=0D # Common UEFI ones.=0D #=0D diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc b/Platform/RaspberryPi/RPi4= /RPi4.dsc index 0cd1014095..d5952288cc 100644 --- a/Platform/RaspberryPi/RPi4/RPi4.dsc +++ b/Platform/RaspberryPi/RPi4/RPi4.dsc @@ -528,6 +528,17 @@ =0D gRaspberryPiTokenSpaceGuid.PcdPlatformResetDelay|L"ResetDelay"|gRaspberr= yPiTokenSpaceGuid|0x0|0=0D =0D + # Select XHCI/PCIe mode=0D + #=0D + # 0 - DISABLED (not valid for rpi4)=0D + # 1 - Xhci Enabled (default)=0D + # 2 - Pcie Enabled=0D + #=0D + gRaspberryPiTokenSpaceGuid.PcdXhciPci|L"XhciPci"|gConfigDxeFormSetGuid|0= x0|1=0D + # SSDT selectors=0D + gRaspberryPiTokenSpaceGuid.PcdXhci|L"Xhci"|gConfigDxeFormSetGuid|0x0|1=0D + gRaspberryPiTokenSpaceGuid.PcdPci|L"Pci"|gConfigDxeFormSetGuid|0x0|0=0D +=0D #=0D # Common UEFI ones.=0D #=0D diff --git a/Platform/RaspberryPi/RaspberryPi.dec b/Platform/RaspberryPi/Ra= spberryPi.dec index 10723036aa..6c7d4e5116 100644 --- a/Platform/RaspberryPi/RaspberryPi.dec +++ b/Platform/RaspberryPi/RaspberryPi.dec @@ -69,3 +69,6 @@ gRaspberryPiTokenSpaceGuid.PcdFanOnGpio|0|UINT32|0x0000001C=0D gRaspberryPiTokenSpaceGuid.PcdFanTemp|0|UINT32|0x0000001D=0D gRaspberryPiTokenSpaceGuid.PcdPlatformResetDelay|0|UINT32|0x0000001E=0D + gRaspberryPiTokenSpaceGuid.PcdXhci|0|UINT32|0x0000001F=0D + gRaspberryPiTokenSpaceGuid.PcdPci|0|UINT32|0x00000020=0D + gRaspberryPiTokenSpaceGuid.PcdXhciPci|0|UINT32|0x00000021=0D --=20 2.13.7