From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR03-AM5-obe.outbound.protection.outlook.com (EUR03-AM5-obe.outbound.protection.outlook.com [40.107.3.41]) by mx.groups.io with SMTP id smtpd.web10.2240.1590569585958275842 for ; Wed, 27 May 2020 01:53:06 -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=ajPwlDDB; spf=pass (domain: oss.nxp.com, ip: 40.107.3.41, mailfrom: pankaj.bansal@oss.nxp.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=daapLLKuiDkkUcxb1nPYJhlgnGCkfHnkE2JHOkQZzOvp9cO0eVYEomfMZq0G9dV+AbZclG6ZNU5UmUQmHy6Ce0hd2Ie2mGOb+MxFgZdJnuP0Nvcb7npKS6QMlmyD7SLiAZ4HhB5JuHG0fZbDbpfP5valrfOeWeDuBcESKJuF0goJJ5CfviQ4xDzR972fC0YVKEWcIvYblAxO11mmj6TTpSue4nEerZoZuI5FrRrrlZvO+Qur/BNF1f37/Dg7UHS14l2fSviPNVBPH6f5TOpRModf44iklmgQO+Hh0RoP0DQdLV53wYaSY6Bej0x1J+cEylM8Lut/gaEKIS9j4hmmig== 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=cF6nqj4lxU4lFK+iZuNvb+9x7xlTFW52AlLWL14vS1Q=; b=DdceCBuxNILPCgnid0vtYrJ9QkoK2ZDaN/XCXmKKi4GM+SOYcLv0LRcKllvRWrfDjPZskbXhlqGllENCmpaX3m5tMb/mpz6jwsQVDupVL3e0GLyRQR38UVu/F+qvptiY/XPrdAEwJZcljDerk+e1iDL/O5Iq56joPWLgO8x6gztcLLgSn/gF7TLo0er1pH/91JrBN1lzEw56z5FCYmIUn+n58eSfdLJeHfA+FyGLHTm+W/+Ns1zjbt4ghy5g/Dl/RQlbU58CqJgl/NLYxc/ORPtlal0/NnLfCAblRU1qbrxLnDsXDXYf1l7KxAxoa8KHNnM0WRJeY47Uc9moCbdxYQ== 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=cF6nqj4lxU4lFK+iZuNvb+9x7xlTFW52AlLWL14vS1Q=; b=ajPwlDDBLTHs9C56ut9SuD3Vo6zG/ujqRRwSATpxOVo2Zx1LHTAUEHm8vg/54sM12mo0vdnu4Z5FYh7ioe9TXY0wHlsG5vuGVgcWNCGJ5KzxVM3K/DkXD+cvU6VPQxl6gQFtNrfAD6WUnU0bp2TvPmkIDJYrrSmYoy+p7/Cpb4I= 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 VI1PR04MB3181.eurprd04.prod.outlook.com (2603:10a6:802:a::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.27; Wed, 27 May 2020 08:53:03 +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.3021.030; Wed, 27 May 2020 08:53:03 +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 v2 4/9] Platform/NXP/LX2160ARDB: Add ArmPlatformLib Date: Wed, 27 May 2020 14:21:30 +0530 Message-ID: <20200527085135.16717-5-pankaj.bansal@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200527085135.16717-1-pankaj.bansal@oss.nxp.com> References: <20200527085135.16717-1-pankaj.bansal@oss.nxp.com> X-ClientProxiedBy: SG2PR01CA0164.apcprd01.prod.exchangelabs.com (2603:1096:4:28::20) 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 SG2PR01CA0164.apcprd01.prod.exchangelabs.com (2603:1096:4:28::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3045.17 via Frontend Transport; Wed, 27 May 2020 08:53:00 +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: 2a26a3c2-2375-46c5-afbe-08d8021b5d93 X-MS-TrafficTypeDiagnostic: VI1PR04MB3181: 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: 04163EF38A X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +kx2VNJwWrJQUooeer55ZL7X6B1qlcwNQYAA8LqX02i2EGfL/4aNORM5S+4QngNc8cboguAgON7pO8juVK4eqR4jseXtdomQrXyMokwD919mA4rIHRLi741VFqPBuniUwrEYCOeIrUtGejnkiyNpB8xwSAhB9pkMBrRH22RMbIbjH++r9A70x/D7a89LAOM8VF7LhURm0ZbT1UdytCtd9VxB/DAcPdEsN9zYE0e30oci65Md+7RD0PkKr20UrStRYjvjipbQ3bk7Jf2q78HXrKd497DZ1/PbGk7BS/sKKB6rQJ+sR4Kg66EH8TxaGH5NgLU+MeomKKfBoxHZFhXu2A== 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)(39860400002)(346002)(366004)(136003)(376002)(396003)(5660300002)(110136005)(2616005)(956004)(26005)(8936002)(66946007)(316002)(6666004)(186003)(2906002)(66476007)(16526019)(478600001)(44832011)(66556008)(6486002)(6506007)(52116002)(6512007)(19627235002)(8676002)(86362001)(1076003)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 3CSR1OXqQNMUK+SPWDChogSgN4coHZodfd1HEGA0lxuykLdgLlwOalzk9zaZTtxR3TfUeztLkvwA/BaSvxHmeEgUhTCQTmazlVPAJaVUT4RAuppzEsmVTr6KGx3hewwd+IDcmikOw1mACvaGE0oIFz3eT0MlPXRKd8HYN/37NJVLz5Aa5cb8WL2KCpEakDfSmmydjI4OIDO0d7uHYYbt/aioT+4KQuHn7RfLvREOf+LKSDkSNie7mYenOhKhNNt3Brs/Ea/ImY1IKBo9aZgMK+BSl52Ykvqsi5V+w62cMy0tHRsPcIKgPKvrp8zWSGmhDjARejBhgULlcEkqOSIIZVmnlpygrDec4wLQEqmWrWinZAPcbJV5QhVzoL5fxBtMWgLz5Lkfgau+RSAYUORzBlOahTFGYulsFWCyo+GAQPbASq4l1COrmUtJNmMhrtpYcm7dh+4fXwYWhSZ4nGn23fRoskMVl4HVEpjPVj2X8oc= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2a26a3c2-2375-46c5-afbe-08d8021b5d93 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 May 2020 08:53:03.2826 (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: 4G39pJaBk+aH8RdsTTuWOR5qe+KTI1FbtzxAaLI1gbwBo6XJyR43E9HTuN8Fb9UFA+I4l2oLsWtKHsPf3fNjGw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB3181 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 --- Notes: 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