mb/system76/cml-u/dt: Make use of chipset devicetree
[coreboot.git] / src / soc / intel / common / block / rtc / rtc.c
blob5a5de912bba7fe0269874c0c21cb617536a410ae
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <intelblocks/pcr.h>
4 #include <intelblocks/rtc.h>
5 #include <soc/pcr_ids.h>
6 #include <pc80/mc146818rtc.h>
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)
18 void enable_rtc_upper_bank(void)
20 /* Enable upper 128 bytes of CMOS */
21 pcr_or32(PID_RTC, PCR_RTC_CONF, PCR_RTC_CONF_UCMOS_EN);
24 __weak int soc_get_rtc_failed(void)
26 return 0;
29 void rtc_init(void)
31 /* Ensure the date is set including century byte. */
32 cmos_check_update_date();
34 cmos_init(soc_get_rtc_failed());
37 void rtc_conf_set_bios_interface_lockdown(void)
39 pcr_rmw32(PID_RTC, PCR_RTC_CONF, ~PCR_RTC_CONF_BILD,
40 PCR_RTC_CONF_BILD);
43 #if CONFIG(INTEL_HAS_TOP_SWAP)
44 void configure_rtc_buc_top_swap(enum ts_config ts_state)
46 pcr_rmw32(PID_RTC, PCR_RTC_BUC, ~PCR_RTC_BUC_TOP_SWAP, ts_state);
49 enum ts_config get_rtc_buc_top_swap_status(void)
51 if (pcr_read32(PID_RTC, PCR_RTC_BUC) & PCR_RTC_BUC_TOP_SWAP)
52 return TS_ENABLE;
53 else
54 return TS_DISABLE;
56 #endif