device.h 2.9 KB

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