opcodes.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Tegra host1x opcodes
  4. *
  5. * Copyright (c) 2022 NVIDIA Corporation.
  6. */
  7. #ifndef __HOST1X_OPCODES_H
  8. #define __HOST1X_OPCODES_H
  9. #include <linux/types.h>
  10. static inline u32 host1x_class_host_wait_syncpt(
  11. unsigned indx, unsigned threshold)
  12. {
  13. return host1x_uclass_wait_syncpt_indx_f(indx)
  14. | host1x_uclass_wait_syncpt_thresh_f(threshold);
  15. }
  16. static inline u32 host1x_class_host_load_syncpt_base(
  17. unsigned indx, unsigned threshold)
  18. {
  19. return host1x_uclass_load_syncpt_base_base_indx_f(indx)
  20. | host1x_uclass_load_syncpt_base_value_f(threshold);
  21. }
  22. static inline u32 host1x_class_host_wait_syncpt_base(
  23. unsigned indx, unsigned base_indx, unsigned offset)
  24. {
  25. return host1x_uclass_wait_syncpt_base_indx_f(indx)
  26. | host1x_uclass_wait_syncpt_base_base_indx_f(base_indx)
  27. | host1x_uclass_wait_syncpt_base_offset_f(offset);
  28. }
  29. static inline u32 host1x_class_host_incr_syncpt_base(
  30. unsigned base_indx, unsigned offset)
  31. {
  32. return host1x_uclass_incr_syncpt_base_base_indx_f(base_indx)
  33. | host1x_uclass_incr_syncpt_base_offset_f(offset);
  34. }
  35. static inline u32 host1x_class_host_incr_syncpt(
  36. unsigned cond, unsigned indx)
  37. {
  38. return host1x_uclass_incr_syncpt_cond_f(cond)
  39. | host1x_uclass_incr_syncpt_indx_f(indx);
  40. }
  41. static inline u32 host1x_class_host_indoff_reg_write(
  42. unsigned mod_id, unsigned offset, bool auto_inc)
  43. {
  44. u32 v = host1x_uclass_indoff_indbe_f(0xf)
  45. | host1x_uclass_indoff_indmodid_f(mod_id)
  46. | host1x_uclass_indoff_indroffset_f(offset);
  47. if (auto_inc)
  48. v |= host1x_uclass_indoff_autoinc_f(1);
  49. return v;
  50. }
  51. static inline u32 host1x_class_host_indoff_reg_read(
  52. unsigned mod_id, unsigned offset, bool auto_inc)
  53. {
  54. u32 v = host1x_uclass_indoff_indmodid_f(mod_id)
  55. | host1x_uclass_indoff_indroffset_f(offset)
  56. | host1x_uclass_indoff_rwn_read_v();
  57. if (auto_inc)
  58. v |= host1x_uclass_indoff_autoinc_f(1);
  59. return v;
  60. }
  61. static inline u32 host1x_opcode_setclass(
  62. unsigned class_id, unsigned offset, unsigned mask)
  63. {
  64. return (0 << 28) | (offset << 16) | (class_id << 6) | mask;
  65. }
  66. static inline u32 host1x_opcode_incr(unsigned offset, unsigned count)
  67. {
  68. return (1 << 28) | (offset << 16) | count;
  69. }
  70. static inline u32 host1x_opcode_nonincr(unsigned offset, unsigned count)
  71. {
  72. return (2 << 28) | (offset << 16) | count;
  73. }
  74. static inline u32 host1x_opcode_mask(unsigned offset, unsigned mask)
  75. {
  76. return (3 << 28) | (offset << 16) | mask;
  77. }
  78. static inline u32 host1x_opcode_imm(unsigned offset, unsigned value)
  79. {
  80. return (4 << 28) | (offset << 16) | value;
  81. }
  82. static inline u32 host1x_opcode_imm_incr_syncpt(unsigned cond, unsigned indx)
  83. {
  84. return host1x_opcode_imm(host1x_uclass_incr_syncpt_r(),
  85. host1x_class_host_incr_syncpt(cond, indx));
  86. }
  87. static inline u32 host1x_opcode_restart(unsigned address)
  88. {
  89. return (5 << 28) | (address >> 4);
  90. }
  91. static inline u32 host1x_opcode_gather(unsigned count)
  92. {
  93. return (6 << 28) | count;
  94. }
  95. static inline u32 host1x_opcode_gather_nonincr(unsigned offset, unsigned count)
  96. {
  97. return (6 << 28) | (offset << 16) | BIT(15) | count;
  98. }
  99. static inline u32 host1x_opcode_gather_incr(unsigned offset, unsigned count)
  100. {
  101. return (6 << 28) | (offset << 16) | BIT(15) | BIT(14) | count;
  102. }
  103. static inline u32 host1x_opcode_setstreamid(unsigned streamid)
  104. {
  105. return (7 << 28) | streamid;
  106. }
  107. static inline u32 host1x_opcode_setpayload(unsigned payload)
  108. {
  109. return (9 << 28) | payload;
  110. }
  111. static inline u32 host1x_opcode_gather_wide(unsigned count)
  112. {
  113. return (12 << 28) | count;
  114. }
  115. static inline u32 host1x_opcode_acquire_mlock(unsigned mlock)
  116. {
  117. return (14 << 28) | (0 << 24) | mlock;
  118. }
  119. static inline u32 host1x_opcode_release_mlock(unsigned mlock)
  120. {
  121. return (14 << 28) | (1 << 24) | mlock;
  122. }
  123. #define HOST1X_OPCODE_NOP host1x_opcode_nonincr(0, 0)
  124. #endif