Edk2-platforms contains two DS3231RealTimeClockLib instances:
- Silicon/Hisilicon/Library/DS3231RealTimeClockLib
- Platform/Hisilicon/D03/Library/DS3231RealTimeClockLib
The latter is still used (by the D03 and D05 platforms), but the former
has not been referenced since commit 478282ea28c7 ("Hisilicon/D02: Remove
D02 platform", 2018-08-08). Remove the unused library instance.
(There's no reference in edk2-non-osi either.)
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Wenyi Xie <xiewenyi2@huawei.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=4564
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
Silicon/Hisilicon/Library/DS3231RealTimeClockLib/DS3231RealTimeClockLib.inf | 43 --
Silicon/Hisilicon/Library/DS3231RealTimeClockLib/DS3231RealTimeClock.h | 172 --------
Silicon/Hisilicon/Library/DS3231RealTimeClockLib/DS3231RealTimeClockLib.c | 427 --------------------
3 files changed, 642 deletions(-)
diff --git a/Silicon/Hisilicon/Library/DS3231RealTimeClockLib/DS3231RealTimeClockLib.inf b/Silicon/Hisilicon/Library/DS3231RealTimeClockLib/DS3231RealTimeClockLib.inf
deleted file mode 100644
index 35042e07ed1f..000000000000
--- a/Silicon/Hisilicon/Library/DS3231RealTimeClockLib/DS3231RealTimeClockLib.inf
+++ /dev/null
@@ -1,43 +0,0 @@
-#/** @file
-#
-# Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
-# Copyright (c) 2011-2013, ARM Ltd. All rights reserved.<BR>
-# Copyright (c) 2015, Hisilicon Limited. All rights reserved.
-# Copyright (c) 2015, Linaro Limited. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-#
-# Based on the files under ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.inf
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = DS3231RealTimeClockLib
- FILE_GUID = 5FD8127D-11E1-488F-8CF1-A143157D6BF0
- MODULE_TYPE = BASE
- VERSION_STRING = 1.0
- LIBRARY_CLASS = RealTimeClockLib
-
-[Sources.common]
- DS3231RealTimeClockLib.c
-
-[Packages]
- MdePkg/MdePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
- Silicon/Hisilicon/HisiPkg.dec
-
-[LibraryClasses]
- IoLib
- UefiLib
- DebugLib
- PcdLib
- I2CLib
- TimeBaseLib
- TimerLib
-# Use EFiAtRuntime to check stage
- UefiRuntimeLib
-
-[Pcd]
-
diff --git a/Silicon/Hisilicon/Library/DS3231RealTimeClockLib/DS3231RealTimeClock.h b/Silicon/Hisilicon/Library/DS3231RealTimeClockLib/DS3231RealTimeClock.h
deleted file mode 100644
index da18d0f5589e..000000000000
--- a/Silicon/Hisilicon/Library/DS3231RealTimeClockLib/DS3231RealTimeClock.h
+++ /dev/null
@@ -1,172 +0,0 @@
-/** @file
-*
-* Copyright (c) 2011, ARM Limited. All rights reserved.
-* Copyright (c) 2015, Hisilicon Limited. All rights reserved.
-* Copyright (c) 2015, Linaro Limited. All rights reserved.
-*
-* SPDX-License-Identifier: BSD-2-Clause-Patent
-*
-* Based on the files under ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.inf
-**/
-
-
-#ifndef __DS3231_REAL_TIME_CLOCK_H__
-#define __DS3231_REAL_TIME_CLOCK_H__
-
-#define DS3231_REGADDR_SECONDS 0x00
-#define DS3231_REGADDR_MIUTES 0x01
-#define DS3231_REGADDR_HOURS 0x02
-#define DS3231_REGADDR_DAY 0x03
-#define DS3231_REGADDR_DATE 0x04
-#define DS3231_REGADDR_MONTH 0x05
-#define DS3231_REGADDR_YEAR 0x06
-#define DS3231_REGADDR_ALARM1SEC 0x07
-#define DS3231_REGADDR_ALARM1MIN 0x08
-#define DS3231_REGADDR_ALARM1HOUR 0x09
-#define DS3231_REGADDR_ALARM1DAY 0x0A
-#define DS3231_REGADDR_ALARM2MIN 0x0B
-#define DS3231_REGADDR_ALARM2HOUR 0x0C
-#define DS3231_REGADDR_ALARM2DAY 0x0D
-#define DS3231_REGADDR_CONTROL 0x0E
-#define DS3231_REGADDR_STATUS 0x0F
-#define DS3231_REGADDR_AGOFFSET 0x10
-#define DS3231_REGADDR_TEMPMSB 0x11
-#define DS3231_REGADDR_TEMPLSB 0x12
-
-
-typedef union {
- struct{
- UINT8 A1IE:1;
- UINT8 A2IE:1;
- UINT8 INTCN:1;
- UINT8 RSV:2;
- UINT8 CONV:1;
- UINT8 BBSQW:1;
- UINT8 EOSC_N:1;
- }bits;
- UINT8 u8;
-}RTC_DS3231_CONTROL;
-
-typedef union {
- struct{
- UINT8 A1F:1;
- UINT8 A2F:1;
- UINT8 BSY:1;
- UINT8 EN32KHZ:2;
- UINT8 Rsv:3;
- UINT8 OSF:1;
- }bits;
- UINT8 u8;
-}RTC_DS3231_STATUS;
-
-
-typedef union {
- struct{
- UINT8 Data:7;
- UINT8 Sign:1;
- }bits;
- UINT8 u8;
-}RTC_DS3231_AGOFFSET;
-
-typedef union {
- struct{
- UINT8 Data:7;
- UINT8 Sign:1;
- }bits;
- UINT8 u8;
-}RTC_DS3231_TEMPMSB;
-
-
-typedef union {
- struct{
- UINT8 Rsv:6;
- UINT8 Data:2;
- }bits;
- UINT8 u8;
-}RTC_DS3231_TEMPLSB;
-
-typedef union {
- struct{
- UINT8 Seconds:4;
- UINT8 Seconds10:3;
- UINT8 Rsv:1;
- }bits;
- UINT8 u8;
-}RTC_DS3231_SECONDS;
-
-typedef union {
- struct{
- UINT8 Minutes:4;
- UINT8 Minutes10:3;
- UINT8 Rsv:1;
- }bits;
- UINT8 u8;
-}RTC_DS3231_MINUTES;
-
-typedef union {
- struct{
- UINT8 Hour:4;
- UINT8 Hours10:1;
- UINT8 PM_20Hours:1;
- UINT8 Hour24_n:1;
- UINT8 Rsv:1;
- }bits;
- UINT8 u8;
-}RTC_DS3231_HOURS;
-
-typedef union {
- struct{
- UINT8 Day:3;
- UINT8 Rsv:5;
- }bits;
- UINT8 u8;
-}RTC_DS3231_DAY;
-
-typedef union {
- struct{
- UINT8 Month:4;
- UINT8 Month10:1;
- UINT8 Rsv:2;
- UINT8 Century:1;
- }bits;
- UINT8 u8;
-}RTC_DS3231_MONTH;
-
-typedef union {
- struct{
- UINT8 Year:4;
- UINT8 Year10:4;
- }bits;
- UINT8 u8;
-}RTC_DS3231_YEAR;
-
-typedef union {
- struct{
- UINT8 Seconds:4;
- UINT8 Seconds10:3;
- UINT8 A1M1:1;
- }bits;
- UINT8 u8;
-}RTC_DS3231_ALARM1SEC;
-
-typedef union {
- struct{
- UINT8 Minutes:4;
- UINT8 Minutes10:3;
- UINT8 A1M2:1;
- }bits;
- UINT8 u8;
-}RTC_DS3231_ALARM1MIN;
-
-typedef union {
- struct{
- UINT8 Hour:4;
- UINT8 Hours10:1;
- UINT8 PM_20Hours:1;
- UINT8 Hours24:1;
- UINT8 A1M3:1;
- }bits;
- UINT8 u8;
-}RTC_DS3231_ALARM1HOUR;
-
-#endif
diff --git a/Silicon/Hisilicon/Library/DS3231RealTimeClockLib/DS3231RealTimeClockLib.c b/Silicon/Hisilicon/Library/DS3231RealTimeClockLib/DS3231RealTimeClockLib.c
deleted file mode 100644
index 30dc86414232..000000000000
--- a/Silicon/Hisilicon/Library/DS3231RealTimeClockLib/DS3231RealTimeClockLib.c
+++ /dev/null
@@ -1,427 +0,0 @@
-/** @file
- Implement EFI RealTimeClock runtime services via RTC Lib.
-
- Currently this driver does not support runtime virtual calling.
-
- Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
- Copyright (c) 2011-2013, ARM Ltd. All rights reserved.<BR>
- Copyright (c) 2015, Hisilicon Limited. All rights reserved.<BR>
- Copyright (c) 2015, Linaro Limited. All rights reserved.<BR>
-
- SPDX-License-Identifier: BSD-2-Clause-Patent
-
- Based on the files under ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.inf
-
-**/
-
-#include <Uefi.h>
-#include <PiDxe.h>
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/UefiLib.h>
-// Use EfiAtRuntime to check stage
-#include <Library/UefiRuntimeLib.h>
-#include <Library/IoLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/PcdLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-#include <Library/TimerLib.h>
-#include <Library/TimeBaseLib.h>
-#include <Protocol/RealTimeClock.h>
-#include <Library/I2CLib.h>
-#include "DS3231RealTimeClock.h"
-
-extern I2C_DEVICE gRtcDevice;
-
-STATIC BOOLEAN mDS3231Initialized = FALSE;
-
-EFI_STATUS
-IdentifyDS3231 (
- VOID
- )
-{
- EFI_STATUS Status;
-
- Status = EFI_SUCCESS;
- return Status;
-}
-
-EFI_STATUS
-InitializeDS3231 (
- VOID
- )
-{
- EFI_STATUS Status;
- I2C_DEVICE Dev;
- RTC_DS3231_CONTROL Temp;
- RTC_DS3231_HOURS Hours;
-
- // Prepare the hardware
- (VOID)IdentifyDS3231();
-
- (VOID)CopyMem (&Dev, &gRtcDevice, sizeof (Dev));
-
- Status = I2CInit(Dev.Socket,Dev.Port,Normal);
- if (EFI_ERROR (Status)) {
- goto EXIT;
- }
- // Ensure interrupts are masked. We do not want RTC interrupts in UEFI
- Status = I2CRead(&Dev,DS3231_REGADDR_CONTROL,1,&Temp.u8);
- if (EFI_ERROR (Status)) {
- goto EXIT;
- }
- Temp.bits.INTCN = 0;
- Status = I2CWrite(&Dev,DS3231_REGADDR_CONTROL,1,&Temp.u8);
- if (EFI_ERROR (Status)) {
- goto EXIT;
- }
-
- MicroSecondDelay(2000);
- Status = I2CRead(&Dev,DS3231_REGADDR_HOURS,1,&Hours.u8);
- if (EFI_ERROR (Status)) {
- goto EXIT;
- }
- Hours.bits.Hour24_n = 0;
- Status = I2CWrite(&Dev,DS3231_REGADDR_HOURS,1,&Hours.u8);
- if (EFI_ERROR (Status)) {
- goto EXIT;
- }
-
-
- mDS3231Initialized = TRUE;
-
- EXIT:
- return Status;
-}
-
-
-/**
- Returns the current time and date information, and the time-keeping capabilities
- of the hardware platform.
-
- @param Time A pointer to storage to receive a snapshot of the current time.
- @param Capabilities An optional pointer to a buffer to receive the real time clock
- device's capabilities.
-
- @retval EFI_SUCCESS The operation completed successfully.
- @retval EFI_INVALID_PARAMETER Time is NULL.
- @retval EFI_DEVICE_ERROR The time could not be retrieved due to hardware error.
- @retval EFI_SECURITY_VIOLATION The time could not be retrieved due to an authentication failure.
-**/
-EFI_STATUS
-EFIAPI
-LibGetTime (
- OUT EFI_TIME *Time,
- OUT EFI_TIME_CAPABILITIES *Capabilities
- )
-{
- EFI_STATUS Status = EFI_SUCCESS;
- UINT8 Temp;
- UINT8 BaseHour = 0;
- UINT16 BaseYear = 1900;
-
- I2C_DEVICE Dev;
-
- // Ensure Time is a valid pointer
- if (NULL == Time) {
- return EFI_INVALID_PARAMETER;
- }
-
- // Initialize the hardware if not already done
- if (!mDS3231Initialized) {
- Status = InitializeDS3231 ();
- if (EFI_ERROR (Status)) {
- return EFI_NOT_READY;
- }
- }
-
- (VOID)CopyMem (&Dev, &gRtcDevice, sizeof (Dev));
-
-
- Status |= I2CRead(&Dev,DS3231_REGADDR_MONTH,1,&Temp);
-
- Time->Month = ((Temp>>4)&1)*10+(Temp&0x0F);
-
-
- if(Temp&0x80){
- BaseYear = 2000;
- }
-
- Status |= I2CRead(&Dev,DS3231_REGADDR_YEAR,1,&Temp);
-
- Time->Year = BaseYear+(Temp>>4) *10 + (Temp&0x0F);
-
-
- Status |= I2CRead(&Dev,DS3231_REGADDR_DATE,1,&Temp);
-
- Time->Day = ((Temp>>4)&3) *10 + (Temp&0x0F);
-
-
- Status |= I2CRead(&Dev,DS3231_REGADDR_HOURS,1,&Temp);
-
- BaseHour = 0;
- if((Temp&0x30) == 0x30){
- return EFI_DEVICE_ERROR;
- }else if(Temp&0x20){
- BaseHour = 20;
- }else if(Temp&0x10){
- BaseHour = 10;
- }
- Time->Hour = BaseHour + (Temp&0x0F);
-
-
- Status |= I2CRead(&Dev,DS3231_REGADDR_MIUTES,1,&Temp);
-
- Time->Minute = ((Temp>>4)&7) * 10 + (Temp&0x0F);
-
-
- Status |= I2CRead(&Dev,DS3231_REGADDR_SECONDS,1,&Temp);
-
- Time->Second = (Temp>>4) * 10 + (Temp&0x0F);
-
- Time->Nanosecond = 0;
- Time->Daylight = 0;
- Time->TimeZone = EFI_UNSPECIFIED_TIMEZONE;
-
- if((EFI_ERROR(Status)) || (!IsTimeValid(Time)) || ((Time->Year - BaseYear) > 99)) {
- return EFI_DEVICE_ERROR;
- }
-
- return EFI_SUCCESS;
-}
-
-
-/**
- Sets the current local time and date information.
-
- @param Time A pointer to the current time.
-
- @retval EFI_SUCCESS The operation completed successfully.
- @retval EFI_INVALID_PARAMETER A time field is out of range.
- @retval EFI_DEVICE_ERROR The time could not be set due due to hardware error.
-
-**/
-EFI_STATUS
-EFIAPI
-LibSetTime (
- IN EFI_TIME *Time
- )
-{
- EFI_STATUS Status = EFI_SUCCESS;
- I2C_DEVICE Dev;
- UINT8 Temp;
- UINT16 BaseYear = 1900;
-
- // Check the input parameters are within the range specified by UEFI
- if(!IsTimeValid(Time)){
- return EFI_INVALID_PARAMETER;
- }
-
- // Initialize the hardware if not already done
- if (!mDS3231Initialized) {
- Status = InitializeDS3231 ();
- if (EFI_ERROR (Status)) {
- goto EXIT;
- }
- }
-
- (VOID)CopyMem (&Dev, &gRtcDevice, sizeof (Dev));
-
- Temp = ((Time->Second/10)<<4) | (Time->Second%10);
- MicroSecondDelay(1000);
- Status = I2CWrite(&Dev,DS3231_REGADDR_SECONDS,1,&Temp);
- if(EFI_ERROR (Status)){
- goto EXIT;
- }
-
- Temp = ((Time->Minute/10)<<4) | (Time->Minute%10);
- MicroSecondDelay(1000);
- Status = I2CWrite(&Dev,DS3231_REGADDR_MIUTES,1,&Temp);
- if(EFI_ERROR (Status)){
- goto EXIT;
- }
-
- Temp = 0;
- if(Time->Hour > 19){
- Temp = 2;
- } else if(Time->Hour > 9){
- Temp = 1;
- }
- Temp = (Temp << 4) | (Time->Hour%10);
- MicroSecondDelay(1000);
- Status = I2CWrite(&Dev,DS3231_REGADDR_HOURS,1,&Temp);
- if(EFI_ERROR (Status)){
- goto EXIT;
- }
-
- Temp = ((Time->Day/10)<<4) | (Time->Day%10);
- MicroSecondDelay(1000);
- Status = I2CWrite(&Dev,DS3231_REGADDR_DATE,1,&Temp);
- if(EFI_ERROR (Status)){
- goto EXIT;
- }
-
- Temp = 0;
- if(Time->Year >= 2000){
- Temp = 0x8;
- BaseYear = 2000;
- }
-
- if(Time->Month > 9){
- Temp |= 0x1;
- }
- Temp = (Temp<<4) | (Time->Month%10);
- MicroSecondDelay(1000);
- Status = I2CWrite(&Dev,DS3231_REGADDR_MONTH,1,&Temp);
- if(EFI_ERROR (Status)){
- goto EXIT;
- }
-
- Temp = (((Time->Year-BaseYear)/10)<<4) | (Time->Year%10);
- MicroSecondDelay(1000);
- Status = I2CWrite(&Dev,DS3231_REGADDR_YEAR,1,&Temp);
- if(EFI_ERROR (Status)){
- goto EXIT;
- }
-
- EXIT:
- return Status;
-}
-
-
-/**
- Returns the current wakeup alarm clock setting.
-
- @param Enabled Indicates if the alarm is currently enabled or disabled.
- @param Pending Indicates if the alarm signal is pending and requires acknowledgement.
- @param Time The current alarm setting.
-
- @retval EFI_SUCCESS The alarm settings were returned.
- @retval EFI_INVALID_PARAMETER Any parameter is NULL.
- @retval EFI_DEVICE_ERROR The wakeup time could not be retrieved due to a hardware error.
-
-**/
-EFI_STATUS
-EFIAPI
-LibGetWakeupTime (
- OUT BOOLEAN *Enabled,
- OUT BOOLEAN *Pending,
- OUT EFI_TIME *Time
- )
-{
- // Not a required feature
- return EFI_UNSUPPORTED;
-}
-
-
-/**
- Sets the system wakeup alarm clock time.
-
- @param Enabled Enable or disable the wakeup alarm.
- @param Time If Enable is TRUE, the time to set the wakeup alarm for.
-
- @retval EFI_SUCCESS If Enable is TRUE, then the wakeup alarm was enabled. If
- Enable is FALSE, then the wakeup alarm was disabled.
- @retval EFI_INVALID_PARAMETER A time field is out of range.
- @retval EFI_DEVICE_ERROR The wakeup time could not be set due to a hardware error.
- @retval EFI_UNSUPPORTED A wakeup timer is not supported on this platform.
-
-**/
-EFI_STATUS
-EFIAPI
-LibSetWakeupTime (
- IN BOOLEAN Enabled,
- OUT EFI_TIME *Time
- )
-{
- // Not a required feature
- return EFI_UNSUPPORTED;
-}
-
-
-
-/**
- This is the declaration of an EFI image entry point. This can be the entry point to an application
- written to this specification, an EFI boot service driver, or an EFI runtime driver.
-
- @param ImageHandle Handle that identifies the loaded image.
- @param SystemTable System Table for this image.
-
- @retval EFI_SUCCESS The operation completed successfully.
-
-**/
-EFI_STATUS
-EFIAPI
-LibRtcInitialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- EFI_HANDLE Handle;
-
-
- EFI_TIME EfiTime;
-
- // Setup the setters and getters
- gRT->GetTime = LibGetTime;
- gRT->SetTime = LibSetTime;
- gRT->GetWakeupTime = LibGetWakeupTime;
- gRT->SetWakeupTime = LibSetWakeupTime;
-
- Status = gRT->GetTime (&EfiTime, NULL);
- if(EFI_ERROR (Status) || (EfiTime.Year < 2000) || (EfiTime.Year > 2099)){
- EfiTime.Year = 2000;
- EfiTime.Month = 1;
- EfiTime.Day = 1;
- EfiTime.Hour = 0;
- EfiTime.Minute = 0;
- EfiTime.Second = 0;
- EfiTime.Nanosecond = 0;
- EfiTime.Daylight = 0;
- EfiTime.TimeZone = EFI_UNSPECIFIED_TIMEZONE;
-
- Status = gRT->SetTime(&EfiTime);
- if (EFI_ERROR(Status))
- {
- DEBUG((EFI_D_ERROR, "[%a]:[%dL] Status : %r\n", __FUNCTION__, __LINE__, Status));
- }
- }
-
- // Install the protocol
- Handle = NULL;
- Status = gBS->InstallMultipleProtocolInterfaces (
- &Handle,
- &gEfiRealTimeClockArchProtocolGuid, NULL,
- NULL
- );
-
- return Status;
-}
-
-
-/**
- Fixup internal data so that EFI can be call in virtual mode.
- Call the passed in Child Notify event and convert any pointers in
- lib to virtual mode.
-
- @param[in] Event The Event that is being processed
- @param[in] Context Event Context
-**/
-VOID
-EFIAPI
-LibRtcVirtualNotifyEvent (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- //
- // Only needed if you are going to support the OS calling RTC functions in virtual mode.
- // You will need to call EfiConvertPointer (). To convert any stored physical addresses
- // to virtual address. After the OS transitions to calling in virtual mode, all future
- // runtime calls will be made in virtual mode.
- //
- return;
-}
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#109559): https://edk2.groups.io/g/devel/message/109559
Mute This Topic: https://groups.io/mt/101914671/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/3901457/1787277/102458076/xyzzy [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
© 2016 - 2026 Red Hat, Inc.