PcAtChipsetPkg: Use DV bit to stop the RTC first when changing the time

Legacy BIOS design sets only the Update Cycle Inhibit (SET) bit when
changing the RTC time. Update Cycle Inhibit Bit may not be supported
by the backend device (Common I2C RTC device). It could add Division
Chain Select (DV) bit to stop the RTC first (Write to 0x07), Changing
the RTC time and then Set the DV bit back.

Signed-off-by: Di Zhang <di.zhang@intel.com>
This commit is contained in:
Chen Lin Z 2024-10-15 13:51:12 +08:00 committed by mergify[bot]
parent f1674e665c
commit df6b43f61b
2 changed files with 11 additions and 0 deletions

View File

@ -561,6 +561,7 @@ PcRtcSetTime (
{
EFI_STATUS Status;
EFI_TIME RtcTime;
RTC_REGISTER_A RegisterA;
RTC_REGISTER_B RegisterB;
UINT32 TimerVar;
@ -638,6 +639,11 @@ PcRtcSetTime (
RegisterB.Bits.Set = 1;
RtcWrite (RTC_ADDRESS_REGISTER_B, RegisterB.Data);
RegisterA.Data = RtcRead (RTC_ADDRESS_REGISTER_A);
//
// Set Divider in Reset status, RTC stops
//
RtcWrite (RTC_ADDRESS_REGISTER_A, RegisterA.Data | RTC_DIV_RESET);
//
// Store the century value to RTC before converting to BCD format.
//
@ -660,6 +666,10 @@ PcRtcSetTime (
RegisterB.Bits.Set = 0;
RtcWrite (RTC_ADDRESS_REGISTER_B, RegisterB.Data);
//
// Restore Divider status
//
RtcWrite (RTC_ADDRESS_REGISTER_A, RegisterA.Data);
//
// Release RTC Lock.
//

View File

@ -70,6 +70,7 @@ extern PC_RTC_MODULE_GLOBALS mModuleGlobal;
//
// Register A
//
#define RTC_DIV_RESET 0x70
typedef struct {
UINT8 Rs : 4; // Rate Selection Bits
UINT8 Dv : 3; // Divisor