2015-01-14 13:12:11 +08:00
|
|
|
#ifndef __NVKM_TIMER_H__
|
|
|
|
#define __NVKM_TIMER_H__
|
2012-07-11 14:08:25 +08:00
|
|
|
#include <core/subdev.h>
|
|
|
|
|
2015-01-14 13:12:11 +08:00
|
|
|
struct nvkm_alarm {
|
2012-07-11 14:08:25 +08:00
|
|
|
struct list_head head;
|
|
|
|
u64 timestamp;
|
2015-01-14 13:12:11 +08:00
|
|
|
void (*func)(struct nvkm_alarm *);
|
2012-07-11 14:08:25 +08:00
|
|
|
};
|
|
|
|
|
2012-09-03 07:37:02 +08:00
|
|
|
static inline void
|
2015-01-14 13:12:11 +08:00
|
|
|
nvkm_alarm_init(struct nvkm_alarm *alarm,
|
|
|
|
void (*func)(struct nvkm_alarm *))
|
2012-09-03 07:37:02 +08:00
|
|
|
{
|
|
|
|
INIT_LIST_HEAD(&alarm->head);
|
|
|
|
alarm->func = func;
|
|
|
|
}
|
|
|
|
|
2015-01-14 13:12:11 +08:00
|
|
|
bool nvkm_timer_wait_eq(void *, u64 nsec, u32 addr, u32 mask, u32 data);
|
|
|
|
bool nvkm_timer_wait_ne(void *, u64 nsec, u32 addr, u32 mask, u32 data);
|
|
|
|
bool nvkm_timer_wait_cb(void *, u64 nsec, bool (*func)(void *), void *data);
|
|
|
|
void nvkm_timer_alarm(void *, u32 nsec, struct nvkm_alarm *);
|
|
|
|
void nvkm_timer_alarm_cancel(void *, struct nvkm_alarm *);
|
2012-07-11 14:08:25 +08:00
|
|
|
|
|
|
|
#define NV_WAIT_DEFAULT 2000000000ULL
|
|
|
|
#define nv_wait(o,a,m,v) \
|
2015-01-14 13:12:11 +08:00
|
|
|
nvkm_timer_wait_eq((o), NV_WAIT_DEFAULT, (a), (m), (v))
|
2012-07-11 14:08:25 +08:00
|
|
|
#define nv_wait_ne(o,a,m,v) \
|
2015-01-14 13:12:11 +08:00
|
|
|
nvkm_timer_wait_ne((o), NV_WAIT_DEFAULT, (a), (m), (v))
|
2012-07-31 14:16:21 +08:00
|
|
|
#define nv_wait_cb(o,c,d) \
|
2015-01-14 13:12:11 +08:00
|
|
|
nvkm_timer_wait_cb((o), NV_WAIT_DEFAULT, (c), (d))
|
2012-07-11 14:08:25 +08:00
|
|
|
|
2015-01-14 13:12:11 +08:00
|
|
|
struct nvkm_timer {
|
|
|
|
struct nvkm_subdev base;
|
|
|
|
u64 (*read)(struct nvkm_timer *);
|
|
|
|
void (*alarm)(struct nvkm_timer *, u64 time, struct nvkm_alarm *);
|
|
|
|
void (*alarm_cancel)(struct nvkm_timer *, struct nvkm_alarm *);
|
2012-07-11 14:08:25 +08:00
|
|
|
};
|
|
|
|
|
2015-01-14 13:12:11 +08:00
|
|
|
static inline struct nvkm_timer *
|
|
|
|
nvkm_timer(void *obj)
|
2012-07-11 14:08:25 +08:00
|
|
|
{
|
2015-01-14 13:12:11 +08:00
|
|
|
return (void *)nvkm_subdev(obj, NVDEV_SUBDEV_TIMER);
|
2012-07-11 14:08:25 +08:00
|
|
|
}
|
|
|
|
|
2015-01-14 13:12:11 +08:00
|
|
|
#define nvkm_timer_create(p,e,o,d) \
|
|
|
|
nvkm_subdev_create_((p), (e), (o), 0, "PTIMER", "timer", \
|
2012-07-11 14:08:25 +08:00
|
|
|
sizeof(**d), (void **)d)
|
2015-01-14 13:12:11 +08:00
|
|
|
#define nvkm_timer_destroy(p) \
|
|
|
|
nvkm_subdev_destroy(&(p)->base)
|
|
|
|
#define nvkm_timer_init(p) \
|
|
|
|
nvkm_subdev_init(&(p)->base)
|
|
|
|
#define nvkm_timer_fini(p,s) \
|
|
|
|
nvkm_subdev_fini(&(p)->base, (s))
|
|
|
|
|
|
|
|
int nvkm_timer_create_(struct nvkm_object *, struct nvkm_engine *,
|
|
|
|
struct nvkm_oclass *, int size, void **);
|
|
|
|
|
|
|
|
extern struct nvkm_oclass nv04_timer_oclass;
|
|
|
|
extern struct nvkm_oclass gk20a_timer_oclass;
|
2012-07-11 14:08:25 +08:00
|
|
|
#endif
|