2. linux kernel 中 已经支持S3C2410的RTC,但是并没有添加到平台设备初始化数组中,所以系统启动时并不会初始化这一部分,需要修改文件mach-smdk.c
static struct platform_device *smdk2410_devices[] __initdata = {
&s3c_device_ohci,
&s3c_device_lcd,
&s3c_device_wdt,
&s3c_device_i2c0,
&s3c_device_iis,
&s3c_device_rtc, //新增代码
};
3. 创建设备节点,在文件系统/dev目录下执行:
sudo mknod rtc c 10 135
4. 重新编译内核,查看启动信息
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
s3c-rtc s3c2410-rtc: rtc disabled, re-enabling
s3c-rtc s3c2410-rtc: rtc core: registered s3c as rtc0
这里说明rtc驱动起来可以正常工作了
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
No device for DAI UDA134X
No device for DAI s3c24xx-i2s
ALSA device list:
No soundcards found.
TCP cubic registered
NET: Registered protocol family 17
s3c-rtc s3c2410-rtc: hctosys: invalid date/time
以上信息说明当前 RTC 时间invalid , RTC 初始时间为 Wed Dec 31 23:59:59 1969 ;
从内核函数 int rtc_valid_tm(struct rtc_time *tm) ,可以看出,当 year 小于 1970 时,认为是时间 invalid ,函数返回 -EINVAL ;
drivers/rtc/rtc-lib.c
/*
* Does the rtc_time represent a valid date/time?
*/
int rtc_valid_tm(struct rtc_time *tm)
{
if (tm->tm_year < 70
|| ((unsigned)tm->tm_mon) >= 12
|| tm->tm_mday < 1
|| tm->tm_mday > rtc_month_days(tm->tm_mon, tm->tm_year + 1900)
|| ((unsigned)tm->tm_hour) >= 24
|| ((unsigned)tm->tm_min) >= 60
|| ((unsigned)tm->tm_sec) >= 60)
return -EINVAL;
return 0;
}
EXPORT_SYMBOL(rtc_valid_tm);