SyterKit 0.4.0.x
SyterKit is a bare-metal framework
Loading...
Searching...
No Matches
Functions
sys-rtc.c File Reference

System RTC (Real-Time Clock) driver for Allwinner (sunxi) platforms. More...

#include <io.h>
#include <log.h>
#include <mmu.h>
#include <cache.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <timer.h>
#include <types.h>
#include <reg-ncat.h>
#include <sys-rtc.h>
Include dependency graph for sys-rtc.c:

Functions

void rtc_write_data (int index, uint32_t val)
 Write data to an RTC register.
 
uint32_t rtc_read_data (int index)
 Read data from an RTC register.
 
void rtc_set_fel_flag (void)
 Set the FEL (Fastboot External Loader) flag.
 
void rtc_set_start_time_ms (void)
 Set the initialization timestamp.
 
void rtc_set_dram_para (uint32_t dram_para_addr)
 Sets the parameters for Dynamic Random Access Memory (DRAM).
 
uint32_t rtc_probe_fel_flag (void)
 Check if the FEL flag is set.
 
void rtc_clear_fel_flag (void)
 Clear the FEL (Fastboot External Loader) flag.
 
int rtc_set_bootmode_flag (uint8_t flag)
 Set the boot mode flag.
 
int rtc_get_bootmode_flag (void)
 Get the boot mode flag.
 

Detailed Description

System RTC (Real-Time Clock) driver for Allwinner (sunxi) platforms.

This file implements RTC functionality for Allwinner SoCs, providing interface functions to read from and write to RTC registers. The RTC is used to store various persistent flags and parameters, including FEL (Fastboot External Loader) mode flag, boot mode information, DRAM parameters, and initialization timestamp. These values are retained even when the system is powered off, as long as there is backup battery power.

Function Documentation

◆ rtc_clear_fel_flag()

void rtc_clear_fel_flag ( void  )

Clear the FEL (Fastboot External Loader) flag.

Clear the FEL (Fastboot External Loader) flag in the RTC register.

Clears the FEL flag in the RTC register after it has been processed. The function verifies the write operation was successful by reading back the value.

◆ rtc_get_bootmode_flag()

int rtc_get_bootmode_flag ( void  )

Get the boot mode flag.

Get the bootmode flag from the RTC register.

Reads the boot mode flag from the RTC register. This is used to determine how the system should boot. The operation is designed to be compatible with how the kernel reads this value.

Returns
The value of the boot mode flag

◆ rtc_probe_fel_flag()

uint32_t rtc_probe_fel_flag ( void  )

Check if the FEL flag is set.

Probe the FEL (Fastboot External Loader) flag in the RTC register.

Reads the FEL flag from the RTC register and returns whether it is set.

Returns
1 if the FEL flag is set, 0 otherwise

◆ rtc_read_data()

uint32_t rtc_read_data ( int  index)

Read data from an RTC register.

Read data from the RTC register at the specified index.

Reads a 32-bit value from the RTC register at the specified index.

Parameters
indexThe index of the RTC register to read data from
Returns
The value read from the RTC register

◆ rtc_set_bootmode_flag()

int rtc_set_bootmode_flag ( uint8_t  flag)

Set the boot mode flag.

Set the bootmode flag in the RTC register.

Sets the boot mode flag in the RTC register, which determines how the system will boot. The function verifies the write operation was successful.

Parameters
flagThe boot mode flag value to set
Returns
0 if successful

◆ rtc_set_dram_para()

void rtc_set_dram_para ( uint32_t  dram_para_addr)

Sets the parameters for Dynamic Random Access Memory (DRAM).

This function is used to set the parameters for DRAM and ensures the success of parameter setting through a loop.

Parameters
dram_para_addrAddress for DRAM parameters to be set.
Returns
None.
Note
This function continuously attempts to set DRAM parameters until it succeeds.

◆ rtc_set_fel_flag()

void rtc_set_fel_flag ( void  )

Set the FEL (Fastboot External Loader) flag.

Set the FEL (Fastboot External Loader) flag in the RTC register.

Sets the FEL flag in the RTC register, which indicates that the system should enter Fastboot mode. The function verifies the write operation was successful by reading back the value.

◆ rtc_set_start_time_ms()

void rtc_set_start_time_ms ( void  )

Set the initialization timestamp.

Set the start time in milliseconds in the RTC register.

Stores the initialization timestamp (in milliseconds) in the RTC register. This value can be used for timing operations or to determine the system uptime. The function verifies the write operation was successful.

◆ rtc_write_data()

void rtc_write_data ( int  index,
uint32_t  val 
)

Write data to an RTC register.

Write data to the RTC register at the specified index.

Writes a 32-bit value to the RTC register at the specified index.

Parameters
indexThe index of the RTC register to write data to
valThe value to write to the RTC register