hw_host1x02_sync.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2013 NVIDIA Corporation.
  4. */
  5. /*
  6. * Function naming determines intended use:
  7. *
  8. * <x>_r(void) : Returns the offset for register <x>.
  9. *
  10. * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
  11. *
  12. * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
  13. *
  14. * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
  15. * and masked to place it at field <y> of register <x>. This value
  16. * can be |'d with others to produce a full register value for
  17. * register <x>.
  18. *
  19. * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
  20. * value can be ~'d and then &'d to clear the value of field <y> for
  21. * register <x>.
  22. *
  23. * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
  24. * to place it at field <y> of register <x>. This value can be |'d
  25. * with others to produce a full register value for <x>.
  26. *
  27. * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
  28. * <x> value 'r' after being shifted to place its LSB at bit 0.
  29. * This value is suitable for direct comparison with other unshifted
  30. * values appropriate for use in field <y> of register <x>.
  31. *
  32. * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
  33. * field <y> of register <x>. This value is suitable for direct
  34. * comparison with unshifted values appropriate for use in field <y>
  35. * of register <x>.
  36. */
  37. #ifndef HOST1X_HW_HOST1X02_SYNC_H
  38. #define HOST1X_HW_HOST1X02_SYNC_H
  39. #define REGISTER_STRIDE 4
  40. static inline u32 host1x_sync_syncpt_r(unsigned int id)
  41. {
  42. return 0x400 + id * REGISTER_STRIDE;
  43. }
  44. #define HOST1X_SYNC_SYNCPT(id) \
  45. host1x_sync_syncpt_r(id)
  46. static inline u32 host1x_sync_syncpt_thresh_cpu0_int_status_r(unsigned int id)
  47. {
  48. return 0x40 + id * REGISTER_STRIDE;
  49. }
  50. #define HOST1X_SYNC_SYNCPT_THRESH_CPU0_INT_STATUS(id) \
  51. host1x_sync_syncpt_thresh_cpu0_int_status_r(id)
  52. static inline u32 host1x_sync_syncpt_thresh_int_disable_r(unsigned int id)
  53. {
  54. return 0x60 + id * REGISTER_STRIDE;
  55. }
  56. #define HOST1X_SYNC_SYNCPT_THRESH_INT_DISABLE(id) \
  57. host1x_sync_syncpt_thresh_int_disable_r(id)
  58. static inline u32 host1x_sync_syncpt_thresh_int_enable_cpu0_r(unsigned int id)
  59. {
  60. return 0x68 + id * REGISTER_STRIDE;
  61. }
  62. #define HOST1X_SYNC_SYNCPT_THRESH_INT_ENABLE_CPU0(id) \
  63. host1x_sync_syncpt_thresh_int_enable_cpu0_r(id)
  64. static inline u32 host1x_sync_cf_setup_r(unsigned int channel)
  65. {
  66. return 0x80 + channel * REGISTER_STRIDE;
  67. }
  68. #define HOST1X_SYNC_CF_SETUP(channel) \
  69. host1x_sync_cf_setup_r(channel)
  70. static inline u32 host1x_sync_cf_setup_base_v(u32 r)
  71. {
  72. return (r >> 0) & 0x3ff;
  73. }
  74. #define HOST1X_SYNC_CF_SETUP_BASE_V(r) \
  75. host1x_sync_cf_setup_base_v(r)
  76. static inline u32 host1x_sync_cf_setup_limit_v(u32 r)
  77. {
  78. return (r >> 16) & 0x3ff;
  79. }
  80. #define HOST1X_SYNC_CF_SETUP_LIMIT_V(r) \
  81. host1x_sync_cf_setup_limit_v(r)
  82. static inline u32 host1x_sync_cmdproc_stop_r(void)
  83. {
  84. return 0xac;
  85. }
  86. #define HOST1X_SYNC_CMDPROC_STOP \
  87. host1x_sync_cmdproc_stop_r()
  88. static inline u32 host1x_sync_ch_teardown_r(void)
  89. {
  90. return 0xb0;
  91. }
  92. #define HOST1X_SYNC_CH_TEARDOWN \
  93. host1x_sync_ch_teardown_r()
  94. static inline u32 host1x_sync_usec_clk_r(void)
  95. {
  96. return 0x1a4;
  97. }
  98. #define HOST1X_SYNC_USEC_CLK \
  99. host1x_sync_usec_clk_r()
  100. static inline u32 host1x_sync_ctxsw_timeout_cfg_r(void)
  101. {
  102. return 0x1a8;
  103. }
  104. #define HOST1X_SYNC_CTXSW_TIMEOUT_CFG \
  105. host1x_sync_ctxsw_timeout_cfg_r()
  106. static inline u32 host1x_sync_ip_busy_timeout_r(void)
  107. {
  108. return 0x1bc;
  109. }
  110. #define HOST1X_SYNC_IP_BUSY_TIMEOUT \
  111. host1x_sync_ip_busy_timeout_r()
  112. static inline u32 host1x_sync_mlock_owner_r(unsigned int id)
  113. {
  114. return 0x340 + id * REGISTER_STRIDE;
  115. }
  116. #define HOST1X_SYNC_MLOCK_OWNER(id) \
  117. host1x_sync_mlock_owner_r(id)
  118. static inline u32 host1x_sync_mlock_owner_chid_v(u32 v)
  119. {
  120. return (v >> 8) & 0xf;
  121. }
  122. #define HOST1X_SYNC_MLOCK_OWNER_CHID_V(v) \
  123. host1x_sync_mlock_owner_chid_v(v)
  124. static inline u32 host1x_sync_mlock_owner_cpu_owns_v(u32 r)
  125. {
  126. return (r >> 1) & 0x1;
  127. }
  128. #define HOST1X_SYNC_MLOCK_OWNER_CPU_OWNS_V(r) \
  129. host1x_sync_mlock_owner_cpu_owns_v(r)
  130. static inline u32 host1x_sync_mlock_owner_ch_owns_v(u32 r)
  131. {
  132. return (r >> 0) & 0x1;
  133. }
  134. #define HOST1X_SYNC_MLOCK_OWNER_CH_OWNS_V(r) \
  135. host1x_sync_mlock_owner_ch_owns_v(r)
  136. static inline u32 host1x_sync_syncpt_int_thresh_r(unsigned int id)
  137. {
  138. return 0x500 + id * REGISTER_STRIDE;
  139. }
  140. #define HOST1X_SYNC_SYNCPT_INT_THRESH(id) \
  141. host1x_sync_syncpt_int_thresh_r(id)
  142. static inline u32 host1x_sync_syncpt_base_r(unsigned int id)
  143. {
  144. return 0x600 + id * REGISTER_STRIDE;
  145. }
  146. #define HOST1X_SYNC_SYNCPT_BASE(id) \
  147. host1x_sync_syncpt_base_r(id)
  148. static inline u32 host1x_sync_syncpt_cpu_incr_r(unsigned int id)
  149. {
  150. return 0x700 + id * REGISTER_STRIDE;
  151. }
  152. #define HOST1X_SYNC_SYNCPT_CPU_INCR(id) \
  153. host1x_sync_syncpt_cpu_incr_r(id)
  154. static inline u32 host1x_sync_cbread_r(unsigned int channel)
  155. {
  156. return 0x720 + channel * REGISTER_STRIDE;
  157. }
  158. #define HOST1X_SYNC_CBREAD(channel) \
  159. host1x_sync_cbread_r(channel)
  160. static inline u32 host1x_sync_cfpeek_ctrl_r(void)
  161. {
  162. return 0x74c;
  163. }
  164. #define HOST1X_SYNC_CFPEEK_CTRL \
  165. host1x_sync_cfpeek_ctrl_r()
  166. static inline u32 host1x_sync_cfpeek_ctrl_addr_f(u32 v)
  167. {
  168. return (v & 0x3ff) << 0;
  169. }
  170. #define HOST1X_SYNC_CFPEEK_CTRL_ADDR_F(v) \
  171. host1x_sync_cfpeek_ctrl_addr_f(v)
  172. static inline u32 host1x_sync_cfpeek_ctrl_channr_f(u32 v)
  173. {
  174. return (v & 0xf) << 16;
  175. }
  176. #define HOST1X_SYNC_CFPEEK_CTRL_CHANNR_F(v) \
  177. host1x_sync_cfpeek_ctrl_channr_f(v)
  178. static inline u32 host1x_sync_cfpeek_ctrl_ena_f(u32 v)
  179. {
  180. return (v & 0x1) << 31;
  181. }
  182. #define HOST1X_SYNC_CFPEEK_CTRL_ENA_F(v) \
  183. host1x_sync_cfpeek_ctrl_ena_f(v)
  184. static inline u32 host1x_sync_cfpeek_read_r(void)
  185. {
  186. return 0x750;
  187. }
  188. #define HOST1X_SYNC_CFPEEK_READ \
  189. host1x_sync_cfpeek_read_r()
  190. static inline u32 host1x_sync_cfpeek_ptrs_r(void)
  191. {
  192. return 0x754;
  193. }
  194. #define HOST1X_SYNC_CFPEEK_PTRS \
  195. host1x_sync_cfpeek_ptrs_r()
  196. static inline u32 host1x_sync_cfpeek_ptrs_cf_rd_ptr_v(u32 r)
  197. {
  198. return (r >> 0) & 0x3ff;
  199. }
  200. #define HOST1X_SYNC_CFPEEK_PTRS_CF_RD_PTR_V(r) \
  201. host1x_sync_cfpeek_ptrs_cf_rd_ptr_v(r)
  202. static inline u32 host1x_sync_cfpeek_ptrs_cf_wr_ptr_v(u32 r)
  203. {
  204. return (r >> 16) & 0x3ff;
  205. }
  206. #define HOST1X_SYNC_CFPEEK_PTRS_CF_WR_PTR_V(r) \
  207. host1x_sync_cfpeek_ptrs_cf_wr_ptr_v(r)
  208. static inline u32 host1x_sync_cbstat_r(unsigned int channel)
  209. {
  210. return 0x758 + channel * REGISTER_STRIDE;
  211. }
  212. #define HOST1X_SYNC_CBSTAT(channel) \
  213. host1x_sync_cbstat_r(channel)
  214. static inline u32 host1x_sync_cbstat_cboffset_v(u32 r)
  215. {
  216. return (r >> 0) & 0xffff;
  217. }
  218. #define HOST1X_SYNC_CBSTAT_CBOFFSET_V(r) \
  219. host1x_sync_cbstat_cboffset_v(r)
  220. static inline u32 host1x_sync_cbstat_cbclass_v(u32 r)
  221. {
  222. return (r >> 16) & 0x3ff;
  223. }
  224. #define HOST1X_SYNC_CBSTAT_CBCLASS_V(r) \
  225. host1x_sync_cbstat_cbclass_v(r)
  226. #endif