]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - drivers/gpu/drm/nouveau/core/engine/graph/nv108.c
Merge tag 'staging-3.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh...
[karo-tx-linux.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
27 /*******************************************************************************
28  * Graphics object classes
29  ******************************************************************************/
30
31 static struct nouveau_oclass
32 nv108_graph_sclass[] = {
33         { 0x902d, &nouveau_object_ofuncs },
34         { 0xa140, &nouveau_object_ofuncs },
35         { 0xa197, &nouveau_object_ofuncs },
36         { 0xa1c0, &nouveau_object_ofuncs },
37         {}
38 };
39
40 /*******************************************************************************
41  * PGRAPH engine/subdev functions
42  ******************************************************************************/
43
44 static struct nvc0_graph_init
45 nv108_graph_init_regs[] = {
46         { 0x400080,   1, 0x04, 0x003083c2 },
47         { 0x400088,   1, 0x04, 0x0001bfe7 },
48         { 0x40008c,   1, 0x04, 0x00000000 },
49         { 0x400090,   1, 0x04, 0x00000030 },
50         { 0x40013c,   1, 0x04, 0x003901f7 },
51         { 0x400140,   1, 0x04, 0x00000100 },
52         { 0x400144,   1, 0x04, 0x00000000 },
53         { 0x400148,   1, 0x04, 0x00000110 },
54         { 0x400138,   1, 0x04, 0x00000000 },
55         { 0x400130,   2, 0x04, 0x00000000 },
56         { 0x400124,   1, 0x04, 0x00000002 },
57         {}
58 };
59
60 struct nvc0_graph_init
61 nv108_graph_init_unk58xx[] = {
62         { 0x405844,   1, 0x04, 0x00ffffff },
63         { 0x405850,   1, 0x04, 0x00000000 },
64         { 0x405900,   1, 0x04, 0x00000000 },
65         { 0x405908,   1, 0x04, 0x00000000 },
66         { 0x405928,   1, 0x04, 0x00000000 },
67         { 0x40592c,   1, 0x04, 0x00000000 },
68         {}
69 };
70
71 static struct nvc0_graph_init
72 nv108_graph_init_gpc[] = {
73         { 0x418408,   1, 0x04, 0x00000000 },
74         { 0x4184a0,   3, 0x04, 0x00000000 },
75         { 0x418604,   1, 0x04, 0x00000000 },
76         { 0x418680,   1, 0x04, 0x00000000 },
77         { 0x418714,   1, 0x04, 0x00000000 },
78         { 0x418384,   2, 0x04, 0x00000000 },
79         { 0x418814,   3, 0x04, 0x00000000 },
80         { 0x418b04,   1, 0x04, 0x00000000 },
81         { 0x4188c8,   2, 0x04, 0x00000000 },
82         { 0x4188d0,   1, 0x04, 0x00010000 },
83         { 0x4188d4,   1, 0x04, 0x00000201 },
84         { 0x418910,   1, 0x04, 0x00010001 },
85         { 0x418914,   1, 0x04, 0x00000301 },
86         { 0x418918,   1, 0x04, 0x00800000 },
87         { 0x418980,   1, 0x04, 0x77777770 },
88         { 0x418984,   3, 0x04, 0x77777777 },
89         { 0x418c04,   1, 0x04, 0x00000000 },
90         { 0x418c64,   2, 0x04, 0x00000000 },
91         { 0x418c88,   1, 0x04, 0x00000000 },
92         { 0x418cb4,   2, 0x04, 0x00000000 },
93         { 0x418d00,   1, 0x04, 0x00000000 },
94         { 0x418d28,   2, 0x04, 0x00000000 },
95         { 0x418f00,   1, 0x04, 0x00000400 },
96         { 0x418f08,   1, 0x04, 0x00000000 },
97         { 0x418f20,   2, 0x04, 0x00000000 },
98         { 0x418e00,   1, 0x04, 0x00000000 },
99         { 0x418e08,   1, 0x04, 0x00000000 },
100         { 0x418e1c,   2, 0x04, 0x00000000 },
101         { 0x41900c,   1, 0x04, 0x00000000 },
102         { 0x419018,   1, 0x04, 0x00000000 },
103         {}
104 };
105
106 static struct nvc0_graph_init
107 nv108_graph_init_tpc[] = {
108         { 0x419d0c,   1, 0x04, 0x00000000 },
109         { 0x419d10,   1, 0x04, 0x00000014 },
110         { 0x419ab0,   1, 0x04, 0x00000000 },
111         { 0x419ac8,   1, 0x04, 0x00000000 },
112         { 0x419ab8,   1, 0x04, 0x000000e7 },
113         { 0x419abc,   2, 0x04, 0x00000000 },
114         { 0x419ab4,   1, 0x04, 0x00000000 },
115         { 0x419aa8,   2, 0x04, 0x00000000 },
116         { 0x41980c,   1, 0x04, 0x00000010 },
117         { 0x419844,   1, 0x04, 0x00000000 },
118         { 0x419850,   1, 0x04, 0x00000004 },
119         { 0x419854,   2, 0x04, 0x00000000 },
120         { 0x419c98,   1, 0x04, 0x00000000 },
121         { 0x419ca8,   1, 0x04, 0x00000000 },
122         { 0x419cb0,   1, 0x04, 0x01000000 },
123         { 0x419cb4,   1, 0x04, 0x00000000 },
124         { 0x419cb8,   1, 0x04, 0x00b08bea },
125         { 0x419c84,   1, 0x04, 0x00010384 },
126         { 0x419cbc,   1, 0x04, 0x281b3646 },
127         { 0x419cc0,   2, 0x04, 0x00000000 },
128         { 0x419c80,   1, 0x04, 0x00000230 },
129         { 0x419ccc,   2, 0x04, 0x00000000 },
130         { 0x419c0c,   1, 0x04, 0x00000000 },
131         { 0x419e00,   1, 0x04, 0x00000080 },
132         { 0x419ea0,   1, 0x04, 0x00000000 },
133         { 0x419ee4,   1, 0x04, 0x00000000 },
134         { 0x419ea4,   1, 0x04, 0x00000100 },
135         { 0x419ea8,   1, 0x04, 0x00000000 },
136         { 0x419eb4,   1, 0x04, 0x00000000 },
137         { 0x419ebc,   2, 0x04, 0x00000000 },
138         { 0x419edc,   1, 0x04, 0x00000000 },
139         { 0x419f00,   1, 0x04, 0x00000000 },
140         { 0x419ed0,   1, 0x04, 0x00003234 },
141         { 0x419f74,   1, 0x04, 0x00015555 },
142         { 0x419f80,   4, 0x04, 0x00000000 },
143         {}
144 };
145
146 static int
147 nv108_graph_fini(struct nouveau_object *object, bool suspend)
148 {
149         struct nvc0_graph_priv *priv = (void *)object;
150         static const struct {
151                 u32 addr;
152                 u32 data;
153         } magic[] = {
154                 { 0x020520, 0xfffffffc },
155                 { 0x020524, 0xfffffffe },
156                 { 0x020524, 0xfffffffc },
157                 { 0x020524, 0xfffffff8 },
158                 { 0x020524, 0xffffffe0 },
159                 { 0x020530, 0xfffffffe },
160                 { 0x02052c, 0xfffffffa },
161                 { 0x02052c, 0xfffffff0 },
162                 { 0x02052c, 0xffffffc0 },
163                 { 0x02052c, 0xffffff00 },
164                 { 0x02052c, 0xfffffc00 },
165                 { 0x02052c, 0xfffcfc00 },
166                 { 0x02052c, 0xfff0fc00 },
167                 { 0x02052c, 0xff80fc00 },
168                 { 0x020528, 0xfffffffe },
169                 { 0x020528, 0xfffffffc },
170         };
171         int i;
172
173         nv_mask(priv, 0x000200, 0x08001000, 0x00000000);
174         nv_mask(priv, 0x0206b4, 0x00000000, 0x00000000);
175         for (i = 0; i < ARRAY_SIZE(magic); i++) {
176                 nv_wr32(priv, magic[i].addr, magic[i].data);
177                 nv_wait(priv, magic[i].addr, 0x80000000, 0x00000000);
178         }
179
180         return nouveau_graph_fini(&priv->base, suspend);
181 }
182
183 static struct nvc0_graph_init *
184 nv108_graph_init_mmio[] = {
185         nv108_graph_init_regs,
186         nvf0_graph_init_unk40xx,
187         nvc0_graph_init_unk44xx,
188         nvc0_graph_init_unk78xx,
189         nvc0_graph_init_unk60xx,
190         nvd9_graph_init_unk64xx,
191         nv108_graph_init_unk58xx,
192         nvc0_graph_init_unk80xx,
193         nvf0_graph_init_unk70xx,
194         nvf0_graph_init_unk5bxx,
195         nv108_graph_init_gpc,
196         nv108_graph_init_tpc,
197         nve4_graph_init_unk,
198         nve4_graph_init_unk88xx,
199         NULL
200 };
201
202 #include "fuc/hubnv108.fuc5.h"
203
204 static struct nvc0_graph_ucode
205 nv108_graph_fecs_ucode = {
206         .code.data = nv108_grhub_code,
207         .code.size = sizeof(nv108_grhub_code),
208         .data.data = nv108_grhub_data,
209         .data.size = sizeof(nv108_grhub_data),
210 };
211
212 #include "fuc/gpcnv108.fuc5.h"
213
214 static struct nvc0_graph_ucode
215 nv108_graph_gpccs_ucode = {
216         .code.data = nv108_grgpc_code,
217         .code.size = sizeof(nv108_grgpc_code),
218         .data.data = nv108_grgpc_data,
219         .data.size = sizeof(nv108_grgpc_data),
220 };
221
222 struct nouveau_oclass *
223 nv108_graph_oclass = &(struct nvc0_graph_oclass) {
224         .base.handle = NV_ENGINE(GR, 0x08),
225         .base.ofuncs = &(struct nouveau_ofuncs) {
226                 .ctor = nvc0_graph_ctor,
227                 .dtor = nvc0_graph_dtor,
228                 .init = nve4_graph_init,
229                 .fini = nv108_graph_fini,
230         },
231         .cclass = &nv108_grctx_oclass,
232         .sclass =  nv108_graph_sclass,
233         .mmio = nv108_graph_init_mmio,
234         .fecs.ucode = &nv108_graph_fecs_ucode,
235         .gpccs.ucode = &nv108_graph_gpccs_ucode,
236 }.base;