From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c09::242; helo=mail-wm0-x242.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E7986210E3DE1 for ; Mon, 18 Jun 2018 08:55:40 -0700 (PDT) Received: by mail-wm0-x242.google.com with SMTP id e16-v6so14961317wmd.0 for ; Mon, 18 Jun 2018 08:55:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=RV0T5wxznMVZSlfcAh5zBv9xCNTyn3YR1EfuSLh2qIE=; b=kzsM4e0t0vRtUr/I3yTIPwwtWRy5/BHUkOvy+MpBzQsg7r7UwSE4Q2VleVI9MeD5aO WlOeMtMYQtTdpZhGwQiWv8sAKkuupZcSWoGxaBmNDFEzB3haC6Ff2K47bSkfSd/afOyI quw8mwiu0lcbogeMYzAOxg17yKA9ch9n85QEU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=RV0T5wxznMVZSlfcAh5zBv9xCNTyn3YR1EfuSLh2qIE=; b=qXe4ZlnUZL6uGkbpea7lVq2yNfxgUqb8yprzaajFxkwJd0QO99/pkfJ7hywzH2oDnO jsBSysQ8pRDb/Ago1/tXQrRLrAL0V7tQfoMlcm4TmV9pN1JtcYzt/pKpvO8XXEMSTBvr IDwBx36I7hdjwvMks99SkVdGW7r1cDnqTYo+LkRdlopGMbzVvr98uFnIgF86MEN4S24S 6qACXl05JX8P15nHT/jZTVQyGxF8NaMO3FJujuOEWmg07g65bKlhVMEtAuCBYBWag+3l vnAB8/CfnfCZu7TmubLJx/JlmTNuDbu58PgF+Ocwv1rt6nFlkC3FFyDOZs1mzLIecP+W reDQ== X-Gm-Message-State: APt69E3gTkygdSfF+dxb/MX3NrFHd1q2zNqyLK4min/V6gaksqcvXIfR PECBFABLPbeUTvTHF/h4GJqmcg== X-Google-Smtp-Source: ADUXVKIxPyoMIAXu9LjXCO/Ifa4o+ckY+Gc3r3SETVxnjRDcd1FMdtOmfCar5KtBBDymvMZCIQKgRQ== X-Received: by 2002:a1c:7d56:: with SMTP id y83-v6mr9991933wmc.65.1529337339180; Mon, 18 Jun 2018 08:55:39 -0700 (PDT) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id t11-v6sm12638569wrp.94.2018.06.18.08.55.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 08:55:37 -0700 (PDT) Date: Mon, 18 Jun 2018 16:55:36 +0100 From: Leif Lindholm To: Marcin Wojtas Cc: edk2-devel@lists.01.org, ard.biesheuvel@linaro.org, nadavh@marvell.com, jinghua@marvell.com, jsd@semihalf.com, jaz@semihalf.com Message-ID: <20180618155536.talyfrmpeq6nt2dl@bivouac.eciton.net> References: <1529266325-18371-1-git-send-email-mw@semihalf.com> <1529266325-18371-11-git-send-email-mw@semihalf.com> MIME-Version: 1.0 In-Reply-To: <1529266325-18371-11-git-send-email-mw@semihalf.com> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [platforms: PATCH v2 10/25] Marvell/Drivers: Pp2Dxe: Switch to use MARVELL_BOARD_DESC protocol X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jun 2018 15:55:41 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sun, Jun 17, 2018 at 10:11:50PM +0200, Marcin Wojtas wrote: > Pp2Dxe driver used to get Armada7k8k PP2 controller description from > hardcoded values stored in the header file MvHwDescLib.h. > As a result it is very hard to support other Armada SoC families > with this driver. > > This patch updates the driver to get PP2 controller description from > newly introduced MARVELL_BOARD_DESC protocol, and removes the dependency > on the hardcoded structures. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Marcin Wojtas Reviewed-by: Leif Lindholm > --- > Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.inf | 2 +- > Silicon/Marvell/Include/Library/MvHwDescLib.h | 26 ------------ > Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c | 43 ++++++++------------ > 3 files changed, 19 insertions(+), 52 deletions(-) > > diff --git a/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.inf b/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.inf > index fcd0611..be536ab 100644 > --- a/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.inf > +++ b/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.inf > @@ -67,11 +67,11 @@ > gEfiSimpleNetworkProtocolGuid > gEfiDevicePathProtocolGuid > gEfiCpuArchProtocolGuid > + gMarvellBoardDescProtocolGuid > gMarvellMdioProtocolGuid > gMarvellPhyProtocolGuid > > [Pcd] > - gMarvellTokenSpaceGuid.PcdPp2Controllers > gMarvellTokenSpaceGuid.PcdPp2GopIndexes > gMarvellTokenSpaceGuid.PcdPp2InterfaceAlwaysUp > gMarvellTokenSpaceGuid.PcdPp2InterfaceSpeed > diff --git a/Silicon/Marvell/Include/Library/MvHwDescLib.h b/Silicon/Marvell/Include/Library/MvHwDescLib.h > index 34d03d4..5fd514c 100644 > --- a/Silicon/Marvell/Include/Library/MvHwDescLib.h > +++ b/Silicon/Marvell/Include/Library/MvHwDescLib.h > @@ -105,17 +105,6 @@ typedef struct { > } MVHW_NONDISCOVERABLE_DESC; > > // > -// PP2 NIC devices description template definition > -// > -#define MVHW_MAX_PP2_DEVS 4 > - > -typedef struct { > - UINT8 Pp2DevCount; > - UINTN Pp2BaseAddresses[MVHW_MAX_PP2_DEVS]; > - UINTN Pp2ClockFrequency[MVHW_MAX_PP2_DEVS]; > -} MVHW_PP2_DESC; > - > -// > // Platform description of CommonPhy devices > // > #define MVHW_CP0_COMPHY_BASE 0xF2441000 > @@ -200,19 +189,4 @@ MVHW_NONDISCOVERABLE_DESC mA7k8kNonDiscoverableDescTemplate = {\ > { NonDiscoverableDeviceDmaTypeCoherent, NonDiscoverableDeviceDmaTypeCoherent }\ > } > > -// > -// Platform description of Pp2 NIC devices > -// > -#define MVHW_CP0_PP2_BASE 0xF2000000 > -#define MVHW_CP1_PP2_BASE 0xF4000000 > -#define MVHW_PP2_CLK_FREQ 333333333 > - > -#define DECLARE_A7K8K_PP2_TEMPLATE \ > -STATIC \ > -MVHW_PP2_DESC mA7k8kPp2DescTemplate = {\ > - 2,\ > - { MVHW_CP0_PP2_BASE, MVHW_CP1_PP2_BASE },\ > - { MVHW_PP2_CLK_FREQ, MVHW_PP2_CLK_FREQ } \ > -} > - > #endif /* __MVHWDESCLIB_H__ */ > diff --git a/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c b/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c > index 3ed10f6..02b2798 100644 > --- a/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c > +++ b/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c > @@ -32,6 +32,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > > *******************************************************************************/ > > +#include > #include > #include > #include > @@ -42,7 +43,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > #include > #include > #include > -#include > #include > #include > #include > @@ -54,8 +54,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > > #define ReturnUnlock(tpl, status) do { gBS->RestoreTPL (tpl); return (status); } while(0) > > -DECLARE_A7K8K_PP2_TEMPLATE; > - > STATIC PP2_DEVICE_PATH Pp2DevicePathTemplate = { > { > { > @@ -1343,35 +1341,28 @@ Pp2DxeInitialise ( > IN EFI_SYSTEM_TABLE *SystemTable > ) > { > - MVHW_PP2_DESC *Desc = &mA7k8kPp2DescTemplate; > - UINT8 *Pp2DeviceTable, Index; > + MARVELL_BOARD_DESC_PROTOCOL *BoardDescProtocol; > + MV_BOARD_PP2_DESC *Pp2BoardDesc; > MVPP2_SHARED *Mvpp2Shared; > EFI_STATUS Status; > + UINTN Index; > > /* Obtain table with enabled Pp2 devices */ > - Pp2DeviceTable = (UINT8 *)PcdGetPtr (PcdPp2Controllers); > - if (Pp2DeviceTable == NULL) { > - DEBUG ((DEBUG_ERROR, "Missing PcdPp2Controllers\n")); > - return EFI_INVALID_PARAMETER; > - } > - > - if (PcdGetSize (PcdPp2Controllers) > MVHW_MAX_PP2_DEVS) { > - DEBUG ((DEBUG_ERROR, "Wrong PcdPp2Controllers format\n")); > - return EFI_INVALID_PARAMETER; > + Status = gBS->LocateProtocol (&gMarvellBoardDescProtocolGuid, > + NULL, > + (VOID **)&BoardDescProtocol); > + if (EFI_ERROR (Status)) { > + return Status; > } > > - /* Check amount of declared ports */ > - if (PcdGetSize (PcdPp2Port2Controller) > Desc->Pp2DevCount * MVPP2_MAX_PORT) { > - DEBUG ((DEBUG_ERROR, "Pp2Dxe: Wrong too many ports declared\n")); > - return EFI_INVALID_PARAMETER; > + Status = BoardDescProtocol->BoardDescPp2Get (BoardDescProtocol, > + &Pp2BoardDesc); > + if (EFI_ERROR (Status)) { > + return Status; > } > > /* Initialize enabled chips */ > - for (Index = 0; Index < PcdGetSize (PcdPp2Controllers); Index++) { > - if (!MVHW_DEV_ENABLED (Pp2, Index)) { > - DEBUG ((DEBUG_ERROR, "Skip Pp2 controller %d\n", Index)); > - continue; > - } > + for (Index = 0; Index < Pp2BoardDesc->Pp2DevCount; Index++) { > > /* Initialize private data */ > Mvpp2Shared = AllocateZeroPool (sizeof (MVPP2_SHARED)); > @@ -1383,8 +1374,8 @@ Pp2DxeInitialise ( > Status = Pp2DxeInitialiseController ( > Index, > Mvpp2Shared, > - Desc->Pp2BaseAddresses[Index], > - Desc->Pp2ClockFrequency[Index] > + Pp2BoardDesc[Index].SoC->Pp2BaseAddress, > + Pp2BoardDesc[Index].SoC->Pp2ClockFrequency > ); > if (EFI_ERROR(Status)) { > FreePool (Mvpp2Shared); > @@ -1393,5 +1384,7 @@ Pp2DxeInitialise ( > } > } > > + BoardDescProtocol->BoardDescFree (Pp2BoardDesc); > + > return EFI_SUCCESS; > } > -- > 2.7.4 >