timer.h revision 5a5c7432bbbd2e318dff107b4ff960ab543a7cef
1#ifndef __NOUVEAU_TIMER_H__ 2#define __NOUVEAU_TIMER_H__ 3 4#include <core/subdev.h> 5#include <core/device.h> 6 7struct nouveau_alarm { 8 struct list_head head; 9 u64 timestamp; 10 void (*func)(struct nouveau_alarm *); 11}; 12 13bool nouveau_timer_wait_eq(void *, u64 nsec, u32 addr, u32 mask, u32 data); 14bool nouveau_timer_wait_ne(void *, u64 nsec, u32 addr, u32 mask, u32 data); 15bool nouveau_timer_wait_cb(void *, u64 nsec, bool (*func)(void *), void *data); 16void nouveau_timer_alarm(void *, u32 nsec, struct nouveau_alarm *); 17 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,a,m,v) \ 24 nouveau_timer_wait_cb((o), NV_WAIT_DEFAULT, (a), (m), (v)) 25 26struct nouveau_timer { 27 struct nouveau_subdev base; 28 u64 (*read)(struct nouveau_timer *); 29 void (*alarm)(struct nouveau_timer *, u32 time, struct nouveau_alarm *); 30}; 31 32static inline struct nouveau_timer * 33nouveau_timer(void *obj) 34{ 35 return (void *)nv_device(obj)->subdev[NVDEV_SUBDEV_TIMER]; 36} 37 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)) 47 48int nouveau_timer_create_(struct nouveau_object *, struct nouveau_engine *, 49 struct nouveau_oclass *, int size, void **); 50 51extern struct nouveau_oclass nv04_timer_oclass; 52 53#endif 54