Skip to contentSkip to conversation

rtc: Fix hwclock write fail problem in x86 arch

PATCH New Sang Yan 1 participant 1 message May 19, 2021 x86

lore
Share & tools
lore

Sang Yan

author
#0 lore raw

PATCH 1/1 rtc: Fix hwclock write fail problem in x86 arch

From: Jingxian He <[email protected]>

When RTC_ALWAYS_BCD is set as 1, the function mc146818_set_time ignores the reading value of RTC_CONTROL register, and assumes that RTC always operates in binary mode.

However, the mc146818 development manual says that:
if !(CMOS_READ(RTC_CONTROL) & 0x04), then the rtc time is in binary mode;
if (CMOS_READ(RTC_CONTROL) & 0x04), then the rtc time is in bcd mode.

We use 'hwclock -w' to set the RTC from the system time at our x86 machines, and we find that when (CMOS_READ(RTC_CONTROL) & 0x04) is equal to 1, 'hwclock -w' will fail to set the RTC.

We change the RTC_ALWAYS_BCD to 0 to parse the rtc time according to the read value of RTC_CONTROL register.

---
 arch/x86/include/asm/mc146818rtc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/mc146818rtc.h +1 -1
index 9719800..63cf0d5 100644
@@ -10,7 +10,7 @@
 
 #ifndef RTC_PORT
 #define RTC_PORT(x)	(0x70 + (x))
-#define RTC_ALWAYS_BCD	1	/* RTC operates in binary mode */
+#define RTC_ALWAYS_BCD	0
 #endif
 
 #if defined(CONFIG_X86_32)
Signature · 1 line
2.9.5