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:c0c::244; helo=mail-wr0-x244.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x244.google.com (mail-wr0-x244.google.com [IPv6:2a00:1450:400c:c0c::244]) (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 AA00820979D4E for ; Mon, 18 Jun 2018 08:53:14 -0700 (PDT) Received: by mail-wr0-x244.google.com with SMTP id a12-v6so17406884wro.1 for ; Mon, 18 Jun 2018 08:53:14 -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=gho6l96EciZAJGcXgXLhnnxLGdNCvCU3Hqk7zem/840=; b=Z+TGajX4fiefad5Nf9fRWgEB2rY6jB3npPFHDDx44lhfD0LVBIUgsrGedwo6QZlrgt lw3dfTViAiWnE5TYQQctRZ4B8BEJlAYYIfrEQ+GE9Z16PjHcKz94rk1zSSumJZ/AJaJu 5Vb1j7ao3ZyZN3eOas3owJC2vC4Vz9Jq34vds= 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=gho6l96EciZAJGcXgXLhnnxLGdNCvCU3Hqk7zem/840=; b=MVHJSy/FpKx2QV0Yc4Sglz0XWZBJFt/1qN7yjWlpo7Rv3qf4eZKRupY30hXZ8vx3am SPVz6hD2iBrqopBasIo0YM38bXrFhodI34KsTODYHys76WbfTKTzAFA9vAauZObvv+mv uYC4ikjaQVI7Yqcm37IWmGEaPPYKomB3IJV1PZQSZxQiDL7QmzIa1bYmJBTX7o/ml9Ee Mg8QydFpj5wGrz/7I/Fc8uCsrUYFbakCjvg9fpDEnCNzYyuSJcwTJkJEzCN/GdTRf+C6 kYqlkubTf9YiIMVQrA4kiT9fgo1fPpn4WWchTyURANaEGiXsHUkNX25osIWzQlOMlWKB Cf1Q== X-Gm-Message-State: APt69E29XtHdmyQj+G3xpUK/ow93JTdcyDkB/O66GL+U5v6MF5DYWIrr +yEs/2F77GBtD+mYWnEXS9Kc3w== X-Google-Smtp-Source: ADUXVKJsFnTTuQX7NmdD5tT0G1AWE6TA2Qq9moQNGZALl73T3aQrpIKmBFA1LYppnCBG1zzzMhtexA== X-Received: by 2002:adf:824e:: with SMTP id 72-v6mr11246385wrb.127.1529337192910; Mon, 18 Jun 2018 08:53:12 -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 j131-v6sm14798609wmg.24.2018.06.18.08.53.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 08:53:11 -0700 (PDT) Date: Mon, 18 Jun 2018 16:53:09 +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: <20180618155309.lgiiradea4cnkcqn@bivouac.eciton.net> References: <1529266325-18371-1-git-send-email-mw@semihalf.com> <1529266325-18371-10-git-send-email-mw@semihalf.com> MIME-Version: 1.0 In-Reply-To: <1529266325-18371-10-git-send-email-mw@semihalf.com> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [platforms: PATCH v2 09/25] Marvell/Drivers: MvBoardDesc: Extend protocol with PP2 support 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:53:15 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sun, Jun 17, 2018 at 10:11:49PM +0200, Marcin Wojtas wrote: > Introduce new callback that can provide information > about PP2 NICs to the Pp2Dxe driver. > > Extend ArmadaBoardDescLib with new structure MV_BOARD_PP2_DESC, > for holding board specific data. In further steps it should > be extended and replace PCD port's representation with the > appropriate structures. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Marcin Wojtas Reviewed-by: Leif Lindholm > --- > Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.inf | 1 + > Silicon/Marvell/Include/Library/ArmadaBoardDescLib.h | 8 +++ > Silicon/Marvell/Include/Protocol/BoardDesc.h | 8 +++ > Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c | 63 ++++++++++++++++++++ > 4 files changed, 80 insertions(+) > > diff --git a/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.inf b/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.inf > index 5da5f21..6f57f06 100644 > --- a/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.inf > +++ b/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.inf > @@ -58,6 +58,7 @@ > > [Pcd] > gMarvellTokenSpaceGuid.PcdPciEXhci > + gMarvellTokenSpaceGuid.PcdPp2Controllers > gMarvellTokenSpaceGuid.PcdUtmiControllersEnabled > gMarvellTokenSpaceGuid.PcdUtmiPortType > > diff --git a/Silicon/Marvell/Include/Library/ArmadaBoardDescLib.h b/Silicon/Marvell/Include/Library/ArmadaBoardDescLib.h > index 068535a..ab94877 100644 > --- a/Silicon/Marvell/Include/Library/ArmadaBoardDescLib.h > +++ b/Silicon/Marvell/Include/Library/ArmadaBoardDescLib.h > @@ -17,6 +17,14 @@ > #include > > // > +// PP2 NIC devices per-board description > +// > +typedef struct { > + MV_SOC_PP2_DESC *SoC; > + UINT8 Pp2DevCount; > +} MV_BOARD_PP2_DESC; > + > +// > // UTMI PHY devices per-board description > // > typedef struct { > diff --git a/Silicon/Marvell/Include/Protocol/BoardDesc.h b/Silicon/Marvell/Include/Protocol/BoardDesc.h > index f8a2902..114a0ec 100644 > --- a/Silicon/Marvell/Include/Protocol/BoardDesc.h > +++ b/Silicon/Marvell/Include/Protocol/BoardDesc.h > @@ -43,6 +43,13 @@ typedef struct _MARVELL_BOARD_DESC_PROTOCOL MARVELL_BOARD_DESC_PROTOCOL; > > typedef > EFI_STATUS > +(EFIAPI *MV_BOARD_DESC_PP2_GET) ( > + IN MARVELL_BOARD_DESC_PROTOCOL *This, > + IN OUT MV_BOARD_PP2_DESC **Pp2Desc > + ); > + > +typedef > +EFI_STATUS > (EFIAPI *MV_BOARD_DESC_UTMI_GET) ( > IN MARVELL_BOARD_DESC_PROTOCOL *This, > IN OUT MV_BOARD_UTMI_DESC **UtmiDesc > @@ -55,6 +62,7 @@ VOID > ); > > struct _MARVELL_BOARD_DESC_PROTOCOL { > + MV_BOARD_DESC_PP2_GET BoardDescPp2Get; > MV_BOARD_DESC_UTMI_GET BoardDescUtmiGet; > MV_BOARD_DESC_FREE BoardDescFree; > }; > diff --git a/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c b/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c > index 0232a21..7c0bc39 100644 > --- a/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c > +++ b/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c > @@ -37,6 +37,68 @@ MV_BOARD_DESC *mBoardDescInstance; > > STATIC > EFI_STATUS > +MvBoardDescPp2Get ( > + IN MARVELL_BOARD_DESC_PROTOCOL *This, > + IN OUT MV_BOARD_PP2_DESC **Pp2Desc > + ) > +{ > + UINT8 *Pp2DeviceEnabled; > + UINTN Pp2Count, Pp2DeviceTableSize, Pp2Index, Index; > + MV_BOARD_PP2_DESC *BoardDesc; > + MV_SOC_PP2_DESC *SoCDesc; > + EFI_STATUS Status; > + > + /* Get SoC data about all available PP2 controllers */ > + Status = ArmadaSoCDescPp2Get (&SoCDesc, &Pp2Count); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + > + /* > + * Obtain table with enabled Pp2 controllers, > + * which is represented as an array of UINT8 values > + * (0x0 - disabled, 0x1 enabled). > + */ > + Pp2DeviceEnabled = PcdGetPtr (PcdPp2Controllers); > + if (Pp2DeviceEnabled == NULL) { > + /* No PP2 NIC on platform */ > + return EFI_SUCCESS; > + } > + > + Pp2DeviceTableSize = PcdGetSize (PcdPp2Controllers); > + > + /* Check if PCD with PP2 NICs is correctly defined */ > + if (Pp2DeviceTableSize > Pp2Count) { > + DEBUG ((DEBUG_ERROR, "%a: Wrong PcdPp2Controllers format\n", __FUNCTION__)); > + return EFI_INVALID_PARAMETER; > + } > + > + /* Allocate and fill board description */ > + BoardDesc = AllocateZeroPool (Pp2DeviceTableSize * sizeof (MV_BOARD_PP2_DESC)); > + if (BoardDesc == NULL) { > + DEBUG ((DEBUG_ERROR, "%a: Cannot allocate memory\n", __FUNCTION__)); > + return EFI_OUT_OF_RESOURCES; > + } > + > + Pp2Index = 0; > + for (Index = 0; Index < Pp2DeviceTableSize; Index++) { > + if (!Pp2DeviceEnabled[Index]) { > + continue; > + } > + > + BoardDesc[Pp2Index].SoC = &SoCDesc[Index]; > + Pp2Index++; > + } > + > + BoardDesc->Pp2DevCount = Pp2Index; > + > + *Pp2Desc = BoardDesc; > + > + return EFI_SUCCESS; > +} > + > +STATIC > +EFI_STATUS > MvBoardDescUtmiGet ( > IN MARVELL_BOARD_DESC_PROTOCOL *This, > IN OUT MV_BOARD_UTMI_DESC **UtmiDesc > @@ -140,6 +202,7 @@ MvBoardDescInitProtocol ( > IN MARVELL_BOARD_DESC_PROTOCOL *BoardDescProtocol > ) > { > + BoardDescProtocol->BoardDescPp2Get = MvBoardDescPp2Get; > BoardDescProtocol->BoardDescUtmiGet = MvBoardDescUtmiGet; > BoardDescProtocol->BoardDescFree = MvBoardDescFree; > > -- > 2.7.4 >