gf100.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. /*
  2. * Copyright 2010 Red Hat Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. * Authors: Ben Skeggs
  23. */
  24. #ifndef __GF100_GR_H__
  25. #define __GF100_GR_H__
  26. #define gf100_gr(p) container_of((p), struct gf100_gr, base)
  27. #include "priv.h"
  28. #include <core/gpuobj.h>
  29. #include <subdev/ltc.h>
  30. #include <subdev/mmu.h>
  31. #define GPC_MAX 32
  32. #define TPC_MAX_PER_GPC 8
  33. #define TPC_MAX (GPC_MAX * TPC_MAX_PER_GPC)
  34. #define ROP_BCAST(r) (0x408800 + (r))
  35. #define ROP_UNIT(u, r) (0x410000 + (u) * 0x400 + (r))
  36. #define GPC_BCAST(r) (0x418000 + (r))
  37. #define GPC_UNIT(t, r) (0x500000 + (t) * 0x8000 + (r))
  38. #define PPC_UNIT(t, m, r) (0x503000 + (t) * 0x8000 + (m) * 0x200 + (r))
  39. #define TPC_UNIT(t, m, r) (0x504000 + (t) * 0x8000 + (m) * 0x800 + (r))
  40. struct gf100_gr_data {
  41. u32 size;
  42. u32 align;
  43. u32 access;
  44. };
  45. struct gf100_gr_mmio {
  46. u32 addr;
  47. u32 data;
  48. u32 shift;
  49. int buffer;
  50. };
  51. struct gf100_gr_fuc {
  52. u32 *data;
  53. u32 size;
  54. };
  55. struct gf100_gr_zbc_color {
  56. u32 format;
  57. u32 ds[4];
  58. u32 l2[4];
  59. };
  60. struct gf100_gr_zbc_depth {
  61. u32 format;
  62. u32 ds;
  63. u32 l2;
  64. };
  65. struct gf100_gr {
  66. const struct gf100_gr_func *func;
  67. struct nvkm_gr base;
  68. struct gf100_gr_fuc fuc409c;
  69. struct gf100_gr_fuc fuc409d;
  70. struct gf100_gr_fuc fuc41ac;
  71. struct gf100_gr_fuc fuc41ad;
  72. bool firmware;
  73. /*
  74. * Used if the register packs are loaded from NVIDIA fw instead of
  75. * using hardcoded arrays. To be allocated with vzalloc().
  76. */
  77. struct gf100_gr_pack *fuc_sw_nonctx;
  78. struct gf100_gr_pack *fuc_sw_ctx;
  79. struct gf100_gr_pack *fuc_bundle;
  80. struct gf100_gr_pack *fuc_method;
  81. struct gf100_gr_zbc_color zbc_color[NVKM_LTC_MAX_ZBC_CNT];
  82. struct gf100_gr_zbc_depth zbc_depth[NVKM_LTC_MAX_ZBC_CNT];
  83. u8 rop_nr;
  84. u8 gpc_nr;
  85. u8 tpc_nr[GPC_MAX];
  86. u8 tpc_total;
  87. u8 ppc_nr[GPC_MAX];
  88. u8 ppc_mask[GPC_MAX];
  89. u8 ppc_tpc_nr[GPC_MAX][4];
  90. struct gf100_gr_data mmio_data[4];
  91. struct gf100_gr_mmio mmio_list[4096/8];
  92. u32 size;
  93. u32 *data;
  94. u8 screen_tile_row_offset;
  95. };
  96. int gf100_gr_ctor(const struct gf100_gr_func *, struct nvkm_device *,
  97. int, struct gf100_gr *);
  98. int gf100_gr_new_(const struct gf100_gr_func *, struct nvkm_device *,
  99. int, struct nvkm_gr **);
  100. void *gf100_gr_dtor(struct nvkm_gr *);
  101. struct gf100_gr_func {
  102. void (*dtor)(struct gf100_gr *);
  103. int (*init)(struct gf100_gr *);
  104. void (*init_gpc_mmu)(struct gf100_gr *);
  105. void (*init_rop_active_fbps)(struct gf100_gr *);
  106. void (*init_ppc_exceptions)(struct gf100_gr *);
  107. void (*set_hww_esr_report_mask)(struct gf100_gr *);
  108. const struct gf100_gr_pack *mmio;
  109. struct {
  110. struct gf100_gr_ucode *ucode;
  111. } fecs;
  112. struct {
  113. struct gf100_gr_ucode *ucode;
  114. } gpccs;
  115. int (*rops)(struct gf100_gr *);
  116. int ppc_nr;
  117. const struct gf100_grctx_func *grctx;
  118. struct nvkm_sclass sclass[];
  119. };
  120. int gf100_gr_init(struct gf100_gr *);
  121. int gf100_gr_rops(struct gf100_gr *);
  122. int gk104_gr_init(struct gf100_gr *);
  123. void gk104_gr_init_rop_active_fbps(struct gf100_gr *);
  124. void gk104_gr_init_ppc_exceptions(struct gf100_gr *);
  125. int gk20a_gr_init(struct gf100_gr *);
  126. int gm200_gr_init(struct gf100_gr *);
  127. int gm200_gr_rops(struct gf100_gr *);
  128. #define gf100_gr_chan(p) container_of((p), struct gf100_gr_chan, object)
  129. struct gf100_gr_chan {
  130. struct nvkm_object object;
  131. struct gf100_gr *gr;
  132. struct nvkm_memory *mmio;
  133. struct nvkm_vma mmio_vma;
  134. int mmio_nr;
  135. struct {
  136. struct nvkm_memory *mem;
  137. struct nvkm_vma vma;
  138. } data[4];
  139. };
  140. void gf100_gr_ctxctl_debug(struct gf100_gr *);
  141. void gf100_gr_dtor_fw(struct gf100_gr_fuc *);
  142. int gf100_gr_ctor_fw(struct gf100_gr *, const char *,
  143. struct gf100_gr_fuc *);
  144. u64 gf100_gr_units(struct nvkm_gr *);
  145. void gf100_gr_zbc_init(struct gf100_gr *);
  146. extern const struct nvkm_object_func gf100_fermi;
  147. struct gf100_gr_init {
  148. u32 addr;
  149. u8 count;
  150. u8 pitch;
  151. u32 data;
  152. };
  153. struct gf100_gr_pack {
  154. const struct gf100_gr_init *init;
  155. u32 type;
  156. };
  157. #define pack_for_each_init(init, pack, head) \
  158. for (pack = head; pack && pack->init; pack++) \
  159. for (init = pack->init; init && init->count; init++)
  160. struct gf100_gr_ucode {
  161. struct gf100_gr_fuc code;
  162. struct gf100_gr_fuc data;
  163. };
  164. extern struct gf100_gr_ucode gf100_gr_fecs_ucode;
  165. extern struct gf100_gr_ucode gf100_gr_gpccs_ucode;
  166. extern struct gf100_gr_ucode gk110_gr_fecs_ucode;
  167. extern struct gf100_gr_ucode gk110_gr_gpccs_ucode;
  168. int gf100_gr_wait_idle(struct gf100_gr *);
  169. void gf100_gr_mmio(struct gf100_gr *, const struct gf100_gr_pack *);
  170. void gf100_gr_icmd(struct gf100_gr *, const struct gf100_gr_pack *);
  171. void gf100_gr_mthd(struct gf100_gr *, const struct gf100_gr_pack *);
  172. int gf100_gr_init_ctxctl(struct gf100_gr *);
  173. /* external bundles loading functions */
  174. int gk20a_gr_av_to_init(struct gf100_gr *, const char *,
  175. struct gf100_gr_pack **);
  176. int gk20a_gr_aiv_to_init(struct gf100_gr *, const char *,
  177. struct gf100_gr_pack **);
  178. int gk20a_gr_av_to_method(struct gf100_gr *, const char *,
  179. struct gf100_gr_pack **);
  180. int gm200_gr_new_(const struct gf100_gr_func *, struct nvkm_device *, int,
  181. struct nvkm_gr **);
  182. /* register init value lists */
  183. extern const struct gf100_gr_init gf100_gr_init_main_0[];
  184. extern const struct gf100_gr_init gf100_gr_init_fe_0[];
  185. extern const struct gf100_gr_init gf100_gr_init_pri_0[];
  186. extern const struct gf100_gr_init gf100_gr_init_rstr2d_0[];
  187. extern const struct gf100_gr_init gf100_gr_init_pd_0[];
  188. extern const struct gf100_gr_init gf100_gr_init_ds_0[];
  189. extern const struct gf100_gr_init gf100_gr_init_scc_0[];
  190. extern const struct gf100_gr_init gf100_gr_init_prop_0[];
  191. extern const struct gf100_gr_init gf100_gr_init_gpc_unk_0[];
  192. extern const struct gf100_gr_init gf100_gr_init_setup_0[];
  193. extern const struct gf100_gr_init gf100_gr_init_crstr_0[];
  194. extern const struct gf100_gr_init gf100_gr_init_setup_1[];
  195. extern const struct gf100_gr_init gf100_gr_init_zcull_0[];
  196. extern const struct gf100_gr_init gf100_gr_init_gpm_0[];
  197. extern const struct gf100_gr_init gf100_gr_init_gpc_unk_1[];
  198. extern const struct gf100_gr_init gf100_gr_init_gcc_0[];
  199. extern const struct gf100_gr_init gf100_gr_init_tpccs_0[];
  200. extern const struct gf100_gr_init gf100_gr_init_tex_0[];
  201. extern const struct gf100_gr_init gf100_gr_init_pe_0[];
  202. extern const struct gf100_gr_init gf100_gr_init_l1c_0[];
  203. extern const struct gf100_gr_init gf100_gr_init_wwdx_0[];
  204. extern const struct gf100_gr_init gf100_gr_init_tpccs_1[];
  205. extern const struct gf100_gr_init gf100_gr_init_mpc_0[];
  206. extern const struct gf100_gr_init gf100_gr_init_be_0[];
  207. extern const struct gf100_gr_init gf100_gr_init_fe_1[];
  208. extern const struct gf100_gr_init gf100_gr_init_pe_1[];
  209. extern const struct gf100_gr_init gf104_gr_init_ds_0[];
  210. extern const struct gf100_gr_init gf104_gr_init_tex_0[];
  211. extern const struct gf100_gr_init gf104_gr_init_sm_0[];
  212. extern const struct gf100_gr_init gf108_gr_init_gpc_unk_0[];
  213. extern const struct gf100_gr_init gf108_gr_init_setup_1[];
  214. extern const struct gf100_gr_init gf119_gr_init_pd_0[];
  215. extern const struct gf100_gr_init gf119_gr_init_ds_0[];
  216. extern const struct gf100_gr_init gf119_gr_init_prop_0[];
  217. extern const struct gf100_gr_init gf119_gr_init_gpm_0[];
  218. extern const struct gf100_gr_init gf119_gr_init_gpc_unk_1[];
  219. extern const struct gf100_gr_init gf119_gr_init_tex_0[];
  220. extern const struct gf100_gr_init gf119_gr_init_sm_0[];
  221. extern const struct gf100_gr_init gf119_gr_init_fe_1[];
  222. extern const struct gf100_gr_init gf117_gr_init_pes_0[];
  223. extern const struct gf100_gr_init gf117_gr_init_wwdx_0[];
  224. extern const struct gf100_gr_init gf117_gr_init_cbm_0[];
  225. extern const struct gf100_gr_init gk104_gr_init_main_0[];
  226. extern const struct gf100_gr_init gk104_gr_init_tpccs_0[];
  227. extern const struct gf100_gr_init gk104_gr_init_pe_0[];
  228. extern const struct gf100_gr_init gk104_gr_init_be_0[];
  229. extern const struct gf100_gr_pack gk104_gr_pack_mmio[];
  230. extern const struct gf100_gr_init gk110_gr_init_fe_0[];
  231. extern const struct gf100_gr_init gk110_gr_init_ds_0[];
  232. extern const struct gf100_gr_init gk110_gr_init_sked_0[];
  233. extern const struct gf100_gr_init gk110_gr_init_cwd_0[];
  234. extern const struct gf100_gr_init gk110_gr_init_gpc_unk_1[];
  235. extern const struct gf100_gr_init gk110_gr_init_tex_0[];
  236. extern const struct gf100_gr_init gk110_gr_init_sm_0[];
  237. extern const struct gf100_gr_init gk208_gr_init_gpc_unk_0[];
  238. extern const struct gf100_gr_init gm107_gr_init_scc_0[];
  239. extern const struct gf100_gr_init gm107_gr_init_prop_0[];
  240. extern const struct gf100_gr_init gm107_gr_init_setup_1[];
  241. extern const struct gf100_gr_init gm107_gr_init_zcull_0[];
  242. extern const struct gf100_gr_init gm107_gr_init_gpc_unk_1[];
  243. extern const struct gf100_gr_init gm107_gr_init_tex_0[];
  244. extern const struct gf100_gr_init gm107_gr_init_l1c_0[];
  245. extern const struct gf100_gr_init gm107_gr_init_wwdx_0[];
  246. extern const struct gf100_gr_init gm107_gr_init_cbm_0[];
  247. void gm107_gr_init_bios(struct gf100_gr *);
  248. void gm200_gr_init_gpc_mmu(struct gf100_gr *);
  249. #endif