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::143; helo=mail-lf1-x143.google.com; envelope-from=mw@semihalf.com; receiver=edk2-devel@lists.01.org Received: from mail-lf1-x143.google.com (mail-lf1-x143.google.com [IPv6:2a00:1450:4864:20::143]) (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 763BB21BADAB2 for ; Fri, 5 Oct 2018 06:26:22 -0700 (PDT) Received: by mail-lf1-x143.google.com with SMTP id d4-v6so9366266lfa.3 for ; Fri, 05 Oct 2018 06:26:22 -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=thvZPDAgRImJ2Q6mq0W2Jp1EHVCjH6iD3Ctgd68jUYI=; b=wwYX6RwKfdmThwC5PEt0HoYNoNLT81Cbnm7CBHfI6LOl5B2ITA0ZtQnvle31zTwYH7 85gj+ePCuke0k79nYFWkSF2ntvNubFkRT+ClZvEx45xhUKpDfrmR25tTATkvkhG9bqzN LZ2uyzVD5vd/MQjoJYzLT468Z1I4fmxdW2oI8k8Csuxr6wII3V3SiP7S0c7ZoXgpbSM3 D/7siXFs7LRW8RvKHtYMCCWHB2ymlIbzcgs2ByGPzVwthCnCMAbeC4zsl7hxac6GT4uE ZRz0of6mL91EfPHSEqbxKn1G+oM46u2eNfl+Q9AA7pW0dtAWo8HTwUCsv/pX0iJWiIN9 QfyQ== 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=X66WHTyAuCxu2GiqXCjz24EOSGcCBhU7RABWGSJD6HpK2NYxQPEXi9IjM6DSAOj8re Pvt2J08m0T0jkBFLuZb75h8O0h4cllQYtCl6dO/DQ/dACbGKqFifqAy7CjVY+phYINgv aZGpSIgZH2yzCuIUrtXbs7Kt0ja/M6iVoVAYswFyYEx18CzhvxlsdMWcGvBEBdp8tqcS zV9H7mWr7AsHl2gYm96euCb7xIzuCKz2ZhmRJM3YJh27EjkAQAkCAH+EOUgvxtJ49xIG xeb8yRR4inXXCjD9bCRrqw55uTNDHx7ydAR/pmwQLXeR1rlRahZ6S4lBcQPl5v4+/egU c+AA== X-Gm-Message-State: ABuFfognJ23FGYZthmnqu74iYTU4JRO6GBlaJqrdbG+nQ3IHg2JqTQYr Hv37xKu92Dt3eGYl8VkShLSEKrCvkkY= X-Google-Smtp-Source: ACcGV60EKHGVkyl1y7VRKx8jB8RaYJ4q+wN2NrJmgEOQteHVuNb0Bvq4Hzl/M1+mzODxej54JlBtTw== X-Received: by 2002:a19:a3d1:: with SMTP id m200-v6mr6269889lfe.38.1538745980435; Fri, 05 Oct 2018 06:26:20 -0700 (PDT) Received: from gilgamesh.semihalf.com (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id p130-v6sm1817659lfd.55.2018.10.05.06.26.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 05 Oct 2018 06:26:19 -0700 (PDT) From: Marcin Wojtas To: edk2-devel@lists.01.org Cc: leif.lindholm@linaro.org, hao.a.wu@intel.com, ard.biesheuvel@linaro.org, nadavh@marvell.com, mw@semihalf.com, jsd@semihalf.com, tm@semihalf.com Date: Fri, 5 Oct 2018 15:26:07 +0200 Message-Id: <1538745968-22526-7-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1538745968-22526-1-git-send-email-mw@semihalf.com> References: <1538745968-22526-1-git-send-email-mw@semihalf.com> Subject: [platforms: PATCH v2 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, 05 Oct 2018 13:26:23 -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