1 #ifndef __NVIF_DEVICE_H__ 2 #define __NVIF_DEVICE_H__ 3 4 #include <nvif/object.h> 5 #include <nvif/class.h> 6 7 struct nvif_device { 8 struct nvif_object base; 9 struct nvif_object *object; /*XXX: hack for nvif_object() */ 10 struct nv_device_info_v0 info; 11 }; 12 13 static inline struct nvif_device * 14 nvif_device(struct nvif_object *object) 15 { 16 while (object && object->oclass != 0x0080 /*XXX: NV_DEVICE_CLASS*/ ) 17 object = object->parent; 18 return (void *)object; 19 } 20 21 int nvif_device_init(struct nvif_object *, void (*dtor)(struct nvif_device *), 22 u32 handle, u32 oclass, void *, u32, 23 struct nvif_device *); 24 void nvif_device_fini(struct nvif_device *); 25 int nvif_device_new(struct nvif_object *, u32 handle, u32 oclass, 26 void *, u32, struct nvif_device **); 27 void nvif_device_ref(struct nvif_device *, struct nvif_device **); 28 u64 nvif_device_time(struct nvif_device *); 29 30 /* Delay based on GPU time (ie. PTIMER). 31 * 32 * Will return -ETIMEDOUT unless the loop was terminated with 'break', 33 * where it will return the number of nanoseconds taken instead. 34 */ 35 #define nvif_nsec(d,n,cond...) ({ \ 36 struct nvif_device *_device = (d); \ 37 u64 _nsecs = (n), _time0 = nvif_device_time(_device); \ 38 s64 _taken = 0; \ 39 \ 40 do { \ 41 cond \ 42 } while (_taken = nvif_device_time(_device) - _time0, _taken < _nsecs);\ 43 \ 44 if (_taken >= _nsecs) \ 45 _taken = -ETIMEDOUT; \ 46 _taken; \ 47 }) 48 #define nvif_usec(d,u,cond...) nvif_nsec((d), (u) * 1000, ##cond) 49 #define nvif_msec(d,m,cond...) nvif_usec((d), (m) * 1000, ##cond) 50 51 /*XXX*/ 52 #include <subdev/bios.h> 53 #include <subdev/fb.h> 54 #include <subdev/mmu.h> 55 #include <subdev/bar.h> 56 #include <subdev/gpio.h> 57 #include <subdev/clk.h> 58 #include <subdev/i2c.h> 59 #include <subdev/timer.h> 60 #include <subdev/therm.h> 61 62 #define nvxx_device(a) nv_device(nvxx_object((a))) 63 #define nvxx_bios(a) nvkm_bios(nvxx_device(a)) 64 #define nvxx_fb(a) nvkm_fb(nvxx_device(a)) 65 #define nvxx_mmu(a) nvkm_mmu(nvxx_device(a)) 66 #define nvxx_bar(a) nvkm_bar(nvxx_device(a)) 67 #define nvxx_gpio(a) nvkm_gpio(nvxx_device(a)) 68 #define nvxx_clk(a) nvkm_clk(nvxx_device(a)) 69 #define nvxx_i2c(a) nvkm_i2c(nvxx_device(a)) 70 #define nvxx_timer(a) nvkm_timer(nvxx_device(a)) 71 #define nvxx_therm(a) nvkm_therm(nvxx_device(a)) 72 73 #include <core/device.h> 74 #include <engine/fifo.h> 75 #include <engine/gr.h> 76 #include <engine/sw.h> 77 78 #define nvxx_fifo(a) nvkm_fifo(nvxx_device(a)) 79 #define nvxx_fifo_chan(a) ((struct nvkm_fifo_chan *)nvxx_object(a)) 80 #define nvxx_gr(a) ((struct nvkm_gr *)nvkm_engine(nvxx_object(a), NVDEV_ENGINE_GR)) 81 #endif 82