]>
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 (&gFdtClientProtocolGuid
, NULL
,
35 ASSERT_EFI_ERROR (Status
);
37 Status
= FdtClient
->FindCompatibleNode (FdtClient
, "arm,pl031", &Node
);
38 if (EFI_ERROR (Status
)) {
39 DEBUG ((EFI_D_WARN
, "%a: No 'arm,pl031' compatible DT node found\n",
44 Status
= FdtClient
->GetNodeProperty (FdtClient
, Node
, "reg",
45 (CONST VOID
**)&Reg
, &RegSize
);
46 if (EFI_ERROR (Status
)) {
48 "%a: No 'reg' property found in 'arm,pl031' compatible DT node\n",
53 ASSERT (RegSize
== 16);
55 RegBase
= SwapBytes64 (Reg
[0]);
56 ASSERT (RegBase
< MAX_UINT32
);
58 PcdStatus
= PcdSet32S (PcdPL031RtcBase
, (UINT32
)RegBase
);
59 ASSERT_RETURN_ERROR (PcdStatus
);
61 DEBUG ((EFI_D_INFO
, "Found PL031 RTC @ 0x%Lx\n", RegBase
));
64 // UEFI takes ownership of the RTC hardware, and exposes its functionality
65 // through the UEFI Runtime Services GetTime, SetTime, etc. This means we
66 // need to disable it in the device tree to prevent the OS from attaching
67 // its device driver as well.
69 Status
= FdtClient
->SetNodeProperty (FdtClient
, Node
, "status",
70 "disabled", sizeof ("disabled"));
71 if (EFI_ERROR (Status
)) {
72 DEBUG ((EFI_D_WARN
, "Failed to set PL031 status to 'disabled'\n"));