From nobody Mon Feb 9 17:37:41 2026 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+41072+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+41072+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1558366079; cv=none; d=zoho.com; s=zohoarc; b=dSUJ9czL8w4YEE6upLjP4G3QsoTTQTKGX38y39dZYcQOfRO9TnPSbg56WWvHfsUTyjsIANOYl8zurqRhry5xq6OIrTdDtkN5Gg8ZjBN54xLvHfa2G+K7swqNcMHO5S5bX6u0mhdUjr+nJPOfgP9csPaDzrx+DRNHhpzBR4wJ6nw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558366079; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=fG07BvjkbCRC28dXf8Ux14br1UG6SMYdjRpvajzXAGk=; b=CqkJCmEZI2SPXoGzphMZ4XAT5YPI0uwtlFoZuh+VBw4k5dvHg2xLKP48t7xt1gmoQVjfsmvJ0fwjlKgVLP9YdZo1VQYs1LfSZoRXodjL6mxNhcgqVbmH6vw4S2KrmAOwEkQ1ScLcrmuhl077s5FMuuWov/KpyINitx6LP44hbh4= 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+41072+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1558366079841520.1699872334182; Mon, 20 May 2019 08:27:59 -0700 (PDT) Return-Path: X-Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) by groups.io with SMTP; Mon, 20 May 2019 08:27:59 -0700 X-Received: by mail-lj1-f194.google.com with SMTP id m15so3574683ljg.13 for ; Mon, 20 May 2019 08:27:58 -0700 (PDT) X-Gm-Message-State: APjAAAWBWtPIAH8vGk/ng+J7TtFafpngA1wCldiXaLA8G2BdqoW3igkF 0zb0UjXzUnRhpWusMDyZAjoL3jVuvZM= X-Google-Smtp-Source: APXvYqwdnhG+Si1GrXTUV0qFzV8Udntitr19Kuq15ITHK26eNeco5Z0FhoqoOFxrGMsfY462/tNeqw== X-Received: by 2002:a2e:9f41:: with SMTP id v1mr189475ljk.66.1558366076636; Mon, 20 May 2019 08:27:56 -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 d5sm3906205lji.85.2019.05.20.08.27.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 20 May 2019 08:27:55 -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, rebecca@bluestop.org, kettenis@jive.eu Subject: [edk2-devel] [edk2-platforms: PATCH v2 05/14] Marvell/Armada7k8k: MvBoardDesc: Extend protocol with PCIE support Date: Mon, 20 May 2019 17:27:18 +0200 Message-Id: <1558366047-15994-6-git-send-email-mw@semihalf.com> In-Reply-To: <1558366047-15994-1-git-send-email-mw@semihalf.com> References: <1558366047-15994-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=1558366079; bh=Tb+lVrx0BWCwte1bIqMcghGRf5Gbdo/nZSmIKT1aq4c=; h=Cc:Date:From:Reply-To:Subject:To; b=h32rRXQfwMbtJDDVd2AJTJ5n+SrwpEVqk3xDtgyaeQQS2EriWVnyV2yRnicPUJ2GijW 2/O7m0yEc0N+UH3/DK7Bn4LBPoAz4oyVpbM4LiUSpRX/VviA2XotdcopNLxyIybp0E7KH ozTgCbjmVPcs4XMFERYN8RzFFqiOc4dzENI= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Introduce new callback that can provide information about PCIE controllers, which are used on the platform. According ArmadaSoCDescLib ArmadaBoardDescLib routines are used for obtaining required data. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Marcin Wojtas --- Silicon/Marvell/Include/Protocol/BoardDesc.h | 22 +++++ Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c | 86 ++++++++++++++++++= ++ 2 files changed, 108 insertions(+) diff --git a/Silicon/Marvell/Include/Protocol/BoardDesc.h b/Silicon/Marvell= /Include/Protocol/BoardDesc.h index 02905ea..48f6d9d 100644 --- a/Silicon/Marvell/Include/Protocol/BoardDesc.h +++ b/Silicon/Marvell/Include/Protocol/BoardDesc.h @@ -90,6 +90,27 @@ EFI_STATUS IN OUT MV_BOARD_XHCI_DESC **XhciDesc ); =20 +/** + Return the description of PCIE controllers used on the platform. + + @param[in out] *This Pointer to board description proto= col. + @param[in out] **PcieDescription Array containing PCIE controllers' + description. + + @retval EFI_SUCCESS The data were obtained successfull= y. + @retval EFI_NOT_FOUND None of the controllers is used. + @retval EFI_INVALID_PARAMETER Description wrongly defined. + @retval EFI_OUT_OF_RESOURCES Lack of resources. + @retval Other Return error status. + +**/ +typedef +EFI_STATUS +(EFIAPI *MV_BOARD_PCIE_DESCRIPTION_GET) ( + IN MARVELL_BOARD_DESC_PROTOCOL *This, + IN OUT MV_BOARD_PCIE_DESCRIPTION CONST **PcieDescription + ); + typedef EFI_STATUS (EFIAPI *MV_BOARD_DESC_PP2_GET) ( @@ -121,6 +142,7 @@ struct _MARVELL_BOARD_DESC_PROTOCOL { MV_BOARD_DESC_XHCI_GET BoardDescXhciGet; MV_BOARD_DESC_FREE BoardDescFree; MV_BOARD_GPIO_DESCRIPTION_GET GpioDescriptionGet; + MV_BOARD_PCIE_DESCRIPTION_GET PcieDescriptionGet; }; =20 #endif // __MARVELL_BOARD_DESC_PROTOCOL_H__ diff --git a/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c b/Silicon/M= arvell/Drivers/BoardDesc/MvBoardDescDxe.c index 973c362..042db28 100644 --- a/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c +++ b/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c @@ -36,6 +36,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMA= GE. MV_BOARD_DESC *mBoardDescInstance; =20 STATIC MV_BOARD_GPIO_DESCRIPTION *mGpioDescription; +STATIC MV_BOARD_PCIE_DESCRIPTION *mPcieDescription; =20 STATIC EFI_STATUS @@ -444,6 +445,90 @@ MvBoardDescXhciGet ( return EFI_SUCCESS; } =20 +/** + Return the description of PCIE controllers used on the platform. + + @param[in out] *This Pointer to board description proto= col. + @param[in out] **PcieDescription Array containing PCIE controllers' + description. + + @retval EFI_SUCCESS The data were obtained successfull= y. + @retval EFI_NOT_FOUND None of the controllers is used. + @retval EFI_INVALID_PARAMETER Description wrongly defined. + @retval EFI_OUT_OF_RESOURCES Lack of resources. + @retval Other Return error status. + +**/ +STATIC +EFI_STATUS +MvBoardPcieDescriptionGet ( + IN MARVELL_BOARD_DESC_PROTOCOL *This, + IN OUT MV_BOARD_PCIE_DESCRIPTION CONST **PcieDescription + ) +{ + UINTN SoCPcieControllerCount, BoardPcieControllerCount, SoCIndex, BoardI= ndex; + EFI_PHYSICAL_ADDRESS *PcieDbiAddresses; + MV_PCIE_CONTROLLER CONST *PcieControllers; + EFI_STATUS Status; + + /* Use existing structure if already created. */ + if (mPcieDescription !=3D NULL) { + *PcieDescription =3D mPcieDescription; + return EFI_SUCCESS; + } + + /* Get SoC data about all available PCIE controllers. */ + Status =3D ArmadaSoCPcieGet (&PcieDbiAddresses, &SoCPcieControllerCount); + if (EFI_ERROR (Status)) { + return Status; + } + + /* Get per-board information about all used PCIE controllers. */ + Status =3D ArmadaBoardPcieControllerGet (&PcieControllers, + &BoardPcieControllerCount); + if (EFI_ERROR (Status)) { + return Status; + } + + /* Sanity check of the board description. */ + if (BoardPcieControllerCount > SoCPcieControllerCount) { + DEBUG ((DEBUG_ERROR, "%a: Too many controllers described\n", __FUNCTIO= N__)); + return EFI_INVALID_PARAMETER; + } + + for (BoardIndex =3D 0; BoardIndex < BoardPcieControllerCount; BoardIndex= ++) { + for (SoCIndex =3D 0; SoCIndex < SoCPcieControllerCount; SoCIndex++) { + if (PcieControllers[BoardIndex].PcieDbiAddress =3D=3D + PcieDbiAddresses[SoCIndex]) { + /* Match found */ + break; + } + } + if (SoCIndex =3D=3D SoCPcieControllerCount) { + DEBUG ((DEBUG_ERROR, + "%a: Controller #%d base address invalid: 0x%x\n", + __FUNCTION__, + BoardIndex, + PcieControllers[BoardIndex].PcieDbiAddress)); + return EFI_INVALID_PARAMETER; + } + } + + /* Allocate and fill board description. */ + mPcieDescription =3D AllocateZeroPool (sizeof (MV_BOARD_PCIE_DESCRIPTION= )); + if (mPcieDescription =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: Cannot allocate memory\n", __FUNCTION__)); + return EFI_OUT_OF_RESOURCES; + } + + mPcieDescription->PcieControllers =3D PcieControllers; + mPcieDescription->PcieControllerCount =3D BoardPcieControllerCount; + + *PcieDescription =3D mPcieDescription; + + return EFI_SUCCESS; +} + STATIC EFI_STATUS MvBoardDescPp2Get ( @@ -621,6 +706,7 @@ MvBoardDescInitProtocol ( BoardDescProtocol->BoardDescXhciGet =3D MvBoardDescXhciGet; BoardDescProtocol->BoardDescFree =3D MvBoardDescFree; BoardDescProtocol->GpioDescriptionGet =3D MvBoardGpioDescriptionGet; + BoardDescProtocol->PcieDescriptionGet =3D MvBoardPcieDescriptionGet; =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 (#41072): https://edk2.groups.io/g/devel/message/41072 Mute This Topic: https://groups.io/mt/31686571/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-