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 3635121106F24 for ; Fri, 8 Jun 2018 08:34:52 -0700 (PDT) Received: by mail-lf0-x242.google.com with SMTP id q11-v6so20701056lfc.7 for ; Fri, 08 Jun 2018 08:34:52 -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=fD6IE7kjfrgHwtjMQb1JvtYoNiughwUxynn7ieL8sNg=; b=1iCI2K5NhAbM5PAKySktLuJrj9GoUuM7K8xPwPXtzQ1bIQvN0aMNuU43whjVXHkUVf va9AHo8xMhbYFMwJPwRBKUVwC/THBweW6JPMrLAOGS9x1ZnD0GMHKgjO1LIQbIMnRGQ1 U8qqsGh//h0PKbyza0AO437ppC8H4yiYHHc84zb4YXkNRkUhDDBjFK4hFM6ELj2xPdaN 8ScEnVVho2Enws2C+sGw/QFLhnJp29yYtcVL0lnxhRNsJW01zXEsizYKXm8FwSySlHGZ tUPBqYeTdtDNkozixuP8t3pTeq3nBj/uYeLNF98X6hhwbO2ebj3f2GFfCL9f7JjnWPaM qt1w== 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=fD6IE7kjfrgHwtjMQb1JvtYoNiughwUxynn7ieL8sNg=; b=IEtB5hdaDxIZAQorNrGW6Xk0Z110TmNQcADrk7nQhgCDUDmy6uZTalIt2Yvy3MyQU1 R2hp/O1lClTavY2QJSfW2d1FAW0dFi2ImGOQ2VQOmEWsMUm501pEu4ddLZkU90Lplx6J mAJ+d3gpufIMYX5MyEnE06RxQot/aKoA3DnOqti+ZbizLzv0C//6avhSFSB920r/Krdd i/G1LS59U8v16E/Gff5Q+wLF9LYGTzUmTirFLB+HRJJWespjs2k1lqz2k5JXpTd9ACqQ hX5vFTnh522EUae7o/CqgvBS/Z0LR4wDU6AlcDYyDkx6hhLrNYaDbRSg+yJyL4sRb8SC 1XHw== X-Gm-Message-State: APt69E10A5kS1vx6r74i68Yxf6rM/GoTaSOk+psS0UM7vKmpwpr8CqWq qCG4ChryEEWrzSxKwavm7qF6TWWKI+M= X-Google-Smtp-Source: ADUXVKI/9VuE2V8gMDTgyHFr7d4n5+wz1w6wBZiC0R2vdLke7yekFSDq28fmHMMRZMGNHHD9R0LreA== X-Received: by 2002:a19:5113:: with SMTP id f19-v6mr4405030lfb.13.1528472090224; Fri, 08 Jun 2018 08:34:50 -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.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 08 Jun 2018 08:34:49 -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:34:05 +0200 Message-Id: <1528472063-1660-8-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 07/25] Marvell/Library: RealTimeClockLib: Simplify obtaining base address 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:52 -0000 Hitherto mechanism of obtaining RTC base address proved to be not flexible enough to support more than one SoC family. Because there can be a single controller in use anyway, this patch drops utilization of MvHwDescLib header with hardcoded structure and replace it with simple UINT64 PCD. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Marcin Wojtas Reviewed-by: Hua Jing --- Platform/Marvell/Armada70x0Db/Armada70x0Db.dsc | 2 +- Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.c | 29 ++++---------------- Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.inf | 2 +- Silicon/Marvell/Include/Library/MvHwDescLib.h | 25 ----------------- Silicon/Marvell/Marvell.dec | 2 +- 5 files changed, 9 insertions(+), 51 deletions(-) diff --git a/Platform/Marvell/Armada70x0Db/Armada70x0Db.dsc b/Platform/Marvell/Armada70x0Db/Armada70x0Db.dsc index 46a1ea9..b51b6fb 100644 --- a/Platform/Marvell/Armada70x0Db/Armada70x0Db.dsc +++ b/Platform/Marvell/Armada70x0Db/Armada70x0Db.dsc @@ -134,4 +134,4 @@ gMarvellTokenSpaceGuid.PcdPciESdhci|{ 0x1, 0x1 } #RTC - gMarvellTokenSpaceGuid.PcdRtcEnabled|{ 0x1 } + gMarvellTokenSpaceGuid.PcdRtcBaseAddress|0xF2284000 diff --git a/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.c b/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.c index d671b6a..087bd9a 100644 --- a/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.c +++ b/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -34,7 +33,6 @@ #include #include "RealTimeClockLib.h" -DECLARE_A7K8K_RTC_TEMPLATE; STATIC EFI_EVENT mRtcVirtualAddrChangeEvent; STATIC UINTN mArmadaRtcBase; @@ -216,28 +214,13 @@ LibRtcInitialize ( IN EFI_SYSTEM_TABLE *SystemTable ) { - MVHW_RTC_DESC *Desc = &mA7k8kRtcDescTemplate; - UINT8 *RtcDeviceTable, Index; EFI_HANDLE Handle; EFI_STATUS Status; - // Pick RTC device and initialize its data - RtcDeviceTable = (UINT8 *) PcdGetPtr (PcdRtcEnabled); - if (RtcDeviceTable == NULL) { - DEBUG ((DEBUG_ERROR, "RTC: Missing PcdRtcEnabled\n")); - return EFI_INVALID_PARAMETER; - } - - // Initialize only first of enabled controllers - for (Index = 0; Index < PcdGetSize (PcdRtcEnabled); Index++) { - if (MVHW_DEV_ENABLED (Rtc, Index)) { - DEBUG ((DEBUG_ERROR, "RTC: Initialize controller %d\n", Index)); - mArmadaRtcBase = Desc->RtcBaseAddresses[Index]; - break; - } - } + // Obtain RTC device base address + mArmadaRtcBase = PcdGet64 (PcdRtcBaseAddress); - // Check if any of the controllers can be initialized + // Check if the controller can be initialized if (mArmadaRtcBase == 0) { DEBUG ((DEBUG_ERROR, "RTC: None of controllers enabled\n")); return EFI_INVALID_PARAMETER; @@ -247,7 +230,7 @@ LibRtcInitialize ( Status = gDS->AddMemorySpace ( EfiGcdMemoryTypeMemoryMappedIo, mArmadaRtcBase, - Desc->RtcMemSize[Index], + SIZE_4KB, EFI_MEMORY_UC | EFI_MEMORY_RUNTIME ); if (EFI_ERROR (Status)) { @@ -257,7 +240,7 @@ LibRtcInitialize ( Status = gDS->SetMemorySpaceAttributes ( mArmadaRtcBase, - Desc->RtcMemSize[Index], + SIZE_4KB, EFI_MEMORY_UC | EFI_MEMORY_RUNTIME ); if (EFI_ERROR (Status)) { @@ -304,7 +287,7 @@ LibRtcInitialize ( ErrEvent: gBS->UninstallProtocolInterface (Handle, &gEfiRealTimeClockArchProtocolGuid, NULL); ErrSetMem: - gDS->RemoveMemorySpace (mArmadaRtcBase, Desc->RtcMemSize[Index]); + gDS->RemoveMemorySpace (mArmadaRtcBase, SIZE_4KB); return Status; } diff --git a/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.inf b/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.inf index 59c71c4..1ecd444 100644 --- a/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.inf +++ b/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.inf @@ -49,7 +49,7 @@ gEfiEventVirtualAddressChangeGuid [Pcd] - gMarvellTokenSpaceGuid.PcdRtcEnabled + gMarvellTokenSpaceGuid.PcdRtcBaseAddress [Depex.common.DXE_RUNTIME_DRIVER] gEfiCpuArchProtocolGuid diff --git a/Silicon/Marvell/Include/Library/MvHwDescLib.h b/Silicon/Marvell/Include/Library/MvHwDescLib.h index e13814a..34d03d4 100644 --- a/Silicon/Marvell/Include/Library/MvHwDescLib.h +++ b/Silicon/Marvell/Include/Library/MvHwDescLib.h @@ -116,17 +116,6 @@ typedef struct { } MVHW_PP2_DESC; // -// RealTimeClock devices description template definition -// -#define MVHW_MAX_RTC_DEVS 2 - -typedef struct { - UINT8 RtcDevCount; - UINTN RtcBaseAddresses[MVHW_MAX_RTC_DEVS]; - UINTN RtcMemSize[MVHW_MAX_RTC_DEVS]; -} MVHW_RTC_DESC; - -// // Platform description of CommonPhy devices // #define MVHW_CP0_COMPHY_BASE 0xF2441000 @@ -226,18 +215,4 @@ MVHW_PP2_DESC mA7k8kPp2DescTemplate = {\ { MVHW_PP2_CLK_FREQ, MVHW_PP2_CLK_FREQ } \ } -// -// Platform description of RealTimeClock devices -// -#define MVHW_CP0_RTC0_BASE 0xF2284000 -#define MVHW_CP1_RTC0_BASE 0xF4284000 - -#define DECLARE_A7K8K_RTC_TEMPLATE \ -STATIC \ -MVHW_RTC_DESC mA7k8kRtcDescTemplate = {\ - 2,\ - { MVHW_CP0_RTC0_BASE, MVHW_CP1_RTC0_BASE },\ - { SIZE_4KB, SIZE_4KB }\ -} - #endif /* __MVHWDESCLIB_H__ */ diff --git a/Silicon/Marvell/Marvell.dec b/Silicon/Marvell/Marvell.dec index 6861cc4..4def897 100644 --- a/Silicon/Marvell/Marvell.dec +++ b/Silicon/Marvell/Marvell.dec @@ -195,7 +195,7 @@ gMarvellTokenSpaceGuid.PcdPciESdhci|{ 0x0 }|VOID*|0x3000035 #RTC - gMarvellTokenSpaceGuid.PcdRtcEnabled|{ 0x0 }|VOID*|0x40000052 + gMarvellTokenSpaceGuid.PcdRtcBaseAddress|0x0|UINT64|0x40000052 #TRNG gMarvellTokenSpaceGuid.PcdEip76TrngBaseAddress|0x0|UINT64|0x50000053 -- 2.7.4