]> git.proxmox.com Git - mirror_edk2.git/blobdiff - PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.h
PcAtChipsetPkg: Add MMIO Support to RTC driver
[mirror_edk2.git] / PcAtChipsetPkg / PcatRealTimeClockRuntimeDxe / PcRtc.h
index 85492f7b5972a861cebeca9c78f025dac5dd4042..47293ce44c5a1f4792892892f7da40d7f0a5a001 100644 (file)
@@ -1,14 +1,10 @@
 /** @file\r
   Header file for real time clock driver.\r
 \r
-Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2017, AMD Inc. All rights reserved.<BR>\r
 \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -19,6 +15,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include <Uefi.h>\r
 \r
+#include <Guid/Acpi.h>\r
+\r
 #include <Protocol/RealTimeClock.h>\r
 \r
 #include <Library/BaseLib.h>\r
@@ -32,16 +30,16 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/UefiRuntimeLib.h>\r
 #include <Library/UefiRuntimeServicesTableLib.h>\r
 #include <Library/PcdLib.h>\r
-\r
+#include <Library/ReportStatusCodeLib.h>\r
 \r
 typedef struct {\r
   EFI_LOCK  RtcLock;\r
   INT16     SavedTimeZone;\r
   UINT8     Daylight;\r
+  UINT8     CenturyRtcAddress;\r
 } PC_RTC_MODULE_GLOBALS;\r
 \r
-#define PCAT_RTC_ADDRESS_REGISTER 0x70\r
-#define PCAT_RTC_DATA_REGISTER    0x71\r
+extern PC_RTC_MODULE_GLOBALS  mModuleGlobal;\r
 \r
 //\r
 // Dallas DS12C887 Real Time Clock\r
@@ -60,7 +58,6 @@ typedef struct {
 #define RTC_ADDRESS_REGISTER_B        11  // R/W\r
 #define RTC_ADDRESS_REGISTER_C        12  // RO\r
 #define RTC_ADDRESS_REGISTER_D        13  // RO\r
-#define RTC_ADDRESS_CENTURY           50  // R/W  Range 19..20 Bit 8 is R/W\r
 //\r
 // Date and time initial values.\r
 // They are used if the RTC values are invalid during driver initialization\r
@@ -70,23 +67,15 @@ typedef struct {
 #define RTC_INIT_HOUR   0\r
 #define RTC_INIT_DAY    1\r
 #define RTC_INIT_MONTH  1\r
-#define RTC_INIT_YEAR   2001\r
-\r
-//\r
-// Register initial values\r
-//\r
-#define RTC_INIT_REGISTER_A 0x26\r
-#define RTC_INIT_REGISTER_B 0x02\r
-#define RTC_INIT_REGISTER_D 0x0\r
 \r
 #pragma pack(1)\r
 //\r
 // Register A\r
 //\r
 typedef struct {\r
-  UINT8 RS : 4;   // Rate Selection Bits\r
-  UINT8 DV : 3;   // Divisor\r
-  UINT8 UIP : 1;  // Update in progress\r
+  UINT8 Rs : 4;   // Rate Selection Bits\r
+  UINT8 Dv : 3;   // Divisor\r
+  UINT8 Uip : 1;  // Update in progress\r
 } RTC_REGISTER_A_BITS;\r
 \r
 typedef union {\r
@@ -98,14 +87,14 @@ typedef union {
 // Register B\r
 //\r
 typedef struct {\r
-  UINT8 DSE : 1;  // 0 - Daylight saving disabled  1 - Daylight savings enabled\r
-  UINT8 MIL : 1;  // 0 - 12 hour mode              1 - 24 hour mode\r
-  UINT8 DM : 1;   // 0 - BCD Format                1 - Binary Format\r
-  UINT8 SQWE : 1; // 0 - Disable SQWE output       1 - Enable SQWE output\r
-  UINT8 UIE : 1;  // 0 - Update INT disabled       1 - Update INT enabled\r
-  UINT8 AIE : 1;  // 0 - Alarm INT disabled        1 - Alarm INT Enabled\r
-  UINT8 PIE : 1;  // 0 - Periodic INT disabled     1 - Periodic INT Enabled\r
-  UINT8 SET : 1;  // 0 - Normal operation.         1 - Updates inhibited\r
+  UINT8 Dse : 1;  // 0 - Daylight saving disabled  1 - Daylight savings enabled\r
+  UINT8 Mil : 1;  // 0 - 12 hour mode              1 - 24 hour mode\r
+  UINT8 Dm : 1;   // 0 - BCD Format                1 - Binary Format\r
+  UINT8 Sqwe : 1; // 0 - Disable SQWE output       1 - Enable SQWE output\r
+  UINT8 Uie : 1;  // 0 - Update INT disabled       1 - Update INT enabled\r
+  UINT8 Aie : 1;  // 0 - Alarm INT disabled        1 - Alarm INT Enabled\r
+  UINT8 Pie : 1;  // 0 - Periodic INT disabled     1 - Periodic INT Enabled\r
+  UINT8 Set : 1;  // 0 - Normal operation.         1 - Updates inhibited\r
 } RTC_REGISTER_B_BITS;\r
 \r
 typedef union {\r
@@ -118,10 +107,10 @@ typedef union {
 //\r
 typedef struct {\r
   UINT8 Reserved : 4; // Read as zero.  Can not be written.\r
-  UINT8 UF : 1;       // Update End Interrupt Flag\r
-  UINT8 AF : 1;       // Alarm Interrupt Flag\r
-  UINT8 PF : 1;       // Periodic Interrupt Flag\r
-  UINT8 IRQF : 1;     // Iterrupt Request Flag = PF & PIE | AF & AIE | UF & UIE\r
+  UINT8 Uf : 1;       // Update End Interrupt Flag\r
+  UINT8 Af : 1;       // Alarm Interrupt Flag\r
+  UINT8 Pf : 1;       // Periodic Interrupt Flag\r
+  UINT8 Irqf : 1;     // Interrupt Request Flag = PF & PIE | AF & AIE | UF & UIE\r
 } RTC_REGISTER_C_BITS;\r
 \r
 typedef union {\r
@@ -134,7 +123,7 @@ typedef union {
 //\r
 typedef struct {\r
   UINT8 Reserved : 7; // Read as zero.  Can not be written.\r
-  UINT8 VRT : 1;      // Valid RAM and Time\r
+  UINT8 Vrt : 1;      // Valid RAM and Time\r
 } RTC_REGISTER_D_BITS;\r
 \r
 typedef union {\r
@@ -245,7 +234,7 @@ PcRtcGetWakeupTime (
 /**\r
   The user Entry Point for PcRTC module.\r
 \r
-  This is the entrhy point for PcRTC module. It installs the UEFI runtime service\r
+  This is the entry point for PcRTC module. It installs the UEFI runtime service\r
   including GetTime(),SetTime(),GetWakeupTime(),and SetWakeupTime().\r
 \r
   @param  ImageHandle    The firmware allocated handle for the EFI image.\r
@@ -277,23 +266,20 @@ RtcTimeFieldsValid (
   );\r
 \r
 /**\r
-  Converts time from EFI_TIME format defined by UEFI spec to RTC's.\r
+  Converts time from EFI_TIME format defined by UEFI spec to RTC format.\r
 \r
-  This function converts time from EFI_TIME format defined by UEFI spec to RTC's.\r
+  This function converts time from EFI_TIME format defined by UEFI spec to RTC format.\r
   If data mode of RTC is BCD, then converts EFI_TIME to it.\r
   If RTC is in 12-hour format, then converts EFI_TIME to it.\r
 \r
   @param   Time       On input, the time data read from UEFI to convert\r
                       On output, the time converted to RTC format\r
   @param   RegisterB  Value of Register B of RTC, indicating data mode\r
-  @param   Century    It is set according to EFI_TIME Time.\r
-\r
 **/\r
 VOID\r
 ConvertEfiTimeToRtcTime (\r
   IN OUT EFI_TIME        *Time,\r
-  IN     RTC_REGISTER_B  RegisterB,\r
-  OUT    UINT8           *Century\r
+  IN     RTC_REGISTER_B  RegisterB\r
   );\r
 \r
 \r
