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=wHCsohJd; 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; Thu, 09 May 2019 02:54:00 -0700 Received: by mail-lj1-f196.google.com with SMTP id e13so1430939ljl.11 for ; Thu, 09 May 2019 02:54:00 -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=tTdbseshSsvevXW6a4Ez/+YQeKH1BoMMzwFKsctzmxM=; b=wHCsohJdlVt7KPIdRfaVFeNm16hACDKgKuWMM0lG6KT/vY6x2bHOUGGrTo21rL8SwT zP67BRxc+f1PW7x7Daboy6z723RlrDfxs8yfAETvG0cNiKqBlgQOghcrcdoAC1k8HqOC HuU/NIEXIO8zeufZDh79rsYRGfYiWNApY0+PrjFaym0eJ4xcVwwUL48xX3nRNQKMs4LV B6U1bV6fdPe3jvgWfAAXO5YKIwMSpDm6fcPjbXKjdyVSOLqCelbuOLWNqg8vZWC4ou/S 3VhOTcZEATUTIcpO9F40YkIL117/p7pwQBQqbECtw4S5n/HXY8kY3N6zNeUyVGUMB0mN gnWQ== 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=tTdbseshSsvevXW6a4Ez/+YQeKH1BoMMzwFKsctzmxM=; b=tB/WF+zYMEYFC2hdBP95ZADez7TrWJRXYdQlMek5qhBwRkeT5oJ1IZwyah4/DF1rmy 4nGcZVitbryIPfhNLhrjed40DZnasWU0R5EgTQB+c/00Ci2QNc/Tmmt3jUUOvNFWsIJ9 nv+w9j5GmxxWppfFpSk8uEEaBYzigg76Pp6r5N7FAsP1JUIv9Mu0cNN2FU85pxV3njBp 9ZD8+KYVY7ACP7jL2SxfhNgKTn4hW/HGO1gzKXORMIsTpr6gW/xNL7kgkjs1FdiKaEzG Dwc+hkb4s3xSrCS4ErfYZdCASETeBL2vsd+plCCqIM+kWMSAzLFmr8BI0xLGxSOnuikD UPQA== X-Gm-Message-State: APjAAAVWtXLCRSW8FU2EqIZe3IFiX4MholaMMdafri9Z5a68lYM2EkCN W4ZP0BCwm0qtZjMxiFrsvDlwhvwTvqo= X-Google-Smtp-Source: APXvYqyuIn3RCBsYiAno1+JrTHM8bnS2E8Z4IvALQ6LCB+x9f93FHggG4qKMFoTPC1SNW5CqHAUhhA== X-Received: by 2002:a05:651c:150:: with SMTP id c16mr1643905ljd.65.1557395638121; Thu, 09 May 2019 02:53:58 -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 l25sm276668lfk.57.2019.05.09.02.53.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 09 May 2019 02:53:57 -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 02/14] Marvell/Library: ArmadaSoCDescLib: Add PCIE information Date: Thu, 9 May 2019 11:53:30 +0200 Message-Id: <1557395622-32425-3-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1557395622-32425-1-git-send-email-mw@semihalf.com> References: <1557395622-32425-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 8bbc5b0..e904222 100644 --- a/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.h +++ b/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.h @@ -82,6 +82,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 fc17c3a..ff617e6 100644 --- a/Silicon/Marvell/Include/Library/ArmadaSoCDescLib.h +++ b/Silicon/Marvell/Include/Library/ArmadaSoCDescLib.h @@ -191,6 +191,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] **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 + ); + // // PP2 NIC devices SoC description // diff --git a/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.c b/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.c index 355be64..4f8a59a 100644 --- a/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.c +++ b/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.c @@ -278,6 +278,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