coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
rtc_common.h File Reference
#include <commonlib/bsd/bcd.h>
#include <console/console.h>
#include <rtc.h>
#include <stdbool.h>
Include dependency graph for rtc_common.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define RTCTAG   "[RTC]"
 
#define rtc_info(fmt, arg ...)
 

Enumerations

enum  { RTC_DEFAULT_YEA = 2010 , RTC_DEFAULT_MTH = 1 , RTC_DEFAULT_DOM = 1 , RTC_DEFAULT_DOW = 5 }
 
enum  { RTC_2SEC_REBOOT_ENABLE = 1 , RTC_2SEC_MODE = 2 }
 
enum  { RTC_OSC32CON_UNLOCK1 = 0x1A57 , RTC_OSC32CON_UNLOCK2 = 0x2B68 }
 
enum  { RTC_PROT_UNLOCK1 = 0x586A , RTC_PROT_UNLOCK2 = 0x9136 }
 
enum  { RTC_BBPU_KEY = 0x43 << 8 }
 
enum  { RTC_IRQ_STA_AL = 1U << 0 , RTC_IRQ_STA_TC = 1U << 1 , RTC_IRQ_STA_LP = 1U << 3 }
 
enum  {
  RTC_IRQ_EN_AL = 1U << 0 , RTC_IRQ_EN_TC = 1U << 1 , RTC_IRQ_EN_ONESHOT = 1U << 2 , RTC_IRQ_EN_LP = 1U << 3 ,
  RTC_IRQ_EN_ONESHOT_AL = RTC_IRQ_EN_ONESHOT | RTC_IRQ_EN_AL
}
 
enum  { RTC_POWERKEY1_KEY = 0xA357 , RTC_POWERKEY2_KEY = 0x67D2 }
 
enum  { RTC_SPAR0_32K_LESS = 1U << 6 }
 
enum  { RTC_MIN_YEAR = 1968 , RTC_BASE_YEAR = 1900 , RTC_MIN_YEAR_OFFSET = RTC_MIN_YEAR - RTC_BASE_YEAR , RTC_NUM_YEARS = 128 }
 
enum  { RTC_STATE_REBOOT = 0 , RTC_STATE_RECOVER = 1 , RTC_STATE_INIT = 2 }
 
enum  {
  RTC_STATUS_OK = 0 , RTC_STATUS_POWERKEY_INIT_FAIL , RTC_STATUS_WRITEIF_UNLOCK_FAIL , RTC_STATUS_OSC_SETTING_FAIL ,
  RTC_STATUS_GPIO_INIT_FAIL , RTC_STATUS_HW_INIT_FAIL , RTC_STATUS_REG_INIT_FAIL , RTC_STATUS_LPD_INIT_FAIL
}
 

Functions

bool rtc_write_trigger (void)
 
bool rtc_writeif_unlock (void)
 
bool rtc_xosc_write (u16 val)
 
bool rtc_lpen (u16 con)
 
bool rtc_reg_init (void)
 
void rtc_osc_init (void)
 
bool rtc_powerkey_init (void)
 
void rtc_boot_common (void)
 

Macro Definition Documentation

◆ rtc_info

