2 * Copyright 2012 Red Hat Inc.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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.
26 #include <core/client.h>
27 #include <subdev/timer.h>
29 #include <nvif/class.h>
30 #include <nvif/unpack.h>
32 const struct nv50_disp_mthd_list
33 nv50_disp_core_mthd_base
= {
45 static const struct nv50_disp_mthd_list
46 nv50_disp_core_mthd_dac
= {
57 const struct nv50_disp_mthd_list
58 nv50_disp_core_mthd_sor
= {
67 const struct nv50_disp_mthd_list
68 nv50_disp_core_mthd_pior
= {
77 static const struct nv50_disp_mthd_list
78 nv50_disp_core_mthd_head
= {
100 { 0x084c, 0x610ab0 },
101 { 0x0860, 0x610a84 },
102 { 0x0864, 0x610a90 },
103 { 0x0868, 0x610b18 },
104 { 0x086c, 0x610b20 },
105 { 0x0870, 0x610ac8 },
106 { 0x0874, 0x610a38 },
107 { 0x0880, 0x610a58 },
108 { 0x0884, 0x610a9c },
109 { 0x08a0, 0x610a70 },
110 { 0x08a4, 0x610a50 },
111 { 0x08a8, 0x610ae0 },
112 { 0x08c0, 0x610b28 },
113 { 0x08c4, 0x610b30 },
114 { 0x08c8, 0x610b40 },
115 { 0x08d4, 0x610b38 },
116 { 0x08d8, 0x610b48 },
117 { 0x08dc, 0x610b50 },
118 { 0x0900, 0x610a18 },
119 { 0x0904, 0x610ab8 },
124 const struct nv50_disp_mthd_chan
125 nv50_disp_core_mthd_chan
= {
129 { "Global", 1, &nv50_disp_core_mthd_base
},
130 { "DAC", 3, &nv50_disp_core_mthd_dac
},
131 { "SOR", 2, &nv50_disp_core_mthd_sor
},
132 { "PIOR", 3, &nv50_disp_core_mthd_pior
},
133 { "HEAD", 2, &nv50_disp_core_mthd_head
},
139 nv50_disp_core_fini(struct nvkm_object
*object
, bool suspend
)
141 struct nv50_disp
*disp
= (void *)object
->engine
;
142 struct nv50_disp_dmac
*mast
= (void *)object
;
143 struct nvkm_subdev
*subdev
= &disp
->base
.engine
.subdev
;
144 struct nvkm_device
*device
= subdev
->device
;
146 /* deactivate channel */
147 nvkm_mask(device
, 0x610200, 0x00000010, 0x00000000);
148 nvkm_mask(device
, 0x610200, 0x00000003, 0x00000000);
149 if (nvkm_msec(device
, 2000,
150 if (!(nvkm_rd32(device
, 0x610200) & 0x001e0000))
153 nvkm_error(subdev
, "core fini: %08x\n",
154 nvkm_rd32(device
, 0x610200));
159 /* disable error reporting and completion notifications */
160 nvkm_mask(device
, 0x610028, 0x00010001, 0x00000000);
162 return nv50_disp_chan_fini(&mast
->base
, suspend
);
166 nv50_disp_core_init(struct nvkm_object
*object
)
168 struct nv50_disp
*disp
= (void *)object
->engine
;
169 struct nv50_disp_dmac
*mast
= (void *)object
;
170 struct nvkm_subdev
*subdev
= &disp
->base
.engine
.subdev
;
171 struct nvkm_device
*device
= subdev
->device
;
174 ret
= nv50_disp_chan_init(&mast
->base
);
178 /* enable error reporting */
179 nvkm_mask(device
, 0x610028, 0x00010000, 0x00010000);
181 /* attempt to unstick channel from some unknown state */
182 if ((nvkm_rd32(device
, 0x610200) & 0x009f0000) == 0x00020000)
183 nvkm_mask(device
, 0x610200, 0x00800000, 0x00800000);
184 if ((nvkm_rd32(device
, 0x610200) & 0x003f0000) == 0x00030000)
185 nvkm_mask(device
, 0x610200, 0x00600000, 0x00600000);
187 /* initialise channel for dma command submission */
188 nvkm_wr32(device
, 0x610204, mast
->push
);
189 nvkm_wr32(device
, 0x610208, 0x00010000);
190 nvkm_wr32(device
, 0x61020c, 0x00000000);
191 nvkm_mask(device
, 0x610200, 0x00000010, 0x00000010);
192 nvkm_wr32(device
, 0x640000, 0x00000000);
193 nvkm_wr32(device
, 0x610200, 0x01000013);
195 /* wait for it to go inactive */
196 if (nvkm_msec(device
, 2000,
197 if (!(nvkm_rd32(device
, 0x610200) & 0x80000000))
200 nvkm_error(subdev
, "core init: %08x\n",
201 nvkm_rd32(device
, 0x610200));
209 nv50_disp_core_ctor(struct nvkm_object
*parent
,
210 struct nvkm_object
*engine
,
211 struct nvkm_oclass
*oclass
, void *data
, u32 size
,
212 struct nvkm_object
**pobject
)
215 struct nv50_disp_core_channel_dma_v0 v0
;
217 struct nv50_disp_dmac
*mast
;
220 nvif_ioctl(parent
, "create disp core channel dma size %d\n", size
);
221 if (nvif_unpack(args
->v0
, 0, 0, false)) {
222 nvif_ioctl(parent
, "create disp core channel dma vers %d "
224 args
->v0
.version
, args
->v0
.pushbuf
);
228 ret
= nv50_disp_dmac_create_(parent
, engine
, oclass
, args
->v0
.pushbuf
,
229 0, sizeof(*mast
), (void **)&mast
);
230 *pobject
= nv_object(mast
);
237 struct nv50_disp_chan_impl
238 nv50_disp_core_ofuncs
= {
239 .base
.ctor
= nv50_disp_core_ctor
,
240 .base
.dtor
= nv50_disp_dmac_dtor
,
241 .base
.init
= nv50_disp_core_init
,
242 .base
.fini
= nv50_disp_core_fini
,
243 .base
.map
= nv50_disp_chan_map
,
244 .base
.ntfy
= nv50_disp_chan_ntfy
,
245 .base
.rd32
= nv50_disp_chan_rd32
,
246 .base
.wr32
= nv50_disp_chan_wr32
,
248 .attach
= nv50_disp_dmac_object_attach
,
249 .detach
= nv50_disp_dmac_object_detach
,