aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/rtc.h
diff options
context:
space:
mode:
authorAlessandro Zummo <a.zummo@towertech.it>2006-03-27 04:16:37 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-27 11:44:51 -0500
commit0c86edc0d4970649f39748c4ce4f2895f728468f (patch)
treed4a4b0a45922fff8add243d14c8377eb902aa80a /include/linux/rtc.h
parent4079c39aaab65022f4875609d76e62669ef94c29 (diff)
[PATCH] RTC subsystem: class
Add the basic RTC subsystem infrastructure to the kernel. rtc/class.c - registration facilities for RTC drivers rtc/interface.c - kernel/rtc interface functions rtc/hctosys.c - snippet of code that copies hw clock to sw clock at bootup, if configured to do so. Signed-off-by: Alessandro Zummo <a.zummo@towertech.it> Acked-by: Greg Kroah-Hartman <gregkh@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/linux/rtc.h')
-rw-r--r--include/linux/rtc.h87
1 files changed, 87 insertions, 0 deletions
diff --git a/include/linux/rtc.h b/include/linux/rtc.h
index 8454337c7058..ab61cd1199f2 100644
--- a/include/linux/rtc.h
+++ b/include/linux/rtc.h
@@ -91,6 +91,12 @@ struct rtc_pll_info {
91#define RTC_PLL_GET _IOR('p', 0x11, struct rtc_pll_info) /* Get PLL correction */ 91#define RTC_PLL_GET _IOR('p', 0x11, struct rtc_pll_info) /* Get PLL correction */
92#define RTC_PLL_SET _IOW('p', 0x12, struct rtc_pll_info) /* Set PLL correction */ 92#define RTC_PLL_SET _IOW('p', 0x12, struct rtc_pll_info) /* Set PLL correction */
93 93
94/* interrupt flags */
95#define RTC_IRQF 0x80 /* any of the following is active */
96#define RTC_PF 0x40
97#define RTC_AF 0x20
98#define RTC_UF 0x10
99
94#ifdef __KERNEL__ 100#ifdef __KERNEL__
95 101
96#include <linux/interrupt.h> 102#include <linux/interrupt.h>
@@ -100,6 +106,87 @@ extern int rtc_valid_tm(struct rtc_time *tm);
100extern int rtc_tm_to_time(struct rtc_time *tm, unsigned long *time); 106extern int rtc_tm_to_time(struct rtc_time *tm, unsigned long *time);
101extern void rtc_time_to_tm(unsigned long time, struct rtc_time *tm); 107extern void rtc_time_to_tm(unsigned long time, struct rtc_time *tm);
102 108
109#include <linux/device.h>
110#include <linux/seq_file.h>
111#include <linux/cdev.h>
112#include <linux/poll.h>
113#include <linux/mutex.h>
114
115extern struct class *rtc_class;
116
117struct rtc_class_ops {
118 int (*open)(struct device *);
119 void (*release)(struct device *);
120 int (*ioctl)(struct device *, unsigned int, unsigned long);
121 int (*read_time)(struct device *, struct rtc_time *);
122 int (*set_time)(struct device *, struct rtc_time *);
123 int (*read_alarm)(struct device *, struct rtc_wkalrm *);
124 int (*set_alarm)(struct device *, struct rtc_wkalrm *);
125 int (*proc)(struct device *, struct seq_file *);
126 int (*set_mmss)(struct device *, unsigned long secs);
127 int (*irq_set_state)(struct device *, int enabled);
128 int (*irq_set_freq)(struct device *, int freq);
129 int (*read_callback)(struct device *, int data);
130};
131
132#define RTC_DEVICE_NAME_SIZE 20
133struct rtc_task;
134
135struct rtc_device
136{
137 struct class_device class_dev;
138 struct module *owner;
139
140 int id;
141 char name[RTC_DEVICE_NAME_SIZE];
142
143 struct rtc_class_ops *ops;
144 struct mutex ops_lock;
145
146 struct class_device *rtc_dev;
147 struct cdev char_dev;
148 struct mutex char_lock;
149
150 unsigned long irq_data;
151 spinlock_t irq_lock;
152 wait_queue_head_t irq_queue;
153 struct fasync_struct *async_queue;
154
155 struct rtc_task *irq_task;
156 spinlock_t irq_task_lock;
157 int irq_freq;
158};
159#define to_rtc_device(d) container_of(d, struct rtc_device, class_dev)
160
161extern struct rtc_device *rtc_device_register(const char *name,
162 struct device *dev,
163 struct rtc_class_ops *ops,
164 struct module *owner);
165extern void rtc_device_unregister(struct rtc_device *rdev);
166extern int rtc_interface_register(struct class_interface *intf);
167
168extern int rtc_read_time(struct class_device *class_dev, struct rtc_time *tm);
169extern int rtc_set_time(struct class_device *class_dev, struct rtc_time *tm);
170extern int rtc_set_mmss(struct class_device *class_dev, unsigned long secs);
171extern int rtc_read_alarm(struct class_device *class_dev,
172 struct rtc_wkalrm *alrm);
173extern int rtc_set_alarm(struct class_device *class_dev,
174 struct rtc_wkalrm *alrm);
175extern void rtc_update_irq(struct class_device *class_dev,
176 unsigned long num, unsigned long events);
177
178extern struct class_device *rtc_class_open(char *name);
179extern void rtc_class_close(struct class_device *class_dev);
180
181extern int rtc_irq_register(struct class_device *class_dev,
182 struct rtc_task *task);
183extern void rtc_irq_unregister(struct class_device *class_dev,
184 struct rtc_task *task);
185extern int rtc_irq_set_state(struct class_device *class_dev,
186 struct rtc_task *task, int enabled);
187extern int rtc_irq_set_freq(struct class_device *class_dev,
188 struct rtc_task *task, int freq);
189
103typedef struct rtc_task { 190typedef struct rtc_task {
104 void (*func)(void *private_data); 191 void (*func)(void *private_data);
105 void *private_data; 192 void *private_data;