RTC

Introduction

Face-RK3399 development board has an RTC (Real Time Clock) integrated into the RK808. The main functions are clock, calendar, alarm clock, periodic interrupt, dual channel 32KHz clock output.

After J2 is connected with CR2032 button battery, it can ensure that the RTC can run normally after the board power down.

After Face-RK3399 V2, RTC uses hym8563 external RTC chip which run in i2c7 bus. There is farad capacitor on the board for power consumption.

RTC drive

  • DTS configuration information is stored on the rk808 node.

  • Driver code path: drivers/rtc/rtc-rk808.c

  • V2 Driver code path: drivers/rtc/rtc-hym8563.c

Interface usage

Linux provides three user-space interfaces. The corresponding path in the Face-RK3399 development board is:

  • SYSFS Interface: /sys/class/rtc/rtc0/

  • PROCFS Interface: /proc/driver/rtc

  • IOCTL Interface: /dev/rtc0

SYSFS Interface

You can operate the interfaces in /sys/class/rtc/rtc0/ by cat and echo command directly.

For example, check the date and time of the current RTC:

# cat /sys/class/rtc/rtc0/date
2013-01-18
# cat /sys/class/rtc/rtc0/time
09:36:10

Set the startup time, such as starting up after 120 seconds:

# Start up after 120 seconds
echo +120 >  /sys/class/rtc/rtc0/wakealarm
# View boot time
cat /sys/class/rtc/rtc0/wakealarm
# Power off
reboot -p

PROCFS Interface

Print RTC related information:

# cat /proc/driver/rtc
rtc_time        : 09:34:59
rtc_date        : 2013-01-18
alrm_time       : 08:52:45
alrm_date       : 2013-01-18
alarm_IRQ       : no
alrm_pending    : no
update IRQ enabled      : no
periodic IRQ enabled    : no
periodic IRQ frequency  : 1
max user IRQ frequency  : 64
24hr            : yes

IOCTL Interface

You can use ioctl to control /dev/rtc0.

Please refer to the document rtc.txt for more details.

FAQs

Q1: The time is out of sync after the development board is powered on?

A1 : Check that the RTC battery is properly connected.