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::544; helo=mail-ed1-x544.google.com; envelope-from=mw@semihalf.com; receiver=edk2-devel@lists.01.org Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) (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 EEDD721A07A80 for ; Sun, 18 Nov 2018 22:54:18 -0800 (PST) Received: by mail-ed1-x544.google.com with SMTP id h15so19595695edb.4 for ; Sun, 18 Nov 2018 22:54:18 -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=SJhzzEjwC2rLnidM8nYam79jyj5e+U/D6MUiAMXMhIA=; b=BiKT/oDDgzeQmauoZqbhuVri49ow78YUhl7/zYRfl8E4a8voH6HiU6IXM3cygTIiSn 6zkZVISXvm1h6erLzHesmJ/F5e/jLJO10JdD3xkneJsgyCkLJMC0Bnw3L8KYTTSkxg4H 5dkbN8FJkvlVUwr89KcvrTDUjEBUldadbAB+TWAg8W0O0Nh36BvMvVbq/rqfMjj9Rc1j u0FleEEJyYMuuvzK3YxNLPRrDZf5Q9TAQhcP41vReXrM8AIoRAayUJRNuCVFFrleAxxU z+LYa+vbKxFZ0Aayo5jJ/joiKMopjuzh+oQku1c6RqPUuXiRtbYVfe0iHBNzmIsQPZsp uknA== 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=SJhzzEjwC2rLnidM8nYam79jyj5e+U/D6MUiAMXMhIA=; b=oMwOUWfGh3PgKKt7uTTjFP9w/xgzs5Z+V0zzmhiXm+r8LogICxF/hNib+frA9H3fpR yT4wd5RjTpvoJqU+7c70oVp9UsUJAgCuj56GBzIx06E1UndrnASs1PspI16FPHoCJ5cd HlBZMgbJvakxAKmRPVVJh7uw9zPgvDuGvu6WKUIC6vhaFnwZEB9/6FZOUKGdiax1WI4p +HY0ST8gi7nca8NFp8NLMJboTDHgb3gmBn01pYSm6so6jDtfbM/uQJAlN+TzO2nA/ZbM HWbBZeB30o0+eZhB/KMnyb4DdZIy5kx1zow7ftbxg3udiSpcveRV7OkJ8iihxr7QT4tD MQTg== X-Gm-Message-State: AGRZ1gJxCxATmRR0i1S0advlEpMpFs5IBICk6sCCc+zs2kq6bAs+KYtJ ryl3RQCN29SS7Psylc+AUuBOO5c1j40= X-Google-Smtp-Source: AJdET5cLnMxybpwkn1gBebvWh8uTwhkiO25E7wnGoAjWixv5Es+TXOeS6c/NIv/iTc/4LvgTOEs0Dg== X-Received: by 2002:a50:cb85:: with SMTP id k5-v6mr19190465edi.171.1542610457285; Sun, 18 Nov 2018 22:54:17 -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 i56sm4893236eda.37.2018.11.18.22.54.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 18 Nov 2018 22:54:16 -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: Mon, 19 Nov 2018 07:53:38 +0100 Message-Id: <1542610420-9258-7-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1542610420-9258-1-git-send-email-mw@semihalf.com> References: <1542610420-9258-1-git-send-email-mw@semihalf.com> Subject: [platforms: PATCH v6 6/8] 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, 19 Nov 2018 06:54:19 -0000 X-List-Received-Date: Mon, 19 Nov 2018 06:54:19 -0000 X-List-Received-Date: Mon, 19 Nov 2018 06:54:19 -0000 X-List-Received-Date: Mon, 19 Nov 2018 06:54:19 -0000 X-List-Received-Date: Mon, 19 Nov 2018 06:54:19 -0000 X-List-Received-Date: Mon, 19 Nov 2018 06:54:19 -0000 X-List-Received-Date: Mon, 19 Nov 2018 06:54:19 -0000 X-List-Received-Date: Mon, 19 Nov 2018 06:54:19 -0000 X-List-Received-Date: Mon, 19 Nov 2018 06:54:19 -0000 X-List-Received-Date: Mon, 19 Nov 2018 06:54:19 -0000 X-List-Received-Date: Mon, 19 Nov 2018 06:54:19 -0000 X-List-Received-Date: Mon, 19 Nov 2018 06:54:19 -0000 X-List-Received-Date: Mon, 19 Nov 2018 06:54:19 -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 Reviewed-by: Ard Biesheuvel --- Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.inf | 1 + Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c | 24 +++++++++++++------- Silicon/Marvell/Drivers/NonDiscoverableDxe/NonDiscoverableDxe.c | 1 - 3 files changed, 17 insertions(+), 9 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++; } diff --git a/Silicon/Marvell/Drivers/NonDiscoverableDxe/NonDiscoverableDxe.c b/Silicon/Marvell/Drivers/NonDiscoverableDxe/NonDiscoverableDxe.c index c5cf904..116e9d4 100644 --- a/Silicon/Marvell/Drivers/NonDiscoverableDxe/NonDiscoverableDxe.c +++ b/Silicon/Marvell/Drivers/NonDiscoverableDxe/NonDiscoverableDxe.c @@ -189,7 +189,6 @@ NonDiscoverableEntryPoint ( if (EFI_ERROR(Status)) { return Status; } - BoardDescProtocol->BoardDescFree (SdMmcBoardDesc); return EFI_SUCCESS; } -- 2.7.4