@@ -307,7 +293,6 @@ ConvertEfiTimeToRtcTime (
 \r
   @param   Time       On input, the time data read from RTC to convert\r
                       On output, the time converted to UEFI format\r
-  @param   Century    Value of century read from RTC.\r
   @param   RegisterB  Value of Register B of RTC, indicating data mode\r
                       and hour format.\r
 \r
@@ -318,7 +303,6 @@ ConvertEfiTimeToRtcTime (
 EFI_STATUS\r
 ConvertRtcTimeToEfiTime (\r
   IN OUT EFI_TIME        *Time,\r
-  IN     UINT8           Century,\r
   IN     RTC_REGISTER_B  RegisterB\r
   );\r
 \r
@@ -328,7 +312,7 @@ ConvertRtcTimeToEfiTime (
   @param    Timeout  Tell how long it should take to wait.\r
 \r
   @retval   EFI_DEVICE_ERROR   RTC device error.\r
-  @retval   EFI_SUCCESS        RTC is updated and ready.  \r
+  @retval   EFI_SUCCESS        RTC is updated and ready.\r
 **/\r
 EFI_STATUS\r
 RtcWaitToUpdate (\r
@@ -361,4 +345,30 @@ IsLeapYear (
   IN EFI_TIME   *Time\r
   );\r
 \r
+/**\r
+  Get the century RTC address from the ACPI FADT table.\r
+\r
+  @return  The century RTC address or 0 if not found.\r
+**/\r
+UINT8\r
+GetCenturyRtcAddress (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Notification function of ACPI Table change.\r
+\r
+  This is a notification function registered on ACPI Table change event.\r
+  It saves the Century address stored in ACPI FADT table.\r
+\r
+  @param  Event        Event whose notification function is being invoked.\r
+  @param  Context      Pointer to the notification function's context.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+PcRtcAcpiTableChangeCallback (\r
+  IN EFI_EVENT        Event,\r
+  IN VOID             *Context\r
+  );\r
 #endif\r