1b7019ac5SIlia Mirkin // SPDX-License-Identifier: MIT
2b8bf04e1SBen Skeggs #include "nv20.h"
3b8bf04e1SBen Skeggs #include "regs.h"
4b8bf04e1SBen Skeggs
513de7f46SBen Skeggs #include <core/gpuobj.h>
6e3c71eb2SBen Skeggs #include <engine/fifo.h>
79a65a38cSBen Skeggs #include <engine/fifo/chan.h>
8e3c71eb2SBen Skeggs
9b8bf04e1SBen Skeggs /*******************************************************************************
10b8bf04e1SBen Skeggs * PGRAPH context
11b8bf04e1SBen Skeggs ******************************************************************************/
12b8bf04e1SBen Skeggs
1327f3d6cfSBen Skeggs static const struct nvkm_object_func
1427f3d6cfSBen Skeggs nv2a_gr_chan = {
1527f3d6cfSBen Skeggs .dtor = nv20_gr_chan_dtor,
1627f3d6cfSBen Skeggs .init = nv20_gr_chan_init,
1727f3d6cfSBen Skeggs .fini = nv20_gr_chan_fini,
1827f3d6cfSBen Skeggs };
1927f3d6cfSBen Skeggs
20b8bf04e1SBen Skeggs static int
nv2a_gr_chan_new(struct nvkm_gr * base,struct nvkm_chan * fifoch,const struct nvkm_oclass * oclass,struct nvkm_object ** pobject)21*c546656fSBen Skeggs nv2a_gr_chan_new(struct nvkm_gr *base, struct nvkm_chan *fifoch,
2227f3d6cfSBen Skeggs const struct nvkm_oclass *oclass, struct nvkm_object **pobject)
23b8bf04e1SBen Skeggs {
2427f3d6cfSBen Skeggs struct nv20_gr *gr = nv20_gr(base);
25b8bf04e1SBen Skeggs struct nv20_gr_chan *chan;
26b8bf04e1SBen Skeggs int ret, i;
27b8bf04e1SBen Skeggs
2827f3d6cfSBen Skeggs if (!(chan = kzalloc(sizeof(*chan), GFP_KERNEL)))
2927f3d6cfSBen Skeggs return -ENOMEM;
3027f3d6cfSBen Skeggs nvkm_object_ctor(&nv2a_gr_chan, oclass, &chan->object);
3127f3d6cfSBen Skeggs chan->gr = gr;
32c358f538SBen Skeggs chan->chid = fifoch->id;
3327f3d6cfSBen Skeggs *pobject = &chan->object;
3427f3d6cfSBen Skeggs
3527f3d6cfSBen Skeggs ret = nvkm_memory_new(gr->base.engine.subdev.device,
3627f3d6cfSBen Skeggs NVKM_MEM_TARGET_INST, 0x36b0, 16, true,
3727f3d6cfSBen Skeggs &chan->inst);
38b8bf04e1SBen Skeggs if (ret)
39b8bf04e1SBen Skeggs return ret;
40b8bf04e1SBen Skeggs
4127f3d6cfSBen Skeggs nvkm_kmap(chan->inst);
4227f3d6cfSBen Skeggs nvkm_wo32(chan->inst, 0x0000, 0x00000001 | (chan->chid << 24));
4327f3d6cfSBen Skeggs nvkm_wo32(chan->inst, 0x033c, 0xffff0000);
4427f3d6cfSBen Skeggs nvkm_wo32(chan->inst, 0x03a0, 0x0fff0000);
4527f3d6cfSBen Skeggs nvkm_wo32(chan->inst, 0x03a4, 0x0fff0000);
4627f3d6cfSBen Skeggs nvkm_wo32(chan->inst, 0x047c, 0x00000101);
4727f3d6cfSBen Skeggs nvkm_wo32(chan->inst, 0x0490, 0x00000111);
4827f3d6cfSBen Skeggs nvkm_wo32(chan->inst, 0x04a8, 0x44400000);
49b8bf04e1SBen Skeggs for (i = 0x04d4; i <= 0x04e0; i += 4)
5027f3d6cfSBen Skeggs nvkm_wo32(chan->inst, i, 0x00030303);
51b8bf04e1SBen Skeggs for (i = 0x04f4; i <= 0x0500; i += 4)
5227f3d6cfSBen Skeggs nvkm_wo32(chan->inst, i, 0x00080000);
53b8bf04e1SBen Skeggs for (i = 0x050c; i <= 0x0518; i += 4)
5427f3d6cfSBen Skeggs nvkm_wo32(chan->inst, i, 0x01012000);
55b8bf04e1SBen Skeggs for (i = 0x051c; i <= 0x0528; i += 4)
5627f3d6cfSBen Skeggs nvkm_wo32(chan->inst, i, 0x000105b8);
57b8bf04e1SBen Skeggs for (i = 0x052c; i <= 0x0538; i += 4)
5827f3d6cfSBen Skeggs nvkm_wo32(chan->inst, i, 0x00080008);
59b8bf04e1SBen Skeggs for (i = 0x055c; i <= 0x0598; i += 4)
6027f3d6cfSBen Skeggs nvkm_wo32(chan->inst, i, 0x07ff0000);
6127f3d6cfSBen Skeggs nvkm_wo32(chan->inst, 0x05a4, 0x4b7fffff);
6227f3d6cfSBen Skeggs nvkm_wo32(chan->inst, 0x05fc, 0x00000001);
6327f3d6cfSBen Skeggs nvkm_wo32(chan->inst, 0x0604, 0x00004000);
6427f3d6cfSBen Skeggs nvkm_wo32(chan->inst, 0x0610, 0x00000001);
6527f3d6cfSBen Skeggs nvkm_wo32(chan->inst, 0x0618, 0x00040000);
6627f3d6cfSBen Skeggs nvkm_wo32(chan->inst, 0x061c, 0x00010000);
67b8bf04e1SBen Skeggs for (i = 0x1a9c; i <= 0x22fc; i += 16) { /*XXX: check!! */
6827f3d6cfSBen Skeggs nvkm_wo32(chan->inst, (i + 0), 0x10700ff9);
6927f3d6cfSBen Skeggs nvkm_wo32(chan->inst, (i + 4), 0x0436086c);
7027f3d6cfSBen Skeggs nvkm_wo32(chan->inst, (i + 8), 0x000c001b);
71b8bf04e1SBen Skeggs }
7227f3d6cfSBen Skeggs nvkm_wo32(chan->inst, 0x269c, 0x3f800000);
7327f3d6cfSBen Skeggs nvkm_wo32(chan->inst, 0x26b0, 0x3f800000);
7427f3d6cfSBen Skeggs nvkm_wo32(chan->inst, 0x26dc, 0x40000000);
7527f3d6cfSBen Skeggs nvkm_wo32(chan->inst, 0x26e0, 0x3f800000);
7627f3d6cfSBen Skeggs nvkm_wo32(chan->inst, 0x26e4, 0x3f000000);
7727f3d6cfSBen Skeggs nvkm_wo32(chan->inst, 0x26ec, 0x40000000);
7827f3d6cfSBen Skeggs nvkm_wo32(chan->inst, 0x26f0, 0x3f800000);
7927f3d6cfSBen Skeggs nvkm_wo32(chan->inst, 0x26f8, 0xbf800000);
8027f3d6cfSBen Skeggs nvkm_wo32(chan->inst, 0x2700, 0xbf800000);
8127f3d6cfSBen Skeggs nvkm_wo32(chan->inst, 0x3024, 0x000fe000);
8227f3d6cfSBen Skeggs nvkm_wo32(chan->inst, 0x30a0, 0x000003f8);
8327f3d6cfSBen Skeggs nvkm_wo32(chan->inst, 0x33fc, 0x002fe000);
84b8bf04e1SBen Skeggs for (i = 0x341c; i <= 0x3438; i += 4)
8527f3d6cfSBen Skeggs nvkm_wo32(chan->inst, i, 0x001c527c);
8627f3d6cfSBen Skeggs nvkm_done(chan->inst);
87b8bf04e1SBen Skeggs return 0;
88b8bf04e1SBen Skeggs }
89b8bf04e1SBen Skeggs
90b8bf04e1SBen Skeggs /*******************************************************************************
91b8bf04e1SBen Skeggs * PGRAPH engine/subdev functions
92b8bf04e1SBen Skeggs ******************************************************************************/
93b8bf04e1SBen Skeggs
9427f3d6cfSBen Skeggs static const struct nvkm_gr_func
9527f3d6cfSBen Skeggs nv2a_gr = {
96c85ee6caSBen Skeggs .dtor = nv20_gr_dtor,
97c85ee6caSBen Skeggs .oneinit = nv20_gr_oneinit,
98c85ee6caSBen Skeggs .init = nv20_gr_init,
99c85ee6caSBen Skeggs .intr = nv20_gr_intr,
100c85ee6caSBen Skeggs .tile = nv20_gr_tile,
10127f3d6cfSBen Skeggs .chan_new = nv2a_gr_chan_new,
10227f3d6cfSBen Skeggs .sclass = {
10327f3d6cfSBen Skeggs { -1, -1, 0x0012, &nv04_gr_object }, /* beta1 */
10427f3d6cfSBen Skeggs { -1, -1, 0x0019, &nv04_gr_object }, /* clip */
10527f3d6cfSBen Skeggs { -1, -1, 0x0030, &nv04_gr_object }, /* null */
10627f3d6cfSBen Skeggs { -1, -1, 0x0039, &nv04_gr_object }, /* m2mf */
10727f3d6cfSBen Skeggs { -1, -1, 0x0043, &nv04_gr_object }, /* rop */
10827f3d6cfSBen Skeggs { -1, -1, 0x0044, &nv04_gr_object }, /* patt */
10927f3d6cfSBen Skeggs { -1, -1, 0x004a, &nv04_gr_object }, /* gdi */
11027f3d6cfSBen Skeggs { -1, -1, 0x0062, &nv04_gr_object }, /* surf2d */
11127f3d6cfSBen Skeggs { -1, -1, 0x0072, &nv04_gr_object }, /* beta4 */
11227f3d6cfSBen Skeggs { -1, -1, 0x0089, &nv04_gr_object }, /* sifm */
11327f3d6cfSBen Skeggs { -1, -1, 0x008a, &nv04_gr_object }, /* ifc */
11427f3d6cfSBen Skeggs { -1, -1, 0x0096, &nv04_gr_object }, /* celcius */
11527f3d6cfSBen Skeggs { -1, -1, 0x009e, &nv04_gr_object }, /* swzsurf */
11627f3d6cfSBen Skeggs { -1, -1, 0x009f, &nv04_gr_object }, /* imageblit */
11727f3d6cfSBen Skeggs { -1, -1, 0x0597, &nv04_gr_object }, /* kelvin */
11827f3d6cfSBen Skeggs {}
11927f3d6cfSBen Skeggs }
12027f3d6cfSBen Skeggs };
12127f3d6cfSBen Skeggs
122c85ee6caSBen Skeggs int
nv2a_gr_new(struct nvkm_device * device,enum nvkm_subdev_type type,int inst,struct nvkm_gr ** pgr)123864d37c3SBen Skeggs nv2a_gr_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, struct nvkm_gr **pgr)
124b8bf04e1SBen Skeggs {
125864d37c3SBen Skeggs return nv20_gr_new_(&nv2a_gr, device, type, inst, pgr);
126b8bf04e1SBen Skeggs }
127