etnaviv_gpu.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2015-2018 Etnaviv Project
  4. */
  5. #ifndef __ETNAVIV_GPU_H__
  6. #define __ETNAVIV_GPU_H__
  7. #include "etnaviv_cmdbuf.h"
  8. #include "etnaviv_gem.h"
  9. #include "etnaviv_mmu.h"
  10. #include "etnaviv_drv.h"
  11. struct etnaviv_gem_submit;
  12. struct etnaviv_vram_mapping;
  13. struct etnaviv_chip_identity {
  14. u32 model;
  15. u32 revision;
  16. u32 product_id;
  17. u32 customer_id;
  18. u32 eco_id;
  19. /* Supported feature fields. */
  20. u32 features;
  21. /* Supported minor feature fields. */
  22. u32 minor_features0;
  23. u32 minor_features1;
  24. u32 minor_features2;
  25. u32 minor_features3;
  26. u32 minor_features4;
  27. u32 minor_features5;
  28. u32 minor_features6;
  29. u32 minor_features7;
  30. u32 minor_features8;
  31. u32 minor_features9;
  32. u32 minor_features10;
  33. u32 minor_features11;
  34. /* Number of streams supported. */
  35. u32 stream_count;
  36. /* Total number of temporary registers per thread. */
  37. u32 register_max;
  38. /* Maximum number of threads. */
  39. u32 thread_count;
  40. /* Number of shader cores. */
  41. u32 shader_core_count;
  42. /* Size of the vertex cache. */
  43. u32 vertex_cache_size;
  44. /* Number of entries in the vertex output buffer. */
  45. u32 vertex_output_buffer_size;
  46. /* Number of pixel pipes. */
  47. u32 pixel_pipes;
  48. /* Number of instructions. */
  49. u32 instruction_count;
  50. /* Number of constants. */
  51. u32 num_constants;
  52. /* Buffer size */
  53. u32 buffer_size;
  54. /* Number of varyings */
  55. u8 varyings_count;
  56. };
  57. enum etnaviv_sec_mode {
  58. ETNA_SEC_NONE = 0,
  59. ETNA_SEC_KERNEL,
  60. ETNA_SEC_TZ
  61. };
  62. struct etnaviv_event {
  63. struct dma_fence *fence;
  64. struct etnaviv_gem_submit *submit;
  65. void (*sync_point)(struct etnaviv_gpu *gpu, struct etnaviv_event *event);
  66. };
  67. struct etnaviv_cmdbuf_suballoc;
  68. struct regulator;
  69. struct clk;
  70. #define ETNA_NR_EVENTS 30
  71. struct etnaviv_gpu {
  72. struct drm_device *drm;
  73. struct thermal_cooling_device *cooling;
  74. struct device *dev;
  75. struct mutex lock;
  76. struct etnaviv_chip_identity identity;
  77. enum etnaviv_sec_mode sec_mode;
  78. struct workqueue_struct *wq;
  79. struct drm_gpu_scheduler sched;
  80. bool initialized;
  81. bool fe_running;
  82. /* 'ring'-buffer: */
  83. struct etnaviv_cmdbuf buffer;
  84. int exec_state;
  85. /* event management: */
  86. DECLARE_BITMAP(event_bitmap, ETNA_NR_EVENTS);
  87. struct etnaviv_event event[ETNA_NR_EVENTS];
  88. struct completion event_free;
  89. spinlock_t event_spinlock;
  90. u32 idle_mask;
  91. /* Fencing support */
  92. struct mutex fence_lock;
  93. struct idr fence_idr;
  94. u32 next_fence;
  95. u32 completed_fence;
  96. wait_queue_head_t fence_event;
  97. u64 fence_context;
  98. spinlock_t fence_spinlock;
  99. /* worker for handling 'sync' points: */
  100. struct work_struct sync_point_work;
  101. int sync_point_event;
  102. /* hang detection */
  103. u32 hangcheck_dma_addr;
  104. u32 hangcheck_fence;
  105. void __iomem *mmio;
  106. int irq;
  107. struct etnaviv_iommu_context *mmu_context;
  108. unsigned int flush_seq;
  109. /* Power Control: */
  110. struct clk *clk_bus;
  111. struct clk *clk_reg;
  112. struct clk *clk_core;
  113. struct clk *clk_shader;
  114. unsigned int freq_scale;
  115. unsigned long base_rate_core;
  116. unsigned long base_rate_shader;
  117. };
  118. static inline void gpu_write(struct etnaviv_gpu *gpu, u32 reg, u32 data)
  119. {
  120. writel(data, gpu->mmio + reg);
  121. }
  122. static inline u32 gpu_read(struct etnaviv_gpu *gpu, u32 reg)
  123. {
  124. return readl(gpu->mmio + reg);
  125. }
  126. int etnaviv_gpu_get_param(struct etnaviv_gpu *gpu, u32 param, u64 *value);
  127. int etnaviv_gpu_init(struct etnaviv_gpu *gpu);
  128. bool etnaviv_fill_identity_from_hwdb(struct etnaviv_gpu *gpu);
  129. #ifdef CONFIG_DEBUG_FS
  130. int etnaviv_gpu_debugfs(struct etnaviv_gpu *gpu, struct seq_file *m);
  131. #endif
  132. void etnaviv_gpu_recover_hang(struct etnaviv_gpu *gpu);
  133. void etnaviv_gpu_retire(struct etnaviv_gpu *gpu);
  134. int etnaviv_gpu_wait_fence_interruptible(struct etnaviv_gpu *gpu,
  135. u32 fence, struct drm_etnaviv_timespec *timeout);
  136. int etnaviv_gpu_wait_obj_inactive(struct etnaviv_gpu *gpu,
  137. struct etnaviv_gem_object *etnaviv_obj,
  138. struct drm_etnaviv_timespec *timeout);
  139. struct dma_fence *etnaviv_gpu_submit(struct etnaviv_gem_submit *submit);
  140. int etnaviv_gpu_pm_get_sync(struct etnaviv_gpu *gpu);
  141. void etnaviv_gpu_pm_put(struct etnaviv_gpu *gpu);
  142. int etnaviv_gpu_wait_idle(struct etnaviv_gpu *gpu, unsigned int timeout_ms);
  143. void etnaviv_gpu_start_fe(struct etnaviv_gpu *gpu, u32 address, u16 prefetch);
  144. extern struct platform_driver etnaviv_gpu_driver;
  145. #endif /* __ETNAVIV_GPU_H__ */