From nobody Mon Sep 16 18:52:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1529266361081695.6065618516064; Sun, 17 Jun 2018 13:12:41 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 94DBC2096FADA; Sun, 17 Jun 2018 13:12:34 -0700 (PDT) Received: from mail-lf0-x241.google.com (mail-lf0-x241.google.com [IPv6:2a00:1450:4010:c07::241]) (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 3D665209605C7 for ; Sun, 17 Jun 2018 13:12:33 -0700 (PDT) Received: by mail-lf0-x241.google.com with SMTP id p23-v6so9859789lfh.11 for ; Sun, 17 Jun 2018 13:12:33 -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 q75-v6sm387272lfq.47.2018.06.17.13.12.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 17 Jun 2018 13:12:30 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: None (no SPF record) identity=mailfrom; client-ip=2a00:1450:4010:c07::241; helo=mail-lf0-x241.google.com; envelope-from=mw@semihalf.com; receiver=edk2-devel@lists.01.org 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=OX506bKF0y6Un0Dq3tLGxcjtvYVs/ZxFA6HsOmmjtHo=; b=bKSXtVnTDimfsNrcL/XOK0l4LkMQzvle2mGSmg08X38mfbRSlwD4TJcl0AcTYgKM6T yvLwKM57HfR7MN6/TT7w0Q394JByYJxj/tz6sOmntPq5PbrKBeXBKYoKKRxUJL7JAPnF 0tGfZj+ms8sbQpgxpMSHP6OZT/acyH755eIPb0AVjtLb0j2/vF/MWeFf+J30HliWpdNT XvQe5IWehxTS9QyTnp5b9y3Ip22vC+ss3/trz3J1xyLX0cydBy/8p5dPSdZ4DctGIhsS EEtXrtcwENIRxYgre/yR8uKKpXvOfQJUnMpnOOJXdi2DzaYdX66Vj9CE1ZzLUS04RsNy Ss7A== 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=OX506bKF0y6Un0Dq3tLGxcjtvYVs/ZxFA6HsOmmjtHo=; b=FIbya94qmZeWpmM6WGdX8TmXMurNgALyrecZK5CGhwKUwcrrWvss4cdzoqj2NNMyJx xGqJKjg7kT6LNkces3YzhKf30N4tANe6bogslXh2I5MkVJFtl3tkfdd4V1b2iI7yBB8B oHyemC80R0q9gKFrJ6Iex7q+wa0EJMWfMy/95rC0Uw5COEi05p+rH2jVYM41/akx59JG qoG8Coghu+R/83mfFDn36pOJQRy7Tvo0xOVsrR02VZPYwaXb8+4M3V5UV3KVdI6I+/Kr GFlm20cZpcUGwHS3GYIOLU5Y/W2XuuWL+FyreVsVSOv9OZidQl0ijKASQuYEn7akhlc/ fT3A== X-Gm-Message-State: APt69E1w8LbMEEADs9ZEbdsd0YS6uc9rXfysvmpQAWshCmBNO9v4IFva XpjK9ZZ992bzXe3wmRHQaBgHi/vTO0s= X-Google-Smtp-Source: ADUXVKLRnLmo99eY49WuJqmQpvBeOwy0gSK0DT0eYAdMMDLRuuhTEBxQAm7T783b2J1QSOAHESrCrA== X-Received: by 2002:a2e:1414:: with SMTP id u20-v6mr6535390ljd.134.1529266351248; Sun, 17 Jun 2018 13:12:31 -0700 (PDT) From: Marcin Wojtas To: edk2-devel@lists.01.org Date: Sun, 17 Jun 2018 22:11:44 +0200 Message-Id: <1529266325-18371-5-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1529266325-18371-1-git-send-email-mw@semihalf.com> References: <1529266325-18371-1-git-send-email-mw@semihalf.com> Subject: [edk2] [platforms: PATCH v2 04/25] Marvell/Drivers: MvBoardDesc: Introduce board description driver X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jinghua@marvell.com, ard.biesheuvel@linaro.org, jaz@semihalf.com, leif.lindholm@linaro.org, nadavh@marvell.com MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: jinghua This patch introduces a producer of MARVELL_BOARD_DESC_PROTOCOL, which gets SoC description from ArmadaSoCDescLib, then based on dsc file, provide only enabled hardware module controllers for the consumers, which are typically controllers' drivers. Thanks to that there is a separation between obtaining the platform description and the drivers. A first example of the board description callback is information about UTMI controllers and type. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: jinghua Signed-off-by: Marcin Wojtas Reviewed-by: Leif Lindholm --- Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.inf | 65 ++++++++ Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.h | 57 +++++++ Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c | 176 +++++++++++++++= +++++ 3 files changed, 298 insertions(+) create mode 100644 Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.inf create mode 100644 Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.h create mode 100644 Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c diff --git a/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.inf b/Silicon= /Marvell/Drivers/BoardDesc/MvBoardDescDxe.inf new file mode 100644 index 0000000..5da5f21 --- /dev/null +++ b/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.inf @@ -0,0 +1,65 @@ +# +# Marvell BSD License Option +# +# If you received this File from Marvell, you may opt to use, redistribute +# and/or modify this File under the following licensing terms. +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are m= et: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# * Neither the name of Marvell nor the names of its contributors may be +# used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS = IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPO= SE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIA= BLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTI= AL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS = OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEV= ER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABI= LITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF TH= E USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +[Defines] + INF_VERSION =3D 0x0001001A + BASE_NAME =3D BoardDescDxe + FILE_GUID =3D 4ed385f9-5d2c-4774-95c5-d5d9d70b3c37 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D MvBoardDescEntryPoint + +[Sources] + MvBoardDescDxe.c + MvBoardDescDxe.h + +[Packages] + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + Silicon/Marvell/Marvell.dec + +[LibraryClasses] + ArmadaSoCDescLib + DebugLib + MemoryAllocationLib + UefiDriverEntryPoint + UefiLib + +[Protocols] + gMarvellBoardDescProtocolGuid + +[Pcd] + gMarvellTokenSpaceGuid.PcdPciEXhci + gMarvellTokenSpaceGuid.PcdUtmiControllersEnabled + gMarvellTokenSpaceGuid.PcdUtmiPortType + +[Depex] + TRUE diff --git a/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.h b/Silicon/M= arvell/Drivers/BoardDesc/MvBoardDescDxe.h new file mode 100644 index 0000000..2813f0d --- /dev/null +++ b/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.h @@ -0,0 +1,57 @@ +/*************************************************************************= ****** +Copyright (C) 2018 Marvell International Ltd. +Marvell BSD License Option + +If you received this File from Marvell, you may opt to use, redistribute a= nd/or +modify this File under the following licensing terms. +Redistribution and use in source and binary forms, with or without modific= ation, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +* Neither the name of Marvell nor the names of its contributors may be + used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS= " AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPL= IED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABL= E FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAM= AGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICE= S; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AN= D ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF T= HIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +**************************************************************************= *****/ +#ifndef __MV_BOARD_DESC_H__ +#define __MV_BOARD_DESC_H__ + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#define MV_BOARD_DESC_SIGNATURE SIGNATURE_64 ('M', 'V', 'B', 'R', 'D', 'D'= , 'S', 'C') + +typedef struct { + MARVELL_BOARD_DESC_PROTOCOL BoardDescProtocol; + UINTN Signature; + EFI_HANDLE Handle; + EFI_LOCK Lock; +} MV_BOARD_DESC; + +#endif // __MV_BOARD_DESC_H__ diff --git a/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c b/Silicon/M= arvell/Drivers/BoardDesc/MvBoardDescDxe.c new file mode 100644 index 0000000..0232a21 --- /dev/null +++ b/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c @@ -0,0 +1,176 @@ +/*************************************************************************= ****** +Copyright (C) 2018 Marvell International Ltd. + +Marvell BSD License Option + +If you received this File from Marvell, you may opt to use, redistribute a= nd/or +modify this File under the following licensing terms. +Redistribution and use in source and binary forms, with or without modific= ation, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +* Neither the name of Marvell nor the names of its contributors may be + used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS= " AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPL= IED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABL= E FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAM= AGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICE= S; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AN= D ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF T= HIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +**************************************************************************= *****/ +#include "MvBoardDescDxe.h" + +MV_BOARD_DESC *mBoardDescInstance; + +STATIC +EFI_STATUS +MvBoardDescUtmiGet ( + IN MARVELL_BOARD_DESC_PROTOCOL *This, + IN OUT MV_BOARD_UTMI_DESC **UtmiDesc + ) +{ + UINT8 *UtmiDeviceEnabled, *XhciDeviceEnabled, *UtmiPortType; + UINTN UtmiCount, UtmiDeviceTableSize, UtmiIndex, Index; + MV_BOARD_UTMI_DESC *BoardDesc; + MV_SOC_UTMI_DESC *SoCDesc; + EFI_STATUS Status; + + /* Get SoC data about all available UTMI controllers */ + Status =3D ArmadaSoCDescUtmiGet (&SoCDesc, &UtmiCount); + if (EFI_ERROR (Status)) { + return Status; + } + + /* + * Obtain table with enabled Utmi PHY's, + * which is represented as an array of UINT8 values + * (0x0 - disabled, 0x1 enabled). + */ + UtmiDeviceEnabled =3D PcdGetPtr (PcdUtmiControllersEnabled); + if (UtmiDeviceEnabled =3D=3D NULL) { + /* No UTMI PHY on platform */ + return EFI_SUCCESS; + } + + /* Make sure XHCI controllers table is present */ + XhciDeviceEnabled =3D PcdGetPtr (PcdPciEXhci); + if (XhciDeviceEnabled =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: Missing PcdPciEXhci\n", __FUNCTION__)); + return EFI_INVALID_PARAMETER; + } + + UtmiDeviceTableSize =3D PcdGetSize (PcdUtmiControllersEnabled); + + /* Check if PCD with UTMI PHYs is correctly defined */ + if ((UtmiDeviceTableSize > UtmiCount) || + (UtmiDeviceTableSize > PcdGetSize (PcdPciEXhci))) { + DEBUG ((DEBUG_ERROR, + "%a: Wrong PcdUtmiControllersEnabled format\n", + __FUNCTION__)); + return EFI_INVALID_PARAMETER; + } + + /* Obtain port type table - also stored as UINT8 array */ + UtmiPortType =3D PcdGetPtr (PcdUtmiPortType); + if ((UtmiPortType =3D=3D NULL) || + (PcdGetSize (PcdUtmiPortType) !=3D UtmiDeviceTableSize)) { + DEBUG ((DEBUG_ERROR, "%a: Wrong PcdUtmiPortType format\n", __FUNCTION_= _)); + return EFI_INVALID_PARAMETER; + } + + /* Allocate and fill board description */ + BoardDesc =3D AllocateZeroPool (UtmiDeviceTableSize * sizeof (MV_BOARD_U= TMI_DESC)); + if (BoardDesc =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: Cannot allocate memory\n", __FUNCTION__)); + return EFI_OUT_OF_RESOURCES; + } + + UtmiIndex =3D 0; + for (Index =3D 0; Index < UtmiDeviceTableSize; Index++) { + if (!UtmiDeviceEnabled[Index]) { + continue; + } + + /* UTMI PHY without enabled XHCI controller is useless */ + if (!XhciDeviceEnabled[Index]) { + DEBUG ((DEBUG_ERROR, + "%a: Disabled Xhci controller %d\n", + Index, + __FUNCTION__)); + return EFI_INVALID_PARAMETER; + } + + BoardDesc[UtmiIndex].SoC =3D &SoCDesc[Index]; + BoardDesc[UtmiIndex].UtmiPortType =3D UtmiPortType[Index]; + UtmiIndex++; + } + + BoardDesc->UtmiDevCount =3D UtmiIndex; + + *UtmiDesc =3D BoardDesc; + + return EFI_SUCCESS; +} + +STATIC +VOID +MvBoardDescFree ( + IN VOID *BoardDesc + ) +{ + FreePool (BoardDesc); +} + +STATIC +EFI_STATUS +MvBoardDescInitProtocol ( + IN MARVELL_BOARD_DESC_PROTOCOL *BoardDescProtocol + ) +{ + BoardDescProtocol->BoardDescUtmiGet =3D MvBoardDescUtmiGet; + BoardDescProtocol->BoardDescFree =3D MvBoardDescFree; + + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +MvBoardDescEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + mBoardDescInstance =3D AllocateZeroPool (sizeof (MV_BOARD_DESC)); + if (mBoardDescInstance =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + MvBoardDescInitProtocol (&mBoardDescInstance->BoardDescProtocol); + + mBoardDescInstance->Signature =3D MV_BOARD_DESC_SIGNATURE; + + Status =3D gBS->InstallMultipleProtocolInterfaces (&(mBoardDescInstance-= >Handle), + &gMarvellBoardDescProtocolGuid, + &(mBoardDescInstance->BoardDescProtocol)); + if (EFI_ERROR (Status)) { + FreePool (mBoardDescInstance); + return Status; + } + + return EFI_SUCCESS; +} --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel