xref: /linux/drivers/gpu/drm/nouveau/include/nvif/device.h (revision 93df8a1ed6231727c5db94a80b1a6bd5ee67cec3)
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 
29 /*XXX*/
30 #include <subdev/bios.h>
31 #include <subdev/fb.h>
32 #include <subdev/mmu.h>
33 #include <subdev/bar.h>
34 #include <subdev/gpio.h>
35 #include <subdev/clk.h>
36 #include <subdev/i2c.h>
37 #include <subdev/timer.h>
38 #include <subdev/therm.h>
39 
40 #define nvxx_device(a) nv_device(nvxx_object((a)))
41 #define nvxx_bios(a) nvkm_bios(nvxx_device(a))
42 #define nvxx_fb(a) nvkm_fb(nvxx_device(a))
43 #define nvxx_mmu(a) nvkm_mmu(nvxx_device(a))
44 #define nvxx_bar(a) nvkm_bar(nvxx_device(a))
45 #define nvxx_gpio(a) nvkm_gpio(nvxx_device(a))
46 #define nvxx_clk(a) nvkm_clk(nvxx_device(a))
47 #define nvxx_i2c(a) nvkm_i2c(nvxx_device(a))
48 #define nvxx_timer(a) nvkm_timer(nvxx_device(a))
49 #define nvxx_wait(a,b,c,d) nv_wait(nvxx_timer(a), (b), (c), (d))
50 #define nvxx_wait_cb(a,b,c) nv_wait_cb(nvxx_timer(a), (b), (c))
51 #define nvxx_therm(a) nvkm_therm(nvxx_device(a))
52 
53 #include <core/device.h>
54 #include <engine/fifo.h>
55 #include <engine/gr.h>
56 #include <engine/sw.h>
57 
58 #define nvxx_fifo(a) nvkm_fifo(nvxx_device(a))
59 #define nvxx_fifo_chan(a) ((struct nvkm_fifo_chan *)nvxx_object(a))
60 #define nvxx_gr(a) ((struct nvkm_gr *)nvkm_engine(nvxx_object(a), NVDEV_ENGINE_GR))
61 #endif
62