RTC时钟驱动总结

RTC 也就是实时时钟,用于记录当前系统时间,对于 Linux 系统而言时间是非常重要的
RTC 设备驱动是一个标准的字符设备驱动
Linux 内核将 RTC 设备抽象为 rtc_device 结构体 rtc_device 注册到 Linux 内核里面,这样 Linux 内核就有一个 RTC 设备的
rtc_device 注册到 Linux 内核里面,这样 Linux 内核就有一个 RTC 设备的。
71 struct rtc_class_ops {
72 int (*open)(struct device *);
73 void (*release)(struct device *);
74 int (*ioctl)(struct device *, unsigned int, unsigned long);
75 int (*read_time)(struct device *, struct rtc_time *);
76 int (*set_time)(struct device *, struct rtc_time *);
77 int (*read_alarm)(struct device *, struct rtc_wkalrm *);
78 int (*set_alarm)(struct device *, struct rtc_wkalrm *);
79 int (*proc)(struct device *, struct seq_file *);
80 int (*set_mmss64)(struct device *, time64_t secs);
81 int (*set_mmss)(struct device *, unsigned long secs);
82 int (*read_callback)(struct device *, int data);
83 int (*alarm_irq_enable)(struct device *, unsigned int enabled);
84 };

 struct rtc_device
105 {
106 struct device dev; /* 设备 */
107 struct module *owner;
108 
109 int id; /* ID */ 
110 char name[RTC_DEVICE_NAME_SIZE]; /* 名字 */
111 
112 const struct rtc_class_ops *ops; /* RTC 设备底层操作函数 */
113 struct mutex ops_lock;
114
115 struct cdev char_dev; /* 字符设备 */
116 unsigned long flags;
117
118 unsigned long irq_data;
119 spinlock_t irq_lock;
120 wait_queue_head_t irq_queue;
121 struct fasync_struct *async_queue;
122
123 struct rtc_task *irq_task;
124 spinlock_t irq_task_lock;
125 int irq_freq;
126 int max_user_freq;
127
128 struct timerqueue_head timerqueue;
129 struct rtc_timer aie_timer;
130 struct rtc_timer uie_rtctimer;
131 struct hrtimer pie_timer; /* sub second exp, so needs hrtimer */
132 int pie_enabled;
133 struct work_struct irqwork;
134 /* Some hardware can't support UIE mode */
135 int uie_unsupported;

先直接告诉大家,I.MX6U 的 RTC 驱动我们不用自己编写,因为 NXP 已经写好了。其实对
于大多数的 SOC 来讲,内部 RTC 驱动都不需要我们去编写,半导体厂商会编写好。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

梦幽风

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值