rtc_time()

unsigned long rtc_time (void)

This is a user-replaceable function responsible for returning the number of seconds since January 1 1970 00:00:00 GMT.

x86
This function defaults to calling rtc_time_mc146818(), which knows how to get the time from an IBM-PC standard clock chip.
MIPS, PowerPC, ARM
The default library version simply returns zero.
SH
The default function calls rtc_time_sh4(), which knows how to get the time from the SH-4 on-chip rtc.

Currently, these are the chip-specific versions:

rtc_time_ds1386()
Dallas Semiconductor DS-1386 compatible
rtc_time_m48t5x()
SGS-Thomson M48T59 RTC/NVRAM chip
rtc_time_mc146818()
Motorola 146818 compatible
rtc_time_rtc72423()
FOX RTC-72423 compatible
rtc_time_rtc8xx()
PPC 800 onboard RTC hardware

There's also a "none" version to use if your board doesn't have RTC hardware:

unsigned long rtc_time_none(void);

For the PPC 800 onboard RTC hardware, the function is simply as follows:

unsigned long rtc_time_rtc8xx(void);

If you're supplying the rtc_time() routine, you should call one of the chip-specific routines or write your own. The chip-specific routines all share the same parameter list:

(paddr_t base, unsigned reg_shift, int mmap, int cent_reg);

The base parameter indicates the physical base address or I/O port of the device. The reg_shift indicates the register offset as a power of two.

A typical value would be 0 (meaning 20, i.e. 1), indicating that the registers of the device are one byte apart in the address space. As another example, a value of 2 (meaning 22, i.e. 4) indicates that the registers in the device are four bytes apart.

If the mmap variable is 0, then the device is in I/O space. If mmap is 1, then the device is in memory space.

Finally, cent_reg indicates which register in the device contains the century byte (-1 indicates no such register). If there's no century byte register, then the behavior is chip-specific. If the chip is year 2000-compliant, then we will get the correct time. If the chip isn't compliant, then if the year is less than 70, we assume it's in the range 2000 to 2069; else we assume it's in the range 1970 to 1999.