From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (EUR01-HE1-obe.outbound.protection.outlook.com []) by mx.groups.io with SMTP id smtpd.web11.29383.1590731602469379720 for ; Thu, 28 May 2020 22:53:23 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@nxp1.onmicrosoft.com header.s=selector2-nxp1-onmicrosoft-com header.b=Rp2MdZUL; spf=fail (domain: oss.nxp.com, ip: , mailfrom: pankaj.bansal@oss.nxp.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XYTSYRDVvufj5z3XGUjRvqiq79bZV2wEQhFCYdng8zb3WMlBbPX65F66OzyOLld07sjUgsgzjkTgZLZ0m9jXsLJHkiHX1CgbbhxBhgfdeOzO7sYDM0HdTn/9C4P7LE3Y7F55cIUnBUYy1dAfcVAYjcH8O99iBPWmEByfCiWbW4oryPPwOgM96rm0h5lAkJ4JQSq3aIDRaPv+DPIAX3DKYn6Qzv936FMnO1sFJroTkteXAyYWqxy4Sr1IaYQ4G6UJ9dC/VZYEn1m8BpGeLAZQkaq0giHqw98rQIskSMibIbzJPl0kl+vL+QAtyRYaKgKQ1knHiJNHICPNfqPXt/BYFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qmLwzf9qCXYsFlb0t8Z9yEMvcIi59e4t2h6rUGk2pRU=; b=XR1beNCsW0vV5jl/H07gS+kAeBTzo4aaW6rMjF8RHV1hKim1FPnXYt+x6/Z2WKz0w9Xk8+WnMnMbw288ge59X8qbOVgW18oJIZEscoimbLlvJ4iAw5Pk/iX43TxyxPbXpcB7HmIYIip2EMrcRbJqnytFBq/ceoh4un3jSysgq8BS70dBQUUj5klx5qhBrPUzYd3gnWI5YNTDsV6aOxDPLWHtzyTFy7vyqK6tOMUYboqYPHGX0stcAlmmdX8JCMajiL6c+/GVctcFMbDplD2bRpRMdwGr6cItMRC2cvvO/DIJ9wRaJdgNhCaG3dw7/UrxbHUBs6yT8WNnW0IR7riA2A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qmLwzf9qCXYsFlb0t8Z9yEMvcIi59e4t2h6rUGk2pRU=; b=Rp2MdZULCmQBxvtV7yjGgUk2/0hmYWJ2MJThUAuscITL2OyHiChSVhMQPx/T47TFh2lSlT+tWuI9ctS9n+3/Lc6rzKteglWFYZUbMospfmmcv+qVvYZSUy7rOl83t9RMoV30jL4+TQg07cMhNwG+EqR/QS18COzPubRMcIoJpYA= Authentication-Results: nuviainc.com; dkim=none (message not signed) header.d=none;nuviainc.com; dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5933.eurprd04.prod.outlook.com (2603:10a6:803:ec::16) by VI1PR04MB5598.eurprd04.prod.outlook.com (2603:10a6:803:e9::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3045.19; Fri, 29 May 2020 05:53:21 +0000 Received: from VI1PR04MB5933.eurprd04.prod.outlook.com ([fe80::45c4:8846:5327:9513]) by VI1PR04MB5933.eurprd04.prod.outlook.com ([fe80::45c4:8846:5327:9513%7]) with mapi id 15.20.3045.018; Fri, 29 May 2020 05:53:21 +0000 From: "Pankaj Bansal" To: Leif Lindholm , Meenakshi Aggarwal , Michael D Kinney , devel@edk2.groups.io, Varun Sethi , Samer El-Haj-Mahmoud , Jon Nettleton , Ard Biesheuvel Subject: [PATCH edk2-platforms v3 05/10] Platform/NXP/LX2160ARDB: Add ArmPlatformLib Date: Fri, 29 May 2020 11:21:44 +0530 Message-ID: <20200529055149.30953-6-pankaj.bansal@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200529055149.30953-1-pankaj.bansal@oss.nxp.com> References: <20200529055149.30953-1-pankaj.bansal@oss.nxp.com> X-ClientProxiedBy: SG2PR01CA0112.apcprd01.prod.exchangelabs.com (2603:1096:4:40::16) To VI1PR04MB5933.eurprd04.prod.outlook.com (2603:10a6:803:ec::16) Return-Path: pankaj.bansal@oss.nxp.com MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from uefi-workstation.ap.freescale.net (92.120.0.69) by SG2PR01CA0112.apcprd01.prod.exchangelabs.com (2603:1096:4:40::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3045.19 via Frontend Transport; Fri, 29 May 2020 05:53:19 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [92.120.0.69] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 1beb72b6-8acc-436e-cd0a-08d80394980c X-MS-TrafficTypeDiagnostic: VI1PR04MB5598: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-Forefront-PRVS: 04180B6720 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jt0ZrtXmiEKPMKsS/D62nRFvxc08CopKptzuC3ASmKld+nxr3WfvWDhKyB0znEPcvAI+8MK4Z1IFJVKNqC9QVQ4ipFhA+CblcxGhEmBEzAwUVgJZvj+wdkK7ygcEg67uqi0RDO89WlZFGX06eFvaBaIPNRvG/9OI7Z1ypeB4NzA/ieye+Rk18+R/9l9fje9aFztar1gp6BTrqNrGj0+SCtve0ImFp4vXt2RxyX2ba/MGq150yYuJeI3J1PZNxUYFQ9kbB4bxeCisJ4t+y/s8zh6c3JkQ1ZwKaqr1KsNQB8FmbulzkXnZcpv9rnPivCiwMhN7URd7voH9ZdptaBoWYw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5933.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(366004)(136003)(39860400002)(396003)(376002)(346002)(110136005)(316002)(52116002)(66946007)(66476007)(66556008)(2906002)(6666004)(86362001)(1076003)(83380400001)(8936002)(5660300002)(8676002)(19627235002)(956004)(44832011)(2616005)(6486002)(6512007)(6506007)(16526019)(186003)(478600001)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: yvnbj4xDZ5QyqLkZFhKVRbG0ouXwpueYjz9WZIn0jO8Qb3QFQL9rQnTjKnbLh0lTTFA0CcRnUbp8ahYJshS4VlNftWl64rIEqmkjJeExF/gKMyZzQmN5MFMQhlfSrz5kodCUrqzXrdYkm1aLgfCqQnFqwIjQ+LvQ2IoTV50p2gUphvEyQG908+QWIItF9y2ZvqPo/fzbybT7/X5u+zM/E4A/mxsPub6mBJ9b4aSqPwqEnEUYJSWMxomGXP3NyYjHMpn9nBFCvAIrQqA5tYxWFau1L6GHdogzB1r49GD+7JZ6vJZaIM73AfZA5BuvJbpNqSfuzy3DypX5xV9wqhPtJufDjWkkHguPOncoTA7R99kWfrB2iOvCC8QMMW3rufSeyxMZcaWYIcx68OgxfOA1UVvJ0w3ElAgVoghXgGiF8kaK5W7GPZ+y4KGcC/JWdV/3xdZ6LyLm84OSzKUJTdaOBkDgGEDOtuMols/y+UKqFK0= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1beb72b6-8acc-436e-cd0a-08d80394980c X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2020 05:53:21.6722 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: sa9YqNgi4XxKIjcz8jsvqhVfuY+iCeYNaHsxj80mvrEnuWiMBeKGqjgn9CWtlhnLbOrHmnzd5QeYKISN0PFyJg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5598 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain From: Pankaj Bansal Add ArmPlatformLib for LX2160ARDB platform that is based on ArmPlatformPkg/Library/ArmPlatformLibNull. Apart from the the interfaces exposed by ArmPlatformLibNull, this library also implements gPlatformGetClockPpi, which is specific to NXP SOCs' based platforms. Refer edk2-platforms/Silicon/NXP/Include/Ppi/NxpPlatformGetClock.h for the details. Signed-off-by: Pankaj Bansal Reviewed-by: Leif Lindholm --- Notes: V3: - No change =20 V2: - New commit - split Platform/NXP/LX2160aRdbPkg/Library/ArmPlatformLib/ in two parts part containing gPlatformGetClockPpi is put before PL011UartClockLib implementation. Platform/NXP/LX2160aRdbPkg/Library/ArmPlatformLib/ArmPlatformLib.inf = | 39 ++++++ Platform/NXP/LX2160aRdbPkg/Library/ArmPlatformLib/ArmPlatformLib.c = | 145 ++++++++++++++++++++ Platform/NXP/LX2160aRdbPkg/Library/ArmPlatformLib/ArmPlatformLibMem.c = | 28 ++++ Platform/NXP/LX2160aRdbPkg/Library/ArmPlatformLib/AArch64/ArmPlatformHelpe= r.S | 45 ++++++ 4 files changed, 257 insertions(+) diff --git a/Platform/NXP/LX2160aRdbPkg/Library/ArmPlatformLib/ArmPlatformL= ib.inf b/Platform/NXP/LX2160aRdbPkg/Library/ArmPlatformLib/ArmPlatformLib.i= nf new file mode 100644 index 000000000000..743836e57141 --- /dev/null +++ b/Platform/NXP/LX2160aRdbPkg/Library/ArmPlatformLib/ArmPlatformLib.inf @@ -0,0 +1,39 @@ +#/* @file +# Copyright 2018, 2020 NXP +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +#*/ + +[Defines] + INF_VERSION =3D 0x0001001A + BASE_NAME =3D PlatformLib + FILE_GUID =3D d1361285-8a47-421c-9efd-6b262c9093fc + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D ArmPlatformLib + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + ArmPkg/ArmPkg.dec + ArmPlatformPkg/ArmPlatformPkg.dec + Silicon/NXP/NxpQoriqLs.dec + +[LibraryClasses] + ArmLib + DebugLib + +[Sources.common] + ArmPlatformLib.c + ArmPlatformLibMem.c + +[Sources.AArch64] + AArch64/ArmPlatformHelper.S + +[FixedPcd] + gArmTokenSpaceGuid.PcdArmPrimaryCoreMask + gArmTokenSpaceGuid.PcdArmPrimaryCore + +[Ppis] + gArmMpCoreInfoPpiGuid diff --git a/Platform/NXP/LX2160aRdbPkg/Library/ArmPlatformLib/ArmPlatformL= ib.c b/Platform/NXP/LX2160aRdbPkg/Library/ArmPlatformLib/ArmPlatformLib.c new file mode 100644 index 000000000000..806cfd180bee --- /dev/null +++ b/Platform/NXP/LX2160aRdbPkg/Library/ArmPlatformLib/ArmPlatformLib.c @@ -0,0 +1,145 @@ +/** @file +* +* Copyright 2018-2020 NXP +* +* SPDX-License-Identifier: BSD-2-Clause-Patent +* +**/ + +#include +#include + +#include +#include + +ARM_CORE_INFO mLX2160aMpCoreInfoTable[] =3D { + { + // Cluster 0, Core 0 + 0x0, 0x0, + + // MP Core MailBox Set/Get/Clear Addresses and Clear Value + (EFI_PHYSICAL_ADDRESS)0, + (EFI_PHYSICAL_ADDRESS)0, + (EFI_PHYSICAL_ADDRESS)0, + (UINT64)0xFFFFFFFF + } +}; + +/** + Return the current Boot Mode + + This function returns the boot reason on the platform + +**/ +EFI_BOOT_MODE +ArmPlatformGetBootMode ( + VOID + ) +{ + return BOOT_WITH_FULL_CONFIGURATION; +} + +/** + Get the clocks supplied by Platform(Board) to NXP Layerscape SOC IPs + + @param[in] ClockType Variable of Type NXP_IP_CLOCK. Indicates which IP= clock + is to be retrieved. + @param[in] ... Variable argument list which is parsed based on + ClockType. e.g. if the ClockType is NXP_I2C_CLOCK= , then + the second argument will be interpreted as contro= ller + number. + if ClockType is NXP_CORE_CLOCK, then second argum= ent + is interpreted as cluster number and third argume= nt is + interpreted as core number (within the cluster) + + @return Actual Clock Frequency. Return value 0 should be + interpreted as clock not being provided to IP. +**/ +UINT64 +EFIAPI +NxpPlatformGetClock( + IN UINT32 ClockType, + ... + ) +{ + UINT64 Clock; + VA_LIST Args; + + Clock =3D 0; + + VA_START (Args, ClockType); + + switch (ClockType) { + case NXP_SYSTEM_CLOCK: + Clock =3D 100 * 1000 * 1000; // 100 MHz + break; + case NXP_I2C_CLOCK: + case NXP_UART_CLOCK: + Clock =3D NxpPlatformGetClock (NXP_SYSTEM_CLOCK); + break; + default: + break; + } + + VA_END (Args); + + return Clock; +} + +/** + Initialize controllers that must setup in the normal world + + This function is called by the ArmPlatformPkg/PrePi or ArmPlatformPkg/Pl= atformPei + in the PEI phase. + +**/ +EFI_STATUS +ArmPlatformInitialize ( + IN UINTN MpId + ) +{ + //TODO: Implement me + + return EFI_SUCCESS; +} + +EFI_STATUS +PrePeiCoreGetMpCoreInfo ( + OUT UINTN *CoreCount, + OUT ARM_CORE_INFO **ArmCoreTable + ) +{ + if (ArmIsMpCore()) { + *CoreCount =3D sizeof(mLX2160aMpCoreInfoTable) / sizeof(ARM_CORE_IN= FO); + *ArmCoreTable =3D mLX2160aMpCoreInfoTable; + return EFI_SUCCESS; + } else { + return EFI_UNSUPPORTED; + } +} + +ARM_MP_CORE_INFO_PPI mMpCoreInfoPpi =3D { PrePeiCoreGetMpCoreInfo }; +NXP_PLATFORM_GET_CLOCK_PPI gPlatformGetClockPpi =3D { NxpPlatformGetClock = }; + +EFI_PEI_PPI_DESCRIPTOR gPlatformPpiTable[] =3D { + { + EFI_PEI_PPI_DESCRIPTOR_PPI, + &gArmMpCoreInfoPpiGuid, + &mMpCoreInfoPpi + } +}; + +VOID +ArmPlatformGetPlatformPpiList ( + OUT UINTN *PpiListSize, + OUT EFI_PEI_PPI_DESCRIPTOR **PpiList + ) +{ + if (ArmIsMpCore()) { + *PpiListSize =3D sizeof(gPlatformPpiTable); + *PpiList =3D gPlatformPpiTable; + } else { + *PpiListSize =3D 0; + *PpiList =3D NULL; + } +} diff --git a/Platform/NXP/LX2160aRdbPkg/Library/ArmPlatformLib/ArmPlatformL= ibMem.c b/Platform/NXP/LX2160aRdbPkg/Library/ArmPlatformLib/ArmPlatformLibM= em.c new file mode 100644 index 000000000000..ad6862dd81eb --- /dev/null +++ b/Platform/NXP/LX2160aRdbPkg/Library/ArmPlatformLib/ArmPlatformLibMem.c @@ -0,0 +1,28 @@ +/** @file +* +* Copyright 2018, 2020 NXP +* +* SPDX-License-Identifier: BSD-2-Clause-Patent +* +**/ + +#include +#include + +/** + Return the Virtual Memory Map of your platform + + This Virtual Memory Map is used by MemoryInitPei Module to initialize th= e MMU on your platform. + + @param[out] VirtualMemoryMap Array of ARM_MEMORY_REGION_DESCRIPTOR = describing a Physical-to- + Virtual Memory mapping. This array mus= t be ended by a zero-filled + entry + +**/ +VOID +ArmPlatformGetVirtualMemoryMap ( + IN ARM_MEMORY_REGION_DESCRIPTOR** VirtualMemoryMap + ) +{ + ASSERT(0); +} diff --git a/Platform/NXP/LX2160aRdbPkg/Library/ArmPlatformLib/AArch64/ArmP= latformHelper.S b/Platform/NXP/LX2160aRdbPkg/Library/ArmPlatformLib/AArch64= /ArmPlatformHelper.S new file mode 100644 index 000000000000..b7c6dbdc2e61 --- /dev/null +++ b/Platform/NXP/LX2160aRdbPkg/Library/ArmPlatformLib/AArch64/ArmPlatform= Helper.S @@ -0,0 +1,45 @@ +// +// Copyright (c) 2012-2013, ARM Limited. All rights reserved. +// +// SPDX-License-Identifier: BSD-2-Clause-Patent +// +// + +#include +#include + +ASM_FUNC(ArmPlatformPeiBootAction) + ret + +//UINTN +//ArmPlatformGetCorePosition ( +// IN UINTN MpId +// ); +// With this function: CorePos =3D (ClusterId * 4) + CoreId +ASM_FUNC(ArmPlatformGetCorePosition) + and x1, x0, #ARM_CORE_MASK + and x0, x0, #ARM_CLUSTER_MASK + add x0, x1, x0, LSR #6 + ret + +//UINTN +//ArmPlatformGetPrimaryCoreMpId ( +// VOID +// ); +ASM_FUNC(ArmPlatformGetPrimaryCoreMpId) + MOV32 (w0, FixedPcdGet32 (PcdArmPrimaryCore)) + ret + +//UINTN +//ArmPlatformIsPrimaryCore ( +// IN UINTN MpId +// ); +ASM_FUNC(ArmPlatformIsPrimaryCore) + MOV32 (w1, FixedPcdGet32 (PcdArmPrimaryCoreMask)) + and x0, x0, x1 + MOV32 (w1, FixedPcdGet32 (PcdArmPrimaryCore)) + cmp w0, w1 + mov x0, #1 + mov x1, #0 + csel x0, x0, x1, eq + ret --=20 2.17.1