内核版本:linux-2.6.32.2 实验平台:mini2440
s3c2440的rtc平台设备已经定义好了的,定义在plat-s3c24xx/devs.c中:
/* RTC */
static struct resource s3c_rtc_resource[] = {
[0] = {
.start = S3C24XX_PA_RTC,
.end = S3C24XX_PA_RTC + 0xff,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = IRQ_RTC,
.end = IRQ_RTC,
.flags = IORESOURCE_IRQ,
},
[2] = {
.start = IRQ_TICK,
.end = IRQ_TICK,
.flags = IORESOURCE_IRQ
}
};
struct platform_device s3c_device_rtc = {
.name = "s3c2410-rtc",
.id = -1,
.num_resources = ARRAY_SIZE(s3c_rtc_resource),
.resource = s3c_rtc_resource,
};
EXPORT_SYMBOL(s3c_device_rtc);
将s3c_device_rtc添加到mini2440_devices这个平台设备数组里面:static struct platform_device *mini2440_devices[] __initdata = {
/* ... */
&s3c_device_rtc,
/* ... */
};
2. 配置
linux的s3c2440的rtc驱动已经支持的很好了,只需要配置使用就可以了:
Device Drivers ---> <*> Real Time Clock ---> [*] Set system time from RTC on startup and resume (rtc0) RTC used to set the system time [*] /sys/class/rtc/rtcN (sysfs) [*] /proc/driver/rtc (procfs for rtc0) [*] /dev/rtcN (character devices) <*> Samsung S3C series SoC RTC
3. 测试
使用date命令修改linux的系统时钟:
date "2014-07-09 23:44:00"使用hwclock -w命令将系统时钟写入到硬件时钟里面,hwclock -r显示硬件时钟,当系统启动之后会将系统时钟设置为当前的硬件时钟,这样在电池存在情况下,即使板子掉电时钟也能正常走动。