From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: None (no SPF record) identity=mailfrom; client-ip=2a00:1450:4010:c07::242; helo=mail-lf0-x242.google.com; envelope-from=mw@semihalf.com; receiver=edk2-devel@lists.01.org Received: from mail-lf0-x242.google.com (mail-lf0-x242.google.com [IPv6:2a00:1450:4010:c07::242]) (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 6BC0821106F24 for ; Fri, 8 Jun 2018 08:34:44 -0700 (PDT) Received: by mail-lf0-x242.google.com with SMTP id n3-v6so20688034lfe.12 for ; Fri, 08 Jun 2018 08:34:44 -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=y0dClf/wZRq0Kd5fFTMNat+aU6qlw58nwjAuYXqWz94=; b=iZIp1IOzzdPhMGTRonpvPAZxif95P5/ZKBVy5Wzr9vPpcAHUIBffByQ8vQwmAv/Zz7 hxVUfKw/KNZ1U9KmtUaH6reNXl/5YeW7+BF4U1aOwlrWyBFMxVSOD5vOK50BuXIs4MZc 8AAYFwCx+A6j66q/+5gEm3ztJ70AhZzd+un+Csi+8r6xGVsz1eebksuP4WfH36TJAL43 qJYYUsk6+0E3i/7NRZKnFE/NkQTf1z2zzz9fhJZF82WaKLbdp0yEzSlmBTPfjnTyfanl pvMkW2uByn6ubGxQurLUpmDEaXM848ybF9y224q3bESgh/ov/Q0hL0rgIXa/CxlIlsrX mKmg== 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=y0dClf/wZRq0Kd5fFTMNat+aU6qlw58nwjAuYXqWz94=; b=n7b46gJq32BUxBV4mGevU2QsIRkvU3qB32wadHEMQZw0fE3VnWkCX5nI2kt3K5T0OC XeEOM2b3qpaMtdPqcL3gbb0ZEH201nZ8y6xcap3GlkkfqUwYHJzsEhGhKRHQ1+OujBOe kEkk/unPu8bjlrkc+a2qgH0eIhHhVr0eP1O3MNqfPntodB2Ut2zfRjuIxvtdt6YEEtFR V4UxO1UuJ3s9y2J7YHgR0uQjQRbL2P/43wcaNFdOcVBf1PKKW3Klzs/vFaAXt5AQnmwD 6utIgJ5wGNLLpITPJAaKTyxPyNssh2A4ho+yVZESQzv+cGiPraWPrRiwHn+L9O99b1OC bZOA== X-Gm-Message-State: APt69E33UBUxveNZilAcjhDc5Yb0BWjOH2JATaySJfwD3Ay2Jl+uUXlT voZ+qF9ikJhTNyKxrqBfhaYA0qOjJpA= X-Google-Smtp-Source: ADUXVKKDNV7E52opXD46Any4+3YZUF5QJeCkBSoLXlZ3DhtUwvxFM2VTkUrvc5L6ss9+OfbEmhOVeA== X-Received: by 2002:a19:d245:: with SMTP id j66-v6mr4498600lfg.139.1528472082317; Fri, 08 Jun 2018 08:34:42 -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 v79-v6sm7355396lfd.32.2018.06.08.08.34.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 08 Jun 2018 08:34:41 -0700 (PDT) From: Marcin Wojtas To: edk2-devel@lists.01.org Cc: leif.lindholm@linaro.org, ard.biesheuvel@linaro.org, nadavh@marvell.com, jinghua@marvell.com, mw@semihalf.com, jsd@semihalf.com, jaz@semihalf.com Date: Fri, 8 Jun 2018 17:33:59 +0200 Message-Id: <1528472063-1660-2-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1528472063-1660-1-git-send-email-mw@semihalf.com> References: <1528472063-1660-1-git-send-email-mw@semihalf.com> Subject: [platforms PATCH 01/25] Marvell/Library: Introduce ArmadaSoCDescLib class 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: , X-List-Received-Date: Fri, 08 Jun 2018 15:34:45 -0000 From: jinghua ArmadaSoCDescLib is a per SoC family library, which provides SoC description, like register base of some hardware module controller, COMPHY/I2C/NETWORK etc., which right now is hardcoded in MvHwDescLib.h. There will be a new protocol, which gets SoC description from this library, and provides board description based on enable/disable values of each hardware module controller in dsc file. As a first example implement obtaining UTMI controllers information. Remaining interfaces will be added in follow-up commits. This patch introduces new library callback (ArmadaSoCDescUtmiGet ()), which dynamically allocates and fills MV_SOC_UTMI_DESC structure, SoC description of UTMI PHYs. A new PCD is introduced (PcdMaxCpCount) which stores maximal amount of CP110 blocks in the SoC family. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: jinghua Signed-off-by: Marcin Wojtas --- Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.c | 78 ++++++++++++++++++++ Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.inf | 37 ++++++++++ Silicon/Marvell/Include/Library/ArmadaSoCDescLib.h | 33 +++++++++ Silicon/Marvell/Marvell.dec | 4 + 4 files changed, 152 insertions(+) diff --git a/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.c b/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.c new file mode 100644 index 0000000..0ee943b --- /dev/null +++ b/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.c @@ -0,0 +1,78 @@ +/** +* +* Copyright (C) 2018, Marvell International Ltd. and its affiliates. +* +* This program and the accompanying materials are licensed and made available +* under the terms and conditions of the BSD License which accompanies this +* distribution. The full text of the license may be found at +* http://opensource.org/licenses/bsd-license.php +* +* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +* +* Glossary - abbreviations used in Marvell SampleAtReset library implementation: +* AP - Application Processor hardware block (Armada 7k8k incorporates AP806) +* CP - South Bridge hardware blocks (Armada 7k8k incorporates CP110) +**/ + +#include + +#include +#include +#include +#include +#include +#include + +#include + +// +// Common macros +// +#define MV_SOC_CP_BASE(Cp) (0xF2000000 + (Cp) * 0x2000000) + +// +// Platform description of UTMI PHY's +// +#define MV_SOC_UTMI_PER_CP_COUNT 2 +#define MV_SOC_UTMI_ID(Utmi) (Utmi) +#define MV_SOC_UTMI_BASE(Utmi) (0x580000 + (Utmi) * 0x1000) +#define MV_SOC_UTMI_CFG_BASE 0x440440 +#define MV_SOC_UTMI_USB_CFG_BASE 0x440420 + +EFI_STATUS +EFIAPI +ArmadaSoCDescUtmiGet ( + IN OUT MV_SOC_UTMI_DESC **UtmiDesc, + IN OUT UINT8 *DescCount + ) +{ + MV_SOC_UTMI_DESC *Desc; + UINT8 CpCount = FixedPcdGet8 (PcdMaxCpCount); + UINT8 Index, CpIndex, UtmiIndex = 0; + + Desc = AllocateZeroPool (CpCount * MV_SOC_UTMI_PER_CP_COUNT * + sizeof (MV_SOC_UTMI_DESC)); + if (Desc == NULL) { + DEBUG ((DEBUG_ERROR, "%a: Cannot allocate memory\n", __FUNCTION__)); + return EFI_OUT_OF_RESOURCES; + } + + for (CpIndex = 0; CpIndex < CpCount; CpIndex++) { + for (Index = 0; Index < MV_SOC_UTMI_PER_CP_COUNT; Index++) { + Desc[UtmiIndex].UtmiPhyId = MV_SOC_UTMI_ID (UtmiIndex); + Desc[UtmiIndex].UtmiBaseAddress = + MV_SOC_CP_BASE (CpIndex) + MV_SOC_UTMI_BASE (Index); + Desc[UtmiIndex].UtmiConfigAddress = + MV_SOC_CP_BASE (CpIndex) + MV_SOC_UTMI_CFG_BASE; + Desc[UtmiIndex].UsbConfigAddress = + MV_SOC_CP_BASE (CpIndex) + MV_SOC_UTMI_USB_CFG_BASE; + UtmiIndex++; + } + } + + *UtmiDesc = Desc; + *DescCount = UtmiIndex; + + return EFI_SUCCESS; +} diff --git a/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.inf b/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.inf new file mode 100644 index 0000000..e993878 --- /dev/null +++ b/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.inf @@ -0,0 +1,37 @@ +## @file +# +# Copyright (C) 2018, Marvell International Ltd. and its affiliates
+# +# This program and the accompanying materials are licensed and made available +# under the terms and conditions of the BSD License which accompanies this +# distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR +# IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010019 + BASE_NAME = Armada7k8kDescLib + FILE_GUID = c64f0048-4ca3-4573-b0a6-c2e9e6457285 + MODULE_TYPE = BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = ArmadaSoCDescLib + +[Sources] + Armada7k8kSoCDescLib.c + +[Packages] + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + Silicon/Marvell/Marvell.dec + +[LibraryClasses] + DebugLib + IoLib + PcdLib + +[FixedPcd] + gMarvellTokenSpaceGuid.PcdMaxCpCount diff --git a/Silicon/Marvell/Include/Library/ArmadaSoCDescLib.h b/Silicon/Marvell/Include/Library/ArmadaSoCDescLib.h new file mode 100644 index 0000000..22f5c17 --- /dev/null +++ b/Silicon/Marvell/Include/Library/ArmadaSoCDescLib.h @@ -0,0 +1,33 @@ +/** +* +* Copyright (C) 2018, Marvell International Ltd. and its affiliates +* +* This program and the accompanying materials are licensed and made available +* under the terms and conditions of the BSD License which accompanies this +* distribution. The full text of the license may be found at +* http://opensource.org/licenses/bsd-license.php +* +* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +* +**/ +#ifndef __ARMADA_SOC_DESC_LIB_H__ +#define __ARMADA_SOC_DESC_LIB_H__ + +// +// UTMI PHY devices SoC description +// +typedef struct { + UINT8 UtmiPhyId; + UINTN UtmiBaseAddress; + UINTN UtmiConfigAddress; + UINTN UsbConfigAddress; +} MV_SOC_UTMI_DESC; + +EFI_STATUS +EFIAPI +ArmadaSoCDescUtmiGet ( + IN OUT MV_SOC_UTMI_DESC **UtmiDesc, + IN OUT UINT8 *DescCount + ); +#endif /* __ARMADA_SOC_DESC_LIB_H__ */ diff --git a/Silicon/Marvell/Marvell.dec b/Silicon/Marvell/Marvell.dec index be74b4e..2a92eff 100644 --- a/Silicon/Marvell/Marvell.dec +++ b/Silicon/Marvell/Marvell.dec @@ -60,6 +60,7 @@ gMarvellSpiFlashDxeGuid = { 0x49d7fb74, 0x306d, 0x42bd, { 0x94, 0xc8, 0xc0, 0xc5, 0x4b, 0x18, 0x1d, 0xd7 } } [LibraryClasses] + ArmadaSoCDescLib|Include/Library/ArmadaSoCDescLib.h SampleAtResetLib|Include/Library/SampleAtResetLib.h [Protocols] @@ -68,6 +69,9 @@ gMarvellPlatformInitCompleteProtocolGuid = { 0x465b8cf7, 0x016f, 0x4ba6, { 0xbe, 0x6b, 0x28, 0x0e, 0x3a, 0x7d, 0x38, 0x6f } } [PcdsFixedAtBuild.common] +#Board description + gMarvellTokenSpaceGuid.PcdMaxCpCount|0x2|UINT8|0x30000072 + #MPP gMarvellTokenSpaceGuid.PcdMppChipCount|0|UINT32|0x30000001 -- 2.7.4