1 /* $NetBSD: nouveau_nvkm_engine_gr_gk208.c,v 1.3 2021/12/18 23:45:36 riastradh Exp $ */
2
3 /*
4 * Copyright 2013 Red Hat Inc.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
23 *
24 * Authors: Ben Skeggs <bskeggs@redhat.com>
25 */
26 #include <sys/cdefs.h>
27 __KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_engine_gr_gk208.c,v 1.3 2021/12/18 23:45:36 riastradh Exp $");
28
29 #include "gf100.h"
30 #include "ctxgf100.h"
31
32 #include <subdev/timer.h>
33
34 #include <nvif/class.h>
35
36 /*******************************************************************************
37 * PGRAPH register lists
38 ******************************************************************************/
39
40 static const struct gf100_gr_init
41 gk208_gr_init_main_0[] = {
42 { 0x400080, 1, 0x04, 0x003083c2 },
43 { 0x400088, 1, 0x04, 0x0001bfe7 },
44 { 0x40008c, 1, 0x04, 0x00000000 },
45 { 0x400090, 1, 0x04, 0x00000030 },
46 { 0x40013c, 1, 0x04, 0x003901f7 },
47 { 0x400140, 1, 0x04, 0x00000100 },
48 { 0x400144, 1, 0x04, 0x00000000 },
49 { 0x400148, 1, 0x04, 0x00000110 },
50 { 0x400138, 1, 0x04, 0x00000000 },
51 { 0x400130, 2, 0x04, 0x00000000 },
52 { 0x400124, 1, 0x04, 0x00000002 },
53 {}
54 };
55
56 static const struct gf100_gr_init
57 gk208_gr_init_ds_0[] = {
58 { 0x405844, 1, 0x04, 0x00ffffff },
59 { 0x405850, 1, 0x04, 0x00000000 },
60 { 0x405900, 1, 0x04, 0x00000000 },
61 { 0x405908, 1, 0x04, 0x00000000 },
62 { 0x405928, 2, 0x04, 0x00000000 },
63 {}
64 };
65
66 const struct gf100_gr_init
67 gk208_gr_init_gpc_unk_0[] = {
68 { 0x418604, 1, 0x04, 0x00000000 },
69 { 0x418680, 1, 0x04, 0x00000000 },
70 { 0x418714, 1, 0x04, 0x00000000 },
71 { 0x418384, 2, 0x04, 0x00000000 },
72 {}
73 };
74
75 static const struct gf100_gr_init
76 gk208_gr_init_setup_1[] = {
77 { 0x4188c8, 2, 0x04, 0x00000000 },
78 { 0x4188d0, 1, 0x04, 0x00010000 },
79 { 0x4188d4, 1, 0x04, 0x00000201 },
80 {}
81 };
82
83 static const struct gf100_gr_init
84 gk208_gr_init_tex_0[] = {
85 { 0x419ab0, 1, 0x04, 0x00000000 },
86 { 0x419ac8, 1, 0x04, 0x00000000 },
87 { 0x419ab8, 1, 0x04, 0x000000e7 },
88 { 0x419abc, 2, 0x04, 0x00000000 },
89 { 0x419ab4, 1, 0x04, 0x00000000 },
90 { 0x419aa8, 2, 0x04, 0x00000000 },
91 {}
92 };
93
94 static const struct gf100_gr_init
95 gk208_gr_init_l1c_0[] = {
96 { 0x419c98, 1, 0x04, 0x00000000 },
97 { 0x419ca8, 1, 0x04, 0x00000000 },
98 { 0x419cb0, 1, 0x04, 0x01000000 },
99 { 0x419cb4, 1, 0x04, 0x00000000 },
100 { 0x419cb8, 1, 0x04, 0x00b08bea },
101 { 0x419c84, 1, 0x04, 0x00010384 },
102 { 0x419cbc, 1, 0x04, 0x281b3646 },
103 { 0x419cc0, 2, 0x04, 0x00000000 },
104 { 0x419c80, 1, 0x04, 0x00000230 },
105 { 0x419ccc, 2, 0x04, 0x00000000 },
106 {}
107 };
108
109 static const struct gf100_gr_pack
110 gk208_gr_pack_mmio[] = {
111 { gk208_gr_init_main_0 },
112 { gk110_gr_init_fe_0 },
113 { gf100_gr_init_pri_0 },
114 { gf100_gr_init_rstr2d_0 },
115 { gf119_gr_init_pd_0 },
116 { gk208_gr_init_ds_0 },
117 { gf100_gr_init_scc_0 },
118 { gk110_gr_init_sked_0 },
119 { gk110_gr_init_cwd_0 },
120 { gf119_gr_init_prop_0 },
121 { gk208_gr_init_gpc_unk_0 },
122 { gf100_gr_init_setup_0 },
123 { gf100_gr_init_crstr_0 },
124 { gk208_gr_init_setup_1 },
125 { gf100_gr_init_zcull_0 },
126 { gf119_gr_init_gpm_0 },
127 { gk110_gr_init_gpc_unk_1 },
128 { gf100_gr_init_gcc_0 },
129 { gk104_gr_init_gpc_unk_2 },
130 { gk104_gr_init_tpccs_0 },
131 { gk208_gr_init_tex_0 },
132 { gk104_gr_init_pe_0 },
133 { gk208_gr_init_l1c_0 },
134 { gf100_gr_init_mpc_0 },
135 { gk110_gr_init_sm_0 },
136 { gf117_gr_init_pes_0 },
137 { gf117_gr_init_wwdx_0 },
138 { gf117_gr_init_cbm_0 },
139 { gk104_gr_init_be_0 },
140 { gf100_gr_init_fe_1 },
141 {}
142 };
143
144 /*******************************************************************************
145 * PGRAPH engine/subdev functions
146 ******************************************************************************/
147
148 #include "fuc/hubgk208.fuc5.h"
149
150 static struct gf100_gr_ucode
151 gk208_gr_fecs_ucode = {
152 .code.data = gk208_grhub_code,
153 .code.size = sizeof(gk208_grhub_code),
154 .data.data = gk208_grhub_data,
155 .data.size = sizeof(gk208_grhub_data),
156 };
157
158 #include "fuc/gpcgk208.fuc5.h"
159
160 static struct gf100_gr_ucode
161 gk208_gr_gpccs_ucode = {
162 .code.data = gk208_grgpc_code,
163 .code.size = sizeof(gk208_grgpc_code),
164 .data.data = gk208_grgpc_data,
165 .data.size = sizeof(gk208_grgpc_data),
166 };
167
168 static const struct gf100_gr_func
169 gk208_gr = {
170 .oneinit_tiles = gf100_gr_oneinit_tiles,
171 .oneinit_sm_id = gf100_gr_oneinit_sm_id,
172 .init = gf100_gr_init,
173 .init_gpc_mmu = gf100_gr_init_gpc_mmu,
174 .init_vsc_stream_master = gk104_gr_init_vsc_stream_master,
175 .init_zcull = gf117_gr_init_zcull,
176 .init_num_active_ltcs = gf100_gr_init_num_active_ltcs,
177 .init_rop_active_fbps = gk104_gr_init_rop_active_fbps,
178 .init_fecs_exceptions = gf100_gr_init_fecs_exceptions,
179 .init_sked_hww_esr = gk104_gr_init_sked_hww_esr,
180 .init_419cc0 = gf100_gr_init_419cc0,
181 .init_ppc_exceptions = gk104_gr_init_ppc_exceptions,
182 .init_tex_hww_esr = gf100_gr_init_tex_hww_esr,
183 .init_shader_exceptions = gf100_gr_init_shader_exceptions,
184 .init_400054 = gf100_gr_init_400054,
185 .trap_mp = gf100_gr_trap_mp,
186 .mmio = gk208_gr_pack_mmio,
187 .fecs.ucode = &gk208_gr_fecs_ucode,
188 .gpccs.ucode = &gk208_gr_gpccs_ucode,
189 .rops = gf100_gr_rops,
190 .ppc_nr = 1,
191 .grctx = &gk208_grctx,
192 .zbc = &gf100_gr_zbc,
193 .sclass = {
194 { -1, -1, FERMI_TWOD_A },
195 { -1, -1, KEPLER_INLINE_TO_MEMORY_B },
196 { -1, -1, KEPLER_B, &gf100_fermi },
197 { -1, -1, KEPLER_COMPUTE_B },
198 {}
199 }
200 };
201
202 static const struct gf100_gr_fwif
203 gk208_gr_fwif[] = {
204 { -1, gf100_gr_load, &gk208_gr },
205 { -1, gf100_gr_nofw, &gk208_gr },
206 {}
207 };
208
209 int
gk208_gr_new(struct nvkm_device * device,int index,struct nvkm_gr ** pgr)210 gk208_gr_new(struct nvkm_device *device, int index, struct nvkm_gr **pgr)
211 {
212 return gf100_gr_new_(gk208_gr_fwif, device, index, pgr);
213 }
214