From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: None (no SPF record) identity=mailfrom; client-ip=2a00:1450:4864:20::243; helo=mail-lj1-x243.google.com; envelope-from=mw@semihalf.com; receiver=edk2-devel@lists.01.org Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) (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 00E3121A00AE6 for ; Fri, 9 Nov 2018 15:02:21 -0800 (PST) Received: by mail-lj1-x243.google.com with SMTP id s15-v6so2967775lji.3 for ; Fri, 09 Nov 2018 15:02:20 -0800 (PST) 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=thvZPDAgRImJ2Q6mq0W2Jp1EHVCjH6iD3Ctgd68jUYI=; b=F1mFen6Q1EgHVQrAINjEnMDESD6tvHxZaTcAiDWF0WnOgn0SUFcucUU8xYD5hFopaI lFnw3hfYgNcXmCe9X0ZyciQthMaDyTnA5DkF0pewFITzxh0kTKw5hPp92Zq/P1D9Yt/+ 13pgUu5EjAjZLnZGLqf37zm/z+lVJczJzxB+rXM0jymcpFImWq/P5k5P+tV3m7VVUPMY QMSFIqbxaG7Lj5M7fRcXFWnHP4g5ojNskVOpv/wvcqEfMy8eSacoRur5bmil+ABBB1yp cEIwPe3yXGmV/vonTkYORV/PsPz0NT3yJHFdIn4JlFB97zZ3l/pK2Tmt34TqenOhkpCo 2VWw== 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=thvZPDAgRImJ2Q6mq0W2Jp1EHVCjH6iD3Ctgd68jUYI=; b=Dw0xvuDX5zEJcwZEHBDNFQYho2qFgQOtB76GynV8Z7zKHwwxROgPgGC9EPlD8k7uW5 +JlsuNn0nHqIrxbX+rzP8ZEynHhLIfS8TWjs1elW18jd2+e1/HnaBTSpiKIKTN8Nlkop 4LzgocVrTz5vBCNIL45DKUCwCVypNeSRkDgjr4EX89Wa6h9sv2/vtDGOO4jhek8fyh7q bIH4lY7SomwBSCa5BD2VhKVYo/Dlcg9M5JfILpTfn7SbZLhz20Gm/s9JZsXRcxZradeb lxK0nNYCI2jwFy8PN5yOUxYev98GnWnUR+U/F9TOJvFmDSdoLaS4g1aOQUaRlM6VtA// Likg== X-Gm-Message-State: AGRZ1gJJE1LMVRHtRTwSjs3C+QiB1ovGNNsp8CRsNoI6J0JMRHoLTDdC ReGBlsrUbv0FXldMauLdr+/GONMOYEA= X-Google-Smtp-Source: AJdET5eGtEwEDLtQmfvQyLB8RndJutAw0+ultt3ohQNtiEP5AfUWvhkMAUUvjdVPmHhVEw2SI0aBAQ== X-Received: by 2002:a2e:93ca:: with SMTP id p10-v6mr7165559ljh.158.1541804539046; Fri, 09 Nov 2018 15:02:19 -0800 (PST) Received: from gilgamesh.semihalf.com (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id a127sm1274268lfe.73.2018.11.09.15.02.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Nov 2018 15:02:18 -0800 (PST) From: Marcin Wojtas To: edk2-devel@lists.01.org Cc: leif.lindholm@linaro.org, ard.biesheuvel@linaro.org, hao.a.wu@intel.com, nadavh@marvell.com, mw@semihalf.com, jsd@semihalf.com, jaz@semihalf.com, kostap@marvell.com, tm@semihalf.com Date: Sat, 10 Nov 2018 00:01:47 +0100 Message-Id: <1541804508-27499-7-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1541804508-27499-1-git-send-email-mw@semihalf.com> References: <1541804508-27499-1-git-send-email-mw@semihalf.com> Subject: [platforms: PATCH v4 6/7] Marvell/Drivers: MvBoardDesc: Extend information for SdMmc X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Nov 2018 23:02:21 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:21 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:21 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:21 -0000 From: Tomasz Michalec Extend MvBoardDescSdMmcGet function to fill MV_BOARD_SDMMC_DESC with Xenon specific info obtained from ArmadaBoardDescLib. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Marcin Wojtas --- Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.inf | 1 + Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c | 24 +++++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.inf b/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.inf index 41f72d6..0b93948 100644 --- a/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.inf +++ b/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.inf @@ -47,6 +47,7 @@ Silicon/Marvell/Marvell.dec [LibraryClasses] + ArmadaBoardDescLib ArmadaSoCDescLib DebugLib MemoryAllocationLib diff --git a/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c b/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c index 39dc06c..f71bfc4 100644 --- a/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c +++ b/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c @@ -270,6 +270,7 @@ MvBoardDescSdMmcGet ( { UINT8 *SdMmcDeviceEnabled; UINTN SdMmcCount, SdMmcDeviceTableSize, SdMmcIndex, Index; + UINTN SdMmcDevCount; MV_BOARD_SDMMC_DESC *BoardDesc; MV_SOC_SDMMC_DESC *SoCDesc; EFI_STATUS Status; @@ -280,6 +281,13 @@ MvBoardDescSdMmcGet ( return Status; } + /* Get per-board configuration of the controllers */ + Status = ArmadaBoardDescSdMmcGet (&SdMmcDevCount, &BoardDesc); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ArmadaBoardDescSdMmcGet filed\n", __FUNCTION__)); + return Status; + } + /* * Obtain table with enabled SDMMC controllers * which is represented as an array of UINT8 values @@ -294,18 +302,12 @@ MvBoardDescSdMmcGet ( SdMmcDeviceTableSize = PcdGetSize (PcdPciESdhci); /* Check if PCD with SDMMC controllers is correctly defined */ - if (SdMmcDeviceTableSize > SdMmcCount) { + if ((SdMmcDeviceTableSize > SdMmcCount) || + (SdMmcDeviceTableSize < SdMmcDevCount)) { DEBUG ((DEBUG_ERROR, "%a: Wrong PcdPciESdhci format\n", __FUNCTION__)); return EFI_INVALID_PARAMETER; } - /* Allocate and fill board description */ - BoardDesc = AllocateZeroPool (SdMmcDeviceTableSize * sizeof (MV_BOARD_SDMMC_DESC)); - if (BoardDesc == NULL) { - DEBUG ((DEBUG_ERROR, "%a: Cannot allocate memory\n", __FUNCTION__)); - return EFI_OUT_OF_RESOURCES; - } - SdMmcIndex = 0; for (Index = 0; Index < SdMmcDeviceTableSize; Index++) { if (!SdMmcDeviceEnabled[Index]) { @@ -313,6 +315,12 @@ MvBoardDescSdMmcGet ( continue; } + if (SdMmcIndex >= SdMmcDevCount) { + DEBUG ((DEBUG_ERROR, + "%a: More enabled devices than returned by ArmadaBoardDescSdMmcGet\n", + __FUNCTION__)); + return EFI_INVALID_PARAMETER; + } BoardDesc[SdMmcIndex].SoC = &SoCDesc[Index]; SdMmcIndex++; } -- 2.7.4