1 /*
2  * Copyright 2013 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 <bskeggs@redhat.com>
23  */
24 #include "gf100.h"
25 #include "ctxgf100.h"
26 
27 #include <subdev/timer.h>
28 
29 #include <nvif/class.h>
30 
31 /*******************************************************************************
32  * Graphics object classes
33  ******************************************************************************/
34 
35 static struct nvkm_oclass
36 gk208_gr_sclass[] = {
37 	{ FERMI_TWOD_A, &nvkm_object_ofuncs },
38 	{ KEPLER_INLINE_TO_MEMORY_B, &nvkm_object_ofuncs },
39 	{ KEPLER_B, &gf100_fermi_ofuncs },
40 	{ KEPLER_COMPUTE_B, &nvkm_object_ofuncs },
41 	{}
42 };
43 
44 /*******************************************************************************
45  * PGRAPH register lists
46  ******************************************************************************/
47 
48 static const struct gf100_gr_init
49 gk208_gr_init_main_0[] = {
50 	{ 0x400080,   1, 0x04, 0x003083c2 },
51 	{ 0x400088,   1, 0x04, 0x0001bfe7 },
52 	{ 0x40008c,   1, 0x04, 0x00000000 },
53 	{ 0x400090,   1, 0x04, 0x00000030 },
54 	{ 0x40013c,   1, 0x04, 0x003901f7 },
55 	{ 0x400140,   1, 0x04, 0x00000100 },
56 	{ 0x400144,   1, 0x04, 0x00000000 },
57 	{ 0x400148,   1, 0x04, 0x00000110 },
58 	{ 0x400138,   1, 0x04, 0x00000000 },
59 	{ 0x400130,   2, 0x04, 0x00000000 },
60 	{ 0x400124,   1, 0x04, 0x00000002 },
61 	{}
62 };
63 
64 static const struct gf100_gr_init
65 gk208_gr_init_ds_0[] = {
66 	{ 0x405844,   1, 0x04, 0x00ffffff },
67 	{ 0x405850,   1, 0x04, 0x00000000 },
68 	{ 0x405900,   1, 0x04, 0x00000000 },
69 	{ 0x405908,   1, 0x04, 0x00000000 },
70 	{ 0x405928,   2, 0x04, 0x00000000 },
71 	{}
72 };
73 
74 const struct gf100_gr_init
75 gk208_gr_init_gpc_unk_0[] = {
76 	{ 0x418604,   1, 0x04, 0x00000000 },
77 	{ 0x418680,   1, 0x04, 0x00000000 },
78 	{ 0x418714,   1, 0x04, 0x00000000 },
79 	{ 0x418384,   2, 0x04, 0x00000000 },
80 	{}
81 };
82 
83 static const struct gf100_gr_init
84 gk208_gr_init_setup_1[] = {
85 	{ 0x4188c8,   2, 0x04, 0x00000000 },
86 	{ 0x4188d0,   1, 0x04, 0x00010000 },
87 	{ 0x4188d4,   1, 0x04, 0x00000201 },
88 	{}
89 };
90 
91 static const struct gf100_gr_init
92 gk208_gr_init_tex_0[] = {
93 	{ 0x419ab0,   1, 0x04, 0x00000000 },
94 	{ 0x419ac8,   1, 0x04, 0x00000000 },
95 	{ 0x419ab8,   1, 0x04, 0x000000e7 },
96 	{ 0x419abc,   2, 0x04, 0x00000000 },
97 	{ 0x419ab4,   1, 0x04, 0x00000000 },
98 	{ 0x419aa8,   2, 0x04, 0x00000000 },
99 	{}
100 };
101 
102 static const struct gf100_gr_init
103 gk208_gr_init_l1c_0[] = {
104 	{ 0x419c98,   1, 0x04, 0x00000000 },
105 	{ 0x419ca8,   1, 0x04, 0x00000000 },
106 	{ 0x419cb0,   1, 0x04, 0x01000000 },
107 	{ 0x419cb4,   1, 0x04, 0x00000000 },
108 	{ 0x419cb8,   1, 0x04, 0x00b08bea },
109 	{ 0x419c84,   1, 0x04, 0x00010384 },
110 	{ 0x419cbc,   1, 0x04, 0x281b3646 },
111 	{ 0x419cc0,   2, 0x04, 0x00000000 },
112 	{ 0x419c80,   1, 0x04, 0x00000230 },
113 	{ 0x419ccc,   2, 0x04, 0x00000000 },
114 	{}
115 };
116 
117 static const struct gf100_gr_pack
118 gk208_gr_pack_mmio[] = {
119 	{ gk208_gr_init_main_0 },
120 	{ gk110_gr_init_fe_0 },
121 	{ gf100_gr_init_pri_0 },
122 	{ gf100_gr_init_rstr2d_0 },
123 	{ gf119_gr_init_pd_0 },
124 	{ gk208_gr_init_ds_0 },
125 	{ gf100_gr_init_scc_0 },
126 	{ gk110_gr_init_sked_0 },
127 	{ gk110_gr_init_cwd_0 },
128 	{ gf119_gr_init_prop_0 },
129 	{ gk208_gr_init_gpc_unk_0 },
130 	{ gf100_gr_init_setup_0 },
131 	{ gf100_gr_init_crstr_0 },
132 	{ gk208_gr_init_setup_1 },
133 	{ gf100_gr_init_zcull_0 },
134 	{ gf119_gr_init_gpm_0 },
135 	{ gk110_gr_init_gpc_unk_1 },
136 	{ gf100_gr_init_gcc_0 },
137 	{ gk104_gr_init_tpccs_0 },
138 	{ gk208_gr_init_tex_0 },
139 	{ gk104_gr_init_pe_0 },
140 	{ gk208_gr_init_l1c_0 },
141 	{ gf100_gr_init_mpc_0 },
142 	{ gk110_gr_init_sm_0 },
143 	{ gf117_gr_init_pes_0 },
144 	{ gf117_gr_init_wwdx_0 },
145 	{ gf117_gr_init_cbm_0 },
146 	{ gk104_gr_init_be_0 },
147 	{ gf100_gr_init_fe_1 },
148 	{}
149 };
150 
151 /*******************************************************************************
152  * PGRAPH engine/subdev functions
153  ******************************************************************************/
154 
155 #include "fuc/hubgk208.fuc5.h"
156 
157 static struct gf100_gr_ucode
158 gk208_gr_fecs_ucode = {
159 	.code.data = gk208_grhub_code,
160 	.code.size = sizeof(gk208_grhub_code),
161 	.data.data = gk208_grhub_data,
162 	.data.size = sizeof(gk208_grhub_data),
163 };
164 
165 #include "fuc/gpcgk208.fuc5.h"
166 
167 static struct gf100_gr_ucode
168 gk208_gr_gpccs_ucode = {
169 	.code.data = gk208_grgpc_code,
170 	.code.size = sizeof(gk208_grgpc_code),
171 	.data.data = gk208_grgpc_data,
172 	.data.size = sizeof(gk208_grgpc_data),
173 };
174 
175 struct nvkm_oclass *
176 gk208_gr_oclass = &(struct gf100_gr_oclass) {
177 	.base.handle = NV_ENGINE(GR, 0x08),
178 	.base.ofuncs = &(struct nvkm_ofuncs) {
179 		.ctor = gk104_gr_ctor,
180 		.dtor = gf100_gr_dtor,
181 		.init = gk104_gr_init,
182 		.fini = _nvkm_gr_fini,
183 	},
184 	.cclass = &gk208_grctx_oclass,
185 	.sclass =  gk208_gr_sclass,
186 	.mmio = gk208_gr_pack_mmio,
187 	.fecs.ucode = &gk208_gr_fecs_ucode,
188 	.gpccs.ucode = &gk208_gr_gpccs_ucode,
189 	.ppc_nr = 1,
190 }.base;
191