]>
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> |
a04d0423 BS |
7 | |
8 | struct nvif_device { | |
a01ca78c | 9 | struct nvif_object object; |
a04d0423 BS |
10 | struct nv_device_info_v0 info; |
11 | }; | |
12 | ||
315a8b2e | 13 | int nvif_device_init(struct nvif_object *, u32 handle, s32 oclass, void *, u32, |
a04d0423 BS |
14 | struct nvif_device *); |
15 | void nvif_device_fini(struct nvif_device *); | |
56f67dc1 BS |
16 | u64 nvif_device_time(struct nvif_device *); |
17 | ||
18 | /* Delay based on GPU time (ie. PTIMER). | |
19 | * | |
20 | * Will return -ETIMEDOUT unless the loop was terminated with 'break', | |
21 | * where it will return the number of nanoseconds taken instead. | |
22 | */ | |
23 | #define nvif_nsec(d,n,cond...) ({ \ | |
24 | struct nvif_device *_device = (d); \ | |
25 | u64 _nsecs = (n), _time0 = nvif_device_time(_device); \ | |
26 | s64 _taken = 0; \ | |
27 | \ | |
28 | do { \ | |
29 | cond \ | |
30 | } while (_taken = nvif_device_time(_device) - _time0, _taken < _nsecs);\ | |
31 | \ | |
32 | if (_taken >= _nsecs) \ | |
33 | _taken = -ETIMEDOUT; \ | |
34 | _taken; \ | |
35 | }) | |
36 | #define nvif_usec(d,u,cond...) nvif_nsec((d), (u) * 1000, ##cond) | |
37 | #define nvif_msec(d,m,cond...) nvif_usec((d), (m) * 1000, ##cond) | |
a04d0423 BS |
38 | |
39 | /*XXX*/ | |
40 | #include <subdev/bios.h> | |
41 | #include <subdev/fb.h> | |
5ce3bf3c | 42 | #include <subdev/mmu.h> |
a04d0423 BS |
43 | #include <subdev/bar.h> |
44 | #include <subdev/gpio.h> | |
f3867f43 | 45 | #include <subdev/clk.h> |
a04d0423 BS |
46 | #include <subdev/i2c.h> |
47 | #include <subdev/timer.h> | |
48 | #include <subdev/therm.h> | |
340b0e7c | 49 | #include <subdev/pci.h> |
a04d0423 | 50 | |
a01ca78c BS |
51 | #define nvxx_device(a) ({ \ |
52 | struct nvif_device *_device = (a); \ | |
68f3f702 BS |
53 | struct { \ |
54 | struct nvkm_object object; \ | |
55 | struct nvkm_device *device; \ | |
56 | } *_udevice = _device->object.priv; \ | |
57 | _udevice->device; \ | |
a01ca78c | 58 | }) |
46484438 | 59 | #define nvxx_bios(a) nvxx_device(a)->bios |
03c8952f | 60 | #define nvxx_fb(a) nvxx_device(a)->fb |
c9582455 | 61 | #define nvxx_mmu(a) nvxx_device(a)->mmu |
32932281 | 62 | #define nvxx_bar(a) nvxx_device(a)->bar |
2ea7249f | 63 | #define nvxx_gpio(a) nvxx_device(a)->gpio |
6625f55c | 64 | #define nvxx_clk(a) nvxx_device(a)->clk |
49bd8da5 | 65 | #define nvxx_i2c(a) nvxx_device(a)->i2c |
353b9834 | 66 | #define nvxx_iccsense(a) nvxx_device(a)->iccsense |
57113c01 | 67 | #define nvxx_therm(a) nvxx_device(a)->therm |
2e7db87d | 68 | #define nvxx_volt(a) nvxx_device(a)->volt |
a04d0423 | 69 | |
9719047b | 70 | #include <core/device.h> |
a04d0423 | 71 | #include <engine/fifo.h> |
b8bf04e1 | 72 | #include <engine/gr.h> |
8700287b | 73 | #include <engine/sw.h> |
a04d0423 | 74 | |
8f0649b5 | 75 | #define nvxx_fifo(a) nvxx_device(a)->fifo |
27f3d6cf | 76 | #define nvxx_gr(a) nvxx_device(a)->gr |
a04d0423 | 77 | #endif |