]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/gpu/drm/nouveau/core/engine/graph/nvc0.h
a74c24c1ab0930c20521e52d6bc11c8719c1e74c
[karo-tx-linux.git] / drivers / gpu / drm / nouveau / core / engine / graph / nvc0.h
1 /*
2  * Copyright 2010 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
23  */
24
25 #ifndef __NVC0_GRAPH_H__
26 #define __NVC0_GRAPH_H__
27
28 #include <core/client.h>
29 #include <core/handle.h>
30 #include <core/gpuobj.h>
31 #include <core/option.h>
32
33 #include <subdev/fb.h>
34 #include <subdev/vm.h>
35 #include <subdev/bar.h>
36 #include <subdev/timer.h>
37
38 #include <engine/fifo.h>
39 #include <engine/graph.h>
40
41 #define GPC_MAX 32
42 #define TPC_MAX (GPC_MAX * 8)
43
44 #define ROP_BCAST(r)      (0x408800 + (r))
45 #define ROP_UNIT(u, r)    (0x410000 + (u) * 0x400 + (r))
46 #define GPC_BCAST(r)      (0x418000 + (r))
47 #define GPC_UNIT(t, r)    (0x500000 + (t) * 0x8000 + (r))
48 #define TPC_UNIT(t, m, r) (0x504000 + (t) * 0x8000 + (m) * 0x800 + (r))
49
50 struct nvc0_graph_data {
51         u32 size;
52         u32 align;
53         u32 access;
54 };
55
56 struct nvc0_graph_mmio {
57         u32 addr;
58         u32 data;
59         u32 shift;
60         u32 buffer;
61 };
62
63 struct nvc0_graph_fuc {
64         u32 *data;
65         u32  size;
66 };
67
68 struct nvc0_graph_priv {
69         struct nouveau_graph base;
70
71         struct nvc0_graph_fuc fuc409c;
72         struct nvc0_graph_fuc fuc409d;
73         struct nvc0_graph_fuc fuc41ac;
74         struct nvc0_graph_fuc fuc41ad;
75         bool firmware;
76
77         u8 rop_nr;
78         u8 gpc_nr;
79         u8 tpc_nr[GPC_MAX];
80         u8 tpc_total;
81
82         struct nouveau_gpuobj *unk4188b4;
83         struct nouveau_gpuobj *unk4188b8;
84
85         struct nvc0_graph_data mmio_data[4];
86         struct nvc0_graph_mmio mmio_list[4096/8];
87         u32  size;
88         u32 *data;
89
90         u8 magic_not_rop_nr;
91 };
92
93 struct nvc0_graph_chan {
94         struct nouveau_graph_chan base;
95
96         struct nouveau_gpuobj *mmio;
97         struct nouveau_vma mmio_vma;
98         int mmio_nr;
99         struct {
100                 struct nouveau_gpuobj *mem;
101                 struct nouveau_vma vma;
102         } data[4];
103 };
104
105 int  nvc0_graph_context_ctor(struct nouveau_object *, struct nouveau_object *,
106                              struct nouveau_oclass *, void *, u32,
107                              struct nouveau_object **);
108 void nvc0_graph_context_dtor(struct nouveau_object *);
109
110 void nvc0_graph_ctxctl_debug(struct nvc0_graph_priv *);
111
112 u64  nvc0_graph_units(struct nouveau_graph *);
113 int  nvc0_graph_ctor(struct nouveau_object *, struct nouveau_object *,
114                      struct nouveau_oclass *, void *data, u32 size,
115                      struct nouveau_object **);
116 void nvc0_graph_dtor(struct nouveau_object *);
117 int  nvc0_graph_init(struct nouveau_object *);
118 int  nve4_graph_init(struct nouveau_object *);
119
120 extern struct nouveau_oclass nvc0_graph_sclass[];
121
122 extern struct nouveau_oclass nvc8_graph_sclass[];
123
124 struct nvc0_graph_init {
125         u32 addr;
126         u8  count;
127         u8  pitch;
128         u32 data;
129 };
130
131 struct nvc0_graph_pack {
132         const struct nvc0_graph_init *init;
133         u32 type;
134 };
135
136 #define pack_for_each_init(init, pack, head)                                   \
137         for (pack = head; pack && pack->init; pack++)                          \
138                   for (init = pack->init; init && init->count; init++)
139
140 struct nvc0_graph_ucode {
141         struct nvc0_graph_fuc code;
142         struct nvc0_graph_fuc data;
143 };
144
145 extern struct nvc0_graph_ucode nvc0_graph_fecs_ucode;
146 extern struct nvc0_graph_ucode nvc0_graph_gpccs_ucode;
147
148 struct nvc0_graph_oclass {
149         struct nouveau_oclass base;
150         struct nouveau_oclass **cclass;
151         struct nouveau_oclass *sclass;
152         const struct nvc0_graph_pack *mmio;
153         struct {
154                 struct nvc0_graph_ucode *ucode;
155         } fecs;
156         struct {
157                 struct nvc0_graph_ucode *ucode;
158         } gpccs;
159 };
160
161 void nvc0_graph_mmio(struct nvc0_graph_priv *, const struct nvc0_graph_pack *);
162 void nvc0_graph_icmd(struct nvc0_graph_priv *, const struct nvc0_graph_pack *);
163 void nvc0_graph_mthd(struct nvc0_graph_priv *, const struct nvc0_graph_pack *);
164 int  nvc0_graph_init_ctxctl(struct nvc0_graph_priv *);
165
166 /* register init value lists */
167
168 extern const struct nvc0_graph_init nvc0_graph_init_main_0[];
169 extern const struct nvc0_graph_init nvc0_graph_init_fe_0[];
170 extern const struct nvc0_graph_init nvc0_graph_init_pri_0[];
171 extern const struct nvc0_graph_init nvc0_graph_init_rstr2d_0[];
172 extern const struct nvc0_graph_init nvc0_graph_init_pd_0[];
173 extern const struct nvc0_graph_init nvc0_graph_init_ds_0[];
174 extern const struct nvc0_graph_init nvc0_graph_init_scc_0[];
175 extern const struct nvc0_graph_init nvc0_graph_init_gpc_0[];
176 extern const struct nvc0_graph_init nvc0_graph_init_be_0[];
177 extern const struct nvc0_graph_init nvc0_graph_init_fe_1[];
178 extern const struct nvc0_graph_init nvc0_graph_init_tpc_1[];
179
180 extern const struct nvc0_graph_init nvc4_graph_init_ds_0[];
181
182 extern const struct nvc0_graph_init nvd9_graph_init_pd_0[];
183 extern const struct nvc0_graph_init nvd9_graph_init_ds_0[];
184 extern const struct nvc0_graph_init nvd9_graph_init_gpc_0[];
185 extern const struct nvc0_graph_init nvd9_graph_init_fe_1[];
186
187 extern const struct nvc0_graph_init nvd7_graph_init_ppc_0[];
188
189 extern const struct nvc0_graph_init nve4_graph_init_main_0[];
190 extern const struct nvc0_graph_init nve4_graph_init_be_0[];
191
192 extern const struct nvc0_graph_init nvf0_graph_init_fe_0[];
193 extern const struct nvc0_graph_init nvf0_graph_init_sked_0[];
194 extern const struct nvc0_graph_init nvf0_graph_init_cwd_0[];
195
196
197 #endif