• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <intelblocks/pcr.h>
4 #include <intelblocks/rtc.h>
5 #include <soc/pcr_ids.h>
6 #include <pc80/mc146818rtc.h>
7 
8 /* RTC PCR configuration */
9 #define PCR_RTC_CONF		0x3400
10 #define PCR_RTC_CONF_UCMOS_EN	(1 << 2)
11 #define PCR_RTC_CONF_LCMOS_LOCK	(1 << 3)
12 #define PCR_RTC_CONF_UCMOS_LOCK	(1 << 4)
13 #define PCR_RTC_CONF_BILD	(1 << 31)
14 /* RTC backed up control register */
15 #define PCR_RTC_BUC		0x3414
16 #define  PCR_RTC_BUC_TOP_SWAP	(1 << 0)
17 
enable_rtc_upper_bank(void)18 void enable_rtc_upper_bank(void)
19 {
20 	/* Enable upper 128 bytes of CMOS */
21 	pcr_or32(PID_RTC, PCR_RTC_CONF, PCR_RTC_CONF_UCMOS_EN);
22 }
23 
soc_get_rtc_failed(void)24 __weak int soc_get_rtc_failed(void)
25 {
26 	return 0;
27 }
28 
rtc_init(void)29 void rtc_init(void)
30 {
31 	/* Ensure the date is set including century byte. */
32 	cmos_check_update_date();
33 
34 	cmos_init(soc_get_rtc_failed());
35 }
36 
rtc_conf_set_bios_interface_lockdown(void)37 void rtc_conf_set_bios_interface_lockdown(void)
38 {
39 	pcr_rmw32(PID_RTC, PCR_RTC_CONF, ~PCR_RTC_CONF_BILD,
40 					PCR_RTC_CONF_BILD);
41 }
42 
43 #if CONFIG(INTEL_HAS_TOP_SWAP)
configure_rtc_buc_top_swap(enum ts_config ts_state)44 void configure_rtc_buc_top_swap(enum ts_config ts_state)
45 {
46 	pcr_rmw32(PID_RTC, PCR_RTC_BUC, ~PCR_RTC_BUC_TOP_SWAP, ts_state);
47 }
48 
get_rtc_buc_top_swap_status(void)49 enum ts_config get_rtc_buc_top_swap_status(void)
50 {
51 	if (pcr_read32(PID_RTC, PCR_RTC_BUC) & PCR_RTC_BUC_TOP_SWAP)
52 		return TS_ENABLE;
53 	else
54 		return TS_DISABLE;
55 }
56 #endif
57