RTC驱动

RTC功能:
RTC time: 系统关机后保持计时,当系统启动根据RTC时间来更新系统时间,之后系统时间独自运行。关机时把系统时间更新至RTC,因为系统时间精度比较高,相对准确一些。
RTC alarm: 当系统休眠时,用来唤醒系统。比如定时开关机。
RTC watchdog: 系统宕机时,自动重启系统。

The sysfs interface under /sys/class/rtc/rtcN provides access to various
rtc attributes without requiring the use of ioctls.
hctosys: 1 if the RTC provided the system time at boot via the
                 CONFIG_RTC_HCTOSYS kernel option, 0 otherwise
ioctl中有RTC_SET_TIME并且set_time不为NULL
.set_time        = rtc_settime,那么执行哪一个?
系统会先调用RTC_SET_TIME判断其返回状态,如果返回ENOIOCTLCMD,则执行.set_time。

If a driver supports "Magic Close", the driver will not disable the
watchdog unless a specific magic character 'V' has been sent to
/dev/watchdog just before closing the file.
如果你支持:Magic Close ,驱动代码大概会是这样子:
if (c == 'V')
    set_bit(WDT_OK_TO_CLOSE, &wdt_status);

RTC 测试:
time 相关:
date 更改系统时间
设置系统时间:date 032409282011
查看系统时间:date

查看RTC时间:
hwclock -r
把系统时间更新至RTC
hwclock -w
把RTC时间更新至系统
hwclock -s


设置后可以如下查看RTC信息:
cat /proc/driver/rtc
rtc_time        : 09:32:13
rtc_date        : 2011-03-24
alrm_time        : **:**:**
alrm_date        : 2063-**-31
alarm_IRQ        : no
alrm_pending        : no
24hr                : yes

最大值最小值:
date 123123592127
date 限制最大值为2037?(1970 - 2037)
设置格式由上层去做,确保传给驱动的值是合法值

闰年问题:
主要看2月份
闰年:date 022823592020 平年:date 022823592011
设置为2月28日,等一会查看是变为29日还是3月1日。

 

alarm相关:
 /kernel/Documentation/rtc.txt中有个测试程序

watchdog相关:
cat /dev/watchdog 后, watchdog 将启动,timeout后会重启系统
/kernel/Documentation/watchdog下面有测试例子

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值