From: "Ard Biesheuvel" <ard.biesheuvel@arm.com>
To: devel@edk2.groups.io
Cc: leif@nuviainc.com, philmd@redhat.com,
Ard Biesheuvel <ard.biesheuvel@arm.com>
Subject: [PATCH edk2-platforms v3 6/8] Platform/RaspberryPi4: Register GENET platform device protocol
Date: Tue, 12 May 2020 18:41:23 +0200 [thread overview]
Message-ID: <20200512164125.28139-7-ard.biesheuvel@arm.com> (raw)
In-Reply-To: <20200512164125.28139-1-ard.biesheuvel@arm.com>
Register an event at EndOfDxe to instantiate the EFI device path protocol
with the GENET MAC address on a new handle, and install the
BcmGenetPlatformDeviceProtocol on that handle. This protocol is used to
pass platform information (GENET MAC address and register base address)
to the GENET driver, which will consume this in its implementation of the
UEFI driver model Supported/Start/Stop methods.
Co-authored-by: Samer El-Haj-Mahmoud <samer.el-haj-mahmoud@arm.com>
Co-authored-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
Co-authored-by: Andrei Warkentin <awarkentin@vmware.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
---
Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf | 8 +-
Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c | 91 +++++++++++++++++++-
2 files changed, 95 insertions(+), 4 deletions(-)
diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf
index 44b5cc2294d0..f20f3bcc1243 100644
--- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf
+++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf
@@ -23,7 +23,6 @@ [Defines]
#
# VALID_ARCHITECTURES = AARCH64
#
-
[Sources]
ConfigDxe.c
ConfigDxeFormSetGuid.h
@@ -57,10 +56,12 @@ [LibraryClasses]
[Guids]
gConfigDxeFormSetGuid
+ gEfiEndOfDxeEventGroupGuid
[Protocols]
- gRaspberryPiFirmwareProtocolGuid ## CONSUMES
- gRaspberryPiConfigAppliedProtocolGuid ## PRODUCES
+ gBcmGenetPlatformDeviceProtocolGuid ## PRODUCES
+ gRaspberryPiFirmwareProtocolGuid ## CONSUMES
+ gRaspberryPiConfigAppliedProtocolGuid ## PRODUCES
[FixedPcd]
gRaspberryPiTokenSpaceGuid.PcdCpuLowSpeedMHz
@@ -69,6 +70,7 @@ [FixedPcd]
[Pcd]
gBcm27xxTokenSpaceGuid.PcdBcm27xxRegistersAddress
+ gBcm27xxTokenSpaceGuid.PcdBcmGenetRegistersAddress
gBcm283xTokenSpaceGuid.PcdBcm283xRegistersAddress
gRaspberryPiTokenSpaceGuid.PcdCpuClock
gRaspberryPiTokenSpaceGuid.PcdCustomCpuClock
diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
index df82902e8958..ac1004fe1836 100644
--- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
+++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
@@ -22,6 +22,7 @@
#include <Library/NetLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Protocol/BcmGenetPlatformDevice.h>
#include <Protocol/RpiFirmware.h>
#include <ConfigVars.h>
#include "ConfigDxeFormSetGuid.h"
@@ -35,6 +36,8 @@ STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL *mFwProtocol;
STATIC UINT32 mModelFamily = 0;
STATIC UINT32 mModelInstalledMB = 0;
+STATIC EFI_MAC_ADDRESS mMacAddress;
+
/*
* The GUID inside Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.inf and
* Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf _must_ match below.
@@ -48,6 +51,18 @@ typedef struct {
EFI_DEVICE_PATH_PROTOCOL End;
} HII_VENDOR_DEVICE_PATH;
+#pragma pack (1)
+typedef struct {
+ MAC_ADDR_DEVICE_PATH MacAddrDP;
+ EFI_DEVICE_PATH_PROTOCOL End;
+} GENET_DEVICE_PATH;
+
+typedef struct {
+ GENET_DEVICE_PATH DevicePath;
+ BCM_GENET_PLATFORM_DEVICE_PROTOCOL PlatformDevice;
+} GENET_DEVICE;
+#pragma pack ()
+
STATIC HII_VENDOR_DEVICE_PATH mVendorDevicePath = {
{
{
@@ -70,6 +85,65 @@ STATIC HII_VENDOR_DEVICE_PATH mVendorDevicePath = {
}
};
+STATIC GENET_DEVICE mGenetDevice = {
+ {
+ {
+ {
+ MESSAGING_DEVICE_PATH,
+ MSG_MAC_ADDR_DP,
+ {
+ (UINT8)(sizeof (MAC_ADDR_DEVICE_PATH)),
+ (UINT8)((sizeof (MAC_ADDR_DEVICE_PATH)) >> 8)
+ }
+ },
+ {{ 0 }},
+ NET_IFTYPE_ETHERNET
+ },
+ {
+ END_DEVICE_PATH_TYPE,
+ END_ENTIRE_DEVICE_PATH_SUBTYPE,
+ {
+ sizeof (EFI_DEVICE_PATH_PROTOCOL),
+ 0
+ }
+ }
+ },
+ {
+ GENET_BASE_ADDRESS,
+ {{ 0 }}
+ }
+};
+
+
+STATIC
+VOID
+EFIAPI
+RegisterDevices (
+ EFI_EVENT Event,
+ VOID *Context
+ )
+{
+ EFI_HANDLE Handle;
+ EFI_STATUS Status;
+
+ if (mModelFamily == 4) {
+ DEBUG ((DEBUG_INFO, "GENET: MAC address %02X:%02X:%02X:%02X:%02X:%02X\n",
+ mMacAddress.Addr[0], mMacAddress.Addr[1], mMacAddress.Addr[2],
+ mMacAddress.Addr[3], mMacAddress.Addr[4], mMacAddress.Addr[5]));
+
+ CopyMem (&mGenetDevice.DevicePath.MacAddrDP.MacAddress, mMacAddress.Addr,
+ NET_ETHER_ADDR_LEN);
+ CopyMem (&mGenetDevice.PlatformDevice.MacAddress, mMacAddress.Addr,
+ NET_ETHER_ADDR_LEN);
+
+ Handle = NULL;
+ Status = gBS->InstallMultipleProtocolInterfaces (&Handle,
+ &gEfiDevicePathProtocolGuid, &mGenetDevice.DevicePath,
+ &gBcmGenetPlatformDeviceProtocolGuid, &mGenetDevice.PlatformDevice,
+ NULL);
+ ASSERT_EFI_ERROR (Status);
+ }
+}
STATIC EFI_STATUS
InstallHiiPages (
@@ -243,6 +317,16 @@ SetupVariables (
PcdSet32 (PcdDisplayEnableSShot, PcdGet32 (PcdDisplayEnableSShot));
}
+ if (mModelFamily == 4) {
+ //
+ // Get the MAC address from the firmware.
+ //
+ Status = mFwProtocol->GetMacAddress (mMacAddress.Addr);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_WARN, "%a: failed to retrieve MAC address\n", __FUNCTION__));
+ }
+ }
+
return EFI_SUCCESS;
}
@@ -449,7 +533,8 @@ ConfigInitialize (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
+ EFI_EVENT EndOfDxeEvent;
Status = gBS->LocateProtocol (&gRaspberryPiFirmwareProtocolGuid,
NULL, (VOID**)&mFwProtocol);
@@ -495,5 +580,9 @@ ConfigInitialize (
ASSERT_EFI_ERROR (Status);
}
+ Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_NOTIFY, RegisterDevices,
+ NULL, &gEfiEndOfDxeEventGroupGuid, &EndOfDxeEvent);
+ ASSERT_EFI_ERROR (Status);
+
return EFI_SUCCESS;
}
--
2.17.1
next prev parent reply other threads:[~2020-05-12 16:41 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-12 16:41 [PATCH edk2-platforms v3 0/8] Add Broadcom GENET driver for RPi4 Ard Biesheuvel
2020-05-12 16:41 ` [PATCH edk2-platforms v3 1/8] Platform/RaspberryPi4: set DMA translation for BCM Genet driver Ard Biesheuvel
2020-05-12 16:41 ` [PATCH edk2-platforms v3 2/8] Silicon/Broadcom: Add BcmGenetPlatformDevice protocol Ard Biesheuvel
2020-05-12 16:41 ` [PATCH edk2-platforms v3 3/8] Silicon/Broadcom/BcmGenetDxe: Add GENET driver Ard Biesheuvel
2020-05-12 16:41 ` [PATCH edk2-platforms v3 4/8] Platform/RaspberryPi4: Clean up PCDs out of the " Ard Biesheuvel
2020-05-12 16:41 ` [PATCH edk2-platforms v3 5/8] Platform/RaspberryPi/ConfigDxe: preliminary cleanup Ard Biesheuvel
2020-05-12 16:41 ` Ard Biesheuvel [this message]
2020-05-12 16:41 ` [PATCH edk2-platforms v3 7/8] Platform/RaspberryPi4: Remove PlatformPcdLib Ard Biesheuvel
2020-05-12 16:41 ` [PATCH edk2-platforms v3 8/8] Platform/RaspberryPi4: remove ASIX 88772b driver Ard Biesheuvel
2020-05-12 17:15 ` [edk2-devel] [PATCH edk2-platforms v3 0/8] Add Broadcom GENET driver for RPi4 Leif Lindholm
2020-05-12 17:21 ` Ard Biesheuvel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200512164125.28139-7-ard.biesheuvel@arm.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox