2 * Copyright 2010 Red Hat Inc.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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.
24 #ifndef __GF100_GR_H__
25 #define __GF100_GR_H__
26 #define gf100_gr(p) container_of((p), struct gf100_gr, base)
29 #include <core/gpuobj.h>
30 #include <subdev/ltc.h>
31 #include <subdev/mmu.h>
34 #define TPC_MAX (GPC_MAX * 8)
36 #define ROP_BCAST(r) (0x408800 + (r))
37 #define ROP_UNIT(u, r) (0x410000 + (u) * 0x400 + (r))
38 #define GPC_BCAST(r) (0x418000 + (r))
39 #define GPC_UNIT(t, r) (0x500000 + (t) * 0x8000 + (r))
40 #define PPC_UNIT(t, m, r) (0x503000 + (t) * 0x8000 + (m) * 0x200 + (r))
41 #define TPC_UNIT(t, m, r) (0x504000 + (t) * 0x8000 + (m) * 0x800 + (r))
43 struct gf100_gr_data
{
49 struct gf100_gr_mmio
{
61 struct gf100_gr_zbc_color
{
67 struct gf100_gr_zbc_depth
{
74 const struct gf100_gr_func
*func
;
77 struct gf100_gr_fuc fuc409c
;
78 struct gf100_gr_fuc fuc409d
;
79 struct gf100_gr_fuc fuc41ac
;
80 struct gf100_gr_fuc fuc41ad
;
84 * Used if the register packs are loaded from NVIDIA fw instead of
85 * using hardcoded arrays.
87 struct gf100_gr_pack
*fuc_sw_nonctx
;
88 struct gf100_gr_pack
*fuc_sw_ctx
;
89 struct gf100_gr_pack
*fuc_bundle
;
90 struct gf100_gr_pack
*fuc_method
;
92 struct gf100_gr_zbc_color zbc_color
[NVKM_LTC_MAX_ZBC_CNT
];
93 struct gf100_gr_zbc_depth zbc_depth
[NVKM_LTC_MAX_ZBC_CNT
];
100 u8 ppc_mask
[GPC_MAX
];
101 u8 ppc_tpc_nr
[GPC_MAX
][4];
103 struct nvkm_memory
*unk4188b4
;
104 struct nvkm_memory
*unk4188b8
;
106 struct gf100_gr_data mmio_data
[4];
107 struct gf100_gr_mmio mmio_list
[4096/8];
114 int gf100_gr_ctor(const struct gf100_gr_func
*, struct nvkm_device
*,
115 int, struct gf100_gr
*);
116 int gf100_gr_new_(const struct gf100_gr_func
*, struct nvkm_device
*,
117 int, struct nvkm_gr
**);
118 void *gf100_gr_dtor(struct nvkm_gr
*);
120 struct gf100_gr_func
{
121 void (*dtor
)(struct gf100_gr
*);
122 int (*init
)(struct gf100_gr
*);
123 void (*init_gpc_mmu
)(struct gf100_gr
*);
124 void (*set_hww_esr_report_mask
)(struct gf100_gr
*);
125 const struct gf100_gr_pack
*mmio
;
127 struct gf100_gr_ucode
*ucode
;
130 struct gf100_gr_ucode
*ucode
;
133 const struct gf100_grctx_func
*grctx
;
134 struct nvkm_sclass sclass
[];
137 int gf100_gr_init(struct gf100_gr
*);
139 int gk104_gr_init(struct gf100_gr
*);
141 int gk20a_gr_new_(const struct gf100_gr_func
*, struct nvkm_device
*,
142 int, struct nvkm_gr
**);
143 void gk20a_gr_dtor(struct gf100_gr
*);
144 int gk20a_gr_init(struct gf100_gr
*);
146 int gm204_gr_init(struct gf100_gr
*);
148 #define gf100_gr_chan(p) container_of((p), struct gf100_gr_chan, object)
150 struct gf100_gr_chan
{
151 struct nvkm_object object
;
154 struct nvkm_memory
*mmio
;
155 struct nvkm_vma mmio_vma
;
159 struct nvkm_memory
*mem
;
164 void gf100_gr_ctxctl_debug(struct gf100_gr
*);
166 void gf100_gr_dtor_fw(struct gf100_gr_fuc
*);
167 int gf100_gr_ctor_fw(struct gf100_gr
*, const char *,
168 struct gf100_gr_fuc
*);
169 u64
gf100_gr_units(struct nvkm_gr
*);
170 void gf100_gr_zbc_init(struct gf100_gr
*);
172 extern const struct nvkm_object_func gf100_fermi
;
174 struct gf100_gr_init
{
181 struct gf100_gr_pack
{
182 const struct gf100_gr_init
*init
;
186 #define pack_for_each_init(init, pack, head) \
187 for (pack = head; pack && pack->init; pack++) \
188 for (init = pack->init; init && init->count; init++)
190 struct gf100_gr_ucode
{
191 struct gf100_gr_fuc code
;
192 struct gf100_gr_fuc data
;
195 extern struct gf100_gr_ucode gf100_gr_fecs_ucode
;
196 extern struct gf100_gr_ucode gf100_gr_gpccs_ucode
;
198 extern struct gf100_gr_ucode gk110_gr_fecs_ucode
;
199 extern struct gf100_gr_ucode gk110_gr_gpccs_ucode
;
201 int gf100_gr_wait_idle(struct gf100_gr
*);
202 void gf100_gr_mmio(struct gf100_gr
*, const struct gf100_gr_pack
*);
203 void gf100_gr_icmd(struct gf100_gr
*, const struct gf100_gr_pack
*);
204 void gf100_gr_mthd(struct gf100_gr
*, const struct gf100_gr_pack
*);
205 int gf100_gr_init_ctxctl(struct gf100_gr
*);
207 /* register init value lists */
209 extern const struct gf100_gr_init gf100_gr_init_main_0
[];
210 extern const struct gf100_gr_init gf100_gr_init_fe_0
[];
211 extern const struct gf100_gr_init gf100_gr_init_pri_0
[];
212 extern const struct gf100_gr_init gf100_gr_init_rstr2d_0
[];
213 extern const struct gf100_gr_init gf100_gr_init_pd_0
[];
214 extern const struct gf100_gr_init gf100_gr_init_ds_0
[];
215 extern const struct gf100_gr_init gf100_gr_init_scc_0
[];
216 extern const struct gf100_gr_init gf100_gr_init_prop_0
[];
217 extern const struct gf100_gr_init gf100_gr_init_gpc_unk_0
[];
218 extern const struct gf100_gr_init gf100_gr_init_setup_0
[];
219 extern const struct gf100_gr_init gf100_gr_init_crstr_0
[];
220 extern const struct gf100_gr_init gf100_gr_init_setup_1
[];
221 extern const struct gf100_gr_init gf100_gr_init_zcull_0
[];
222 extern const struct gf100_gr_init gf100_gr_init_gpm_0
[];
223 extern const struct gf100_gr_init gf100_gr_init_gpc_unk_1
[];
224 extern const struct gf100_gr_init gf100_gr_init_gcc_0
[];
225 extern const struct gf100_gr_init gf100_gr_init_tpccs_0
[];
226 extern const struct gf100_gr_init gf100_gr_init_tex_0
[];
227 extern const struct gf100_gr_init gf100_gr_init_pe_0
[];
228 extern const struct gf100_gr_init gf100_gr_init_l1c_0
[];
229 extern const struct gf100_gr_init gf100_gr_init_wwdx_0
[];
230 extern const struct gf100_gr_init gf100_gr_init_tpccs_1
[];
231 extern const struct gf100_gr_init gf100_gr_init_mpc_0
[];
232 extern const struct gf100_gr_init gf100_gr_init_be_0
[];
233 extern const struct gf100_gr_init gf100_gr_init_fe_1
[];
234 extern const struct gf100_gr_init gf100_gr_init_pe_1
[];
236 extern const struct gf100_gr_init gf104_gr_init_ds_0
[];
237 extern const struct gf100_gr_init gf104_gr_init_tex_0
[];
238 extern const struct gf100_gr_init gf104_gr_init_sm_0
[];
240 extern const struct gf100_gr_init gf108_gr_init_gpc_unk_0
[];
241 extern const struct gf100_gr_init gf108_gr_init_setup_1
[];
243 extern const struct gf100_gr_init gf119_gr_init_pd_0
[];
244 extern const struct gf100_gr_init gf119_gr_init_ds_0
[];
245 extern const struct gf100_gr_init gf119_gr_init_prop_0
[];
246 extern const struct gf100_gr_init gf119_gr_init_gpm_0
[];
247 extern const struct gf100_gr_init gf119_gr_init_gpc_unk_1
[];
248 extern const struct gf100_gr_init gf119_gr_init_tex_0
[];
249 extern const struct gf100_gr_init gf119_gr_init_sm_0
[];
250 extern const struct gf100_gr_init gf119_gr_init_fe_1
[];
252 extern const struct gf100_gr_init gf117_gr_init_pes_0
[];
253 extern const struct gf100_gr_init gf117_gr_init_wwdx_0
[];
254 extern const struct gf100_gr_init gf117_gr_init_cbm_0
[];
256 extern const struct gf100_gr_init gk104_gr_init_main_0
[];
257 extern const struct gf100_gr_init gk104_gr_init_tpccs_0
[];
258 extern const struct gf100_gr_init gk104_gr_init_pe_0
[];
259 extern const struct gf100_gr_init gk104_gr_init_be_0
[];
260 extern const struct gf100_gr_pack gk104_gr_pack_mmio
[];
262 extern const struct gf100_gr_init gk110_gr_init_fe_0
[];
263 extern const struct gf100_gr_init gk110_gr_init_ds_0
[];
264 extern const struct gf100_gr_init gk110_gr_init_sked_0
[];
265 extern const struct gf100_gr_init gk110_gr_init_cwd_0
[];
266 extern const struct gf100_gr_init gk110_gr_init_gpc_unk_1
[];
267 extern const struct gf100_gr_init gk110_gr_init_tex_0
[];
268 extern const struct gf100_gr_init gk110_gr_init_sm_0
[];
270 extern const struct gf100_gr_init gk208_gr_init_gpc_unk_0
[];
272 extern const struct gf100_gr_init gm107_gr_init_scc_0
[];
273 extern const struct gf100_gr_init gm107_gr_init_prop_0
[];
274 extern const struct gf100_gr_init gm107_gr_init_setup_1
[];
275 extern const struct gf100_gr_init gm107_gr_init_zcull_0
[];
276 extern const struct gf100_gr_init gm107_gr_init_gpc_unk_1
[];
277 extern const struct gf100_gr_init gm107_gr_init_tex_0
[];
278 extern const struct gf100_gr_init gm107_gr_init_l1c_0
[];
279 extern const struct gf100_gr_init gm107_gr_init_wwdx_0
[];
280 extern const struct gf100_gr_init gm107_gr_init_cbm_0
[];
281 void gm107_gr_init_bios(struct gf100_gr
*);
283 extern const struct gf100_gr_pack gm204_gr_pack_mmio
[];