fix dependency check logic cause config always disabled
[lunaix-os.git] / lunaix-os / includes / hal / hwrtc.h
1 #ifndef __LUNAIX_HWRTC_H
2 #define __LUNAIX_HWRTC_H
3
4 #include <lunaix/device.h>
5 #include <lunaix/ds/ldga.h>
6 #include <lunaix/ds/llist.h>
7 #include <lunaix/time.h>
8
9 #define RTC_STATE_MASKED 0x1
10
11 struct hwrtc_potens;
12 struct hwrtc_potens_ops
13 {
14     void (*get_walltime)(struct hwrtc_potens*, datetime_t*);
15     void (*set_walltime)(struct hwrtc_potens*, datetime_t*);
16     void (*set_proactive)(struct hwrtc_potens*, bool);
17     int  (*chfreq)(struct hwrtc_potens*, int);
18
19     int (*calibrate)(struct hwrtc_potens*);
20 };
21
22 struct hwrtc_potens
23 {
24     POTENS_META;
25
26     struct llist_header rtc_potentes;
27     struct device* rtc_proxy;
28
29     ticks_t base_freq;
30     volatile ticks_t live;
31     int state;
32
33     struct hwrtc_potens_ops* ops;
34 };
35
36 void
37 hwrtc_init();
38
39 void
40 hwrtc_walltime(datetime_t* dt);
41
42 struct hwrtc_potens*
43 hwrtc_attach_potens(struct device* raw_rtcdev, struct hwrtc_potens_ops* ops);
44
45 #endif /* __LUNAIX_HWRTC_H */