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 750B62110E898 for ; Sun, 2 Sep 2018 21:54:34 -0700 (PDT) Received: by mail-lf1-x143.google.com with SMTP id l26-v6so14109525lfc.8 for ; Sun, 02 Sep 2018 21:54:34 -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=RdgEM8bhilHyeeAbpyac/zd0gUpbB0ozNiDSHJ4VDxdNch6sjknQ/s2H1P10N2supb hq6q1qM98/5/0KGpBxuYkTJ4a8cca1XYCLDoqZxm3yZg25TIpToHSjJDZ6lXucf2Na2l 4kFezdXZHWezq8oJqecYxvz+wMc25CLxLI96MFGhY7Uwj2wO9OpC4ifflPvJLYVGrA2B u1aem5JrK7SqCKfRFx+hyYT/wDm+eMyQjeFi4QlkO2aoZGBarbclNijzYjwLJZ0KYSUV fwxSe8T/HLU3D3tgNmNmL6LOoWTRZUUCMo4oIAtXJ9YbYW385tQiJx76+syR4Z0QSnWd 5BaQ== 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=apxN61UqP7hcccDJiQ2mM6lf1qgAlg9q/SA7zPL6AILuyrEdqFaHOx5UNOQhpYAcDh YqM0dFLCRyV1GATGDOrH50ZKAoRRmnpxaBFoEQjhwfYXPQV5rmrTuH11Ar0O5goli8Pf nnqMut1gxQf5V5OksjWsKGTC589DY+9GzmHRjWEIErD8ngCCBPrF2TpLK86HqzYZEfZ4 jvkJcWoT4DXNj6aZPO+fXAaLyrcAF5+MWR5a0pCazC4YFDCSM15fxfO5401op6hhPOsJ CwLcMtyHyhtGTNzU7z3DoSggMp3f7fzvOBy6dytzqF8WTJFkYJ+dszLRFGdbDZf/qVam Ow1g== X-Gm-Message-State: APzg51CPLAWiY2jUZAETPITZJfrb8kI8t6cfc1DXqyM988AuW/TRTXtU vxCJEhVtVrWEqBcmi479TkHNmwsJeC0= X-Google-Smtp-Source: ANB0Vda/oRzUHj6ToJLqrU8+Xf7o4rvSRB5fXWscqFM16EeVF41R6e3zof/HfRUZyoctX8K3FgBlzA== X-Received: by 2002:a19:4e4e:: with SMTP id c75-v6mr16171940lfb.116.1535950472414; Sun, 02 Sep 2018 21:54:32 -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 i22-v6sm3311445lfh.2.2018.09.02.21.54.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 02 Sep 2018 21:54:31 -0700 (PDT) From: Marcin Wojtas To: edk2-devel@lists.01.org Cc: leif.lindholm@linaro.org, ard.biesheuvel@linaro.org, nadavh@marvell.com, mw@semihalf.com, jsd@semihalf.com, jaz@semihalf.com, Tomasz Michalec Date: Mon, 3 Sep 2018 06:54:02 +0200 Message-Id: <1535950443-27106-7-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535950443-27106-1-git-send-email-mw@semihalf.com> References: <1535950443-27106-1-git-send-email-mw@semihalf.com> Subject: [platforms: PATCH 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: Mon, 03 Sep 2018 04:54:34 -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