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
35struct nvkm_oclass
36gk110_gr_sclass[] = {
37	{ FERMI_TWOD_A, &nvkm_object_ofuncs },
38	{ KEPLER_INLINE_TO_MEMORY_B, &nvkm_object_ofuncs },
39	{ KEPLER_B, &gf100_fermi_ofuncs, gf100_gr_9097_omthds },
40	{ KEPLER_COMPUTE_B, &nvkm_object_ofuncs, gf100_gr_90c0_omthds },
41	{}
42};
43
44/*******************************************************************************
45 * PGRAPH register lists
46 ******************************************************************************/
47
48const struct gf100_gr_init
49gk110_gr_init_fe_0[] = {
50	{ 0x40415c,   1, 0x04, 0x00000000 },
51	{ 0x404170,   1, 0x04, 0x00000000 },
52	{ 0x4041b4,   1, 0x04, 0x00000000 },
53	{}
54};
55
56const struct gf100_gr_init
57gk110_gr_init_ds_0[] = {
58	{ 0x405844,   1, 0x04, 0x00ffffff },
59	{ 0x405850,   1, 0x04, 0x00000000 },
60	{ 0x405900,   1, 0x04, 0x0000ff00 },
61	{ 0x405908,   1, 0x04, 0x00000000 },
62	{ 0x405928,   2, 0x04, 0x00000000 },
63	{}
64};
65
66const struct gf100_gr_init
67gk110_gr_init_sked_0[] = {
68	{ 0x407010,   1, 0x04, 0x00000000 },
69	{ 0x407040,   1, 0x04, 0x80440424 },
70	{ 0x407048,   1, 0x04, 0x0000000a },
71	{}
72};
73
74const struct gf100_gr_init
75gk110_gr_init_cwd_0[] = {
76	{ 0x405b44,   1, 0x04, 0x00000000 },
77	{ 0x405b50,   1, 0x04, 0x00000000 },
78	{}
79};
80
81const struct gf100_gr_init
82gk110_gr_init_gpc_unk_1[] = {
83	{ 0x418d00,   1, 0x04, 0x00000000 },
84	{ 0x418d28,   2, 0x04, 0x00000000 },
85	{ 0x418f00,   1, 0x04, 0x00000400 },
86	{ 0x418f08,   1, 0x04, 0x00000000 },
87	{ 0x418f20,   2, 0x04, 0x00000000 },
88	{ 0x418e00,   1, 0x04, 0x00000000 },
89	{ 0x418e08,   1, 0x04, 0x00000000 },
90	{ 0x418e1c,   2, 0x04, 0x00000000 },
91	{}
92};
93
94const struct gf100_gr_init
95gk110_gr_init_tex_0[] = {
96	{ 0x419ab0,   1, 0x04, 0x00000000 },
97	{ 0x419ac8,   1, 0x04, 0x00000000 },
98	{ 0x419ab8,   1, 0x04, 0x000000e7 },
99	{ 0x419aec,   1, 0x04, 0x00000000 },
100	{ 0x419abc,   2, 0x04, 0x00000000 },
101	{ 0x419ab4,   1, 0x04, 0x00000000 },
102	{ 0x419aa8,   2, 0x04, 0x00000000 },
103	{}
104};
105
106static const struct gf100_gr_init
107gk110_gr_init_l1c_0[] = {
108	{ 0x419c98,   1, 0x04, 0x00000000 },
109	{ 0x419ca8,   1, 0x04, 0x00000000 },
110	{ 0x419cb0,   1, 0x04, 0x01000000 },
111	{ 0x419cb4,   1, 0x04, 0x00000000 },
112	{ 0x419cb8,   1, 0x04, 0x00b08bea },
113	{ 0x419c84,   1, 0x04, 0x00010384 },
114	{ 0x419cbc,   1, 0x04, 0x281b3646 },
115	{ 0x419cc0,   2, 0x04, 0x00000000 },
116	{ 0x419c80,   1, 0x04, 0x00020230 },
117	{ 0x419ccc,   2, 0x04, 0x00000000 },
118	{}
119};
120
121const struct gf100_gr_init
122gk110_gr_init_sm_0[] = {
123	{ 0x419e00,   1, 0x04, 0x00000080 },
124	{ 0x419ea0,   1, 0x04, 0x00000000 },
125	{ 0x419ee4,   1, 0x04, 0x00000000 },
126	{ 0x419ea4,   1, 0x04, 0x00000100 },
127	{ 0x419ea8,   1, 0x04, 0x00000000 },
128	{ 0x419eb4,   1, 0x04, 0x00000000 },
129	{ 0x419ebc,   2, 0x04, 0x00000000 },
130	{ 0x419edc,   1, 0x04, 0x00000000 },
131	{ 0x419f00,   1, 0x04, 0x00000000 },
132	{ 0x419ed0,   1, 0x04, 0x00003234 },
133	{ 0x419f74,   1, 0x04, 0x00015555 },
134	{ 0x419f80,   4, 0x04, 0x00000000 },
135	{}
136};
137
138static const struct gf100_gr_pack
139gk110_gr_pack_mmio[] = {
140	{ gk104_gr_init_main_0 },
141	{ gk110_gr_init_fe_0 },
142	{ gf100_gr_init_pri_0 },
143	{ gf100_gr_init_rstr2d_0 },
144	{ gf119_gr_init_pd_0 },
145	{ gk110_gr_init_ds_0 },
146	{ gf100_gr_init_scc_0 },
147	{ gk110_gr_init_sked_0 },
148	{ gk110_gr_init_cwd_0 },
149	{ gf119_gr_init_prop_0 },
150	{ gf108_gr_init_gpc_unk_0 },
151	{ gf100_gr_init_setup_0 },
152	{ gf100_gr_init_crstr_0 },
153	{ gf108_gr_init_setup_1 },
154	{ gf100_gr_init_zcull_0 },
155	{ gf119_gr_init_gpm_0 },
156	{ gk110_gr_init_gpc_unk_1 },
157	{ gf100_gr_init_gcc_0 },
158	{ gk104_gr_init_tpccs_0 },
159	{ gk110_gr_init_tex_0 },
160	{ gk104_gr_init_pe_0 },
161	{ gk110_gr_init_l1c_0 },
162	{ gf100_gr_init_mpc_0 },
163	{ gk110_gr_init_sm_0 },
164	{ gf117_gr_init_pes_0 },
165	{ gf117_gr_init_wwdx_0 },
166	{ gf117_gr_init_cbm_0 },
167	{ gk104_gr_init_be_0 },
168	{ gf100_gr_init_fe_1 },
169	{}
170};
171
172/*******************************************************************************
173 * PGRAPH engine/subdev functions
174 ******************************************************************************/
175
176#include "fuc/hubgk110.fuc3.h"
177
178struct gf100_gr_ucode
179gk110_gr_fecs_ucode = {
180	.code.data = gk110_grhub_code,
181	.code.size = sizeof(gk110_grhub_code),
182	.data.data = gk110_grhub_data,
183	.data.size = sizeof(gk110_grhub_data),
184};
185
186#include "fuc/gpcgk110.fuc3.h"
187
188struct gf100_gr_ucode
189gk110_gr_gpccs_ucode = {
190	.code.data = gk110_grgpc_code,
191	.code.size = sizeof(gk110_grgpc_code),
192	.data.data = gk110_grgpc_data,
193	.data.size = sizeof(gk110_grgpc_data),
194};
195
196struct nvkm_oclass *
197gk110_gr_oclass = &(struct gf100_gr_oclass) {
198	.base.handle = NV_ENGINE(GR, 0xf0),
199	.base.ofuncs = &(struct nvkm_ofuncs) {
200		.ctor = gk104_gr_ctor,
201		.dtor = gf100_gr_dtor,
202		.init = gk104_gr_init,
203		.fini = _nvkm_gr_fini,
204	},
205	.cclass = &gk110_grctx_oclass,
206	.sclass =  gk110_gr_sclass,
207	.mmio = gk110_gr_pack_mmio,
208	.fecs.ucode = &gk110_gr_fecs_ucode,
209	.gpccs.ucode = &gk110_gr_gpccs_ucode,
210	.ppc_nr = 2,
211}.base;
212