1 #ifndef __NOUVEAU_TIMER_H__
2 #define __NOUVEAU_TIMER_H__
4 #include <core/subdev.h>
5 #include <core/device.h>
10 void (*func)(struct nouveau_alarm *);
13 bool nouveau_timer_wait_eq(void *, u64 nsec, u32 addr, u32 mask, u32 data);
14 bool nouveau_timer_wait_ne(void *, u64 nsec, u32 addr, u32 mask, u32 data);
15 bool nouveau_timer_wait_cb(void *, u64 nsec, bool (*func)(void *), void *data);
16 void nouveau_timer_alarm(void *, u32 nsec, struct nouveau_alarm *);
18 #define NV_WAIT_DEFAULT 2000000000ULL
19 #define nv_wait(o,a,m,v) \
20 nouveau_timer_wait_eq((o), NV_WAIT_DEFAULT, (a), (m), (v))
21 #define nv_wait_ne(o,a,m,v) \
22 nouveau_timer_wait_ne((o), NV_WAIT_DEFAULT, (a), (m), (v))
23 #define nv_wait_cb(o,c,d) \
24 nouveau_timer_wait_cb((o), NV_WAIT_DEFAULT, (c), (d))
26 struct nouveau_timer {
27 struct nouveau_subdev base;
28 u64 (*read)(struct nouveau_timer *);
29 void (*alarm)(struct nouveau_timer *, u32 time, struct nouveau_alarm *);
32 static inline struct nouveau_timer *
33 nouveau_timer(void *obj)
35 return (void *)nv_device(obj)->subdev[NVDEV_SUBDEV_TIMER];
38 #define nouveau_timer_create(p,e,o,d) \
39 nouveau_subdev_create_((p), (e), (o), 0, "PTIMER", "timer", \
40 sizeof(**d), (void **)d)
41 #define nouveau_timer_destroy(p) \
42 nouveau_subdev_destroy(&(p)->base)
43 #define nouveau_timer_init(p) \
44 nouveau_subdev_init(&(p)->base)
45 #define nouveau_timer_fini(p,s) \
46 nouveau_subdev_fini(&(p)->base, (s))
48 int nouveau_timer_create_(struct nouveau_object *, struct nouveau_engine *,
49 struct nouveau_oclass *, int size, void **);
51 extern struct nouveau_oclass nv04_timer_oclass;