hw_host1x04_sync.h 7.3 KB

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