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