xref: /linux/drivers/gpu/drm/nouveau/include/nvif/device.h (revision 44f57d78)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __NVIF_DEVICE_H__
3 #define __NVIF_DEVICE_H__
4 
5 #include <nvif/object.h>
6 #include <nvif/cl0080.h>
7 #include <nvif/user.h>
8 
9 struct nvif_device {
10 	struct nvif_object object;
11 	struct nv_device_info_v0 info;
12 
13 	struct nvif_fifo_runlist {
14 		u64 engines;
15 	} *runlist;
16 	int runlists;
17 
18 	struct nvif_user user;
19 };
20 
21 int  nvif_device_init(struct nvif_object *, u32 handle, s32 oclass, void *, u32,
22 		      struct nvif_device *);
23 void nvif_device_fini(struct nvif_device *);
24 u64  nvif_device_time(struct nvif_device *);
25 
26 /* Delay based on GPU time (ie. PTIMER).
27  *
28  * Will return -ETIMEDOUT unless the loop was terminated with 'break',
29  * where it will return the number of nanoseconds taken instead.
30  */
31 #define nvif_nsec(d,n,cond...) ({                                              \
32 	struct nvif_device *_device = (d);                                     \
33 	u64 _nsecs = (n), _time0 = nvif_device_time(_device);                  \
34 	s64 _taken = 0;                                                        \
35                                                                                \
36 	do {                                                                   \
37 		cond                                                           \
38 	} while (_taken = nvif_device_time(_device) - _time0, _taken < _nsecs);\
39                                                                                \
40 	if (_taken >= _nsecs)                                                  \
41 		_taken = -ETIMEDOUT;                                           \
42 	_taken;                                                                \
43 })
44 #define nvif_usec(d,u,cond...) nvif_nsec((d), (u) * 1000, ##cond)
45 #define nvif_msec(d,m,cond...) nvif_usec((d), (m) * 1000, ##cond)
46 
47 /*XXX*/
48 #include <subdev/bios.h>
49 #include <subdev/fb.h>
50 #include <subdev/bar.h>
51 #include <subdev/gpio.h>
52 #include <subdev/clk.h>
53 #include <subdev/i2c.h>
54 #include <subdev/timer.h>
55 #include <subdev/therm.h>
56 #include <subdev/pci.h>
57 
58 #define nvxx_device(a) ({                                                      \
59 	struct nvif_device *_device = (a);                                     \
60 	struct {                                                               \
61 		struct nvkm_object object;                                     \
62 		struct nvkm_device *device;                                    \
63 	} *_udevice = _device->object.priv;                                    \
64 	_udevice->device;                                                      \
65 })
66 #define nvxx_bios(a) nvxx_device(a)->bios
67 #define nvxx_fb(a) nvxx_device(a)->fb
68 #define nvxx_gpio(a) nvxx_device(a)->gpio
69 #define nvxx_clk(a) nvxx_device(a)->clk
70 #define nvxx_i2c(a) nvxx_device(a)->i2c
71 #define nvxx_iccsense(a) nvxx_device(a)->iccsense
72 #define nvxx_therm(a) nvxx_device(a)->therm
73 #define nvxx_volt(a) nvxx_device(a)->volt
74 
75 #include <engine/fifo.h>
76 #include <engine/gr.h>
77 
78 #define nvxx_gr(a) nvxx_device(a)->gr
79 #endif
80