gf100.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  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. #include <engine/falcon.h>
  32. #define GPC_MAX 32
  33. #define TPC_MAX_PER_GPC 8
  34. #define TPC_MAX (GPC_MAX * TPC_MAX_PER_GPC)
  35. #define ROP_BCAST(r) (0x408800 + (r))
  36. #define ROP_UNIT(u, r) (0x410000 + (u) * 0x400 + (r))
  37. #define GPC_BCAST(r) (0x418000 + (r))
  38. #define GPC_UNIT(t, r) (0x500000 + (t) * 0x8000 + (r))
  39. #define PPC_UNIT(t, m, r) (0x503000 + (t) * 0x8000 + (m) * 0x200 + (r))
  40. #define TPC_UNIT(t, m, r) (0x504000 + (t) * 0x8000 + (m) * 0x800 + (r))
  41. struct gf100_gr_data {
  42. u32 size;
  43. u32 align;
  44. u32 access;
  45. };
  46. struct gf100_gr_mmio {
  47. u32 addr;
  48. u32 data;
  49. u32 shift;
  50. int buffer;
  51. };
  52. struct gf100_gr_fuc {
  53. u32 *data;
  54. u32 size;
  55. };
  56. struct gf100_gr_zbc_color {
  57. u32 format;
  58. u32 ds[4];
  59. u32 l2[4];
  60. };
  61. struct gf100_gr_zbc_depth {
  62. u32 format;
  63. u32 ds;
  64. u32 l2;
  65. };
  66. struct gf100_gr {
  67. const struct gf100_gr_func *func;
  68. struct nvkm_gr base;
  69. struct nvkm_falcon *fecs;
  70. struct nvkm_falcon *gpccs;
  71. struct gf100_gr_fuc fuc409c;
  72. struct gf100_gr_fuc fuc409d;
  73. struct gf100_gr_fuc fuc41ac;
  74. struct gf100_gr_fuc fuc41ad;
  75. bool firmware;
  76. /*
  77. * Used if the register packs are loaded from NVIDIA fw instead of
  78. * using hardcoded arrays. To be allocated with vzalloc().
  79. */
  80. struct gf100_gr_pack *fuc_sw_nonctx;
  81. struct gf100_gr_pack *fuc_sw_ctx;
  82. struct gf100_gr_pack *fuc_bundle;
  83. struct gf100_gr_pack *fuc_method;
  84. struct gf100_gr_zbc_color zbc_color[NVKM_LTC_MAX_ZBC_CNT];
  85. struct gf100_gr_zbc_depth zbc_depth[NVKM_LTC_MAX_ZBC_CNT];
  86. u8 rop_nr;
  87. u8 gpc_nr;
  88. u8 tpc_nr[GPC_MAX];
  89. u8 tpc_total;
  90. u8 ppc_nr[GPC_MAX];
  91. u8 ppc_mask[GPC_MAX];
  92. u8 ppc_tpc_nr[GPC_MAX][4];
  93. struct gf100_gr_data mmio_data[4];
  94. struct gf100_gr_mmio mmio_list[4096/8];
  95. u32 size;
  96. u32 *data;
  97. u8 screen_tile_row_offset;
  98. };
  99. int gf100_gr_ctor(const struct gf100_gr_func *, struct nvkm_device *,
  100. int, struct gf100_gr *);
  101. int gf100_gr_new_(const struct gf100_gr_func *, struct nvkm_device *,
  102. int, struct nvkm_gr **);
  103. void *gf100_gr_dtor(struct nvkm_gr *);
  104. struct gf100_gr_func {
  105. void (*dtor)(struct gf100_gr *);
  106. int (*init)(struct gf100_gr *);
  107. void (*init_gpc_mmu)(struct gf100_gr *);
  108. void (*init_rop_active_fbps)(struct gf100_gr *);
  109. void (*init_ppc_exceptions)(struct gf100_gr *);
  110. void (*init_swdx_pes_mask)(struct gf100_gr *);
  111. void (*init_num_active_ltcs)(struct gf100_gr *);
  112. void (*set_hww_esr_report_mask)(struct gf100_gr *);
  113. const struct gf100_gr_pack *mmio;
  114. struct {
  115. struct gf100_gr_ucode *ucode;
  116. } fecs;
  117. struct {
  118. struct gf100_gr_ucode *ucode;
  119. } gpccs;
  120. int (*rops)(struct gf100_gr *);
  121. int ppc_nr;
  122. const struct gf100_grctx_func *grctx;
  123. struct nvkm_sclass sclass[];
  124. };
  125. int gf100_gr_init(struct gf100_gr *);
  126. int gf100_gr_rops(struct gf100_gr *);
  127. int gk104_gr_init(struct gf100_gr *);
  128. void gk104_gr_init_rop_active_fbps(struct gf100_gr *);
  129. void gk104_gr_init_ppc_exceptions(struct gf100_gr *);
  130. int gk20a_gr_init(struct gf100_gr *);
  131. int gm200_gr_init(struct gf100_gr *);
  132. int gm200_gr_rops(struct gf100_gr *);
  133. int gp100_gr_init(struct gf100_gr *);
  134. void gp100_gr_init_rop_active_fbps(struct gf100_gr *);
  135. #define gf100_gr_chan(p) container_of((p), struct gf100_gr_chan, object)
  136. struct gf100_gr_chan {
  137. struct nvkm_object object;
  138. struct gf100_gr *gr;
  139. struct nvkm_memory *mmio;
  140. struct nvkm_vma mmio_vma;
  141. int mmio_nr;
  142. struct {
  143. struct nvkm_memory *mem;
  144. struct nvkm_vma vma;
  145. } data[4];
  146. };
  147. void gf100_gr_ctxctl_debug(struct gf100_gr *);
  148. void gf100_gr_dtor_fw(struct gf100_gr_fuc *);
  149. int gf100_gr_ctor_fw(struct gf100_gr *, const char *,
  150. struct gf100_gr_fuc *);
  151. u64 gf100_gr_units(struct nvkm_gr *);
  152. void gf100_gr_zbc_init(struct gf100_gr *);
  153. extern const struct nvkm_object_func gf100_fermi;
  154. struct gf100_gr_init {
  155. u32 addr;
  156. u8 count;
  157. u8 pitch;
  158. u32 data;
  159. };
  160. struct gf100_gr_pack {
  161. const struct gf100_gr_init *init;
  162. u32 type;
  163. };
  164. #define pack_for_each_init(init, pack, head) \
  165. for (pack = head; pack && pack->init; pack++) \
  166. for (init = pack->init; init && init->count; init++)
  167. struct gf100_gr_ucode {
  168. struct gf100_gr_fuc code;
  169. struct gf100_gr_fuc data;
  170. };
  171. extern struct gf100_gr_ucode gf100_gr_fecs_ucode;
  172. extern struct gf100_gr_ucode gf100_gr_gpccs_ucode;
  173. extern struct gf100_gr_ucode gk110_gr_fecs_ucode;
  174. extern struct gf100_gr_ucode gk110_gr_gpccs_ucode;
  175. int gf100_gr_wait_idle(struct gf100_gr *);
  176. void gf100_gr_mmio(struct gf100_gr *, const struct gf100_gr_pack *);
  177. void gf100_gr_icmd(struct gf100_gr *, const struct gf100_gr_pack *);
  178. void gf100_gr_mthd(struct gf100_gr *, const struct gf100_gr_pack *);
  179. int gf100_gr_init_ctxctl(struct gf100_gr *);
  180. /* external bundles loading functions */
  181. int gk20a_gr_av_to_init(struct gf100_gr *, const char *,
  182. struct gf100_gr_pack **);
  183. int gk20a_gr_aiv_to_init(struct gf100_gr *, const char *,
  184. struct gf100_gr_pack **);
  185. int gk20a_gr_av_to_method(struct gf100_gr *, const char *,
  186. struct gf100_gr_pack **);
  187. int gm200_gr_new_(const struct gf100_gr_func *, struct nvkm_device *, int,
  188. struct nvkm_gr **);
  189. /* register init value lists */
  190. extern const struct gf100_gr_init gf100_gr_init_main_0[];
  191. extern const struct gf100_gr_init gf100_gr_init_fe_0[];
  192. extern const struct gf100_gr_init gf100_gr_init_pri_0[];
  193. extern const struct gf100_gr_init gf100_gr_init_rstr2d_0[];
  194. extern const struct gf100_gr_init gf100_gr_init_pd_0[];
  195. extern const struct gf100_gr_init gf100_gr_init_ds_0[];
  196. extern const struct gf100_gr_init gf100_gr_init_scc_0[];
  197. extern const struct gf100_gr_init gf100_gr_init_prop_0[];
  198. extern const struct gf100_gr_init gf100_gr_init_gpc_unk_0[];
  199. extern const struct gf100_gr_init gf100_gr_init_setup_0[];
  200. extern const struct gf100_gr_init gf100_gr_init_crstr_0[];
  201. extern const struct gf100_gr_init gf100_gr_init_setup_1[];
  202. extern const struct gf100_gr_init gf100_gr_init_zcull_0[];
  203. extern const struct gf100_gr_init gf100_gr_init_gpm_0[];
  204. extern const struct gf100_gr_init gf100_gr_init_gpc_unk_1[];
  205. extern const struct gf100_gr_init gf100_gr_init_gcc_0[];
  206. extern const struct gf100_gr_init gf100_gr_init_tpccs_0[];
  207. extern const struct gf100_gr_init gf100_gr_init_tex_0[];
  208. extern const struct gf100_gr_init gf100_gr_init_pe_0[];
  209. extern const struct gf100_gr_init gf100_gr_init_l1c_0[];
  210. extern const struct gf100_gr_init gf100_gr_init_wwdx_0[];
  211. extern const struct gf100_gr_init gf100_gr_init_tpccs_1[];
  212. extern const struct gf100_gr_init gf100_gr_init_mpc_0[];
  213. extern const struct gf100_gr_init gf100_gr_init_be_0[];
  214. extern const struct gf100_gr_init gf100_gr_init_fe_1[];
  215. extern const struct gf100_gr_init gf100_gr_init_pe_1[];
  216. extern const struct gf100_gr_init gf104_gr_init_ds_0[];
  217. extern const struct gf100_gr_init gf104_gr_init_tex_0[];
  218. extern const struct gf100_gr_init gf104_gr_init_sm_0[];
  219. extern const struct gf100_gr_init gf108_gr_init_gpc_unk_0[];
  220. extern const struct gf100_gr_init gf108_gr_init_setup_1[];
  221. extern const struct gf100_gr_init gf119_gr_init_pd_0[];
  222. extern const struct gf100_gr_init gf119_gr_init_ds_0[];
  223. extern const struct gf100_gr_init gf119_gr_init_prop_0[];
  224. extern const struct gf100_gr_init gf119_gr_init_gpm_0[];
  225. extern const struct gf100_gr_init gf119_gr_init_gpc_unk_1[];
  226. extern const struct gf100_gr_init gf119_gr_init_tex_0[];
  227. extern const struct gf100_gr_init gf119_gr_init_sm_0[];
  228. extern const struct gf100_gr_init gf119_gr_init_fe_1[];
  229. extern const struct gf100_gr_init gf117_gr_init_pes_0[];
  230. extern const struct gf100_gr_init gf117_gr_init_wwdx_0[];
  231. extern const struct gf100_gr_init gf117_gr_init_cbm_0[];
  232. extern const struct gf100_gr_init gk104_gr_init_main_0[];
  233. extern const struct gf100_gr_init gk104_gr_init_tpccs_0[];
  234. extern const struct gf100_gr_init gk104_gr_init_pe_0[];
  235. extern const struct gf100_gr_init gk104_gr_init_be_0[];
  236. extern const struct gf100_gr_pack gk104_gr_pack_mmio[];
  237. extern const struct gf100_gr_init gk110_gr_init_fe_0[];
  238. extern const struct gf100_gr_init gk110_gr_init_ds_0[];
  239. extern const struct gf100_gr_init gk110_gr_init_sked_0[];
  240. extern const struct gf100_gr_init gk110_gr_init_cwd_0[];
  241. extern const struct gf100_gr_init gk110_gr_init_gpc_unk_1[];
  242. extern const struct gf100_gr_init gk110_gr_init_tex_0[];
  243. extern const struct gf100_gr_init gk110_gr_init_sm_0[];
  244. extern const struct gf100_gr_init gk208_gr_init_gpc_unk_0[];
  245. extern const struct gf100_gr_init gm107_gr_init_scc_0[];
  246. extern const struct gf100_gr_init gm107_gr_init_prop_0[];
  247. extern const struct gf100_gr_init gm107_gr_init_setup_1[];
  248. extern const struct gf100_gr_init gm107_gr_init_zcull_0[];
  249. extern const struct gf100_gr_init gm107_gr_init_gpc_unk_1[];
  250. extern const struct gf100_gr_init gm107_gr_init_tex_0[];
  251. extern const struct gf100_gr_init gm107_gr_init_l1c_0[];
  252. extern const struct gf100_gr_init gm107_gr_init_wwdx_0[];
  253. extern const struct gf100_gr_init gm107_gr_init_cbm_0[];
  254. void gm107_gr_init_bios(struct gf100_gr *);
  255. void gm200_gr_init_gpc_mmu(struct gf100_gr *);
  256. void gp100_gr_init_num_active_ltcs(struct gf100_gr *gr);
  257. void gp102_gr_init_swdx_pes_mask(struct gf100_gr *);
  258. #endif