Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / drm / nouveau / core / engine / graph / nv108.c
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
25 #include "nvc0.h"
26 #include "ctxnvc0.h"
27
28 /*******************************************************************************
29  * Graphics object classes
30  ******************************************************************************/
31
32 static struct nouveau_oclass
33 nv108_graph_sclass[] = {
34         { 0x902d, &nouveau_object_ofuncs },
35         { 0xa140, &nouveau_object_ofuncs },
36         { KEPLER_B, &nvc0_fermi_ofuncs },
37         { 0xa1c0, &nouveau_object_ofuncs },
38         {}
39 };
40
41 /*******************************************************************************
42  * PGRAPH register lists
43  ******************************************************************************/
44
45 static const struct nvc0_graph_init
46 nv108_graph_init_main_0[] = {
47         { 0x400080,   1, 0x04, 0x003083c2 },
48         { 0x400088,   1, 0x04, 0x0001bfe7 },
49         { 0x40008c,   1, 0x04, 0x00000000 },
50         { 0x400090,   1, 0x04, 0x00000030 },
51         { 0x40013c,   1, 0x04, 0x003901f7 },
52         { 0x400140,   1, 0x04, 0x00000100 },
53         { 0x400144,   1, 0x04, 0x00000000 },
54         { 0x400148,   1, 0x04, 0x00000110 },
55         { 0x400138,   1, 0x04, 0x00000000 },
56         { 0x400130,   2, 0x04, 0x00000000 },
57         { 0x400124,   1, 0x04, 0x00000002 },
58         {}
59 };
60
61 static const struct nvc0_graph_init
62 nv108_graph_init_ds_0[] = {
63         { 0x405844,   1, 0x04, 0x00ffffff },
64         { 0x405850,   1, 0x04, 0x00000000 },
65         { 0x405900,   1, 0x04, 0x00000000 },
66         { 0x405908,   1, 0x04, 0x00000000 },
67         { 0x405928,   2, 0x04, 0x00000000 },
68         {}
69 };
70
71 const struct nvc0_graph_init
72 nv108_graph_init_gpc_unk_0[] = {
73         { 0x418604,   1, 0x04, 0x00000000 },
74         { 0x418680,   1, 0x04, 0x00000000 },
75         { 0x418714,   1, 0x04, 0x00000000 },
76         { 0x418384,   2, 0x04, 0x00000000 },
77         {}
78 };
79
80 static const struct nvc0_graph_init
81 nv108_graph_init_setup_1[] = {
82         { 0x4188c8,   2, 0x04, 0x00000000 },
83         { 0x4188d0,   1, 0x04, 0x00010000 },
84         { 0x4188d4,   1, 0x04, 0x00000201 },
85         {}
86 };
87
88 static const struct nvc0_graph_init
89 nv108_graph_init_tex_0[] = {
90         { 0x419ab0,   1, 0x04, 0x00000000 },
91         { 0x419ac8,   1, 0x04, 0x00000000 },
92         { 0x419ab8,   1, 0x04, 0x000000e7 },
93         { 0x419abc,   2, 0x04, 0x00000000 },
94         { 0x419ab4,   1, 0x04, 0x00000000 },
95         { 0x419aa8,   2, 0x04, 0x00000000 },
96         {}
97 };
98
99 static const struct nvc0_graph_init
100 nv108_graph_init_l1c_0[] = {
101         { 0x419c98,   1, 0x04, 0x00000000 },
102         { 0x419ca8,   1, 0x04, 0x00000000 },
103         { 0x419cb0,   1, 0x04, 0x01000000 },
104         { 0x419cb4,   1, 0x04, 0x00000000 },
105         { 0x419cb8,   1, 0x04, 0x00b08bea },
106         { 0x419c84,   1, 0x04, 0x00010384 },
107         { 0x419cbc,   1, 0x04, 0x281b3646 },
108         { 0x419cc0,   2, 0x04, 0x00000000 },
109         { 0x419c80,   1, 0x04, 0x00000230 },
110         { 0x419ccc,   2, 0x04, 0x00000000 },
111         {}
112 };
113
114 static const struct nvc0_graph_pack
115 nv108_graph_pack_mmio[] = {
116         { nv108_graph_init_main_0 },
117         { nvf0_graph_init_fe_0 },
118         { nvc0_graph_init_pri_0 },
119         { nvc0_graph_init_rstr2d_0 },
120         { nvd9_graph_init_pd_0 },
121         { nv108_graph_init_ds_0 },
122         { nvc0_graph_init_scc_0 },
123         { nvf0_graph_init_sked_0 },
124         { nvf0_graph_init_cwd_0 },
125         { nvd9_graph_init_prop_0 },
126         { nv108_graph_init_gpc_unk_0 },
127         { nvc0_graph_init_setup_0 },
128         { nvc0_graph_init_crstr_0 },
129         { nv108_graph_init_setup_1 },
130         { nvc0_graph_init_zcull_0 },
131         { nvd9_graph_init_gpm_0 },
132         { nvf0_graph_init_gpc_unk_1 },
133         { nvc0_graph_init_gcc_0 },
134         { nve4_graph_init_tpccs_0 },
135         { nv108_graph_init_tex_0 },
136         { nve4_graph_init_pe_0 },
137         { nv108_graph_init_l1c_0 },
138         { nvc0_graph_init_mpc_0 },
139         { nvf0_graph_init_sm_0 },
140         { nvd7_graph_init_pes_0 },
141         { nvd7_graph_init_wwdx_0 },
142         { nvd7_graph_init_cbm_0 },
143         { nve4_graph_init_be_0 },
144         { nvc0_graph_init_fe_1 },
145         {}
146 };
147
148 /*******************************************************************************
149  * PGRAPH engine/subdev functions
150  ******************************************************************************/
151
152 static int
153 nv108_graph_fini(struct nouveau_object *object, bool suspend)
154 {
155         struct nvc0_graph_priv *priv = (void *)object;
156         static const struct {
157                 u32 addr;
158                 u32 data;
159         } magic[] = {
160                 { 0x020520, 0xfffffffc },
161                 { 0x020524, 0xfffffffe },
162                 { 0x020524, 0xfffffffc },
163                 { 0x020524, 0xfffffff8 },
164                 { 0x020524, 0xffffffe0 },
165                 { 0x020530, 0xfffffffe },
166                 { 0x02052c, 0xfffffffa },
167                 { 0x02052c, 0xfffffff0 },
168                 { 0x02052c, 0xffffffc0 },
169                 { 0x02052c, 0xffffff00 },
170                 { 0x02052c, 0xfffffc00 },
171                 { 0x02052c, 0xfffcfc00 },
172                 { 0x02052c, 0xfff0fc00 },
173                 { 0x02052c, 0xff80fc00 },
174                 { 0x020528, 0xfffffffe },
175                 { 0x020528, 0xfffffffc },
176         };
177         int i;
178
179         nv_mask(priv, 0x000200, 0x08001000, 0x00000000);
180         nv_mask(priv, 0x0206b4, 0x00000000, 0x00000000);
181         for (i = 0; i < ARRAY_SIZE(magic); i++) {
182                 nv_wr32(priv, magic[i].addr, magic[i].data);
183                 nv_wait(priv, magic[i].addr, 0x80000000, 0x00000000);
184         }
185
186         return nouveau_graph_fini(&priv->base, suspend);
187 }
188
189 #include "fuc/hubnv108.fuc5.h"
190
191 static struct nvc0_graph_ucode
192 nv108_graph_fecs_ucode = {
193         .code.data = nv108_grhub_code,
194         .code.size = sizeof(nv108_grhub_code),
195         .data.data = nv108_grhub_data,
196         .data.size = sizeof(nv108_grhub_data),
197 };
198
199 #include "fuc/gpcnv108.fuc5.h"
200
201 static struct nvc0_graph_ucode
202 nv108_graph_gpccs_ucode = {
203         .code.data = nv108_grgpc_code,
204         .code.size = sizeof(nv108_grgpc_code),
205         .data.data = nv108_grgpc_data,
206         .data.size = sizeof(nv108_grgpc_data),
207 };
208
209 struct nouveau_oclass *
210 nv108_graph_oclass = &(struct nvc0_graph_oclass) {
211         .base.handle = NV_ENGINE(GR, 0x08),
212         .base.ofuncs = &(struct nouveau_ofuncs) {
213                 .ctor = nvc0_graph_ctor,
214                 .dtor = nvc0_graph_dtor,
215                 .init = nve4_graph_init,
216                 .fini = nv108_graph_fini,
217         },
218         .cclass = &nv108_grctx_oclass,
219         .sclass =  nv108_graph_sclass,
220         .mmio = nv108_graph_pack_mmio,
221         .fecs.ucode = &nv108_graph_fecs_ucode,
222         .gpccs.ucode = &nv108_graph_gpccs_ucode,
223         .ppc_nr = 1,
224 }.base;