device.h 2.8 KB

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