RTC实时时钟设备由结构体struct rtc_device 表示
struct rtc_device
{
struct device dev; //内嵌设备结构体
struct module *owner; //指向自身所在的模块
int id; //设备的ID号
char name[RTC_DEVICE_NAME_SIZE]; //RTC名字
const struct rtc_class_ops *ops; //类操作函数集
struct mutex ops_lock; //互斥锁
struct cdev char_dev; //内嵌一个字符设备
unsigned long flags; //RTC状态标志
unsigned long irq_data; //中断数据
spinlock_t irq_lock; //中断自旋锁
wait_queue_head_t irq_queue; //中断等待队列头
struct fasync_struct *async_queue; //异步队列
struct rtc_task *irq_task; //RTC的任务结构体
spinlock_t irq_task_lock; //自旋锁
int irq_freq; //中断频率
int max_user_freq; 最大的用户频率
#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL
struct work_struct uie_task;
struct timer_list uie_timer;
/* Those fields are protected by rtc->irq_lock */
unsigned int oldsecs;
unsigned int uie_irq_active:1;
unsigned int stop_uie_polling:1;
unsigned int uie_task_active:1;
unsigned int uie_timer_active:1;T
#endif
};
RTC平台设备结构体:
struct platform_device s3c_device_rtc = {
.name = "s3c2410-rtc",
.id = -1,
.num_resources = ARRAY_SIZE(s3c_rtc_resource),
.resource = s3c_rtc_resource,
};
s3c2440处理器的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
}
}; |