Add the rt linux 4.1.3-rt3 as base
[kvmfornfv.git] / kernel / drivers / gpu / drm / nouveau / include / nvkm / subdev / timer.h
1 #ifndef __NVKM_TIMER_H__
2 #define __NVKM_TIMER_H__
3 #include <core/subdev.h>
4
5 struct nvkm_alarm {
6         struct list_head head;
7         u64 timestamp;
8         void (*func)(struct nvkm_alarm *);
9 };
10
11 static inline void
12 nvkm_alarm_init(struct nvkm_alarm *alarm,
13                    void (*func)(struct nvkm_alarm *))
14 {
15         INIT_LIST_HEAD(&alarm->head);
16         alarm->func = func;
17 }
18
19 bool nvkm_timer_wait_eq(void *, u64 nsec, u32 addr, u32 mask, u32 data);
20 bool nvkm_timer_wait_ne(void *, u64 nsec, u32 addr, u32 mask, u32 data);
21 bool nvkm_timer_wait_cb(void *, u64 nsec, bool (*func)(void *), void *data);
22 void nvkm_timer_alarm(void *, u32 nsec, struct nvkm_alarm *);
23 void nvkm_timer_alarm_cancel(void *, struct nvkm_alarm *);
24
25 #define NV_WAIT_DEFAULT 2000000000ULL
26 #define nv_wait(o,a,m,v)                                                       \
27         nvkm_timer_wait_eq((o), NV_WAIT_DEFAULT, (a), (m), (v))
28 #define nv_wait_ne(o,a,m,v)                                                    \
29         nvkm_timer_wait_ne((o), NV_WAIT_DEFAULT, (a), (m), (v))
30 #define nv_wait_cb(o,c,d)                                                      \
31         nvkm_timer_wait_cb((o), NV_WAIT_DEFAULT, (c), (d))
32
33 struct nvkm_timer {
34         struct nvkm_subdev base;
35         u64  (*read)(struct nvkm_timer *);
36         void (*alarm)(struct nvkm_timer *, u64 time, struct nvkm_alarm *);
37         void (*alarm_cancel)(struct nvkm_timer *, struct nvkm_alarm *);
38 };
39
40 static inline struct nvkm_timer *
41 nvkm_timer(void *obj)
42 {
43         return (void *)nvkm_subdev(obj, NVDEV_SUBDEV_TIMER);
44 }
45
46 #define nvkm_timer_create(p,e,o,d)                                          \
47         nvkm_subdev_create_((p), (e), (o), 0, "PTIMER", "timer",            \
48                                sizeof(**d), (void **)d)
49 #define nvkm_timer_destroy(p)                                               \
50         nvkm_subdev_destroy(&(p)->base)
51 #define nvkm_timer_init(p)                                                  \
52         nvkm_subdev_init(&(p)->base)
53 #define nvkm_timer_fini(p,s)                                                \
54         nvkm_subdev_fini(&(p)->base, (s))
55
56 int nvkm_timer_create_(struct nvkm_object *, struct nvkm_engine *,
57                           struct nvkm_oclass *, int size, void **);
58
59 extern struct nvkm_oclass nv04_timer_oclass;
60 extern struct nvkm_oclass gk20a_timer_oclass;
61 #endif