adreno_gpu.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*
  2. * Copyright (C) 2013 Red Hat
  3. * Author: Rob Clark <robdclark@gmail.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License version 2 as published by
  7. * the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef __ADRENO_GPU_H__
  18. #define __ADRENO_GPU_H__
  19. #include <linux/firmware.h>
  20. #include "msm_gpu.h"
  21. #include "adreno_common.xml.h"
  22. #include "adreno_pm4.xml.h"
  23. struct adreno_rev {
  24. uint8_t core;
  25. uint8_t major;
  26. uint8_t minor;
  27. uint8_t patchid;
  28. };
  29. #define ADRENO_REV(core, major, minor, patchid) \
  30. ((struct adreno_rev){ core, major, minor, patchid })
  31. struct adreno_gpu_funcs {
  32. struct msm_gpu_funcs base;
  33. };
  34. struct adreno_info;
  35. struct adreno_rbmemptrs {
  36. volatile uint32_t rptr;
  37. volatile uint32_t wptr;
  38. volatile uint32_t fence;
  39. };
  40. struct adreno_gpu {
  41. struct msm_gpu base;
  42. struct adreno_rev rev;
  43. const struct adreno_info *info;
  44. uint32_t gmem; /* actual gmem size */
  45. uint32_t revn; /* numeric revision name */
  46. const struct adreno_gpu_funcs *funcs;
  47. /* firmware: */
  48. const struct firmware *pm4, *pfp;
  49. /* ringbuffer rptr/wptr: */
  50. // TODO should this be in msm_ringbuffer? I think it would be
  51. // different for z180..
  52. struct adreno_rbmemptrs *memptrs;
  53. struct drm_gem_object *memptrs_bo;
  54. uint32_t memptrs_iova;
  55. };
  56. #define to_adreno_gpu(x) container_of(x, struct adreno_gpu, base)
  57. /* platform config data (ie. from DT, or pdata) */
  58. struct adreno_platform_config {
  59. struct adreno_rev rev;
  60. uint32_t fast_rate, slow_rate, bus_freq;
  61. #ifdef CONFIG_MSM_BUS_SCALING
  62. struct msm_bus_scale_pdata *bus_scale_table;
  63. #endif
  64. };
  65. #define ADRENO_IDLE_TIMEOUT (20 * 1000)
  66. static inline bool adreno_is_a3xx(struct adreno_gpu *gpu)
  67. {
  68. return (gpu->revn >= 300) && (gpu->revn < 400);
  69. }
  70. static inline bool adreno_is_a305(struct adreno_gpu *gpu)
  71. {
  72. return gpu->revn == 305;
  73. }
  74. static inline bool adreno_is_a320(struct adreno_gpu *gpu)
  75. {
  76. return gpu->revn == 320;
  77. }
  78. static inline bool adreno_is_a330(struct adreno_gpu *gpu)
  79. {
  80. return gpu->revn == 330;
  81. }
  82. static inline bool adreno_is_a330v2(struct adreno_gpu *gpu)
  83. {
  84. return adreno_is_a330(gpu) && (gpu->rev.patchid > 0);
  85. }
  86. int adreno_get_param(struct msm_gpu *gpu, uint32_t param, uint64_t *value);
  87. int adreno_hw_init(struct msm_gpu *gpu);
  88. uint32_t adreno_last_fence(struct msm_gpu *gpu);
  89. void adreno_recover(struct msm_gpu *gpu);
  90. int adreno_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit,
  91. struct msm_file_private *ctx);
  92. void adreno_flush(struct msm_gpu *gpu);
  93. void adreno_idle(struct msm_gpu *gpu);
  94. #ifdef CONFIG_DEBUG_FS
  95. void adreno_show(struct msm_gpu *gpu, struct seq_file *m);
  96. #endif
  97. void adreno_wait_ring(struct msm_gpu *gpu, uint32_t ndwords);
  98. int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,
  99. struct adreno_gpu *gpu, const struct adreno_gpu_funcs *funcs,
  100. struct adreno_rev rev);
  101. void adreno_gpu_cleanup(struct adreno_gpu *gpu);
  102. /* ringbuffer helpers (the parts that are adreno specific) */
  103. static inline void
  104. OUT_PKT0(struct msm_ringbuffer *ring, uint16_t regindx, uint16_t cnt)
  105. {
  106. adreno_wait_ring(ring->gpu, cnt+1);
  107. OUT_RING(ring, CP_TYPE0_PKT | ((cnt-1) << 16) | (regindx & 0x7FFF));
  108. }
  109. /* no-op packet: */
  110. static inline void
  111. OUT_PKT2(struct msm_ringbuffer *ring)
  112. {
  113. adreno_wait_ring(ring->gpu, 1);
  114. OUT_RING(ring, CP_TYPE2_PKT);
  115. }
  116. static inline void
  117. OUT_PKT3(struct msm_ringbuffer *ring, uint8_t opcode, uint16_t cnt)
  118. {
  119. adreno_wait_ring(ring->gpu, cnt+1);
  120. OUT_RING(ring, CP_TYPE3_PKT | ((cnt-1) << 16) | ((opcode & 0xFF) << 8));
  121. }
  122. #endif /* __ADRENO_GPU_H__ */