From nobody Mon Feb 9 19:07:23 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+59251+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+59251+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1589270127; cv=none; d=zohomail.com; s=zohoarc; b=B5Df5UYWIJxKPFLE9N7oA1fAtBZIxDsvZP7wAzxn95cj0NnOYFuZpRP96yo0fXeYTo9jjGyPGu6lkttLv0IxAjYl9mavTNIkP6sYB/oxrOWFXM+rvTEHC0Rk3BlpCtZSNDgfvYz6g98Kv72bxsJf6RytQC4a2DpxpLUAHWfqyzo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589270127; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=kk9u3WDFBn21AbyXKuF+aGyKmMsaS+rIgQ6sIZHGyjY=; b=a+q7RTtmeBSGq0C4xx7mE2iJOHOjaIlTLtrBlzVNqJnnhiw4Cs3chxa9DgNeIjsL+CiYhOQsfXUEfAYWx1TfRe1/MvGnFk21ULs0OvstkwP9jWf9Vttascs/JCmEu3sSr3NXmPZpzB7+PqkZweqhPqOaxetoZhgy6oBaK1kYs4E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+59251+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1589270126987749.7913352456095; Tue, 12 May 2020 00:55:26 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id FoT5YY1788612xGtrLS4NjCe; Tue, 12 May 2020 00:55:26 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.1723.1589270125751657767 for ; Tue, 12 May 2020 00:55:25 -0700 X-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 6ECD01042; Tue, 12 May 2020 00:55:25 -0700 (PDT) X-Received: from e123331-lin.nice.arm.com (unknown [10.37.8.255]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6867C3F305; Tue, 12 May 2020 00:55:24 -0700 (PDT) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: leif@nuviainc.com, philmd@redhat.com, Ard Biesheuvel Subject: [edk2-devel] [PATCH edk2-platforms v2 5/7] Platform/RaspberryPi4: Register GENET platform device protocol Date: Tue, 12 May 2020 09:55:10 +0200 Message-Id: <20200512075512.12645-6-ard.biesheuvel@arm.com> In-Reply-To: <20200512075512.12645-1-ard.biesheuvel@arm.com> References: <20200512075512.12645-1-ard.biesheuvel@arm.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ard.biesheuvel@arm.com X-Gm-Message-State: 0BWEXxFPWsaVQPB4mZ94h7iEx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1589270126; bh=xTEu7sx0Xzw1/jdoBa+LjCwkA0wXE4NfxqTir2SEbeA=; h=Cc:Date:From:Reply-To:Subject:To; b=mVeMkXyTrBwH84yFeCWbnt7qoXDaXaRs7zFrW6QRmbUF+Qfdls0YTv2aKZ/lIwHYSW3 +C55JUMnBOIXi6fh6vktBsPYXOL4I//fu90XSS0eDNH987HvZInHek0Dm8/zh9ofGwDta W71lQxp+Ho9kRd03ZHcS/RUwwrpXNjaAk5s= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Co-authored-by: Ard Biesheuvel Co-authored-by: Andrei Warkentin Signed-off-by: Ard Biesheuvel --- Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf | 29 ++++-- Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c | 108 +++++++++++++++= +++-- 2 files changed, 117 insertions(+), 20 deletions(-) diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf b/Platfor= m/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf index e47f3af69199..f20f3bcc1243 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf @@ -1,6 +1,8 @@ #/** @file # -# Copyright (c) 2019, ARM Limited. All rights reserved. +# Component description file for the RasbperryPi DXE platform config driv= er. +# +# Copyright (c) 2019 - 2020, ARM Limited. All rights reserved. # Copyright (c) 2018, Andrei Warkentin # # SPDX-License-Identifier: BSD-2-Clause-Patent @@ -21,7 +23,6 @@ [Defines] # # VALID_ARCHITECTURES =3D AARCH64 # - [Sources] ConfigDxe.c ConfigDxeFormSetGuid.h @@ -31,31 +32,36 @@ [Sources] [Packages] ArmPkg/ArmPkg.dec ArmPlatformPkg/ArmPlatformPkg.dec - MdePkg/MdePkg.dec + EmbeddedPkg/EmbeddedPkg.dec MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + NetworkPkg/NetworkPkg.dec + Platform/RaspberryPi/RaspberryPi.dec Silicon/Broadcom/Bcm27xx/Bcm27xx.dec Silicon/Broadcom/Bcm283x/Bcm283x.dec - Platform/RaspberryPi/RaspberryPi.dec - EmbeddedPkg/EmbeddedPkg.dec + Silicon/Broadcom/Drivers/Net/BcmNet.dec =20 [LibraryClasses] + AcpiLib BaseLib DebugLib DxeServicesTableLib + GpioLib + HiiLib + NetLib PcdLib UefiBootServicesTableLib - UefiRuntimeServicesTableLib UefiDriverEntryPoint - HiiLib - GpioLib - AcpiLib + UefiRuntimeServicesTableLib =20 [Guids] gConfigDxeFormSetGuid + gEfiEndOfDxeEventGroupGuid =20 [Protocols] - gRaspberryPiFirmwareProtocolGuid ## CONSUMES - gRaspberryPiConfigAppliedProtocolGuid ## PRODUCES + gBcmGenetPlatformDeviceProtocolGuid ## PRODUCES + gRaspberryPiFirmwareProtocolGuid ## CONSUMES + gRaspberryPiConfigAppliedProtocolGuid ## PRODUCES =20 [FixedPcd] gRaspberryPiTokenSpaceGuid.PcdCpuLowSpeedMHz @@ -64,6 +70,7 @@ [FixedPcd] =20 [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 00867879da20..47ca0a89a3d8 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c @@ -1,6 +1,6 @@ /** @file * - * Copyright (c) 2019, ARM Limited. All rights reserved. + * Copyright (c) 2019 - 2020, ARM Limited. All rights reserved. * Copyright (c) 2018 - 2019, Andrei Warkentin * * SPDX-License-Identifier: BSD-2-Clause-Patent @@ -8,19 +8,21 @@ **/ =20 #include +#include +#include +#include +#include #include -#include #include +#include #include +#include +#include #include +#include #include #include -#include -#include -#include -#include -#include -#include +#include #include #include #include "ConfigDxeFormSetGuid.h" @@ -34,6 +36,8 @@ STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL *mFwProtocol; STATIC UINT32 mModelFamily =3D 0; STATIC UINT32 mModelInstalledMB =3D 0; =20 +STATIC EFI_MAC_ADDRESS MacAddress; + /* * The GUID inside Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.inf and * Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf _must_ match below. @@ -47,6 +51,18 @@ typedef struct { EFI_DEVICE_PATH_PROTOCOL End; } HII_VENDOR_DEVICE_PATH; =20 +#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 =3D { { { @@ -69,6 +85,65 @@ STATIC HII_VENDOR_DEVICE_PATH mVendorDevicePath =3D { } }; =20 +STATIC GENET_DEVICE mGenetDevice =3D { + { + { + { + 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 =3D=3D 4) { + DEBUG ((DEBUG_INFO, "GENET: MAC address %02X:%02X:%02X:%02X:%02X:%02X\= n", + MacAddress.Addr[0], MacAddress.Addr[1], MacAddress.Addr[2], + MacAddress.Addr[3], MacAddress.Addr[4], MacAddress.Addr[5])); + + CopyMem (&mGenetDevice.DevicePath.MacAddrDP.MacAddress, MacAddress.Add= r, + NET_ETHER_ADDR_LEN); + CopyMem (&mGenetDevice.PlatformDevice.MacAddress, MacAddress.Addr, + NET_ETHER_ADDR_LEN); + + Handle =3D NULL; + Status =3D gBS->InstallMultipleProtocolInterfaces (&Handle, + &gEfiDevicePathProtocolGuid, &mGenetDevice.De= vicePath, + &gBcmGenetPlatformDeviceProtocolGuid, &mGenetDevice.Pl= atformDevice, + NULL); + ASSERT_EFI_ERROR (Status); + } +} =20 STATIC EFI_STATUS InstallHiiPages ( @@ -242,6 +317,16 @@ SetupVariables ( PcdSet32 (PcdDisplayEnableSShot, PcdGet32 (PcdDisplayEnableSShot)); } =20 + if (mModelFamily =3D=3D 4) { + // + // Get the MAC address from the firmware. + // + Status =3D mFwProtocol->GetMacAddress (MacAddress.Addr); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_WARN, "%a: failed to retrieve MAC address\n", __FUNCTI= ON__)); + } + } + return EFI_SUCCESS; } =20 @@ -448,7 +533,8 @@ ConfigInitialize ( IN EFI_SYSTEM_TABLE *SystemTable ) { - EFI_STATUS Status; + EFI_STATUS Status; + EFI_EVENT EndOfDxeEvent; =20 Status =3D gBS->LocateProtocol (&gRaspberryPiFirmwareProtocolGuid, NULL, (VOID**)&mFwProtocol); @@ -494,5 +580,9 @@ ConfigInitialize ( ASSERT_EFI_ERROR (Status); } =20 + Status =3D gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_NOTIFY, RegisterDe= vices, + NULL, &gEfiEndOfDxeEventGroupGuid, &EndOfDxeEvent); + ASSERT_EFI_ERROR (Status); + return EFI_SUCCESS; } --=20 2.17.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#59251): https://edk2.groups.io/g/devel/message/59251 Mute This Topic: https://groups.io/mt/74154334/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-