-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Silicon/Rockchip: Add 8563-based RTC support
Uses Pcf8563RealTimeClockLib, which is compatible with the HYM8563 chip used on many Rockchip platforms.
- Loading branch information
1 parent
a5fdc7c
commit 1ca239f
Showing
5 changed files
with
151 additions
and
2 deletions.
There are no files selected for viewing
98 changes: 98 additions & 0 deletions
98
edk2-rockchip/Silicon/Rockchip/Drivers/Rtc8563PlatformDxe/Rtc8563PlatformDxe.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/** @file | ||
* | ||
* Pcf8563RealTimeClockLib initializer for Rockchip platforms. | ||
* | ||
* Copyright (c) 2023, Mario Bălănică <[email protected]> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause-Patent | ||
* | ||
**/ | ||
|
||
#include <Library/UefiLib.h> | ||
#include <Library/UefiBootServicesTableLib.h> | ||
#include <Library/MemoryAllocationLib.h> | ||
#include <Library/DebugLib.h> | ||
#include <Protocol/RockchipI2cMasterProtocol.h> | ||
|
||
STATIC | ||
VOID | ||
EFIAPI | ||
RockchipI2cMasterRegistrationEvent ( | ||
IN EFI_EVENT Event, | ||
IN VOID *Context | ||
) | ||
{ | ||
EFI_STATUS Status; | ||
EFI_HANDLE *Handles; | ||
UINTN NumHandles; | ||
ROCKCHIP_I2C_MASTER_PROTOCOL *RockchipI2cMaster; | ||
UINTN Index; | ||
|
||
Handles = NULL; | ||
Status = gBS->LocateHandleBuffer ( | ||
ByProtocol, | ||
&gRockchipI2cMasterProtocolGuid, | ||
NULL, | ||
&NumHandles, | ||
&Handles | ||
); | ||
if (EFI_ERROR(Status)) { | ||
if (Status != EFI_NOT_FOUND) { | ||
DEBUG((DEBUG_WARN, "%a: Failed to locate gRockchipI2cMasterProtocolGuid. Status=%r\n", | ||
__FUNCTION__, Status)); | ||
} | ||
return; | ||
} | ||
|
||
for (Index = 0; Index < NumHandles; Index++) { | ||
Status = gBS->HandleProtocol ( | ||
Handles[Index], | ||
&gRockchipI2cMasterProtocolGuid, | ||
(VOID **)&RockchipI2cMaster | ||
); | ||
if (EFI_ERROR (Status)) { | ||
DEBUG ((DEBUG_ERROR, "%a: Failed to get RockchipI2cMaster: %r\n", __FUNCTION__, Status)); | ||
continue; | ||
} | ||
|
||
if (RockchipI2cMaster->Bus != FixedPcdGet8 (PcdRtc8563Bus)) { | ||
continue; | ||
} | ||
|
||
Status = gBS->InstallMultipleProtocolInterfaces ( | ||
&Handles[Index], | ||
&gPcf8563RealTimeClockLibI2cMasterProtocolGuid, | ||
NULL, | ||
NULL | ||
); | ||
if (EFI_ERROR (Status)) { | ||
DEBUG ((DEBUG_ERROR, "%a: Failed to install gPcf8563RealTimeClockLibI2cMasterProtocolGuid: %r\n", | ||
__FUNCTION__, Status)); | ||
continue; | ||
} | ||
|
||
gBS->CloseEvent (Event); | ||
} | ||
|
||
FreePool (Handles); | ||
} | ||
|
||
EFI_STATUS | ||
EFIAPI | ||
Rtc8563PlatformDxeInitialize ( | ||
IN EFI_HANDLE ImageHandle, | ||
IN EFI_SYSTEM_TABLE *SystemTable | ||
) | ||
{ | ||
VOID *Registration = NULL; | ||
|
||
EfiCreateProtocolNotifyEvent ( | ||
&gRockchipI2cMasterProtocolGuid, | ||
TPL_CALLBACK, | ||
RockchipI2cMasterRegistrationEvent, | ||
NULL, | ||
&Registration | ||
); | ||
|
||
return EFI_SUCCESS; | ||
} |
42 changes: 42 additions & 0 deletions
42
edk2-rockchip/Silicon/Rockchip/Drivers/Rtc8563PlatformDxe/Rtc8563PlatformDxe.inf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#/** @file | ||
# | ||
# Pcf8563RealTimeClockLib initializer for Rockchip platforms. | ||
# | ||
# Copyright (c) 2023, Mario Bălănică <[email protected]> | ||
# | ||
# SPDX-License-Identifier: BSD-2-Clause-Patent | ||
# | ||
#**/ | ||
|
||
[Defines] | ||
INF_VERSION = 0x00010019 | ||
BASE_NAME = RtcPlatformDxe | ||
FILE_GUID = b4d6e6b1-b2a0-4c79-8bf1-3af8c485ec3d | ||
MODULE_TYPE = DXE_DRIVER | ||
VERSION_STRING = 1.0 | ||
ENTRY_POINT = Rtc8563PlatformDxeInitialize | ||
|
||
[Sources.common] | ||
Rtc8563PlatformDxe.c | ||
|
||
[Packages] | ||
MdePkg/MdePkg.dec | ||
Silicon/Rockchip/RockchipPkg.dec | ||
Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.dec | ||
|
||
[LibraryClasses] | ||
UefiDriverEntryPoint | ||
UefiLib | ||
UefiBootServicesTableLib | ||
MemoryAllocationLib | ||
DebugLib | ||
|
||
[Protocols] | ||
gRockchipI2cMasterProtocolGuid ## CONSUMES | ||
gPcf8563RealTimeClockLibI2cMasterProtocolGuid ## PRODUCES | ||
|
||
[Pcd] | ||
gRockchipTokenSpaceGuid.PcdRtc8563Bus | ||
|
||
[Depex] | ||
TRUE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters