From nobody Fri May 3 17:19:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+40020+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+40020+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1557110240; cv=none; d=zoho.com; s=zohoarc; b=X8aN/878397VZnnQHbSrL+SLrqFSMl3DHqLVumfgyIONgbHxdvywcccseqkR9teM9qqPABdDtxUwjARyF/TrjE84j2UpWhGjQmnaGc5/kLj/NAVvhlxl+dcsQ4IITxSIReEPlCYPJrh2mjZne1h7nJ3VwOxsRxpT+Z6b7SSU9Bc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557110240; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=/XR3g/vsO13n2Vd0ru+sF3sT4T9VSEix6K0xxmFLRXg=; b=fIbbWgkB/hR5SPqQ4deLxsY7IqKnpZCko1+sK5dpjdoLCw5dwAImViiWInDzRxD+kjRE5CFPHKcZW6/maH+X1si4/96ViWHj1qhlp1HjlTuJ9v1zBCnqUeWTJoVKFlrX5fz6f4mBaQ9QD/C6nlQlYRN91f6O2Hv5dTm+sgldNFs= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+40020+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1557110240492766.4272131320711; Sun, 5 May 2019 19:37:20 -0700 (PDT) Return-Path: X-Received: from mail-lf1-f67.google.com (mail-lf1-f67.google.com [209.85.167.67]) by groups.io with SMTP; Sun, 05 May 2019 19:37:19 -0700 X-Received: by mail-lf1-f67.google.com with SMTP id n134so6167307lfn.11 for ; Sun, 05 May 2019 19:37:18 -0700 (PDT) X-Gm-Message-State: APjAAAXvK3ULiGkFVMV4qincK+k9wFiRqHXZdvWmgpkMS+tjdCL3uINI KcsjuKuIaryZEZOvrqhYUOEwpXh8qOs= X-Google-Smtp-Source: APXvYqyRPdEEtfA3O1Vv9WT0yxIu/hK5PK3iIUr0Lmqpd95e5xGbj4EPC49JbvA0A/3TTHhCoYFqPw== X-Received: by 2002:ac2:5934:: with SMTP id v20mr2699522lfi.4.1557110236871; Sun, 05 May 2019 19:37:16 -0700 (PDT) X-Received: from gilgamesh.semihalf.com (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id v6sm288378lfg.96.2019.05.05.19.37.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 05 May 2019 19:37:16 -0700 (PDT) From: "Marcin Wojtas" To: devel@edk2.groups.io Cc: leif.lindholm@linaro.org, ard.biesheuvel@linaro.org, mw@semihalf.com, jsd@semihalf.com, jaz@semihalf.com, kostap@marvell.com, Jici.Gao@arm.com, Tomasz Michalec Subject: [edk2-devel] [edk2-platforms: PATCH v2 1/4] Marvel/Drivers: Pp2Dxe: Basic support for Adapter Information Protocol Date: Mon, 6 May 2019 04:37:04 +0200 Message-Id: <1557110227-31466-2-git-send-email-mw@semihalf.com> In-Reply-To: <1557110227-31466-1-git-send-email-mw@semihalf.com> References: <1557110227-31466-1-git-send-email-mw@semihalf.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,mw@semihalf.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1557110239; bh=838K6Zo2MoJsbOwf5UnymFkeuhnqt8a7hnoYeIMDSu8=; h=Cc:Date:From:Reply-To:Subject:To; b=F0FbVoIJTH7zcimHiTxdVd7jTyBHzxX9P606neNvSS0d3u54pH37ycGPiAwMFLznbcV Qa2NGu+O9Y6JBuvvOHvGrWIKJ3wwYDJGY0/4L6KMnEH687xiONF278+Or2qIDzyDBgpBv gcmtD7MilfB+6ITkrFz0z/YackaWteLiuZc= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Tomasz Michalec Add implementation of Adapter Information Protocol in Armada 7k8k PP2 NIC driver. Support retrieving information about media state which allows to use NetLibDetectMediaWaitTimeout on network interface. This patch fixes possible hangs when attempting to PXE boot on unconnected interfaces. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Marcin Wojtas Reviewed-by: Leif Lindholm --- Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.inf | 1 + Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.h | 3 + Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c | 166 ++++++++++++++++++++ 3 files changed, 170 insertions(+) diff --git a/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.inf b/Silicon/Marvel= l/Drivers/Net/Pp2Dxe/Pp2Dxe.inf index be536ab..73aa413 100644 --- a/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.inf +++ b/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.inf @@ -64,6 +64,7 @@ CacheMaintenanceLib =20 [Protocols] + gEfiAdapterInformationProtocolGuid gEfiSimpleNetworkProtocolGuid gEfiDevicePathProtocolGuid gEfiCpuArchProtocolGuid diff --git a/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.h b/Silicon/Marvell/= Drivers/Net/Pp2Dxe/Pp2Dxe.h index b8a5dae..66bd46a 100644 --- a/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.h +++ b/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.h @@ -35,6 +35,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMA= GE. #ifndef __PP2_DXE_H__ #define __PP2_DXE_H__ =20 +#include #include #include #include @@ -59,6 +60,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMA= GE. #define MVPP2_MAX_PORT 3 =20 #define PP2DXE_SIGNATURE SIGNATURE_32('P', 'P', '2', 'D= ') +#define INSTANCE_FROM_AIP(a) CR((a), PP2DXE_CONTEXT, Aip, P= P2DXE_SIGNATURE) #define INSTANCE_FROM_SNP(a) CR((a), PP2DXE_CONTEXT, Snp, P= P2DXE_SIGNATURE) =20 /* OS API */ @@ -365,6 +367,7 @@ typedef struct { UINTN CompletionQueueTail; EFI_EVENT EfiExitBootServicesEvent; PP2_DEVICE_PATH *DevicePath; + EFI_ADAPTER_INFORMATION_PROTOCOL Aip; } PP2DXE_CONTEXT; =20 /* Inline helpers */ diff --git a/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c b/Silicon/Marvell/= Drivers/Net/Pp2Dxe/Pp2Dxe.c index 02b2798..8983646 100644 --- a/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c +++ b/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c @@ -1129,6 +1129,7 @@ Pp2DxeSnpInstall ( &Handle, &gEfiSimpleNetworkProtocolGuid, &Pp2Context->Snp, &gEfiDevicePathProtocolGuid, Pp2DevicePath, + &gEfiAdapterInformationProtocolGuid, &Pp2Context->Aip, NULL ); =20 @@ -1139,6 +1140,166 @@ Pp2DxeSnpInstall ( return Status; } =20 +/** + Returns the current state information for the adapter. + + This function returns information of type InformationType from the adapt= er. + If an adapter does not support the requested informational type, then + EFI_UNSUPPORTED is returned. + + @param[in] This A pointer to the EFI_ADAPTER_INFORMAT= ION_PROTOCOL instance. + @param[in] InformationType A pointer to an EFI_GUID that defines= the contents of InformationBlock. + @param[out] InformationBlock The service returns a pointer to the = buffer with the InformationBlock + structure which contains details abou= t the data specific to InformationType. + @param[out] InformationBlockSize The driver returns the size of the In= formationBlock in bytes. + + @retval EFI_SUCCESS The InformationType information was r= etrieved. + @retval EFI_UNSUPPORTED The InformationType is not known. + @retval EFI_DEVICE_ERROR The device reported an error. + @retval EFI_OUT_OF_RESOURCES The request could not be completed du= e to a lack of resources. + @retval EFI_INVALID_PARAMETER This is NULL. + @retval EFI_INVALID_PARAMETER InformationBlock is NULL. + @retval EFI_INVALID_PARAMETER InformationBlockSize is NULL. + +**/ +STATIC +EFI_STATUS +EFIAPI +Pp2AipGetInformation ( + IN EFI_ADAPTER_INFORMATION_PROTOCOL *This, + IN EFI_GUID *InformationType, + OUT VOID **InformationBlock, + OUT UINTN *InformationBlockSize + ) +{ + EFI_ADAPTER_INFO_MEDIA_STATE *AdapterInfo; + PP2DXE_CONTEXT *Pp2Context; + EFI_STATUS Status; + + if (This =3D=3D NULL || InformationBlock =3D=3D NULL || InformationBlock= Size =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + if (!CompareGuid (InformationType, &gEfiAdapterInfoMediaStateGuid)) { + return EFI_UNSUPPORTED; + } + + AdapterInfo =3D AllocateZeroPool (sizeof (EFI_ADAPTER_INFO_MEDIA_STATE)); + if (AdapterInfo =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + *InformationBlock =3D AdapterInfo; + *InformationBlockSize =3D sizeof (EFI_ADAPTER_INFO_MEDIA_STATE); + + Pp2Context =3D INSTANCE_FROM_AIP (This); + + Status =3D Pp2Context->Snp.GetStatus (&(Pp2Context->Snp), NULL, NULL); + if (Status =3D=3D EFI_NOT_READY){ + AdapterInfo->MediaState =3D EFI_NOT_READY; + return EFI_SUCCESS; + } else if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a Failed to get media status\n", __FUNCTION__)); + return EFI_DEVICE_ERROR; + } + + if (Pp2Context->Snp.Mode->MediaPresent) { + AdapterInfo->MediaState =3D EFI_SUCCESS; + } else { + AdapterInfo->MediaState =3D EFI_NOT_READY; + } + + return EFI_SUCCESS; +} + +/** + Sets state information for an adapter. + + This function sends information of type InformationType for an adapter. + If an adapter does not support the requested information type, then EFI_= UNSUPPORTED + is returned. + + @param[in] This A pointer to the EFI_ADAPTER_INFORMAT= ION_PROTOCOL instance. + @param[in] InformationType A pointer to an EFI_GUID that defines= the contents of InformationBlock. + @param[in] InformationBlock A pointer to the InformationBlock str= ucture which contains details + about the data specific to Informatio= nType. + @param[in] InformationBlockSize The size of the InformationBlock in b= ytes. + + @retval EFI_SUCCESS The information was received and inte= rpreted successfully. + @retval EFI_UNSUPPORTED The InformationType is not known. + @retval EFI_DEVICE_ERROR The device reported an error. + @retval EFI_INVALID_PARAMETER This is NULL. + @retval EFI_INVALID_PARAMETER InformationBlock is NULL. + @retval EFI_WRITE_PROTECTED The InformationType cannot be modifie= d using EFI_ADAPTER_INFO_SET_INFO(). + +**/ +STATIC +EFI_STATUS +EFIAPI +Pp2AipSetInformation ( + IN EFI_ADAPTER_INFORMATION_PROTOCOL *This, + IN EFI_GUID *InformationType, + IN VOID *InformationBlock, + IN UINTN InformationBlockSize + ) +{ + if (This =3D=3D NULL || InformationBlock =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + if (CompareGuid (InformationType, &gEfiAdapterInfoMediaStateGuid)) { + return EFI_WRITE_PROTECTED; + } + + return EFI_UNSUPPORTED; +} + +/** + Get a list of supported information types for this instance of the proto= col. + + This function returns a list of InformationType GUIDs that are supported= on an + adapter with this instance of EFI_ADAPTER_INFORMATION_PROTOCOL. The list= is returned + in InfoTypesBuffer, and the number of GUID pointers in InfoTypesBuffer i= s returned in + InfoTypesBufferCount. + + @param[in] This A pointer to the EFI_ADAPTER_INFORMATI= ON_PROTOCOL instance. + @param[out] InfoTypesBuffer A pointer to the array of InformationT= ype GUIDs that are supported + by This. + @param[out] InfoTypesBufferCount A pointer to the number of GUIDs prese= nt in InfoTypesBuffer. + + @retval EFI_SUCCESS The list of information type GUIDs tha= t are supported on this adapter was + returned in InfoTypesBuffer. The numbe= r of information type GUIDs was + returned in InfoTypesBufferCount. + @retval EFI_INVALID_PARAMETER This is NULL. + @retval EFI_INVALID_PARAMETER InfoTypesBuffer is NULL. + @retval EFI_INVALID_PARAMETER InfoTypesBufferCount is NULL. + @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to sto= re the results. + +**/ +STATIC +EFI_STATUS +EFIAPI +Pp2AipGetSupportedTypes ( + IN EFI_ADAPTER_INFORMATION_PROTOCOL *This, + OUT EFI_GUID **InfoTypesBuffer, + OUT UINTN *InfoTypesBufferCount + ) +{ + if (This =3D=3D NULL || InfoTypesBuffer =3D=3D NULL || InfoTypesBufferCo= unt =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + *InfoTypesBuffer =3D AllocatePool (sizeof (EFI_GUID)); + if (*InfoTypesBuffer =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + *InfoTypesBufferCount =3D 1; + CopyGuid (*InfoTypesBuffer, &gEfiAdapterInfoMediaStateGuid); + + return EFI_SUCCESS; +} + STATIC VOID Pp2DxeParsePortPcd ( @@ -1290,6 +1451,11 @@ Pp2DxeInitialiseController ( Pp2Context->Instance =3D DeviceInstance; DeviceInstance++; =20 + /* Prepare AIP Protocol */ + Pp2Context->Aip.GetInformation =3D Pp2AipGetInformation; + Pp2Context->Aip.SetInformation =3D Pp2AipSetInformation; + Pp2Context->Aip.GetSupportedTypes =3D Pp2AipGetSupportedTypes; + /* Install SNP protocol */ Status =3D Pp2DxeSnpInstall(Pp2Context); if (EFI_ERROR(Status)) { --=20 2.7.4 -=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 (#40020): https://edk2.groups.io/g/devel/message/40020 Mute This Topic: https://groups.io/mt/31515977/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- From nobody Fri May 3 17:19:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+40021+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+40021+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1557110241; cv=none; d=zoho.com; s=zohoarc; b=QXGnZCGTBmCAhZ3AXQ6EZx347Juqj8EHJp+HhKZ1g2NMJASd4Z+U+QnSKcIwKTXm9zHgdC14dF5ScVmhwuo6S4IwpnMqwSFs4Djs6S3jrQyh7GqR4sOXWiFYRyGXfIXm+9yyK94XaP8MOP39gIHvyugkMUnv5C+gLv9dxm254yU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557110241; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=Za9/w09N4H4pI6/Ay57Vnd0fGy1ydtxa6uJ3xZ08shs=; b=OXz153uJZkW/BE2zhuNWAR6KAKNefn7Ap6YCVFEvkW/3CdSePiQ3nNrw2GkSs5RcpH4ftkc6b7F+CiPbwqpUbgPQj18mZ9wUMidFNMRhyihQDSXZ0BSU2Z4fMYLK7piHFw7vewElsyfiEdgcqOXY3x5EMb/o6JOgy0aJ01UCMBg= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+40021+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1557110241810130.92065984759142; Sun, 5 May 2019 19:37:21 -0700 (PDT) Return-Path: X-Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) by groups.io with SMTP; Sun, 05 May 2019 19:37:20 -0700 X-Received: by mail-lj1-f193.google.com with SMTP id z5so4602159lji.10 for ; Sun, 05 May 2019 19:37:20 -0700 (PDT) X-Gm-Message-State: APjAAAVW5JcvIyGIv9iUuIfq8XMtTFJSycGsx95H15398XMhnq9/tLAW RW4cc5eFQw2r/G40Xu0YIF9xaSsc798= X-Google-Smtp-Source: APXvYqytfaw/JX2xrivE2CVpQ2w/GQYbZck4YAN0Kvv7Nx+zvz78qKDcAP12m72jWkaRmR2RxkniZA== X-Received: by 2002:a2e:85d2:: with SMTP id h18mr11784407ljj.128.1557110238366; Sun, 05 May 2019 19:37:18 -0700 (PDT) X-Received: from gilgamesh.semihalf.com (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id v6sm288378lfg.96.2019.05.05.19.37.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 05 May 2019 19:37:17 -0700 (PDT) From: "Marcin Wojtas" To: devel@edk2.groups.io Cc: leif.lindholm@linaro.org, ard.biesheuvel@linaro.org, mw@semihalf.com, jsd@semihalf.com, jaz@semihalf.com, kostap@marvell.com, Jici.Gao@arm.com Subject: [edk2-devel] [edk2-platforms: PATCH v2 2/4] Marvell/Drivers: MvPhyDxe: Refactor 88E1510 initialization Date: Mon, 6 May 2019 04:37:05 +0200 Message-Id: <1557110227-31466-3-git-send-email-mw@semihalf.com> In-Reply-To: <1557110227-31466-1-git-send-email-mw@semihalf.com> References: <1557110227-31466-1-git-send-email-mw@semihalf.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,mw@semihalf.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1557110241; bh=2Hlszv/12Wy3Ak8B403gf0OMGiZhUOhkqcUzXxdGNk4=; h=Cc:Date:From:Reply-To:Subject:To; b=VdN6MUkPdlYXjFY3ig8i1wBeH5b0bm99ylkBQ1fSzzy3HFvcBnvPismOkkuQvrPF30J d/1e4cm30RnJ6Tkb1Ft+4K7utmvuMLDSOnuLByiZjNa/xuFrS8/ayaO/8yKqe9Xw9Rq1+ +suwr4rXeI6eW3fByLs9bkcptVLltkWGYC4= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch adds only a non-functional change, extracting common startup autonegotiation configuration into a separate routine. It will be re-used in 88E1112 PHY support addition in a following patch. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Marcin Wojtas Reviewed-by: Leif Lindholm --- Silicon/Marvell/Drivers/Net/MvPhyDxe/MvPhyDxe.c | 86 +++++++++++++------- 1 file changed, 57 insertions(+), 29 deletions(-) diff --git a/Silicon/Marvell/Drivers/Net/MvPhyDxe/MvPhyDxe.c b/Silicon/Marv= ell/Drivers/Net/MvPhyDxe/MvPhyDxe.c index 9be0489..63af640 100644 --- a/Silicon/Marvell/Drivers/Net/MvPhyDxe/MvPhyDxe.c +++ b/Silicon/Marvell/Drivers/Net/MvPhyDxe/MvPhyDxe.c @@ -251,6 +251,58 @@ MvPhyParseStatus ( return EFI_SUCCESS; } =20 +/** + Configure PHY device autonegotiation. + + @param[in out] *PhyDevice A pointer to configured PHY device stru= cture. + +**/ +STATIC +EFI_STATUS +MvPhyConfigureAutonegotiation ( + IN OUT PHY_DEVICE *PhyDevice + ) +{ + UINT32 Data; + INTN Index; + + /* Read BMSR register in order to check autoneg capabilities and status.= */ + Mdio->Read (Mdio, PhyDevice->Addr, PhyDevice->MdioIndex, MII_BMSR, &Data= ); + + if ((Data & BMSR_ANEGCAPABLE) && !(Data & BMSR_ANEGCOMPLETE)) { + + DEBUG ((DEBUG_INFO, + "%a: Waiting for PHY auto negotiation...", + __FUNCTION__)); + + /* Wait for autonegotiation to complete and read media status */ + for (Index =3D 0; !(Data & BMSR_ANEGCOMPLETE); Index++) { + if (Index > PHY_AUTONEGOTIATE_TIMEOUT) { + DEBUG ((DEBUG_ERROR, "%a: Timeout\n", __FUNCTION__)); + PhyDevice->LinkUp =3D FALSE; + return EFI_TIMEOUT; + } + gBS->Stall (1000); /* 1 ms */ + Mdio->Read (Mdio, PhyDevice->Addr, PhyDevice->MdioIndex, MII_BMSR, &= Data); + } + + PhyDevice->LinkUp =3D TRUE; + DEBUG ((DEBUG_INFO, "%a: link up\n", __FUNCTION__)); + } else { + Mdio->Read (Mdio, PhyDevice->Addr, PhyDevice->MdioIndex, MII_BMSR, &Da= ta); + + if (Data & BMSR_LSTATUS) { + PhyDevice->LinkUp =3D TRUE; + DEBUG ((DEBUG_INFO, "%a: link up\n", __FUNCTION__)); + } else { + PhyDevice->LinkUp =3D FALSE; + DEBUG ((DEBUG_INFO, "%a: link down\n", __FUNCTION__)); + } + } + + return EFI_SUCCESS; +} + STATIC VOID MvPhy1512WriteBits ( @@ -282,8 +334,7 @@ MvPhyInit1512 ( IN OUT PHY_DEVICE *PhyDev ) { - UINT32 Data; - INTN i; + EFI_STATUS Status; =20 if (PhyDev->Connection =3D=3D PHY_CONNECTION_SGMII) { /* Select page 0xff and update configuration registers according to @@ -321,34 +372,11 @@ MvPhyInit1512 ( if (!PcdGetBool (PcdPhyStartupAutoneg)) return EFI_SUCCESS; =20 - Mdio->Read (Mdio, PhyDev->Addr, PhyDev->MdioIndex, MII_BMSR, &Data); - - if ((Data & BMSR_ANEGCAPABLE) && !(Data & BMSR_ANEGCOMPLETE)) { - - DEBUG((DEBUG_ERROR, "MvPhyDxe: Waiting for PHY auto negotiation... ")); - for (i =3D 0; !(Data & BMSR_ANEGCOMPLETE); i++) { - if (i > PHY_AUTONEGOTIATE_TIMEOUT) { - DEBUG((DEBUG_ERROR, "timeout\n")); - PhyDev->LinkUp =3D FALSE; - return EFI_TIMEOUT; - } - - gBS->Stall(1000); /* 1 ms */ - Mdio->Read (Mdio, PhyDev->Addr, PhyDev->MdioIndex, MII_BMSR, &Data); - } - PhyDev->LinkUp =3D TRUE; - DEBUG((DEBUG_INFO, "MvPhyDxe: link up\n")); - } else { - Mdio->Read (Mdio, PhyDev->Addr, PhyDev->MdioIndex, MII_BMSR, &Data); - - if (Data & BMSR_LSTATUS) { - PhyDev->LinkUp =3D TRUE; - DEBUG((DEBUG_INFO, "MvPhyDxe: link up\n")); - } else { - PhyDev->LinkUp =3D FALSE; - DEBUG((DEBUG_INFO, "MvPhyDxe: link down\n")); - } + Status =3D MvPhyConfigureAutonegotiation (PhyDev); + if (EFI_ERROR (Status)) { + return Status; } + MvPhyParseStatus (PhyDev); =20 return EFI_SUCCESS; --=20 2.7.4 -=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 (#40021): https://edk2.groups.io/g/devel/message/40021 Mute This Topic: https://groups.io/mt/31515978/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- From nobody Fri May 3 17:19:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+40022+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+40022+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1557110243; cv=none; d=zoho.com; s=zohoarc; b=kqnBd4dVL4rO+wooJPB+2j8bEXVtEEvHarRPyZsdaBS/VtqxoFXUf/EG9WPxz2dmKVsA5JfYKxhcgLx4x79G9E84EaKUgd9UkRAbuy2arWSdHfZrJViwg9ao1TAAsHCKa17nJFBG+Fsxj1Nt88a7k4eNmy/1ahF4eXNHUOYcpEo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557110243; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=IZllRoZ+P6oJhYkZHKmYRnu5kV/nFDbLtxpR2GKPkLg=; b=eCVthN3J3HfJtDRKUBkCuQC2rIrwDfCxUI3TvNEkIGXyGRPvJMM6OKiffBlvHd1XYEE4LxwpqQDW2PXUYBjH+sQ7iAhVNSNGByz4TYM92ua9zEAb1EdbbD17lawuG8PKKfsH78NJR2LlqoDVFJsHDQDVlw6ab6CvHuq2CKkXWKU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+40022+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1557110243016423.4192822046982; Sun, 5 May 2019 19:37:23 -0700 (PDT) Return-Path: X-Received: from mail-lf1-f66.google.com (mail-lf1-f66.google.com [209.85.167.66]) by groups.io with SMTP; Sun, 05 May 2019 19:37:21 -0700 X-Received: by mail-lf1-f66.google.com with SMTP id z124so1854282lfd.6 for ; Sun, 05 May 2019 19:37:21 -0700 (PDT) X-Gm-Message-State: APjAAAXUi+1Pd6OCkPzSGQ0FBZcKAopES7tJQ0EGCloiyIMfS8zvLcdk JrvqCHf7cb06scNq8urIw61H5xyNtiA= X-Google-Smtp-Source: APXvYqy4FFNyCw8ZOZxlwmkSUq7P3PHktCQM20cAd5uPuK+qaw7KaHGqvWz9qXbBku6lGS3Fy0yfEw== X-Received: by 2002:a19:520e:: with SMTP id m14mr11966031lfb.65.1557110239535; Sun, 05 May 2019 19:37:19 -0700 (PDT) X-Received: from gilgamesh.semihalf.com (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id v6sm288378lfg.96.2019.05.05.19.37.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 05 May 2019 19:37:18 -0700 (PDT) From: "Marcin Wojtas" To: devel@edk2.groups.io Cc: leif.lindholm@linaro.org, ard.biesheuvel@linaro.org, mw@semihalf.com, jsd@semihalf.com, jaz@semihalf.com, kostap@marvell.com, Jici.Gao@arm.com Subject: [edk2-devel] [edk2-platforms: PATCH v2 3/4] Marvell/Drivers: MvPhyDxe: Introduce 88E1112 initialization Date: Mon, 6 May 2019 04:37:06 +0200 Message-Id: <1557110227-31466-4-git-send-email-mw@semihalf.com> In-Reply-To: <1557110227-31466-1-git-send-email-mw@semihalf.com> References: <1557110227-31466-1-git-send-email-mw@semihalf.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,mw@semihalf.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1557110242; bh=3hcjLgKP3cX3IKJzVz83eF2Fp6WMgK/hFpZDpEgeohk=; h=Cc:Date:From:Reply-To:Subject:To; b=KKo6jhaoTy3kH32njC8TcqAHLWA9vedV8qpniujS0pDYsTzLInvHo+T03bU5ucbHQeh 3TEEYXr4L6lL08MsHIBVxKL3j4qtQbvDDhHHjqRE0nMam0aFWhFDsEsm+5Cxngu5TI6Dm KIu7wwUvzzBRwrjWFvGkO7xtnHu5F8ZEIuI= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch adds 88E1112 PHY support and updates PortingGuide accordingly. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Marcin Wojtas Reviewed-by: Leif Lindholm --- Silicon/Marvell/Drivers/Net/MvPhyDxe/MvPhyDxe.h | 17 ++++++++++- Silicon/Marvell/Drivers/Net/MvPhyDxe/MvPhyDxe.c | 31 ++++++++++++++++++++ Silicon/Marvell/Documentation/PortingGuide.txt | 7 +++-- 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/Silicon/Marvell/Drivers/Net/MvPhyDxe/MvPhyDxe.h b/Silicon/Marv= ell/Drivers/Net/MvPhyDxe/MvPhyDxe.h index 66974bb..cd5a475 100644 --- a/Silicon/Marvell/Drivers/Net/MvPhyDxe/MvPhyDxe.h +++ b/Silicon/Marvell/Drivers/Net/MvPhyDxe/MvPhyDxe.h @@ -75,7 +75,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMA= GE. #define MIIM_88E1111_HWCFG_FIBER_COPPER_RES 0x2000 =20 typedef enum { - MV_PHY_DEVICE_1512 + MV_PHY_DEVICE_1512, + MV_PHY_DEVICE_1112 } MV_PHY_DEVICE_ID; =20 typedef @@ -97,4 +98,18 @@ MvPhyInit1512 ( IN OUT PHY_DEVICE *PhyDev ); =20 +/** + Initialize Marvell 88E1112 PHY. + + @param[in] MvPhyProtocol Marvell PHY protocol instance. + @param[in out] *PhyDevice PHY device structure. + +**/ +STATIC +EFI_STATUS +MvPhyInit1112 ( + IN CONST MARVELL_PHY_PROTOCOL *MvPhyProtocol, + IN OUT PHY_DEVICE *PhyDevice + ); + #endif diff --git a/Silicon/Marvell/Drivers/Net/MvPhyDxe/MvPhyDxe.c b/Silicon/Marv= ell/Drivers/Net/MvPhyDxe/MvPhyDxe.c index 63af640..81f9c0f 100644 --- a/Silicon/Marvell/Drivers/Net/MvPhyDxe/MvPhyDxe.c +++ b/Silicon/Marvell/Drivers/Net/MvPhyDxe/MvPhyDxe.c @@ -66,6 +66,7 @@ STATIC UINT8 * CONST PhySmiAddresses =3D PcdGetPtr (PcdPh= ySmiAddresses); =20 STATIC MV_PHY_DEVICE MvPhyDevices[] =3D { { MV_PHY_DEVICE_1512, MvPhyInit1512 }, + { MV_PHY_DEVICE_1112, MvPhyInit1112 }, { 0, NULL } }; =20 @@ -382,6 +383,36 @@ MvPhyInit1512 ( return EFI_SUCCESS; } =20 +/** + Initialize Marvell 88E1112 PHY. + + @param[in] MvPhyProtocol Marvell PHY protocol instance. + @param[in out] *PhyDevice PHY device structure. + +**/ +STATIC +EFI_STATUS +MvPhyInit1112 ( + IN CONST MARVELL_PHY_PROTOCOL *MvPhyProtocol, + IN OUT PHY_DEVICE *PhyDevice + ) +{ + EFI_STATUS Status; + + MvPhyM88e1111sConfig (PhyDevice); + + if (PcdGetBool (PcdPhyStartupAutoneg)) { + Status =3D MvPhyConfigureAutonegotiation (PhyDevice); + if (EFI_ERROR (Status)) { + return Status; + } + + MvPhyParseStatus (PhyDevice); + } + + return EFI_SUCCESS; +} + EFI_STATUS MvPhyInit ( IN CONST MARVELL_PHY_PROTOCOL *Snp, diff --git a/Silicon/Marvell/Documentation/PortingGuide.txt b/Silicon/Marve= ll/Documentation/PortingGuide.txt index 2603980..9dee5c8 100644 --- a/Silicon/Marvell/Documentation/PortingGuide.txt +++ b/Silicon/Marvell/Documentation/PortingGuide.txt @@ -146,7 +146,7 @@ Example PHY Driver configuration =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D MvPhyDxe provides basic initialization and status routines for Marvell PHY= s. -Currently only 1518 series PHYs are supported. Following PCDs are required: +Currently only 1512 and 1112 series PHYs are supported. Following PCDs are= required: =20 - gMarvellTokenSpaceGuid.PcdPhyStartupAutoneg (boolean - if true, driver waits for autonegotiation on startup) @@ -162,6 +162,7 @@ MV_PHY_DEVICE_ID: =20 typedef enum { 0 MV_PHY_DEVICE_1512, + 1 MV_PHY_DEVICE_1112, } MV_PHY_DEVICE_ID; =20 It should be extended when adding support for other PHY models. @@ -170,9 +171,9 @@ Disable autonegotiation: =20 gMarvellTokenSpaceGuid.PcdPhyStartupAutoneg|FALSE =20 -assuming, that PHY models are 1512: +assuming, that PHY models are 1512 and 1112 for two consecutive ports: =20 - gMarvellTokenSpaceGuid.PcdPhyDeviceIds|{ 0x0, 0x0 } + gMarvellTokenSpaceGuid.PcdPhyDeviceIds|{ 0x0, 0x1 } =20 =20 MDIO configuration --=20 2.7.4 -=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 (#40022): https://edk2.groups.io/g/devel/message/40022 Mute This Topic: https://groups.io/mt/31515979/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- From nobody Fri May 3 17:19:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+40023+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+40023+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1557110243; cv=none; d=zoho.com; s=zohoarc; b=TzNSm56eJgouIUB33497G9mUP9SIuBIQOMXvIusRuPUOr1fOu18vlD7ZxSGIc9kG8PEzt/udaWvGbyvb/H/znEubbKKx+1fH0WphbJddgwNCDFXCS6YkLQ5nzPUgVMPnbriQKAae6OAtnx9b+gJLVKDpME2YXgMhKiLAIl/QL/Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557110243; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=h+0zVz5r70kfuEc4Mle87vp3pwnM9xguRGsOD3CPEd4=; b=Til9TdIaZIOqc17LoEzO8A2e8UV1YcI3noGRHUYrwKXQpZ3BcVx8DiZVL3W6JAuiN3gefOn5Za2nTuNrkQasNnVppS3OO8MetZSVm6MrMqNcGJarPtBa6k7AdmYYmf38WbubrImTBLz85oM85qO0YEIBB7QbbW7k7TkWY1SbTGs= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+40023+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1557110243933314.8708650618014; Sun, 5 May 2019 19:37:23 -0700 (PDT) Return-Path: X-Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) by groups.io with SMTP; Sun, 05 May 2019 19:37:23 -0700 X-Received: by mail-lj1-f195.google.com with SMTP id 132so1980083ljj.4 for ; Sun, 05 May 2019 19:37:22 -0700 (PDT) X-Gm-Message-State: APjAAAVFQm+Q5SSmWOPPDdbMByN13iXY8cGtHjF++ORe/ofMOdmPFc2h XbxJ+UNzLqEirkwNTr3w7BFIdn9L6ng= X-Google-Smtp-Source: APXvYqwd5qUJpFlSiiPWvHcxLr4tLMwHqsm1QOaNs8N/XjddoEaW9PYpxL+0DJtODfqZPDpQOwQT7Q== X-Received: by 2002:a2e:9713:: with SMTP id r19mr12437613lji.189.1557110240733; Sun, 05 May 2019 19:37:20 -0700 (PDT) X-Received: from gilgamesh.semihalf.com (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id v6sm288378lfg.96.2019.05.05.19.37.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 05 May 2019 19:37:20 -0700 (PDT) From: "Marcin Wojtas" To: devel@edk2.groups.io Cc: leif.lindholm@linaro.org, ard.biesheuvel@linaro.org, mw@semihalf.com, jsd@semihalf.com, jaz@semihalf.com, kostap@marvell.com, Jici.Gao@arm.com Subject: [edk2-devel] [edk2-platforms: PATCH v2 4/4] Marvell/Drivers: MvPhyDxe: Reset PHY only once Date: Mon, 6 May 2019 04:37:07 +0200 Message-Id: <1557110227-31466-5-git-send-email-mw@semihalf.com> In-Reply-To: <1557110227-31466-1-git-send-email-mw@semihalf.com> References: <1557110227-31466-1-git-send-email-mw@semihalf.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,mw@semihalf.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1557110243; bh=TtGtYyZ271O7T2U/wf3r7OwsgGq/B9Df8pOMpR75SV8=; h=Cc:Date:From:Reply-To:Subject:To; b=e8DldTCpcn2KRFjU5ysGan8tWAXBZJYg0MVYTMfsqnvl9IWFcG3QTAyMctfmPsRIzNB qBfUKc8LVi8Zl6UEU8pd2aHZFV7HejHtMgOu7DxHrGbVbypxUK4Vs1NLwJiUMRsjtne7Y aVP1EORCJMy20Qb4PMk43k27adeyq2udxDs= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" At the end of PHY low level configuration a soft reset was performed twice. It is not necessary, so remove redundant reset call. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Marcin Wojtas Reviewed-by: Leif Lindholm --- Silicon/Marvell/Drivers/Net/MvPhyDxe/MvPhyDxe.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/Silicon/Marvell/Drivers/Net/MvPhyDxe/MvPhyDxe.c b/Silicon/Marv= ell/Drivers/Net/MvPhyDxe/MvPhyDxe.c index 81f9c0f..4376172 100644 --- a/Silicon/Marvell/Drivers/Net/MvPhyDxe/MvPhyDxe.c +++ b/Silicon/Marvell/Drivers/Net/MvPhyDxe/MvPhyDxe.c @@ -180,8 +180,6 @@ MvPhyM88e1111sConfig ( /* Soft reset */ MvPhyReset (PhyDev); =20 - MvPhyReset (PhyDev); - return EFI_SUCCESS; } =20 --=20 2.7.4 -=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 (#40023): https://edk2.groups.io/g/devel/message/40023 Mute This Topic: https://groups.io/mt/31515980/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-