From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@semihalf-com.20150623.gappssmtp.com header.s=20150623 header.b=KIRStu91; spf=none, err=SPF record not found (domain: semihalf.com, ip: 209.85.208.196, mailfrom: mw@semihalf.com) Received: from mail-lj1-f196.google.com (mail-lj1-f196.google.com [209.85.208.196]) by groups.io with SMTP; Fri, 24 May 2019 08:59:32 -0700 Received: by mail-lj1-f196.google.com with SMTP id z1so3635853ljb.3 for ; Fri, 24 May 2019 08:59:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=n/WxT5cLbsqCXhcSVU1sb85yyqwpgy4xIypecGINkCM=; b=KIRStu91Ii1NdSt/p6PkY6dp6+UaHqHZ8fvjybvrYTVmMY73CPhNKJ1stVosuvT0UP KJO90IpWsuVElHKOKYnznxWwBOEu8qwBCBMU3q1se6xVCjwosnNLQjx8cZJT6UdyRmIS AOQ3A4n6SXGhelO8epIwgCPlHRR0034fvVvPZAmNsvuLTG0DPRO7ERQtKWCwhUyaYoFk 5hxFF6vIvzjcOhZGHdn9IyieeInccrkZk3JTI9JufMzKtG9u3kQypEXQa40KylBxbVOC vz45oSP6XqJu5aBesJxB6xPTy877yX4ZwhlUbc74riPy/nTscTLgluUy+07CKcsL7nHK e9pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=n/WxT5cLbsqCXhcSVU1sb85yyqwpgy4xIypecGINkCM=; b=A/5dkgGf5nGn5f1Pw3+AK98WSdFtGfVvbGLfwfvIUFY6sJIqDuSdKpbXWy9Iygnvep WnuIFq/7+14O6nGcw5ENhvbWsbexMZ3jg66lScfcfkpbB9YEApREQBQ7gYQB/08sO4tc Xm+0OI+wq4xHeOj4Qrp1A9vuQM4BL4SIuACR2SMKwTnGBTWmmxIFf5srG0gcrLN9l1Fy lC3PPfs+8eVNXWSI47BFrzt7CrX/iSv83rSVMeGmPPP9xLHHdOFSI4F1J1haCrQeI5T7 eqmCz5Ge2vZGCtkVfG9uAtTn1ubs6lzh3fVXD+Jq6xw5lN6DBjgquyvJX2wUh6mys207 I9Bg== X-Gm-Message-State: APjAAAX4Bh+I9Ccpi9yP5AKYn3rfQuyVcNik122m6WtvsT1LWGgrhwyv 7f/GHF7gSMvUyHKZaow3DDGXbSipazjZ9A== X-Google-Smtp-Source: APXvYqxRBpyntRqaNV/dABFELpCtuqqNMltcKTf6f/RIu6y7G+6+zvrm2D+SWM6zBAeulXyscEBOrA== X-Received: by 2002:a2e:994:: with SMTP id 142mr45939886ljj.192.1558713570303; Fri, 24 May 2019 08:59:30 -0700 (PDT) Return-Path: Received: from gilgamesh.semihalf.com (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id d18sm685280lfl.95.2019.05.24.08.59.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 24 May 2019 08:59:29 -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-platforms: PATCH v3 02/14] Marvell/Library: ArmadaSoCDescLib: Add PCIE information Date: Fri, 24 May 2019 17:58:59 +0200 Message-Id: <1558713551-25363-3-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1558713551-25363-1-git-send-email-mw@semihalf.com> References: <1558713551-25363-1-git-send-email-mw@semihalf.com> This patch introduces new library callback (ArmadaSoCPcieGet ()), which dynamically allocates and fills array with all available PCIE controllers' base addresses. It is needed for the configuration of PCIE, whose support will be added in the upcoming patches. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Marcin Wojtas --- Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.h | 6 +++ Silicon/Marvell/Include/Library/ArmadaSoCDescLib.h | 20 +++++++++ Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.c | 44 ++++++++++++++++++++ 3 files changed, 70 insertions(+) diff --git a/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.h b/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.h index 74883fd..0296d43 100644 --- a/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.h +++ b/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.h @@ -76,6 +76,12 @@ #define MV_SOC_MDIO_ID(Cp) (Cp) // +// Platform description of PCIE +// +#define MV_SOC_PCIE_PER_CP_COUNT 3 +#define MV_SOC_PCIE_BASE(Index) (0x600000 + ((Index) * 0x20000)) + +// // Platform description of PP2 NIC // #define MV_SOC_PP2_BASE(Cp) MV_SOC_CP_BASE (Cp) diff --git a/Silicon/Marvell/Include/Library/ArmadaSoCDescLib.h b/Silicon/Marvell/Include/Library/ArmadaSoCDescLib.h index cd9c9f2..6432916 100644 --- a/Silicon/Marvell/Include/Library/ArmadaSoCDescLib.h +++ b/Silicon/Marvell/Include/Library/ArmadaSoCDescLib.h @@ -185,6 +185,26 @@ ArmadaSoCDescXhciGet ( IN OUT UINTN *DescCount ); +/** + This function returns the total number of PCIE controllers and an array + with their base addresses. + + @param[in out] **PcieDbiAddresses Array containing PCIE controllers' base + adresses. + @param[in out] *Count Total amount of available PCIE controllers. + + @retval EFI_SUCCESS The data were obtained successfully. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a + lack of resources. + +**/ +EFI_STATUS +EFIAPI +ArmadaSoCPcieGet ( + IN OUT EFI_PHYSICAL_ADDRESS **PcieDbiAddresses, + IN OUT UINTN *Count + ); + // // PP2 NIC devices SoC description // diff --git a/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.c b/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.c index b637966..5947601 100644 --- a/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.c +++ b/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.c @@ -272,6 +272,50 @@ ArmadaSoCDescAhciGet ( return EFI_SUCCESS; } +/** + This function returns the total number of PCIE controllers and an array + with their base addresses. + + @param[in out] **PcieBaseAddresses Array containing PCIE controllers' base + adresses. + @param[in out] *Count Total amount of available PCIE controllers. + + @retval EFI_SUCCESS The data were obtained successfully. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a + lack of resources. + +**/ +EFI_STATUS +EFIAPI +ArmadaSoCPcieGet ( + IN OUT EFI_PHYSICAL_ADDRESS **PcieBaseAddresses, + IN OUT UINTN *Count + ) +{ + UINTN CpCount, CpIndex, Index; + EFI_PHYSICAL_ADDRESS *BaseAddress; + + CpCount = FixedPcdGet8 (PcdMaxCpCount); + + *Count = CpCount * MV_SOC_PCIE_PER_CP_COUNT; + BaseAddress = AllocateZeroPool (*Count * sizeof (EFI_PHYSICAL_ADDRESS)); + if (BaseAddress == NULL) { + DEBUG ((DEBUG_ERROR, "%a: Cannot allocate memory\n", __FUNCTION__)); + return EFI_OUT_OF_RESOURCES; + } + + *PcieBaseAddresses = BaseAddress; + + for (CpIndex = 0; CpIndex < CpCount; CpIndex++) { + for (Index = 0; Index < MV_SOC_PCIE_PER_CP_COUNT; Index++) { + *BaseAddress = MV_SOC_CP_BASE (CpIndex) + MV_SOC_PCIE_BASE (Index); + BaseAddress++; + } + } + + return EFI_SUCCESS; +} + EFI_STATUS EFIAPI ArmadaSoCDescPp2Get ( -- 2.7.4