#define rtc_info (   fmt,
  arg ... 
)
Value:
printk(BIOS_INFO, RTCTAG "%s,%d: " fmt, \
__func__, __LINE__, ## arg)
#define printk(level,...)
Definition: stdlib.h:16
struct bootblock_arg arg
Definition: decompressor.c:22
#define BIOS_INFO
BIOS_INFO - Expected events.
Definition: loglevel.h:113
#define RTCTAG
Definition: rtc_common.h:11

Definition at line 12 of file rtc_common.h.

◆ RTCTAG

#define RTCTAG   "[RTC]"

Definition at line 11 of file rtc_common.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
RTC_DEFAULT_YEA 
RTC_DEFAULT_MTH 
RTC_DEFAULT_DOM 
RTC_DEFAULT_DOW 

Definition at line 22 of file rtc_common.h.

◆ anonymous enum

anonymous enum
Enumerator
RTC_2SEC_REBOOT_ENABLE 
RTC_2SEC_MODE 

Definition at line 29 of file rtc_common.h.

◆ anonymous enum

anonymous enum
Enumerator
RTC_OSC32CON_UNLOCK1 
RTC_OSC32CON_UNLOCK2 

Definition at line 34 of file rtc_common.h.

◆ anonymous enum

anonymous enum
Enumerator
RTC_PROT_UNLOCK1 
RTC_PROT_UNLOCK2 

Definition at line 39 of file rtc_common.h.

◆ anonymous enum

anonymous enum
Enumerator
RTC_BBPU_KEY 

Definition at line 44 of file rtc_common.h.

◆ anonymous enum

anonymous enum
Enumerator
RTC_IRQ_STA_AL 
RTC_IRQ_STA_TC 
RTC_IRQ_STA_LP 

Definition at line 48 of file rtc_common.h.

◆ anonymous enum

anonymous enum
Enumerator
RTC_IRQ_EN_AL 
RTC_IRQ_EN_TC 
RTC_IRQ_EN_ONESHOT 
RTC_IRQ_EN_LP 
RTC_IRQ_EN_ONESHOT_AL 

Definition at line 54 of file rtc_common.h.

◆ anonymous enum

anonymous enum
Enumerator
RTC_POWERKEY1_KEY 
RTC_POWERKEY2_KEY 

Definition at line 62 of file rtc_common.h.

◆ anonymous enum

anonymous enum
Enumerator
RTC_SPAR0_32K_LESS 

Definition at line 67 of file rtc_common.h.

◆ anonymous enum

anonymous enum
Enumerator
RTC_MIN_YEAR 
RTC_BASE_YEAR 
RTC_MIN_YEAR_OFFSET 
RTC_NUM_YEARS 

Definition at line 71 of file rtc_common.h.

◆ anonymous enum

anonymous enum
Enumerator
RTC_STATE_REBOOT 
RTC_STATE_RECOVER 
RTC_STATE_INIT 

Definition at line 79 of file rtc_common.h.

◆ anonymous enum

anonymous enum
Enumerator
RTC_STATUS_OK 
RTC_STATUS_POWERKEY_INIT_FAIL 
RTC_STATUS_WRITEIF_UNLOCK_FAIL 
RTC_STATUS_OSC_SETTING_FAIL 
RTC_STATUS_GPIO_INIT_FAIL 
RTC_STATUS_HW_INIT_FAIL 
RTC_STATUS_REG_INIT_FAIL 
RTC_STATUS_LPD_INIT_FAIL 

Definition at line 86 of file rtc_common.h.

Function Documentation

◆ rtc_boot_common()

void rtc_boot_common ( void  )

Definition at line 190 of file rtc.c.

References RTC_BBPU, RTC_BBPU_KEY, RTC_BBPU_RELOAD, rtc_check_state(), RTC_CON, rtc_info, rtc_init(), RTC_IRQ_STA, rtc_osc_init(), rtc_read(), RTC_STATE_INIT, RTC_STATE_REBOOT, RTC_STATE_RECOVER, rtc_write(), and rtc_write_trigger().

Referenced by rtc_boot().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rtc_lpen()

bool rtc_lpen ( u16  con)

Definition at line 97 of file rtc.c.

References RTC_CON, RTC_CON_LPRST, rtc_write(), and rtc_write_trigger().

Referenced by rtc_lpd_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rtc_osc_init()

void rtc_osc_init ( void  )

Definition at line 54 of file rtc_osc_init.c.

References PMIC_RG_TOP_CKTST2, rtc_eosc_cali(), rtc_gpio_init(), rtc_info, RTC_OSC32CON, rtc_read(), rtc_write(), rtc_xosc_write(), and RTC_XOSCCALI_MASK.

Referenced by rtc_boot_common(), and rtc_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rtc_powerkey_init()

bool rtc_powerkey_init ( void  )

Definition at line 156 of file rtc.c.

References RTC_POWERKEY1, RTC_POWERKEY1_KEY, RTC_POWERKEY2, RTC_POWERKEY2_KEY, rtc_write(), and rtc_write_trigger().

Referenced by rtc_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rtc_reg_init()

bool rtc_reg_init ( void  )

◆ rtc_write_trigger()

bool rtc_write_trigger ( void  )

Definition at line 27 of file rtc.c.

References rtc_busy_wait(), rtc_write(), and RTC_WRTGR.

Referenced by rtc_bbpu_power_on(), rtc_boot_common(), rtc_enable_dcxo(), rtc_get_frequency_meter(), rtc_gpio_init(), rtc_hw_init(), rtc_init(), rtc_lpd_init(), rtc_lpen(), rtc_powerkey_init(), rtc_reg_init(), rtc_writeif_unlock(), and rtc_xosc_write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rtc_writeif_unlock()

bool rtc_writeif_unlock ( void  )

Definition at line 34 of file rtc.c.

References RTC_PROT, RTC_PROT_UNLOCK1, RTC_PROT_UNLOCK2, rtc_write(), and rtc_write_trigger().

Referenced by poweroff(), rtc_check_state(), rtc_enable_dcxo(), and rtc_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rtc_xosc_write()

bool rtc_xosc_write ( u16  val)

Definition at line 74 of file rtc.c.

References RTC_BBPU, RTC_BBPU_KEY, RTC_BBPU_RELOAD, rtc_busy_wait(), RTC_OSC32CON, RTC_OSC32CON_UNLOCK1, RTC_OSC32CON_UNLOCK2, rtc_read(), rtc_write(), rtc_write_trigger(), and val.

Referenced by rtc_enable_dcxo(), rtc_get_frequency_meter(), rtc_init(), and rtc_osc_init().

Here is the call graph for this function:
Here is the caller graph for this function: