1/* SPDX-License-Identifier: MIT */
2#ifndef __NVKM_GRCTX_NVC0_H__
3#define __NVKM_GRCTX_NVC0_H__
4#include "gf100.h"
5
6void gf100_grctx_patch_wr32(struct gf100_gr_chan *, u32 addr, u32 data);
7
8struct gf100_grctx_func {
9	void (*unkn88c)(struct gf100_gr *, bool on);
10	/* main context generation function */
11	void  (*main)(struct gf100_gr_chan *);
12	/* context-specific modify-on-first-load list generation function */
13	void  (*unkn)(struct gf100_gr *);
14	/* mmio context data */
15	const struct gf100_gr_pack *hub;
16	const struct gf100_gr_pack *gpc_0;
17	const struct gf100_gr_pack *gpc_1;
18	const struct gf100_gr_pack *zcull;
19	const struct gf100_gr_pack *tpc;
20	const struct gf100_gr_pack *ppc;
21	/* indirect context data, generated with icmds/mthds */
22	const struct gf100_gr_pack *icmd;
23	const struct gf100_gr_pack *mthd;
24	const struct gf100_gr_pack *sw_veid_bundle_init;
25	const struct gf100_gr_pack *sw_bundle64_init;
26	/* bundle circular buffer */
27	void (*bundle)(struct gf100_gr_chan *, u64 addr, u32 size);
28	u32 bundle_size;
29	u32 bundle_min_gpm_fifo_depth;
30	u32 bundle_token_limit;
31	/* pagepool */
32	void (*pagepool)(struct gf100_gr_chan *, u64 addr);
33	u32 pagepool_size;
34	/* attribute(/alpha) circular buffer */
35	u32 (*attrib_cb_size)(struct gf100_gr *);
36	void (*attrib_cb)(struct gf100_gr_chan *, u64 addr, u32 size);
37	void (*attrib)(struct gf100_gr_chan *);
38	u32 attrib_nr_max;
39	u32 attrib_nr;
40	u32 alpha_nr_max;
41	u32 alpha_nr;
42	u32 gfxp_nr;
43	/* some other context buffer */
44	void (*unknown)(struct gf100_gr_chan *, u64 addr, u32 size);
45	u32 unknown_size;
46	/* other patch buffer stuff */
47	void (*patch_ltc)(struct gf100_gr_chan *);
48	/* floorsweeping */
49	void (*sm_id)(struct gf100_gr *, int gpc, int tpc, int sm);
50	void (*tpc_nr)(struct gf100_gr *, int gpc);
51	bool skip_pd_num_tpc_per_gpc;
52	void (*r4060a8)(struct gf100_gr *);
53	void (*rop_mapping)(struct gf100_gr *);
54	void (*alpha_beta_tables)(struct gf100_gr *);
55	void (*max_ways_evict)(struct gf100_gr *);
56	void (*dist_skip_table)(struct gf100_gr *);
57	void (*r406500)(struct gf100_gr *);
58	void (*gpc_tpc_nr)(struct gf100_gr *);
59	void (*r419f78)(struct gf100_gr *);
60	void (*tpc_mask)(struct gf100_gr *);
61	void (*smid_config)(struct gf100_gr *);
62	/* misc other things */
63	void (*r400088)(struct gf100_gr *, bool);
64	void (*r419cb8)(struct gf100_gr *);
65	void (*r418800)(struct gf100_gr *);
66	void (*r419eb0)(struct gf100_gr *);
67	void (*r419e00)(struct gf100_gr *);
68	void (*r418e94)(struct gf100_gr *);
69	void (*r419a3c)(struct gf100_gr *);
70	void (*r408840)(struct gf100_gr *);
71	void (*r419c0c)(struct gf100_gr *);
72	void (*r419ea8)(struct gf100_gr *);
73};
74
75extern const struct gf100_grctx_func gf100_grctx;
76int  gf100_grctx_generate(struct gf100_gr *, struct gf100_gr_chan *, struct nvkm_gpuobj *inst);
77void gf100_grctx_generate_main(struct gf100_gr_chan *);
78void gf100_grctx_generate_pagepool(struct gf100_gr_chan *, u64);
79void gf100_grctx_generate_bundle(struct gf100_gr_chan *, u64, u32);
80u32 gf100_grctx_generate_attrib_cb_size(struct gf100_gr *);
81void gf100_grctx_generate_attrib_cb(struct gf100_gr_chan *, u64, u32);
82void gf100_grctx_generate_attrib(struct gf100_gr_chan *);
83void gf100_grctx_generate_unkn(struct gf100_gr *);
84void gf100_grctx_generate_floorsweep(struct gf100_gr *);
85void gf100_grctx_generate_sm_id(struct gf100_gr *, int, int, int);
86void gf100_grctx_generate_tpc_nr(struct gf100_gr *, int);
87void gf100_grctx_generate_r4060a8(struct gf100_gr *);
88void gf100_grctx_generate_rop_mapping(struct gf100_gr *);
89void gf100_grctx_generate_alpha_beta_tables(struct gf100_gr *);
90void gf100_grctx_generate_max_ways_evict(struct gf100_gr *);
91void gf100_grctx_generate_r419cb8(struct gf100_gr *);
92
93extern const struct gf100_grctx_func gf108_grctx;
94void gf108_grctx_generate_attrib(struct gf100_gr_chan *);
95void gf108_grctx_generate_unkn(struct gf100_gr *);
96
97extern const struct gf100_grctx_func gf104_grctx;
98extern const struct gf100_grctx_func gf110_grctx;
99
100extern const struct gf100_grctx_func gf117_grctx;
101void gf117_grctx_generate_attrib(struct gf100_gr_chan *);
102void gf117_grctx_generate_rop_mapping(struct gf100_gr *);
103void gf117_grctx_generate_dist_skip_table(struct gf100_gr *);
104
105extern const struct gf100_grctx_func gf119_grctx;
106
107extern const struct gf100_grctx_func gk104_grctx;
108void gk104_grctx_generate_alpha_beta_tables(struct gf100_gr *);
109void gk104_grctx_generate_gpc_tpc_nr(struct gf100_gr *);
110
111extern const struct gf100_grctx_func gk20a_grctx;
112void gk104_grctx_generate_pagepool(struct gf100_gr_chan *, u64);
113void gk104_grctx_generate_bundle(struct gf100_gr_chan *, u64, u32);
114void gk104_grctx_generate_patch_ltc(struct gf100_gr_chan *);
115void gk104_grctx_generate_unkn(struct gf100_gr *);
116void gk104_grctx_generate_r418800(struct gf100_gr *);
117
118extern const struct gf100_grctx_func gk110_grctx;
119void gk110_grctx_generate_r419eb0(struct gf100_gr *);
120void gk110_grctx_generate_r419f78(struct gf100_gr *);
121
122extern const struct gf100_grctx_func gk110b_grctx;
123extern const struct gf100_grctx_func gk208_grctx;
124
125extern const struct gf100_grctx_func gm107_grctx;
126void gm107_grctx_generate_pagepool(struct gf100_gr_chan *, u64);
127void gm107_grctx_generate_bundle(struct gf100_gr_chan *, u64, u32);
128void gm107_grctx_generate_attrib_cb(struct gf100_gr_chan *, u64, u32);
129void gm107_grctx_generate_attrib(struct gf100_gr_chan *);
130void gm107_grctx_generate_sm_id(struct gf100_gr *, int, int, int);
131
132extern const struct gf100_grctx_func gm200_grctx;
133void gm200_grctx_generate_dist_skip_table(struct gf100_gr *);
134void gm200_grctx_generate_r406500(struct gf100_gr *);
135void gm200_grctx_generate_tpc_mask(struct gf100_gr *);
136void gm200_grctx_generate_smid_config(struct gf100_gr *);
137void gm200_grctx_generate_r419a3c(struct gf100_gr *);
138
139extern const struct gf100_grctx_func gm20b_grctx;
140
141extern const struct gf100_grctx_func gp100_grctx;
142void gp100_grctx_generate_pagepool(struct gf100_gr_chan *, u64);
143void gp100_grctx_generate_attrib_cb(struct gf100_gr_chan *, u64, u32);
144void gp100_grctx_generate_smid_config(struct gf100_gr *);
145
146extern const struct gf100_grctx_func gp102_grctx;
147u32 gp102_grctx_generate_attrib_cb_size(struct gf100_gr *);
148void gp102_grctx_generate_attrib(struct gf100_gr_chan *);
149
150extern const struct gf100_grctx_func gp104_grctx;
151
152extern const struct gf100_grctx_func gp107_grctx;
153
154extern const struct gf100_grctx_func gv100_grctx;
155
156extern const struct gf100_grctx_func tu102_grctx;
157void gv100_grctx_unkn88c(struct gf100_gr *, bool);
158void gv100_grctx_generate_unkn(struct gf100_gr *);
159void gv100_grctx_generate_attrib_cb(struct gf100_gr_chan *, u64, u32);
160void gv100_grctx_generate_attrib(struct gf100_gr_chan *);
161void gv100_grctx_generate_rop_mapping(struct gf100_gr *);
162void gv100_grctx_generate_r400088(struct gf100_gr *, bool);
163
164void tu102_grctx_generate_unknown(struct gf100_gr_chan *, u64, u32);
165
166extern const struct gf100_grctx_func ga102_grctx;
167
168/* context init value lists */
169
170extern const struct gf100_gr_pack gf100_grctx_pack_icmd[];
171
172extern const struct gf100_gr_pack gf100_grctx_pack_mthd[];
173extern const struct gf100_gr_init gf100_grctx_init_902d_0[];
174extern const struct gf100_gr_init gf100_grctx_init_9039_0[];
175extern const struct gf100_gr_init gf100_grctx_init_90c0_0[];
176
177extern const struct gf100_gr_pack gf100_grctx_pack_hub[];
178extern const struct gf100_gr_init gf100_grctx_init_main_0[];
179extern const struct gf100_gr_init gf100_grctx_init_fe_0[];
180extern const struct gf100_gr_init gf100_grctx_init_pri_0[];
181extern const struct gf100_gr_init gf100_grctx_init_memfmt_0[];
182extern const struct gf100_gr_init gf100_grctx_init_rstr2d_0[];
183extern const struct gf100_gr_init gf100_grctx_init_scc_0[];
184
185extern const struct gf100_gr_pack gf100_grctx_pack_gpc_0[];
186extern const struct gf100_gr_pack gf100_grctx_pack_gpc_1[];
187extern const struct gf100_gr_init gf100_grctx_init_gpc_unk_0[];
188extern const struct gf100_gr_init gf100_grctx_init_prop_0[];
189extern const struct gf100_gr_init gf100_grctx_init_gpc_unk_1[];
190extern const struct gf100_gr_init gf100_grctx_init_zcull_0[];
191extern const struct gf100_gr_init gf100_grctx_init_crstr_0[];
192extern const struct gf100_gr_init gf100_grctx_init_gpm_0[];
193extern const struct gf100_gr_init gf100_grctx_init_gcc_0[];
194
195extern const struct gf100_gr_pack gf100_grctx_pack_zcull[];
196
197extern const struct gf100_gr_pack gf100_grctx_pack_tpc[];
198extern const struct gf100_gr_init gf100_grctx_init_pe_0[];
199extern const struct gf100_gr_init gf100_grctx_init_wwdx_0[];
200extern const struct gf100_gr_init gf100_grctx_init_mpc_0[];
201extern const struct gf100_gr_init gf100_grctx_init_tpccs_0[];
202
203extern const struct gf100_gr_init gf104_grctx_init_tex_0[];
204extern const struct gf100_gr_init gf104_grctx_init_l1c_0[];
205extern const struct gf100_gr_init gf104_grctx_init_sm_0[];
206
207extern const struct gf100_gr_init gf108_grctx_init_9097_0[];
208
209extern const struct gf100_gr_init gf108_grctx_init_gpm_0[];
210
211extern const struct gf100_gr_init gf108_grctx_init_pe_0[];
212extern const struct gf100_gr_init gf108_grctx_init_wwdx_0[];
213extern const struct gf100_gr_init gf108_grctx_init_tpccs_0[];
214
215extern const struct gf100_gr_init gf110_grctx_init_9197_0[];
216extern const struct gf100_gr_init gf110_grctx_init_9297_0[];
217
218extern const struct gf100_gr_pack gf119_grctx_pack_icmd[];
219
220extern const struct gf100_gr_pack gf119_grctx_pack_mthd[];
221
222extern const struct gf100_gr_init gf119_grctx_init_fe_0[];
223extern const struct gf100_gr_init gf119_grctx_init_be_0[];
224
225extern const struct gf100_gr_init gf119_grctx_init_prop_0[];
226extern const struct gf100_gr_init gf119_grctx_init_gpc_unk_1[];
227extern const struct gf100_gr_init gf119_grctx_init_crstr_0[];
228
229extern const struct gf100_gr_init gf119_grctx_init_sm_0[];
230
231extern const struct gf100_gr_init gf117_grctx_init_pe_0[];
232
233extern const struct gf100_gr_init gf117_grctx_init_wwdx_0[];
234
235extern const struct gf100_gr_pack gf117_grctx_pack_gpc_1[];
236
237extern const struct gf100_gr_init gk104_grctx_init_memfmt_0[];
238extern const struct gf100_gr_init gk104_grctx_init_ds_0[];
239extern const struct gf100_gr_init gk104_grctx_init_scc_0[];
240
241extern const struct gf100_gr_init gk104_grctx_init_gpm_0[];
242
243extern const struct gf100_gr_init gk104_grctx_init_pes_0[];
244
245extern const struct gf100_gr_pack gk104_grctx_pack_hub[];
246extern const struct gf100_gr_pack gk104_grctx_pack_tpc[];
247extern const struct gf100_gr_pack gk104_grctx_pack_ppc[];
248extern const struct gf100_gr_pack gk104_grctx_pack_icmd[];
249extern const struct gf100_gr_init gk104_grctx_init_a097_0[];
250
251extern const struct gf100_gr_pack gk110_grctx_pack_icmd[];
252
253extern const struct gf100_gr_pack gk110_grctx_pack_mthd[];
254
255extern const struct gf100_gr_pack gk110_grctx_pack_hub[];
256extern const struct gf100_gr_init gk110_grctx_init_pri_0[];
257extern const struct gf100_gr_init gk110_grctx_init_cwd_0[];
258
259extern const struct gf100_gr_pack gk110_grctx_pack_gpc_0[];
260extern const struct gf100_gr_pack gk110_grctx_pack_gpc_1[];
261extern const struct gf100_gr_init gk110_grctx_init_gpc_unk_2[];
262
263extern const struct gf100_gr_init gk110_grctx_init_tex_0[];
264extern const struct gf100_gr_init gk110_grctx_init_mpc_0[];
265extern const struct gf100_gr_init gk110_grctx_init_l1c_0[];
266
267extern const struct gf100_gr_pack gk110_grctx_pack_ppc[];
268
269extern const struct gf100_gr_init gk208_grctx_init_rstr2d_0[];
270
271extern const struct gf100_gr_init gk208_grctx_init_prop_0[];
272extern const struct gf100_gr_init gk208_grctx_init_crstr_0[];
273
274extern const struct gf100_gr_init gm107_grctx_init_gpc_unk_0[];
275extern const struct gf100_gr_init gm107_grctx_init_wwdx_0[];
276#endif
277