]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
a04d0423 BS |
2 | #ifndef __NVIF_DEVICE_H__ |
3 | #define __NVIF_DEVICE_H__ | |
4 | ||
c39f472e | 5 | #include <nvif/object.h> |
923bc416 | 6 | #include <nvif/cl0080.h> |
37e1c45a | 7 | #include <nvif/user.h> |
a04d0423 BS |
8 | |
9 | struct nvif_device { | |
a01ca78c | 10 | struct nvif_object object; |
a04d0423 | 11 | struct nv_device_info_v0 info; |
cc362050 BS |
12 | |
13 | struct nvif_fifo_runlist { | |
14 | u64 engines; | |
15 | } *runlist; | |
16 | int runlists; | |
37e1c45a BS |
17 | |
18 | struct nvif_user user; | |
a04d0423 BS |
19 | }; |
20 | ||
315a8b2e | 21 | int nvif_device_init(struct nvif_object *, u32 handle, s32 oclass, void *, u32, |
a04d0423 BS |
22 | struct nvif_device *); |
23 | void nvif_device_fini(struct nvif_device *); | |
56f67dc1 BS |
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) | |
a04d0423 BS |
46 | |
47 | /*XXX*/ | |
48 | #include <subdev/bios.h> | |
49 | #include <subdev/fb.h> | |
a04d0423 BS |
50 | #include <subdev/bar.h> |
51 | #include <subdev/gpio.h> | |
f3867f43 | 52 | #include <subdev/clk.h> |
a04d0423 BS |
53 | #include <subdev/i2c.h> |
54 | #include <subdev/timer.h> | |
55 | #include <subdev/therm.h> | |
340b0e7c | 56 | #include <subdev/pci.h> |
a04d0423 | 57 | |
a01ca78c BS |
58 | #define nvxx_device(a) ({ \ |
59 | struct nvif_device *_device = (a); \ | |
68f3f702 BS |
60 | struct { \ |
61 | struct nvkm_object object; \ | |
62 | struct nvkm_device *device; \ | |
63 | } *_udevice = _device->object.priv; \ | |
64 | _udevice->device; \ | |
a01ca78c | 65 | }) |
46484438 | 66 | #define nvxx_bios(a) nvxx_device(a)->bios |
03c8952f | 67 | #define nvxx_fb(a) nvxx_device(a)->fb |
2ea7249f | 68 | #define nvxx_gpio(a) nvxx_device(a)->gpio |
6625f55c | 69 | #define nvxx_clk(a) nvxx_device(a)->clk |
49bd8da5 | 70 | #define nvxx_i2c(a) nvxx_device(a)->i2c |
353b9834 | 71 | #define nvxx_iccsense(a) nvxx_device(a)->iccsense |
57113c01 | 72 | #define nvxx_therm(a) nvxx_device(a)->therm |
2e7db87d | 73 | #define nvxx_volt(a) nvxx_device(a)->volt |
a04d0423 | 74 | |
a04d0423 | 75 | #include <engine/fifo.h> |
b8bf04e1 | 76 | #include <engine/gr.h> |
a04d0423 | 77 | |
27f3d6cf | 78 | #define nvxx_gr(a) nvxx_device(a)->gr |
a04d0423 | 79 | #endif |