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::541; helo=mail-ed1-x541.google.com; envelope-from=mw@semihalf.com; receiver=edk2-devel@lists.01.org Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) (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 431372194D387 for ; Tue, 13 Nov 2018 04:33:37 -0800 (PST) Received: by mail-ed1-x541.google.com with SMTP id d3so9705598edx.7 for ; Tue, 13 Nov 2018 04:33:37 -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=KQqfMEKTkdZe1hIjg1RYOBYvpYkZsgZ9b781SjghlQo=; b=JNg8+/4m/x8qH5qR9ToCapyPIyE4e2pG4ewPLkYc4ENxf8Gzdp3G26j6Oqy/zUFGkr XukqQ2rfzJjWV+RZfjPfPgSDjO5YLea/BjaIQidTHKIACEGr1F2xBgmY4RwVvc81K/y1 XQotNalegCYooXItIStzHCN1O7JHb0+dsyEeWZQL75eyeht3Zg2MtRUTmHXvIRhYgVg0 GXxZ3BZ+JFZUxwSGxhB7J40+Z1R0dLKDGIniG4I0GXt/Z3SyhoEpaP9KuHfZinwJqk66 +k7rB9WFhsuqKqHxe4NZrP+pA3JlKA6IXn2mPNezLRSwB7gMt0gXx+ppIfmkQscwG16t w0cA== 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=KQqfMEKTkdZe1hIjg1RYOBYvpYkZsgZ9b781SjghlQo=; b=PcsVZy7iNygsULYoAeOsAeoFo0QkQNi9ixu74OMmKaWzZ1fE3QoZT+T2Xgq/aP7Ye1 784LFbVmueicnffxvgJMqUjLUex5ClOGsRldKW0wd80hrznjmOmfHhlTQdwKxlM84kmZ kwx4caRi8bT4eXCWaCN17yCW1fieBRevWQKpM72wp7y5BMYF8acs3zal8MiRe16yBYc8 AAbvdoXNWJCKgyS8fjaGPoCyUIHGm51AYHAiYJJ9gf6m5aikoKQTxjtxlkvlUom+XnmF 2cSw83e01gNXfWqcAgep7woomboZTuSzWuaO+TFjSNQ1FFXoPBrIiKzyiuR90HaF6MKh 7vug== X-Gm-Message-State: AGRZ1gJL+4OYsAa28jKPNlTaMUCLiz0Wfc1g9xYHvpzPsYtpniU3Wejf iCyF/ltFqsMBF56RpPjOV4KeopU4U/o= X-Google-Smtp-Source: AJdET5dMAo55GTAPcflSX/WeW1DYhdbGs0mt/TCbs+AHWEpETrpIcmKJS7ZrPWx2V2C3DLSnio+t1Q== X-Received: by 2002:a17:906:3712:: with SMTP id d18-v6mr12306307ejc.126.1542112415526; Tue, 13 Nov 2018 04:33:35 -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 h28-v6sm5298083ede.49.2018.11.13.04.33.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Nov 2018 04:33:34 -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: Tue, 13 Nov 2018 13:32:49 +0100 Message-Id: <1542112371-32546-7-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1542112371-32546-1-git-send-email-mw@semihalf.com> References: <1542112371-32546-1-git-send-email-mw@semihalf.com> Subject: [platforms: PATCH v5 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: Tue, 13 Nov 2018 12:33:37 -0000 X-List-Received-Date: Tue, 13 Nov 2018 12:33:37 -0000 X-List-Received-Date: Tue, 13 Nov 2018 12:33:37 -0000 X-List-Received-Date: Tue, 13 Nov 2018 12:33:37 -0000 X-List-Received-Date: Tue, 13 Nov 2018 12:33:37 -0000 X-List-Received-Date: Tue, 13 Nov 2018 12:33:37 -0000 X-List-Received-Date: Tue, 13 Nov 2018 12:33:37 -0000 X-List-Received-Date: Tue, 13 Nov 2018 12:33:37 -0000 X-List-Received-Date: Tue, 13 Nov 2018 12:33:37 -0000 X-List-Received-Date: Tue, 13 Nov 2018 12:33:37 -0000 X-List-Received-Date: Tue, 13 Nov 2018 12:33:37 -0000 X-List-Received-Date: Tue, 13 Nov 2018 12:33:37 -0000 X-List-Received-Date: Tue, 13 Nov 2018 12:33:37 -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 +++++++++++++------- 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