]>
git.proxmox.com Git - mirror_edk2.git/blob - ArmVirtPkg/Library/ArmVirtPL031FdtClientLib/ArmVirtPL031FdtClientLib.c
2 FDT client library for ARM's PL031 RTC driver
4 Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
12 #include <Library/BaseLib.h>
13 #include <Library/DebugLib.h>
14 #include <Library/PcdLib.h>
15 #include <Library/UefiBootServicesTableLib.h>
17 #include <Protocol/FdtClient.h>
21 ArmVirtPL031FdtClientLibConstructor (
26 FDT_CLIENT_PROTOCOL
*FdtClient
;
31 RETURN_STATUS PcdStatus
;
33 Status
= gBS
->LocateProtocol (
34 &gFdtClientProtocolGuid
,
38 ASSERT_EFI_ERROR (Status
);
40 Status
= FdtClient
->FindCompatibleNode (FdtClient
, "arm,pl031", &Node
);
41 if (EFI_ERROR (Status
)) {
44 "%a: No 'arm,pl031' compatible DT node found\n",
50 Status
= FdtClient
->GetNodeProperty (
57 if (EFI_ERROR (Status
)) {
60 "%a: No 'reg' property found in 'arm,pl031' compatible DT node\n",
66 ASSERT (RegSize
== 16);
68 RegBase
= SwapBytes64 (Reg
[0]);
69 ASSERT (RegBase
< MAX_UINT32
);
71 PcdStatus
= PcdSet32S (PcdPL031RtcBase
, (UINT32
)RegBase
);
72 ASSERT_RETURN_ERROR (PcdStatus
);
74 DEBUG ((DEBUG_INFO
, "Found PL031 RTC @ 0x%Lx\n", RegBase
));
77 // UEFI takes ownership of the RTC hardware, and exposes its functionality
78 // through the UEFI Runtime Services GetTime, SetTime, etc. This means we
79 // need to disable it in the device tree to prevent the OS from attaching
80 // its device driver as well.
82 Status
= FdtClient
->SetNodeProperty (
89 if (EFI_ERROR (Status
)) {
90 DEBUG ((DEBUG_WARN
, "Failed to set PL031 status to 'disabled'\n"));